design-system-next 2.23.1 → 2.24.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.
package/src/App.vue CHANGED
@@ -1,3 +1,91 @@
1
1
  <template>
2
- <div>Test Component Here</div>
2
+ <div class="spr-h-[600px] spr-w-[75%]">
3
+ <spr-table
4
+ action
5
+ :headers="headers"
6
+ :data-table="data"
7
+ is-multi-select
8
+ :selected-key-id="'name'"
9
+ show-header-filter
10
+ @on-apply-filter="(filters) => console.log(filters)"
11
+ />
12
+ </div>
3
13
  </template>
14
+
15
+ <script setup lang="ts">
16
+ import SprTable from './components/table/table.vue';
17
+ import { ref } from 'vue';
18
+ import { Header } from './components/table/table';
19
+
20
+ const headers = ref<Header[]>([
21
+ { field: 'name', name: 'Role Name', sort: false, hasAvatar: true, hasSubtext: true, width: '250px',
22
+ filterList: [
23
+ { text: 'Role 11', value: 'role11' },
24
+ { text: 'Role 12', value: 'role12' },
25
+ { text: 'Role 13', value: 'role13' },
26
+ { text: 'Role 14', value: 'role14' },
27
+ { text: 'Role 15', value: 'role15' }
28
+ ]
29
+ },
30
+ { field: 'firstUpdate', name: 'Date', sort: false, hasAvatar: false, hasSubtext: false, width: '150px',
31
+ filterList: [
32
+ { text: 'Jan 10, 2025', value: 'jan10' },
33
+ { text: 'Jan 11, 2025', value: 'jan11' },
34
+ { text: 'Jan 12, 2025', value: 'jan12' },
35
+ { text: 'Jan 13, 2025', value: 'jan13' },
36
+ { text: 'Jan 14, 2025', value: 'jan14' }
37
+ ]
38
+ },
39
+ { field: 'lastUpdate', name: 'Date', sort: false, hasAvatar: false, hasSubtext: false, width: '150px',
40
+ filterList: [
41
+ { text: 'Dec 10, 2025', value: 'dec10' },
42
+ { text: 'Dec 11, 2025', value: 'dec11' },
43
+ { text: 'Dec 12, 2025', value: 'dec12' },
44
+ { text: 'Dec 13, 2025', value: 'dec13' },
45
+ { text: 'Dec 14, 2025', value: 'dec14' }
46
+ ]
47
+ },
48
+ { field: 'note', name: 'Note', sort: false, hasAvatar: false, hasSubtext: true, width: '300px',
49
+ filterList: [
50
+ { text: 'Note 11', value: 'note11' },
51
+ { text: 'Note 12', value: 'note12' },
52
+ { text: 'Note 13', value: 'note13' },
53
+ { text: 'Note 14', value: 'note14' },
54
+ { text: 'Note 15', value: 'note15' }
55
+ ]
56
+ },
57
+ { field: 'status', name: 'Status', sort: false, hasAvatar: false, hasSubtext: true, width: '200px',
58
+ filterList: [
59
+ { text: 'Success', value: 'success' },
60
+ { text: 'Pending', value: 'pending' },
61
+ { text: 'Error', value: 'error' }
62
+ ]
63
+ },
64
+ ]);
65
+
66
+ const data = ref([
67
+ // 40 more elements
68
+ ...Array.from({ length: 50 }, (_, i) => ({
69
+ name: {
70
+ title: `Role ${i + 11}`,
71
+ subtext: `Subtext for role ${i + 11}`,
72
+ },
73
+ firstUpdate: {
74
+ title: `Jan ${10 + i}, 2025`,
75
+ subtext: `Subtext for date ${10 + i}`,
76
+ },
77
+ lastUpdate: {
78
+ title: `Dec ${10 + i}, 2025`,
79
+ subtext: `Subtext for date ${10 + i}`,
80
+ },
81
+ note: {
82
+ title: `Note ${i + 11}`,
83
+ subtext: `Subtext for role ${i + 11}`,
84
+ },
85
+ status: {
86
+ title: ['Success', 'Pending', 'Error'][(i + 1) % 3],
87
+ subtext: `Status subtext ${i + 11}`,
88
+ },
89
+ })),
90
+ ]);
91
+ </script>
@@ -141,13 +141,17 @@ export const dropdownPropTypes = {
141
141
  type: Boolean,
142
142
  default: false,
143
143
  },
