pull/5756/head
Cagatay Civici 2024-05-08 21:19:44 +03:00
commit e8a5af2bdd
31 changed files with 82 additions and 99 deletions

View File

@ -261,12 +261,7 @@ const classes = {
inputChip: 'p-autocomplete-input-chip', inputChip: 'p-autocomplete-input-chip',
loader: 'p-autocomplete-loader', loader: 'p-autocomplete-loader',
dropdown: 'p-autocomplete-dropdown', dropdown: 'p-autocomplete-dropdown',
panel: ({ instance }) => [ panel: 'p-autocomplete-overlay p-component',
'p-autocomplete-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
list: 'p-autocomplete-list', list: 'p-autocomplete-list',
optionGroup: 'p-autocomplete-option-group', optionGroup: 'p-autocomplete-option-group',
option: ({ instance, option, i, getItemOptions }) => [ option: ({ instance, option, i, getItemOptions }) => [

View File

@ -219,10 +219,6 @@ const theme = ({ dt }) => `
animation: ripple 0.4s linear; animation: ripple 0.4s linear;
} }
.p-ripple-disabled .p-ink {
display: none;
}
@keyframes ripple { @keyframes ripple {
100% { 100% {
opacity: 0; opacity: 0;

View File

@ -1,5 +1,6 @@
import Base from 'primevue/base'; import Base from 'primevue/base';
import BaseStyle from 'primevue/base/style'; import BaseStyle from 'primevue/base/style';
import PrimeVueService from 'primevue/service';
import Theme, { ThemeService } from 'primevue/themes'; import Theme, { ThemeService } from 'primevue/themes';
import { ObjectUtils, UniqueComponentId } from 'primevue/utils'; import { ObjectUtils, UniqueComponentId } from 'primevue/utils';
import { mergeProps } from 'vue'; import { mergeProps } from 'vue';
@ -193,6 +194,18 @@ const BaseDirective = {
BaseDirective._hook(name, hook, el, binding, vnode, prevVnode); // handle hooks during directive uses (global and self-definition) BaseDirective._hook(name, hook, el, binding, vnode, prevVnode); // handle hooks during directive uses (global and self-definition)
}; };
const handleWatch = (el) => {
const watchers = el.$instance?.watch;
// for 'config'
watchers?.['config']?.call(el.$instance, el.$instance?.$config);
PrimeVueService.on('config:change', ({ newValue, oldValue }) => watchers?.['config']?.call(el.$instance, newValue, oldValue));
// for 'config.ripple'
watchers?.['config.ripple']?.call(el.$instance, el.$instance?.$config?.ripple);
PrimeVueService.on('config:ripple:change', ({ newValue, oldValue }) => watchers?.['config.ripple']?.call(el.$instance, newValue, oldValue));
};
return { return {
created: (el, binding, vnode, prevVnode) => { created: (el, binding, vnode, prevVnode) => {
handleHook('created', el, binding, vnode, prevVnode); handleHook('created', el, binding, vnode, prevVnode);
@ -201,6 +214,7 @@ const BaseDirective = {
el.$attrSelector = UniqueComponentId('pd'); el.$attrSelector = UniqueComponentId('pd');
BaseDirective._loadStyles(el, binding, vnode); BaseDirective._loadStyles(el, binding, vnode);
handleHook('beforeMount', el, binding, vnode, prevVnode); handleHook('beforeMount', el, binding, vnode, prevVnode);
handleWatch(el);
}, },
mounted: (el, binding, vnode, prevVnode) => { mounted: (el, binding, vnode, prevVnode) => {
BaseDirective._loadStyles(el, binding, vnode); BaseDirective._loadStyles(el, binding, vnode);

View File

@ -209,12 +209,7 @@ const classes = {
dropdown: 'p-cascadeselect-dropdown', dropdown: 'p-cascadeselect-dropdown',
loadingIcon: 'p-cascadeselect-loading-icon', loadingIcon: 'p-cascadeselect-loading-icon',
dropdownIcon: 'p-cascadeselect-dropdown-icon', dropdownIcon: 'p-cascadeselect-dropdown-icon',
overlay: ({ instance }) => [ overlay: 'p-cascadeselect-overlay p-component',
'p-cascadeselect-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
listContainer: 'p-cascadeselect-list-container', listContainer: 'p-cascadeselect-list-container',
list: 'p-cascadeselect-list', list: 'p-cascadeselect-list',
item: ({ instance, processedOption }) => [ item: ({ instance, processedOption }) => [

View File

@ -114,12 +114,11 @@ const theme = ({ dt }) => `
const classes = { const classes = {
root: 'p-colorpicker p-component', root: 'p-colorpicker p-component',
preview: ({ props }) => ['p-colorpicker-preview', { 'p-disabled': props.disabled }], preview: ({ props }) => ['p-colorpicker-preview', { 'p-disabled': props.disabled }],
panel: ({ instance, props }) => [ panel: ({ props }) => [
'p-colorpicker-panel', 'p-colorpicker-panel',
{ {
'p-colorpicker-panel-inline': props.inline, 'p-colorpicker-panel-inline': props.inline,
'p-disabled': props.disabled, 'p-disabled': props.disabled
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
colorSelector: 'p-colorpicker-color-selector', colorSelector: 'p-colorpicker-color-selector',

View File

@ -1,4 +1,5 @@
import { FilterMatchMode } from 'primevue/api'; import { FilterMatchMode } from 'primevue/api';
import PrimeVueService from 'primevue/service';
import Theme, { ThemeService } from 'primevue/themes'; import Theme, { ThemeService } from 'primevue/themes';
import { inject, reactive, ref, watch } from 'vue'; import { inject, reactive, ref, watch } from 'vue';
@ -175,14 +176,31 @@ export function setup(app, options) {
export function setupTheme(app, PrimeVue) { export function setupTheme(app, PrimeVue) {
const isChanged = ref(false); const isChanged = ref(false);
watch(
PrimeVue.config,
(newValue, oldValue) => {
PrimeVueService.emit('config:change', { newValue, oldValue });
},
{ immediate: true, deep: true }
);
watch(
() => PrimeVue.config.ripple,
(newValue, oldValue) => {
PrimeVueService.emit('config:ripple:change', { newValue, oldValue });
},
{ immediate: true, deep: true }
);
watch( watch(
PrimeVue.config.theme, PrimeVue.config.theme,
(newValue) => { (newValue, oldValue) => {
if (!isChanged.value) { if (!isChanged.value) {
Theme.setTheme(newValue); Theme.setTheme(newValue);
} }
isChanged.value = false; isChanged.value = false;
PrimeVueService.emit('config:theme:change', { newValue, oldValue });
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
); );

View File

@ -111,12 +111,7 @@ const theme = ({ dt }) => `
`; `;
const classes = { const classes = {
root: ({ instance }) => [ root: 'p-confirmpopup p-component',
'p-confirmpopup p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
content: 'p-confirmpopup-content', content: 'p-confirmpopup-content',
icon: 'p-confirmpopup-icon', icon: 'p-confirmpopup-icon',
message: 'p-confirmpopup-message', message: 'p-confirmpopup-message',

View File

@ -124,12 +124,7 @@ const theme = ({ dt }) => `
`; `;
const classes = { const classes = {
root: ({ instance }) => [ root: 'p-contextmenu p-component',
'p-contextmenu p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
rootList: 'p-contextmenu-root-list', rootList: 'p-contextmenu-root-list',
item: ({ instance, processedItem }) => [ item: ({ instance, processedItem }) => [
'p-contextmenu-item', 'p-contextmenu-item',

View File

@ -643,8 +643,7 @@ const classes = {
filterOverlay: ({ instance, props }) => [ filterOverlay: ({ instance, props }) => [
'p-datatable-filter-overlay p-component', 'p-datatable-filter-overlay p-component',
{ {
'p-datatable-filter-overlay-popover': props.display === 'menu', 'p-datatable-filter-overlay-popover': props.display === 'menu'
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
filterConstraintList: 'p-datatable-filter-constraint-list', filterConstraintList: 'p-datatable-filter-constraint-list',

View File

@ -359,8 +359,7 @@ const classes = {
{ {
'p-datepicker-panel-inline': props.inline, 'p-datepicker-panel-inline': props.inline,
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-datepicker-timeonly': props.timeOnly, 'p-datepicker-timeonly': props.timeOnly
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
calendarContainer: 'p-datepicker-calendar-container', calendarContainer: 'p-datepicker-calendar-container',

View File

@ -167,8 +167,7 @@ const classes = {
'p-dialog p-component', 'p-dialog p-component',
{ {
'p-dialog-rtl': props.rtl, 'p-dialog-rtl': props.rtl,
'p-dialog-maximized': props.maximizable && instance.maximized, 'p-dialog-maximized': props.maximizable && instance.maximized
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
header: 'p-dialog-header', header: 'p-dialog-header',

View File

@ -181,7 +181,6 @@ const classes = {
root: ({ instance }) => [ root: ({ instance }) => [
'p-drawer p-component', 'p-drawer p-component',
{ {
'p-ripple-disabled': instance.$primevue.config.ripple === false,
'p-drawer-full': instance.fullScreen 'p-drawer-full': instance.fullScreen
} }
], ],

View File

@ -402,12 +402,7 @@ const theme = ({ dt }) => `
`; `;
const classes = { const classes = {
mask: ({ instance }) => [ mask: 'p-galleria-mask p-component-overlay p-component-overlay-enter',
'p-galleria-mask p-component-overlay p-component-overlay-enter',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
root: ({ instance }) => { root: ({ instance }) => {
const thumbnailsPosClass = instance.$attrs.showThumbnails && instance.getPositionClass('p-galleria-thumbnails', instance.$attrs.thumbnailsPosition); const thumbnailsPosClass = instance.$attrs.showThumbnails && instance.getPositionClass('p-galleria-thumbnails', instance.$attrs.thumbnailsPosition);
const indicatorPosClass = instance.$attrs.showIndicators && instance.getPositionClass('p-galleria-indicators', instance.$attrs.indicatorsPosition); const indicatorPosClass = instance.$attrs.showIndicators && instance.getPositionClass('p-galleria-indicators', instance.$attrs.indicatorsPosition);

View File

@ -92,11 +92,10 @@ const theme = ({ dt }) => `
`; `;
const classes = { const classes = {
root: ({ instance, props }) => [ root: ({ props }) => [
'p-menu p-component', 'p-menu p-component',
{ {
'p-menu-overlay': props.popup, 'p-menu-overlay': props.popup
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
start: 'p-menu-start', start: 'p-menu-start',

View File

@ -224,12 +224,7 @@ const classes = {
dropdown: 'p-multiselect-dropdown', dropdown: 'p-multiselect-dropdown',
loadingIcon: 'p-multiselect-loading-icon', loadingIcon: 'p-multiselect-loading-icon',
dropdownIcon: 'p-multiselect-dropdown-icon', dropdownIcon: 'p-multiselect-dropdown-icon',
overlay: ({ instance }) => [ overlay: 'p-multiselect-overlay p-component',
'p-multiselect-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
header: 'p-multiselect-header', header: 'p-multiselect-header',
pcFilterContainer: 'p-multiselect-filter-container', pcFilterContainer: 'p-multiselect-filter-container',
pcFilter: 'p-multiselect-filter', pcFilter: 'p-multiselect-filter',

View File

@ -86,12 +86,7 @@ const classes = {
ptInput: 'p-password-input', ptInput: 'p-password-input',
maskIcon: 'p-password-toggle-mask-icon p-password-mask-icon', maskIcon: 'p-password-toggle-mask-icon p-password-mask-icon',
unmaskIcon: 'p-password-toggle-mask-icon p-password-unmask-icon', unmaskIcon: 'p-password-toggle-mask-icon p-password-unmask-icon',
overlay: ({ instance }) => [ overlay: 'p-password-overlay p-component',
'p-password-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
meter: 'p-password-meter', meter: 'p-password-meter',
meterLabel: ({ instance }) => `p-password-meter-label ${instance.meter ? 'p-password-meter-' + instance.meter.strength : ''}`, meterLabel: ({ instance }) => `p-password-meter-label ${instance.meter ? 'p-password-meter-' + instance.meter.strength : ''}`,
meterText: 'p-password-meter-text' meterText: 'p-password-meter-text'

View File

@ -81,12 +81,7 @@ const theme = ({ dt }) => `
`; `;
const classes = { const classes = {
root: ({ instance }) => [ root: 'p-popover p-component',
'p-popover p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
content: 'p-popover-content' content: 'p-popover-content'
}; };

View File

@ -2,14 +2,16 @@ import { DomHandler } from 'primevue/utils';
import BaseRipple from './BaseRipple'; import BaseRipple from './BaseRipple';
const Ripple = BaseRipple.extend('ripple', { const Ripple = BaseRipple.extend('ripple', {
mounted(el) { watch: {
const config = el?.$instance?.$config; 'config.ripple'(newValue) {
if (newValue) {
this.create(this.$host);
this.bindEvents(this.$host);
if (config && config.ripple) { this.$host.setAttribute('data-pd-ripple', true);
this.create(el); } else {
this.bindEvents(el); this.remove(this.$host);
}
el.setAttribute('data-pd-ripple', true);
} }
}, },
unmounted(el) { unmounted(el) {

View File

@ -219,12 +219,7 @@ const classes = {
dropdown: 'p-select-dropdown', dropdown: 'p-select-dropdown',
loadingicon: 'p-select-loading-icon', loadingicon: 'p-select-loading-icon',
dropdownIcon: 'p-select-dropdown-icon', dropdownIcon: 'p-select-dropdown-icon',
overlay: ({ instance }) => [ overlay: 'p-select-overlay p-component',
'p-select-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
header: 'p-select-header', header: 'p-select-header',
pcFilter: 'p-select-filter', pcFilter: 'p-select-filter',
listContainer: 'p-select-list-container', listContainer: 'p-select-list-container',

View File

@ -0,0 +1,3 @@
import { EventBus } from 'primevue/utils';
export default EventBus();

View File

@ -0,0 +1,5 @@
{
"main": "./primevueservice.cjs.js",
"module": "./primevueservice.esm.js",
"unpkg": "./primevueservice.min.js"
}

View File

@ -69,6 +69,8 @@ const theme = ({ dt }) => `
} }
.p-tab { .p-tab {
position: relative;
overflow: hidden;
cursor: pointer; cursor: pointer;
border-style: solid; border-style: solid;
border-width: 0 0 1px 0; border-width: 0 0 1px 0;

View File

@ -135,8 +135,7 @@ const classes = {
root: ({ instance, props }) => [ root: ({ instance, props }) => [
'p-tieredmenu p-component', 'p-tieredmenu p-component',
{ {
'p-tieredmenu-overlay': props.popup, 'p-tieredmenu-overlay': props.popup
'p-ripple-disabled': instance.$primevue.config.ripple === false
} }
], ],
start: 'p-tieredmenu-start', start: 'p-tieredmenu-start',

View File

@ -230,12 +230,7 @@ const inlineStyles = {
}; };
const classes = { const classes = {
root: ({ props, instance }) => [ root: ({ props }) => ['p-toast p-component p-toast-' + props.position],
'p-toast p-component p-toast-' + props.position,
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
message: ({ props }) => [ message: ({ props }) => [
'p-toast-message', 'p-toast-message',
{ {

View File

@ -154,12 +154,7 @@ const classes = {
pcChipLabel: 'p-treeselect-chip-label', pcChipLabel: 'p-treeselect-chip-label',
dropdown: 'p-treeselect-dropdown', dropdown: 'p-treeselect-dropdown',
dropdownIcon: 'p-treeselect-dropdown-icon', dropdownIcon: 'p-treeselect-dropdown-icon',
panel: ({ instance }) => [ panel: 'p-treeselect-overlay p-component',
'p-treeselect-overlay p-component',
{
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
treeContainer: 'p-treeselect-tree-container', treeContainer: 'p-treeselect-tree-container',
emptyMessage: 'p-treeselect-empty-message' emptyMessage: 'p-treeselect-empty-message'
}; };

View File

@ -203,7 +203,7 @@ export default {
EventBus.emit('theme-palette-change'); EventBus.emit('theme-palette-change');
}, },
onRippleChange(value) { onRippleChange(value) {
this.$appState.ripple = value; this.$primevue.config.ripple = value;
}, },
onPresetChange(value) { onPresetChange(value) {
const preset = value === 'Lara' ? Lara : Aura; const preset = value === 'Lara' ? Lara : Aura;
@ -214,7 +214,7 @@ export default {
}, },
computed: { computed: {
rippleActive() { rippleActive() {
return this.$appState.ripple; return this.$primevue.config.ripple;
} }
} }
}; };

View File

@ -73,8 +73,7 @@ export default {
return [ return [
'layout-wrapper', 'layout-wrapper',
{ {
'layout-news-active': this.$appState.newsActive, 'layout-news-active': this.$appState.newsActive
'p-ripple-disabled': this.$appState.ripple === false
} }
]; ];
} }

View File

@ -221,6 +221,7 @@ export default {
}, },
alias: { alias: {
'primevue/utils': path.resolve(__dirname, './components/lib/utils/Utils.js'), 'primevue/utils': path.resolve(__dirname, './components/lib/utils/Utils.js'),
'primevue/service': path.resolve(__dirname, './components/lib/service/PrimeVueService.js'),
'primevue/config': path.resolve(__dirname, './components/lib/config/PrimeVue.js'), 'primevue/config': path.resolve(__dirname, './components/lib/config/PrimeVue.js'),
'primevue/styled': path.resolve(__dirname, './components/lib/styled/PrimeVueStyled.js'), 'primevue/styled': path.resolve(__dirname, './components/lib/styled/PrimeVueStyled.js'),
'primevue/unstyled': path.resolve(__dirname, './components/lib/unstyled/PrimeVueUnstyled.js'), 'primevue/unstyled': path.resolve(__dirname, './components/lib/unstyled/PrimeVueUnstyled.js'),

View File

@ -48,7 +48,7 @@ export default {
}, },
computed: { computed: {
containerClass() { containerClass() {
return ['landing', { 'layout-news-active': this.$appState?.newsActive, 'p-ripple-disabled': this.$appState.ripple === false }]; return ['landing', { 'layout-news-active': this.$appState?.newsActive }];
} }
}, },
components: { components: {

View File

@ -11,7 +11,6 @@ const $appState = {
sourceType: 'options-api', sourceType: 'options-api',
newsActive: false, newsActive: false,
announcement: null, announcement: null,
ripple: false,
storageKey: 'primevue' storageKey: 'primevue'
}); });
} }

View File

@ -228,6 +228,7 @@ const CORE_THEME_DEPENDENCIES = {
const CORE_DEPENDENCIES = { const CORE_DEPENDENCIES = {
'primevue/utils': 'primevue.utils', 'primevue/utils': 'primevue.utils',
'primevue/api': 'primevue.api', 'primevue/api': 'primevue.api',
'primevue/service': 'primevue.service',
'primevue/config': 'primevue.config', 'primevue/config': 'primevue.config',
'primevue/styled': 'primevue.styled', 'primevue/styled': 'primevue.styled',
'primevue/unstyled': 'primevue.unstyled', 'primevue/unstyled': 'primevue.unstyled',
@ -514,6 +515,10 @@ function addDirectives() {
addEntry('animateonscroll', 'AnimateOnScroll.js', 'animateonscroll'); addEntry('animateonscroll', 'AnimateOnScroll.js', 'animateonscroll');
} }
function addService() {
addEntry('service', 'PrimeVueService.js', 'primevueservice');
}
function addConfig() { function addConfig() {
addEntry('config', 'PrimeVue.js', 'config'); addEntry('config', 'PrimeVue.js', 'config');
addEntry('styled', 'PrimeVueStyled.js', 'primevuestyled'); addEntry('styled', 'PrimeVueStyled.js', 'primevuestyled');
@ -605,6 +610,7 @@ addStyle();
addThemes(); addThemes();
addBase(); addBase();
addApi(); addApi();
addService();
addConfig(); addConfig();
addDirectives(); addDirectives();
addServices(); addServices();