@signal24/vue-foundation 4.25.6 → 4.25.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -111,8 +111,7 @@ const searchField = ref<HTMLInputElement>();
|
|
|
111
111
|
const optionsContainer = ref<HTMLDivElement>();
|
|
112
112
|
|
|
113
113
|
const isLoading = ref(false);
|
|
114
|
-
const
|
|
115
|
-
const loadedOptions = ref<T[]>();
|
|
114
|
+
const remoteOptions = ref<T[]>();
|
|
116
115
|
const isSearching = ref(false);
|
|
117
116
|
const searchText = ref('');
|
|
118
117
|
const selectedOption = ref<T | null>(null);
|
|
@@ -122,9 +121,12 @@ const highlightedOptionKey = ref<string | symbol | null>(null);
|
|
|
122
121
|
const shouldShowCreateOption = ref(false);
|
|
123
122
|
const shouldShowCreateTextOnNewItem = computed(() => props.showCreateTextOnNewItem ?? true);
|
|
124
123
|
|
|
124
|
+
const isLoaded = computed(() => !!(props.options || remoteOptions.value));
|
|
125
|
+
const loadedOptions = computed(() => props.options ?? remoteOptions.value ?? []);
|
|
126
|
+
|
|
125
127
|
const effectivePrependOptions = computed(() => props.prependOptions ?? []);
|
|
126
128
|
const effectiveAppendOptions = computed(() => props.appendOptions ?? []);
|
|
127
|
-
const effectiveDisabled = computed(() => !!props.disabled || (!
|
|
129
|
+
const effectiveDisabled = computed(() => !!props.disabled || (!isLoaded.value && !props.loadOptions));
|
|
128
130
|
const effectivePlaceholder = computed(() => {
|
|
129
131
|
if (!isLoaded.value && props.preload) return 'Loading...';
|
|
130
132
|
if (props.nullTitle) return props.nullTitle;
|
|
@@ -158,7 +160,7 @@ const effectiveSelectionFormatter = computed(() => {
|
|
|
158
160
|
return effectiveFormatter.value;
|
|
159
161
|
});
|
|
160
162
|
|
|
161
|
-
const allOptions = computed(() => [...effectivePrependOptions.value, ...
|
|
163
|
+
const allOptions = computed(() => [...effectivePrependOptions.value, ...loadedOptions.value, ...effectiveAppendOptions.value]);
|
|
162
164
|
const isGrouped = computed(() => !!(props.groupField || props.groupFormatter));
|
|
163
165
|
|
|
164
166
|
const optionsDescriptors = computed(() => {
|
|
@@ -254,13 +256,6 @@ const groupedOptions = computed(() => {
|
|
|
254
256
|
|
|
255
257
|
// watch props
|
|
256
258
|
watch(() => props.modelValue, handleValueChanged);
|
|
257
|
-
watch(
|
|
258
|
-
() => props.options,
|
|
259
|
-
() => {
|
|
260
|
-
loadedOptions.value = props.options;
|
|
261
|
-
isLoaded.value = true;
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
259
|
|
|
265
260
|
// watch data
|
|
266
261
|
|
|
@@ -306,14 +301,11 @@ watch(effectiveOptions, () => {
|
|
|
306
301
|
onMounted(async () => {
|
|
307
302
|
shouldShowCreateOption.value = props.onCreateItem !== undefined;
|
|
308
303
|
|
|
309
|
-
if (props.
|
|
310
|
-
loadedOptions.value = [...props.options];
|
|
311
|
-
isLoaded.value = true;
|
|
312
|
-
} else if (props.loadOptions && props.preload) {
|
|
304
|
+
if (props.loadOptions && props.preload) {
|
|
313
305
|
await loadRemoteOptions();
|
|
314
306
|
}
|
|
315
307
|
|
|
316
|
-
if (!props.options && (props.valueField || props.valueExtractor)) {
|
|
308
|
+
if (!props.options && (props.valueField || props.valueExtractor) && (!props.loadOptions || props.preload)) {
|
|
317
309
|
searchText.value = props.loadingText ?? '...';
|
|
318
310
|
} else {
|
|
319
311
|
handleValueChanged();
|
|
@@ -341,15 +333,15 @@ onBeforeUnmount(() => {
|
|
|
341
333
|
|
|
342
334
|
async function loadRemoteOptions() {
|
|
343
335
|
await reloadOptions();
|
|
344
|
-
if (
|
|
336
|
+
if (remoteOptions.value) emit('optionsLoaded', remoteOptions.value);
|
|
345
337
|
}
|
|
346
338
|
|
|
347
339
|
async function reloadOptions() {
|
|
348
340
|
const effectiveSearchText = props.remoteSearch && isSearching.value && searchText.value.length ? searchText.value : null;
|
|
349
341
|
isLoading.value = true;
|
|
350
|
-
|
|
342
|
+
remoteOptions.value = (await props.loadOptions?.(effectiveSearchText)) ?? [];
|
|
351
343
|
isLoading.value = false;
|
|
352
|
-
|
|
344
|
+
setHighlightedOptionKey();
|
|
353
345
|
}
|
|
354
346
|
|
|
355
347
|
function reloadOptionsIfSearching() {
|
|
@@ -575,7 +567,7 @@ function handleValueChanged() {
|
|
|
575
567
|
}
|
|
576
568
|
|
|
577
569
|
function addRemoteOption(option: T) {
|
|
578
|
-
|
|
570
|
+
remoteOptions.value!.unshift(option);
|
|
579
571
|
}
|
|
580
572
|
|
|
581
573
|
function focusNextInput() {
|
package/src/helpers/string.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function desnakeCase(value: string) {
|
|
|
17
17
|
|
|
18
18
|
export function formatPhone(value: string) {
|
|
19
19
|
const cleanValue = value.replace(/\D/g, '').replace(/^1/, '');
|
|
20
|
-
if (cleanValue.length
|
|
20
|
+
if (cleanValue.length !== 10) return value;
|
|
21
21
|
return '(' + cleanValue.substring(0, 3) + ') ' + cleanValue.substring(3, 6) + '-' + cleanValue.substring(6);
|
|
22
22
|
}
|
|
23
23
|
|