144
+ noPadding: {
145
+ type: Boolean,
146
+ default: false,
147
+ }
144
148
  };
145
149
 
146
150
  export const dropdownEmitTypes = {
147
- 'infinite-scroll-trigger': Boolean,
151
+ 'infinite-scroll-trigger': (value: boolean) => typeof value === 'boolean',
148
152
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
149
153
  'update:modelValue': (_value: unknown) => true, // Accept any type of value
150
- 'popper-state': Boolean,
154
+ 'popper-state': (state: boolean) => typeof state === 'boolean',
151
155
  };
152
156
 
153
157
  export type DropdownPropTypes = ExtractPropTypes<typeof dropdownPropTypes>;
@@ -32,7 +32,7 @@
32
32
  <template #popper>
33
33
  <template v-if="$slots.popper">
34
34
  <div
35
- class="spr-overflow-y-auto spr-overflow-x-hidden spr-p-4"
35
+ :class="['spr-overflow-y-auto spr-overflow-x-hidden', !props.noPadding && 'spr-p-4']"
36
36
  :style="{
37
37
  width: props.popperInnerWidth,
38
38
  }"
@@ -111,5 +111,12 @@ const {
111
111
  dropdownValue,
112
112
  removeCurrentLevelInBackLabel,
113
113
  isLadderizedSearch,
114
+ showDropdown,
115
+ hideDropdown,
114
116
  } = useDropdown(props, emit);
117
+
118
+ defineExpose({
119
+ showDropdown,
120
+ hideDropdown,
121
+ });
115
122
  </script>
@@ -82,6 +82,17 @@ export const useDropdown = (props: DropdownPropTypes, emit: SetupContext<Dropdow
82
82
  const dropdownPopperState = ref<boolean>(false);
83
83
  const isDropdownPopperDisabled = computed(() => disabled.value);
84
84
 
85
+ // Exposed methods to show/hide dropdown. This is for custom trigger handling for custom dropdown.
86
+ // To use these methods, set :triggers="[]" on the SprDropdown component to disable default triggers. (reference: https://floating-vue.starpad.dev/api/#shown)
87
+ /* #region - Exposed Methods */
88
+ const showDropdown = () => {
89
+ dropdownPopperState.value = true;
90
+ };
91
+ const hideDropdown = () => {
92
+ dropdownPopperState.value = false;
93
+ };
94
+ /* #endregion - Exposed Methods */
95
+
85
96
  const isLadderizedSearch = computed(
86
97
  () => ladderized.value && searchString.value !== '' && normalizedValue.value.length === 0,
87
98
  );
@@ -503,5 +514,7 @@ export const useDropdown = (props: DropdownPropTypes, emit: SetupContext<Dropdow
503
514
  dropdownValue: compatPreSelectedItems, // Use compatible format for lists
504
515
  removeCurrentLevelInBackLabel,
505
516
  isLadderizedSearch,
517
+ showDropdown,
518
+ hideDropdown,
506
519
  };
507
520
  };
