2022-09-14 11:26:01 +00:00
|
|
|
import { FilterMatchMode } from 'primevue/api';
|
2024-05-27 22:04:12 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
2024-05-08 15:58:22 +00:00
|
|
|
import PrimeVueService from 'primevue/service';
|
2024-05-13 21:57:53 +00:00
|
|
|
import { Theme, ThemeService } from 'primevue/themes';
|
2024-04-02 10:17:58 +00:00
|
|
|
import { inject, reactive, ref, watch } from 'vue';
|
2020-12-09 12:24:11 +00:00
|
|
|
|
2023-04-28 13:58:46 +00:00
|
|
|
export const defaultOptions = {
|
2020-12-09 12:24:11 +00:00
|
|
|
ripple: false,
|
2024-02-01 13:11:24 +00:00
|
|
|
inputStyle: null,
|
2024-05-27 10:28:07 +00:00
|
|
|
inputVariant: null,
|
2020-12-09 12:24:11 +00:00
|
|
|
locale: {
|
2021-02-06 09:26:12 +00:00
|
|
|
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',
|
2021-02-08 12:35:16 +00:00
|
|
|
dateIs: 'Date is',
|
|
|
|
dateIsNot: 'Date is not',
|
|
|
|
dateBefore: 'Date is before',
|
|
|
|
dateAfter: 'Date is after',
|
2021-02-06 09:26:12 +00:00
|
|
|
clear: 'Clear',
|
|
|
|
apply: 'Apply',
|
|
|
|
matchAll: 'Match All',
|
|
|
|
matchAny: 'Match Any',
|
|
|
|
addRule: 'Add Rule',
|
|
|
|
removeRule: 'Remove Rule',
|
2020-12-09 12:24:11 +00:00
|
|
|
accept: 'Yes',
|
|
|
|
reject: 'No',
|
|
|
|
choose: 'Choose',
|
|
|
|
upload: 'Upload',
|
|
|
|
cancel: 'Cancel',
|
2022-12-08 11:04:25 +00:00
|
|
|
completed: 'Completed',
|
|
|
|
pending: 'Pending',
|
2023-09-05 02:01:27 +00:00
|
|
|
fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
2022-09-14 11:26:01 +00:00
|
|
|
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'],
|
2022-07-19 13:04:04 +00:00
|
|
|
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',
|
2020-12-09 12:24:11 +00:00
|
|
|
today: 'Today',
|
|
|
|
weekHeader: 'Wk',
|
|
|
|
firstDayOfWeek: 0,
|
2023-07-09 14:46:01 +00:00
|
|
|
showMonthAfterYear: false,
|
2020-12-09 12:24:11 +00:00
|
|
|
dateFormat: 'mm/dd/yy',
|
|
|
|
weak: 'Weak',
|
|
|
|
medium: 'Medium',
|
|
|
|
strong: 'Strong',
|
2021-02-15 08:50:11 +00:00
|
|
|
passwordPrompt: 'Enter a password',
|
2022-07-29 00:50:40 +00:00
|
|
|
emptyFilterMessage: 'No results found', // @deprecated Use 'emptySearchMessage' option instead.
|
|
|
|
searchMessage: '{0} results are available',
|
|
|
|
selectionMessage: '{0} items selected',
|
|
|
|
emptySelectionMessage: 'No selected item',
|
|
|
|
emptySearchMessage: 'No results found',
|
2024-05-09 14:46:20 +00:00
|
|
|
fileChosenMessage: '{0} files',
|
2024-05-13 12:35:52 +00:00
|
|
|
noFileChosenMessage: 'No file chosen',
|
2022-07-18 10:36:43 +00:00
|
|
|
emptyMessage: 'No available options',
|
|
|
|
aria: {
|
|
|
|
trueLabel: 'True',
|
|
|
|
falseLabel: 'False',
|
2022-07-22 13:30:42 +00:00
|
|
|
nullLabel: 'Not Selected',
|
2022-07-29 13:52:08 +00:00
|
|
|
star: '1 star',
|
|
|
|
stars: '{star} stars',
|
2022-07-29 04:21:24 +00:00
|
|
|
selectAll: 'All items selected',
|
|
|
|
unselectAll: 'All items unselected',
|
2022-09-14 11:26:01 +00:00
|
|
|
close: 'Close',
|
|
|
|
previous: 'Previous',
|
2022-12-08 11:04:25 +00:00
|
|
|
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',
|
2023-11-30 20:06:40 +00:00
|
|
|
pageLabel: 'Page {page}',
|
2022-12-08 11:04:25 +00:00
|
|
|
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',
|
2024-04-24 06:03:12 +00:00
|
|
|
rotateLeft: 'Rotate Left',
|
|
|
|
listLabel: 'Option List'
|
2022-07-18 10:36:43 +00:00
|
|
|
}
|
2021-02-06 09:26:12 +00:00
|
|
|
},
|
|
|
|
filterMatchModeOptions: {
|
2022-09-14 11:26:01 +00:00
|
|
|
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]
|
2021-04-13 13:59:08 +00:00
|
|
|
},
|
|
|
|
zIndex: {
|
|
|
|
modal: 1100,
|
|
|
|
overlay: 1000,
|
|
|
|
menu: 1000,
|
|
|
|
tooltip: 1100
|
2023-04-25 11:36:01 +00:00
|
|
|
},
|
2024-04-01 13:58:07 +00:00
|
|
|
theme: undefined,
|
|
|
|
unstyled: false,
|
2023-05-16 10:29:56 +00:00
|
|
|
pt: undefined,
|
2023-09-20 11:25:33 +00:00
|
|
|
ptOptions: {
|
|
|
|
mergeSections: true,
|
|
|
|
mergeProps: false
|
|
|
|
},
|
2023-08-11 01:34:02 +00:00
|
|
|
csp: {
|
|
|
|
nonce: undefined
|
|
|
|
}
|
2020-12-09 12:24:11 +00:00
|
|
|
};
|
|
|
|
|
2020-12-10 08:03:08 +00:00
|
|
|
const PrimeVueSymbol = Symbol();
|
|
|
|
|
|
|
|
export function usePrimeVue() {
|
|
|
|
const PrimeVue = inject(PrimeVueSymbol);
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2020-12-10 08:03:08 +00:00
|
|
|
if (!PrimeVue) {
|
|
|
|
throw new Error('PrimeVue is not installed!');
|
2022-07-29 00:50:40 +00:00
|
|
|
}
|
|
|
|
|
2020-12-10 08:03:08 +00:00
|
|
|
return PrimeVue;
|
|
|
|
}
|
|
|
|
|
2024-04-01 09:46:31 +00:00
|
|
|
export function setup(app, options) {
|
|
|
|
const PrimeVue = {
|
|
|
|
config: reactive(options)
|
|
|
|
};
|
2024-01-02 10:18:28 +00:00
|
|
|
|
2024-04-01 09:46:31 +00:00
|
|
|
app.config.globalProperties.$primevue = PrimeVue;
|
|
|
|
app.provide(PrimeVueSymbol, PrimeVue);
|
2023-10-17 22:02:28 +00:00
|
|
|
|
2024-05-27 22:04:12 +00:00
|
|
|
setupConfig(app, PrimeVue);
|
2024-04-02 10:17:58 +00:00
|
|
|
|
2024-04-01 09:46:31 +00:00
|
|
|
return PrimeVue;
|
2023-03-03 07:02:10 +00:00
|
|
|
}
|
|
|
|
|
2024-05-27 22:04:12 +00:00
|
|
|
export function setupConfig(app, PrimeVue) {
|
|
|
|
const isThemeChanged = ref(false);
|
2024-04-02 10:17:58 +00:00
|
|
|
|
2024-05-27 22:04:12 +00:00
|
|
|
/*** Methods and Services ***/
|
|
|
|
const loadCommonTheme = () => {
|
|
|
|
// common
|
|
|
|
if (!Theme.isStyleNameLoaded('common')) {
|
|
|
|
const { primitive, semantic } = BaseStyle.getCommonTheme?.() || {};
|
|
|
|
const styleOptions = { nonce: PrimeVue.config?.csp?.nonce };
|
|
|
|
|
|
|
|
BaseStyle.load(primitive?.css, { name: 'primitive-variables', ...styleOptions });
|
|
|
|
BaseStyle.load(semantic?.css, { name: 'semantic-variables', ...styleOptions });
|
|
|
|
BaseStyle.loadTheme({ name: 'global-style', ...styleOptions });
|
|
|
|
|
|
|
|
Theme.setLoadedStyleName('common');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ThemeService.on('theme:change', function (newTheme) {
|
|
|
|
isThemeChanged.value = true;
|
|
|
|
app.config.globalProperties.$primevue.config.theme = newTheme;
|
|
|
|
});
|
|
|
|
|
|
|
|
/*** Watchers ***/
|
2024-05-08 15:58:22 +00:00
|
|
|
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 }
|
|
|
|
);
|
|
|
|
|
2024-04-02 10:17:58 +00:00
|
|
|
watch(
|
2024-05-14 09:25:15 +00:00
|
|
|
() => PrimeVue.config.theme,
|
2024-05-08 15:58:22 +00:00
|
|
|
(newValue, oldValue) => {
|
2024-05-27 22:04:12 +00:00
|
|
|
if (!isThemeChanged.value) {
|
2024-04-02 10:17:58 +00:00
|
|
|
Theme.setTheme(newValue);
|
|
|
|
}
|
|
|
|
|
2024-05-27 22:04:12 +00:00
|
|
|
if (!PrimeVue.config.unstyled) {
|
|
|
|
loadCommonTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
isThemeChanged.value = false;
|
2024-05-08 15:58:22 +00:00
|
|
|
PrimeVueService.emit('config:theme:change', { newValue, oldValue });
|
2024-04-02 10:17:58 +00:00
|
|
|
},
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
);
|
|
|
|
|
2024-05-27 22:04:12 +00:00
|
|
|
watch(
|
|
|
|
() => PrimeVue.config.unstyled,
|
|
|
|
(newValue, oldValue) => {
|
|
|
|
if (!newValue && PrimeVue.config.theme) {
|
|
|
|
loadCommonTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
PrimeVueService.emit('config:unstyled:change', { newValue, oldValue });
|
|
|
|
},
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
);
|
2024-04-02 10:17:58 +00:00
|
|
|
}
|
|
|
|
|
2020-12-09 12:24:11 +00:00
|
|
|
export default {
|
2024-04-01 13:58:07 +00:00
|
|
|
install: (app, options) => {
|
|
|
|
const configOptions = { ...defaultOptions, ...options };
|
|
|
|
|
|
|
|
setup(app, configOptions);
|
2020-12-09 12:24:11 +00:00
|
|
|
}
|
2022-07-29 00:50:40 +00:00
|
|
|
};
|