@spaced-out/ui-design-system 0.3.27 → 0.3.29
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/lib/components/ButtonDropdown/SimpleButtonDropdown.js +3 -1
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +3 -1
- package/lib/components/Dropdown/SimpleDropdown.js +3 -1
- package/lib/components/Dropdown/SimpleDropdown.js.flow +3 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js +3 -1
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +3 -0
- package/lib/components/OptionButton/SimpleOptionButton.js +3 -1
- package/lib/components/OptionButton/SimpleOptionButton.js.flow +3 -1
- 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/components/Typeahead/SimpleTypeahead.js +3 -1
- package/lib/components/Typeahead/SimpleTypeahead.js.flow +3 -0
- 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.29](https://github.com/spaced-out/ui-design-system/compare/v0.3.28...v0.3.29) (2025-03-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* 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))
|
|
11
|
+
|
|
12
|
+
### [0.3.28](https://github.com/spaced-out/ui-design-system/compare/v0.3.27...v0.3.28) (2025-03-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* added allow wraps in simple dropdowns,buttons,typeahead ([#324](https://github.com/spaced-out/ui-design-system/issues/324)) ([ec836ac](https://github.com/spaced-out/ui-design-system/commit/ec836ac0f04ea10384006adc8d649f7dcb163b4c))
|
|
18
|
+
|
|
5
19
|
### [0.3.27](https://github.com/spaced-out/ui-design-system/compare/v0.3.26...v0.3.27) (2025-03-06)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -31,6 +31,7 @@ const SimpleButtonDropdownBase = (props, ref) => {
|
|
|
31
31
|
footer,
|
|
32
32
|
menuClassNames,
|
|
33
33
|
showLabelTooltip,
|
|
34
|
+
allowWrap = false,
|
|
34
35
|
clickAwayRef,
|
|
35
36
|
...buttonProps
|
|
36
37
|
} = props;
|
|
@@ -80,7 +81,8 @@ const SimpleButtonDropdownBase = (props, ref) => {
|
|
|
80
81
|
header,
|
|
81
82
|
footer,
|
|
82
83
|
classNames: menuClassNames,
|
|
83
|
-
showLabelTooltip
|
|
84
|
+
showLabelTooltip,
|
|
85
|
+
allowWrap
|
|
84
86
|
}
|
|
85
87
|
}), optionsVariant === 'checkbox' ? btnText : children);
|
|
86
88
|
};
|
|
@@ -44,7 +44,7 @@ export type SimpleButtonDropdownProps = {
|
|
|
44
44
|
footer?: React.Node,
|
|
45
45
|
menuClassNames?: MenuClassNames,
|
|
46
46
|
showLabelTooltip?: MenuLabelTooltip,
|
|
47
|
-
|
|
47
|
+
allowWrap?: boolean,
|
|
48
48
|
// events
|
|
49
49
|
onOptionSelect?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
50
50
|
onMenuOpen?: () => mixed,
|
|
@@ -78,6 +78,7 @@ const SimpleButtonDropdownBase = (props: SimpleButtonDropdownProps, ref) => {
|
|
|
78
78
|
footer,
|
|
79
79
|
menuClassNames,
|
|
80
80
|
showLabelTooltip,
|
|
81
|
+
allowWrap = false,
|
|
81
82
|
clickAwayRef,
|
|
82
83
|
...buttonProps
|
|
83
84
|
} = props;
|
|
@@ -147,6 +148,7 @@ const SimpleButtonDropdownBase = (props: SimpleButtonDropdownProps, ref) => {
|
|
|
147
148
|
footer,
|
|
148
149
|
classNames: menuClassNames,
|
|
149
150
|
showLabelTooltip,
|
|
151
|
+
allowWrap,
|
|
150
152
|
}}
|
|
151
153
|
>
|
|
152
154
|
{optionsVariant === 'checkbox' ? btnText : children}
|
|
@@ -31,6 +31,7 @@ const SimpleDropdownBase = (props, ref) => {
|
|
|
31
31
|
menuClassNames,
|
|
32
32
|
showLabelTooltip,
|
|
33
33
|
clickAwayRef,
|
|
34
|
+
allowWrap = false,
|
|
34
35
|
...inputProps
|
|
35
36
|
} = props;
|
|
36
37
|
const [dropdownInputText, setDropdownInputText] = React.useState('');
|
|
@@ -80,7 +81,8 @@ const SimpleDropdownBase = (props, ref) => {
|
|
|
80
81
|
header,
|
|
81
82
|
footer,
|
|
82
83
|
classNames: menuClassNames,
|
|
83
|
-
showLabelTooltip
|
|
84
|
+
showLabelTooltip,
|
|
85
|
+
allowWrap
|
|
84
86
|
}
|
|
85
87
|
}));
|
|
86
88
|
};
|
|
@@ -41,6 +41,7 @@ export type SimpleDropdownProps = {
|
|
|
41
41
|
footer?: React.Node,
|
|
42
42
|
menuClassNames?: MenuClassNames,
|
|
43
43
|
showLabelTooltip?: MenuLabelTooltip,
|
|
44
|
+
allowWrap?: boolean,
|
|
44
45
|
|
|
45
46
|
// events
|
|
46
47
|
onChange?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
@@ -74,6 +75,7 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
|
|
|
74
75
|
menuClassNames,
|
|
75
76
|
showLabelTooltip,
|
|
76
77
|
clickAwayRef,
|
|
78
|
+
allowWrap = false,
|
|
77
79
|
...inputProps
|
|
78
80
|
} = props;
|
|
79
81
|
|
|
@@ -143,6 +145,7 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
|
|
|
143
145
|
footer,
|
|
144
146
|
classNames: menuClassNames,
|
|
145
147
|
showLabelTooltip,
|
|
148
|
+
allowWrap,
|
|
146
149
|
}}
|
|
147
150
|
/>
|
|
148
151
|
);
|
|
@@ -32,6 +32,7 @@ const SimpleInlineDropdownBase = (props, ref) => {
|
|
|
32
32
|
menuClassNames,
|
|
33
33
|
showLabelTooltip,
|
|
34
34
|
clickAwayRef,
|
|
35
|
+
allowWrap = false,
|
|
35
36
|
...buttonProps
|
|
36
37
|
} = props;
|
|
37
38
|
const [btnText, setBtnText] = React.useState('');
|
|
@@ -80,7 +81,8 @@ const SimpleInlineDropdownBase = (props, ref) => {
|
|
|
80
81
|
header,
|
|
81
82
|
footer,
|
|
82
83
|
classNames: menuClassNames,
|
|
83
|
-
showLabelTooltip
|
|
84
|
+
showLabelTooltip,
|
|
85
|
+
allowWrap
|
|
84
86
|
}
|
|
85
87
|
}), optionsVariant === 'checkbox' ? btnText : children);
|
|
86
88
|
};
|
|
@@ -38,6 +38,7 @@ export type SimpleInlineDropdownProps = {
|
|
|
38
38
|
allowSearch?: boolean,
|
|
39
39
|
selectedKeys?: Array<string>,
|
|
40
40
|
showLabelTooltip?: MenuLabelTooltip,
|
|
41
|
+
allowWrap?: boolean,
|
|
41
42
|
|
|
42
43
|
// events
|
|
43
44
|
onOptionSelect?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
@@ -77,6 +78,7 @@ const SimpleInlineDropdownBase = (props: SimpleInlineDropdownProps, ref) => {
|
|
|
77
78
|
menuClassNames,
|
|
78
79
|
showLabelTooltip,
|
|
79
80
|
clickAwayRef,
|
|
81
|
+
allowWrap = false,
|
|
80
82
|
...buttonProps
|
|
81
83
|
} = props;
|
|
82
84
|
|
|
@@ -145,6 +147,7 @@ const SimpleInlineDropdownBase = (props: SimpleInlineDropdownProps, ref) => {
|
|
|
145
147
|
footer,
|
|
146
148
|
classNames: menuClassNames,
|
|
147
149
|
showLabelTooltip,
|
|
150
|
+
allowWrap,
|
|
148
151
|
}}
|
|
149
152
|
>
|
|
150
153
|
{optionsVariant === 'checkbox' ? btnText : children}
|
|
@@ -34,6 +34,7 @@ const SimpleOptionButtonBase = (props, ref) => {
|
|
|
34
34
|
menuClassNames,
|
|
35
35
|
showLabelTooltip,
|
|
36
36
|
clickAwayRef,
|
|
37
|
+
allowWrap = false,
|
|
37
38
|
...buttonProps
|
|
38
39
|
} = props;
|
|
39
40
|
const [optionButtonSelectedKeys, setOptionButtonSelectedKeys] = React.useState(selectedKeys);
|
|
@@ -79,7 +80,8 @@ const SimpleOptionButtonBase = (props, ref) => {
|
|
|
79
80
|
header,
|
|
80
81
|
footer,
|
|
81
82
|
classNames: menuClassNames,
|
|
82
|
-
showLabelTooltip
|
|
83
|
+
showLabelTooltip,
|
|
84
|
+
allowWrap
|
|
83
85
|
}
|
|
84
86
|
}), children);
|
|
85
87
|
};
|
|
@@ -46,7 +46,7 @@ export type SimpleOptionButtonProps = {
|
|
|
46
46
|
footer?: React.Node,
|
|
47
47
|
menuClassNames?: MenuClassNames,
|
|
48
48
|
showLabelTooltip?: MenuLabelTooltip,
|
|
49
|
-
|
|
49
|
+
allowWrap?: boolean,
|
|
50
50
|
// events
|
|
51
51
|
onOptionSelect?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
52
52
|
onButtonClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
@@ -84,6 +84,7 @@ const SimpleOptionButtonBase = (props: SimpleOptionButtonProps, ref) => {
|
|
|
84
84
|
menuClassNames,
|
|
85
85
|
showLabelTooltip,
|
|
86
86
|
clickAwayRef,
|
|
87
|
+
allowWrap = false,
|
|
87
88
|
...buttonProps
|
|
88
89
|
} = props;
|
|
89
90
|
|
|
@@ -144,6 +145,7 @@ const SimpleOptionButtonBase = (props: SimpleOptionButtonProps, ref) => {
|
|
|
144
145
|
footer,
|
|
145
146
|
classNames: menuClassNames,
|
|
146
147
|
showLabelTooltip,
|
|
148
|
+
allowWrap,
|
|
147
149
|
}}
|
|
148
150
|
>
|
|
149
151
|
{children}
|
|
@@ -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)),
|
|
@@ -31,6 +31,7 @@ const SimpleTypeaheadBase = (props, ref) => {
|
|
|
31
31
|
clickAwayRef,
|
|
32
32
|
showLabelTooltip,
|
|
33
33
|
allowInternalFilter = true,
|
|
34
|
+
allowWrap = false,
|
|
34
35
|
...inputProps
|
|
35
36
|
} = props;
|
|
36
37
|
const [typeaheadInputText, setTypeaheadInputText] = React.useState('');
|
|
@@ -81,7 +82,8 @@ const SimpleTypeaheadBase = (props, ref) => {
|
|
|
81
82
|
header,
|
|
82
83
|
footer,
|
|
83
84
|
classNames: menuClassNames,
|
|
84
|
-
showLabelTooltip
|
|
85
|
+
showLabelTooltip,
|
|
86
|
+
allowWrap
|
|
85
87
|
},
|
|
86
88
|
clickAwayRef: clickAwayRef
|
|
87
89
|
}));
|
|
@@ -37,6 +37,7 @@ export type SimpleTypeaheadProps = {
|
|
|
37
37
|
footer?: React.Node,
|
|
38
38
|
menuClassNames?: MenuClassNames,
|
|
39
39
|
showLabelTooltip?: MenuLabelTooltip,
|
|
40
|
+
allowWrap?: boolean,
|
|
40
41
|
|
|
41
42
|
// events
|
|
42
43
|
onSelect?: (option: MenuOption, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
@@ -74,6 +75,7 @@ const SimpleTypeaheadBase = (props: SimpleTypeaheadProps, ref) => {
|
|
|
74
75
|
clickAwayRef,
|
|
75
76
|
showLabelTooltip,
|
|
76
77
|
allowInternalFilter = true,
|
|
78
|
+
allowWrap = false,
|
|
77
79
|
...inputProps
|
|
78
80
|
} = props;
|
|
79
81
|
|
|
@@ -143,6 +145,7 @@ const SimpleTypeaheadBase = (props: SimpleTypeaheadProps, ref) => {
|
|
|
143
145
|
footer,
|
|
144
146
|
classNames: menuClassNames,
|
|
145
147
|
showLabelTooltip,
|
|
148
|
+
allowWrap,
|
|
146
149
|
}}
|
|
147
150
|
clickAwayRef={clickAwayRef}
|
|
148
151
|
/>
|