@@ -1,60 +1,60 @@
1
- import type { PropType, ExtractPropTypes } from 'vue';
2
- import type { MenuListType } from '../list';
3
-
4
- export const listItemPropTypes = {
5
- item: {
6
- type: Object as PropType<MenuListType>,
7
- required: true,
8
- },
9
- isSelected: {
10
- type: Boolean,
11
- required: true,
12
- },
13
- classes: {
14
- type: [String, Array, Object] as PropType<string | string[] | Record<string, boolean>>,
15
- required: true,
16
- },
17
- multiSelect: {
18
- type: Boolean,
19
- default: false,
20
- },
21
- lozenge: {
22
- type: Boolean,
23
- default: false,
24
- },
25
- ladderized: {
26
- type: Boolean,
27
- default: false,
28
- },
29
- noCheck: {
30
- type: Boolean,
31
- default: false,
32
- },
33
- itemIcon: {
34
- type: String,
35
- default: '',
36
- },
37
- itemIconTone: {
38
- type: String,
39
- default: 'plain',
40
- },
41
- itemIconFill: {
42
- type: Boolean,
43
- default: false,
44
- },
45
- disabledUnselectedItems: {
46
- type: Boolean,
47
- default: false,
48
- },
49
- radioList: {
50
- type: Boolean,
51
- default: false,
52
- },
53
- };
54
-
55
- export const listItemEmitTypes = {
56
- select: () => true,
57
- };
58
-
59
- export type ListItemPropTypes = ExtractPropTypes<typeof listItemPropTypes>;
60
- export type ListItemEmitTypes = typeof listItemEmitTypes;
1
+ import type { PropType, ExtractPropTypes } from 'vue';
2
+ import type { MenuListType } from '../list';
3
+
4
+ export const listItemPropTypes = {
5
+ item: {
6
+ type: Object as PropType<MenuListType>,
7
+ required: true,
8
+ },
9
+ isSelected: {
10
+ type: Boolean,
11
+ required: true,
12
+ },
13
+ classes: {
14
+ type: [String, Array, Object] as PropType<string | string[] | Record<string, boolean>>,
15
+ required: true,
16
+ },
17
+ multiSelect: {
18
+ type: Boolean,
19
+ default: false,
20
+ },
21
+ lozenge: {
22
+ type: Boolean,
23
+ default: false,
24
+ },
25
+ ladderized: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
29
+ noCheck: {
30
+ type: Boolean,
31
+ default: false,
32
+ },
33
+ itemIcon: {
34
+ type: String,
35
+ default: '',
36
+ },
37
+ itemIconTone: {
38
+ type: String,
39
+ default: 'plain',
40
+ },
41
+ itemIconFill: {
42
+ type: Boolean,
43
+ default: false,
44
+ },
45
+ disabledUnselectedItems: {
46
+ type: Boolean,
47
+ default: false,
48
+ },
49
+ radioList: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
53
+ };
54
+
55
+ export const listItemEmitTypes = {
56
+ select: () => true,
57
+ };
58
+
59
+ export type ListItemPropTypes = ExtractPropTypes<typeof listItemPropTypes>;
60
+ export type ListItemEmitTypes = typeof listItemEmitTypes;
@@ -1,65 +1,65 @@
1
- import type { PropType, ExtractPropTypes } from 'vue';
2
-
3
- export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
4
-
5
- export interface RadioOption {
6
- text: string;
7
- value: string | number | boolean;
8
- disabled?: boolean;
9
- }
10
-
11
- export const radioGroupedPropTypes = {
12
- id: {
13
- type: String,
14
- required: true,
15
- },
16
- modelValue: {
17
- type: [String, Number, Boolean],
18
- },
19
- name: {
20
- type: String,
21
- required: true,
22
- },
23
- options: {
24
- type: Array as PropType<RadioOption[]>,
25
- required: true,
26
- default: () => [],
27
- },
28
- disabled: {
29
- type: Boolean,
30
- default: false,
31
- },
32
- description: {
33
- type: String,
34
- },
35
- bordered: {
36
- type: Boolean,
37
- default: false,
38
- },
39
- displayHelper: {
40
- type: Boolean,
41
- default: false,
42
- },
43
- helperIcon: {
44
- type: String,
45
- default: null,
46
- },
47
- helperText: {
48
- type: String,
49
- default: '',
50
- },
51
- error: {
52
- type: Boolean,
53
- default: false,
54
- },
55
- horizontalAlign: {
56
- type: String as PropType<'left' | 'center' | 'right'>,
57
- default: 'left',
58
- },
59
- };
60
-
61
- export const radioGroupedEmitTypes = ['update:modelValue'];
62
-
63
- export type RadioGroupedPropTypes = ExtractPropTypes<typeof radioGroupedPropTypes>;
64
-
65
- export type RadioGroupedEmitTypes = typeof radioGroupedEmitTypes;
1
+ import type { PropType, ExtractPropTypes } from 'vue';
2
+
3
+ export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
4
+
5
+ export interface RadioOption {
6
+ text: string;
7
+ value: string | number | boolean;
8
+ disabled?: boolean;
9
+ }
10
+
11
+ export const radioGroupedPropTypes = {
12
+ id: {
13
+ type: String,
14
+ required: true,
15
+ },
16
+ modelValue: {
17
+ type: [String, Number, Boolean],
18
+ },
19
+ name: {
20
+ type: String,
21
+ required: true,
22
+ },
23
+ options: {
24
+ type: Array as PropType<RadioOption[]>,
25
+ required: true,
26
+ default: () => [],
27
+ },
28
+ disabled: {
29
+ type: Boolean,
30
+ default: false,
31
+ },
32
+ description: {
33
+ type: String,
34
+ },
35
+ bordered: {
36
+ type: Boolean,
37
+ default: false,
38
+ },
39
+ displayHelper: {
40
+ type: Boolean,
41
+ default: false,
42
+ },
43
+ helperIcon: {
44
+ type: String,
45
+ default: null,
46
+ },
47
+ helperText: {
48
+ type: String,
49
+ default: '',
50
+ },
51
+ error: {
52
+ type: Boolean,
53
+ default: false,
54
+ },
55
+ horizontalAlign: {
56
+ type: String as PropType<'left' | 'center' | 'right'>,
57
+ default: 'left',
58
+ },
59
+ };
60
+
61
+ export const radioGroupedEmitTypes = ['update:modelValue'];
62
+
63
+ export type RadioGroupedPropTypes = ExtractPropTypes<typeof radioGroupedPropTypes>;
64
+
65
+ export type RadioGroupedEmitTypes = typeof radioGroupedEmitTypes;
@@ -1,62 +1,62 @@
1
- import { toRefs, computed, ComputedRef } from 'vue';
2
- import { useVModel } from '@vueuse/core';
3
-
4
- import classNames from 'classnames';
5
-
6
- import type { SetupContext } from 'vue';
7
- import type { RadioGroupedPropTypes, RadioGroupedEmitTypes, RadioOption } from './radio-grouped';
8
-
9
- interface RadioGroupedClasses {
10
- containerClasses: string;
11
- helperClasses: string;
12
- }
13
-
14
- export const useRadioGrouped = (props: RadioGroupedPropTypes, emit: SetupContext<RadioGroupedEmitTypes>['emit']) => {
15
- const { disabled, horizontalAlign, displayHelper, error } = toRefs(props);
16
-
17
- const radioGroupedClasses: ComputedRef<RadioGroupedClasses> = computed(() => {
18
- const alignmentMap = {
19
- left: 'spr-justify-start',
20
- center: 'spr-justify-center',
21
- right: 'spr-justify-end',
22
- };
23
-
24
- const containerClasses = classNames('spr-flex spr-flex-col spr-gap-2', {
25
- [alignmentMap[horizontalAlign.value as keyof typeof alignmentMap]]: true,
26
- });
27
-
28
- const helperClasses = classNames(
29
- 'spr-flex spr-items-center spr-gap-1 spr-mt-size-spacing-2xs spr-body-sm-regular',
30
- {
31
- 'spr-text-mushroom-600': !error.value,
32
- 'spr-text-color-danger-base': error.value,
33
- },
34
- );
35
-
36
- return {
37
- containerClasses,
38
- helperClasses,
39
- };
40
- });
41
-
42
- const proxyValue = useVModel(props, 'modelValue', emit);
43
-
44
- const renderOptions = (): RadioOption[] => {
45
- return props.options || [];
46
- };
47
-
48
- const isOptionDisabled = (option: RadioOption): boolean => {
49
- return disabled.value || (option.disabled ?? false);
50
- };
51
-
52
- return {
53
- radioGroupedClasses,
54
- proxyValue,
55
- renderOptions,
56
- isOptionDisabled,
57
- disabled,
58
- displayHelper,
59
- horizontalAlign,
60
- error,
61
- };
62
- };
1
+ import { toRefs, computed, ComputedRef } from 'vue';
2
+ import { useVModel } from '@vueuse/core';
3
+
4
+ import classNames from 'classnames';
5
+
6
+ import type { SetupContext } from 'vue';
7
+ import type { RadioGroupedPropTypes, RadioGroupedEmitTypes, RadioOption } from './radio-grouped';
8
+
9
+ interface RadioGroupedClasses {
10
+ containerClasses: string;
11
+ helperClasses: string;
12
+ }
13
+
14
+ export const useRadioGrouped = (props: RadioGroupedPropTypes, emit: SetupContext<RadioGroupedEmitTypes>['emit']) => {
15
+ const { disabled, horizontalAlign, displayHelper, error } = toRefs(props);
16
+
17
+ const radioGroupedClasses: ComputedRef<RadioGroupedClasses> = computed(() => {
18
+ const alignmentMap = {
19
+ left: 'spr-justify-start',
20
+ center: 'spr-justify-center',
21
+ right: 'spr-justify-end',
22
+ };
23
+
24
+ const containerClasses = classNames('spr-flex spr-flex-col spr-gap-2', {
25
+ [alignmentMap[horizontalAlign.value as keyof typeof alignmentMap]]: true,
26
+ });
27
+
28
+ const helperClasses = classNames(
29
+ 'spr-flex spr-items-center spr-gap-1 spr-mt-size-spacing-2xs spr-body-sm-regular',
30
+ {
31
+ 'spr-text-mushroom-600': !error.value,
32
+ 'spr-text-color-danger-base': error.value,
33
+ },
34
+ );
35
+
36
+ return {
37
+ containerClasses,
38
+ helperClasses,
39
+ };
40
+ });
41
+
42
+ const proxyValue = useVModel(props, 'modelValue', emit);
43
+
44
+ const renderOptions = (): RadioOption[] => {
45
+ return props.options || [];
46
+ };
47
+
48
+ const isOptionDisabled = (option: RadioOption): boolean => {
49
+ return disabled.value || (option.disabled ?? false);
50
+ };
51
+
52
+ return {
53
+ radioGroupedClasses,
54
+ proxyValue,
55
+ renderOptions,
56
+ isOptionDisabled,
57
+ disabled,
58
+ displayHelper,
59
+ horizontalAlign,
60
+ error,
61
+ };
62
+ };
@@ -104,6 +104,10 @@ export const sidepanelPropTypes = {
104
104
  isActivePanel: {
105
105
  type: Boolean,
106
106
  default: false
107
+ },
108
+ footerNoTopBorder: {
109
+ type: Boolean,
110
+ default: false,
107
111
  }
108
112
  };
