design-system-next 2.15.0 → 2.15.2

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.
Binary file
@@ -1,7 +1,7 @@
1
1
  declare const _default: {
2
2
  "name": "design-system-next",
3
3
  "private": false,
4
- "version": "2.15.0",
4
+ "version": "2.15.2",
5
5
  "main": "./dist/design-system-next.umd.js",
6
6
  "module": "./dist/design-system-next.es.js",
7
7
  "repository": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "design-system-next",
3
3
  "private": false,
4
- "version": "2.15.0",
4
+ "version": "2.15.2",
5
5
  "main": "./dist/design-system-next.umd.js",
6
6
  "module": "./dist/design-system-next.es.js",
7
7
  "repository": {
@@ -117,7 +117,7 @@ export const selectLadderizedPropTypes = {
117
117
  },
118
118
  autoHide: {
119
119
  type: Boolean,
120
- default: true,
120
+ default: false,
121
121
  },
122
122
  wrapperPosition: {
123
123
  type: String,
@@ -83,7 +83,7 @@ export const selectPropTypes = {
83
83
  validator: (value: (typeof TRIGGER_EVENTS)[number][]) => {
84
84
  return value.every((val) => TRIGGER_EVENTS.includes(val));
85
85
  },
86
- default: () => ['click'],
86
+ default: () => [],
87
87
  },
88
88
  popperTriggers: {
89
89
  type: Array as PropType<(typeof TRIGGER_EVENTS)[number][]>,
@@ -94,7 +94,7 @@ export const selectPropTypes = {
94
94
  },
95
95
  autoHide: {
96
96
  type: Boolean,
97
- default: true,
97
+ default: false,
98
98
  },
99
99
  popperStrategy: {
100
100
  type: String,
@@ -27,53 +27,56 @@
27
27
  }"
28
28
  >
29
29
  <div ref="selectRef">
30
- <spr-input
31
- :id="`input-${props.id}`"
32
- v-model="inputText"
33
- :class="{
34
- 'spr-cursor-pointer': !props.searchable,
35
- }"
36
- :placeholder="props.placeholder"
37
- autocomplete="off"
38
- :helper-text="props.helperText"
39
- :helper-icon="props.helperIcon"
40
- :display-helper="props.displayHelper"
41
- :active="props.active"
42
- :readonly="!props.searchable"
43
- :disabled="props.disabled"
44
- :error="props.error"
45
- @keyup="handleSearch"
46
- >
47
- <template #icon>
48
- <div class="spr-flex spr-cursor-pointer spr-items-center">
49
- <Icon
50
- v-if="props.clearable && inputText"
51
- class="spr-cursor-pointer"
52
- icon="ph:x"
53
- @click.stop="handleClear"
54
- />
55
- <Icon icon="ph:caret-down" />
56
- </div>
57
- </template>
58
-
59
- <template #helperMessage>
60
- <slot name="helperMessage" />
61
- </template>
62
- </spr-input>
63
-
64
- <!-- Hidden Select for QA automation -->
65
- <select
66
- v-if="selectOptions && selectOptions.length"
67
- :value="Array.isArray(selectModel) ? selectModel[0] : selectModel"
68
- data-testid="qa-hidden-select"
69
- tabindex="-1"
70
- aria-hidden="true"
71
- hidden
72
- >
73
- <option v-for="item in selectOptions" :key="item.value" :value="item.value">
74
- {{ item.text }}
75
- </option>
76
- </select>
30
+ <div @click="!props.searchable? selectPopperState = !selectPopperState: null">
31
+ <spr-input
32
+ :id="`input-${props.id}`"
33
+ v-model="inputText"
34
+ :class="{
35
+ 'spr-cursor-pointer': !props.searchable,
36
+ }"
37
+ :placeholder="props.placeholder"
38
+ autocomplete="off"
39
+ :helper-text="props.helperText"
40
+ :helper-icon="props.helperIcon"
41
+ :display-helper="props.displayHelper"
42
+ :active="props.active"
43
+ :readonly="!props.searchable"
44
+ :disabled="props.disabled"
45
+ :error="props.error"
46
+ @keyup="handleSearch"
47
+ @click="props.searchable ? selectPopperState = true : null"
48
+ >
49
+ <template #icon>
50
+ <div class="spr-flex spr-cursor-pointer spr-items-center">
51
+ <Icon
52
+ v-if="props.clearable && inputText"
53
+ class="spr-cursor-pointer"
54
+ icon="ph:x"
55
+ @click.stop="handleClear"
56
+ />
57
+ <Icon icon="ph:caret-down" />
58
+ </div>
59
+ </template>
60
+
61
+ <template #helperMessage>
62
+ <slot name="helperMessage" />
63
+ </template>
64
+ </spr-input>
65
+
66
+ <!-- Hidden Select for QA automation -->
67
+ <select
68
+ v-if="selectOptions && selectOptions.length"
69
+ :value="Array.isArray(selectModel) ? selectModel[0] : selectModel"
70
+ data-testid="qa-hidden-select"
71
+ tabindex="-1"
72
+ aria-hidden="true"
73
+ hidden
74
+ >
75
+ <option v-for="item in selectOptions" :key="item.value" :value="item.value">
76
+ {{ item.text }}
77
+ </option>
78
+ </select>
79
+ </div>
77
80
 
78
81
  <!-- This div used to poppulate popper menu -->
79
82
  <div
@@ -180,6 +180,10 @@ export const tablePropTypes = {
180
180
  type: Boolean,
181
181
  default: false,
182
182
  },
183
+ retainSelectionOnDataChange: {
184
+ type: Boolean,
185
+ default: false,
186
+ }
183
187
  };
184
188
 
185
189
  export const tableEmitTypes = {
@@ -204,7 +204,7 @@
204
204
  </template>
205
205
 
206
206
  <script lang="ts" setup>
207
- import { useSlots, useTemplateRef, watch } from 'vue';
207
+ import { useSlots, ref, watch } from 'vue';
208
208
  import { Icon } from '@iconify/vue';
209
209
  import SprAvatar from '@/components/avatar/avatar.vue';
210
210
  import SprEmptyState from '@/components/empty-state/empty-state.vue';
@@ -224,7 +224,7 @@ const props = defineProps(tablePropTypes);
224
224
  const emit = defineEmits(tableEmitTypes);
225
225
  const slots = useSlots();
226
226
 
227
- const sortableTBody = useTemplateRef<HTMLElement>('sortableTBody');
227
+ const sortableTBody = ref<HTMLElement | null>(null);
228
228
 
229
229
  const {
230
230
  getHeaderCount,
@@ -240,6 +240,7 @@ const {
240
240
  dragOptions,
241
241
  tableKey,
242
242
  isDragging,
243
+
243
244
 
244
245
  isRowSelected,
245
246
  sortData,
@@ -250,10 +251,15 @@ const {
250
251
  sortedDataItem,
251
252
  getSortIcon,
252
253
  getRowKey,
254
+ clearSelectedData
253
255
  } = useTable(props, emit, slots);
254
256
 
255
257
  const { reinitializeSortable } = useDraggableTableRows(sortableTBody, dragOptions);
256
258
 
259
+ defineExpose({
260
+ clearSelectedData
261
+ });
262
+
257
263
  watch(tableKey, () => {
258
264
  reinitializeSortable();
259
265
  });
@@ -6,7 +6,7 @@ import type {
6
6
  TABLE_SORT,
7
7
  TableData,
8
8
  TableDataProps,
9
- Header,
9
+ Header,
10
10
  SortableDragEvent,
11
11
  } from './table';
12
12
  import type { SetupContext } from 'vue';
@@ -263,7 +263,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
263
263
  'spr-border-color-weak spr-border-x-0 spr-border-b spr-border-t-0 spr-border-solid',
264
264
  );
265
265
 
266
- const multiselectClass = classNames('spr-px-size-spacing-2xs spr-py-size-spacing-3xs spr-w-[44px] ');
266
+ const multiselectClass = classNames('spr-px-size-spacing-2xs spr-py-size-spacing-3xs spr-w-[44px]');
267
267
 
268
268
  const emptyStateClasses = classNames(`${emptyStateBaseClasses} ${props.emptyStateCustomClasses}`);
269
269
  const tableActionSlotClasses = classNames(`${defaultSlotClasses} ${props.tableActionSlotCustomClasses}`);
@@ -369,7 +369,7 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
369
369
  watch(sortedData, (newVal) => {
370
370
  tableData.value = [...newVal];
371
371
 
372
- if (props.isMultiSelect && selectedData.value.length > 0) {
372
+ if (props.isMultiSelect && selectedData.value.length > 0 && !props.retainSelectionOnDataChange) {
373
373
  // Remove items from selectedData that are not in the new sortedData
374
374
  // This is to ensure that the selectedData is always in sync with the sortedData
375
375
 
@@ -392,12 +392,18 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
392
392
  }
393
393
  });
394
394
 
395
+ const clearSelectedData = () => {
396
+ selectedData.value = [];
397
+ }
398
+
395
399
  watch(tableData, () => {
396
400
  tableKey.value = tableKey.value + 1;
397
401
  });
398
402
 
399
403
  onMounted(() => {
400
- tableData.value = [...sortedData.value];
404
+ if (sortedData.value.length > 0) {
405
+ tableData.value = [...sortedData.value];
406
+ }
401
407
  });
402
408
 
403
409
  return {
@@ -420,12 +426,13 @@ export const useTable = (props: TablePropTypes, emit: SetupContext<TableEmitType
420
426
  sortedDataItem,
421
427
  getSortIcon,
422
428
  sortField,
423
- allowSelfDrag,
429
+ allowSelfDrag,
424
430
  tableData,
425
431
  isDraggable,
426
432
  dragOptions,
427
433
  getRowKey,
428
434
  isDragging: toRef(() => isDragging.value),
429
435
  tableKey,
436
+ clearSelectedData
430
437
  };
431
438
  };