import { ThemeService, Theme } from '@primeuix/styled'; import { FilterMatchMode } from '@primevue/core/api'; import BaseStyle from '@primevue/core/base/style'; import PrimeVueService from '@primevue/core/service'; import { inject, reactive, ref, watch } from 'vue'; import { mergeKeys } from '@primeuix/utils'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var defaultOptions = { ripple: false, inputStyle: null, inputVariant: null, locale: { startsWith: 'Starts with', contains: 'Contains', notContains: 'Not contains', endsWith: 'Ends with', equals: 'Equals', notEquals: 'Not equals', noFilter: 'No Filter', lt: 'Less than', lte: 'Less than or equal to', gt: 'Greater than', gte: 'Greater than or equal to', dateIs: 'Date is', dateIsNot: 'Date is not', dateBefore: 'Date is before', dateAfter: 'Date is after', clear: 'Clear', apply: 'Apply', matchAll: 'Match All', matchAny: 'Match Any', addRule: 'Add Rule', removeRule: 'Remove Rule', accept: 'Yes', reject: 'No', choose: 'Choose', upload: 'Upload', cancel: 'Cancel', completed: 'Completed', pending: 'Pending', fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], chooseYear: 'Choose Year', chooseMonth: 'Choose Month', chooseDate: 'Choose Date', prevDecade: 'Previous Decade', nextDecade: 'Next Decade', prevYear: 'Previous Year', nextYear: 'Next Year', prevMonth: 'Previous Month', nextMonth: 'Next Month', prevHour: 'Previous Hour', nextHour: 'Next Hour', prevMinute: 'Previous Minute', nextMinute: 'Next Minute', prevSecond: 'Previous Second', nextSecond: 'Next Second', am: 'am', pm: 'pm', today: 'Today', weekHeader: 'Wk', firstDayOfWeek: 0, showMonthAfterYear: false, dateFormat: 'mm/dd/yy', weak: 'Weak', medium: 'Medium', strong: 'Strong', passwordPrompt: 'Enter a password', emptyFilterMessage: 'No results found', searchMessage: '{0} results are available', selectionMessage: '{0} items selected', emptySelectionMessage: 'No selected item', emptySearchMessage: 'No results found', fileChosenMessage: '{0} files', noFileChosenMessage: 'No file chosen', emptyMessage: 'No available options', aria: { trueLabel: 'True', falseLabel: 'False', nullLabel: 'Not Selected', star: '1 star', stars: '{star} stars', selectAll: 'All items selected', unselectAll: 'All items unselected', close: 'Close', previous: 'Previous', next: 'Next', navigation: 'Navigation', scrollTop: 'Scroll Top', moveTop: 'Move Top', moveUp: 'Move Up', moveDown: 'Move Down', moveBottom: 'Move Bottom', moveToTarget: 'Move to Target', moveToSource: 'Move to Source', moveAllToTarget: 'Move All to Target', moveAllToSource: 'Move All to Source', pageLabel: 'Page {page}', firstPageLabel: 'First Page', lastPageLabel: 'Last Page', nextPageLabel: 'Next Page', prevPageLabel: 'Previous Page', rowsPerPageLabel: 'Rows per page', jumpToPageDropdownLabel: 'Jump to Page Dropdown', jumpToPageInputLabel: 'Jump to Page Input', selectRow: 'Row Selected', unselectRow: 'Row Unselected', expandRow: 'Row Expanded', collapseRow: 'Row Collapsed', showFilterMenu: 'Show Filter Menu', hideFilterMenu: 'Hide Filter Menu', filterOperator: 'Filter Operator', filterConstraint: 'Filter Constraint', editRow: 'Row Edit', saveEdit: 'Save Edit', cancelEdit: 'Cancel Edit', listView: 'List View', gridView: 'Grid View', slide: 'Slide', slideNumber: '{slideNumber}', zoomImage: 'Zoom Image', zoomIn: 'Zoom In', zoomOut: 'Zoom Out', rotateRight: 'Rotate Right', rotateLeft: 'Rotate Left', listLabel: 'Option List' } }, filterMatchModeOptions: { text: [FilterMatchMode.STARTS_WITH, FilterMatchMode.CONTAINS, FilterMatchMode.NOT_CONTAINS, FilterMatchMode.ENDS_WITH, FilterMatchMode.EQUALS, FilterMatchMode.NOT_EQUALS], numeric: [FilterMatchMode.EQUALS, FilterMatchMode.NOT_EQUALS, FilterMatchMode.LESS_THAN, FilterMatchMode.LESS_THAN_OR_EQUAL_TO, FilterMatchMode.GREATER_THAN, FilterMatchMode.GREATER_THAN_OR_EQUAL_TO], date: [FilterMatchMode.DATE_IS, FilterMatchMode.DATE_IS_NOT, FilterMatchMode.DATE_BEFORE, FilterMatchMode.DATE_AFTER] }, zIndex: { modal: 1100, overlay: 1000, menu: 1000, tooltip: 1100 }, theme: undefined, unstyled: false, pt: undefined, ptOptions: { mergeSections: true, mergeProps: false }, csp: { nonce: undefined } }; var PrimeVueSymbol = Symbol(); function usePrimeVue() { var PrimeVue = inject(PrimeVueSymbol); if (!PrimeVue) { throw new Error('PrimeVue is not installed!'); } return PrimeVue; } function setup(app, options) { var PrimeVue = { config: reactive(options) }; app.config.globalProperties.$primevue = PrimeVue; app.provide(PrimeVueSymbol, PrimeVue); clearConfig(); setupConfig(app, PrimeVue); return PrimeVue; } var stopWatchers = []; function clearConfig() { ThemeService.clear(); stopWatchers.forEach(function (fn) { return fn === null || fn === void 0 ? void 0 : fn(); }); stopWatchers = []; } function setupConfig(app, PrimeVue) { var isThemeChanged = ref(false); /*** Methods and Services ***/ var loadCommonTheme = function loadCommonTheme() { // common if (!Theme.isStyleNameLoaded('common')) { var _BaseStyle$getCommonT, _PrimeVue$config; var _ref = ((_BaseStyle$getCommonT = BaseStyle.getCommonTheme) === null || _BaseStyle$getCommonT === void 0 ? void 0 : _BaseStyle$getCommonT.call(BaseStyle)) || {}, primitive = _ref.primitive, semantic = _ref.semantic; var styleOptions = { nonce: (_PrimeVue$config = PrimeVue.config) === null || _PrimeVue$config === void 0 || (_PrimeVue$config = _PrimeVue$config.csp) === null || _PrimeVue$config === void 0 ? void 0 : _PrimeVue$config.nonce }; BaseStyle.load(primitive === null || primitive === void 0 ? void 0 : primitive.css, _objectSpread({ name: 'primitive-variables' }, styleOptions)); BaseStyle.load(semantic === null || semantic === void 0 ? void 0 : semantic.css, _objectSpread({ name: 'semantic-variables' }, styleOptions)); BaseStyle.loadTheme(_objectSpread({ name: 'global-style' }, styleOptions)); Theme.setLoadedStyleName('common'); } }; ThemeService.on('theme:change', function (newTheme) { if (!isThemeChanged.value) { app.config.globalProperties.$primevue.config.theme = newTheme; isThemeChanged.value = true; } }); /*** Watchers ***/ var stopConfigWatcher = watch(PrimeVue.config, function (newValue, oldValue) { PrimeVueService.emit('config:change', { newValue: newValue, oldValue: oldValue }); }, { immediate: true, deep: true }); var stopRippleWatcher = watch(function () { return PrimeVue.config.ripple; }, function (newValue, oldValue) { PrimeVueService.emit('config:ripple:change', { newValue: newValue, oldValue: oldValue }); }, { immediate: true, deep: true }); var stopThemeWatcher = watch(function () { return PrimeVue.config.theme; }, function (newValue, oldValue) { if (!isThemeChanged.value) { Theme.setTheme(newValue); } if (!PrimeVue.config.unstyled) { loadCommonTheme(); } isThemeChanged.value = false; PrimeVueService.emit('config:theme:change', { newValue: newValue, oldValue: oldValue }); }, { immediate: true, deep: true }); var stopUnstyledWatcher = watch(function () { return PrimeVue.config.unstyled; }, function (newValue, oldValue) { if (!newValue && PrimeVue.config.theme) { loadCommonTheme(); } PrimeVueService.emit('config:unstyled:change', { newValue: newValue, oldValue: oldValue }); }, { immediate: true, deep: true }); stopWatchers.push(stopConfigWatcher); stopWatchers.push(stopRippleWatcher); stopWatchers.push(stopThemeWatcher); stopWatchers.push(stopUnstyledWatcher); } var PrimeVue = { install: function install(app, options) { var configOptions = mergeKeys(defaultOptions, options); setup(app, configOptions); } }; export { clearConfig, PrimeVue as default, defaultOptions, setup, setupConfig, usePrimeVue }; //# sourceMappingURL=index.mjs.map