109
113
 
@@ -17,6 +17,7 @@
17
17
  aria-labelledby="sidepanel-title"
18
18
  aria-describedby="sidepanel-content"
19
19
  :class="sidepanelClasses.sidepanelBaseClasses"
20
+ data-testid="sidepanel-dialog"
20
21
  :style="{ height: typeof height === 'number' ? `${height}px` : height }"
21
22
  >
22
23
  <template v-if="!props.hideHeader">
@@ -29,9 +30,10 @@
29
30
  v-if="props.isExpandable"
30
31
  :class="sidepanelClasses.sidepanelHeaderIconClasses"
31
32
  :icon="isExpanded ? 'ph:arrows-in-simple' : 'ph:arrows-out-simple'"
33
+ data-testid="expand-icon"
32
34
  @click="handlePanelExpansion"
33
35
  />
34
- <Icon :class="sidepanelClasses.sidepanelHeaderIconClasses" icon="ph:x" @click="handleClose" />
36
+ <Icon :class="sidepanelClasses.sidepanelHeaderIconClasses" icon="ph:x" data-testid="x-icon" @click="handleClose" />
35
37
  </div>
36
38
  </div>
37
39
  <div v-else>
@@ -19,7 +19,7 @@ interface SidepanelClasses {
19
19
  }
