@hyphen/hyphen-components 7.3.2 → 7.3.4
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/css/utilities.css +1 -1
- package/dist/css/variables.css +18 -28
- package/dist/hyphen-components.cjs.development.js +5873 -5019
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +18 -2
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +5731 -4844
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +2799 -57
- package/dist/index.js +0 -1
- package/package.json +18 -19
- package/src/components/Badge/Badge.module.scss +6 -0
- package/src/components/Badge/Badge.stories.tsx +1 -0
- package/src/components/Badge/Badge.test.tsx +3 -2
- package/src/components/Badge/Badge.tsx +5 -3
- package/src/components/Box/Box.tsx +5 -2
- package/src/components/Button/Button.module.scss +1 -1
- package/src/components/Button/Button.test.tsx +2 -2
- package/src/components/Calendar/Calendar.test.tsx +262 -0
- package/src/components/Card/Card.tsx +2 -0
- package/src/components/CheckboxInput/components/Checkbox.module.scss +1 -1
- package/src/components/CheckboxInput/components/Checkbox.tsx +2 -0
- package/src/components/Details/Details.module.scss +2 -2
- package/src/components/Details/Details.tsx +2 -0
- package/src/components/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/Drawer/Drawer.test.tsx +494 -56
- package/src/components/Drawer/Drawer.tsx +7 -1
- package/src/components/DropdownMenu/DropdownMenu.test.tsx +532 -12
- package/src/components/FormControl/FormControl.tsx +2 -0
- package/src/components/Formik/Formik.stories.tsx +30 -7
- package/src/components/Formik/FormikSelectInput/FormikSelectInput.tsx +6 -5
- package/src/components/Formik/FormikToggleGroup/FormikToggleGroup.tsx +1 -1
- package/src/components/HelpText/HelpText.tsx +2 -0
- package/src/components/Icon/Icon.stories.tsx +1 -1
- package/src/components/Icon/Icon.tsx +2 -0
- package/src/components/Modal/Modal.test.tsx +630 -81
- package/src/components/Modal/Modal.tsx +2 -0
- package/src/components/Modal/components/ModalFooter/ModalFooter.test.tsx +2 -2
- package/src/components/Popover/Popover.tsx +2 -0
- package/src/components/RadioGroup/RadioInput/RadioInput.tsx +2 -0
- package/src/components/SelectInput/SelectInput.stories.tsx +22 -22
- package/src/components/SelectInput/SelectInput.tsx +13 -9
- package/src/components/SelectInputInset/SelectInputInset.tsx +2 -0
- package/src/components/Sidebar/Sidebar.module.scss +4 -0
- package/src/components/Sidebar/Sidebar.stories.tsx +8 -4
- package/src/components/Sidebar/Sidebar.test.tsx +7 -4
- package/src/components/Sidebar/Sidebar.tsx +7 -4
- package/src/components/Table/Table.stories.tsx +102 -52
- package/src/components/TextInput/TextInput.tsx +2 -0
- package/src/components/TextInputInset/TextInputInset.tsx +2 -0
- package/src/components/TextareaInputInset/TextareaInputInset.tsx +2 -0
- package/src/components/TimePickerNative/TimePickerNative.stories.tsx +0 -1
- package/src/components/Toast/Toast.store.ts +1 -1
- package/src/components/Toast/Toast.stories.tsx +3 -2
- package/src/components/Toast/Toast.test.tsx +8 -6
- package/src/components/Toggle/Toggle.tsx +2 -0
- package/src/components/ToggleGroup/ToggleGroup.tsx +2 -0
- package/src/docs/Colors.mdx +0 -13
- package/src/index.ts +2 -0
- package/src/lib/getColumnKeys.ts +3 -3
- package/src/lib/mergeRefs.ts +1 -1
- package/src/lib/tokens.ts +4 -4
- package/dist/components/Alert/Alert.constants.d.ts +0 -8
- package/dist/components/Alert/Alert.d.ts +0 -42
- package/dist/components/Alert/Alert.stories.d.ts +0 -12
- package/dist/components/Alert/Alert.types.d.ts +0 -7
- package/dist/components/AspectRatio/AspectRatio.d.ts +0 -3
- package/dist/components/AspectRatio/AspectRatio.stories.d.ts +0 -6
- package/dist/components/Badge/Badge.d.ts +0 -24
- package/dist/components/Badge/Badge.stories.d.ts +0 -8
- package/dist/components/Box/Box.d.ts +0 -247
- package/dist/components/Box/Box.stories.d.ts +0 -46
- package/dist/components/Button/Button.constants.d.ts +0 -3
- package/dist/components/Button/Button.d.ts +0 -53
- package/dist/components/Button/Button.stories.d.ts +0 -16
- package/dist/components/Calendar/Calendar.d.ts +0 -7
- package/dist/components/Calendar/Calendar.stories.d.ts +0 -12
- package/dist/components/Card/Card.d.ts +0 -17
- package/dist/components/Card/Card.stories.d.ts +0 -8
- package/dist/components/Card/components/CardFooter/CardFooter.d.ts +0 -13
- package/dist/components/Card/components/CardHeader/CardHeader.d.ts +0 -13
- package/dist/components/Card/components/CardSection/CardSection.d.ts +0 -46
- package/dist/components/Card/components/index.d.ts +0 -3
- package/dist/components/CheckboxInput/CheckboxInput.d.ts +0 -72
- package/dist/components/CheckboxInput/CheckboxInput.stories.d.ts +0 -18
- package/dist/components/CheckboxInput/components/Checkbox.d.ts +0 -71
- package/dist/components/CheckboxInput/components/CheckboxIcon.d.ts +0 -27
- package/dist/components/Collapsible/Collapsible.d.ts +0 -5
- package/dist/components/Collapsible/Collapsible.stories.d.ts +0 -9
- package/dist/components/Details/Details.d.ts +0 -15
- package/dist/components/Details/Details.stories.d.ts +0 -6
- package/dist/components/Details/DetailsSummary.d.ts +0 -7
- package/dist/components/Drawer/Drawer.d.ts +0 -105
- package/dist/components/Drawer/Drawer.stories.d.ts +0 -62
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +0 -25
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts +0 -9
- package/dist/components/FormControl/FormControl.d.ts +0 -38
- package/dist/components/FormLabel/FormLabel.d.ts +0 -41
- package/dist/components/FormLabel/FormLabel.stories.d.ts +0 -6
- package/dist/components/Formik/Formik.stories.d.ts +0 -18
- package/dist/components/Formik/FormikCheckboxInput/FormikCheckboxInput.d.ts +0 -12
- package/dist/components/Formik/FormikRadioGroup/FormikRadioGroup.d.ts +0 -12
- package/dist/components/Formik/FormikSelectInput/FormikSelectInput.d.ts +0 -13
- package/dist/components/Formik/FormikSelectInputInset/FormikSelectInputInset.d.ts +0 -12
- package/dist/components/Formik/FormikSelectInputNative/FormikSelectInputNative.d.ts +0 -12
- package/dist/components/Formik/FormikSwitch/FormikSwitch.d.ts +0 -12
- package/dist/components/Formik/FormikTextInput/FormikTextInput.d.ts +0 -12
- package/dist/components/Formik/FormikTextInputInset/FormikTextInputInset.d.ts +0 -12
- package/dist/components/Formik/FormikTextareaInput/FormikTextareaInput.d.ts +0 -12
- package/dist/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.d.ts +0 -12
- package/dist/components/Formik/FormikTimePicker/FormikTimePicker.d.ts +0 -12
- package/dist/components/Formik/FormikTimePickerNative/FormikTimePickerNative.d.ts +0 -12
- package/dist/components/Formik/FormikToggleGroup/FormikToggleGroup.d.ts +0 -20
- package/dist/components/Formik/FormikToggleGroupMulti/FormikToggleGroupMulti.d.ts +0 -18
- package/dist/components/Heading/Heading.constants.d.ts +0 -10
- package/dist/components/Heading/Heading.d.ts +0 -35
- package/dist/components/Heading/Heading.stories.d.ts +0 -9
- package/dist/components/HelpText/HelpText.d.ts +0 -12
- package/dist/components/Icon/Icon.d.ts +0 -22
- package/dist/components/Icon/Icon.stories.d.ts +0 -10
- package/dist/components/InputValidationMessage/InputValidationMessage.d.ts +0 -9
- package/dist/components/Modal/Modal.d.ts +0 -83
- package/dist/components/Modal/Modal.stories.d.ts +0 -13
- package/dist/components/Modal/components/ModalBody/ModalBody.d.ts +0 -4
- package/dist/components/Modal/components/ModalFooter/ModalFooter.d.ts +0 -4
- package/dist/components/Modal/components/ModalHeader/ModalHeader.d.ts +0 -21
- package/dist/components/Modal/components/index.d.ts +0 -4
- package/dist/components/Pagination/Pagination.d.ts +0 -51
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -8
- package/dist/components/Pagination/Pagination.utilities.d.ts +0 -10
- package/dist/components/Popover/Popover.d.ts +0 -8
- package/dist/components/Popover/Popover.stories.d.ts +0 -7
- package/dist/components/RadioGroup/RadioGroup.d.ts +0 -75
- package/dist/components/RadioGroup/RadioGroup.stories.d.ts +0 -16
- package/dist/components/RadioGroup/RadioInput/RadioInput.d.ts +0 -57
- package/dist/components/RadioGroup/RadioInput/RadioInputIcon.d.ts +0 -27
- package/dist/components/RangeInput/RangeInput.d.ts +0 -29
- package/dist/components/RangeInput/RangeInput.stories.d.ts +0 -7
- package/dist/components/ResponsiveProvider/ResponsiveProvider.d.ts +0 -17
- package/dist/components/ResponsiveProvider/ResponsiveProvider.stories.d.ts +0 -7
- package/dist/components/SelectInput/SelectInput.d.ts +0 -148
- package/dist/components/SelectInput/SelectInput.stories.d.ts +0 -24
- package/dist/components/SelectInputInset/SelectInputInset.d.ts +0 -92
- package/dist/components/SelectInputInset/SelectInputInset.stories.d.ts +0 -12
- package/dist/components/SelectInputNative/SelectInputNative.d.ts +0 -45
- package/dist/components/SelectInputNative/SelectInputNative.stories.d.ts +0 -19
- package/dist/components/Sidebar/Sidebar.d.ts +0 -57
- package/dist/components/Sidebar/Sidebar.stories.d.ts +0 -9
- package/dist/components/Spinner/Spinner.d.ts +0 -12
- package/dist/components/Spinner/Spinner.stories.d.ts +0 -8
- package/dist/components/Switch/Switch.d.ts +0 -64
- package/dist/components/Switch/Switch.stories.d.ts +0 -12
- package/dist/components/Table/Table.d.ts +0 -86
- package/dist/components/Table/Table.stories.d.ts +0 -31
- package/dist/components/Table/TableBody/TableBody.d.ts +0 -52
- package/dist/components/Table/TableBody/TableBodyCell/TableBodyCell.d.ts +0 -45
- package/dist/components/Table/TableHead/TableHead.d.ts +0 -46
- package/dist/components/Table/TableHead/TableHeaderCell/TableHeaderCell.d.ts +0 -65
- package/dist/components/Table/common/TableRow/TableRow.d.ts +0 -67
- package/dist/components/TextInput/TextInput.d.ts +0 -106
- package/dist/components/TextInput/TextInput.stories.d.ts +0 -19
- package/dist/components/TextInputInset/TextInputInset.d.ts +0 -102
- package/dist/components/TextInputInset/TextInputInset.stories.d.ts +0 -13
- package/dist/components/TextareaInput/TextareaInput.d.ts +0 -97
- package/dist/components/TextareaInput/TextareaInput.stories.d.ts +0 -23
- package/dist/components/TextareaInputInset/TextareaInputInset.d.ts +0 -105
- package/dist/components/TextareaInputInset/TextareaInputInset.stories.d.ts +0 -12
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +0 -15
- package/dist/components/ThemeProvider/ThemeProvider.stories.d.ts +0 -6
- package/dist/components/TimePicker/TimePicker.d.ts +0 -35
- package/dist/components/TimePicker/TimePicker.stories.d.ts +0 -12
- package/dist/components/TimePickerNative/TimePickerNative.d.ts +0 -39
- package/dist/components/TimePickerNative/TimePickerNative.stories.d.ts +0 -11
- package/dist/components/Toast/Toast.store.d.ts +0 -36
- package/dist/components/Toast/Toast.stories.d.ts +0 -14
- package/dist/components/Toast/Toast.types.d.ts +0 -75
- package/dist/components/Toast/ToastContainer.d.ts +0 -43
- package/dist/components/Toast/ToastNotification.d.ts +0 -28
- package/dist/components/Toast/index.d.ts +0 -4
- package/dist/components/Toast/toast.d.ts +0 -20
- package/dist/components/Toast/useToasts.d.ts +0 -14
- package/dist/components/Toggle/Toggle.d.ts +0 -7
- package/dist/components/Toggle/Toggle.stories.d.ts +0 -11
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +0 -19
- package/dist/components/ToggleGroup/ToggleGroup.stories.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.d.ts +0 -8
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -8
- package/dist/constants/keyCodes.d.ts +0 -2
- package/dist/css/index.css +0 -36
- package/dist/hooks/index.d.ts +0 -6
- package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +0 -9
- package/dist/hooks/useBreakpoint/useBreakpoint.stories.d.ts +0 -6
- package/dist/hooks/useIsMobile/useIsMobile.d.ts +0 -1
- package/dist/hooks/useIsMobile/useIsMobile.stories.d.ts +0 -6
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +0 -2
- package/dist/hooks/useOpenClose/useOpenClose.d.ts +0 -39
- package/dist/hooks/useOpenClose/useOpenClose.stories.d.ts +0 -6
- package/dist/hooks/useTheme/useTheme.d.ts +0 -5
- package/dist/hooks/useTheme/useTheme.stories.d.ts +0 -6
- package/dist/hooks/useWindowSize/useWindowSize.d.ts +0 -7
- package/dist/hooks/useWindowSize/useWindowSize.stories.d.ts +0 -6
- package/dist/lib/cssShorthandToClasses.d.ts +0 -4
- package/dist/lib/doesStringIncludeCssUnit.d.ts +0 -1
- package/dist/lib/generateResponsiveClasses.d.ts +0 -2
- package/dist/lib/getAutoCompleteValue.d.ts +0 -1
- package/dist/lib/getColumnKeys.d.ts +0 -3
- package/dist/lib/getDimensionCss.d.ts +0 -12
- package/dist/lib/getElementType.d.ts +0 -14
- package/dist/lib/getFlexCss.d.ts +0 -9
- package/dist/lib/index.d.ts +0 -15
- package/dist/lib/isFunction.d.ts +0 -3
- package/dist/lib/mergeRefs.d.ts +0 -2
- package/dist/lib/prefersReducedMotion.d.ts +0 -1
- package/dist/lib/react-children-utilities/filter.d.ts +0 -3
- package/dist/lib/react-children-utilities/index.d.ts +0 -1
- package/dist/lib/reactRouterClickHandler.d.ts +0 -12
- package/dist/lib/resolveValue.d.ts +0 -3
- package/dist/lib/tokens.d.ts +0 -22
- package/dist/modes.d.ts +0 -8
- package/dist/types/index.d.ts +0 -103
- package/dist/types/lib.types.d.ts +0 -3
|
@@ -59,10 +59,10 @@ describe('ModalFooter', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
test('applies custom styles', () => {
|
|
62
|
-
const customStyle = { backgroundColor: '
|
|
62
|
+
const customStyle = { backgroundColor: '#cacaca' };
|
|
63
63
|
const { container } = render(
|
|
64
64
|
<ModalFooter style={customStyle}>test modal</ModalFooter>
|
|
65
65
|
);
|
|
66
|
-
expect(container.firstChild).toHaveStyle('background-color:
|
|
66
|
+
expect(container.firstChild).toHaveStyle('background-color: #cacaca');
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -25,7 +25,7 @@ export const Default = () => {
|
|
|
25
25
|
<SelectInput
|
|
26
26
|
id="singleSelectWithLabel"
|
|
27
27
|
label="Label"
|
|
28
|
-
// @ts-
|
|
28
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
29
29
|
onChange={(event) => setValue(event.target.value)}
|
|
30
30
|
options={options}
|
|
31
31
|
value={value}
|
|
@@ -46,7 +46,7 @@ export const PreSelected = () => {
|
|
|
46
46
|
<SelectInput
|
|
47
47
|
id="preSelected"
|
|
48
48
|
label="Label"
|
|
49
|
-
// @ts-
|
|
49
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
50
50
|
onChange={(event) => setValue(event.target.value)}
|
|
51
51
|
options={options}
|
|
52
52
|
value={value}
|
|
@@ -68,7 +68,7 @@ export const HelpText = () => {
|
|
|
68
68
|
id="helpText"
|
|
69
69
|
label="Flavor"
|
|
70
70
|
helpText="Choose your favorite flavor"
|
|
71
|
-
// @ts-
|
|
71
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
72
72
|
onChange={(event) => setValue(event.target.value)}
|
|
73
73
|
options={options}
|
|
74
74
|
value={value}
|
|
@@ -90,7 +90,7 @@ export const Placeholder = () => {
|
|
|
90
90
|
<SelectInput
|
|
91
91
|
id="customPlaceholder"
|
|
92
92
|
label="Label"
|
|
93
|
-
// @ts-
|
|
93
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
94
94
|
onChange={(event) => setValue(event.target.value)}
|
|
95
95
|
options={options}
|
|
96
96
|
value={value}
|
|
@@ -112,7 +112,7 @@ export const HiddenLabel = () => {
|
|
|
112
112
|
<SelectInput
|
|
113
113
|
id="labelHidden"
|
|
114
114
|
label="My label is hidden"
|
|
115
|
-
// @ts-
|
|
115
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
116
116
|
onChange={(event) => setValue(event.target.value)}
|
|
117
117
|
options={options}
|
|
118
118
|
value={value}
|
|
@@ -134,7 +134,7 @@ export const CreatableSelect = () => {
|
|
|
134
134
|
id="creatableSelect"
|
|
135
135
|
label="Label"
|
|
136
136
|
value={value}
|
|
137
|
-
// @ts-
|
|
137
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
138
138
|
onChange={(event) => setValue(event.target.value)}
|
|
139
139
|
options={options}
|
|
140
140
|
isCreatable
|
|
@@ -182,7 +182,7 @@ export const AsyncSelect = () => {
|
|
|
182
182
|
id="asyncSelect"
|
|
183
183
|
label="Label"
|
|
184
184
|
value={value}
|
|
185
|
-
// @ts-
|
|
185
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
186
186
|
onChange={(event) => setValue(event.target.value)}
|
|
187
187
|
options={loadOptions}
|
|
188
188
|
defaultOptions
|
|
@@ -233,7 +233,7 @@ export const AsyncCreatableSelect = () => {
|
|
|
233
233
|
id="asyncCreateSelect"
|
|
234
234
|
label="Label"
|
|
235
235
|
value={value}
|
|
236
|
-
// @ts-
|
|
236
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
237
237
|
onChange={(event) => setValue(event.target.value)}
|
|
238
238
|
options={loadOptions}
|
|
239
239
|
isCreatable
|
|
@@ -258,7 +258,7 @@ export const MultiSelect = () => {
|
|
|
258
258
|
id="multiSelect"
|
|
259
259
|
label="Label"
|
|
260
260
|
value={value}
|
|
261
|
-
// @ts-
|
|
261
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
262
262
|
onChange={(event) => setValue(event.target.value)}
|
|
263
263
|
options={options}
|
|
264
264
|
isMulti
|
|
@@ -280,7 +280,7 @@ export const MultiSelectAndPreSelected = () => {
|
|
|
280
280
|
id="preSelectMultiSelect"
|
|
281
281
|
label="Label"
|
|
282
282
|
value={value}
|
|
283
|
-
// @ts-
|
|
283
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
284
284
|
onChange={(event) => setValue(event.target.value)}
|
|
285
285
|
options={options}
|
|
286
286
|
isMulti
|
|
@@ -302,7 +302,7 @@ export const MultiSelectCreatable = () => {
|
|
|
302
302
|
id="creatableMultiSelect"
|
|
303
303
|
label="Label"
|
|
304
304
|
value={value}
|
|
305
|
-
// @ts-
|
|
305
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
306
306
|
onChange={(event) => setValue(event.target.value)}
|
|
307
307
|
options={options}
|
|
308
308
|
isMulti
|
|
@@ -325,7 +325,7 @@ export const Autofocus = () => {
|
|
|
325
325
|
id="autoFocus"
|
|
326
326
|
label="Label"
|
|
327
327
|
value={value}
|
|
328
|
-
// @ts-
|
|
328
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
329
329
|
onChange={(event) => setValue(event.target.value)}
|
|
330
330
|
options={options}
|
|
331
331
|
autoFocus
|
|
@@ -347,7 +347,7 @@ export const Required = () => {
|
|
|
347
347
|
id="required"
|
|
348
348
|
label="Label"
|
|
349
349
|
value={value}
|
|
350
|
-
// @ts-
|
|
350
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
351
351
|
onChange={(event) => setValue(event.target.value)}
|
|
352
352
|
options={options}
|
|
353
353
|
isRequired
|
|
@@ -369,7 +369,7 @@ export const Disabled = () => {
|
|
|
369
369
|
id="disabled"
|
|
370
370
|
label="Label"
|
|
371
371
|
value={value}
|
|
372
|
-
// @ts-
|
|
372
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
373
373
|
onChange={(event) => setValue(event.target.value)}
|
|
374
374
|
options={options}
|
|
375
375
|
isDisabled
|
|
@@ -392,7 +392,7 @@ export const Clearable = () => {
|
|
|
392
392
|
label="Label"
|
|
393
393
|
value={value}
|
|
394
394
|
name="myClearableSelect"
|
|
395
|
-
// @ts-
|
|
395
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
396
396
|
onChange={(event) => setValue(event.target.value)}
|
|
397
397
|
options={options}
|
|
398
398
|
isClearable
|
|
@@ -414,7 +414,7 @@ export const Error = () => {
|
|
|
414
414
|
id="error"
|
|
415
415
|
label="Label"
|
|
416
416
|
value={value}
|
|
417
|
-
// @ts-
|
|
417
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
418
418
|
onChange={(event) => setValue(event.target.value)}
|
|
419
419
|
options={options}
|
|
420
420
|
isRequired
|
|
@@ -439,7 +439,7 @@ export const Sizes = () => {
|
|
|
439
439
|
<SelectInput
|
|
440
440
|
id="smallSelect"
|
|
441
441
|
label="Small"
|
|
442
|
-
// @ts-
|
|
442
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
443
443
|
onChange={(event) => setValue(event.target.value)}
|
|
444
444
|
options={options}
|
|
445
445
|
value={value}
|
|
@@ -448,7 +448,7 @@ export const Sizes = () => {
|
|
|
448
448
|
<SelectInput
|
|
449
449
|
id="mediumSelect"
|
|
450
450
|
label="Medium"
|
|
451
|
-
// @ts-
|
|
451
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
452
452
|
onChange={(event) => setValue1(event.target.value)}
|
|
453
453
|
options={options}
|
|
454
454
|
value={value1}
|
|
@@ -457,7 +457,7 @@ export const Sizes = () => {
|
|
|
457
457
|
<SelectInput
|
|
458
458
|
id="largeSelect"
|
|
459
459
|
label="Large"
|
|
460
|
-
// @ts-
|
|
460
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
461
461
|
onChange={(event) => setValue2(event.target.value)}
|
|
462
462
|
options={options}
|
|
463
463
|
value={value2}
|
|
@@ -466,7 +466,7 @@ export const Sizes = () => {
|
|
|
466
466
|
<SelectInput
|
|
467
467
|
id="responsiveSelect"
|
|
468
468
|
label="Responsive"
|
|
469
|
-
// @ts-
|
|
469
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
470
470
|
onChange={(event) => setValue3(event.target.value)}
|
|
471
471
|
options={options}
|
|
472
472
|
value={value3}
|
|
@@ -488,7 +488,7 @@ export const WithPortal = () => {
|
|
|
488
488
|
id="portal"
|
|
489
489
|
label="Flavors"
|
|
490
490
|
value={value}
|
|
491
|
-
// @ts-
|
|
491
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
492
492
|
onChange={(event) => setValue(event.target.value)}
|
|
493
493
|
options={options}
|
|
494
494
|
menuPortalTarget={document.body}
|
|
@@ -509,7 +509,7 @@ export const CustomClasses = () => {
|
|
|
509
509
|
id="customClasses"
|
|
510
510
|
label="Label"
|
|
511
511
|
value={value}
|
|
512
|
-
// @ts-
|
|
512
|
+
// @ts-expect-error - TS is not recognizing the value as a valid option
|
|
513
513
|
onChange={(event) => setValue(event.target.value)}
|
|
514
514
|
options={options}
|
|
515
515
|
className="background-color-primary"
|
|
@@ -18,17 +18,21 @@ import { InputValidationMessage } from '../InputValidationMessage/InputValidatio
|
|
|
18
18
|
import styles from './SelectInput.module.scss';
|
|
19
19
|
import { GroupBase } from 'react-select/dist/declarations/src/types';
|
|
20
20
|
|
|
21
|
-
type
|
|
22
|
-
|
|
21
|
+
type SelectOption = {
|
|
22
|
+
value: string;
|
|
23
|
+
label: ReactNode;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
type SelectGroupOptions = GroupBase<SelectOption>;
|
|
23
27
|
export type SelectInputOptions = OptionsOrGroups<
|
|
24
|
-
|
|
28
|
+
SelectOption,
|
|
25
29
|
SelectGroupOptions
|
|
26
30
|
>;
|
|
27
31
|
|
|
28
32
|
export type SimulatedEventPayloadType = {
|
|
29
33
|
target: {
|
|
30
34
|
name: string;
|
|
31
|
-
value: OnChangeValue<
|
|
35
|
+
value: OnChangeValue<SelectOption, boolean>;
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
|
|
@@ -141,7 +145,9 @@ export interface SelectInputProps {
|
|
|
141
145
|
[x: string]: any; // eslint-disable-line
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
type AsyncOptions = (
|
|
148
|
+
type AsyncOptions = (
|
|
149
|
+
inputValue: string
|
|
150
|
+
) => Promise<OptionsOrGroups<SelectOption, SelectGroupOptions>>;
|
|
145
151
|
type AsyncSelectInputProps = SelectInputProps & {
|
|
146
152
|
/**
|
|
147
153
|
* Load the input asynchronously.
|
|
@@ -202,7 +208,7 @@ export function SelectInput(props: SelectInputProps): JSX.Element {
|
|
|
202
208
|
...restProps
|
|
203
209
|
} = props;
|
|
204
210
|
|
|
205
|
-
const handleChange = (values: OnChangeValue<
|
|
211
|
+
const handleChange = (values: OnChangeValue<SelectOption, boolean>) => {
|
|
206
212
|
const simulatedEventPayloadType: SimulatedEventPayloadType = {
|
|
207
213
|
target: {
|
|
208
214
|
name,
|
|
@@ -245,9 +251,7 @@ export function SelectInput(props: SelectInputProps): JSX.Element {
|
|
|
245
251
|
};
|
|
246
252
|
|
|
247
253
|
const ClearIndicator = (
|
|
248
|
-
props: ClearIndicatorProps<
|
|
249
|
-
OptionsOrGroups<SelectOptions, SelectGroupOptions>
|
|
250
|
-
>
|
|
254
|
+
props: ClearIndicatorProps<SelectOption, boolean, SelectGroupOptions>
|
|
251
255
|
) => (
|
|
252
256
|
<components.ClearIndicator {...props}>
|
|
253
257
|
<Icon name="remove" />
|
|
@@ -340,12 +340,16 @@ interface NavItem {
|
|
|
340
340
|
}[];
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
type Team = {
|
|
344
|
+
name: string;
|
|
345
|
+
};
|
|
346
|
+
|
|
343
347
|
const NavHeader = ({
|
|
344
348
|
activeTeam,
|
|
345
349
|
setActiveTeam,
|
|
346
350
|
}: {
|
|
347
|
-
activeTeam:
|
|
348
|
-
setActiveTeam: (team:
|
|
351
|
+
activeTeam: Team;
|
|
352
|
+
setActiveTeam: (team: Team) => void;
|
|
349
353
|
}) => {
|
|
350
354
|
const { state, isMobile } = useSidebar();
|
|
351
355
|
|
|
@@ -645,8 +649,8 @@ const OrgSwitcher = ({
|
|
|
645
649
|
activeTeam,
|
|
646
650
|
setActiveTeam,
|
|
647
651
|
}: {
|
|
648
|
-
activeTeam:
|
|
649
|
-
setActiveTeam: (team:
|
|
652
|
+
activeTeam: Team;
|
|
653
|
+
setActiveTeam: (team: Team) => void;
|
|
650
654
|
}) => {
|
|
651
655
|
const { state } = useSidebar();
|
|
652
656
|
|
|
@@ -139,10 +139,13 @@ describe('Sidebar', () => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
test.each([
|
|
142
|
-
['input', <input aria-label="input-field" />],
|
|
143
|
-
['textarea', <textarea aria-label="textarea-field" />],
|
|
144
|
-
['select', <select aria-label="select-field" />],
|
|
145
|
-
[
|
|
142
|
+
['input', <input aria-label="input-field" key="input" />],
|
|
143
|
+
['textarea', <textarea aria-label="textarea-field" key="textarea" />],
|
|
144
|
+
['select', <select aria-label="select-field" key="select" />],
|
|
145
|
+
[
|
|
146
|
+
'contenteditable',
|
|
147
|
+
<div aria-label="editable-field" contentEditable key="contenteditable" />,
|
|
148
|
+
],
|
|
146
149
|
])('ignores keyboard shortcuts for %s elements', (label, field) => {
|
|
147
150
|
render(
|
|
148
151
|
<SidebarProvider>
|
|
@@ -198,8 +198,12 @@ const useSidebarSideState = ({
|
|
|
198
198
|
|
|
199
199
|
const toggleSidebar = useCallback(() => {
|
|
200
200
|
lastToggledSideRef.current = side;
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
if (isMobile) {
|
|
202
|
+
setOpenMobile((value) => !value);
|
|
203
|
+
} else {
|
|
204
|
+
setOpen((value) => !value);
|
|
205
|
+
}
|
|
206
|
+
}, [isMobile, setOpen, side, setOpenMobile, lastToggledSideRef]);
|
|
203
207
|
|
|
204
208
|
const state = open ? 'expanded' : 'collapsed';
|
|
205
209
|
|
|
@@ -640,12 +644,11 @@ const SidebarMenuButton = React.forwardRef<
|
|
|
640
644
|
React.ComponentProps<'button'> & {
|
|
641
645
|
asChild?: boolean;
|
|
642
646
|
isActive?: boolean;
|
|
643
|
-
icon?: IconName;
|
|
644
647
|
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
645
648
|
}
|
|
646
649
|
>(
|
|
647
650
|
(
|
|
648
|
-
{ asChild = false, isActive = false,
|
|
651
|
+
{ asChild = false, isActive = false, tooltip, className, ...props },
|
|
649
652
|
ref
|
|
650
653
|
) => {
|
|
651
654
|
const Comp = asChild ? Slot : 'button';
|
|
@@ -3,7 +3,12 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
import { Table } from './Table';
|
|
4
4
|
import { Button } from '../Button/Button';
|
|
5
5
|
import { Badge } from '../Badge/Badge';
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
Column as ColumnType,
|
|
8
|
+
Cell,
|
|
9
|
+
Row,
|
|
10
|
+
EventWithColumnKey,
|
|
11
|
+
} from '../../types';
|
|
7
12
|
|
|
8
13
|
const meta: Meta<typeof Table> = {
|
|
9
14
|
title: 'Components/Table',
|
|
@@ -12,6 +17,13 @@ const meta: Meta<typeof Table> = {
|
|
|
12
17
|
|
|
13
18
|
export default meta;
|
|
14
19
|
|
|
20
|
+
type SortDirection = 'ascending' | 'descending';
|
|
21
|
+
type SortedColumn = {
|
|
22
|
+
dataKey?: string;
|
|
23
|
+
sortDirection?: SortDirection;
|
|
24
|
+
};
|
|
25
|
+
type SortableRow = Record<string, string | number>;
|
|
26
|
+
|
|
15
27
|
export const Column = () =>
|
|
16
28
|
(() => {
|
|
17
29
|
const codePreviewStyle = {
|
|
@@ -94,7 +106,7 @@ export const Column = () =>
|
|
|
94
106
|
{
|
|
95
107
|
heading: 'Type',
|
|
96
108
|
dataKey: 'type',
|
|
97
|
-
render: (cell:
|
|
109
|
+
render: (cell: string) => <code style={codePreviewStyle}>{cell}</code>,
|
|
98
110
|
},
|
|
99
111
|
{ heading: 'Description', dataKey: 'description' },
|
|
100
112
|
];
|
|
@@ -109,12 +121,15 @@ export const CommonExample = () =>
|
|
|
109
121
|
{
|
|
110
122
|
heading: 'Customer',
|
|
111
123
|
dataKey: 'customerInfo',
|
|
112
|
-
render: (_cell
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<div
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
render: (_cell?: Cell, row?: Row) => {
|
|
125
|
+
const customerRow = row as { name?: string; email?: string } | undefined;
|
|
126
|
+
return (
|
|
127
|
+
<div>
|
|
128
|
+
<div>{customerRow?.name}</div>
|
|
129
|
+
<div className="font-color-base">{customerRow?.email}</div>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
118
133
|
},
|
|
119
134
|
{ heading: 'Phone', dataKey: 'phone', width: 125 },
|
|
120
135
|
{ heading: 'Plan', dataKey: 'plan', width: 125 },
|
|
@@ -164,31 +179,37 @@ export const Loading = () =>
|
|
|
164
179
|
})();
|
|
165
180
|
|
|
166
181
|
export const Sortable = () => {
|
|
167
|
-
|
|
168
|
-
const sortDescending = (arrOfObj, key) =>
|
|
182
|
+
const sortDescending = (arrOfObj: SortableRow[], key: string) =>
|
|
169
183
|
[...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
|
|
170
|
-
|
|
171
|
-
const sortAscending = (arrOfObj, key) =>
|
|
184
|
+
const sortAscending = (arrOfObj: SortableRow[], key: string) =>
|
|
172
185
|
[...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
|
|
173
|
-
const getNewSortDirection = (
|
|
186
|
+
const getNewSortDirection = (
|
|
187
|
+
sortedKey: string,
|
|
188
|
+
currentSortedColumn: SortedColumn
|
|
189
|
+
) => {
|
|
174
190
|
if (
|
|
175
|
-
|
|
191
|
+
sortedKey === currentSortedColumn.dataKey &&
|
|
176
192
|
currentSortedColumn.sortDirection === 'ascending'
|
|
177
193
|
)
|
|
178
194
|
return 'descending';
|
|
179
195
|
return 'ascending';
|
|
180
196
|
};
|
|
181
|
-
const initialData = [
|
|
197
|
+
const initialData: SortableRow[] = [
|
|
182
198
|
{ id: 1, color: 'red', flavor: 'vanilla' },
|
|
183
199
|
{ id: 2, color: 'green', flavor: 'strawberry' },
|
|
184
200
|
{ id: 3, color: 'blue', flavor: 'chocolate' },
|
|
185
201
|
];
|
|
186
|
-
const [sortedColumn, setSortedColumn] = useState<
|
|
187
|
-
const [tableData, setTableData] = useState(initialData);
|
|
188
|
-
const handleSort = (event:
|
|
189
|
-
const
|
|
202
|
+
const [sortedColumn, setSortedColumn] = useState<SortedColumn>({});
|
|
203
|
+
const [tableData, setTableData] = useState<SortableRow[]>(initialData);
|
|
204
|
+
const handleSort = (event: EventWithColumnKey) => {
|
|
205
|
+
const sortedKey =
|
|
206
|
+
typeof event.sortedKey === 'string' ? event.sortedKey : undefined;
|
|
207
|
+
if (!sortedKey) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const newSortDirection = getNewSortDirection(sortedKey, sortedColumn);
|
|
190
211
|
setSortedColumn({
|
|
191
|
-
dataKey:
|
|
212
|
+
dataKey: sortedKey,
|
|
192
213
|
sortDirection: newSortDirection,
|
|
193
214
|
});
|
|
194
215
|
};
|
|
@@ -218,38 +239,45 @@ export const Sortable = () => {
|
|
|
218
239
|
};
|
|
219
240
|
|
|
220
241
|
export const SortablewithDefaultSortedColumn = () => {
|
|
221
|
-
|
|
222
|
-
const sortDescending = (arrOfObj, key) =>
|
|
242
|
+
const sortDescending = (arrOfObj: SortableRow[], key: string) =>
|
|
223
243
|
[...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
|
|
224
|
-
|
|
225
|
-
const sortAscending = (arrOfObj, key) =>
|
|
244
|
+
const sortAscending = (arrOfObj: SortableRow[], key: string) =>
|
|
226
245
|
[...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
|
|
227
|
-
const getNewSortDirection = (
|
|
246
|
+
const getNewSortDirection = (
|
|
247
|
+
sortedKey: string,
|
|
248
|
+
currentSortedColumn: SortedColumn
|
|
249
|
+
) => {
|
|
228
250
|
if (
|
|
229
|
-
|
|
251
|
+
sortedKey === currentSortedColumn.dataKey &&
|
|
230
252
|
currentSortedColumn.sortDirection === 'ascending'
|
|
231
253
|
)
|
|
232
254
|
return 'descending';
|
|
233
255
|
return 'ascending';
|
|
234
256
|
};
|
|
235
|
-
const initialData = [
|
|
257
|
+
const initialData: SortableRow[] = [
|
|
236
258
|
{ id: 1, color: 'red', flavor: 'vanilla' },
|
|
237
259
|
{ id: 2, color: 'green', flavor: 'strawberry' },
|
|
238
260
|
{ id: 3, color: 'blue', flavor: 'chocolate' },
|
|
239
261
|
];
|
|
240
|
-
const [sortedColumn, setSortedColumn] = useState<
|
|
262
|
+
const [sortedColumn, setSortedColumn] = useState<SortedColumn>({
|
|
241
263
|
dataKey: 'color',
|
|
242
264
|
sortDirection: 'descending',
|
|
243
265
|
});
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
266
|
+
const initialSortKey = sortedColumn.dataKey ?? 'color';
|
|
267
|
+
const [tableData, setTableData] = useState<SortableRow[]>([
|
|
268
|
+
...(sortedColumn.sortDirection === 'ascending'
|
|
269
|
+
? sortAscending(initialData, initialSortKey)
|
|
270
|
+
: sortDescending(initialData, initialSortKey)),
|
|
248
271
|
]);
|
|
249
|
-
const handleSort = (event:
|
|
250
|
-
const
|
|
272
|
+
const handleSort = (event: EventWithColumnKey) => {
|
|
273
|
+
const sortedKey =
|
|
274
|
+
typeof event.sortedKey === 'string' ? event.sortedKey : undefined;
|
|
275
|
+
if (!sortedKey) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const newSortDirection = getNewSortDirection(sortedKey, sortedColumn);
|
|
251
279
|
setSortedColumn({
|
|
252
|
-
dataKey:
|
|
280
|
+
dataKey: sortedKey,
|
|
253
281
|
sortDirection: newSortDirection,
|
|
254
282
|
});
|
|
255
283
|
};
|
|
@@ -279,31 +307,37 @@ export const SortablewithDefaultSortedColumn = () => {
|
|
|
279
307
|
};
|
|
280
308
|
|
|
281
309
|
export const SortableAndLoading = () => {
|
|
282
|
-
|
|
283
|
-
const sortDescending = (arrOfObj, key) =>
|
|
310
|
+
const sortDescending = (arrOfObj: SortableRow[], key: string) =>
|
|
284
311
|
[...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
|
|
285
|
-
|
|
286
|
-
const sortAscending = (arrOfObj, key) =>
|
|
312
|
+
const sortAscending = (arrOfObj: SortableRow[], key: string) =>
|
|
287
313
|
[...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
|
|
288
|
-
const getNewSortDirection = (
|
|
314
|
+
const getNewSortDirection = (
|
|
315
|
+
sortedKey: string,
|
|
316
|
+
currentSortedColumn: SortedColumn
|
|
317
|
+
) => {
|
|
289
318
|
if (
|
|
290
|
-
|
|
319
|
+
sortedKey === currentSortedColumn.dataKey &&
|
|
291
320
|
currentSortedColumn.sortDirection === 'ascending'
|
|
292
321
|
)
|
|
293
322
|
return 'descending';
|
|
294
323
|
return 'ascending';
|
|
295
324
|
};
|
|
296
|
-
const initialData = [
|
|
325
|
+
const initialData: SortableRow[] = [
|
|
297
326
|
{ id: 1, color: 'red', flavor: 'vanilla' },
|
|
298
327
|
{ id: 2, color: 'green', flavor: 'strawberry' },
|
|
299
328
|
{ id: 3, color: 'blue', flavor: 'chocolate' },
|
|
300
329
|
];
|
|
301
|
-
const [sortedColumn, setSortedColumn] = useState<
|
|
302
|
-
const [tableData, setTableData] = useState(initialData);
|
|
303
|
-
const handleSort = (event:
|
|
304
|
-
const
|
|
330
|
+
const [sortedColumn, setSortedColumn] = useState<SortedColumn>({});
|
|
331
|
+
const [tableData, setTableData] = useState<SortableRow[]>(initialData);
|
|
332
|
+
const handleSort = (event: EventWithColumnKey) => {
|
|
333
|
+
const sortedKey =
|
|
334
|
+
typeof event.sortedKey === 'string' ? event.sortedKey : undefined;
|
|
335
|
+
if (!sortedKey) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const newSortDirection = getNewSortDirection(sortedKey, sortedColumn);
|
|
305
339
|
setSortedColumn({
|
|
306
|
-
dataKey:
|
|
340
|
+
dataKey: sortedKey,
|
|
307
341
|
sortDirection: newSortDirection,
|
|
308
342
|
});
|
|
309
343
|
};
|
|
@@ -652,13 +686,25 @@ export const TruncateOverflow = () =>
|
|
|
652
686
|
|
|
653
687
|
export const CustomActions = () =>
|
|
654
688
|
(() => {
|
|
655
|
-
const renderFlavor = (cell
|
|
656
|
-
const
|
|
689
|
+
const renderFlavor = (cell?: Cell, row?: Row, index?: number) => {
|
|
690
|
+
const flavorCell = cell as { href?: string; name?: string } | undefined;
|
|
691
|
+
const flavorRow = row as { id?: number } | undefined;
|
|
692
|
+
const rows = [
|
|
693
|
+
{
|
|
694
|
+
href: flavorCell?.href ?? '',
|
|
695
|
+
name: flavorCell?.name ?? '',
|
|
696
|
+
id: flavorRow?.id ?? 0,
|
|
697
|
+
index,
|
|
698
|
+
},
|
|
699
|
+
];
|
|
657
700
|
const columns = [
|
|
658
701
|
{
|
|
659
702
|
heading: 'Url',
|
|
660
703
|
dataKey: 'href',
|
|
661
|
-
render: (cell
|
|
704
|
+
render: (cell?: Cell) => {
|
|
705
|
+
const href = typeof cell === 'string' ? cell : '';
|
|
706
|
+
return <a href={href}>{href}</a>;
|
|
707
|
+
},
|
|
662
708
|
},
|
|
663
709
|
{ heading: 'Name', dataKey: 'name' },
|
|
664
710
|
{ heading: 'ID', dataKey: 'id' },
|
|
@@ -672,7 +718,6 @@ export const CustomActions = () =>
|
|
|
672
718
|
{
|
|
673
719
|
heading: 'Based on the cell/row',
|
|
674
720
|
dataKey: 'flavor',
|
|
675
|
-
// @ts-ignore
|
|
676
721
|
render: renderFlavor,
|
|
677
722
|
},
|
|
678
723
|
{ heading: 'Any custom JSX', render: () => <Button>Do anything</Button> },
|
|
@@ -706,7 +751,12 @@ export const EmptyCellPlaceholder = () =>
|
|
|
706
751
|
{
|
|
707
752
|
heading: 'Price',
|
|
708
753
|
dataKey: 'price',
|
|
709
|
-
render: (cell
|
|
754
|
+
render: (cell?: Cell) => {
|
|
755
|
+
if (typeof cell === 'number' || typeof cell === 'string') {
|
|
756
|
+
return cell ? `$${cell}` : null;
|
|
757
|
+
}
|
|
758
|
+
return null;
|
|
759
|
+
},
|
|
710
760
|
emptyCellPlaceholder: '$0.00',
|
|
711
761
|
},
|
|
712
762
|
];
|