@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,196 @@
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
+ optionGroupLabel: {
65
+ type: StringConstructor;
66
+ default: string;
67
+ };
68
+ optionGroupChildren: {
69
+ type: StringConstructor;
70
+ default: string;
71
+ };
72
+ defaultPosition: {
73
+ type: NumberConstructor;
74
+ default: number;
75
+ };
76
+ showIcon: {
77
+ type: BooleanConstructor;
78
+ default: boolean;
79
+ };
80
+ iconColor: {
81
+ type: ObjectConstructor;
82
+ default: () => {};
83
+ };
84
+ }>, {
85
+ refreshData: () => Promise<void>;
86
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
87
+ onBlur: (...args: any[]) => void;
88
+ onChange: (...args: any[]) => void;
89
+ onSelectOption: (...args: any[]) => void;
90
+ onAccessDenied: (...args: any[]) => void;
91
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
92
+ value: {
93
+ type: (StringConstructor | NumberConstructor)[];
94
+ default: string;
95
+ };
96
+ name: {
97
+ type: StringConstructor;
98
+ required: true;
99
+ };
100
+ label: {
101
+ type: StringConstructor;
102
+ default: string;
103
+ };
104
+ placeholder: {
105
+ type: StringConstructor;
106
+ default: string;
107
+ };
108
+ description: {
109
+ type: StringConstructor;
110
+ default: string;
111
+ };
112
+ optionLabel: {
113
+ type: StringConstructor;
114
+ default: string;
115
+ };
116
+ optionValue: {
117
+ type: StringConstructor;
118
+ default: string;
119
+ };
120
+ moreOptions: {
121
+ type: ArrayConstructor;
122
+ default: null;
123
+ };
124
+ optionDisabled: {
125
+ type: (StringConstructor | FunctionConstructor)[];
126
+ default: string;
127
+ };
128
+ service: {
129
+ type: FunctionConstructor;
130
+ required: true;
131
+ };
132
+ loadService: {
133
+ type: FunctionConstructor;
134
+ required: true;
135
+ };
136
+ enableWorkaroundLabelToDisabledOptions: {
137
+ type: BooleanConstructor;
138
+ default: boolean;
139
+ };
140
+ enableClearOption: {
141
+ type: BooleanConstructor;
142
+ default: boolean;
143
+ };
144
+ disableEmitFirstRender: {
145
+ type: BooleanConstructor;
146
+ default: boolean;
147
+ };
148
+ optionGroupLabel: {
149
+ type: StringConstructor;
150
+ default: string;
151
+ };
152
+ optionGroupChildren: {
153
+ type: StringConstructor;
154
+ default: string;
155
+ };
156
+ defaultPosition: {
157
+ type: NumberConstructor;
158
+ default: number;
159
+ };
160
+ showIcon: {
161
+ type: BooleanConstructor;
162
+ default: boolean;
163
+ };
164
+ iconColor: {
165
+ type: ObjectConstructor;
166
+ default: () => {};
167
+ };
168
+ }>> & Readonly<{
169
+ onOnBlur?: ((...args: any[]) => any) | undefined;
170
+ onOnChange?: ((...args: any[]) => any) | undefined;
171
+ onOnSelectOption?: ((...args: any[]) => any) | undefined;
172
+ onOnAccessDenied?: ((...args: any[]) => any) | undefined;
173
+ }>, {
174
+ value: string | number;
175
+ label: string;
176
+ placeholder: string;
177
+ description: string;
178
+ optionLabel: string;
179
+ optionDisabled: string | Function;
180
+ optionGroupLabel: string;
181
+ optionGroupChildren: string;
182
+ optionValue: string;
183
+ enableWorkaroundLabelToDisabledOptions: boolean;
184
+ moreOptions: unknown[];
185
+ enableClearOption: boolean;
186
+ disableEmitFirstRender: boolean;
187
+ defaultPosition: number;
188
+ showIcon: boolean;
189
+ iconColor: Record<string, any>;
190
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
191
+ type __VLS_Slots = {
192
+ footer?: ((props: {}) => any) | undefined;
193
+ } & {
194
+ description?: ((props: {}) => any) | undefined;
195
+ };
196
+ //# sourceMappingURL=field-dropdown-lazy-loader.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-dropdown-lazy-loader.vue.d.ts","sourceRoot":"","sources":["field-dropdown-lazy-loader.vue"],"names":[],"mappings":"wBAu+CqB,OAAO,YAAY;;AADxC,4BAA2B,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;qBAEtD,CAAC,EAAE,CAAC;;;AApFzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAiFG"}
@@ -0,0 +1,11 @@
1
+ {
2
+ "main": "./field-dropdown-lazy-loader.vue",
3
+ "module": "./field-dropdown-lazy-loader.vue",
4
+ "types": "./field-dropdown-lazy-loader.vue.d.ts",
5
+ "browser": {
6
+ "./sfc": "./field-dropdown-lazy-loader.vue"
7
+ },
8
+ "sideEffects": [
9
+ "*.vue"
10
+ ]
11
+ }
@@ -0,0 +1,426 @@
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
+ :pt="{
27
+ filterInput: {
28
+ class: 'w-full',
29
+ 'data-testid': customTestId.filterInput
30
+ },
31
+ trigger: {
32
+ 'data-testid': customTestId.trigger
33
+ },
34
+ loadingIcon: {
35
+ 'data-testid': customTestId.loadingIcon
36
+ }
37
+ }"
38
+ :data-testid="customTestId.dropdown"
39
+ :virtualScrollerOptions="VIRTUAL_SCROLLER_CONFIG"
40
+ >
41
+ <template
42
+ v-if="enableCustomLabel"
43
+ #value="slotProps"
44
+ >
45
+ <span :data-testid="customTestId.value">
46
+ {{ getLabelBySelectedValue(slotProps.value) }}
47
+ </span>
48
+ </template>
49
+
50
+ <template #header>
51
+ <div class="p-2 flex">
52
+ <div class="p-inputgroup">
53
+ <InputText
54
+ type="text"
55
+ v-model="search"
56
+ placeholder="Search"
57
+ class="w-full rounded-r-none"
58
+ :disabled="!hasServiceAccess"
59
+ ref="focusSearch"
60
+ :data-testid="customTestId.search"
61
+ />
62
+ <span
63
+ class="p-inputgroup-addon"
64
+ @click="searchFilter"
65
+ >
66
+ <i class="pi pi-search"></i>
67
+ </span>
68
+ </div>
69
+ </div>
70
+ </template>
71
+
72
+ <template #footer>
73
+ <slot name="footer" />
74
+ </template>
75
+ </Dropdown>
76
+
77
+ <small
78
+ v-if="errorMessage"
79
+ :data-testid="customTestId.error"
80
+ class="p-error text-xs font-normal leading-tight"
81
+ >
82
+ {{ errorMessage }}
83
+ </small>
84
+ <small
85
+ class="text-xs text-color-secondary font-normal leading-5"
86
+ :data-testid="customTestId.description"
87
+ v-if="props.description || hasDescriptionSlot"
88
+ >
89
+ <slot name="description">
90
+ {{ props.description }}
91
+ </slot>
92
+ </small>
93
+ </template>
94
+
95
+ <script setup>
96
+ import Dropdown from 'primevue/dropdown'
97
+ import InputText from 'primevue/inputtext'
98
+ import { useField } from 'vee-validate'
99
+ import { computed, toRef, useSlots, useAttrs, ref, onMounted, watchEffect, watch } from 'vue'
100
+ import { watchDebounced } from '@vueuse/core'
101
+ import LabelBlock from '../label'
102
+
103
+ const props = defineProps({
104
+ value: {
105
+ type: [String, Number],
106
+ default: ''
107
+ },
108
+ name: {
109
+ type: String,
110
+ required: true
111
+ },
112
+ label: {
113
+ type: String,
114
+ default: ''
115
+ },
116
+ placeholder: {
117
+ type: String,
118
+ default: ''
119
+ },
120
+ description: {
121
+ type: String,
122
+ default: ''
123
+ },
124
+ optionLabel: {
125
+ type: String,
126
+ default: ''
127
+ },
128
+ optionValue: {
129
+ type: String,
130
+ default: ''
131
+ },
132
+ moreOptions: {
133
+ type: Array,
134
+ default: null
135
+ },
136
+ optionDisabled: {
137
+ type: [String, Function],
138
+ default: ''
139
+ },
140
+ service: {
141
+ type: Function,
142
+ required: true
143
+ },
144
+ loadService: {
145
+ type: Function,
146
+ required: true
147
+ },
148
+ enableWorkaroundLabelToDisabledOptions: {
149
+ type: Boolean,
150
+ default: false
151
+ },
152
+ enableClearOption: {
153
+ type: Boolean,
154
+ default: false
155
+ },
156
+ disableEmitFirstRender: {
157
+ type: Boolean,
158
+ default: false
159
+ },
160
+ initalData: {
161
+ type: Array,
162
+ default: () => [],
163
+ require: true
164
+ }
165
+ })
166
+
167
+ const emit = defineEmits(['onBlur', 'onChange', 'onSelectOption'])
168
+
169
+ const PAGE_INCREMENT = 1
170
+ const PAGE_SIZE = 100
171
+ const INITIAL_PAGE = 1
172
+ const SEARCH_DEBOUNCE = 500
173
+ const SEARCH_MAX_WAIT = 1000
174
+ const NUMBER_OF_CHARACTERS_MIN_FOR_SEARCH = 3
175
+ const NUMBER_OF_CHARACTERS_TO_RESET_SEARCH = 0
176
+ const hasServiceAccess = ref(true)
177
+
178
+ const name = toRef(props, 'name')
179
+ const slots = useSlots()
180
+ const data = ref([])
181
+ const loading = ref(false)
182
+ const totalCount = ref(0)
183
+ const page = ref(INITIAL_PAGE)
184
+ const search = ref('')
185
+ const focusSearch = ref(null)
186
+ const disableEmitInit = ref(props.disableEmitFirstRender)
187
+
188
+ onMounted(() => {
189
+ loadSelectedValue(props.value)
190
+ })
191
+
192
+ const hasDescriptionSlot = !!slots.description
193
+ const { value: inputValue, errorMessage } = useField(name, undefined, {
194
+ initialValue: props.value
195
+ })
196
+
197
+ const handleLazyLoad = async (event) => {
198
+ const { last } = event
199
+ const numberOfPage = Math.ceil(totalCount.value / PAGE_SIZE)
200
+ const goRequest = last >= data.value?.length
201
+
202
+ if (page.value < numberOfPage && goRequest && !loading.value) {
203
+ page.value += PAGE_INCREMENT
204
+ await fetchData(page.value)
205
+ }
206
+ }
207
+
208
+ const emitBlur = () => {
209
+ emit('onBlur')
210
+ }
211
+
212
+ const emitChange = () => {
213
+ const selectedOption = data.value.find(
214
+ (option) => option[props.optionValue] === inputValue.value
215
+ )
216
+
217
+ emit('onChange', inputValue.value)
218
+
219
+ if (selectedOption) {
220
+ emit('onSelectOption', selectedOption)
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Workaround to resolve the issue described in https://github.com/primefaces/primevue/issues/4431
226
+ * This should be remove from this field component as soon as the
227
+ * primevue team fixes the issue.
228
+ * When we select a disabled value, the label is not showing
229
+ * @param {*} selectedValue The selected value in the Dropdown component.
230
+ * @returns {string | null} The selected value if it corresponds to a disabled option, or null otherwise.
231
+ */
232
+ const getLabelBySelectedValue = (selectedValue) => {
233
+ const result = props.options.find((option) => option.value === selectedValue)
234
+ return result?.label
235
+ }
236
+
237
+ const fetchData = async (currentPage = 1) => {
238
+ try {
239
+ loading.value = true
240
+
241
+ if (currentPage === INITIAL_PAGE) {
242
+ data.value = []
243
+ }
244
+
245
+ const response = await props.service({
246
+ pageSize: PAGE_SIZE,
247
+ page: currentPage,
248
+ search: search.value,
249
+ ordering: 'name'
250
+ })
251
+
252
+ totalCount.value = response.count
253
+ let results = response.body?.map((item) => {
254
+ return {
255
+ [props.optionLabel]: item.name,
256
+ [props.optionValue]: item.id,
257
+ ...props?.moreOptions?.reduce(
258
+ (additionalFields, option) => ({
259
+ ...additionalFields,
260
+ [option]: item[option]
261
+ }),
262
+ {}
263
+ )
264
+ }
265
+ })
266
+
267
+ if (currentPage === INITIAL_PAGE) {
268
+ data.value = results
269
+ } else {
270
+ const uniqueResults = results.filter(
271
+ (newItem) =>
272
+ !data.value.some(
273
+ (existingItem) => existingItem[props.optionValue] === newItem[props.optionValue]
274
+ )
275
+ )
276
+
277
+ data.value = [...data.value, ...uniqueResults]
278
+ }
279
+ } finally {
280
+ loading.value = false
281
+ }
282
+ }
283
+
284
+ const loadSelectedValue = async (id) => {
285
+ if (!id) return
286
+ try {
287
+ loading.value = true
288
+ const results = await props.loadService({ id })
289
+ if (!results) return
290
+
291
+ const newOption = {
292
+ [props.optionLabel]: results.name,
293
+ [props.optionValue]: results.id,
294
+ ...props?.moreOptions?.reduce(
295
+ (additionalFields, option) => ({
296
+ ...additionalFields,
297
+ [option]: results[option]
298
+ }),
299
+ {}
300
+ )
301
+ }
302
+
303
+ const optionExists = data.value.some(
304
+ (item) => item[props.optionValue] === newOption[props.optionValue]
305
+ )
306
+
307
+ if (!optionExists) {
308
+ data.value = [newOption, ...data.value]
309
+ }
310
+
311
+ if (disableEmitInit.value) {
312
+ disableEmitInit.value = false
313
+ return
314
+ }
315
+ emitChange()
316
+ } catch {
317
+ const newOption = {
318
+ [props.optionLabel]: id,
319
+ [props.optionValue]: id
320
+ }
321
+ data.value = [newOption, ...data.value]
322
+ hasServiceAccess.value = false
323
+ } finally {
324
+ loading.value = false
325
+ }
326
+ }
327
+
328
+ const searchFilter = () => {
329
+ page.value = INITIAL_PAGE
330
+ fetchData()
331
+ }
332
+
333
+ const enableCustomLabel = computed(() => {
334
+ return props.enableWorkaroundLabelToDisabledOptions && !!inputValue.value
335
+ })
336
+ /**
337
+ * end of primevue workaround
338
+ */
339
+
340
+ const attrs = useAttrs()
341
+
342
+ const customTestId = computed(() => {
343
+ const id = attrs['data-testid'] || 'field-dropdown'
344
+
345
+ return {
346
+ label: `${id}__label`,
347
+ dropdown: `${id}__dropdown`,
348
+ value: `${id}__value`,
349
+ description: `${id}__description`,
350
+ error: `${id}__error-message`,
351
+ filterInput: `${id}__dropdown-filter-input`,
352
+ trigger: `${id}__dropdown-trigger`,
353
+ loadingIcon: `${id}__loading-icon`,
354
+ search: `${id}__dropdown-search`
355
+ }
356
+ })
357
+
358
+ watch(
359
+ () => props.value,
360
+ (newValue) => {
361
+ const existitemInList = data.value?.some((item) => item[props.optionValue] === newValue)
362
+ if (!existitemInList) {
363
+ loadSelectedValue(newValue)
364
+ }
365
+ }
366
+ )
367
+
368
+ watch(
369
+ () => props.initalData,
370
+ (newValue) => {
371
+ if (!newValue?.body) {
372
+ if (!props.value) {
373
+ data.value = []
374
+ totalCount.value = 0
375
+ }
376
+ return
377
+ }
378
+
379
+ let results = newValue.body.map((item) => {
380
+ return {
381
+ [props.optionLabel]: item.name,
382
+ [props.optionValue]: item.id,
383
+ ...props?.moreOptions?.reduce(
384
+ (additionalFields, option) => ({
385
+ ...additionalFields,
386
+ [option]: item[option]
387
+ }),
388
+ {}
389
+ )
390
+ }
391
+ })
392
+
393
+ const selectedItem = data.value?.find((item) => item[props.optionValue] === props.value)
394
+ data.value = selectedItem ? [selectedItem, ...results] : results || []
395
+ totalCount.value = (newValue && newValue.count) || 0
396
+ },
397
+ { immediate: true }
398
+ )
399
+
400
+ watchDebounced(
401
+ search,
402
+ () => {
403
+ if (
404
+ search.value.length >= NUMBER_OF_CHARACTERS_MIN_FOR_SEARCH ||
405
+ search.value.length === NUMBER_OF_CHARACTERS_TO_RESET_SEARCH
406
+ ) {
407
+ searchFilter()
408
+ }
409
+ },
410
+ { debounce: SEARCH_DEBOUNCE, maxWait: SEARCH_MAX_WAIT }
411
+ )
412
+
413
+ watchEffect(() => {
414
+ if (focusSearch.value) {
415
+ focusSearch.value.$el.focus()
416
+ }
417
+ })
418
+
419
+ const VIRTUAL_SCROLLER_CONFIG = {
420
+ lazy: true,
421
+ onLazyLoad: handleLazyLoad,
422
+ itemSize: 38,
423
+ showLoader: true,
424
+ loading
425
+ }
426
+ </script>