20
20
 
21
21
  export const useSidepanel = (props: SidepanelPropTypes, emit: SetupContext<SidepanelEmitTypes>['emit']) => {
22
- const { size, position, isStacking, footerNoPadding, isExpanded, isActivePanel } = toRefs(props);
22
+ const { size, position, isStacking, footerNoPadding, isExpanded, isActivePanel, footerNoTopBorder } = toRefs(props);
23
23
 
24
24
  const sidepanelClasses: ComputedRef<SidepanelClasses> = computed(() => {
25
25
  const sidepanelBaseClasses = classNames(
@@ -48,9 +48,10 @@ export const useSidepanel = (props: SidepanelPropTypes, emit: SetupContext<Sidep
48
48
  const sidepanelContentClasses = classNames('spr-h-full spr-overflow-y-auto');
49
49
 
50
50
  const sidepanelFooterClasses = classNames(
51
- 'spr-bottom-0 spr-left-0 spr-w-full spr-rounded-b-border-radius-xl spr-border-0 spr-border-t spr-border-solid spr-border-mushroom-200 spr-bg-white-50 ',
51
+ 'spr-bottom-0 spr-left-0 spr-w-full spr-rounded-b-border-radius-xl spr-border-0 spr-border-solid spr-border-mushroom-200 spr-bg-white-50 ',
52
52
  {
53
53
  'spr-py-3': !footerNoPadding.value,
54
+ 'spr-border-t': !footerNoTopBorder.value
54
55
  },
55
56
  );
56
57
 
@@ -0,0 +1,48 @@
1
+ import type { MenuListType } from '@/components/list/list';
2
+ import { type PropType, type ExtractPropTypes, ref } from 'vue';
3
+ import type { Header } from '../table';
4
+ export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
5
+
6
+ const defaultSortOptions = ref([
7
+ { text: 'Sort Ascending', value: 'asc', icon: 'ph:sort-ascending', iconColor: 'spr-text-color-supporting' },
8
+ { text: 'Sort Descending', value: 'desc', icon: 'ph:sort-descending', iconColor: 'spr-text-color-supporting' },
9
+ ]);
10
+
11
+ export const tableHeaderDropdownPropTypes = {
12
+ id: {
13
+ type: String,
14
+ required: true,
15
+ },
16
+ header: {
17
+ type: Object as PropType<Header>,
18
+ default: () => ({}),
19
+ },
20
+ isSortable: {
21
+ type: Boolean,
22
+ default: true,
23
+ },
24
+ headerClasses: {
25
+ type: String,
26
+ default: '',
27
+ },
28
+ sortOptions: {
29
+ type: Array as PropType<MenuListType[]>,
30
+ default: () => defaultSortOptions.value,
31
+ },
32
+ };
33
+
34
+ export interface TableHeaderFilterType {
35
+ headerField: string;
36
+ sortBy: 'asc' | 'desc' | null;
37
+ appliedFilters: Record<string, string>;
38
+ };
39
+
40
+ export const tableHeaderDropdownEmitTypes = {
41
+ onApplyFilter: (filter: TableHeaderFilterType) => !!filter,
42
+ onSelectAll: () => true,
43
+ 'update:selectedSort': (selectedSort: MenuListType[]) => Array.isArray(selectedSort),
44
+ 'update:selectedFilters': (selectedFilters: MenuListType[]) => Array.isArray(selectedFilters),
45
+ };
46
+
47
+ export type TableHeaderDropdownPropTypes = ExtractPropTypes<typeof tableHeaderDropdownPropTypes>;
48
+ export type TableHeaderDropdownEmitTypes = typeof tableHeaderDropdownEmitTypes;