@aziontech/webkit 0.0.1

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 (105) hide show
  1. package/package.json +46 -0
  2. package/src/core/field-auto-complete/field-auto-complete.vue +121 -0
  3. package/src/core/field-auto-complete/field-auto-complete.vue.d.ts +107 -0
  4. package/src/core/field-auto-complete/field-auto-complete.vue.d.ts.map +1 -0
  5. package/src/core/field-auto-complete/package.json +11 -0
  6. package/src/core/field-checkbox-block/field-checkbox-block.vue +106 -0
  7. package/src/core/field-checkbox-block/field-checkbox-block.vue.d.ts +111 -0
  8. package/src/core/field-checkbox-block/field-checkbox-block.vue.d.ts.map +1 -0
  9. package/src/core/field-checkbox-block/package.json +11 -0
  10. package/src/core/field-dropdown/field-dropdown.vue +240 -0
  11. package/src/core/field-dropdown/field-dropdown.vue.d.ts +203 -0
  12. package/src/core/field-dropdown/field-dropdown.vue.d.ts.map +1 -0
  13. package/src/core/field-dropdown/package.json +11 -0
  14. package/src/core/field-dropdown-icon/field-dropdown-icon.vue +129 -0
  15. package/src/core/field-dropdown-icon/field-dropdown-icon.vue.d.ts +111 -0
  16. package/src/core/field-dropdown-icon/field-dropdown-icon.vue.d.ts.map +1 -0
  17. package/src/core/field-dropdown-icon/package.json +11 -0
  18. package/src/core/field-dropdown-lazy-loader/field-dropdown-lazy-loader.vue +631 -0
  19. package/src/core/field-dropdown-lazy-loader/field-dropdown-lazy-loader.vue.d.ts +196 -0
  20. package/src/core/field-dropdown-lazy-loader/field-dropdown-lazy-loader.vue.d.ts.map +1 -0
  21. package/src/core/field-dropdown-lazy-loader/package.json +11 -0
  22. package/src/core/field-dropdown-lazy-loader-dynamic/field-dropdown-lazy-loader-dynamic.vue +426 -0
  23. package/src/core/field-dropdown-lazy-loader-dynamic/field-dropdown-lazy-loader-dynamic.vue.d.ts +158 -0
  24. package/src/core/field-dropdown-lazy-loader-dynamic/field-dropdown-lazy-loader-dynamic.vue.d.ts.map +1 -0
  25. package/src/core/field-dropdown-lazy-loader-dynamic/package.json +11 -0
  26. package/src/core/field-dropdown-lazy-loader-with-filter/field-dropdown-lazy-loader-with-filter.vue +527 -0
  27. package/src/core/field-dropdown-lazy-loader-with-filter/field-dropdown-lazy-loader-with-filter.vue.d.ts +203 -0
  28. package/src/core/field-dropdown-lazy-loader-with-filter/field-dropdown-lazy-loader-with-filter.vue.d.ts.map +1 -0
  29. package/src/core/field-dropdown-lazy-loader-with-filter/package.json +11 -0
  30. package/src/core/field-dropdown-multi-select-lazy-loader/field-dropdown-multi-select-lazy-loader.vue +439 -0
  31. package/src/core/field-dropdown-multi-select-lazy-loader/field-dropdown-multi-select-lazy-loader.vue.d.ts +162 -0
  32. package/src/core/field-dropdown-multi-select-lazy-loader/field-dropdown-multi-select-lazy-loader.vue.d.ts.map +1 -0
  33. package/src/core/field-dropdown-multi-select-lazy-loader/package.json +11 -0
  34. package/src/core/field-group-checkbox/field-group-checkbox.vue +102 -0
  35. package/src/core/field-group-checkbox/field-group-checkbox.vue.d.ts +87 -0
  36. package/src/core/field-group-checkbox/field-group-checkbox.vue.d.ts.map +1 -0
  37. package/src/core/field-group-checkbox/package.json +11 -0
  38. package/src/core/field-group-radio/field-group-radio.vue +149 -0
  39. package/src/core/field-group-radio/field-group-radio.vue.d.ts +99 -0
  40. package/src/core/field-group-radio/field-group-radio.vue.d.ts.map +1 -0
  41. package/src/core/field-group-radio/package.json +11 -0
  42. package/src/core/field-group-switch/field-group-switch.vue +121 -0
  43. package/src/core/field-group-switch/field-group-switch.vue.d.ts +87 -0
  44. package/src/core/field-group-switch/field-group-switch.vue.d.ts.map +1 -0
  45. package/src/core/field-group-switch/package.json +11 -0
  46. package/src/core/field-input-group/field-input-group.vue +111 -0
  47. package/src/core/field-input-group/field-input-group.vue.d.ts +87 -0
  48. package/src/core/field-input-group/field-input-group.vue.d.ts.map +1 -0
  49. package/src/core/field-input-group/package.json +11 -0
  50. package/src/core/field-multi-select/field-multi-select.vue +167 -0
  51. package/src/core/field-multi-select/field-multi-select.vue.d.ts +136 -0
  52. package/src/core/field-multi-select/field-multi-select.vue.d.ts.map +1 -0
  53. package/src/core/field-multi-select/package.json +11 -0
  54. package/src/core/field-number/field-number.vue +144 -0
  55. package/src/core/field-number/field-number.vue.d.ts +132 -0
  56. package/src/core/field-number/field-number.vue.d.ts.map +1 -0
  57. package/src/core/field-number/package.json +11 -0
  58. package/src/core/field-phone-number/field-phone-number.vue +151 -0
  59. package/src/core/field-phone-number/field-phone-number.vue.d.ts +76 -0
  60. package/src/core/field-phone-number/field-phone-number.vue.d.ts.map +1 -0
  61. package/src/core/field-phone-number/package.json +11 -0
  62. package/src/core/field-phone-number-country/field-phone-number-country.vue +60 -0
  63. package/src/core/field-phone-number-country/field-phone-number-country.vue.d.ts +18 -0
  64. package/src/core/field-phone-number-country/field-phone-number-country.vue.d.ts.map +1 -0
  65. package/src/core/field-phone-number-country/package.json +11 -0
  66. package/src/core/field-pick-list/field-pick-list.vue +285 -0
  67. package/src/core/field-pick-list/field-pick-list.vue.d.ts +43 -0
  68. package/src/core/field-pick-list/field-pick-list.vue.d.ts.map +1 -0
  69. package/src/core/field-pick-list/package.json +11 -0
  70. package/src/core/field-radio-block/field-radio-block.vue +108 -0
  71. package/src/core/field-radio-block/field-radio-block.vue.d.ts +115 -0
  72. package/src/core/field-radio-block/field-radio-block.vue.d.ts.map +1 -0
  73. package/src/core/field-radio-block/package.json +11 -0
  74. package/src/core/field-switch/field-switch.vue +41 -0
  75. package/src/core/field-switch/field-switch.vue.d.ts +33 -0
  76. package/src/core/field-switch/field-switch.vue.d.ts.map +1 -0
  77. package/src/core/field-switch/package.json +11 -0
  78. package/src/core/field-switch-block/field-switch-block.vue +123 -0
  79. package/src/core/field-switch-block/field-switch-block.vue.d.ts +123 -0
  80. package/src/core/field-switch-block/field-switch-block.vue.d.ts.map +1 -0
  81. package/src/core/field-switch-block/package.json +11 -0
  82. package/src/core/field-text/field-text.vue +128 -0
  83. package/src/core/field-text/field-text.vue.d.ts +108 -0
  84. package/src/core/field-text/field-text.vue.d.ts.map +1 -0
  85. package/src/core/field-text/package.json +11 -0
  86. package/src/core/field-text-area/field-text-area.vue +178 -0
  87. package/src/core/field-text-area/field-text-area.vue.d.ts +142 -0
  88. package/src/core/field-text-area/field-text-area.vue.d.ts.map +1 -0
  89. package/src/core/field-text-area/package.json +11 -0
  90. package/src/core/field-text-icon/field-text-icon.vue +127 -0
  91. package/src/core/field-text-icon/field-text-icon.vue.d.ts +100 -0
  92. package/src/core/field-text-icon/field-text-icon.vue.d.ts.map +1 -0
  93. package/src/core/field-text-icon/package.json +11 -0
  94. package/src/core/field-text-password/field-text-password.vue +127 -0
  95. package/src/core/field-text-password/field-text-password.vue.d.ts +108 -0
  96. package/src/core/field-text-password/field-text-password.vue.d.ts.map +1 -0
  97. package/src/core/field-text-password/package.json +11 -0
  98. package/src/core/label/label.vue +35 -0
  99. package/src/core/label/label.vue.d.ts +24 -0
  100. package/src/core/label/label.vue.d.ts.map +1 -0
  101. package/src/core/label/package.json +11 -0
  102. package/src/core/selector-block/package.json +11 -0
  103. package/src/core/selector-block/selector-block.vue +128 -0
  104. package/src/core/selector-block/selector-block.vue.d.ts +99 -0
  105. package/src/core/selector-block/selector-block.vue.d.ts.map +1 -0
