@winchsa/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -0
- package/dist/components/Breadcrumbs.vue +46 -0
- package/dist/components/Breadcrumbs.vue.d.ts +6 -0
- package/dist/components/Drawer.vue +60 -0
- package/dist/components/Drawer.vue.d.ts +44 -0
- package/dist/components/IconBtn.vue +18 -0
- package/dist/components/IconBtn.vue.d.ts +30 -0
- package/dist/components/Modal.vue +155 -0
- package/dist/components/Modal.vue.d.ts +0 -0
- package/dist/components/SiteTitle.vue +14 -0
- package/dist/components/SiteTitle.vue.d.ts +2 -0
- package/dist/components/Toaster.vue +19 -0
- package/dist/components/Toaster.vue.d.ts +5 -0
- package/dist/components/cards/CheckboxesCard.vue +76 -0
- package/dist/components/cards/CheckboxesCard.vue.d.ts +20 -0
- package/dist/components/cards/HeaderCard.vue +31 -0
- package/dist/components/cards/HeaderCard.vue.d.ts +8 -0
- package/dist/components/cards/ImageCard.vue +73 -0
- package/dist/components/cards/ImageCard.vue.d.ts +63 -0
- package/dist/components/cards/InputCard.vue +60 -0
- package/dist/components/cards/InputCard.vue.d.ts +41 -0
- package/dist/components/cards/StaticCard.vue +37 -0
- package/dist/components/cards/StaticCard.vue.d.ts +33 -0
- package/dist/components/core/AppBarSearch.vue +345 -0
- package/dist/components/core/AppBarSearch.vue.d.ts +1587 -0
- package/dist/components/core/AppDrawerHeaderSection.vue +21 -0
- package/dist/components/core/AppDrawerHeaderSection.vue.d.ts +30 -0
- package/dist/components/core/AppSearchHeader.vue +72 -0
- package/dist/components/core/AppSearchHeader.vue.d.ts +7 -0
- package/dist/components/core/AppStepper.vue +232 -0
- package/dist/components/core/AppStepper.vue.d.ts +25 -0
- package/dist/components/core/CustomizerSection.vue +19 -0
- package/dist/components/core/CustomizerSection.vue.d.ts +25 -0
- package/dist/components/core/DialogCloseBtn.vue +20 -0
- package/dist/components/core/DialogCloseBtn.vue.d.ts +9 -0
- package/dist/components/core/MoreBtn.vue +27 -0
- package/dist/components/core/MoreBtn.vue.d.ts +25 -0
- package/dist/components/core/ScrollToTop.vue +39 -0
- package/dist/components/core/ScrollToTop.vue.d.ts +2 -0
- package/dist/components/core/app-form-elements/AppCombobox.vue +67 -0
- package/dist/components/core/app-form-elements/AppCombobox.vue.d.ts +0 -0
- package/dist/components/core/app-form-elements/AppSelect.vue +98 -0
- package/dist/components/core/app-form-elements/AppSelect.vue.d.ts +0 -0
- package/dist/components/core/app-form-elements/AppSwitch.vue +59 -0
- package/dist/components/core/app-form-elements/AppSwitch.vue.d.ts +27 -0
- package/dist/components/core/app-form-elements/AppTextField.vue +66 -0
- package/dist/components/core/app-form-elements/AppTextField.vue.d.ts +26 -0
- package/dist/components/core/app-form-elements/AppTextarea.vue +69 -0
- package/dist/components/core/app-form-elements/AppTextarea.vue.d.ts +26 -0
- package/dist/components/core/app-form-elements/CustomCheckboxes.vue +69 -0
- package/dist/components/core/app-form-elements/CustomCheckboxes.vue.d.ts +39 -0
- package/dist/components/core/app-form-elements/CustomCheckboxesWithIcon.vue +80 -0
- package/dist/components/core/app-form-elements/CustomCheckboxesWithIcon.vue.d.ts +39 -0
- package/dist/components/core/app-form-elements/CustomCheckboxesWithImage.vue +67 -0
- package/dist/components/core/app-form-elements/CustomCheckboxesWithImage.vue.d.ts +15 -0
- package/dist/components/core/app-form-elements/CustomRadios.vue +69 -0
- package/dist/components/core/app-form-elements/CustomRadios.vue.d.ts +40 -0
- package/dist/components/core/app-form-elements/CustomRadiosWithIcon.vue +98 -0
- package/dist/components/core/app-form-elements/CustomRadiosWithIcon.vue.d.ts +45 -0
- package/dist/components/core/app-form-elements/CustomRadiosWithImage.vue +69 -0
- package/dist/components/core/app-form-elements/CustomRadiosWithImage.vue.d.ts +53 -0
- package/dist/components/core/cards/AppCard.vue +45 -0
- package/dist/components/core/cards/AppCard.vue.d.ts +26 -0
- package/dist/components/core/cards/AppCardActions.vue +126 -0
- package/dist/components/core/cards/AppCardActions.vue.d.ts +79 -0
- package/dist/components/core/cards/CardStatisticsHorizontal.vue +29 -0
- package/dist/components/core/cards/CardStatisticsHorizontal.vue.d.ts +10 -0
- package/dist/components/forms/Accordion.vue +43 -0
- package/dist/components/forms/Accordion.vue.d.ts +35 -0
- package/dist/components/forms/AppLabel.vue +47 -0
- package/dist/components/forms/AppLabel.vue.d.ts +36 -0
- package/dist/components/forms/AppLink.vue +50 -0
- package/dist/components/forms/AppLink.vue.d.ts +27 -0
- package/dist/components/forms/AppNumberField.vue +85 -0
- package/dist/components/forms/AppNumberField.vue.d.ts +45 -0
- package/dist/components/forms/AppOtpInput.vue +84 -0
- package/dist/components/forms/AppOtpInput.vue.d.ts +16 -0
- package/dist/components/forms/AttachmentCropperInput.vue +228 -0
- package/dist/components/forms/AttachmentCropperInput.vue.d.ts +25 -0
- package/dist/components/forms/AttachmentInput.vue +116 -0
- package/dist/components/forms/AttachmentInput.vue.d.ts +20 -0
- package/dist/components/forms/AutocompleteInput.vue +759 -0
- package/dist/components/forms/AutocompleteInput.vue.d.ts +0 -0
- package/dist/components/forms/BankSelect.vue +43 -0
- package/dist/components/forms/BankSelect.vue.d.ts +19 -0
- package/dist/components/forms/BaseButton.vue +42 -0
- package/dist/components/forms/BaseButton.vue.d.ts +31 -0
- package/dist/components/forms/CounterInput.vue +71 -0
- package/dist/components/forms/CounterInput.vue.d.ts +15 -0
- package/dist/components/forms/DatePicker.vue +400 -0
- package/dist/components/forms/DatePicker.vue.d.ts +34 -0
- package/dist/components/forms/DatePickerRange.vue +129 -0
- package/dist/components/forms/DatePickerRange.vue.d.ts +23 -0
- package/dist/components/forms/DraggedUploadFile.vue +120 -0
- package/dist/components/forms/DraggedUploadFile.vue.d.ts +10 -0
- package/dist/components/forms/ImageCardInput.vue +234 -0
- package/dist/components/forms/ImageCardInput.vue.d.ts +0 -0
- package/dist/components/forms/InputValidationWrapper.vue +24 -0
- package/dist/components/forms/InputValidationWrapper.vue.d.ts +33 -0
- package/dist/components/forms/LicensePlateInput.vue +159 -0
- package/dist/components/forms/LicensePlateInput.vue.d.ts +16 -0
- package/dist/components/forms/ManualDate.vue +262 -0
- package/dist/components/forms/ManualDate.vue.d.ts +17 -0
- package/dist/components/forms/MobileInput.vue +118 -0
- package/dist/components/forms/MobileInput.vue.d.ts +49 -0
- package/dist/components/forms/PasswordInput.vue +29 -0
- package/dist/components/forms/PasswordInput.vue.d.ts +13 -0
- package/dist/components/forms/RangeInput.vue +48 -0
- package/dist/components/forms/RangeInput.vue.d.ts +5 -0
- package/dist/components/forms/Tabs.vue +35 -0
- package/dist/components/forms/Tabs.vue.d.ts +42 -0
- package/dist/components/forms/TimePicker.vue +370 -0
- package/dist/components/forms/TimePicker.vue.d.ts +23 -0
- package/dist/components/icons/EndMarker.vue +25 -0
- package/dist/components/icons/EndMarker.vue.d.ts +17 -0
- package/dist/components/icons/RedXIcon.vue +36 -0
- package/dist/components/icons/RedXIcon.vue.d.ts +2 -0
- package/dist/components/icons/StarFillIcon.vue +28 -0
- package/dist/components/icons/StarFillIcon.vue.d.ts +2 -0
- package/dist/components/icons/StartMarker.vue +25 -0
- package/dist/components/icons/StartMarker.vue.d.ts +17 -0
- package/dist/components/icons/WorkerIcon.vue +39 -0
- package/dist/components/icons/WorkerIcon.vue.d.ts +2 -0
- package/dist/components/loading/LoadingBar.vue +31 -0
- package/dist/components/loading/LoadingBar.vue.d.ts +5 -0
- package/dist/components/loading/LoadingDialog.vue +41 -0
- package/dist/components/loading/LoadingDialog.vue.d.ts +11 -0
- package/dist/components/loading/LoadingItem.vue +66 -0
- package/dist/components/loading/LoadingItem.vue.d.ts +47 -0
- package/dist/components/table/DataTable.vue +319 -0
- package/dist/components/table/DataTable.vue.d.ts +0 -0
- package/dist/components/table/EditableDataTable.vue +329 -0
- package/dist/components/table/EditableDataTable.vue.d.ts +73 -0
- package/dist/components/table/EditableDataTableRow.vue +243 -0
- package/dist/components/table/EditableDataTableRow.vue.d.ts +18 -0
- package/dist/components/table/FilterGenerator.vue +232 -0
- package/dist/components/table/FilterGenerator.vue.d.ts +14 -0
- package/dist/components/table/StaticTable.vue +152 -0
- package/dist/components/table/StaticTable.vue.d.ts +25 -0
- package/dist/components/table/TablePagination.vue +73 -0
- package/dist/components/table/TablePagination.vue.d.ts +13 -0
- package/dist/composables/use-is-mobile.d.ts +1 -0
- package/dist/composables/use-is-mobile.js +10 -0
- package/dist/composables/use-is-mobile.mjs +4 -0
- package/dist/composables/use-table-filters.d.ts +23 -0
- package/dist/composables/use-table-filters.js +196 -0
- package/dist/composables/use-table-filters.mjs +183 -0
- package/dist/fonts/NotoSans-Medium.ttf +0 -0
- package/dist/fonts/NotoSansArabic-Medium.ttf +0 -0
- package/dist/fonts/saudi_riyal_symbol/saudi_riyal_symbol.eot +0 -0
- package/dist/fonts/saudi_riyal_symbol/saudi_riyal_symbol.svg +9 -0
- package/dist/fonts/saudi_riyal_symbol/saudi_riyal_symbol.ttf +0 -0
- package/dist/fonts/saudi_riyal_symbol/saudi_riyal_symbol.woff +0 -0
- package/dist/fonts/saudi_riyal_symbol/saudi_riyal_symbol.woff2 +0 -0
- package/dist/images/avatar.png +0 -0
- package/dist/images/sa.svg +1 -0
- package/dist/images/successful-registration.svg +15 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +447 -0
- package/dist/index.mjs +128 -0
- package/dist/styles/@core/scss/base/_components.scss +164 -0
- package/dist/styles/@core/scss/base/_dark.scss +16 -0
- package/dist/styles/@core/scss/base/_default-layout-w-vertical-nav.scss +106 -0
- package/dist/styles/@core/scss/base/_default-layout.scss +16 -0
- package/dist/styles/@core/scss/base/_index.scss +47 -0
- package/dist/styles/@core/scss/base/_layouts.scss +63 -0
- package/dist/styles/@core/scss/base/_misc.scss +20 -0
- package/dist/styles/@core/scss/base/_mixins.scss +84 -0
- package/dist/styles/@core/scss/base/_route-transitions.scss +70 -0
- package/dist/styles/@core/scss/base/_utilities.scss +418 -0
- package/dist/styles/@core/scss/base/_utils.scss +100 -0
- package/dist/styles/@core/scss/base/_variables.scss +190 -0
- package/dist/styles/@core/scss/base/_vertical-nav.scss +264 -0
- package/dist/styles/@core/scss/base/libs/_perfect-scrollbar.scss +35 -0
- package/dist/styles/@core/scss/base/libs/vuetify/_index.scss +1 -0
- package/dist/styles/@core/scss/base/libs/vuetify/_overrides.scss +385 -0
- package/dist/styles/@core/scss/base/libs/vuetify/_variables.scss +48 -0
- package/dist/styles/@core/scss/base/placeholders/_default-layout-vertical-nav.scss +48 -0
- package/dist/styles/@core/scss/base/placeholders/_default-layout.scss +3 -0
- package/dist/styles/@core/scss/base/placeholders/_index.scss +5 -0
- package/dist/styles/@core/scss/base/placeholders/_misc.scss +7 -0
- package/dist/styles/@core/scss/base/placeholders/_nav.scss +26 -0
- package/dist/styles/@core/scss/base/placeholders/_vertical-nav.scss +84 -0
- package/dist/styles/@core/scss/base/skins/_bordered.scss +60 -0
- package/dist/styles/@core/scss/base/skins/_index.scss +1 -0
- package/dist/styles/@core/scss/template/_components.scss +1035 -0
- package/dist/styles/@core/scss/template/_default-layout-w-vertical-nav.scss +20 -0
- package/dist/styles/@core/scss/template/_utilities.scss +20 -0
- package/dist/styles/@core/scss/template/_variables.scss +67 -0
- package/dist/styles/@core/scss/template/_vertical-nav.scss +41 -0
- package/dist/styles/@core/scss/template/index.css +18764 -0
- package/dist/styles/@core/scss/template/index.scss +15 -0
- package/dist/styles/@core/scss/template/libs/apex-chart.css +90 -0
- package/dist/styles/@core/scss/template/libs/apex-chart.scss +99 -0
- package/dist/styles/@core/scss/template/libs/shepherd.css +82 -0
- package/dist/styles/@core/scss/template/libs/shepherd.scss +88 -0
- package/dist/styles/@core/scss/template/libs/vuetify/_variables.scss +461 -0
- package/dist/styles/@core/scss/template/libs/vuetify/index.css +741 -0
- package/dist/styles/@core/scss/template/libs/vuetify/index.scss +1 -0
- package/dist/styles/@core/scss/template/pages/misc.css +16 -0
- package/dist/styles/@core/scss/template/pages/misc.scss +20 -0
- package/dist/styles/@core/scss/template/placeholders/_default-layout-vertical-nav.scss +9 -0
- package/dist/styles/@core/scss/template/placeholders/_index.scss +3 -0
- package/dist/styles/@core/scss/template/placeholders/_nav.scss +15 -0
- package/dist/styles/@core/scss/template/placeholders/_vertical-nav.scss +18 -0
- package/dist/styles/@core/scss/template/skins/_bordered.scss +36 -0
- package/dist/styles/@core/scss/template/skins/_index.scss +1 -0
- package/dist/styles/@layouts/styles/_classes.scss +3 -0
- package/dist/styles/@layouts/styles/_dashboard-layout.scss +43 -0
- package/dist/styles/@layouts/styles/_global.scss +10 -0
- package/dist/styles/@layouts/styles/_mixins.scss +28 -0
- package/dist/styles/@layouts/styles/_placeholders.scss +53 -0
- package/dist/styles/@layouts/styles/_rtl.scss +7 -0
- package/dist/styles/@layouts/styles/_variables.scss +22 -0
- package/dist/styles/@layouts/styles/index.css +14 -0
- package/dist/styles/@layouts/styles/index.scss +2 -0
- package/dist/styles/assets/scss/styles.css +16099 -0
- package/dist/styles/assets/scss/styles.scss +246 -0
- package/dist/styles/assets/scss/variables/_template.scss +1 -0
- package/dist/styles/assets/scss/variables/_vuetify.scss +1 -0
- package/dist/types.d.ts +226 -0
- package/dist/utils/apiUrl.d.ts +1 -0
- package/dist/utils/apiUrl.js +15 -0
- package/dist/utils/apiUrl.mjs +8 -0
- package/dist/utils/client.d.ts +9 -0
- package/dist/utils/client.js +39 -0
- package/dist/utils/client.mjs +25 -0
- package/dist/utils/files.d.ts +2 -0
- package/dist/utils/files.js +35 -0
- package/dist/utils/files.mjs +22 -0
- package/dist/utils/formValidation.d.ts +7 -0
- package/dist/utils/formValidation.js +20 -0
- package/dist/utils/formValidation.mjs +13 -0
- package/dist/utils/formatters.d.ts +12 -0
- package/dist/utils/formatters.js +84 -0
- package/dist/utils/formatters.mjs +56 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +104 -0
- package/dist/utils/index.mjs +9 -0
- package/dist/utils/queryParams.d.ts +4 -0
- package/dist/utils/queryParams.js +26 -0
- package/dist/utils/queryParams.mjs +18 -0
- package/dist/utils/ruleValidator.d.ts +28 -0
- package/dist/utils/ruleValidator.js +158 -0
- package/dist/utils/ruleValidator.mjs +144 -0
- package/dist/utils/toaster.d.ts +12 -0
- package/dist/utils/toaster.js +71 -0
- package/dist/utils/toaster.mjs +59 -0
- package/dist/utils/utils.d.ts +8 -0
- package/dist/utils/utils.js +70 -0
- package/dist/utils/utils.mjs +56 -0
- package/package.json +79 -0
- package/src/styles/@core/scss/base/_components.scss +164 -0
- package/src/styles/@core/scss/base/_dark.scss +16 -0
- package/src/styles/@core/scss/base/_default-layout-w-vertical-nav.scss +106 -0
- package/src/styles/@core/scss/base/_default-layout.scss +16 -0
- package/src/styles/@core/scss/base/_index.scss +47 -0
- package/src/styles/@core/scss/base/_layouts.scss +63 -0
- package/src/styles/@core/scss/base/_misc.scss +20 -0
- package/src/styles/@core/scss/base/_mixins.scss +84 -0
- package/src/styles/@core/scss/base/_route-transitions.scss +70 -0
- package/src/styles/@core/scss/base/_utilities.scss +418 -0
- package/src/styles/@core/scss/base/_utils.scss +100 -0
- package/src/styles/@core/scss/base/_variables.scss +190 -0
- package/src/styles/@core/scss/base/_vertical-nav.scss +264 -0
- package/src/styles/@core/scss/base/libs/_perfect-scrollbar.scss +35 -0
- package/src/styles/@core/scss/base/libs/vuetify/_index.scss +1 -0
- package/src/styles/@core/scss/base/libs/vuetify/_overrides.scss +385 -0
- package/src/styles/@core/scss/base/libs/vuetify/_variables.scss +48 -0
- package/src/styles/@core/scss/base/placeholders/_default-layout-vertical-nav.scss +48 -0
- package/src/styles/@core/scss/base/placeholders/_default-layout.scss +3 -0
- package/src/styles/@core/scss/base/placeholders/_index.scss +5 -0
- package/src/styles/@core/scss/base/placeholders/_misc.scss +7 -0
- package/src/styles/@core/scss/base/placeholders/_nav.scss +26 -0
- package/src/styles/@core/scss/base/placeholders/_vertical-nav.scss +84 -0
- package/src/styles/@core/scss/base/skins/_bordered.scss +60 -0
- package/src/styles/@core/scss/base/skins/_index.scss +1 -0
- package/src/styles/@core/scss/template/_components.scss +1035 -0
- package/src/styles/@core/scss/template/_default-layout-w-vertical-nav.scss +20 -0
- package/src/styles/@core/scss/template/_utilities.scss +20 -0
- package/src/styles/@core/scss/template/_variables.scss +67 -0
- package/src/styles/@core/scss/template/_vertical-nav.scss +41 -0
- package/src/styles/@core/scss/template/index.scss +15 -0
- package/src/styles/@core/scss/template/libs/apex-chart.scss +99 -0
- package/src/styles/@core/scss/template/libs/shepherd.scss +88 -0
- package/src/styles/@core/scss/template/libs/vuetify/_variables.scss +461 -0
- package/src/styles/@core/scss/template/libs/vuetify/index.scss +1 -0
- package/src/styles/@core/scss/template/pages/misc.scss +20 -0
- package/src/styles/@core/scss/template/placeholders/_default-layout-vertical-nav.scss +9 -0
- package/src/styles/@core/scss/template/placeholders/_index.scss +3 -0
- package/src/styles/@core/scss/template/placeholders/_nav.scss +15 -0
- package/src/styles/@core/scss/template/placeholders/_vertical-nav.scss +18 -0
- package/src/styles/@core/scss/template/skins/_bordered.scss +36 -0
- package/src/styles/@core/scss/template/skins/_index.scss +1 -0
- package/src/styles/@layouts/styles/_classes.scss +3 -0
- package/src/styles/@layouts/styles/_dashboard-layout.scss +43 -0
- package/src/styles/@layouts/styles/_global.scss +10 -0
- package/src/styles/@layouts/styles/_mixins.scss +28 -0
- package/src/styles/@layouts/styles/_placeholders.scss +53 -0
- package/src/styles/@layouts/styles/_rtl.scss +7 -0
- package/src/styles/@layouts/styles/_variables.scss +22 -0
- package/src/styles/@layouts/styles/index.scss +2 -0
- package/src/styles/assets/scss/styles.scss +246 -0
- package/src/styles/assets/scss/variables/_template.scss +1 -0
- package/src/styles/assets/scss/variables/_vuetify.scss +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatTime = exports.formatNumberColor = exports.formatNumber = exports.formatDateWithoutTime = exports.formatDateWithTime = exports.formatDateWithDay = exports.formatDate = exports.extractDate = void 0;
|
|
7
|
+
var _core = require("@vueuse/core");
|
|
8
|
+
var _vueI18n = require("vue-i18n");
|
|
9
|
+
const formatDate = date => {
|
|
10
|
+
return (0, _core.useDateFormat)(date, "DD/MM/YYYY \n hh:mm A").value;
|
|
11
|
+
};
|
|
12
|
+
exports.formatDate = formatDate;
|
|
13
|
+
const formatDateWithoutTime = (date, format = "DD/MM/YYYY") => {
|
|
14
|
+
return (0, _core.useDateFormat)(date, format).value;
|
|
15
|
+
};
|
|
16
|
+
exports.formatDateWithoutTime = formatDateWithoutTime;
|
|
17
|
+
const formatTime = date => {
|
|
18
|
+
return (0, _core.useDateFormat)(date, "hh:mm A").value;
|
|
19
|
+
};
|
|
20
|
+
exports.formatTime = formatTime;
|
|
21
|
+
const formatDateWithTime = date => {
|
|
22
|
+
return (0, _core.useDateFormat)(date, "DD/MM/YYYY - hh:mm A").value;
|
|
23
|
+
};
|
|
24
|
+
exports.formatDateWithTime = formatDateWithTime;
|
|
25
|
+
const formatDateWithDay = date => {
|
|
26
|
+
const {
|
|
27
|
+
locale
|
|
28
|
+
} = (0, _vueI18n.useI18n)({
|
|
29
|
+
useScope: "global"
|
|
30
|
+
});
|
|
31
|
+
return (0, _core.useDateFormat)(date, "HH:mm A dddd - DD/MM/YYYY", {
|
|
32
|
+
locales: locale?.value === "ar" ? "ar-SA" : "en-US"
|
|
33
|
+
}).value;
|
|
34
|
+
};
|
|
35
|
+
exports.formatDateWithDay = formatDateWithDay;
|
|
36
|
+
const extractDate = (dateString, format = "DD/MM/YYYY", hasTime = true) => {
|
|
37
|
+
if (!dateString) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const dateStr = hasTime ? dateString : typeof dateString === "string" ? dateString.split(" ")[0] : dateString;
|
|
41
|
+
const dateFormat = hasTime ? format : format.split(" ")[0];
|
|
42
|
+
const regex = dateFormat.replace(/[\\-]/g, "[/\\-]").replace("YYYY", "(\\d{4})").replace("MM", "(\\d{2})").replace("DD", "(\\d{2})");
|
|
43
|
+
const match = dateStr.toString().match(new RegExp(`^${regex}$`, "i"));
|
|
44
|
+
if (!match) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const [, day, month, year] = match;
|
|
48
|
+
return {
|
|
49
|
+
day,
|
|
50
|
+
month,
|
|
51
|
+
year
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.extractDate = extractDate;
|
|
55
|
+
const formatNumber = (number, withCurrency = false) => {
|
|
56
|
+
const {
|
|
57
|
+
locale
|
|
58
|
+
} = (0, _vueI18n.useI18n)({
|
|
59
|
+
useScope: "global"
|
|
60
|
+
});
|
|
61
|
+
const currency = withCurrency ? String.fromCharCode(59392) : "";
|
|
62
|
+
if (number === void 0 || number === null || number === "" || number === 0) {
|
|
63
|
+
return locale?.value !== "ar" ? `${currency} 0` : `0 ${currency}`;
|
|
64
|
+
}
|
|
65
|
+
if (typeof number === "string") {
|
|
66
|
+
number = parseFloat(number);
|
|
67
|
+
}
|
|
68
|
+
const needsTwoDecimalPlaces = number % 1 !== 0;
|
|
69
|
+
const options = {
|
|
70
|
+
minimumFractionDigits: needsTwoDecimalPlaces ? 2 : 0,
|
|
71
|
+
maximumFractionDigits: needsTwoDecimalPlaces ? 2 : 0
|
|
72
|
+
};
|
|
73
|
+
const formatted = Math.abs(number).toLocaleString("en-US", options);
|
|
74
|
+
return locale?.value !== "ar" ? `${currency} ${number < 0 ? `${formatted}-` : formatted}` : `${number < 0 ? `-${formatted}` : formatted} ${currency}`;
|
|
75
|
+
};
|
|
76
|
+
exports.formatNumber = formatNumber;
|
|
77
|
+
const formatNumberColor = number => {
|
|
78
|
+
const parsedNumber = typeof number === "string" ? parseFloat(number) : number;
|
|
79
|
+
if (parsedNumber === void 0 || parsedNumber === null || parsedNumber === 0 || isNaN(parsedNumber)) {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
return parsedNumber > 0 ? "success" : "red";
|
|
83
|
+
};
|
|
84
|
+
exports.formatNumberColor = formatNumberColor;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useDateFormat } from "@vueuse/core";
|
|
2
|
+
import { useI18n } from "vue-i18n";
|
|
3
|
+
export const formatDate = (date) => {
|
|
4
|
+
return useDateFormat(date, "DD/MM/YYYY \n hh:mm A").value;
|
|
5
|
+
};
|
|
6
|
+
export const formatDateWithoutTime = (date, format = "DD/MM/YYYY") => {
|
|
7
|
+
return useDateFormat(date, format).value;
|
|
8
|
+
};
|
|
9
|
+
export const formatTime = (date) => {
|
|
10
|
+
return useDateFormat(date, "hh:mm A").value;
|
|
11
|
+
};
|
|
12
|
+
export const formatDateWithTime = (date) => {
|
|
13
|
+
return useDateFormat(date, "DD/MM/YYYY - hh:mm A").value;
|
|
14
|
+
};
|
|
15
|
+
export const formatDateWithDay = (date) => {
|
|
16
|
+
const { locale } = useI18n({ useScope: "global" });
|
|
17
|
+
return useDateFormat(date, "HH:mm A dddd - DD/MM/YYYY", { locales: locale?.value === "ar" ? "ar-SA" : "en-US" }).value;
|
|
18
|
+
};
|
|
19
|
+
export const extractDate = (dateString, format = "DD/MM/YYYY", hasTime = true) => {
|
|
20
|
+
if (!dateString) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const dateStr = hasTime ? dateString : typeof dateString === "string" ? dateString.split(" ")[0] : dateString;
|
|
24
|
+
const dateFormat = hasTime ? format : format.split(" ")[0];
|
|
25
|
+
const regex = dateFormat.replace(/[\\-]/g, "[/\\-]").replace("YYYY", "(\\d{4})").replace("MM", "(\\d{2})").replace("DD", "(\\d{2})");
|
|
26
|
+
const match = dateStr.toString().match(new RegExp(`^${regex}$`, "i"));
|
|
27
|
+
if (!match) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const [, day, month, year] = match;
|
|
31
|
+
return { day, month, year };
|
|
32
|
+
};
|
|
33
|
+
export const formatNumber = (number, withCurrency = false) => {
|
|
34
|
+
const { locale } = useI18n({ useScope: "global" });
|
|
35
|
+
const currency = withCurrency ? String.fromCharCode(59392) : "";
|
|
36
|
+
if (number === void 0 || number === null || number === "" || number === 0) {
|
|
37
|
+
return locale?.value !== "ar" ? `${currency} 0` : `0 ${currency}`;
|
|
38
|
+
}
|
|
39
|
+
if (typeof number === "string") {
|
|
40
|
+
number = parseFloat(number);
|
|
41
|
+
}
|
|
42
|
+
const needsTwoDecimalPlaces = number % 1 !== 0;
|
|
43
|
+
const options = {
|
|
44
|
+
minimumFractionDigits: needsTwoDecimalPlaces ? 2 : 0,
|
|
45
|
+
maximumFractionDigits: needsTwoDecimalPlaces ? 2 : 0
|
|
46
|
+
};
|
|
47
|
+
const formatted = Math.abs(number).toLocaleString("en-US", options);
|
|
48
|
+
return locale?.value !== "ar" ? `${currency} ${number < 0 ? `${formatted}-` : formatted}` : `${number < 0 ? `-${formatted}` : formatted} ${currency}`;
|
|
49
|
+
};
|
|
50
|
+
export const formatNumberColor = (number) => {
|
|
51
|
+
const parsedNumber = typeof number === "string" ? parseFloat(number) : number;
|
|
52
|
+
if (parsedNumber === void 0 || parsedNumber === null || parsedNumber === 0 || isNaN(parsedNumber)) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
return parsedNumber > 0 ? "success" : "red";
|
|
56
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './apiUrl';
|
|
2
|
+
export * from './client';
|
|
3
|
+
export * from './files';
|
|
4
|
+
export * from './formValidation';
|
|
5
|
+
export * from './formatters';
|
|
6
|
+
export * from './queryParams';
|
|
7
|
+
export * from './ruleValidator';
|
|
8
|
+
export * from './toaster';
|
|
9
|
+
export * from './utils';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _apiUrl = require("./apiUrl");
|
|
7
|
+
Object.keys(_apiUrl).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _apiUrl[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _apiUrl[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _client = require("./client");
|
|
18
|
+
Object.keys(_client).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _client[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _client[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _files = require("./files");
|
|
29
|
+
Object.keys(_files).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _files[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _files[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _formValidation = require("./formValidation");
|
|
40
|
+
Object.keys(_formValidation).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _formValidation[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _formValidation[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _formatters = require("./formatters");
|
|
51
|
+
Object.keys(_formatters).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _formatters[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _formatters[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _queryParams = require("./queryParams");
|
|
62
|
+
Object.keys(_queryParams).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _queryParams[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _queryParams[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _ruleValidator = require("./ruleValidator");
|
|
73
|
+
Object.keys(_ruleValidator).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _ruleValidator[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _ruleValidator[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _toaster = require("./toaster");
|
|
84
|
+
Object.keys(_toaster).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _toaster[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _toaster[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _utils = require("./utils");
|
|
95
|
+
Object.keys(_utils).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _utils[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./apiUrl.mjs";
|
|
2
|
+
export * from "./client.mjs";
|
|
3
|
+
export * from "./files.mjs";
|
|
4
|
+
export * from "./formValidation.mjs";
|
|
5
|
+
export * from "./formatters.mjs";
|
|
6
|
+
export * from "./queryParams.mjs";
|
|
7
|
+
export * from "./ruleValidator.mjs";
|
|
8
|
+
export * from "./toaster.mjs";
|
|
9
|
+
export * from "./utils.mjs";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
2
|
+
import type { Params } from '../types';
|
|
3
|
+
export declare const buildQueryString: (params: Params | undefined) => string;
|
|
4
|
+
export declare const decodeRouteParams: (to?: RouteLocationNormalizedLoaded) => URLSearchParams;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeRouteParams = exports.buildQueryString = void 0;
|
|
7
|
+
var _vueRouter = require("vue-router");
|
|
8
|
+
const buildQueryString = params => {
|
|
9
|
+
const inputParams = params || {};
|
|
10
|
+
return Object.entries(inputParams).filter(([key, value]) => {
|
|
11
|
+
return key && value !== null && value !== void 0 && (Array.isArray(value) && value.length !== 0 || String(value).trim().length > 0);
|
|
12
|
+
}).map(([key, value]) => {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.map((subValue, index) => subValue ? `${key}[${index}]=${subValue}` : null).join("&");
|
|
15
|
+
}
|
|
16
|
+
return `${key}=${value}`;
|
|
17
|
+
}).join("&");
|
|
18
|
+
};
|
|
19
|
+
exports.buildQueryString = buildQueryString;
|
|
20
|
+
const decodeRouteParams = to => {
|
|
21
|
+
const route = to || (0, _vueRouter.useRoute)();
|
|
22
|
+
const path = decodeURIComponent(route.fullPath.replace(route.path, ""));
|
|
23
|
+
const params = new URLSearchParams(decodeURIComponent(path));
|
|
24
|
+
return params;
|
|
25
|
+
};
|
|
26
|
+
exports.decodeRouteParams = decodeRouteParams;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRoute } from "vue-router";
|
|
2
|
+
export const buildQueryString = (params) => {
|
|
3
|
+
const inputParams = params || {};
|
|
4
|
+
return Object.entries(inputParams).filter(([key, value]) => {
|
|
5
|
+
return key && value !== null && value !== void 0 && (Array.isArray(value) && value.length !== 0 || String(value).trim().length > 0);
|
|
6
|
+
}).map(([key, value]) => {
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
return value.map((subValue, index) => subValue ? `${key}[${index}]=${subValue}` : null).join("&");
|
|
9
|
+
}
|
|
10
|
+
return `${key}=${value}`;
|
|
11
|
+
}).join("&");
|
|
12
|
+
};
|
|
13
|
+
export const decodeRouteParams = (to) => {
|
|
14
|
+
const route = to || useRoute();
|
|
15
|
+
const path = decodeURIComponent(route.fullPath.replace(route.path, ""));
|
|
16
|
+
const params = new URLSearchParams(decodeURIComponent(path));
|
|
17
|
+
return params;
|
|
18
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const ruleValidator: () => {
|
|
2
|
+
fileValidator: (file: File | undefined, maxSizeInMB: number, types: string[]) => boolean | undefined;
|
|
3
|
+
requiredValidator: (value: unknown) => string | true;
|
|
4
|
+
requiredLocationValidator: (locations: Array<{
|
|
5
|
+
name?: string;
|
|
6
|
+
address?: string;
|
|
7
|
+
lat?: number | null;
|
|
8
|
+
lng?: number | null;
|
|
9
|
+
}> | {
|
|
10
|
+
name?: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
lat?: number | null;
|
|
13
|
+
lng?: number | null;
|
|
14
|
+
}) => string | true;
|
|
15
|
+
emailValidator: (value: unknown) => string | true;
|
|
16
|
+
alphaValidator: (value: unknown) => string | true;
|
|
17
|
+
alphaDashValidator: (value: unknown) => string | true;
|
|
18
|
+
alphaWithNumberValidator: (value: unknown) => string | true;
|
|
19
|
+
betweenValidator: (value: unknown, min: number, max: number) => string | true;
|
|
20
|
+
integerValidator: (value: unknown) => string | true;
|
|
21
|
+
numberValidator: (value: unknown) => string | true;
|
|
22
|
+
confirmedValidator: (value: string, target: string) => string | true;
|
|
23
|
+
urlValidator: (value: unknown) => string | true;
|
|
24
|
+
lengthValidator: (value: unknown, length: number) => string | true;
|
|
25
|
+
ibanValidator: (value: unknown) => string | true;
|
|
26
|
+
dateValidator: (value: unknown) => string | true;
|
|
27
|
+
regexValidator: (value: string, regex: RegExp, message?: string) => string | true;
|
|
28
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ruleValidator = void 0;
|
|
7
|
+
var _vueI18n = require("vue-i18n");
|
|
8
|
+
var _toaster = require("./toaster");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
const ruleValidator = () => {
|
|
11
|
+
const {
|
|
12
|
+
t
|
|
13
|
+
} = (0, _vueI18n.useI18n)();
|
|
14
|
+
const requiredValidator = value => {
|
|
15
|
+
if ((0, _utils.isNullOrUndefined)(value) || (0, _utils.isEmptyArray)(value) || value === false) {
|
|
16
|
+
return t("validation.required");
|
|
17
|
+
}
|
|
18
|
+
return !!String(value).trim().length || t("validation.required");
|
|
19
|
+
};
|
|
20
|
+
const requiredLocationValidator = locations => {
|
|
21
|
+
const locationArray = Array.isArray(locations) ? locations : [locations];
|
|
22
|
+
if (!locationArray || locationArray.length === 0) {
|
|
23
|
+
return t("validation.required");
|
|
24
|
+
}
|
|
25
|
+
for (const location of locationArray) {
|
|
26
|
+
if (!location || !location.address || !String(location.address).trim() || location.lat === null || typeof location.lat !== "number" || location.lng === null || typeof location.lng !== "number") {
|
|
27
|
+
return t("validation.required");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
const ibanValidator = value => {
|
|
33
|
+
if ((0, _utils.isNullOrUndefined)(value) || (0, _utils.isEmptyArray)(value) || value === false || String(value).length !== 24) {
|
|
34
|
+
return t("validation.iban");
|
|
35
|
+
}
|
|
36
|
+
return !!String(value).trim().length || t("validation.iban");
|
|
37
|
+
};
|
|
38
|
+
const emailValidator = value => {
|
|
39
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const re = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
return value.every(val => re.test(String(val))) || t("validation.email");
|
|
45
|
+
}
|
|
46
|
+
return re.test(String(value)) || t("validation.email");
|
|
47
|
+
};
|
|
48
|
+
const confirmedValidator = (value, target) => value === target || t("validation.confirmed");
|
|
49
|
+
const betweenValidator = (value, min, max) => {
|
|
50
|
+
const valueAsNumber = Number(value);
|
|
51
|
+
return Number(min) <= valueAsNumber && Number(max) >= valueAsNumber || t("validation.between", {
|
|
52
|
+
min,
|
|
53
|
+
max
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const integerValidator = value => {
|
|
57
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return value.every(val => /^-?[0-9]+$/.test(String(val))) || t("validation.integer");
|
|
62
|
+
}
|
|
63
|
+
return /^-?[0-9]+$/.test(String(value)) || t("validation.integer");
|
|
64
|
+
};
|
|
65
|
+
const numberValidator = value => {
|
|
66
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return /^\d+(\.\d+)?$/.test(String(value)) || t("validation.number");
|
|
70
|
+
};
|
|
71
|
+
const alphaValidator = value => {
|
|
72
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return /^[A-Za-z\u0600-\u06FF\s]*$/i.test(String(value)) || t("validation.alphabetic");
|
|
76
|
+
};
|
|
77
|
+
const alphaWithNumberValidator = value => {
|
|
78
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return /^[A-Za-z\u0600-\u06FF0-9\s]*$/.test(String(value)) || t("validation.alphabetic");
|
|
82
|
+
};
|
|
83
|
+
const urlValidator = value => {
|
|
84
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const re = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}[.]?/;
|
|
88
|
+
return re.test(String(value)) || t("validation.url");
|
|
89
|
+
};
|
|
90
|
+
const lengthValidator = (value, length) => {
|
|
91
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return String(value).length === length || t("validation.length", {
|
|
95
|
+
length
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const alphaDashValidator = value => {
|
|
99
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const valueAsString = String(value);
|
|
103
|
+
return /^[0-9A-Z_-]*$/i.test(valueAsString) || t("validation.alpha_dash");
|
|
104
|
+
};
|
|
105
|
+
const fileValidator = (file, maxSizeInMB, types) => {
|
|
106
|
+
if (!file) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (file.size > maxSizeInMB * 1024 * 1024) {
|
|
110
|
+
(0, _toaster.toaster)().error(t("validation.file_size_limit_exceeded", {
|
|
111
|
+
size: maxSizeInMB
|
|
112
|
+
}));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!types.includes(file.type)) {
|
|
116
|
+
(0, _toaster.toaster)().error(t("validation.file_type_not_allowed", {
|
|
117
|
+
types: types.map(type => type.split("/")[1]).join(", ")
|
|
118
|
+
}));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
const dateValidator = value => {
|
|
124
|
+
if ((0, _utils.isEmpty)(value)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
const dateString = String(value);
|
|
128
|
+
const datePattern = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(\d{4})$/;
|
|
129
|
+
if (!datePattern.test(dateString)) {
|
|
130
|
+
return t("validation.date", {
|
|
131
|
+
format: "DD/MM/YYYY"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
};
|
|
136
|
+
const regexValidator = (value, regex, message) => {
|
|
137
|
+
return regex.test(value) || message || t("validation.invalid");
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
fileValidator,
|
|
141
|
+
requiredValidator,
|
|
142
|
+
requiredLocationValidator,
|
|
143
|
+
emailValidator,
|
|
144
|
+
alphaValidator,
|
|
145
|
+
alphaDashValidator,
|
|
146
|
+
alphaWithNumberValidator,
|
|
147
|
+
betweenValidator,
|
|
148
|
+
integerValidator,
|
|
149
|
+
numberValidator,
|
|
150
|
+
confirmedValidator,
|
|
151
|
+
urlValidator,
|
|
152
|
+
lengthValidator,
|
|
153
|
+
ibanValidator,
|
|
154
|
+
dateValidator,
|
|
155
|
+
regexValidator
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
exports.ruleValidator = ruleValidator;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useI18n } from "vue-i18n";
|
|
2
|
+
import { toaster } from "./toaster.mjs";
|
|
3
|
+
import { isEmpty, isEmptyArray, isNullOrUndefined } from "./utils.mjs";
|
|
4
|
+
export const ruleValidator = () => {
|
|
5
|
+
const { t } = useI18n();
|
|
6
|
+
const requiredValidator = (value) => {
|
|
7
|
+
if (isNullOrUndefined(value) || isEmptyArray(value) || value === false) {
|
|
8
|
+
return t("validation.required");
|
|
9
|
+
}
|
|
10
|
+
return !!String(value).trim().length || t("validation.required");
|
|
11
|
+
};
|
|
12
|
+
const requiredLocationValidator = (locations) => {
|
|
13
|
+
const locationArray = Array.isArray(locations) ? locations : [locations];
|
|
14
|
+
if (!locationArray || locationArray.length === 0) {
|
|
15
|
+
return t("validation.required");
|
|
16
|
+
}
|
|
17
|
+
for (const location of locationArray) {
|
|
18
|
+
if (!location || !location.address || !String(location.address).trim() || location.lat === null || typeof location.lat !== "number" || location.lng === null || typeof location.lng !== "number") {
|
|
19
|
+
return t("validation.required");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
const ibanValidator = (value) => {
|
|
25
|
+
if (isNullOrUndefined(value) || isEmptyArray(value) || value === false || String(value).length !== 24) {
|
|
26
|
+
return t("validation.iban");
|
|
27
|
+
}
|
|
28
|
+
return !!String(value).trim().length || t("validation.iban");
|
|
29
|
+
};
|
|
30
|
+
const emailValidator = (value) => {
|
|
31
|
+
if (isEmpty(value)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const re = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value.every((val) => re.test(String(val))) || t("validation.email");
|
|
37
|
+
}
|
|
38
|
+
return re.test(String(value)) || t("validation.email");
|
|
39
|
+
};
|
|
40
|
+
const confirmedValidator = (value, target) => value === target || t("validation.confirmed");
|
|
41
|
+
const betweenValidator = (value, min, max) => {
|
|
42
|
+
const valueAsNumber = Number(value);
|
|
43
|
+
return Number(min) <= valueAsNumber && Number(max) >= valueAsNumber || t("validation.between", { min, max });
|
|
44
|
+
};
|
|
45
|
+
const integerValidator = (value) => {
|
|
46
|
+
if (isEmpty(value)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
return value.every((val) => /^-?[0-9]+$/.test(String(val))) || t("validation.integer");
|
|
51
|
+
}
|
|
52
|
+
return /^-?[0-9]+$/.test(String(value)) || t("validation.integer");
|
|
53
|
+
};
|
|
54
|
+
const numberValidator = (value) => {
|
|
55
|
+
if (isEmpty(value)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return /^\d+(\.\d+)?$/.test(String(value)) || t("validation.number");
|
|
59
|
+
};
|
|
60
|
+
const alphaValidator = (value) => {
|
|
61
|
+
if (isEmpty(value)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return /^[A-Za-z\u0600-\u06FF\s]*$/i.test(String(value)) || t("validation.alphabetic");
|
|
65
|
+
};
|
|
66
|
+
const alphaWithNumberValidator = (value) => {
|
|
67
|
+
if (isEmpty(value)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return /^[A-Za-z\u0600-\u06FF0-9\s]*$/.test(String(value)) || t("validation.alphabetic");
|
|
71
|
+
};
|
|
72
|
+
const urlValidator = (value) => {
|
|
73
|
+
if (isEmpty(value)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
const re = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}[.]?/;
|
|
77
|
+
return re.test(String(value)) || t("validation.url");
|
|
78
|
+
};
|
|
79
|
+
const lengthValidator = (value, length) => {
|
|
80
|
+
if (isEmpty(value)) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return String(value).length === length || t("validation.length", { length });
|
|
84
|
+
};
|
|
85
|
+
const alphaDashValidator = (value) => {
|
|
86
|
+
if (isEmpty(value)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const valueAsString = String(value);
|
|
90
|
+
return /^[0-9A-Z_-]*$/i.test(valueAsString) || t("validation.alpha_dash");
|
|
91
|
+
};
|
|
92
|
+
const fileValidator = (file, maxSizeInMB, types) => {
|
|
93
|
+
if (!file) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (file.size > maxSizeInMB * 1024 * 1024) {
|
|
97
|
+
toaster().error(
|
|
98
|
+
t("validation.file_size_limit_exceeded", { size: maxSizeInMB })
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!types.includes(file.type)) {
|
|
103
|
+
toaster().error(
|
|
104
|
+
t("validation.file_type_not_allowed", {
|
|
105
|
+
types: types.map((type) => type.split("/")[1]).join(", ")
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
const dateValidator = (value) => {
|
|
113
|
+
if (isEmpty(value)) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const dateString = String(value);
|
|
117
|
+
const datePattern = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(\d{4})$/;
|
|
118
|
+
if (!datePattern.test(dateString)) {
|
|
119
|
+
return t("validation.date", { format: "DD/MM/YYYY" });
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
const regexValidator = (value, regex, message) => {
|
|
124
|
+
return regex.test(value) || message || t("validation.invalid");
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
fileValidator,
|
|
128
|
+
requiredValidator,
|
|
129
|
+
requiredLocationValidator,
|
|
130
|
+
emailValidator,
|
|
131
|
+
alphaValidator,
|
|
132
|
+
alphaDashValidator,
|
|
133
|
+
alphaWithNumberValidator,
|
|
134
|
+
betweenValidator,
|
|
135
|
+
integerValidator,
|
|
136
|
+
numberValidator,
|
|
137
|
+
confirmedValidator,
|
|
138
|
+
urlValidator,
|
|
139
|
+
lengthValidator,
|
|
140
|
+
ibanValidator,
|
|
141
|
+
dateValidator,
|
|
142
|
+
regexValidator
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchError } from 'ofetch';
|
|
2
|
+
import type { ErrorResponse } from '../types';
|
|
3
|
+
export declare const toaster: () => {
|
|
4
|
+
success: (message?: string) => void;
|
|
5
|
+
error: (message?: string) => void;
|
|
6
|
+
successLang: (message: string) => void;
|
|
7
|
+
errorLang: (message: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function responseAlert(): {
|
|
10
|
+
showAlert: (response?: FetchError<ErrorResponse>) => void;
|
|
11
|
+
showValidationAlert: (response?: FetchError<ErrorResponse>) => void;
|
|
12
|
+
};
|