@spaced-out/ui-design-system 0.3.28 → 0.3.30
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/CHANGELOG.md +14 -0
- package/design-tokens/color/app-color.json +2 -2
- package/lib/components/Chip/Chip.module.css +2 -2
- package/lib/components/Table/Table.docs.js +12 -0
- package/lib/components/Table/Table.docs.js.flow +9 -0
- package/lib/components/Table/Table.js +3 -1
- package/lib/components/Table/Table.js.flow +5 -0
- package/lib/components/Table/hooks.js +9 -7
- package/lib/components/Table/hooks.js.flow +9 -6
- package/lib/styles/index.css +1 -1
- package/lib/styles/index.js +1 -1
- package/lib/styles/index.js.flow +1 -1
- package/lib/styles/variables/_color.css +1 -1
- package/lib/styles/variables/_color.js +1 -1
- package/lib/styles/variables/_color.js.flow +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.3.30](https://github.com/spaced-out/ui-design-system/compare/v0.3.29...v0.3.30) (2025-03-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* change tokens ([#327](https://github.com/spaced-out/ui-design-system/issues/327)) ([4fdf2a1](https://github.com/spaced-out/ui-design-system/commit/4fdf2a13af14d0570ce0bf8bc1c3d413fe7e9995))
|
|
11
|
+
|
|
12
|
+
### [0.3.29](https://github.com/spaced-out/ui-design-system/compare/v0.3.28...v0.3.29) (2025-03-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* disabled internal sorting and handled onSOrt ([#325](https://github.com/spaced-out/ui-design-system/issues/325)) ([f43d03a](https://github.com/spaced-out/ui-design-system/commit/f43d03a135240c3dba9a91695ed3128130de63e2))
|
|
18
|
+
|
|
5
19
|
### [0.3.28](https://github.com/spaced-out/ui-design-system/compare/v0.3.27...v0.3.28) (2025-03-09)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
},
|
|
147
147
|
"tertiary": {
|
|
148
148
|
"enabled": {
|
|
149
|
-
"value": "{baseColor.
|
|
149
|
+
"value": "{baseColor.white.100.value}"
|
|
150
150
|
},
|
|
151
151
|
"hovered": {
|
|
152
152
|
"value": "{baseColor.gray.75.value}"
|
|
@@ -359,4 +359,4 @@
|
|
|
359
359
|
"value": "{baseColor.red.900.value}"
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
-
}
|
|
362
|
+
}
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
colorWarningLight,
|
|
10
10
|
colorDangerLightest,
|
|
11
11
|
colorDangerLight,
|
|
12
|
+
colorBackgroundTertiary,
|
|
12
13
|
colorGrayLightest,
|
|
13
|
-
colorFillNone,
|
|
14
14
|
colorTextDisabled,
|
|
15
15
|
colorFillDisabled,
|
|
16
16
|
colorFocusPrimary
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
|
|
119
119
|
.secondary {
|
|
120
120
|
composes: borderPrimary from '../../styles/border.module.css';
|
|
121
|
-
background-color:
|
|
121
|
+
background-color: colorBackgroundTertiary;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.secondary:not(.noHoverState):hover {
|
|
@@ -198,6 +198,18 @@ const TABLE_DOCS = {
|
|
|
198
198
|
summary: false
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
+
},
|
|
202
|
+
enableInternalSorting: {
|
|
203
|
+
description: 'Enable internal sorting for the table. This would sort the table data internally and not rely on the apis sorting',
|
|
204
|
+
control: 'boolean',
|
|
205
|
+
table: {
|
|
206
|
+
type: {
|
|
207
|
+
summary: '?boolean'
|
|
208
|
+
},
|
|
209
|
+
defaultValue: {
|
|
210
|
+
summary: true
|
|
211
|
+
}
|
|
212
|
+
}
|
|
201
213
|
}
|
|
202
214
|
},
|
|
203
215
|
parameters: {
|
|
@@ -162,6 +162,15 @@ export const TABLE_DOCS = {
|
|
|
162
162
|
defaultValue: {summary: false},
|
|
163
163
|
},
|
|
164
164
|
},
|
|
165
|
+
enableInternalSorting: {
|
|
166
|
+
description:
|
|
167
|
+
'Enable internal sorting for the table. This would sort the table data internally and not rely on the apis sorting',
|
|
168
|
+
control: 'boolean',
|
|
169
|
+
table: {
|
|
170
|
+
type: {summary: '?boolean'},
|
|
171
|
+
defaultValue: {summary: true},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
165
174
|
},
|
|
166
175
|
parameters: {
|
|
167
176
|
componentSubtitle: 'Generates a Table component.',
|
|
@@ -44,6 +44,7 @@ function Table(props) {
|
|
|
44
44
|
defaultSortKey,
|
|
45
45
|
defaultSortDirection = 'original',
|
|
46
46
|
onSort,
|
|
47
|
+
enableInternalSorting,
|
|
47
48
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
48
49
|
isLoading,
|
|
49
50
|
idName = 'id',
|
|
@@ -62,7 +63,8 @@ function Table(props) {
|
|
|
62
63
|
} = (0, _hooks.useSortableEntries)(entries, idName, {
|
|
63
64
|
defaultSortKey,
|
|
64
65
|
defaultSortDirection,
|
|
65
|
-
onSort
|
|
66
|
+
onSort,
|
|
67
|
+
enableInternalSorting
|
|
66
68
|
});
|
|
67
69
|
return /*#__PURE__*/React.createElement(_StaticTable.StaticTable, _extends({}, props, sortableProps, {
|
|
68
70
|
sortable: sortable,
|
|
@@ -41,6 +41,8 @@ export type TableProps<T, U> = {
|
|
|
41
41
|
headerIconClassName?: string,
|
|
42
42
|
defaultSortKey?: string,
|
|
43
43
|
defaultSortDirection?: 'asc' | 'desc' | 'original',
|
|
44
|
+
// Please start using this prop if you want internal sorting to work in the table
|
|
45
|
+
enableInternalSorting?: boolean,
|
|
44
46
|
|
|
45
47
|
selectedKeys?: string[],
|
|
46
48
|
onSelect?: (keys: string[]) => mixed,
|
|
@@ -93,6 +95,8 @@ export function Table<Data: GenericObject, Extras: GenericObject>(
|
|
|
93
95
|
defaultSortKey,
|
|
94
96
|
defaultSortDirection = 'original',
|
|
95
97
|
onSort,
|
|
98
|
+
enableInternalSorting,
|
|
99
|
+
|
|
96
100
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
97
101
|
isLoading,
|
|
98
102
|
idName = 'id',
|
|
@@ -111,6 +115,7 @@ export function Table<Data: GenericObject, Extras: GenericObject>(
|
|
|
111
115
|
defaultSortKey,
|
|
112
116
|
defaultSortDirection,
|
|
113
117
|
onSort,
|
|
118
|
+
enableInternalSorting,
|
|
114
119
|
},
|
|
115
120
|
);
|
|
116
121
|
|
|
@@ -15,7 +15,8 @@ function useSortableEntries(entries, idName, _ref) {
|
|
|
15
15
|
let {
|
|
16
16
|
defaultSortKey = 'id',
|
|
17
17
|
defaultSortDirection = 'original',
|
|
18
|
-
onSort
|
|
18
|
+
onSort,
|
|
19
|
+
enableInternalSorting = true
|
|
19
20
|
} = _ref;
|
|
20
21
|
const [sortKey, setSortKey] = React.useState(defaultSortKey);
|
|
21
22
|
const [sortDirection, setSortDirection] = React.useState(defaultSortDirection);
|
|
@@ -38,17 +39,18 @@ function useSortableEntries(entries, idName, _ref) {
|
|
|
38
39
|
return nextDirection;
|
|
39
40
|
};
|
|
40
41
|
const handleSortClick = React.useCallback(nextSortKey => {
|
|
41
|
-
let nextSortDirection
|
|
42
|
+
let nextSortDirection;
|
|
42
43
|
if (nextSortKey === sortKey) {
|
|
43
44
|
nextSortDirection = advanceSortDirection(sortDirection);
|
|
44
45
|
} else {
|
|
45
46
|
setSortKey(nextSortKey);
|
|
46
|
-
|
|
47
|
+
nextSortDirection = 'desc';
|
|
47
48
|
}
|
|
49
|
+
setSortDirection(nextSortDirection);
|
|
48
50
|
onSort?.(nextSortKey, nextSortDirection);
|
|
49
51
|
}, [sortKey, sortDirection, entries]);
|
|
50
52
|
const sortedEntries = React.useMemo(() => {
|
|
51
|
-
if (sortDirection === 'original') {
|
|
53
|
+
if (!enableInternalSorting || sortDirection === 'original') {
|
|
52
54
|
return entries;
|
|
53
55
|
}
|
|
54
56
|
const caseInsensitiveSortFunction = entry => {
|
|
@@ -57,9 +59,9 @@ function useSortableEntries(entries, idName, _ref) {
|
|
|
57
59
|
}
|
|
58
60
|
return entry[sortKey];
|
|
59
61
|
};
|
|
60
|
-
const
|
|
61
|
-
return sortDirection === 'asc' ?
|
|
62
|
-
}, [sortDirection, sortKey, entries]);
|
|
62
|
+
const sortedAsc = (0, _sortBy.default)(entries, caseInsensitiveSortFunction);
|
|
63
|
+
return sortDirection === 'asc' ? sortedAsc : sortedAsc.reverse();
|
|
64
|
+
}, [sortDirection, sortKey, entries, enableInternalSorting]);
|
|
63
65
|
const sortedKeys = React.useMemo(() => sortedEntries.map(ent => (0, _get.default)(ent, idName)), [sortedEntries]);
|
|
64
66
|
return {
|
|
65
67
|
sortedEntries,
|
|
@@ -16,10 +16,12 @@ export function useSortableEntries<T: GenericObject>(
|
|
|
16
16
|
defaultSortKey = 'id',
|
|
17
17
|
defaultSortDirection = 'original',
|
|
18
18
|
onSort,
|
|
19
|
+
enableInternalSorting = true,
|
|
19
20
|
}: {
|
|
20
21
|
defaultSortKey?: $Keys<T>,
|
|
21
22
|
defaultSortDirection?: SortDirection,
|
|
22
23
|
onSort?: (sortKey: string, sortDirection: SortDirection) => mixed,
|
|
24
|
+
enableInternalSorting?: boolean,
|
|
23
25
|
},
|
|
24
26
|
): {
|
|
25
27
|
handleSortClick: (sortKey: $Keys<T>) => mixed,
|
|
@@ -53,20 +55,21 @@ export function useSortableEntries<T: GenericObject>(
|
|
|
53
55
|
|
|
54
56
|
const handleSortClick = React.useCallback(
|
|
55
57
|
(nextSortKey: string) => {
|
|
56
|
-
let nextSortDirection
|
|
58
|
+
let nextSortDirection;
|
|
57
59
|
if (nextSortKey === sortKey) {
|
|
58
60
|
nextSortDirection = advanceSortDirection(sortDirection);
|
|
59
61
|
} else {
|
|
60
62
|
setSortKey(nextSortKey);
|
|
61
|
-
|
|
63
|
+
nextSortDirection = 'desc';
|
|
62
64
|
}
|
|
65
|
+
setSortDirection(nextSortDirection);
|
|
63
66
|
onSort?.(nextSortKey, nextSortDirection);
|
|
64
67
|
},
|
|
65
68
|
[sortKey, sortDirection, entries],
|
|
66
69
|
);
|
|
67
70
|
|
|
68
71
|
const sortedEntries = React.useMemo(() => {
|
|
69
|
-
if (sortDirection === 'original') {
|
|
72
|
+
if (!enableInternalSorting || sortDirection === 'original') {
|
|
70
73
|
return entries;
|
|
71
74
|
}
|
|
72
75
|
const caseInsensitiveSortFunction = (entry) => {
|
|
@@ -75,9 +78,9 @@ export function useSortableEntries<T: GenericObject>(
|
|
|
75
78
|
}
|
|
76
79
|
return entry[sortKey];
|
|
77
80
|
};
|
|
78
|
-
const
|
|
79
|
-
return sortDirection === 'asc' ?
|
|
80
|
-
}, [sortDirection, sortKey, entries]);
|
|
81
|
+
const sortedAsc = sortBy(entries, caseInsensitiveSortFunction);
|
|
82
|
+
return sortDirection === 'asc' ? sortedAsc : sortedAsc.reverse();
|
|
83
|
+
}, [sortDirection, sortKey, entries, enableInternalSorting]);
|
|
81
84
|
|
|
82
85
|
const sortedKeys = React.useMemo(
|
|
83
86
|
() => sortedEntries.map((ent) => get(ent, idName)),
|
package/lib/styles/index.css
CHANGED
package/lib/styles/index.js
CHANGED
|
@@ -113,7 +113,7 @@ const colorButtonFillSecondaryHovered = '#ccc0f0';
|
|
|
113
113
|
exports.colorButtonFillSecondaryHovered = colorButtonFillSecondaryHovered;
|
|
114
114
|
const colorButtonFillSecondaryPressed = '#ccc0f0';
|
|
115
115
|
exports.colorButtonFillSecondaryPressed = colorButtonFillSecondaryPressed;
|
|
116
|
-
const colorButtonFillTertiaryEnabled = '
|
|
116
|
+
const colorButtonFillTertiaryEnabled = '#ffffff';
|
|
117
117
|
exports.colorButtonFillTertiaryEnabled = colorButtonFillTertiaryEnabled;
|
|
118
118
|
const colorButtonFillTertiaryHovered = '#EBEBEB';
|
|
119
119
|
exports.colorButtonFillTertiaryHovered = colorButtonFillTertiaryHovered;
|
package/lib/styles/index.js.flow
CHANGED
|
@@ -106,7 +106,7 @@ export const colorButtonFillSecondaryHovered = '#ccc0f0';
|
|
|
106
106
|
|
|
107
107
|
export const colorButtonFillSecondaryPressed = '#ccc0f0';
|
|
108
108
|
|
|
109
|
-
export const colorButtonFillTertiaryEnabled = '
|
|
109
|
+
export const colorButtonFillTertiaryEnabled = '#ffffff';
|
|
110
110
|
|
|
111
111
|
export const colorButtonFillTertiaryHovered = '#EBEBEB';
|
|
112
112
|
|
|
@@ -88,7 +88,7 @@ const colorButtonFillSecondaryHovered = '#ccc0f0';
|
|
|
88
88
|
exports.colorButtonFillSecondaryHovered = colorButtonFillSecondaryHovered;
|
|
89
89
|
const colorButtonFillSecondaryPressed = '#ccc0f0';
|
|
90
90
|
exports.colorButtonFillSecondaryPressed = colorButtonFillSecondaryPressed;
|
|
91
|
-
const colorButtonFillTertiaryEnabled = '
|
|
91
|
+
const colorButtonFillTertiaryEnabled = '#ffffff';
|
|
92
92
|
exports.colorButtonFillTertiaryEnabled = colorButtonFillTertiaryEnabled;
|
|
93
93
|
const colorButtonFillTertiaryHovered = '#EBEBEB';
|
|
94
94
|
exports.colorButtonFillTertiaryHovered = colorButtonFillTertiaryHovered;
|
|
@@ -82,7 +82,7 @@ export const colorButtonFillSecondaryHovered = '#ccc0f0';
|
|
|
82
82
|
|
|
83
83
|
export const colorButtonFillSecondaryPressed = '#ccc0f0';
|
|
84
84
|
|
|
85
|
-
export const colorButtonFillTertiaryEnabled = '
|
|
85
|
+
export const colorButtonFillTertiaryEnabled = '#ffffff';
|
|
86
86
|
|
|
87
87
|
export const colorButtonFillTertiaryHovered = '#EBEBEB';
|
|
88
88
|
|