design-system-next 2.7.20 → 2.7.22
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 +4340 -4287
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/package.json +1 -1
- package/src/components/calendar-cell/calendar-cell.ts +4 -0
- package/src/components/calendar-cell/calendar-cell.vue +3 -2
- package/src/components/calendar-cell/use-calendar-cell.ts +2 -2
- package/src/components/table/table.ts +6 -0
- package/src/components/table/table.vue +20 -7
- package/src/components/table/use-table.ts +40 -30
- package/src/components/textarea/textarea.ts +4 -0
- package/src/components/textarea/textarea.vue +1 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -10,7 +10,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
10
10
|
toRefs(props);
|
|
11
11
|
const sortField = ref('');
|
|
12
12
|
const searchField = ref(props.searchModel);
|
|
13
|
-
const tableSortOrder = ref<TABLE_SORT>(sortOrder.value
|
|
13
|
+
const tableSortOrder = ref<TABLE_SORT>(sortOrder.value);
|
|
14
14
|
const selectAll = ref(false);
|
|
15
15
|
const selectedData = ref<TableData[]>([]);
|
|
16
16
|
|
|
@@ -25,8 +25,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
const sortedData = computed(() => {
|
|
28
|
-
if (!sortField.value || sortOrder
|
|
29
|
-
|
|
28
|
+
if (!sortField.value || sortOrder?.value) return dataTable.value;
|
|
30
29
|
const sorted = [...dataTable.value].sort((a, b) => {
|
|
31
30
|
const fieldA = extractLowerCasedTitle(a[sortField.value]);
|
|
32
31
|
const fieldB = extractLowerCasedTitle(b[sortField.value]);
|
|
@@ -49,6 +48,14 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
49
48
|
emit('onSort', { field: field, sortOrder: tableSortOrder.value });
|
|
50
49
|
};
|
|
51
50
|
|
|
51
|
+
const getSortIcon = (field: string) => {
|
|
52
|
+
if (sortField.value !== field) {
|
|
53
|
+
return 'ph:caret-up-down-light';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return tableSortOrder.value === 'asc' ? 'ph:arrow-up' : 'ph:arrow-down';
|
|
57
|
+
};
|
|
58
|
+
|
|
52
59
|
const getHeaderCount = computed(() => (action.value ? headers.value.length + 1 : headers.value.length));
|
|
53
60
|
|
|
54
61
|
const updateSearchField = (value: string) => {
|
|
@@ -108,7 +115,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
108
115
|
const tableHeaderActionsClasses = 'spr-border-color-weak spr-w-full spr-border spr-border-solid';
|
|
109
116
|
const tableCellSlotClasses =
|
|
110
117
|
'spr-background-color-surface spr-text-color-strong spr-font-size-100 spr-font-line-height-100 spr-font-letter-spacing-normal spr-uppercase';
|
|
111
|
-
const tableRowClasses = classNames('
|
|
118
|
+
const tableRowClasses = classNames('spr-min-h-[60px]', {
|
|
112
119
|
'spr-cursor-pointer': props.isRowClickable,
|
|
113
120
|
});
|
|
114
121
|
const tableDataClasses =
|
|
@@ -138,6 +145,9 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
138
145
|
|
|
139
146
|
const multiselectClass = classNames('spr-px-size-spacing-2xs spr-py-size-spacing-3xs spr-w-[44px] ');
|
|
140
147
|
|
|
148
|
+
const emptyStateClasses = classNames(`${emptyStateBaseClasses} ${props.emptyStateCustomClasses}`);
|
|
149
|
+
const tableActionSlotClasses = classNames(`${defaultSlotClasses} ${props.tableActionSlotCustomClasses}`);
|
|
150
|
+
|
|
141
151
|
return {
|
|
142
152
|
headerClasses,
|
|
143
153
|
tableWrapperClasses,
|
|
@@ -154,20 +164,19 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
154
164
|
tableBackgroundClasses,
|
|
155
165
|
tableBodyClasses,
|
|
156
166
|
tableFooterClasses,
|
|
157
|
-
|
|
167
|
+
emptyStateClasses,
|
|
168
|
+
tableActionSlotClasses,
|
|
158
169
|
};
|
|
159
170
|
});
|
|
160
171
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
//assert type TableDataProps
|
|
172
|
+
//assert type TableDataProps
|
|
164
173
|
const sortedDataItem = (rowIndex: number, headerField: string) => {
|
|
165
174
|
return sortedData.value[rowIndex][headerField] as TableDataProps;
|
|
166
|
-
}
|
|
175
|
+
};
|
|
167
176
|
|
|
168
177
|
const isTableDataObject = (data: TableDataProps) => {
|
|
169
|
-
return typeof data === 'object' && 'title' in data
|
|
170
|
-
}
|
|
178
|
+
return typeof data === 'object' && 'title' in data;
|
|
179
|
+
};
|
|
171
180
|
|
|
172
181
|
const handleSelect = (item: TableData) => {
|
|
173
182
|
if (!selectedKeyId.value || !(selectedKeyId.value in item)) return;
|
|
@@ -189,7 +198,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
189
198
|
selectedData.value.push(item);
|
|
190
199
|
}
|
|
191
200
|
|
|
192
|
-
emitSelectedData()
|
|
201
|
+
emitSelectedData();
|
|
193
202
|
};
|
|
194
203
|
|
|
195
204
|
const handleSelectAll = () => {
|
|
@@ -199,7 +208,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
199
208
|
selectedData.value = [...sortedData.value];
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
emitSelectedData()
|
|
211
|
+
emitSelectedData();
|
|
203
212
|
};
|
|
204
213
|
|
|
205
214
|
const isRowSelected = (item: TableData) => {
|
|
@@ -217,23 +226,23 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
217
226
|
};
|
|
218
227
|
|
|
219
228
|
const emitSelectedData = () => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
229
|
+
if (returnCompleteSelectedProperties.value) {
|
|
230
|
+
emit('update:selectedData', selectedData.value);
|
|
231
|
+
} else {
|
|
232
|
+
const mappedData = selectedData.value.map((item) => {
|
|
233
|
+
const typedItem = item[selectedKeyId.value] as TableDataProps | string | number;
|
|
234
|
+
if (typeof typedItem === 'object') {
|
|
235
|
+
return { ...typedItem };
|
|
236
|
+
} else {
|
|
237
|
+
return typedItem;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
emit('update:selectedData', mappedData);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
234
243
|
|
|
235
244
|
watch(sortedData, (newVal) => {
|
|
236
|
-
if(newVal && props.isMultiSelect && selectedData.value.length > 0) {
|
|
245
|
+
if (newVal && props.isMultiSelect && selectedData.value.length > 0) {
|
|
237
246
|
// Remove items from selectedData that are not in the new sortedData
|
|
238
247
|
// This is to ensure that the selectedData is always in sync with the sortedData
|
|
239
248
|
|
|
@@ -252,7 +261,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
252
261
|
if (selectedIndex === -1) {
|
|
253
262
|
selectedData.value.splice(selectedIndex, 1);
|
|
254
263
|
}
|
|
255
|
-
})
|
|
264
|
+
});
|
|
256
265
|
}
|
|
257
266
|
});
|
|
258
267
|
|
|
@@ -274,6 +283,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
|
|
|
274
283
|
isRowSelected,
|
|
275
284
|
isIndeterminate,
|
|
276
285
|
sortedDataItem,
|
|
277
|
-
|
|
286
|
+
getSortIcon,
|
|
287
|
+
sortField,
|
|
278
288
|
};
|
|
279
289
|
};
|