@winchsa/ui 0.1.33 → 0.1.35
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/dist/components/Breadcrumbs.d.vue.ts +7 -0
- package/dist/components/Breadcrumbs.vue +46 -0
- package/dist/components/Breadcrumbs.vue.d.ts +7 -0
- package/dist/components/CustomizerSection.d.vue.ts +17 -0
- package/dist/components/CustomizerSection.vue +19 -0
- package/dist/components/CustomizerSection.vue.d.ts +17 -0
- package/dist/components/DialogCloseBtn.d.vue.ts +7 -0
- package/dist/components/DialogCloseBtn.vue +20 -0
- package/dist/components/DialogCloseBtn.vue.d.ts +7 -0
- package/dist/components/Drawer.d.vue.ts +28 -0
- package/dist/components/Drawer.vue +60 -0
- package/dist/components/Drawer.vue.d.ts +28 -0
- package/dist/components/IconBtn.d.vue.ts +18 -0
- package/dist/components/IconBtn.vue +24 -0
- package/dist/components/IconBtn.vue.d.ts +18 -0
- package/dist/components/LoadingBar.d.vue.ts +6 -0
- package/dist/components/LoadingBar.vue +31 -0
- package/dist/components/LoadingBar.vue.d.ts +6 -0
- package/dist/components/LoadingDialog.d.vue.ts +12 -0
- package/dist/components/LoadingDialog.vue +41 -0
- package/dist/components/LoadingDialog.vue.d.ts +12 -0
- package/dist/components/LoadingItem.d.vue.ts +25 -0
- package/dist/components/LoadingItem.vue +66 -0
- package/dist/components/LoadingItem.vue.d.ts +25 -0
- package/dist/components/Modal.d.vue.ts +50 -0
- package/dist/components/Modal.vue +155 -0
- package/dist/components/Modal.vue.d.ts +50 -0
- package/dist/components/MoreBtn.d.vue.ts +17 -0
- package/dist/components/MoreBtn.vue +28 -0
- package/dist/components/MoreBtn.vue.d.ts +17 -0
- package/dist/components/ScrollToTop.d.vue.ts +3 -0
- package/dist/components/ScrollToTop.vue +39 -0
- package/dist/components/ScrollToTop.vue.d.ts +3 -0
- package/dist/components/SiteTitle.d.vue.ts +3 -0
- package/dist/components/SiteTitle.vue +14 -0
- package/dist/components/SiteTitle.vue.d.ts +3 -0
- package/dist/components/Toaster.d.vue.ts +6 -0
- package/dist/components/Toaster.vue +19 -0
- package/dist/components/Toaster.vue.d.ts +6 -0
- package/dist/components/cards/AppCard.d.vue.ts +18 -0
- package/dist/components/cards/AppCard.vue +45 -0
- package/dist/components/cards/AppCard.vue.d.ts +18 -0
- package/dist/components/cards/AppCardActions.d.vue.ts +33 -0
- package/dist/components/cards/AppCardActions.vue +126 -0
- package/dist/components/cards/AppCardActions.vue.d.ts +33 -0
- package/dist/components/cards/CardStatisticsHorizontal.d.vue.ts +9 -0
- package/dist/components/cards/CardStatisticsHorizontal.vue +29 -0
- package/dist/components/cards/CardStatisticsHorizontal.vue.d.ts +9 -0
- package/dist/components/cards/CheckboxesCard.d.vue.ts +18 -0
- package/dist/components/cards/CheckboxesCard.vue +108 -0
- package/dist/components/cards/CheckboxesCard.vue.d.ts +18 -0
- package/dist/components/cards/HeaderCard.d.vue.ts +9 -0
- package/dist/components/cards/HeaderCard.vue +31 -0
- package/dist/components/cards/HeaderCard.vue.d.ts +9 -0
- package/dist/components/cards/ImageCard.d.vue.ts +33 -0
- package/dist/components/cards/ImageCard.vue +73 -0
- package/dist/components/cards/ImageCard.vue.d.ts +33 -0
- package/dist/components/cards/InputCard.d.vue.ts +21 -0
- package/dist/components/cards/InputCard.vue +60 -0
- package/dist/components/cards/InputCard.vue.d.ts +21 -0
- package/dist/components/cards/StaticCard.d.vue.ts +21 -0
- package/dist/components/cards/StaticCard.vue +37 -0
- package/dist/components/cards/StaticCard.vue.d.ts +21 -0
- package/dist/components/forms/Accordion.d.vue.ts +19 -0
- package/dist/components/forms/Accordion.vue +43 -0
- package/dist/components/forms/Accordion.vue.d.ts +19 -0
- package/dist/components/forms/AppBarSearch.d.vue.ts +43 -0
- package/dist/components/forms/AppBarSearch.vue +345 -0
- package/dist/components/forms/AppBarSearch.vue.d.ts +43 -0
- package/dist/components/forms/AppCombobox.d.vue.ts +13 -0
- package/dist/components/forms/AppCombobox.vue +60 -0
- package/dist/components/forms/AppCombobox.vue.d.ts +13 -0
- package/dist/components/forms/AppDrawerHeaderSection.d.vue.ts +20 -0
- package/dist/components/forms/AppDrawerHeaderSection.vue +21 -0
- package/dist/components/forms/AppDrawerHeaderSection.vue.d.ts +20 -0
- package/dist/components/forms/AppLabel.d.vue.ts +24 -0
- package/dist/components/forms/AppLabel.vue +47 -0
- package/dist/components/forms/AppLabel.vue.d.ts +24 -0
- package/dist/components/forms/AppLink.d.vue.ts +19 -0
- package/dist/components/forms/AppLink.vue +50 -0
- package/dist/components/forms/AppLink.vue.d.ts +19 -0
- package/dist/components/forms/AppNumberField.d.vue.ts +20 -0
- package/dist/components/forms/AppNumberField.vue +79 -0
- package/dist/components/forms/AppNumberField.vue.d.ts +20 -0
- package/dist/components/forms/AppOtpInput.d.vue.ts +13 -0
- package/dist/components/forms/AppOtpInput.vue +84 -0
- package/dist/components/forms/AppOtpInput.vue.d.ts +13 -0
- package/dist/components/forms/AppSearchHeader.d.vue.ts +8 -0
- package/dist/components/forms/AppSearchHeader.vue +72 -0
- package/dist/components/forms/AppSearchHeader.vue.d.ts +8 -0
- package/dist/components/forms/AppSelect.d.vue.ts +21 -0
- package/dist/components/forms/AppSelect.vue +94 -0
- package/dist/components/forms/AppSelect.vue.d.ts +21 -0
- package/dist/components/forms/AppStepper.d.vue.ts +21 -0
- package/dist/components/forms/AppStepper.vue +232 -0
- package/dist/components/forms/AppStepper.vue.d.ts +21 -0
- package/dist/components/forms/AppSwitch.d.vue.ts +18 -0
- package/dist/components/forms/AppSwitch.vue +60 -0
- package/dist/components/forms/AppSwitch.vue.d.ts +18 -0
- package/dist/components/forms/AppTextField.d.vue.ts +17 -0
- package/dist/components/forms/AppTextField.vue +62 -0
- package/dist/components/forms/AppTextField.vue.d.ts +17 -0
- package/dist/components/forms/AppTextarea.d.vue.ts +17 -0
- package/dist/components/forms/AppTextarea.vue +65 -0
- package/dist/components/forms/AppTextarea.vue.d.ts +17 -0
- package/dist/components/forms/AttachmentCropperInput.d.vue.ts +18 -0
- package/dist/components/forms/AttachmentCropperInput.vue +227 -0
- package/dist/components/forms/AttachmentCropperInput.vue.d.ts +18 -0
- package/dist/components/forms/AttachmentInput.d.vue.ts +16 -0
- package/dist/components/forms/AttachmentInput.vue +116 -0
- package/dist/components/forms/AttachmentInput.vue.d.ts +16 -0
- package/dist/components/forms/AutocompleteInput.d.vue.ts +86 -0
- package/dist/components/forms/AutocompleteInput.vue +778 -0
- package/dist/components/forms/AutocompleteInput.vue.d.ts +86 -0
- package/dist/components/forms/BankSelect.d.vue.ts +21 -0
- package/dist/components/forms/BankSelect.vue +43 -0
- package/dist/components/forms/BankSelect.vue.d.ts +21 -0
- package/dist/components/forms/BaseButton.d.vue.ts +20 -0
- package/dist/components/forms/BaseButton.vue +42 -0
- package/dist/components/forms/BaseButton.vue.d.ts +20 -0
- package/dist/components/forms/CounterInput.d.vue.ts +13 -0
- package/dist/components/forms/CounterInput.vue +71 -0
- package/dist/components/forms/CounterInput.vue.d.ts +13 -0
- package/dist/components/forms/CustomCheckboxes.d.vue.ts +25 -0
- package/dist/components/forms/CustomCheckboxes.vue +69 -0
- package/dist/components/forms/CustomCheckboxes.vue.d.ts +25 -0
- package/dist/components/forms/CustomCheckboxesWithIcon.d.vue.ts +25 -0
- package/dist/components/forms/CustomCheckboxesWithIcon.vue +80 -0
- package/dist/components/forms/CustomCheckboxesWithIcon.vue.d.ts +25 -0
- package/dist/components/forms/CustomCheckboxesWithImage.d.vue.ts +16 -0
- package/dist/components/forms/CustomCheckboxesWithImage.vue +67 -0
- package/dist/components/forms/CustomCheckboxesWithImage.vue.d.ts +16 -0
- package/dist/components/forms/CustomRadios.d.vue.ts +25 -0
- package/dist/components/forms/CustomRadios.vue +69 -0
- package/dist/components/forms/CustomRadios.vue.d.ts +25 -0
- package/dist/components/forms/CustomRadiosWithIcon.d.vue.ts +28 -0
- package/dist/components/forms/CustomRadiosWithIcon.vue +98 -0
- package/dist/components/forms/CustomRadiosWithIcon.vue.d.ts +28 -0
- package/dist/components/forms/CustomRadiosWithImage.d.vue.ts +35 -0
- package/dist/components/forms/CustomRadiosWithImage.vue +69 -0
- package/dist/components/forms/CustomRadiosWithImage.vue.d.ts +35 -0
- package/dist/components/forms/DatePicker.d.vue.ts +29 -0
- package/dist/components/forms/DatePicker.vue +392 -0
- package/dist/components/forms/DatePicker.vue.d.ts +29 -0
- package/dist/components/forms/DatePickerRange.d.vue.ts +24 -0
- package/dist/components/forms/DatePickerRange.vue +127 -0
- package/dist/components/forms/DatePickerRange.vue.d.ts +24 -0
- package/dist/components/forms/DraggedUploadFile.d.vue.ts +11 -0
- package/dist/components/forms/DraggedUploadFile.vue +120 -0
- package/dist/components/forms/DraggedUploadFile.vue.d.ts +11 -0
- package/dist/components/forms/ImageCardInput.d.vue.ts +35 -0
- package/dist/components/forms/ImageCardInput.vue +234 -0
- package/dist/components/forms/ImageCardInput.vue.d.ts +35 -0
- package/dist/components/forms/InputValidationWrapper.d.vue.ts +26 -0
- package/dist/components/forms/InputValidationWrapper.vue +24 -0
- package/dist/components/forms/InputValidationWrapper.vue.d.ts +26 -0
- package/dist/components/forms/LicensePlateInput.d.vue.ts +21 -0
- package/dist/components/forms/LicensePlateInput.vue +175 -0
- package/dist/components/forms/LicensePlateInput.vue.d.ts +21 -0
- package/dist/components/forms/ManualDate.d.vue.ts +20 -0
- package/dist/components/forms/ManualDate.vue +264 -0
- package/dist/components/forms/ManualDate.vue.d.ts +20 -0
- package/dist/components/forms/MobileInput.d.vue.ts +25 -0
- package/dist/components/forms/MobileInput.vue +118 -0
- package/dist/components/forms/MobileInput.vue.d.ts +25 -0
- package/dist/components/forms/PasswordInput.d.vue.ts +11 -0
- package/dist/components/forms/PasswordInput.vue +29 -0
- package/dist/components/forms/PasswordInput.vue.d.ts +11 -0
- package/dist/components/forms/RangeInput.d.vue.ts +10 -0
- package/dist/components/forms/RangeInput.vue +48 -0
- package/dist/components/forms/RangeInput.vue.d.ts +10 -0
- package/dist/components/forms/Tabs.d.vue.ts +23 -0
- package/dist/components/forms/Tabs.vue +35 -0
- package/dist/components/forms/Tabs.vue.d.ts +23 -0
- package/dist/components/forms/TimePicker.d.vue.ts +18 -0
- package/dist/components/forms/TimePicker.vue +370 -0
- package/dist/components/forms/TimePicker.vue.d.ts +18 -0
- package/dist/components/table/DataTable.d.vue.ts +70 -0
- package/dist/components/table/DataTable.vue +361 -0
- package/dist/components/table/DataTable.vue.d.ts +70 -0
- package/dist/components/table/EditableDataTable.d.vue.ts +21 -0
- package/dist/components/table/EditableDataTable.vue +330 -0
- package/dist/components/table/EditableDataTable.vue.d.ts +21 -0
- package/dist/components/table/EditableDataTableRow.d.vue.ts +20 -0
- package/dist/components/table/EditableDataTableRow.vue +252 -0
- package/dist/components/table/EditableDataTableRow.vue.d.ts +20 -0
- package/dist/components/table/FilterGenerator.d.vue.ts +13 -0
- package/dist/components/table/FilterGenerator.vue +231 -0
- package/dist/components/table/FilterGenerator.vue.d.ts +13 -0
- package/dist/components/table/StaticTable.d.vue.ts +34 -0
- package/dist/components/table/StaticTable.vue +152 -0
- package/dist/components/table/StaticTable.vue.d.ts +34 -0
- package/dist/components/table/TablePagination.d.vue.ts +15 -0
- package/dist/components/table/TablePagination.vue +73 -0
- package/dist/components/table/TablePagination.vue.d.ts +15 -0
- package/dist/composables/useIsMobile.d.ts +1 -0
- package/dist/composables/useIsMobile.js +10 -0
- package/dist/composables/useIsMobile.mjs +4 -0
- package/dist/composables/useTableFilters.d.ts +23 -0
- package/dist/composables/useTableFilters.js +197 -0
- package/dist/composables/useTableFilters.mjs +184 -0
- package/dist/images/avatar.png +0 -0
- package/dist/images/sa.svg +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +454 -0
- package/dist/index.mjs +130 -0
- package/dist/lang/ar.json +54 -0
- package/dist/lang/en.json +54 -0
- package/dist/styles/assets/scss/variables/_template.scss +1 -0
- package/dist/styles/assets/scss/variables/_vuetify.scss +1 -0
- package/dist/styles/core/base/_components.scss +164 -0
- package/dist/styles/core/base/_dark.scss +16 -0
- package/dist/styles/core/base/_default-layout-w-vertical-nav.scss +106 -0
- package/dist/styles/core/base/_default-layout.scss +16 -0
- package/dist/styles/core/base/_index.scss +47 -0
- package/dist/styles/core/base/_layouts.scss +63 -0
- package/dist/styles/core/base/_misc.scss +20 -0
- package/dist/styles/core/base/_mixins.scss +84 -0
- package/dist/styles/core/base/_route-transitions.scss +70 -0
- package/dist/styles/core/base/_utilities.scss +418 -0
- package/dist/styles/core/base/_utils.scss +100 -0
- package/dist/styles/core/base/_variables.scss +190 -0
- package/dist/styles/core/base/_vertical-nav.scss +264 -0
- package/dist/styles/core/base/libs/_perfect-scrollbar.scss +35 -0
- package/dist/styles/core/base/libs/vuetify/_index.scss +1 -0
- package/dist/styles/core/base/libs/vuetify/_overrides.scss +380 -0
- package/dist/styles/core/base/libs/vuetify/_variables.scss +48 -0
- package/dist/styles/core/base/placeholders/_default-layout-vertical-nav.scss +48 -0
- package/dist/styles/core/base/placeholders/_default-layout.scss +3 -0
- package/dist/styles/core/base/placeholders/_index.scss +5 -0
- package/dist/styles/core/base/placeholders/_misc.scss +7 -0
- package/dist/styles/core/base/placeholders/_nav.scss +26 -0
- package/dist/styles/core/base/placeholders/_vertical-nav.scss +84 -0
- package/dist/styles/core/base/skins/_bordered.scss +60 -0
- package/dist/styles/core/base/skins/_index.scss +1 -0
- package/dist/styles/core/template/_components.scss +1044 -0
- package/dist/styles/core/template/_default-layout-w-vertical-nav.scss +20 -0
- package/dist/styles/core/template/_utilities.scss +20 -0
- package/dist/styles/core/template/_variables.scss +67 -0
- package/dist/styles/core/template/_vertical-nav.scss +41 -0
- package/dist/styles/core/template/index.css +18786 -0
- package/dist/styles/core/template/index.scss +15 -0
- package/dist/styles/core/template/libs/vuetify/_variables.scss +464 -0
- package/dist/styles/core/template/libs/vuetify/index.css +739 -0
- package/dist/styles/core/template/libs/vuetify/index.scss +1 -0
- package/dist/styles/core/template/pages/misc.css +16 -0
- package/dist/styles/core/template/pages/misc.scss +20 -0
- package/dist/styles/core/template/placeholders/_default-layout-vertical-nav.scss +9 -0
- package/dist/styles/core/template/placeholders/_index.scss +3 -0
- package/dist/styles/core/template/placeholders/_nav.scss +15 -0
- package/dist/styles/core/template/placeholders/_vertical-nav.scss +18 -0
- package/dist/styles/core/template/skins/_bordered.scss +36 -0
- package/dist/styles/core/template/skins/_index.scss +1 -0
- package/dist/styles/layouts/_classes.scss +3 -0
- package/dist/styles/layouts/_dashboard-layout.scss +43 -0
- package/dist/styles/layouts/_global.scss +10 -0
- package/dist/styles/layouts/_mixins.scss +28 -0
- package/dist/styles/layouts/_placeholders.scss +53 -0
- package/dist/styles/layouts/_rtl.scss +7 -0
- package/dist/styles/layouts/_variables.scss +22 -0
- package/dist/styles/layouts/index.css +14 -0
- package/dist/styles/layouts/index.scss +2 -0
- package/dist/types.d.ts +218 -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 +53 -0
- package/dist/utils/client.mjs +39 -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/hijriDate.d.ts +58 -0
- package/dist/utils/hijriDate.js +168 -0
- package/dist/utils/hijriDate.mjs +1951 -0
- package/dist/utils/i18n.d.ts +8 -0
- package/dist/utils/i18n.js +36 -0
- package/dist/utils/i18n.mjs +27 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +115 -0
- package/dist/utils/index.mjs +10 -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 +41 -0
- package/dist/utils/ruleValidator.js +210 -0
- package/dist/utils/ruleValidator.mjs +195 -0
- package/dist/utils/toaster.d.ts +12 -0
- package/dist/utils/toaster.js +68 -0
- package/dist/utils/toaster.mjs +58 -0
- package/dist/utils/utils.d.ts +9 -0
- package/dist/utils/utils.js +84 -0
- package/dist/utils/utils.mjs +67 -0
- package/package.json +67 -67
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import Cropper from "cropperjs";
|
|
3
|
+
import { ref, computed, watch, nextTick } from "vue";
|
|
4
|
+
import { useI18n } from "vue-i18n";
|
|
5
|
+
import { VIcon, VBtn, VValidation, VSlider } from "vuetify/components";
|
|
6
|
+
import { ruleValidator } from "../../utils/ruleValidator";
|
|
7
|
+
import Modal from "../Modal.vue";
|
|
8
|
+
import { generateUniqueId } from "../../utils/utils";
|
|
9
|
+
import BaseButton from "./BaseButton.vue";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
validTypes: { type: Array, required: false, default: () => ["image/png", "image/jpeg", "image/jpg"] },
|
|
12
|
+
rules: { type: Array, required: false },
|
|
13
|
+
multiple: { type: Boolean, required: false, default: false },
|
|
14
|
+
modelValue: { type: [Object, Array, null], required: true },
|
|
15
|
+
sizeInMB: { type: Number, required: false, default: 3 },
|
|
16
|
+
showPreview: { type: Boolean, required: false, default: true },
|
|
17
|
+
cropWidth: { type: Number, required: false, default: 120 },
|
|
18
|
+
cropHeight: { type: Number, required: false, default: 40 }
|
|
19
|
+
});
|
|
20
|
+
const emit = defineEmits(["update:model-value"]);
|
|
21
|
+
const { locale } = useI18n();
|
|
22
|
+
const { fileValidator } = ruleValidator();
|
|
23
|
+
const imageUploadInput = ref(null);
|
|
24
|
+
const attachments = ref([]);
|
|
25
|
+
const cropperDialog = ref(false);
|
|
26
|
+
const cropImageSrc = ref(null);
|
|
27
|
+
const selectedFile = ref(null);
|
|
28
|
+
const cropperInstance = ref(null);
|
|
29
|
+
const zoomLevel = ref(1);
|
|
30
|
+
const initialZoom = ref(1);
|
|
31
|
+
const cropperImage = ref(null);
|
|
32
|
+
const allowMultipleAttachments = computed(
|
|
33
|
+
() => props.multiple || !props.showPreview ? true : attachments.value?.length === 0
|
|
34
|
+
);
|
|
35
|
+
const onImageChanged = (e) => {
|
|
36
|
+
const target = e.target;
|
|
37
|
+
const file = target.files?.[0];
|
|
38
|
+
const isValid = fileValidator(file, props.sizeInMB, props.validTypes);
|
|
39
|
+
if (isValid && file) {
|
|
40
|
+
selectedFile.value = file;
|
|
41
|
+
cropImageSrc.value = URL.createObjectURL(file);
|
|
42
|
+
cropperDialog.value = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const initCropper = () => {
|
|
46
|
+
if (cropperInstance.value) {
|
|
47
|
+
cropperInstance.value.destroy();
|
|
48
|
+
}
|
|
49
|
+
if (cropperImage.value) {
|
|
50
|
+
cropperInstance.value = new Cropper(cropperImage.value, {
|
|
51
|
+
viewMode: 1,
|
|
52
|
+
responsive: true,
|
|
53
|
+
zoomable: true,
|
|
54
|
+
scalable: false,
|
|
55
|
+
movable: true,
|
|
56
|
+
wheelZoomRatio: 0,
|
|
57
|
+
zoomOnWheel: false,
|
|
58
|
+
ready() {
|
|
59
|
+
const data = cropperInstance.value?.getImageData();
|
|
60
|
+
initialZoom.value = data ? Math.min(data.width / data.naturalWidth, data.height / data.naturalHeight) : 1;
|
|
61
|
+
zoomLevel.value = initialZoom.value;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const closeCropper = () => {
|
|
67
|
+
cropperDialog.value = false;
|
|
68
|
+
selectedFile.value = null;
|
|
69
|
+
if (imageUploadInput.value) {
|
|
70
|
+
imageUploadInput.value.value = "";
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const resizeCanvas = (canvas, width, height) => {
|
|
74
|
+
const offscreenCanvas = document.createElement("canvas");
|
|
75
|
+
offscreenCanvas.width = width;
|
|
76
|
+
offscreenCanvas.height = height;
|
|
77
|
+
const ctx = offscreenCanvas.getContext("2d");
|
|
78
|
+
if (ctx) {
|
|
79
|
+
ctx.drawImage(canvas, 0, 0, width, height);
|
|
80
|
+
}
|
|
81
|
+
return offscreenCanvas;
|
|
82
|
+
};
|
|
83
|
+
const cropImage = () => {
|
|
84
|
+
if (!cropperInstance.value) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const targetWidth = props.cropWidth;
|
|
88
|
+
const targetHeight = props.cropHeight;
|
|
89
|
+
let canvas = cropperInstance.value.getCroppedCanvas();
|
|
90
|
+
if (!canvas) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (canvas.width !== targetWidth || canvas.height !== targetHeight) {
|
|
94
|
+
canvas = resizeCanvas(canvas, targetWidth, targetHeight);
|
|
95
|
+
}
|
|
96
|
+
canvas.toBlob((blob) => {
|
|
97
|
+
if (blob && selectedFile.value) {
|
|
98
|
+
const croppedFile = new File([blob], selectedFile.value.name, { type: selectedFile.value.type });
|
|
99
|
+
const attachment = {
|
|
100
|
+
id: generateUniqueId(),
|
|
101
|
+
src: URL.createObjectURL(croppedFile),
|
|
102
|
+
file: croppedFile
|
|
103
|
+
};
|
|
104
|
+
attachments.value.push(attachment);
|
|
105
|
+
emit("update:model-value", props.multiple ? attachments.value : attachment);
|
|
106
|
+
cropperDialog.value = false;
|
|
107
|
+
}
|
|
108
|
+
}, selectedFile.value?.type);
|
|
109
|
+
};
|
|
110
|
+
const removeImageCopy = (id) => {
|
|
111
|
+
const index = attachments.value.findIndex((attachment) => attachment.id === id);
|
|
112
|
+
if (index > -1) {
|
|
113
|
+
attachments.value.splice(index, 1);
|
|
114
|
+
emit("update:model-value", props.multiple ? attachments.value : attachments.value[0] || null);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
watch(zoomLevel, async (newZoom) => {
|
|
118
|
+
await nextTick(() => {
|
|
119
|
+
if (cropperInstance.value) {
|
|
120
|
+
cropperInstance.value.zoomTo(newZoom);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<template>
|
|
127
|
+
<div class="d-flex flex-column">
|
|
128
|
+
<div class="d-flex align-center gap-3">
|
|
129
|
+
<BaseButton
|
|
130
|
+
v-if="allowMultipleAttachments"
|
|
131
|
+
size="48"
|
|
132
|
+
color="gray-200"
|
|
133
|
+
elevation="0"
|
|
134
|
+
class="app-z-40"
|
|
135
|
+
@click="imageUploadInput?.click()"
|
|
136
|
+
>
|
|
137
|
+
<VIcon size="28" icon="tabler-upload" color="on-gray-200" />
|
|
138
|
+
</BaseButton>
|
|
139
|
+
|
|
140
|
+
<TransitionGroup
|
|
141
|
+
v-if="showPreview"
|
|
142
|
+
tag="div"
|
|
143
|
+
class="d-flex align-center flex-wrap sb-w-full gap-3"
|
|
144
|
+
enter-active-class="slide-in-right"
|
|
145
|
+
leave-active-class="slide-out-right"
|
|
146
|
+
mode="out-in"
|
|
147
|
+
>
|
|
148
|
+
<div
|
|
149
|
+
v-for="attachment in attachments"
|
|
150
|
+
:key="attachment.id"
|
|
151
|
+
class="app-w-48px app-h-48px bg-gray-50 app-rounded-6 position-relative d-flex align-center justify-center"
|
|
152
|
+
>
|
|
153
|
+
<img v-if="attachment.src" :src="attachment.src" class="app-rounded-6 overflow-hidden app-w-48px app-h-48px">
|
|
154
|
+
<VIcon v-else color="gray-600">
|
|
155
|
+
tabler-pdf
|
|
156
|
+
</VIcon>
|
|
157
|
+
<VBtn
|
|
158
|
+
icon="tabler-x"
|
|
159
|
+
size="20"
|
|
160
|
+
color="red"
|
|
161
|
+
small
|
|
162
|
+
class="d-flex align-center justify-center position-absolute app-top--8px app-z-10"
|
|
163
|
+
:class="locale === 'en' ? 'app-right--8px' : 'app-left--8px'"
|
|
164
|
+
@click="removeImageCopy(attachment.id)"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
</TransitionGroup>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<VValidation
|
|
171
|
+
v-slot="{ errorMessages: validationErrors, isValid }"
|
|
172
|
+
ref="attachmentInputRef"
|
|
173
|
+
v-model="attachments"
|
|
174
|
+
:rules="rules"
|
|
175
|
+
validate-on="submit lazy"
|
|
176
|
+
>
|
|
177
|
+
<div class="d-flex flex-column">
|
|
178
|
+
<input
|
|
179
|
+
ref="imageUploadInput"
|
|
180
|
+
class="d-none"
|
|
181
|
+
type="file"
|
|
182
|
+
:disabled="!allowMultipleAttachments"
|
|
183
|
+
:accept="validTypes?.join(',')"
|
|
184
|
+
@change="onImageChanged($event)"
|
|
185
|
+
>
|
|
186
|
+
<VMessages class="mt-1 d-block" :messages="validationErrors.value" :active="isValid.value === false" />
|
|
187
|
+
</div>
|
|
188
|
+
</VValidation>
|
|
189
|
+
|
|
190
|
+
<!-- Cropper Dialog -->
|
|
191
|
+
<Modal
|
|
192
|
+
v-model="cropperDialog"
|
|
193
|
+
persistent
|
|
194
|
+
width="500"
|
|
195
|
+
:has-icon="false"
|
|
196
|
+
@save="cropImage"
|
|
197
|
+
@cancel="closeCropper"
|
|
198
|
+
>
|
|
199
|
+
<img
|
|
200
|
+
v-if="cropImageSrc"
|
|
201
|
+
ref="cropperImage"
|
|
202
|
+
:src="cropImageSrc"
|
|
203
|
+
style="max-width: 100%; margin-bottom: 1px;"
|
|
204
|
+
@load="initCropper"
|
|
205
|
+
>
|
|
206
|
+
|
|
207
|
+
<template #additional-actions>
|
|
208
|
+
<VSlider
|
|
209
|
+
v-model="zoomLevel"
|
|
210
|
+
class="pa-3 mt-2 flex-grow-1"
|
|
211
|
+
:min="initialZoom"
|
|
212
|
+
:max="initialZoom * 3"
|
|
213
|
+
step="0.1"
|
|
214
|
+
density="comfortable"
|
|
215
|
+
track-size="6"
|
|
216
|
+
thumb-size="18"
|
|
217
|
+
prepend-icon="tabler-minus"
|
|
218
|
+
append-icon="tabler-plus"
|
|
219
|
+
/>
|
|
220
|
+
</template>
|
|
221
|
+
</Modal>
|
|
222
|
+
</div>
|
|
223
|
+
</template>
|
|
224
|
+
|
|
225
|
+
<style scoped>
|
|
226
|
+
@import "cropperjs/dist/cropper.css";:deep(.cropper-container){width:auto!important}:global(.cropper-line),:global(.cropper-point){background-color:rgb(var(--v-theme-primary))!important}:global(.cropper-view-box){outline-color:rgba(var(--v-theme-primary),.75)!important}
|
|
227
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Attachment } from '../../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
validTypes?: string[];
|
|
4
|
+
rules?: ((value: unknown) => typeof value | string)[];
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
modelValue: Attachment | Attachment[] | null;
|
|
7
|
+
sizeInMB?: number;
|
|
8
|
+
showPreview?: boolean;
|
|
9
|
+
cropWidth?: number;
|
|
10
|
+
cropHeight?: number;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
+
"update:model-value": (value: Attachment | Attachment[]) => any;
|
|
14
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
"onUpdate:model-value"?: ((value: Attachment | Attachment[]) => any) | undefined;
|
|
16
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Attachment } from '../../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
validTypes?: string[];
|
|
4
|
+
rules?: ((value: unknown) => typeof value | string)[];
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
modelValue: Attachment | Attachment[] | null;
|
|
7
|
+
sizeInMB?: number;
|
|
8
|
+
showPreview?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
|
+
"update:model-value": (value: Attachment | Attachment[]) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
"onUpdate:model-value"?: ((value: Attachment | Attachment[]) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { VBtn, VIcon, VValidation, VMessages } from "vuetify/components";
|
|
3
|
+
import { ref, computed } from "vue";
|
|
4
|
+
import { useI18n } from "vue-i18n";
|
|
5
|
+
import { generateUniqueId } from "../../utils/utils";
|
|
6
|
+
import { ruleValidator } from "../../utils/ruleValidator";
|
|
7
|
+
import BaseButton from "./BaseButton.vue";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
validTypes: { type: Array, required: false, default: () => ["image/png", "image/jpeg", "image/jpg"] },
|
|
10
|
+
rules: { type: Array, required: false },
|
|
11
|
+
multiple: { type: Boolean, required: false, default: false },
|
|
12
|
+
modelValue: { type: [Object, Array, null], required: true },
|
|
13
|
+
sizeInMB: { type: Number, required: false, default: 3 },
|
|
14
|
+
showPreview: { type: Boolean, required: false, default: true }
|
|
15
|
+
});
|
|
16
|
+
const emit = defineEmits(["update:model-value"]);
|
|
17
|
+
const { locale } = useI18n();
|
|
18
|
+
const { fileValidator } = ruleValidator();
|
|
19
|
+
const imageUploadInput = ref(null);
|
|
20
|
+
const attachments = ref([]);
|
|
21
|
+
const allowMultipleAttachments = computed(() => props.multiple || !props.showPreview ? true : attachments.value?.length === 0 && attachments.value?.length < 1);
|
|
22
|
+
const onImageChanged = (e, validate) => {
|
|
23
|
+
const target = e.target;
|
|
24
|
+
const file = target.files?.[0];
|
|
25
|
+
const isVaild = fileValidator(file, props.sizeInMB, props.validTypes);
|
|
26
|
+
if (isVaild && file) {
|
|
27
|
+
const attachment = {
|
|
28
|
+
id: generateUniqueId(),
|
|
29
|
+
src: file.type !== "application/pdf" ? createImageUrl(file) : "",
|
|
30
|
+
file
|
|
31
|
+
};
|
|
32
|
+
attachments.value.push(attachment);
|
|
33
|
+
validate();
|
|
34
|
+
emit("update:model-value", props.multiple ? attachments.value : attachments.value[attachments.value.length - 1]);
|
|
35
|
+
if (imageUploadInput.value) {
|
|
36
|
+
imageUploadInput.value.value = "";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function createImageUrl(file) {
|
|
41
|
+
const imageUrl = URL.createObjectURL(file);
|
|
42
|
+
return imageUrl;
|
|
43
|
+
}
|
|
44
|
+
const removeImageCopy = (id) => {
|
|
45
|
+
const attachmentIndex = attachments.value.findIndex((attachment) => attachment.id === id);
|
|
46
|
+
if (attachmentIndex > -1) {
|
|
47
|
+
attachments.value.splice(attachmentIndex, 1);
|
|
48
|
+
emit("update:model-value", props.multiple ? attachments.value : attachments.value[0]);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div class="d-flex flex-column">
|
|
55
|
+
<div class="d-flex align-center gap-3">
|
|
56
|
+
<BaseButton
|
|
57
|
+
v-if="allowMultipleAttachments"
|
|
58
|
+
size="48"
|
|
59
|
+
color="gray-200"
|
|
60
|
+
elevation="0"
|
|
61
|
+
class="app-z-40"
|
|
62
|
+
@click="imageUploadInput?.click()"
|
|
63
|
+
>
|
|
64
|
+
<VIcon
|
|
65
|
+
size="28"
|
|
66
|
+
icon="tabler-upload"
|
|
67
|
+
color="on-gray-200"
|
|
68
|
+
/>
|
|
69
|
+
</BaseButton>
|
|
70
|
+
<TransitionGroup
|
|
71
|
+
v-if="showPreview"
|
|
72
|
+
tag="div"
|
|
73
|
+
class="d-flex align-center flex-wrap sb-w-full gap-3"
|
|
74
|
+
enter-active-class="slide-in-right"
|
|
75
|
+
leave-active-class="slide-out-right"
|
|
76
|
+
mode="out-in"
|
|
77
|
+
>
|
|
78
|
+
<div v-for="attachment in attachments" :key="attachment.id" class="app-w-48px app-h-48px bg-gray-50 app-rounded-6 position-relative d-flex align-center justify-center">
|
|
79
|
+
<img v-if="attachment.src" :src="attachment.src" class="app-rounded-6 overflow-hidden app-w-48px app-h-48px">
|
|
80
|
+
<VIcon v-else color="gray-600">
|
|
81
|
+
tabler-pdf
|
|
82
|
+
</VIcon>
|
|
83
|
+
<VBtn
|
|
84
|
+
icon="tabler-x"
|
|
85
|
+
size="20"
|
|
86
|
+
color="red"
|
|
87
|
+
small
|
|
88
|
+
class="d-flex align-center justify-center position-absolute app-top--8px app-z-10"
|
|
89
|
+
:class="locale === 'en' ? 'app-right--8px' : 'app-left--8px'"
|
|
90
|
+
@click="removeImageCopy(attachment.id)"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</TransitionGroup>
|
|
94
|
+
</div>
|
|
95
|
+
<VValidation
|
|
96
|
+
v-slot="{ errorMessages: validationErrors, isValid, validate }"
|
|
97
|
+
ref="attachmentInputRef"
|
|
98
|
+
v-model="attachments"
|
|
99
|
+
:rules="rules"
|
|
100
|
+
validate-on="submit lazy"
|
|
101
|
+
>
|
|
102
|
+
<div class="d-flex flex-column">
|
|
103
|
+
<input
|
|
104
|
+
ref="imageUploadInput"
|
|
105
|
+
class="d-none"
|
|
106
|
+
type="file"
|
|
107
|
+
:disabled="!allowMultipleAttachments"
|
|
108
|
+
:accept="validTypes?.join(',')"
|
|
109
|
+
@change="onImageChanged($event, validate)"
|
|
110
|
+
>
|
|
111
|
+
|
|
112
|
+
<VMessages class="mt-1 d-block" :messages="validationErrors.value" :active="isValid.value === false" />
|
|
113
|
+
</div>
|
|
114
|
+
</VValidation>
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Attachment } from '../../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
validTypes?: string[];
|
|
4
|
+
rules?: ((value: unknown) => typeof value | string)[];
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
modelValue: Attachment | Attachment[] | null;
|
|
7
|
+
sizeInMB?: number;
|
|
8
|
+
showPreview?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
|
+
"update:model-value": (value: Attachment | Attachment[]) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
"onUpdate:model-value"?: ((value: Attachment | Attachment[]) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { OptionItem, Params } from '../../types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
options?: OptionItem[] | string[] | number[];
|
|
5
|
+
rules?: ((value: unknown) => typeof value | string)[];
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
searchable?: boolean;
|
|
8
|
+
searchInternally?: boolean;
|
|
9
|
+
querySearchParam?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
grouped?: boolean;
|
|
13
|
+
returnObject?: boolean;
|
|
14
|
+
teleported?: boolean;
|
|
15
|
+
preselectFirst?: boolean;
|
|
16
|
+
hideSelected?: boolean;
|
|
17
|
+
error?: boolean;
|
|
18
|
+
modelValue?: unknown;
|
|
19
|
+
itemLabel?: string;
|
|
20
|
+
groupValues?: string;
|
|
21
|
+
groupLabel?: string;
|
|
22
|
+
trackBy?: string;
|
|
23
|
+
trackByValue?: string | number | string[];
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
deselectLabel?: string;
|
|
29
|
+
selectLabel?: string;
|
|
30
|
+
selectedLabel?: string;
|
|
31
|
+
errorMessages?: string;
|
|
32
|
+
params?: Params;
|
|
33
|
+
hideDetails?: boolean;
|
|
34
|
+
fetchEnabled?: boolean;
|
|
35
|
+
isLoading?: boolean;
|
|
36
|
+
disableIfEmpty?: boolean;
|
|
37
|
+
clearable?: boolean;
|
|
38
|
+
};
|
|
39
|
+
declare var __VLS_71: string | number, __VLS_72: any, __VLS_136: string | number, __VLS_137: any;
|
|
40
|
+
type __VLS_Slots = {} & {
|
|
41
|
+
[K in NonNullable<typeof __VLS_71>]?: (props: typeof __VLS_72) => any;
|
|
42
|
+
} & {
|
|
43
|
+
[K in NonNullable<typeof __VLS_136>]?: (props: typeof __VLS_137) => any;
|
|
44
|
+
};
|
|
45
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
46
|
+
records: Ref<{
|
|
47
|
+
id?: string | number | boolean | undefined;
|
|
48
|
+
name?: string | number | undefined;
|
|
49
|
+
value?: string | number | boolean | undefined;
|
|
50
|
+
allowTranslate?: boolean | undefined;
|
|
51
|
+
svg_icon_url?: string | undefined;
|
|
52
|
+
png_icon_url?: string | undefined;
|
|
53
|
+
children?: /*elided*/ any[] | undefined;
|
|
54
|
+
}[], OptionItem[] | {
|
|
55
|
+
id?: string | number | boolean | undefined;
|
|
56
|
+
name?: string | number | undefined;
|
|
57
|
+
value?: string | number | boolean | undefined;
|
|
58
|
+
allowTranslate?: boolean | undefined;
|
|
59
|
+
svg_icon_url?: string | undefined;
|
|
60
|
+
png_icon_url?: string | undefined;
|
|
61
|
+
children?: /*elided*/ any[] | undefined;
|
|
62
|
+
}[]>;
|
|
63
|
+
internalOptions: import("vue").ComputedRef<({
|
|
64
|
+
id?: string | number | boolean | undefined;
|
|
65
|
+
name?: string | number | undefined;
|
|
66
|
+
value?: string | number | boolean | undefined;
|
|
67
|
+
allowTranslate?: boolean | undefined;
|
|
68
|
+
svg_icon_url?: string | undefined;
|
|
69
|
+
png_icon_url?: string | undefined;
|
|
70
|
+
children?: /*elided*/ any[] | undefined;
|
|
71
|
+
} | null)[]>;
|
|
72
|
+
loading: import("vue").ComputedRef<boolean>;
|
|
73
|
+
refetch: () => Promise<OptionItem[]>;
|
|
74
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
75
|
+
"update:model-value": (value: unknown) => any;
|
|
76
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
77
|
+
"onUpdate:model-value"?: ((value: unknown) => any) | undefined;
|
|
78
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
79
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
80
|
+
declare const _default: typeof __VLS_export;
|
|
81
|
+
export default _default;
|
|
82
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
83
|
+
new (): {
|
|
84
|
+
$slots: S;
|
|
85
|
+
};
|
|
86
|
+
};
|