@weconstudio/nuxt 0.0.0-stage → 1.72.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.
Files changed (208) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +115 -2
  3. package/dist/module.d.mts +7 -0
  4. package/dist/module.json +12 -0
  5. package/dist/module.mjs +250 -0
  6. package/dist/runtime/components/We/Autocomplete.d.vue.ts +13 -0
  7. package/dist/runtime/components/We/Autocomplete.vue +91 -0
  8. package/dist/runtime/components/We/Autocomplete.vue.d.ts +13 -0
  9. package/dist/runtime/components/We/BoldText.d.vue.ts +17 -0
  10. package/dist/runtime/components/We/BoldText.vue +29 -0
  11. package/dist/runtime/components/We/BoldText.vue.d.ts +17 -0
  12. package/dist/runtime/components/We/ColorPicker.d.vue.ts +11 -0
  13. package/dist/runtime/components/We/ColorPicker.vue +199 -0
  14. package/dist/runtime/components/We/ColorPicker.vue.d.ts +11 -0
  15. package/dist/runtime/components/We/ConfirmDialog.d.vue.ts +104 -0
  16. package/dist/runtime/components/We/ConfirmDialog.vue +143 -0
  17. package/dist/runtime/components/We/ConfirmDialog.vue.d.ts +104 -0
  18. package/dist/runtime/components/We/Datatable.d.vue.ts +40 -0
  19. package/dist/runtime/components/We/Datatable.vue +87 -0
  20. package/dist/runtime/components/We/Datatable.vue.d.ts +40 -0
  21. package/dist/runtime/components/We/DatatableInternal.d.vue.ts +194 -0
  22. package/dist/runtime/components/We/DatatableInternal.vue +638 -0
  23. package/dist/runtime/components/We/DatatableInternal.vue.d.ts +194 -0
  24. package/dist/runtime/components/We/DatePicker.d.vue.ts +51 -0
  25. package/dist/runtime/components/We/DatePicker.vue +901 -0
  26. package/dist/runtime/components/We/DatePicker.vue.d.ts +51 -0
  27. package/dist/runtime/components/We/Dt/Actions.d.vue.ts +51 -0
  28. package/dist/runtime/components/We/Dt/Actions.vue +106 -0
  29. package/dist/runtime/components/We/Dt/Actions.vue.d.ts +51 -0
  30. package/dist/runtime/components/We/Dt/BooleanFormatter.d.vue.ts +8 -0
  31. package/dist/runtime/components/We/Dt/BooleanFormatter.vue +26 -0
  32. package/dist/runtime/components/We/Dt/BooleanFormatter.vue.d.ts +8 -0
  33. package/dist/runtime/components/We/Dt/CardFilterContainer.d.vue.ts +17 -0
  34. package/dist/runtime/components/We/Dt/CardFilterContainer.vue +60 -0
  35. package/dist/runtime/components/We/Dt/CardFilterContainer.vue.d.ts +17 -0
  36. package/dist/runtime/components/We/Dt/CheckboxFilter.d.vue.ts +16 -0
  37. package/dist/runtime/components/We/Dt/CheckboxFilter.vue +47 -0
  38. package/dist/runtime/components/We/Dt/CheckboxFilter.vue.d.ts +16 -0
  39. package/dist/runtime/components/We/Dt/ChipGroupSelect.d.vue.ts +7 -0
  40. package/dist/runtime/components/We/Dt/ChipGroupSelect.vue +35 -0
  41. package/dist/runtime/components/We/Dt/ChipGroupSelect.vue.d.ts +7 -0
  42. package/dist/runtime/components/We/Dt/ClusterFilter.d.vue.ts +18 -0
  43. package/dist/runtime/components/We/Dt/ClusterFilter.vue +68 -0
  44. package/dist/runtime/components/We/Dt/ClusterFilter.vue.d.ts +18 -0
  45. package/dist/runtime/components/We/Dt/DatasetFormatter.d.vue.ts +19 -0
  46. package/dist/runtime/components/We/Dt/DatasetFormatter.vue +65 -0
  47. package/dist/runtime/components/We/Dt/DatasetFormatter.vue.d.ts +19 -0
  48. package/dist/runtime/components/We/Dt/DaterangeFilter.d.vue.ts +28 -0
  49. package/dist/runtime/components/We/Dt/DaterangeFilter.vue +140 -0
  50. package/dist/runtime/components/We/Dt/DaterangeFilter.vue.d.ts +28 -0
  51. package/dist/runtime/components/We/Dt/Filter.d.vue.ts +7 -0
  52. package/dist/runtime/components/We/Dt/Filter.vue +234 -0
  53. package/dist/runtime/components/We/Dt/Filter.vue.d.ts +7 -0
  54. package/dist/runtime/components/We/Dt/Filters.d.vue.ts +6 -0
  55. package/dist/runtime/components/We/Dt/Filters.vue +24 -0
  56. package/dist/runtime/components/We/Dt/Filters.vue.d.ts +6 -0
  57. package/dist/runtime/components/We/Dt/LuxonFormatter.d.vue.ts +12 -0
  58. package/dist/runtime/components/We/Dt/LuxonFormatter.vue +23 -0
  59. package/dist/runtime/components/We/Dt/LuxonFormatter.vue.d.ts +12 -0
  60. package/dist/runtime/components/We/Dt/SelectFilter.d.vue.ts +60 -0
  61. package/dist/runtime/components/We/Dt/SelectFilter.vue +333 -0
  62. package/dist/runtime/components/We/Dt/SelectFilter.vue.d.ts +60 -0
  63. package/dist/runtime/components/We/Dt/SelectResourceFilter.d.vue.ts +43 -0
  64. package/dist/runtime/components/We/Dt/SelectResourceFilter.vue +127 -0
  65. package/dist/runtime/components/We/Dt/SelectResourceFilter.vue.d.ts +43 -0
  66. package/dist/runtime/components/We/Dt/dt.types.d.ts +8 -0
  67. package/dist/runtime/components/We/EndpointSwitcher.d.vue.ts +12 -0
  68. package/dist/runtime/components/We/EndpointSwitcher.vue +256 -0
  69. package/dist/runtime/components/We/EndpointSwitcher.vue.d.ts +12 -0
  70. package/dist/runtime/components/We/Import.d.vue.ts +118 -0
  71. package/dist/runtime/components/We/Import.vue +730 -0
  72. package/dist/runtime/components/We/Import.vue.d.ts +118 -0
  73. package/dist/runtime/components/We/ImportDefaultValues.d.vue.ts +3666 -0
  74. package/dist/runtime/components/We/ImportDefaultValues.vue +115 -0
  75. package/dist/runtime/components/We/ImportDefaultValues.vue.d.ts +3666 -0
  76. package/dist/runtime/components/We/ImportMatchColumns.d.vue.ts +66 -0
  77. package/dist/runtime/components/We/ImportMatchColumns.vue +172 -0
  78. package/dist/runtime/components/We/ImportMatchColumns.vue.d.ts +66 -0
  79. package/dist/runtime/components/We/ImportPreviewResults.d.vue.ts +38 -0
  80. package/dist/runtime/components/We/ImportPreviewResults.vue +165 -0
  81. package/dist/runtime/components/We/ImportPreviewResults.vue.d.ts +38 -0
  82. package/dist/runtime/components/We/ImportSelectStart.d.vue.ts +47 -0
  83. package/dist/runtime/components/We/ImportSelectStart.vue +106 -0
  84. package/dist/runtime/components/We/ImportSelectStart.vue.d.ts +47 -0
  85. package/dist/runtime/components/We/Notification.d.vue.ts +7 -0
  86. package/dist/runtime/components/We/Notification.vue +49 -0
  87. package/dist/runtime/components/We/Notification.vue.d.ts +7 -0
  88. package/dist/runtime/components/We/S3Dropzone.d.vue.ts +17 -0
  89. package/dist/runtime/components/We/S3Dropzone.vue +527 -0
  90. package/dist/runtime/components/We/S3Dropzone.vue.d.ts +17 -0
  91. package/dist/runtime/components/We/Select.d.vue.ts +39 -0
  92. package/dist/runtime/components/We/Select.vue +354 -0
  93. package/dist/runtime/components/We/Select.vue.d.ts +39 -0
  94. package/dist/runtime/components/We/TipTap.d.vue.ts +26 -0
  95. package/dist/runtime/components/We/TipTap.vue +362 -0
  96. package/dist/runtime/components/We/TipTap.vue.d.ts +26 -0
  97. package/dist/runtime/components/We/datatable.props.d.ts +57 -0
  98. package/dist/runtime/components/We/datatable.props.js +60 -0
  99. package/dist/runtime/composables/datatable/useAutoFillHeight.d.ts +31 -0
  100. package/dist/runtime/composables/datatable/useAutoFillHeight.js +57 -0
  101. package/dist/runtime/composables/datatable/useDataTable.d.ts +33 -0
  102. package/dist/runtime/composables/datatable/useDataTable.js +161 -0
  103. package/dist/runtime/composables/datatable/useDatatableColumns.d.ts +12 -0
  104. package/dist/runtime/composables/datatable/useDatatableColumns.js +96 -0
  105. package/dist/runtime/composables/useApi.d.ts +56 -0
  106. package/dist/runtime/composables/useApi.js +230 -0
  107. package/dist/runtime/composables/useApiFetch.d.ts +2 -0
  108. package/dist/runtime/composables/useApiFetch.js +9 -0
  109. package/dist/runtime/composables/useApiUrl.d.ts +10 -0
  110. package/dist/runtime/composables/useApiUrl.js +37 -0
  111. package/dist/runtime/composables/useAuth.d.ts +9 -0
  112. package/dist/runtime/composables/useAuth.js +22 -0
  113. package/dist/runtime/composables/useBus.d.ts +8 -0
  114. package/dist/runtime/composables/useBus.js +18 -0
  115. package/dist/runtime/composables/useDateRangePresets.d.ts +21 -0
  116. package/dist/runtime/composables/useDateRangePresets.js +90 -0
  117. package/dist/runtime/composables/useForm.d.ts +29 -0
  118. package/dist/runtime/composables/useForm.js +74 -0
  119. package/dist/runtime/composables/useFormLock.d.ts +11 -0
  120. package/dist/runtime/composables/useFormLock.js +8 -0
  121. package/dist/runtime/composables/useFormWrapper.d.ts +16 -0
  122. package/dist/runtime/composables/useFormWrapper.js +36 -0
  123. package/dist/runtime/composables/useImportJob.d.ts +55 -0
  124. package/dist/runtime/composables/useImportJob.js +94 -0
  125. package/dist/runtime/composables/useLux.d.ts +1 -0
  126. package/dist/runtime/composables/useLux.js +8 -0
  127. package/dist/runtime/composables/useNotify.d.ts +12 -0
  128. package/dist/runtime/composables/useNotify.js +24 -0
  129. package/dist/runtime/composables/usePaginatedFetch.d.ts +24 -0
  130. package/dist/runtime/composables/usePaginatedFetch.js +154 -0
  131. package/dist/runtime/composables/useServerErrors.d.ts +16 -0
  132. package/dist/runtime/composables/useServerErrors.js +60 -0
  133. package/dist/runtime/composables/useValidators.d.ts +18 -0
  134. package/dist/runtime/composables/useValidators.js +56 -0
  135. package/dist/runtime/generator/code/dt.d.ts +8 -0
  136. package/dist/runtime/generator/code/dt.js +97 -0
  137. package/dist/runtime/generator/code/edit.d.ts +4 -0
  138. package/dist/runtime/generator/code/edit.js +41 -0
  139. package/dist/runtime/generator/code/form.d.ts +6 -0
  140. package/dist/runtime/generator/code/form.js +229 -0
  141. package/dist/runtime/generator/code/i18n.d.ts +5 -0
  142. package/dist/runtime/generator/code/i18n.js +43 -0
  143. package/dist/runtime/generator/code/index.d.ts +11 -0
  144. package/dist/runtime/generator/code/index.js +90 -0
  145. package/dist/runtime/generator/components/CodeSnippet.d.vue.ts +14 -0
  146. package/dist/runtime/generator/components/CodeSnippet.vue +49 -0
  147. package/dist/runtime/generator/components/CodeSnippet.vue.d.ts +14 -0
  148. package/dist/runtime/generator/components/Configuration.d.vue.ts +16 -0
  149. package/dist/runtime/generator/components/Configuration.vue +154 -0
  150. package/dist/runtime/generator/components/Configuration.vue.d.ts +16 -0
  151. package/dist/runtime/generator/components/GeneratorPage.d.vue.ts +50 -0
  152. package/dist/runtime/generator/components/GeneratorPage.vue +226 -0
  153. package/dist/runtime/generator/components/GeneratorPage.vue.d.ts +50 -0
  154. package/dist/runtime/generator/fs.d.ts +16 -0
  155. package/dist/runtime/generator/fs.js +79 -0
  156. package/dist/runtime/generator/index.d.vue.ts +52 -0
  157. package/dist/runtime/generator/index.vue +17 -0
  158. package/dist/runtime/generator/index.vue.d.ts +52 -0
  159. package/dist/runtime/internals/api.d.ts +3 -0
  160. package/dist/runtime/internals/api.js +16 -0
  161. package/dist/runtime/internals/bus.d.ts +1 -0
  162. package/dist/runtime/internals/bus.js +2 -0
  163. package/dist/runtime/internals/dt.d.ts +24 -0
  164. package/dist/runtime/internals/dt.js +57 -0
  165. package/dist/runtime/lang/en.json +211 -0
  166. package/dist/runtime/lang/it.json +211 -0
  167. package/dist/runtime/mixins/formValidator.d.ts +38 -0
  168. package/dist/runtime/mixins/formValidator.js +118 -0
  169. package/dist/runtime/plugins/api-legacy.d.ts +76 -0
  170. package/dist/runtime/plugins/api-legacy.js +11 -0
  171. package/dist/runtime/plugins/auth-legacy.d.ts +22 -0
  172. package/dist/runtime/plugins/auth-legacy.js +14 -0
  173. package/dist/runtime/plugins/bus-legacy.d.ts +6 -0
  174. package/dist/runtime/plugins/bus-legacy.js +9 -0
  175. package/dist/runtime/plugins/notify-legacy.d.ts +25 -0
  176. package/dist/runtime/plugins/notify-legacy.js +35 -0
  177. package/dist/runtime/plugins/portal.d.ts +2 -0
  178. package/dist/runtime/plugins/portal.js +5 -0
  179. package/dist/runtime/plugins/update-sanctum-app-config.d.ts +2 -0
  180. package/dist/runtime/plugins/update-sanctum-app-config.js +44 -0
  181. package/dist/runtime/plugins/vuetify-nuxt-icon.d.ts +4 -0
  182. package/dist/runtime/plugins/vuetify-nuxt-icon.js +30 -0
  183. package/dist/runtime/types/app-config.d.ts +24 -0
  184. package/dist/runtime/types/app-config.js +1 -0
  185. package/dist/runtime/types/icons.d.ts +82 -0
  186. package/dist/runtime/types/icons.js +84 -0
  187. package/dist/runtime/types/index.d.ts +2 -0
  188. package/dist/runtime/types/index.js +2 -0
  189. package/dist/runtime/types/module-options.d.ts +29 -0
  190. package/dist/runtime/types/module-options.js +0 -0
  191. package/dist/runtime/types/runtime-hooks.d.ts +17 -0
  192. package/dist/runtime/types/runtime-hooks.js +1 -0
  193. package/dist/runtime/utils/color.d.ts +10 -0
  194. package/dist/runtime/utils/color.js +38 -0
  195. package/dist/runtime/utils/file.d.ts +17 -0
  196. package/dist/runtime/utils/file.js +108 -0
  197. package/dist/runtime/utils/format.d.ts +1 -0
  198. package/dist/runtime/utils/format.js +14 -0
  199. package/dist/runtime/utils/make-enum.d.ts +15 -0
  200. package/dist/runtime/utils/make-enum.js +27 -0
  201. package/dist/runtime/utils/mergeDefaults.d.ts +1 -0
  202. package/dist/runtime/utils/mergeDefaults.js +18 -0
  203. package/dist/runtime/utils/object-to-formdata.d.ts +10 -0
  204. package/dist/runtime/utils/object-to-formdata.js +82 -0
  205. package/dist/runtime/utils/uuid.d.ts +1 -0
  206. package/dist/runtime/utils/uuid.js +9 -0
  207. package/dist/types.d.mts +9 -0
  208. package/package.json +92 -4