@@ -0,0 +1,158 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
+ type __VLS_WithSlots<T, S> = T & (new () => {
5
+ $slots: S;
6
+ });
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ value: {
9
+ type: (StringConstructor | NumberConstructor)[];
10
+ default: string;
11
+ };
12
+ name: {
13
+ type: StringConstructor;
14
+ required: true;
15
+ };
16
+ label: {
17
+ type: StringConstructor;
18
+ default: string;
19
+ };
20
+ placeholder: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ description: {
25
+ type: StringConstructor;
26
+ default: string;
27
+ };
28
+ optionLabel: {
29
+ type: StringConstructor;
30
+ default: string;
31
+ };
32
+ optionValue: {
33
+ type: StringConstructor;
34
+ default: string;
35
+ };
36
+ moreOptions: {
37
+ type: ArrayConstructor;
38
+ default: null;
39
+ };
40
+ optionDisabled: {
41
+ type: (StringConstructor | FunctionConstructor)[];
42
+ default: string;
43
+ };
44
+ service: {
45
+ type: FunctionConstructor;
46
+ required: true;
47
+ };
48
+ loadService: {
49
+ type: FunctionConstructor;
50
+ required: true;
51
+ };
52
+ enableWorkaroundLabelToDisabledOptions: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ enableClearOption: {
57
+ type: BooleanConstructor;
58
+ default: boolean;
59
+ };
60
+ disableEmitFirstRender: {
61
+ type: BooleanConstructor;
62
+ default: boolean;
63
+ };
64
+ initalData: {
65
+ type: ArrayConstructor;
66
+ default: () => never[];
67
+ require: boolean;
68
+ };
69
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
70
+ onBlur: (...args: any[]) => void;
71
+ onChange: (...args: any[]) => void;
72
+ onSelectOption: (...args: any[]) => void;
73
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
74
+ value: {
75
+ type: (StringConstructor | NumberConstructor)[];
76
+ default: string;
77
+ };
78
+ name: {
79
+ type: StringConstructor;
80
+ required: true;
81
+ };
82
+ label: {
83
+ type: StringConstructor;
84
+ default: string;
85
+ };
86
+ placeholder: {
87
+ type: StringConstructor;
88
+ default: string;
89
+ };
90
+ description: {
91
+ type: StringConstructor;
92
+ default: string;
93
+ };
94
+ optionLabel: {
95
+ type: StringConstructor;
96
+ default: string;
97
+ };
98
+ optionValue: {
99
+ type: StringConstructor;
100
+ default: string;
101
+ };
102
+ moreOptions: {
103
+ type: ArrayConstructor;
104
+ default: null;
105
+ };
106
+ optionDisabled: {
107
+ type: (StringConstructor | FunctionConstructor)[];
108
+ default: string;
109
+ };
110
+ service: {
111
+ type: FunctionConstructor;
112
+ required: true;
113
+ };
114
+ loadService: {
115
+ type: FunctionConstructor;
116
+ required: true;
117
+ };
118
+ enableWorkaroundLabelToDisabledOptions: {
119
+ type: BooleanConstructor;
120
+ default: boolean;
121
+ };
122
+ enableClearOption: {
123
+ type: BooleanConstructor;
124
+ default: boolean;
125
+ };
126
+ disableEmitFirstRender: {
127
+ type: BooleanConstructor;
128
+ default: boolean;
129
+ };
130
+ initalData: {
131
+ type: ArrayConstructor;
132
+ default: () => never[];
133
+ require: boolean;
134
+ };
135
+ }>> & Readonly<{
136
+ onOnBlur?: ((...args: any[]) => any) | undefined;
137
+ onOnChange?: ((...args: any[]) => any) | undefined;
138
+ onOnSelectOption?: ((...args: any[]) => any) | undefined;
139
+ }>, {
140
+ value: string | number;
141
+ label: string;
142
+ placeholder: string;
143
+ description: string;
144
+ optionLabel: string;
145
+ optionDisabled: string | Function;
146
+ optionValue: string;
147
+ enableWorkaroundLabelToDisabledOptions: boolean;
148
+ moreOptions: unknown[];
149
+ enableClearOption: boolean;
150
+ disableEmitFirstRender: boolean;
151
+ initalData: unknown[];
152
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
153
+ type __VLS_Slots = {
154
+ footer?: ((props: {}) => any) | undefined;
155
+ } & {
156
+ description?: ((props: {}) => any) | undefined;
157
+ };
158
+ //# sourceMappingURL=field-dropdown-lazy-loader-dynamic.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-dropdown-lazy-loader-dynamic.vue.d.ts","sourceRoot":"","sources":["field-dropdown-lazy-loader-dynamic.vue"],"names":[],"mappings":"wBAsiCqB,OAAO,YAAY;;AADxC,4BAA2B,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;qBAEtD,CAAC,EAAE,CAAC;;;AApEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAiEG"}
@@ -0,0 +1,11 @@
1
+ {
2
+ "main": "./field-dropdown-lazy-loader-dynamic.vue",
3
+ "module": "./field-dropdown-lazy-loader-dynamic.vue",
4
+ "types": "./field-dropdown-lazy-loader-dynamic.vue.d.ts",
5
+ "browser": {
6
+ "./sfc": "./field-dropdown-lazy-loader-dynamic.vue"
7
+ },
8
+ "sideEffects": [
9
+ "*.vue"
10
+ ]
11
+ }
@@ -0,0 +1,527 @@
1
+ <template>
2
+ <LabelBlock
3
+ v-if="props.label"
4
+ :for="props.name"
5
+ :label="props.label"
6
+ :isRequired="$attrs.required"
7
+ :data-testid="customTestId.label"
8
+ />
9
+ <Dropdown
10
+ appendTo="self"
11
+ :id="name"
12
+ :name="props.name"
13
+ :loading="loading"
14
+ v-model="inputValue"
15
+ :options="data"
16
+ :optionLabel="props.optionLabel"
17
+ :optionDisabled="props.optionDisabled"
18
+ :optionValue="props.optionValue"
19
+ :placeholder="props.placeholder"
20
+ :showClear="props.enableClearOption"
21
+ @change="emitChange"
22
+ @blur="emitBlur"
23
+ :class="errorMessage ? 'p-invalid' : ''"
24
+ v-bind="$attrs"
25
+ class="w-full"
26
+ :optionGroupLabel="props.optionGroupLabel"
27
+ :optionGroupChildren="props.optionGroupChildren"
28
+ :pt="{
29
+ clearIcon: {
30
+ 'data-testid': customTestId.clearIcon
31
+ },
32
+ filterInput: {
33
+ class: 'w-full',
34
+ 'data-testid': customTestId.filterInput
35
+ },
36
+ trigger: {
37
+ 'data-testid': customTestId.trigger
38
+ },
39
+ loadingIcon: {
40
+ 'data-testid': customTestId.loadingIcon
41
+ }
42
+ }"
43
+ :data-testid="customTestId.dropdown"
44
+ :virtualScrollerOptions="VIRTUAL_SCROLLER_CONFIG"
45
+ >
46
+ <template
47
+ v-if="enableCustomLabel"
48
+ #value="slotProps"
49
+ >
50
+ <span :data-testid="customTestId.value">
51
+ {{ getLabelBySelectedValue(slotProps.value) }}
52
+ </span>
53
+ </template>
54
+ <template #option="slotProps">
55
+ <div class="flex align-items-center gap-2">
56
+ <i
57
+ v-if="slotProps.option.icon"
58
+ :class="`pi ${slotProps.option.icon}`"
59
+ ></i>
60
+ <div>{{ slotProps.option.name }}</div>
61
+ </div>
62
+ </template>
63
+
64
+ <template #header>
65
+ <div class="p-2 flex">
66
+ <div class="p-inputgroup">
67
+ <InputText
68
+ type="text"
69
+ v-model="search"
70
+ placeholder="Search"
71
+ class="w-full rounded-r-none"
72
+ ref="focusSearch"
73
+ :data-testid="customTestId.search"
74
+ />
75
+ <span
76
+ class="p-inputgroup-addon"
77
+ @click="searchFilter"
78
+ >
79
+ <i class="pi pi-search"></i>
80
+ </span>
81
+ </div>
82
+ </div>
83
+ </template>
84
+
85
+ <template #footer>
86
+ <slot name="footer" />
87
+ </template>
88
+ </Dropdown>
89
+
90
+ <small
91
+ v-if="errorMessage"
92
+ :data-testid="customTestId.error"
93
+ class="p-error text-xs font-normal leading-tight"
94
+ >
95
+ {{ errorMessage }}
96
+ </small>
97
+ <small
98
+ class="text-xs text-color-secondary font-normal leading-5"
99
+ :data-testid="customTestId.description"
100
+ v-if="props.description || hasDescriptionSlot"
101
+ >
102
+ <slot name="description">
103
+ {{ props.description }}
104
+ </slot>
105
+ </small>
106
+ </template>
107
+
108
+ <script setup>
109
+ import Dropdown from 'primevue/dropdown'
110
+ import InputText from 'primevue/inputtext'
111
+ import { useField } from 'vee-validate'
112
+ import { computed, toRef, useSlots, useAttrs, ref, onMounted, watchEffect, watch } from 'vue'
113
+ import { watchDebounced } from '@vueuse/core'
114
+ import LabelBlock from '../label'
115
+
116
+ const props = defineProps({
117
+ value: {
118
+ type: [String, Number],
119
+ default: ''
120
+ },
121
+ name: {
122
+ type: String,
123
+ required: true
124
+ },
125
+ label: {
126
+ type: String,
127
+ default: ''
128
+ },
129
+ placeholder: {
130
+ type: String,
131
+ default: ''
132
+ },
133
+ description: {
134
+ type: String,
135
+ default: ''
136
+ },
137
+ optionLabel: {
138
+ type: String,
139
+ default: ''
140
+ },
141
+ optionValue: {
142
+ type: String,
143
+ default: ''
144
+ },
145
+ moreOptions: {
146
+ type: Array,
147
+ default: null
148
+ },
149
+ optionDisabled: {
150
+ type: [String, Function],
151
+ default: ''
152
+ },
153
+ service: {
154
+ type: Function,
155
+ required: true
156
+ },
157
+ loadService: {
158
+ type: Function,
159
+ required: true
160
+ },
161
+ enableWorkaroundLabelToDisabledOptions: {
162
+ type: Boolean,
163
+ default: false
164
+ },
165
+ enableClearOption: {
166
+ type: Boolean,
167
+ default: false
168
+ },
169
+ disableEmitFirstRender: {
170
+ type: Boolean,
171
+ default: false
172
+ },
173
+ keyToFilter: {
174
+ type: String,
175
+ default: ''
176
+ },
177
+ valuesToFilter: {
178
+ type: Array,
179
+ default: () => []
180
+ },
181
+ showGroup: {
182
+ type: Boolean,
183
+ default: false
184
+ },
185
+ optionGroupLabel: {
186
+ type: String,
187
+ default: ''
188
+ },
189
+ optionGroupChildren: {
190
+ type: String,
191
+ default: ''
192
+ },
193
+ defaultGroup: {
194
+ type: String,
195
+ default: ''
196
+ }
197
+ })
198
+
199
+ const emit = defineEmits(['onBlur', 'onChange', 'onSelectOption', 'onAccessDenied'])
200
+
201
+ const PAGE_INCREMENT = 1
202
+ const PAGE_SIZE = 100
203
+ const INITIAL_PAGE = 1
204
+ const SEARCH_DEBOUNCE = 500
205
+ const SEARCH_MAX_WAIT = 1000
206
+ const NUMBER_OF_CHARACTERS_MIN_FOR_SEARCH = 3
207
+ const NUMBER_OF_CHARACTERS_TO_RESET_SEARCH = 0
208
+ const PERMISSION_DENIED = 'You do not have permission'
209
+ const hasNoPermission = ref(false)
210
+ const notRequest = ref(false)
211
+ const name = toRef(props, 'name')
212
+ const slots = useSlots()
213
+ const data = ref([])
214
+ const loading = ref(false)
215
+ const totalCount = ref(0)
216
+ const page = ref(INITIAL_PAGE)
217
+ const search = ref('')
218
+ const focusSearch = ref(null)
219
+ const disableEmitInit = ref(props.disableEmitFirstRender)
220
+
221
+ onMounted(async () => {
222
+ await fetchData()
223
+ })
224
+
225
+ const hasDescriptionSlot = !!slots.description
226
+ const { value: inputValue, errorMessage } = useField(name, undefined, {
227
+ initialValue: props.value
228
+ })
229
+
230
+ const handleLazyLoad = async (event) => {
231
+ const { last } = event
232
+ let totalItems = 0
233
+
234
+ if (props.showGroup) {
235
+ totalItems = data.value.reduce((acc, group) => acc + group.items.length, 0)
236
+ } else {
237
+ totalItems = data.value.length
238
+ }
239
+
240
+ if (!notRequest.value && last >= totalItems) {
241
+ try {
242
+ page.value += PAGE_INCREMENT
243
+ await fetchData(page.value)
244
+ } catch (error) {
245
+ notRequest.value = true
246
+ } finally {
247
+ loading.value = false
248
+ }
249
+ }
250
+ }
251
+
252
+ const emitBlur = () => {
253
+ emit('onBlur')
254
+ }
255
+
256
+ const selectedOptionHandler = () => {
257
+ if (props.showGroup) {
258
+ const group = data.value.find((group) => group.group === props.defaultGroup)
259
+ if (!group || !Array.isArray(group.items)) {
260
+ return null
261
+ }
262
+ return group.items.find((item) => item[props.optionValue] === inputValue.value) || null
263
+ }
264
+
265
+ return data.value.find((item) => item[props.optionValue] === inputValue.value) || null
266
+ }
267
+
268
+ const emitChange = () => {
269
+ const selectedOption = selectedOptionHandler()
270
+
271
+ emit('onChange', inputValue.value)
272
+
273
+ if (inputValue.value === null) {
274
+ emit('onClear')
275
+ }
276
+
277
+ if (selectedOption) {
278
+ emit('onSelectOption', selectedOption)
279
+ }
280
+ }
281
+
282
+ const preventValueSetWithoutPermission = () => {
283
+ data.value = [
284
+ {
285
+ [props.optionValue]: props.value,
286
+ name: props.value
287
+ }
288
+ ]
289
+ }
290
+
291
+ const filterData = (result) => {
292
+ const filteredData = result.filter((item) =>
293
+ props.valuesToFilter.includes(item[props.keyToFilter])
294
+ )
295
+ const mappedData = filteredData.map((item) => {
296
+ return {
297
+ [props.optionLabel]: item.name,
298
+ [props.optionValue]: item.id,
299
+ group: item?.group,
300
+ ...props?.moreOptions?.reduce(
301
+ (additionalFields, option) => ({
302
+ ...additionalFields,
303
+ [option]: item[option]
304
+ }),
305
+ {}
306
+ )
307
+ }
308
+ })
309
+
310
+ if (props.showGroup) {
311
+ const groupedData = mappedData.reduce((acc, item) => {
312
+ const group = item.group
313
+ if (!acc[group]) {
314
+ acc[group] = []
315
+ }
316
+ acc[group].push(item)
317
+ return acc
318
+ }, {})
319
+
320
+ return Object.entries(groupedData).map(([group, items]) => ({
321
+ group,
322
+ items
323
+ }))
324
+ }
325
+
326
+ return mappedData
327
+ }
328
+
329
+ /**
330
+ * Workaround to resolve the issue described in https://github.com/primefaces/primevue/issues/4431
331
+ * This should be remove from this field component as soon as the
332
+ * primevue team fixes the issue.
333
+ * When we select a disabled value, the label is not showing
334
+ * @param {*} selectedValue The selected value in the Dropdown component.
335
+ * @returns {string | null} The selected value if it corresponds to a disabled option, or null otherwise.
336
+ */
337
+ const getLabelBySelectedValue = (selectedValue) => {
338
+ const result = props.options.find((option) => option.value === selectedValue)
339
+ return result?.label
340
+ }
341
+
342
+ const fetchData = async (currentPage = 1) => {
343
+ try {
344
+ loading.value = true
345
+
346
+ if (currentPage === INITIAL_PAGE) {
347
+ data.value = []
348
+ }
349
+
350
+ const response = await props.service({
351
+ pageSize: PAGE_SIZE,
352
+ page: currentPage,
353
+ search: search.value,
354
+ ordering: 'name'
355
+ })
356
+
357
+ totalCount.value = response.count
358
+ let results = filterData(response.body)
359
+
360
+ if (currentPage === INITIAL_PAGE) {
361
+ data.value = results ? results : []
362
+ } else {
363
+ const uniqueResults = results.filter(
364
+ (newItem) =>
365
+ !data.value.some((groupOrItem) => {
366
+ if (Array.isArray(groupOrItem.items)) {
367
+ return groupOrItem.items.some(
368
+ (item) => item[props.optionValue] === newItem[props.optionValue]
369
+ )
370
+ }
371
+ return groupOrItem[props.optionValue] === newItem[props.optionValue]
372
+ })
373
+ )
374
+
375
+ if (props.showGroup) {
376
+ data.value = data.value.map((group) => {
377
+ if (group.group === props.defaultGroup) {
378
+ const findGroup = uniqueResults.find((item) => item.group === group.group)
379
+ group.items = [...group.items, ...findGroup.items]
380
+ }
381
+ return group
382
+ })
383
+ } else {
384
+ data.value = [...data.value, ...uniqueResults]
385
+ }
386
+ }
387
+
388
+ if (currentPage === INITIAL_PAGE && props.value && search.value === '') {
389
+ await checkValueInList(props.value)
390
+ }
391
+ } catch (error) {
392
+ //Here we check if the error was caused by a lack of permission. If that's not the case, we add the ID to avoid blocking the user's experience.
393
+ if (typeof error === 'string' && error?.includes(PERMISSION_DENIED)) {
394
+ hasNoPermission.value = true
395
+ preventValueSetWithoutPermission()
396
+ emit('onAccessDenied')
397
+ }
398
+ throw error(error)
399
+ } finally {
400
+ loading.value = false
401
+ }
402
+ }
403
+
404
+ const loadSelectedValue = async (id) => {
405
+ if (!id) return
406
+ try {
407
+ loading.value = true
408
+ const results = await props.loadService({ id })
409
+ if (!results) return
410
+
411
+ const newOption = {
412
+ [props.optionLabel]: results.name,
413
+ [props.optionValue]: results.id,
414
+ ...props?.moreOptions?.reduce(
415
+ (additionalFields, option) => ({
416
+ ...additionalFields,
417
+ [option]: results[option]
418
+ }),
419
+ {}
420
+ )
421
+ }
422
+
423
+ const optionExists = data.value.some(
424
+ (item) => item[props.optionValue] === newOption[props.optionValue]
425
+ )
426
+
427
+ if (!optionExists) {
428
+ if (props.showGroup) {
429
+ data.value.map((item) => {
430
+ if (item.group === props.defaultGroup) {
431
+ item.items.unshift(newOption)
432
+ }
433
+ })
434
+ } else {
435
+ data.value = [...data.value, newOption]
436
+ }
437
+ }
438
+
439
+ if (disableEmitInit.value) {
440
+ disableEmitInit.value = false
441
+ return
442
+ }
443
+ emitChange()
444
+ } finally {
445
+ loading.value = false
446
+ }
447
+ }
448
+
449
+ const searchFilter = () => {
450
+ page.value = INITIAL_PAGE
451
+ fetchData()
452
+ }
453
+
454
+ const enableCustomLabel = computed(() => {
455
+ return props.enableWorkaroundLabelToDisabledOptions && !!inputValue.value
456
+ })
457
+ /**
458
+ * end of primevue workaround
459
+ */
460
+
461
+ const attrs = useAttrs()
462
+
463
+ const customTestId = computed(() => {
464
+ const id = attrs['data-testid'] || 'field-dropdown'
465
+
466
+ return {
467
+ label: `${id}__label`,
468
+ dropdown: `${id}__dropdown`,
469
+ value: `${id}__value`,
470
+ clearIcon: `${id}__clear-icon`,
471
+ description: `${id}__description`,
472
+ error: `${id}__error-message`,
473
+ filterInput: `${id}__dropdown-filter-input`,
474
+ trigger: `${id}__dropdown-trigger`,
475
+ loadingIcon: `${id}__loading-icon`,
476
+ search: `${id}__dropdown-search`
477
+ }
478
+ })
479
+
480
+ watch(
481
+ () => props.value,
482
+ (newValue) => {
483
+ if (hasNoPermission.value) {
484
+ preventValueSetWithoutPermission()
485
+ }
486
+ checkValueInList(newValue)
487
+ }
488
+ )
489
+
490
+ watchDebounced(
491
+ search,
492
+ () => {
493
+ if (
494
+ search.value.length >= NUMBER_OF_CHARACTERS_MIN_FOR_SEARCH ||
495
+ search.value.length === NUMBER_OF_CHARACTERS_TO_RESET_SEARCH
496
+ ) {
497
+ searchFilter()
498
+ }
499
+ },
500
+ { debounce: SEARCH_DEBOUNCE, maxWait: SEARCH_MAX_WAIT }
501
+ )
502
+
503
+ watchEffect(() => {
504
+ if (focusSearch.value) {
505
+ focusSearch.value.$el.focus()
506
+ }
507
+ })
508
+
509
+ const VIRTUAL_SCROLLER_CONFIG = {
510
+ lazy: true,
511
+ onLazyLoad: handleLazyLoad,
512
+ itemSize: 38,
513
+ showLoader: true,
514
+ loading
515
+ }
516
+
517
+ const checkValueInList = (value) => {
518
+ const existitemInList = data.value?.some((item) => item[props.optionValue] === value)
519
+
520
+ if (!existitemInList) {
521
+ loadSelectedValue(value)
522
+ } else {
523
+ const selectedOption = selectedOptionHandler()
524
+ emit('onSelectOption', selectedOption)
525
+ }
526
+ }
527
+ </script>