@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,333 @@
1
+ <template>
2
+ <v-menu
3
+ v-model="menu"
4
+ :location
5
+ :width
6
+ :close-on-content-click="false"
7
+ >
8
+ <template #activator="{ props: activatorProps }">
9
+ <WeDtCardFilterContainer
10
+ v-bind="{ ...$attrs, ...activatorProps }"
11
+ >
12
+ <v-card-text class="d-flex align-center pa-2">
13
+ <span
14
+ class="mx-2 text-no-wrap text-truncate"
15
+ :class="selectedItems.length ? 'text-medium-emphasis' : ''"
16
+ >
17
+ {{ label }}
18
+ </span>
19
+
20
+ <div class="d-flex align-center ga-1">
21
+ <template
22
+ v-for="(item, index) in selectedItems"
23
+ :key="item.value"
24
+ >
25
+ <v-chip
26
+ v-if="index < maxChips"
27
+ v-bind="defaults.chipProps ?? { variant: 'tonal', rounded: 'lg', class: 'font-weight-bold' }"
28
+ :color="hideColor ? 'primary' : item.color ?? 'primary'"
29
+ :prepend-icon="hideColor ? void 0 : item.icon"
30
+ :class="{
31
+ 'dt-filters_truncate-chip-content': truncateChipText
32
+ }"
33
+ >
34
+ {{ itemLabel(item) }}
35
+ </v-chip>
36
+
37
+ <v-chip
38
+ v-else-if="index === maxChips"
39
+ v-bind="defaults.chipProps ?? { variant: 'tonal', rounded: 'lg', class: 'font-weight-bold' }"
40
+ color="primary"
41
+ >
42
+ +{{ selectedItems.length - maxChips }}
43
+ </v-chip>
44
+ </template>
45
+ </div>
46
+
47
+ <v-icon>
48
+ $dropdown
49
+ </v-icon>
50
+ </v-card-text>
51
+ </WeDtCardFilterContainer>
52
+ </template>
53
+ <v-card>
54
+ <v-card-title class="d-flex align-center pb-0 mt-2">
55
+ {{ label }}
56
+ <v-spacer />
57
+ <v-btn
58
+ v-if="multiple"
59
+ variant="text"
60
+ border="sm"
61
+ size="small"
62
+ class="ml-1"
63
+ @click="singleValue = !singleValue"
64
+ >
65
+ <v-icon start>
66
+ {{ !singleValue ? "$checkboxMultipleOn" : "$checkboxOn" }}
67
+ </v-icon>
68
+ {{ !singleValue ? $t("dt.filter.multiple") : $t("dt.filter.single") }}
69
+ </v-btn>
70
+ <v-btn
71
+ v-if="clearable && !mandatory"
72
+ variant="text"
73
+ border="sm"
74
+ color="error"
75
+ size="small"
76
+ class="ml-1"
77
+ @click="reset"
78
+ >
79
+ {{ $t("reset") }}
80
+ </v-btn>
81
+ </v-card-title>
82
+ <v-text-field
83
+ v-if="!hideSearch"
84
+ v-model="search"
85
+ prepend-inner-icon="$search"
86
+ :placeholder="$t('dt.search.label')"
87
+ class="mx-3 my-2"
88
+ rounded="we"
89
+ density="compact"
90
+ variant="solo-filled"
91
+ flat
92
+
93
+ hide-details
94
+ clearable
95
+ />
96
+ <v-progress-linear v-show="loading" :height="3" indeterminate color="primary" />
97
+ <v-alert
98
+ v-if="maxReached"
99
+ color="info"
100
+ variant="tonal"
101
+ density="compact"
102
+ rounded="we"
103
+ border="start"
104
+ icon="$info"
105
+ class="mx-3 my-2"
106
+ :text="$t('dt.filter.maxReached', { max: maxSelectionNumber })"
107
+ />
108
+
109
+ <div
110
+ v-if="filteredItems.length === 0 && loading !== true"
111
+ class="pa-4 text-center text-medium-emphasis"
112
+ >
113
+ Nessun elemento trovato
114
+ </div>
115
+
116
+ <slot
117
+ name="before-list"
118
+ v-bind="{ filteredItems, selectAll, deselectAll, allSelected, someSelected }"
119
+ />
120
+
121
+ <v-virtual-scroll
122
+ :height="virtualScrollHeight"
123
+ :items="filteredItems"
124
+ >
125
+ <template #default="{ item, index }">
126
+ <v-list-item
127
+ lines="one"
128
+ :disabled="isItemDisabled(item)"
129
+ :append-icon="hideColor || !item.color ? item.icon : void 0"
130
+ @click="toggle(item)"
131
+ >
132
+ <template #prepend>
133
+ <v-list-item-action start>
134
+ <v-checkbox-btn
135
+ :model-value="isSelected(item)"
136
+ :disabled="isItemDisabled(item)"
137
+ @click.stop.prevent="toggle(item)"
138
+ />
139
+ </v-list-item-action>
140
+ </template>
141
+ <slot name="item-title" v-bind="{ item }">
142
+ <v-list-item-title v-if="hideColor || !item.color">
143
+ {{ itemLabel(item) }}
144
+ </v-list-item-title>
145
+ <v-list-item-title v-else>
146
+ <v-chip
147
+ v-bind="defaults.chipProps ?? { rounded: 'lg' }"
148
+ :color="item.color"
149
+ :prepend-icon="item.icon"
150
+ >
151
+ {{ itemLabel(item) }}
152
+ </v-chip>
153
+ </v-list-item-title>
154
+ </slot>
155
+ <div
156
+ v-if="onIntersectLast && index === filteredItems.length - 1"
157
+ v-intersect="onIntersectLast"
158
+ />
159
+ </v-list-item>
160
+ </template>
161
+ </v-virtual-scroll>
162
+ </v-card>
163
+ </v-menu>
164
+ </template>
165
+
166
+ <script setup>
167
+ import { computed, ref, watch } from "vue";
168
+ import { useDefaults } from "vuetify";
169
+ const {
170
+ items = [],
171
+ resolvedItems = [],
172
+ maxChips = 2,
173
+ maxSelection,
174
+ emitRawValue = false,
175
+ location = "bottom end",
176
+ width = "400px",
177
+ hideSearch = false,
178
+ clearable = true,
179
+ onIntersectLast,
180
+ multiple = true,
181
+ mandatory = false,
182
+ truncateChipText = true,
183
+ hideColor = false,
184
+ chipProps
185
+ } = defineProps({
186
+ items: { type: Array, required: false },
187
+ resolvedItems: { type: Array, required: false },
188
+ label: { type: String, required: false },
189
+ width: { type: [String, Number], required: false },
190
+ maxChips: { type: Number, required: false },
191
+ maxSelection: { type: [Number, String], required: false },
192
+ emitRawValue: { type: Boolean, required: false },
193
+ location: { type: null, required: false },
194
+ hideSearch: { type: Boolean, required: false },
195
+ clearable: { type: Boolean, required: false },
196
+ loading: { type: Boolean, required: false },
197
+ multiple: { type: Boolean, required: false },
198
+ mandatory: { type: Boolean, required: false },
199
+ hideColor: { type: Boolean, required: false },
200
+ chipProps: { type: Object, required: false },
201
+ truncateChipText: { type: Boolean, required: false },
202
+ onIntersectLast: { type: Function, required: false }
203
+ });
204
+ const defaults = useDefaults({ get chipProps() {
205
+ return chipProps;
206
+ } }, "WeDtSelectFilter");
207
+ const model = defineModel({ type: null, ...{
208
+ default: () => null
209
+ } });
210
+ const search = defineModel("search", {
211
+ type: String,
212
+ default: ""
213
+ });
214
+ const menu = defineModel("menu", {
215
+ type: Boolean,
216
+ default: false
217
+ });
218
+ function reset() {
219
+ model.value = null;
220
+ menu.value = false;
221
+ }
222
+ const singleValue = ref(false);
223
+ function isSelected(item) {
224
+ const selectedValue = (emitRawValue ? model.value : model.value?.value) ?? [];
225
+ if (multiple) {
226
+ return selectedValue.includes(item.value);
227
+ }
228
+ return item.value === selectedValue;
229
+ }
230
+ const selectedItems = computed(() => {
231
+ const selected = (emitRawValue ? model.value : model.value?.value) ?? [];
232
+ const values = selected === null || selected === void 0 ? [] : Array.isArray(selected) ? selected : [selected];
233
+ return values.map((v) => {
234
+ const item = items.find((i) => i.value === v) ?? resolvedItems.find((i) => i.value === v);
235
+ if (item) {
236
+ return item;
237
+ }
238
+ return { value: v, title: String(v) };
239
+ }).filter(Boolean);
240
+ });
241
+ watch([() => multiple, singleValue], () => {
242
+ emitValue(selectedItems.value.length ? selectedItems.value[0]?.value : []);
243
+ });
244
+ const maxSelectionNumber = computed(() => {
245
+ if (maxSelection == null || maxSelection === "") {
246
+ return null;
247
+ }
248
+ const parsed = Number(maxSelection);
249
+ return Number.isNaN(parsed) ? null : parsed;
250
+ });
251
+ const maxReached = computed(
252
+ () => multiple && maxSelectionNumber.value !== null && selectedItems.value.length >= maxSelectionNumber.value
253
+ );
254
+ function isItemDisabled(item) {
255
+ return maxReached.value && !isSelected(item);
256
+ }
257
+ const virtualScrollHeight = computed(() => {
258
+ const itemHeight = 48;
259
+ return Math.min(itemHeight * items.length, 400);
260
+ });
261
+ const filteredItems = computed(() => {
262
+ if (!search.value) {
263
+ return items;
264
+ }
265
+ return items.filter((item) => itemLabel(item).toLowerCase().includes(search.value.toLowerCase()));
266
+ });
267
+ function itemLabel(item) {
268
+ return item.title ?? item.text ?? "";
269
+ }
270
+ function safeValue(value) {
271
+ return multiple ? Array.isArray(value) ? value : [value] : Array.isArray(value) ? value[0] : value;
272
+ }
273
+ function defaultValue() {
274
+ return multiple ? [] : null;
275
+ }
276
+ const allSelected = computed(
277
+ () => filteredItems.value.length > 0 && filteredItems.value.every(isSelected)
278
+ );
279
+ const someSelected = computed(() => filteredItems.value.some(isSelected));
280
+ function currentValues() {
281
+ const raw = (emitRawValue ? model.value : model.value?.value) ?? defaultValue();
282
+ return Array.isArray(raw) ? raw : raw != null ? [raw] : [];
283
+ }
284
+ function selectAll() {
285
+ const filtered = new Set(filteredItems.value.map((i) => i.value));
286
+ const merged = [.../* @__PURE__ */ new Set([...currentValues(), ...filtered])];
287
+ emitValue(merged);
288
+ }
289
+ function deselectAll() {
290
+ const filtered = new Set(filteredItems.value.map((i) => i.value));
291
+ emitValue(currentValues().filter((v) => !filtered.has(v)));
292
+ }
293
+ function toggle(s) {
294
+ const value = safeValue((emitRawValue ? model.value : model.value?.value) ?? defaultValue());
295
+ const selected = isSelected(s);
296
+ const onlyOneItemSelected = multiple ? value.length === 1 : value !== null;
297
+ if (mandatory && onlyOneItemSelected && selected) {
298
+ return;
299
+ }
300
+ if (!selected && isItemDisabled(s)) {
301
+ return;
302
+ }
303
+ if (singleValue.value || multiple === false) {
304
+ emitValue(selected ? [] : [s.value]);
305
+ menu.value = false;
306
+ return;
307
+ }
308
+ if (selected) {
309
+ emitValue(value.filter((v) => v !== s.value));
310
+ } else {
311
+ emitValue([...value, s.value]);
312
+ }
313
+ }
314
+ function emitValue(v) {
315
+ const val = safeValue(v);
316
+ model.value = emitRawValue ? val : {
317
+ operator: multiple ? "in" : "=",
318
+ value: val || defaultValue()
319
+ };
320
+ }
321
+ </script>
322
+
323
+ <style>
324
+ .dt-filters_truncate-chip-content {
325
+ max-width: 120px !important;
326
+ }
327
+ .dt-filters_truncate-chip-content .v-chip__content {
328
+ text-overflow: ellipsis !important;
329
+ display: block !important;
330
+ overflow: hidden !important;
331
+ white-space: nowrap !important;
332
+ }
333
+ </style>
@@ -0,0 +1,60 @@
1
+ import type { Anchor } from 'vuetify';
2
+ import type { DtFilterSelectItem } from './dt.types.js';
3
+ type __VLS_Props = {
4
+ items?: DtFilterSelectItem[];
5
+ resolvedItems?: DtFilterSelectItem[];
6
+ label?: string;
7
+ width?: string | number;
8
+ maxChips?: number;
9
+ maxSelection?: number | string;
10
+ emitRawValue?: boolean;
11
+ location?: Anchor;
12
+ hideSearch?: boolean;
13
+ clearable?: boolean;
14
+ loading?: boolean;
15
+ multiple?: boolean;
16
+ mandatory?: boolean;
17
+ hideColor?: boolean;
18
+ chipProps?: Record<string, unknown>;
19
+ truncateChipText?: boolean;
20
+ onIntersectLast?: (isIntersecting: boolean) => void;
21
+ };
22
+ declare const search: import("vue").ModelRef<string, string, string, string>;
23
+ declare const menu: import("vue").ModelRef<boolean, string, boolean, boolean>;
24
+ type __VLS_PublicProps = __VLS_Props & {
25
+ modelValue?: any | {
26
+ value: any;
27
+ };
28
+ 'search'?: typeof search['value'];
29
+ 'menu'?: typeof menu['value'];
30
+ };
31
+ declare var __VLS_70: {
32
+ filteredItems: any;
33
+ selectAll: any;
34
+ deselectAll: any;
35
+ allSelected: any;
36
+ someSelected: any;
37
+ }, __VLS_96: {
38
+ item: any;
39
+ };
40
+ type __VLS_Slots = {} & {
41
+ 'before-list'?: (props: typeof __VLS_70) => any;
42
+ } & {
43
+ 'item-title'?: (props: typeof __VLS_96) => any;
44
+ };
45
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
46
+ "update:modelValue": (value: any) => any;
47
+ "update:search": (value: string) => any;
48
+ "update:menu": (value: boolean) => any;
49
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
50
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
51
+ "onUpdate:search"?: ((value: string) => any) | undefined;
52
+ "onUpdate:menu"?: ((value: boolean) => any) | undefined;
53
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
54
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
55
+ export default _default;
56
+ type __VLS_WithSlots<T, S> = T & {
57
+ new (): {
58
+ $slots: S;
59
+ };
60
+ };
@@ -0,0 +1,43 @@
1
+ import type { Anchor } from 'vuetify';
2
+ import type { PaginateOptions } from '~/src/runtime/composables/usePaginatedFetch';
3
+ type __VLS_Props = {
4
+ resource: string;
5
+ itemValue?: string;
6
+ itemText?: string | ((item: any) => string);
7
+ paginate?: PaginateOptions;
8
+ lazy?: boolean;
9
+ extraParams?: Record<string, any>;
10
+ waitForInteraction?: boolean;
11
+ resolvedItems?: any[];
12
+ label?: string;
13
+ maxChips?: number;
14
+ hideColor?: boolean;
15
+ emitRawValue?: boolean;
16
+ location?: Anchor;
17
+ width?: string | number;
18
+ };
19
+ type __VLS_PublicProps = __VLS_Props & {
20
+ modelValue?: any | {
21
+ value: any;
22
+ };
23
+ };
24
+ declare var __VLS_10: {
25
+ item: any;
26
+ }, __VLS_12: any;
27
+ type __VLS_Slots = {} & {
28
+ 'item-title'?: (props: typeof __VLS_10) => any;
29
+ } & {
30
+ 'before-list'?: (props: typeof __VLS_12) => any;
31
+ };
32
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ "update:modelValue": (value: any) => any;
34
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
35
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
36
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
38
+ export default _default;
39
+ type __VLS_WithSlots<T, S> = T & {
40
+ new (): {
41
+ $slots: S;
42
+ };
43
+ };
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <WeDtSelectFilter
3
+ v-model="model"
4
+ v-model:search="search"
5
+ v-bind="$attrs"
6
+ :items="selectItems"
7
+ :emit-raw-value
8
+ :label
9
+ :width
10
+ :max-chips
11
+ :location
12
+ :loading
13
+ :hide-color
14
+ :on-intersect-last="infiniteScrolling"
15
+ @update:menu="handleUpdateSelectFilterMenu"
16
+ >
17
+ <template #item-title="{ item }">
18
+ <slot name="item-title" :item="item" />
19
+ </template>
20
+ <template
21
+ v-if="$slots['before-list']"
22
+ #before-list="slotProps"
23
+ >
24
+ <slot name="before-list" v-bind="slotProps" />
25
+ </template>
26
+ </WeDtSelectFilter>
27
+ </template>
28
+
29
+ <script setup>
30
+ import { usePaginatedFetch } from "#imports";
31
+ import { computed, reactive, ref, toRaw, watch } from "vue";
32
+ const {
33
+ resource,
34
+ itemValue = "id",
35
+ itemText = "name",
36
+ paginate = true,
37
+ lazy = false,
38
+ extraParams = {},
39
+ waitForInteraction,
40
+ emitRawValue = false,
41
+ label,
42
+ maxChips = 2,
43
+ hideColor = false,
44
+ width = "400px",
45
+ location = "bottom end",
46
+ resolvedItems = []
47
+ } = defineProps({
48
+ resource: { type: String, required: true },
49
+ itemValue: { type: String, required: false },
50
+ itemText: { type: [String, Function], required: false },
51
+ paginate: { type: [Boolean, Object], required: false },
52
+ lazy: { type: Boolean, required: false },
53
+ extraParams: { type: Object, required: false },
54
+ waitForInteraction: { type: Boolean, required: false },
55
+ resolvedItems: { type: Array, required: false },
56
+ label: { type: String, required: false },
57
+ maxChips: { type: Number, required: false },
58
+ hideColor: { type: Boolean, required: false },
59
+ emitRawValue: { type: Boolean, required: false },
60
+ location: { type: null, required: false },
61
+ width: { type: [String, Number], required: false }
62
+ });
63
+ const model = defineModel({ type: null, ...{
64
+ default: () => null
65
+ } });
66
+ const search = ref("");
67
+ const userHasInteracted = ref(false);
68
+ function handleUpdateSelectFilterMenu(value) {
69
+ if (value) {
70
+ userHasInteracted.value = true;
71
+ }
72
+ }
73
+ const frozen = computed(() => {
74
+ return waitForInteraction && !userHasInteracted.value;
75
+ });
76
+ const { items: apiItems, hasMore, loadMore, loading } = usePaginatedFetch(
77
+ resource,
78
+ {
79
+ search,
80
+ extraParams: () => extraParams,
81
+ paginate: () => paginate,
82
+ lazy: () => lazy,
83
+ frozen,
84
+ onError: (e) => {
85
+ console.error(e);
86
+ }
87
+ }
88
+ );
89
+ function infiniteScrolling(isIntersecting) {
90
+ if (!isIntersecting || !hasMore.value || loading.value || paginate === false) {
91
+ return;
92
+ }
93
+ loadMore();
94
+ }
95
+ const cacheFetchedItems = reactive({});
96
+ watch(apiItems, (newItems) => {
97
+ newItems.forEach((item) => {
98
+ cacheFetchedItems[item[itemValue]] = item;
99
+ });
100
+ });
101
+ watch(() => resolvedItems, (newItems) => {
102
+ newItems.forEach((item) => {
103
+ if (!cacheFetchedItems[item[itemValue]]) {
104
+ cacheFetchedItems[item[itemValue]] = item;
105
+ }
106
+ });
107
+ }, { immediate: true });
108
+ const items = computed(() => {
109
+ const selectedItemsRaw = emitRawValue ? toRaw(model.value) || [] : toRaw(model.value)?.value || [];
110
+ const selectedItems = Array.isArray(selectedItemsRaw) ? selectedItemsRaw : [selectedItemsRaw].filter(Boolean);
111
+ const ret = [...apiItems.value];
112
+ selectedItems.map((item) => cacheFetchedItems[item]).filter(Boolean).forEach((selectedItem) => {
113
+ if (!ret.find((item) => item[itemValue] === selectedItem[itemValue])) {
114
+ ret.push(selectedItem);
115
+ }
116
+ });
117
+ return ret;
118
+ });
119
+ function mapToSelectItem(item) {
120
+ return {
121
+ ...item,
122
+ value: item[itemValue],
123
+ text: typeof itemText === "function" ? itemText(item) : item[itemText]
124
+ };
125
+ }
126
+ const selectItems = computed(() => items.value.map(mapToSelectItem));
127
+ </script>
@@ -0,0 +1,43 @@
1
+ import type { Anchor } from 'vuetify';
2
+ import type { PaginateOptions } from '~/src/runtime/composables/usePaginatedFetch';
3
+ type __VLS_Props = {
4
+ resource: string;
5
+ itemValue?: string;
6
+ itemText?: string | ((item: any) => string);
7
+ paginate?: PaginateOptions;
8
+ lazy?: boolean;
9
+ extraParams?: Record<string, any>;
10
+ waitForInteraction?: boolean;
11
+ resolvedItems?: any[];
12
+ label?: string;
13
+ maxChips?: number;
14
+ hideColor?: boolean;
15
+ emitRawValue?: boolean;
16
+ location?: Anchor;
17
+ width?: string | number;
18
+ };
19
+ type __VLS_PublicProps = __VLS_Props & {
20
+ modelValue?: any | {
21
+ value: any;
22
+ };
23
+ };
24
+ declare var __VLS_10: {
25
+ item: any;
26
+ }, __VLS_12: any;
27
+ type __VLS_Slots = {} & {
28
+ 'item-title'?: (props: typeof __VLS_10) => any;
29
+ } & {
30
+ 'before-list'?: (props: typeof __VLS_12) => any;
31
+ };
32
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ "update:modelValue": (value: any) => any;
34
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
35
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
36
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
38
+ export default _default;
39
+ type __VLS_WithSlots<T, S> = T & {
40
+ new (): {
41
+ $slots: S;
42
+ };
43
+ };
@@ -0,0 +1,8 @@
1
+ export type DtFilterSelectItem = {
2
+ value: unknown
3
+ color?: string
4
+ icon?: string
5
+ } & (
6
+ { title: string, text?: never }
7
+ | { text: string, title?: never }
8
+ )
@@ -0,0 +1,12 @@
1
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
2
+ export default _default;
3
+ type __VLS_WithSlots<T, S> = T & (new () => {
4
+ $slots: S;
5
+ });
6
+ declare const __VLS_component: import("vue").DefineComponent<{}, {
7
+ password: string;
8
+ $props: any;
9
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
10
+ type __VLS_Slots = {
11
+ activator?: ((props: any) => any) | undefined;
12
+ };