@@ -0,0 +1,47 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ headers: {
3
+ type: ArrayConstructor;
4
+ required: true;
5
+ };
6
+ items: {
7
+ type: ArrayConstructor;
8
+ required: true;
9
+ };
10
+ value: {
11
+ type: (NumberConstructor | StringConstructor)[];
12
+ default: null;
13
+ };
14
+ }>, {}, {
15
+ currentRow: string | number;
16
+ }, {
17
+ previewHeaders(): unknown[];
18
+ }, {
19
+ itemRowBackground({ item }: {
20
+ item: any;
21
+ }): {
22
+ class?: undefined;
23
+ } | {
24
+ class: string[];
25
+ };
26
+ rowSelected(): void;
27
+ }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "update:modelValue" | "back")[], "input" | "update:modelValue" | "back", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
28
+ headers: {
29
+ type: ArrayConstructor;
30
+ required: true;
31
+ };
32
+ items: {
33
+ type: ArrayConstructor;
34
+ required: true;
35
+ };
36
+ value: {
37
+ type: (NumberConstructor | StringConstructor)[];
38
+ default: null;
39
+ };
40
+ }>> & Readonly<{
41
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
42
+ onInput?: ((...args: any[]) => any) | undefined;
43
+ onBack?: ((...args: any[]) => any) | undefined;
44
+ }>, {
45
+ value: string | number;
46
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
47
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { NotivueTheme } from 'notivue';
2
+ type __VLS_Props = {
3
+ /** Variabili `--nv-*` che sovrascrivono quelle del tema di default. */
4
+ theme?: NotivueTheme;
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ export default _default;
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <notivue v-slot="item">
3
+ <notifications
4
+ :theme="notivueTheme"
5
+ :item="item"
6
+ />
7
+ </notivue>
8
+ </template>
9
+
10
+ <script setup>
11
+ import { materialTheme, Notifications, Notivue } from "notivue";
12
+ import { computed } from "vue";
13
+ defineOptions(
14
+ { name: "WeNotification" }
15
+ );
16
+ const props = defineProps({
17
+ theme: { type: Object, required: false }
18
+ });
19
+ const vuetifyTheme = {
20
+ ...materialTheme,
21
+ "--nv-global-bg": "rgb(var(--v-theme-surface))",
22
+ "--nv-global-fg": "rgb(var(--v-theme-on-surface))",
23
+ "--nv-global-accent": "rgb(var(--v-theme-on-surface))",
24
+ "--nv-success-bg": "rgb(var(--v-theme-success))",
25
+ "--nv-success-fg": "rgb(var(--v-theme-on-success))",
26
+ "--nv-success-accent": "rgb(var(--v-theme-on-success))",
27
+ "--nv-error-bg": "rgb(var(--v-theme-error))",
28
+ "--nv-error-fg": "rgb(var(--v-theme-on-error))",
29
+ "--nv-error-accent": "rgb(var(--v-theme-on-error))",
30
+ "--nv-warning-bg": "rgb(var(--v-theme-warning))",
31
+ "--nv-warning-fg": "rgb(var(--v-theme-on-warning))",
32
+ "--nv-warning-accent": "rgb(var(--v-theme-on-warning))",
33
+ "--nv-info-bg": "rgb(var(--v-theme-info))",
34
+ "--nv-info-fg": "rgb(var(--v-theme-on-info))",
35
+ "--nv-info-accent": "rgb(var(--v-theme-on-info))",
36
+ // `promise` e i suoi esiti restano neutri, come in `materialTheme`
37
+ "--nv-promise-bg": "rgb(var(--v-theme-surface))",
38
+ "--nv-promise-fg": "rgb(var(--v-theme-on-surface))",
39
+ "--nv-promise-accent": "rgb(var(--v-theme-on-surface))"
40
+ };
41
+ const notivueTheme = computed(() => ({
42
+ ...vuetifyTheme,
43
+ ...props.theme
44
+ }));
45
+ </script>
46
+
47
+ <style>
48
+ :root{--nv-z:9999}.Notivue__content-message{overflow-wrap:anywhere;word-break:break-word}
49
+ </style>
@@ -0,0 +1,7 @@
1
+ import type { NotivueTheme } from 'notivue';
2
+ type __VLS_Props = {
3
+ /** Variabili `--nv-*` che sovrascrivono quelle del tema di default. */
4
+ theme?: NotivueTheme;
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ export default _default;
@@ -0,0 +1,17 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ clearFile: typeof clearFile;
3
+ getFiles: typeof getFiles;
4
+ $emit: (event: "reset" | "update:modelValue" | "progressing", ...args: any[]) => void;
5
+ title: string;
6
+ multiple: boolean;
7
+ readonly: boolean;
8
+ disabled: boolean;
9
+ acceptedFiles: string;
10
+ maxFiles: string | number;
11
+ hideRemoveAll: boolean;
12
+ signedUrl?: string | undefined;
13
+ $props: any;
14
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ export default _default;
16
+ declare function clearFile(): void;
17
+ declare function getFiles(): any[];
@@ -0,0 +1,527 @@
1
+ <script setup>
2
+ import { useApi, useNotify } from "#imports";
3
+ import { useDropZone } from "@vueuse/core";
4
+ import { computed, ref, watch } from "vue";
5
+ import { useI18n } from "vue-i18n";
6
+ import { useFormLock } from "../../composables/useFormLock";
7
+ import { getExtensionType, getFileCategory } from "../../utils/file";
8
+ import { humanFileSize } from "../../utils/format";
9
+ import { generateUUID } from "../../utils/uuid";
10
+ const props = defineProps({
11
+ multiple: {
12
+ type: Boolean,
13
+ required: false,
14
+ default: false
15
+ },
16
+ acceptedFiles: {
17
+ type: String,
18
+ default: null
19
+ },
20
+ maxFiles: {
21
+ type: [Number, String],
22
+ default: null
23
+ },
24
+ hideRemoveAll: {
25
+ type: Boolean,
26
+ default: false
27
+ },
28
+ title: {
29
+ type: String,
30
+ default: null
31
+ },
32
+ signedUrl: {
33
+ type: String,
34
+ default: void 0
35
+ },
36
+ readonly: {
37
+ type: Boolean,
38
+ default: null
39
+ },
40
+ disabled: {
41
+ type: Boolean,
42
+ default: null
43
+ }
44
+ });
45
+ const emit = defineEmits(["update:modelValue", "progressing", "reset"]);
46
+ const { t } = useI18n();
47
+ const { isReadonly, isDisabled } = useFormLock(props);
48
+ const isLocked = computed(() => isReadonly.value || isDisabled.value);
49
+ const files = ref([]);
50
+ const fileInput = ref(null);
51
+ const dropZoneRef = ref(null);
52
+ const dialog = ref(false);
53
+ const formModel = ref(null);
54
+ const isHovered = ref(false);
55
+ const isDragging = ref(false);
56
+ const existingAttachments = defineModel("existingAttachments", { type: Array, default: [] });
57
+ defineExpose({
58
+ clearFile,
59
+ getFiles
60
+ });
61
+ useDropZone(dropZoneRef, {
62
+ onDrop(filesList) {
63
+ isDragging.value = false;
64
+ isHovered.value = false;
65
+ if (isLocked.value) {
66
+ return;
67
+ }
68
+ filesSelected(filesList);
69
+ }
70
+ });
71
+ const loadedFiles = computed(() => {
72
+ return files.value?.filter((f) => f.loading === false && !f.isExisting);
73
+ });
74
+ const validExtensions = computed(() => {
75
+ if (!props.acceptedFiles || props.acceptedFiles.trim() === "") {
76
+ return null;
77
+ }
78
+ return parseAcceptedFiles(props.acceptedFiles);
79
+ });
80
+ function createTempFile({ file, loading = true, isExisting = false, s3 = null, uuid = generateUUID() }) {
81
+ const tempFile = {
82
+ uuid,
83
+ name: file.name ?? file.filename,
84
+ size: file.size,
85
+ loading,
86
+ isExisting,
87
+ title: t("weS3Dropzone.tempFile.title")
88
+ };
89
+ if (s3) {
90
+ tempFile.s3 = s3;
91
+ }
92
+ return tempFile;
93
+ }
94
+ watch(existingAttachments, (value) => {
95
+ if (!Array.isArray(value) || value.length === 0) {
96
+ return;
97
+ }
98
+ const attachments = value.map((v) => ({
99
+ ...v,
100
+ name: v.filename,
101
+ type: v.extension
102
+ }));
103
+ attachments.forEach((attachment) => {
104
+ const tempFile = createTempFile({
105
+ file: attachment,
106
+ loading: false,
107
+ isExisting: true,
108
+ s3: {
109
+ key: attachment.key,
110
+ uuid: attachment.uuid,
111
+ url: attachment.url
112
+ }
113
+ });
114
+ files.value.push(tempFile);
115
+ });
116
+ }, { immediate: true });
117
+ watch(loadedFiles, (value) => {
118
+ emit("update:modelValue", value);
119
+ });
120
+ watch(files.value, (value) => {
121
+ const allUploaded = value.every((f) => f.loading === false);
122
+ emit("progressing", allUploaded);
123
+ }, { immediate: true });
124
+ function parseAcceptedFiles(acceptedFilesString) {
125
+ return acceptedFilesString.split(",").map((ext) => ext.replace(".", "").trim().toLowerCase()).filter(Boolean);
126
+ }
127
+ function filesSelected(filesList) {
128
+ const maxFiles = props.multiple === false ? 1 : props.maxFiles;
129
+ const currentCount = files.value.length;
130
+ const existingNames = files.value.map((f) => f.name.toLowerCase());
131
+ const { validFiles, invalidExtensions, uniqueFiles, duplicates } = [...filesList].reduce((acc, file) => {
132
+ const ext = file.name.split(".").pop().toLowerCase();
133
+ const name = file.name.toLowerCase();
134
+ if (validExtensions.value && !validExtensions.value.includes(ext)) {
135
+ acc.invalidExtensions.push(file.name);
136
+ } else {
137
+ acc.validFiles.push(file);
138
+ if (existingNames.includes(name)) {
139
+ acc.duplicates.push(file.name);
140
+ } else {
141
+ acc.uniqueFiles.push(file);
142
+ }
143
+ }
144
+ return acc;
145
+ }, {
146
+ validFiles: [],
147
+ invalidExtensions: [],
148
+ uniqueFiles: [],
149
+ duplicates: []
150
+ });
151
+ if (invalidExtensions.length > 0) {
152
+ useNotify().error(t("weS3Dropzone.errors.onlyValidExtensions", [validExtensions.value.join(", ")]));
153
+ }
154
+ if (validFiles.length === 0) {
155
+ return;
156
+ }
157
+ if (duplicates.length > 0) {
158
+ useNotify().error(t("weS3Dropzone.errors.duplicate", [duplicates.join(", ")]));
159
+ }
160
+ if (uniqueFiles.length === 0) {
161
+ return;
162
+ }
163
+ const availableSlots = maxFiles ? maxFiles - currentCount : uniqueFiles.length;
164
+ if (availableSlots <= 0) {
165
+ useNotify().error(t("weS3Dropzone.errors.exceedsMaxFiles", [maxFiles]));
166
+ return;
167
+ }
168
+ const filesToUpload = uniqueFiles.slice(0, availableSlots);
169
+ if (uniqueFiles.length > availableSlots) {
170
+ useNotify().error(t("weS3Dropzone.errors.exceedsMaxFiles", [maxFiles]));
171
+ }
172
+ filesToUpload.forEach((file) => {
173
+ upload(file);
174
+ });
175
+ }
176
+ function handleFileInput(event) {
177
+ const inputFiles = event.target.files;
178
+ filesSelected(inputFiles);
179
+ }
180
+ async function upload(file) {
181
+ const uuid = generateUUID();
182
+ const tempFile = createTempFile({ file, uuid });
183
+ files.value.push(tempFile);
184
+ try {
185
+ const res = await useApi().uploadFile(file, {}, props.signedUrl);
186
+ if (res) {
187
+ const fileIndex = files.value.findIndex((f) => f.uuid === uuid);
188
+ if (fileIndex !== -1) {
189
+ files.value[fileIndex] = {
190
+ name: file.name,
191
+ size: file.size,
192
+ loading: false,
193
+ s3: { key: res.key, uuid: res.uuid, url: res.url }
194
+ };
195
+ }
196
+ }
197
+ } catch (error) {
198
+ const fileIndex = files.value.findIndex((f) => f.uuid === uuid);
199
+ if (fileIndex !== -1) {
200
+ files.value.splice(fileIndex, 1);
201
+ }
202
+ useNotify().error(error);
203
+ console.error(error);
204
+ }
205
+ }
206
+ function getFiles() {
207
+ return files.value.map((data) => {
208
+ const { name, size, s3 } = data;
209
+ if (s3) {
210
+ const { url, ...extra } = s3;
211
+ return {
212
+ ...extra,
213
+ name,
214
+ size,
215
+ type: formatType(data)
216
+ };
217
+ } else {
218
+ return {
219
+ name,
220
+ size,
221
+ type: formatType(data),
222
+ original: data?.original
223
+ };
224
+ }
225
+ });
226
+ }
227
+ function formatType({ type }) {
228
+ return type || null;
229
+ }
230
+ function removeFiles() {
231
+ if (confirm(t("weS3Dropzone.removeFiles.confirm"))) {
232
+ clearFile();
233
+ }
234
+ }
235
+ function triggerInput() {
236
+ if (isLocked.value) {
237
+ return;
238
+ }
239
+ fileInput.value?.click();
240
+ }
241
+ function clearFile() {
242
+ files.value = [];
243
+ if (fileInput.value) {
244
+ fileInput.value.value = "";
245
+ }
246
+ emit("reset");
247
+ }
248
+ function deleteFile(file) {
249
+ const index = files.value.findIndex((f) => f.name === file.name && f.size === file.size);
250
+ if (index !== -1) {
251
+ files.value.splice(index, 1);
252
+ }
253
+ if (file.isExisting) {
254
+ const existingIndex = existingAttachments.value.findIndex((f) => f.filename === file.name && f.size === file.size);
255
+ if (existingIndex !== -1) {
256
+ existingAttachments.value.splice(existingIndex, 1);
257
+ }
258
+ }
259
+ if (files.value.length === 0 && fileInput.value) {
260
+ fileInput.value.value = "";
261
+ }
262
+ }
263
+ function fileUrl(file) {
264
+ return file?.s3?.url ?? URL?.createObjectURL(file);
265
+ }
266
+ function getFileExtension(file) {
267
+ return file.name.substring(file.name.lastIndexOf(".") + 1);
268
+ }
269
+ function cardSubtitle(file) {
270
+ const extension = getFileExtension(file);
271
+ const size = humanFileSize(file.size);
272
+ return extension ? `${getExtensionType(extension)} (${size})` : size;
273
+ }
274
+ function getFileTypeIcon(file) {
275
+ return getFileCategory(file).icon;
276
+ }
277
+ function getFileTypeColor(file) {
278
+ return getFileCategory(file).color;
279
+ }
280
+ function openPreview(file) {
281
+ if (!file.loading) {
282
+ const extension = getFileExtension(file);
283
+ const isImg = getExtensionType(extension) === "image";
284
+ if (isImg) {
285
+ formModel.value = file;
286
+ dialog.value = true;
287
+ } else {
288
+ openFile(file);
289
+ }
290
+ }
291
+ }
292
+ function openFile(file) {
293
+ const selectedFile = fileUrl(file);
294
+ window.open(selectedFile, "", "width=1200, height=800");
295
+ if (file instanceof File) {
296
+ URL.revokeObjectURL(file);
297
+ }
298
+ }
299
+ const dropZoneTitle = computed(() => {
300
+ if (isLocked.value) {
301
+ return t("weS3Dropzone.empty");
302
+ }
303
+ if (props.title) {
304
+ return props.title;
305
+ }
306
+ return !props.multiple ? t("weS3Dropzone.title") : t("weS3Dropzone.titleMultiple");
307
+ });
308
+ </script>
309
+
310
+ <template>
311
+ <div>
312
+ <div
313
+ ref="dropZoneRef"
314
+ class="drop-zone"
315
+ :class="{ 'is-hovered': !isLocked && (isDragging || isHovered), 'is-locked': isLocked, 'is-disabled': isDisabled }"
316
+ @click="triggerInput"
317
+ @mouseenter="isHovered = true"
318
+ @mouseleave="isHovered = false"
319
+ @dragover.prevent="isDragging = true"
320
+ @dragleave="isDragging = false"
321
+ >
322
+ <div v-if="files.length === 0">
323
+ <div style="font-size: 20px;">
324
+ {{ dropZoneTitle }}
325
+ </div>
326
+ <span
327
+ v-if="validExtensions && !isLocked"
328
+ class="text-body-1 mt-1"
329
+ >
330
+ {{ $t('weS3Dropzone.subtitle', [validExtensions.join(', ')]) }}
331
+ </span>
332
+ </div>
333
+ <div
334
+ v-else
335
+ class="d-flex flex-wrap justify-center"
336
+ style="margin: 8px; gap: 8px;"
337
+ >
338
+ <div
339
+ v-for="(file, i) in files"
340
+ :key="i"
341
+ >
342
+ <v-card
343
+ class="rounded-xl drop-zone-card"
344
+ color="surface"
345
+ elevation="1"
346
+ :subtitle="cardSubtitle(file)"
347
+ @click.stop="openPreview(file)"
348
+ >
349
+ <template #title>
350
+ <span class="text-truncate">{{ file.name }}</span>
351
+ </template>
352
+ <template #prepend>
353
+ <v-btn
354
+ class="drop-zone-card-prepend"
355
+ rounded="xl"
356
+ :loading="file.loading"
357
+ elevation="0"
358
+ :color="getFileTypeColor(file)"
359
+ >
360
+ <v-icon
361
+ :icon="getFileTypeIcon(file)"
362
+ color="white"
363
+ size="x-large"
364
+ />
365
+ </v-btn>
366
+ </template>
367
+
368
+ <template
369
+ v-if="!isLocked"
370
+ #append
371
+ >
372
+ <v-btn
373
+ icon
374
+ size="x-small"
375
+ variant="flat"
376
+ @click.stop="deleteFile(file)"
377
+ >
378
+ <v-icon size="large">
379
+ $close
380
+ </v-icon>
381
+ </v-btn>
382
+ </template>
383
+ </v-card>
384
+ </div>
385
+ </div>
386
+
387
+ <input
388
+ ref="fileInput"
389
+ type="file"
390
+ :accept="props.acceptedFiles"
391
+ :multiple="props.multiple"
392
+ class="d-none"
393
+ @change="handleFileInput"
394
+ >
395
+ </div>
396
+ <div
397
+ v-if="!hideRemoveAll && !isLocked"
398
+ class="d-flex justify-end"
399
+ >
400
+ <v-btn
401
+ variant="text"
402
+ class="pr-0 text-none"
403
+ :ripple="false"
404
+ @click="removeFiles"
405
+ >
406
+ {{ $t('weS3Dropzone.removeFiles.text') }}
407
+ </v-btn>
408
+ </div>
409
+ <v-dialog
410
+ v-model="dialog"
411
+ max-width="90vw"
412
+ class="dialog-preview"
413
+ >
414
+ <v-card
415
+ elevation="0"
416
+ class="img-preview d-block"
417
+ >
418
+ <div class="d-flex justify-end pa-4">
419
+ <v-btn
420
+ class="ml-2"
421
+ elevation="0"
422
+ variant="outlined"
423
+ :ripple="false"
424
+ @click="dialog = false"
425
+ >
426
+ <v-icon
427
+ color="error"
428
+ >
429
+ $close
430
+ </v-icon>
431
+ </v-btn>
432
+ </div>
433
+ <v-divider />
434
+ <v-img
435
+ :src="fileUrl(formModel)"
436
+ contain
437
+ style="height: 500px !important; width: 500px !important"
438
+ />
439
+ </v-card>
440
+ </v-dialog>
441
+ </div>
442
+ </template>
443
+
444
+ <style>
445
+ .drop-zone {
446
+ min-height: 200px;
447
+ border: 2px dashed rgba(var(--v-border-color), var(--v-border-opacity));
448
+ border-radius: 8px;
449
+ display: flex;
450
+ align-items: center;
451
+ justify-content: center;
452
+ text-align: center;
453
+ color: rgba(var(--v-theme-on-surface), 0.6);
454
+ background-color: rgba(var(--v-theme-surface), 0.6);
455
+ cursor: pointer;
456
+ transition: background-color 0.3s, border-color 0.3s;
457
+ }
458
+ .drop-zone.is-hovered {
459
+ background-color: rgb(var(--v-theme-surface));
460
+ border-color: rgb(var(--v-theme-primary));
461
+ }
462
+ .drop-zone.is-locked {
463
+ cursor: default;
464
+ }
465
+ .drop-zone.is-disabled {
466
+ opacity: var(--v-disabled-opacity);
467
+ }
468
+
469
+ .drop-zone-card {
470
+ min-width: 250px !important;
471
+ max-width: 550px !important;
472
+ text-align: start;
473
+ border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity)) !important;
474
+ }
475
+ .drop-zone-card .v-card-item {
476
+ padding: 10px !important;
477
+ }
478
+ .drop-zone-card .v-card-item__content {
479
+ padding-left: 4px;
480
+ padding-right: 4px;
481
+ }
482
+ .drop-zone-card .v-card-subtitle {
483
+ display: flex;
484
+ }
485
+ .drop-zone-card .v-card-item__append {
486
+ align-self: self-start;
487
+ }
488
+ .drop-zone-card .drop-zone-card-prepend {
489
+ display: flex;
490
+ align-items: center;
491
+ justify-content: center;
492
+ height: 60px !important;
493
+ width: 60px !important;
494
+ }
495
+
496
+ .img-preview .v-btn--absolute.v-btn--top {
497
+ top: 5px !important;
498
+ }
499
+
500
+ .img-preview .v-btn--absolute.v-btn--right {
501
+ right: 5px !important;
502
+ }
503
+
504
+ .v-dialog__content .v-dialog {
505
+ max-width: 90vw;
506
+ width: auto;
507
+ overflow-y: hidden;
508
+ }
509
+
510
+ .dialog-preview {
511
+ height: 500px;
512
+ width: 500px;
513
+ }
514
+
515
+ .img-preview {
516
+ max-height: 90vh;
517
+ display: flex;
518
+ align-items: center;
519
+ justify-content: center;
520
+ position: relative;
521
+ }
522
+
523
+ .img-preview > img {
524
+ max-height: 90vh;
525
+ border-radius: 6px;
526
+ }
527
+ </style>
@@ -0,0 +1,17 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ clearFile: typeof clearFile;
3
+ getFiles: typeof getFiles;
4
+ $emit: (event: "reset" | "update:modelValue" | "progressing", ...args: any[]) => void;
5
+ title: string;
6
+ multiple: boolean;
7
+ readonly: boolean;
8
+ disabled: boolean;
9
+ acceptedFiles: string;
10
+ maxFiles: string | number;
11
+ hideRemoveAll: boolean;
12
+ signedUrl?: string | undefined;
13
+ $props: any;
14
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ export default _default;
16
+ declare function clearFile(): void;
17
+ declare function getFiles(): any[];