design-system-next 2.8.0 → 2.8.3
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/dist/design-system-next.js +4900 -4996
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/dist/package.json.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/list/ladderized-list/use-ladderized-list.ts +11 -1
- package/src/components/select/select-ladderized/select-ladderized.ts +3 -3
- package/src/components/select/select-ladderized/select-ladderized.vue +7 -7
- package/src/components/select/select-ladderized/use-select-ladderized.ts +13 -14
- package/src/components/select/select-multiple/select-multiple.ts +1 -15
- package/src/components/select/select-multiple/select-multiple.vue +17 -72
- package/src/components/select/select-multiple/use-select-multiple.ts +112 -215
- package/src/components/select/select.ts +2 -2
- package/src/components/select/select.vue +12 -12
- package/src/components/select/use-select.ts +26 -25
- package/src/components/snackbar/snack/snack.vue +6 -1
|
@@ -13,7 +13,7 @@ interface SelectClasses {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitTypes>['emit']) => {
|
|
16
|
-
const { displayText,
|
|
16
|
+
const { displayText, options, disabled, textField, valueField, disabledLocalSearch } = toRefs(props);
|
|
17
17
|
|
|
18
18
|
const selectClasses: ComputedRef<SelectClasses> = computed(() => {
|
|
19
19
|
const baseClasses = classNames('spr-flex spr-flex-col spr-gap-size-spacing-4xs');
|
|
@@ -36,7 +36,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
36
36
|
// Select Variables
|
|
37
37
|
const selectModel = useVModel(props, 'modelValue', emit);
|
|
38
38
|
const selectedListItems = ref<MenuListType[]>();
|
|
39
|
-
const
|
|
39
|
+
const selectOptions = ref<MenuListType[]>([]);
|
|
40
40
|
const hasUserSelected = ref(false);
|
|
41
41
|
|
|
42
42
|
// Input Text Variables
|
|
@@ -44,7 +44,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
44
44
|
const inputTextBackup = ref<string | number>('');
|
|
45
45
|
const isSearching = ref<boolean>(false);
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const handleOptionsToggle = () => {
|
|
48
48
|
selectPopperState.value = true;
|
|
49
49
|
|
|
50
50
|
isSearching.value = false;
|
|
@@ -77,19 +77,19 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
77
77
|
return [selectModel.value];
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
const
|
|
80
|
+
const processOptions = () => {
|
|
81
81
|
// Handle empty array or non-array values
|
|
82
|
-
if (!
|
|
83
|
-
|
|
82
|
+
if (!options.value || !Array.isArray(options.value) || options.value.length === 0) {
|
|
83
|
+
selectOptions.value = [];
|
|
84
84
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const firstItem =
|
|
88
|
+
const firstItem = options.value[0];
|
|
89
89
|
|
|
90
90
|
// Handle array of strings
|
|
91
91
|
if (typeof firstItem === 'string') {
|
|
92
|
-
|
|
92
|
+
selectOptions.value = (options.value as string[]).map((item) => ({
|
|
93
93
|
text: item,
|
|
94
94
|
value: item,
|
|
95
95
|
}));
|
|
@@ -99,7 +99,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
99
99
|
|
|
100
100
|
// Handle array of numbers
|
|
101
101
|
if (typeof firstItem === 'number') {
|
|
102
|
-
|
|
102
|
+
selectOptions.value = (options.value as number[]).map((item) => ({
|
|
103
103
|
text: item.toString(),
|
|
104
104
|
value: item, // Keep the value as a number instead of converting to string
|
|
105
105
|
}));
|
|
@@ -111,13 +111,13 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
111
111
|
if (typeof firstItem === 'object' && firstItem !== null) {
|
|
112
112
|
// Check if it's already in MenuListType format
|
|
113
113
|
if ('text' in firstItem && 'value' in firstItem) {
|
|
114
|
-
|
|
114
|
+
selectOptions.value = options.value as MenuListType[];
|
|
115
115
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// Transform to MenuListType format using textField and valueField
|
|
120
|
-
|
|
120
|
+
selectOptions.value = (options.value as Record<string, unknown>[]).map((item) => {
|
|
121
121
|
const displayText = item[textField.value] || 'Unnamed';
|
|
122
122
|
// Use the specified value field if available, otherwise use the entire object
|
|
123
123
|
const itemValue = valueField.value && item[valueField.value] !== undefined ? item[valueField.value] : item;
|
|
@@ -132,23 +132,23 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
selectOptions.value = options.value as MenuListType[];
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
const
|
|
138
|
+
const filteredSelectOptions = computed(() => {
|
|
139
139
|
if (disabledLocalSearch.value) {
|
|
140
|
-
return
|
|
140
|
+
return selectOptions.value;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
const query = inputText.value.toString().toLowerCase().trim();
|
|
144
144
|
|
|
145
|
-
if (!query) return
|
|
145
|
+
if (!query) return selectOptions.value;
|
|
146
146
|
|
|
147
|
-
return
|
|
147
|
+
return selectOptions.value.filter((item) => item.text?.toString().toLowerCase().includes(query));
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
watch(
|
|
151
|
-
|
|
150
|
+
watch(options, () => {
|
|
151
|
+
processOptions();
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
// Search handler: always emit search-string, but only filter locally if local search is enabled
|
|
@@ -221,7 +221,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
221
221
|
|
|
222
222
|
// Update selected items when model value changes externally
|
|
223
223
|
const updateSelectedItemsFromValue = () => {
|
|
224
|
-
if (!
|
|
224
|
+
if (!selectOptions.value.length) return;
|
|
225
225
|
|
|
226
226
|
const values = normalizedValue.value;
|
|
227
227
|
|
|
@@ -272,7 +272,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
272
272
|
// Extract just string values for comparison
|
|
273
273
|
const valueStrings = valueData.map((v) => v.string);
|
|
274
274
|
|
|
275
|
-
selectedListItems.value =
|
|
275
|
+
selectedListItems.value = selectOptions.value.filter((item) => {
|
|
276
276
|
// Handle objects with _originalObject property
|
|
277
277
|
if ('_originalObject' in item && item._originalObject) {
|
|
278
278
|
return valueData.some((v) => {
|
|
@@ -290,6 +290,7 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
290
290
|
return v.id === originalObj.id;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
+
|
|
293
294
|
return false;
|
|
294
295
|
});
|
|
295
296
|
}
|
|
@@ -327,12 +328,12 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
327
328
|
updateSelectedItemsFromValue();
|
|
328
329
|
});
|
|
329
330
|
|
|
330
|
-
watch(
|
|
331
|
+
watch(selectOptions, () => {
|
|
331
332
|
updateSelectedItemsFromValue();
|
|
332
333
|
});
|
|
333
334
|
|
|
334
335
|
onMounted(() => {
|
|
335
|
-
|
|
336
|
+
processOptions();
|
|
336
337
|
|
|
337
338
|
// Set initial selected items based on model value
|
|
338
339
|
if (normalizedValue.value.length > 0) {
|
|
@@ -346,11 +347,11 @@ export const useSelect = (props: SelectPropTypes, emit: SetupContext<SelectEmitT
|
|
|
346
347
|
return {
|
|
347
348
|
selectClasses,
|
|
348
349
|
selectPopperState,
|
|
349
|
-
|
|
350
|
+
handleOptionsToggle,
|
|
350
351
|
selectRef,
|
|
351
352
|
selectModel: compatPreSelectedItems, // Use compatible format for lists
|
|
352
|
-
|
|
353
|
-
|
|
353
|
+
selectOptions,
|
|
354
|
+
filteredSelectOptions,
|
|
354
355
|
selectedListItems,
|
|
355
356
|
inputText,
|
|
356
357
|
isSelectPopperDisabled,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
@click="handleClick"
|
|
7
7
|
>
|
|
8
8
|
<div class="spr-flex spr-flex-auto spr-items-center">
|
|
9
|
+
<slot name="icon">
|
|
9
10
|
<Icon
|
|
10
11
|
v-if="showIcon"
|
|
11
12
|
:icon="snackIcon"
|
|
@@ -13,7 +14,11 @@
|
|
|
13
14
|
:height="iconSize"
|
|
14
15
|
:class="[snackToneCssClass, 'spr-mr-size-spacing-3xs spr-flex-shrink-0']"
|
|
15
16
|
/>
|
|
16
|
-
|
|
17
|
+
</slot>
|
|
18
|
+
|
|
19
|
+
<slot name="label">
|
|
20
|
+
<label>{{ text }}</label>
|
|
21
|
+
</slot>
|
|
17
22
|
</div>
|
|
18
23
|
<template v-if="showAction">
|
|
19
24
|
<slot>
|