@hyphen/hyphen-components 2.9.0
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/LICENSE +21 -0
- package/README.md +70 -0
- package/package.json +138 -0
- package/src/components/Alert/Alert.constants.ts +19 -0
- package/src/components/Alert/Alert.mdx +29 -0
- package/src/components/Alert/Alert.module.scss +74 -0
- package/src/components/Alert/Alert.stories.tsx +102 -0
- package/src/components/Alert/Alert.test.tsx +187 -0
- package/src/components/Alert/Alert.tsx +157 -0
- package/src/components/Alert/Alert.types.ts +14 -0
- package/src/components/Badge/Badge.mdx +28 -0
- package/src/components/Badge/Badge.module.scss +155 -0
- package/src/components/Badge/Badge.stories.tsx +52 -0
- package/src/components/Badge/Badge.test.tsx +74 -0
- package/src/components/Badge/Badge.tsx +70 -0
- package/src/components/Box/Box.mdx +259 -0
- package/src/components/Box/Box.module.scss +16 -0
- package/src/components/Box/Box.stories.tsx +1679 -0
- package/src/components/Box/Box.test.tsx +478 -0
- package/src/components/Box/Box.tsx +636 -0
- package/src/components/Button/Button.constants.ts +10 -0
- package/src/components/Button/Button.mdx +71 -0
- package/src/components/Button/Button.module.scss +312 -0
- package/src/components/Button/Button.stories.tsx +117 -0
- package/src/components/Button/Button.test.tsx +460 -0
- package/src/components/Button/Button.tsx +241 -0
- package/src/components/Card/Card.mdx +46 -0
- package/src/components/Card/Card.module.scss +6 -0
- package/src/components/Card/Card.stories.tsx +101 -0
- package/src/components/Card/Card.test.tsx +11 -0
- package/src/components/Card/Card.tsx +61 -0
- package/src/components/Card/components/CardFooter/CardFooter.test.tsx +11 -0
- package/src/components/Card/components/CardFooter/CardFooter.tsx +35 -0
- package/src/components/Card/components/CardHeader/CardHeader.test.tsx +23 -0
- package/src/components/Card/components/CardHeader/CardHeader.tsx +54 -0
- package/src/components/Card/components/CardSection/CardSection.test.tsx +28 -0
- package/src/components/Card/components/CardSection/CardSection.tsx +102 -0
- package/src/components/Card/components/index.ts +3 -0
- package/src/components/CheckboxInput/CheckboxInput.mdx +98 -0
- package/src/components/CheckboxInput/CheckboxInput.stories.tsx +254 -0
- package/src/components/CheckboxInput/CheckboxInput.test.tsx +436 -0
- package/src/components/CheckboxInput/CheckboxInput.tsx +171 -0
- package/src/components/CheckboxInput/components/Checkbox.module.scss +174 -0
- package/src/components/CheckboxInput/components/Checkbox.test.tsx +201 -0
- package/src/components/CheckboxInput/components/Checkbox.tsx +176 -0
- package/src/components/CheckboxInput/components/CheckboxIcon.tsx +71 -0
- package/src/components/DateInput/DateInput.mdx +61 -0
- package/src/components/DateInput/DateInput.stories.tsx +168 -0
- package/src/components/DateInput/DateInput.test.tsx +258 -0
- package/src/components/DateInput/DateInput.tsx +189 -0
- package/src/components/DatePicker/DatePicker.mdx +52 -0
- package/src/components/DatePicker/DatePicker.module.scss +603 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +199 -0
- package/src/components/DatePicker/DatePicker.test.tsx +26 -0
- package/src/components/DatePicker/DatePicker.tsx +138 -0
- package/src/components/Details/Details.mdx +30 -0
- package/src/components/Details/Details.module.scss +32 -0
- package/src/components/Details/Details.stories.tsx +38 -0
- package/src/components/Details/Details.test.tsx +189 -0
- package/src/components/Details/Details.tsx +51 -0
- package/src/components/Details/DetailsSummary.tsx +65 -0
- package/src/components/Drawer/Drawer.mdx +117 -0
- package/src/components/Drawer/Drawer.module.scss +96 -0
- package/src/components/Drawer/Drawer.stories.tsx +380 -0
- package/src/components/Drawer/Drawer.test.tsx +90 -0
- package/src/components/Drawer/Drawer.tsx +249 -0
- package/src/components/FormControl/FormControl.tsx +78 -0
- package/src/components/FormLabel/FormLabel.mdx +24 -0
- package/src/components/FormLabel/FormLabel.module.scss +19 -0
- package/src/components/FormLabel/FormLabel.stories.tsx +20 -0
- package/src/components/FormLabel/FormLabel.test.tsx +35 -0
- package/src/components/FormLabel/FormLabel.tsx +96 -0
- package/src/components/Formik/Formik.mdx +10 -0
- package/src/components/Formik/Formik.stories.tsx +307 -0
- package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.test.tsx +172 -0
- package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.tsx +41 -0
- package/src/components/Formik/FormikRadioGroup/FormikRadioGroup.test.tsx +205 -0
- package/src/components/Formik/FormikRadioGroup/FormikRadioGroup.tsx +37 -0
- package/src/components/Formik/FormikSelectInput/FormikSelectInput.test.tsx +210 -0
- package/src/components/Formik/FormikSelectInput/FormikSelectInput.tsx +41 -0
- package/src/components/Formik/FormikSelectInputInset/FormikSelectInputInset.test.tsx +153 -0
- package/src/components/Formik/FormikSelectInputInset/FormikSelectInputInset.tsx +44 -0
- package/src/components/Formik/FormikSelectInputNative/FormikSelectInputNative.test.tsx +161 -0
- package/src/components/Formik/FormikSelectInputNative/FormikSelectInputNative.tsx +46 -0
- package/src/components/Formik/FormikTextInput/FormikTextInput.test.tsx +176 -0
- package/src/components/Formik/FormikTextInput/FormikTextInput.tsx +38 -0
- package/src/components/Formik/FormikTextInputInset/FormikTextInputInset.test.tsx +170 -0
- package/src/components/Formik/FormikTextInputInset/FormikTextInputInset.tsx +42 -0
- package/src/components/Formik/FormikTextareaInput/FormikTextareaInput.test.tsx +186 -0
- package/src/components/Formik/FormikTextareaInput/FormikTextareaInput.tsx +42 -0
- package/src/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.test.tsx +179 -0
- package/src/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.tsx +42 -0
- package/src/components/Formik/FormikTimePicker/FormikTimePicker.test.tsx +224 -0
- package/src/components/Formik/FormikTimePicker/FormikTimePicker.tsx +37 -0
- package/src/components/Formik/FormikTimePickerNative/FormikTimePickerNative.test.tsx +175 -0
- package/src/components/Formik/FormikTimePickerNative/FormikTimePickerNative.tsx +38 -0
- package/src/components/Formik/FormikToggle/FormikToggle.test.tsx +172 -0
- package/src/components/Formik/FormikToggle/FormikToggle.tsx +38 -0
- package/src/components/Heading/Heading.constants.ts +19 -0
- package/src/components/Heading/Heading.mdx +35 -0
- package/src/components/Heading/Heading.module.scss +5 -0
- package/src/components/Heading/Heading.stories.tsx +90 -0
- package/src/components/Heading/Heading.test.tsx +67 -0
- package/src/components/Heading/Heading.tsx +67 -0
- package/src/components/HelpText/HelpText.module.scss +14 -0
- package/src/components/HelpText/HelpText.tsx +33 -0
- package/src/components/Icon/Icon.mdx +40 -0
- package/src/components/Icon/Icon.stories.tsx +72 -0
- package/src/components/Icon/Icon.test.tsx +30 -0
- package/src/components/Icon/Icon.tsx +61 -0
- package/src/components/InputValidationMessage/InputValidationMessage.module.scss +3 -0
- package/src/components/InputValidationMessage/InputValidationMessage.tsx +27 -0
- package/src/components/Modal/Modal.mdx +60 -0
- package/src/components/Modal/Modal.module.scss +135 -0
- package/src/components/Modal/Modal.stories.tsx +194 -0
- package/src/components/Modal/Modal.test.tsx +81 -0
- package/src/components/Modal/Modal.tsx +174 -0
- package/src/components/Modal/components/ModalBody/ModalBody.test.tsx +20 -0
- package/src/components/Modal/components/ModalBody/ModalBody.tsx +24 -0
- package/src/components/Modal/components/ModalFooter/ModalFooter.test.tsx +32 -0
- package/src/components/Modal/components/ModalFooter/ModalFooter.tsx +37 -0
- package/src/components/Modal/components/ModalHeader/ModalHeader.test.tsx +29 -0
- package/src/components/Modal/components/ModalHeader/ModalHeader.tsx +58 -0
- package/src/components/Modal/components/index.ts +5 -0
- package/src/components/Pagination/Pagination.mdx +26 -0
- package/src/components/Pagination/Pagination.stories.tsx +55 -0
- package/src/components/Pagination/Pagination.test.tsx +225 -0
- package/src/components/Pagination/Pagination.tsx +162 -0
- package/src/components/Pagination/Pagination.utilities.test.ts +133 -0
- package/src/components/Pagination/Pagination.utilities.ts +101 -0
- package/src/components/Popover/Popover.mdx +104 -0
- package/src/components/Popover/Popover.module.scss +74 -0
- package/src/components/Popover/Popover.stories.tsx +471 -0
- package/src/components/Popover/Popover.test.tsx +128 -0
- package/src/components/Popover/Popover.tsx +277 -0
- package/src/components/RadioGroup/RadioGroup.mdx +81 -0
- package/src/components/RadioGroup/RadioGroup.module.scss +23 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +375 -0
- package/src/components/RadioGroup/RadioGroup.test.tsx +282 -0
- package/src/components/RadioGroup/RadioGroup.tsx +145 -0
- package/src/components/RadioGroup/RadioInput/RadioInput.module.scss +114 -0
- package/src/components/RadioGroup/RadioInput/RadioInput.test.tsx +156 -0
- package/src/components/RadioGroup/RadioInput/RadioInput.tsx +148 -0
- package/src/components/RadioGroup/RadioInput/RadioInputIcon.tsx +59 -0
- package/src/components/ResponsiveProvider/ResponsiveProvider.mdx +36 -0
- package/src/components/ResponsiveProvider/ResponsiveProvider.stories.tsx +54 -0
- package/src/components/ResponsiveProvider/ResponsiveProvider.test.tsx +70 -0
- package/src/components/ResponsiveProvider/ResponsiveProvider.tsx +73 -0
- package/src/components/SelectInput/SelectInput.mdx +115 -0
- package/src/components/SelectInput/SelectInput.module.scss +357 -0
- package/src/components/SelectInput/SelectInput.stories.tsx +373 -0
- package/src/components/SelectInput/SelectInput.test.tsx +403 -0
- package/src/components/SelectInput/SelectInput.tsx +245 -0
- package/src/components/SelectInputInset/SelectInputInset.mdx +56 -0
- package/src/components/SelectInputInset/SelectInputInset.module.scss +397 -0
- package/src/components/SelectInputInset/SelectInputInset.stories.tsx +189 -0
- package/src/components/SelectInputInset/SelectInputInset.test.tsx +305 -0
- package/src/components/SelectInputInset/SelectInputInset.tsx +235 -0
- package/src/components/SelectInputNative/SelectInputNative.mdx +87 -0
- package/src/components/SelectInputNative/SelectInputNative.module.scss +356 -0
- package/src/components/SelectInputNative/SelectInputNative.stories.tsx +282 -0
- package/src/components/SelectInputNative/SelectInputNative.test.tsx +341 -0
- package/src/components/SelectInputNative/SelectInputNative.tsx +121 -0
- package/src/components/Spinner/Spinner.mdx +29 -0
- package/src/components/Spinner/Spinner.module.scss +16 -0
- package/src/components/Spinner/Spinner.stories.tsx +48 -0
- package/src/components/Spinner/Spinner.test.tsx +47 -0
- package/src/components/Spinner/Spinner.tsx +116 -0
- package/src/components/Table/Table.mdx +216 -0
- package/src/components/Table/Table.module.scss +61 -0
- package/src/components/Table/Table.stories.tsx +884 -0
- package/src/components/Table/Table.test.tsx +437 -0
- package/src/components/Table/Table.tsx +171 -0
- package/src/components/Table/TableBody/TableBody.module.scss +19 -0
- package/src/components/Table/TableBody/TableBody.test.tsx +38 -0
- package/src/components/Table/TableBody/TableBody.tsx +96 -0
- package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.module.scss +47 -0
- package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.test.tsx +81 -0
- package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.tsx +94 -0
- package/src/components/Table/TableHead/TableHead.test.tsx +20 -0
- package/src/components/Table/TableHead/TableHead.tsx +78 -0
- package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.module.scss +72 -0
- package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.test.tsx +187 -0
- package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.tsx +192 -0
- package/src/components/Table/common/TableRow/TableRow.module.scss +5 -0
- package/src/components/Table/common/TableRow/TableRow.test.tsx +52 -0
- package/src/components/Table/common/TableRow/TableRow.tsx +155 -0
- package/src/components/TextInput/TextInput.mdx +96 -0
- package/src/components/TextInput/TextInput.module.scss +405 -0
- package/src/components/TextInput/TextInput.stories.tsx +268 -0
- package/src/components/TextInput/TextInput.test.tsx +231 -0
- package/src/components/TextInput/TextInput.tsx +263 -0
- package/src/components/TextInputInset/TextInputInset.mdx +62 -0
- package/src/components/TextInputInset/TextInputInset.module.scss +418 -0
- package/src/components/TextInputInset/TextInputInset.stories.tsx +213 -0
- package/src/components/TextInputInset/TextInputInset.test.tsx +222 -0
- package/src/components/TextInputInset/TextInputInset.tsx +261 -0
- package/src/components/TextareaInput/TextareaInput.mdx +117 -0
- package/src/components/TextareaInput/TextareaInput.module.scss +275 -0
- package/src/components/TextareaInput/TextareaInput.stories.tsx +293 -0
- package/src/components/TextareaInput/TextareaInput.test.tsx +195 -0
- package/src/components/TextareaInput/TextareaInput.tsx +182 -0
- package/src/components/TextareaInputInset/TextareaInputInset.mdx +55 -0
- package/src/components/TextareaInputInset/TextareaInputInset.module.scss +337 -0
- package/src/components/TextareaInputInset/TextareaInputInset.stories.tsx +160 -0
- package/src/components/TextareaInputInset/TextareaInputInset.test.tsx +199 -0
- package/src/components/TextareaInputInset/TextareaInputInset.tsx +213 -0
- package/src/components/ThemeProvider/ThemeProvider.mdx +11 -0
- package/src/components/ThemeProvider/ThemeProvider.stories.tsx +56 -0
- package/src/components/ThemeProvider/ThemeProvider.tsx +75 -0
- package/src/components/TimePicker/TimePicker.mdx +75 -0
- package/src/components/TimePicker/TimePicker.stories.tsx +149 -0
- package/src/components/TimePicker/TimePicker.test.tsx +97 -0
- package/src/components/TimePicker/TimePicker.tsx +83 -0
- package/src/components/TimePickerNative/TimePickerNative.mdx +67 -0
- package/src/components/TimePickerNative/TimePickerNative.stories.tsx +151 -0
- package/src/components/TimePickerNative/TimePickerNative.test.tsx +117 -0
- package/src/components/TimePickerNative/TimePickerNative.tsx +93 -0
- package/src/components/Toast/Toast.mdx +134 -0
- package/src/components/Toast/Toast.store.ts +280 -0
- package/src/components/Toast/Toast.stories.tsx +283 -0
- package/src/components/Toast/Toast.test.tsx +784 -0
- package/src/components/Toast/Toast.types.ts +98 -0
- package/src/components/Toast/ToastContainer.tsx +170 -0
- package/src/components/Toast/ToastNotification.module.scss +63 -0
- package/src/components/Toast/ToastNotification.tsx +176 -0
- package/src/components/Toast/index.ts +4 -0
- package/src/components/Toast/toast.ts +102 -0
- package/src/components/Toast/useToasts.ts +102 -0
- package/src/components/Toggle/Toggle.mdx +51 -0
- package/src/components/Toggle/Toggle.module.scss +294 -0
- package/src/components/Toggle/Toggle.stories.tsx +128 -0
- package/src/components/Toggle/Toggle.test.tsx +308 -0
- package/src/components/Toggle/Toggle.tsx +184 -0
- package/src/constants/keyCodes.ts +2 -0
- package/src/docs/Brands.mdx +153 -0
- package/src/docs/Colors.mdx +158 -0
- package/src/docs/DesignTokens.mdx +415 -0
- package/src/docs/GetStarted.mdx +47 -0
- package/src/docs/intro.mdx +12 -0
- package/src/fonts/AvenirBold.otf +0 -0
- package/src/fonts/AvenirBold.woff +0 -0
- package/src/fonts/AvenirBold.woff2 +0 -0
- package/src/fonts/AvenirLight.otf +0 -0
- package/src/fonts/AvenirLight.woff +0 -0
- package/src/fonts/AvenirLight.woff2 +0 -0
- package/src/fonts/AvenirRegular.otf +0 -0
- package/src/fonts/AvenirRegular.woff +0 -0
- package/src/fonts/AvenirRegular.woff2 +0 -0
- package/src/fonts/Geist-Bold.otf +0 -0
- package/src/fonts/Geist-Bold.woff +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-Medium.otf +0 -0
- package/src/fonts/Geist-Medium.woff +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.otf +0 -0
- package/src/fonts/Geist-Regular.woff +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.otf +0 -0
- package/src/fonts/Geist-SemiBold.woff +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/GeistMono-Regular.otf +0 -0
- package/src/fonts/GeistMono-Regular.woff +0 -0
- package/src/fonts/GeistMono-Regular.woff2 +0 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useBreakpoint/useBreakpoint.mdx +26 -0
- package/src/hooks/useBreakpoint/useBreakpoint.stories.tsx +30 -0
- package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +19 -0
- package/src/hooks/useBreakpoint/useBreakpoint.ts +50 -0
- package/src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayouEffect.ts +5 -0
- package/src/hooks/useOpenClose/useOpenClose.mdx +15 -0
- package/src/hooks/useOpenClose/useOpenClose.stories.tsx +41 -0
- package/src/hooks/useOpenClose/useOpenClose.test.tsx +119 -0
- package/src/hooks/useOpenClose/useOpenClose.tsx +95 -0
- package/src/hooks/useWindowSize/useWindowSize.mdx +25 -0
- package/src/hooks/useWindowSize/useWindowSize.stories.tsx +35 -0
- package/src/hooks/useWindowSize/useWindowSize.ts +24 -0
- package/src/index.ts +48 -0
- package/src/lib/cssShorthandToClasses.test.ts +149 -0
- package/src/lib/cssShorthandToClasses.ts +133 -0
- package/src/lib/doesStringIncludeCssUnit.ts +6 -0
- package/src/lib/generateResponsiveClasses.test.ts +24 -0
- package/src/lib/generateResponsiveClasses.ts +30 -0
- package/src/lib/getAutoCompleteValue.test.ts +27 -0
- package/src/lib/getAutoCompleteValue.ts +12 -0
- package/src/lib/getColumnKeys.ts +27 -0
- package/src/lib/getDimensionCss.test.ts +148 -0
- package/src/lib/getDimensionCss.ts +73 -0
- package/src/lib/getElementType.test.tsx +42 -0
- package/src/lib/getElementType.ts +42 -0
- package/src/lib/getFlexCss.test.ts +122 -0
- package/src/lib/getFlexCss.ts +67 -0
- package/src/lib/index.ts +15 -0
- package/src/lib/isFunction.ts +6 -0
- package/src/lib/mergeRefs.ts +15 -0
- package/src/lib/prefersReducedMotion.ts +12 -0
- package/src/lib/react-children-utilities/filter.ts +12 -0
- package/src/lib/react-children-utilities/index.ts +1 -0
- package/src/lib/reactRouterClickHandler.ts +37 -0
- package/src/lib/resolveValue.ts +7 -0
- package/src/lib/tokens.ts +139 -0
- package/src/modes.ts +8 -0
- package/src/styles/animation.scss +152 -0
- package/src/styles/cursor.scss +43 -0
- package/src/styles/display.scss +119 -0
- package/src/styles/flex.scss +453 -0
- package/src/styles/fonts.scss +44 -0
- package/src/styles/globals/utilities.scss +4 -0
- package/src/styles/mixins.scss +14 -0
- package/src/styles/overflow.scss +41 -0
- package/src/styles/position.scss +45 -0
- package/src/styles/reset.scss +108 -0
- package/src/styles/text-align.scss +21 -0
- package/src/styles/utilities.scss +9 -0
- package/src/styles/variables/forms.scss +71 -0
- package/src/styles/variables/index.scss +3 -0
- package/src/styles/white-space.scss +21 -0
- package/src/types/index.ts +201 -0
- package/src/types/lib.types.ts +3 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import styles from './Spinner.module.scss';
|
|
4
|
+
|
|
5
|
+
export interface SpinnerProps {
|
|
6
|
+
/**
|
|
7
|
+
* Custom className to be applied to spinner container div element.
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Size of the spinner.
|
|
12
|
+
*/
|
|
13
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Spinner: FC<SpinnerProps> = ({ className, size = 'md' }) => {
|
|
17
|
+
const classes = classNames(className, styles.spinner);
|
|
18
|
+
|
|
19
|
+
const sizeInPixels = () => {
|
|
20
|
+
let pixels;
|
|
21
|
+
if (size === 'sm') pixels = '12';
|
|
22
|
+
if (size === 'md') pixels = '16';
|
|
23
|
+
if (size === 'lg') pixels = '24';
|
|
24
|
+
if (size === 'xl') pixels = '30';
|
|
25
|
+
|
|
26
|
+
return pixels;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<span className={classes}>
|
|
31
|
+
<svg
|
|
32
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
33
|
+
width={sizeInPixels()}
|
|
34
|
+
height={sizeInPixels()}
|
|
35
|
+
viewBox="0 0 16 16"
|
|
36
|
+
data-testid="spinner-testid"
|
|
37
|
+
>
|
|
38
|
+
<g fill="currentColor">
|
|
39
|
+
<rect
|
|
40
|
+
fill="currentColor"
|
|
41
|
+
height="2"
|
|
42
|
+
rx=".5"
|
|
43
|
+
width="4"
|
|
44
|
+
x="12"
|
|
45
|
+
y="7"
|
|
46
|
+
></rect>
|
|
47
|
+
<rect
|
|
48
|
+
fill="currentColor"
|
|
49
|
+
height="4.001"
|
|
50
|
+
rx=".5"
|
|
51
|
+
width="1.999"
|
|
52
|
+
opacity=".4"
|
|
53
|
+
x="11.243"
|
|
54
|
+
y="10.242"
|
|
55
|
+
transform="rotate(-44.975 12.243 12.243)"
|
|
56
|
+
></rect>
|
|
57
|
+
<rect
|
|
58
|
+
fill="currentColor"
|
|
59
|
+
height="4"
|
|
60
|
+
rx=".5"
|
|
61
|
+
width="2"
|
|
62
|
+
opacity=".4"
|
|
63
|
+
x="7"
|
|
64
|
+
y="12"
|
|
65
|
+
></rect>
|
|
66
|
+
<rect
|
|
67
|
+
fill="currentColor"
|
|
68
|
+
height="1.999"
|
|
69
|
+
rx=".5"
|
|
70
|
+
width="4.001"
|
|
71
|
+
opacity=".4"
|
|
72
|
+
x="1.757"
|
|
73
|
+
y="11.243"
|
|
74
|
+
transform="rotate(-45.03 3.757 12.242)"
|
|
75
|
+
></rect>
|
|
76
|
+
<rect
|
|
77
|
+
fill="currentColor"
|
|
78
|
+
height="2"
|
|
79
|
+
rx=".5"
|
|
80
|
+
width="4"
|
|
81
|
+
opacity=".4"
|
|
82
|
+
y="7"
|
|
83
|
+
></rect>
|
|
84
|
+
<rect
|
|
85
|
+
fill="currentColor"
|
|
86
|
+
height="4.001"
|
|
87
|
+
rx=".5"
|
|
88
|
+
width="1.999"
|
|
89
|
+
opacity=".4"
|
|
90
|
+
x="2.758"
|
|
91
|
+
y="1.757"
|
|
92
|
+
transform="rotate(-44.975 3.757 3.757)"
|
|
93
|
+
></rect>
|
|
94
|
+
<rect
|
|
95
|
+
fill="currentColor"
|
|
96
|
+
height="4"
|
|
97
|
+
rx=".5"
|
|
98
|
+
width="2"
|
|
99
|
+
opacity=".6"
|
|
100
|
+
x="7"
|
|
101
|
+
></rect>
|
|
102
|
+
<rect
|
|
103
|
+
fill="currentColor"
|
|
104
|
+
height="1.999"
|
|
105
|
+
rx=".5"
|
|
106
|
+
width="4.001"
|
|
107
|
+
opacity=".8"
|
|
108
|
+
x="10.242"
|
|
109
|
+
y="2.758"
|
|
110
|
+
transform="rotate(-45.03 12.242 3.757)"
|
|
111
|
+
></rect>
|
|
112
|
+
</g>
|
|
113
|
+
</svg>
|
|
114
|
+
</span>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Canvas, Meta, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import { Table } from './Table';
|
|
3
|
+
import * as Stories from './Table.stories';
|
|
4
|
+
|
|
5
|
+
<Meta of={Stories} />
|
|
6
|
+
|
|
7
|
+
# Table
|
|
8
|
+
|
|
9
|
+
Use tables to render datasets.
|
|
10
|
+
|
|
11
|
+
Tables display information in a way that’s easy to scan, while making it easy to interact with individual records in a data set.
|
|
12
|
+
|
|
13
|
+
Lastly use tables when you need the ability to sort, filter and/or paginate data.
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
<ArgTypes of={Table} />
|
|
18
|
+
|
|
19
|
+
## Column
|
|
20
|
+
|
|
21
|
+
The column object allows you to configure each table column header as well as some aspects about its underlying cells.
|
|
22
|
+
You will pass an array of columns to your table, where each column is an object with the following properties.
|
|
23
|
+
NOTE: all properties in a column object are optional, but we highly recommend including a `heading` in every column.
|
|
24
|
+
|
|
25
|
+
<Canvas of={Stories.Column} />
|
|
26
|
+
|
|
27
|
+
## Common Example
|
|
28
|
+
|
|
29
|
+
An example showcasing the props required to render a list of customers in a table. `rows` and `columns`.
|
|
30
|
+
|
|
31
|
+
<Canvas of={Stories.CommonExample} />
|
|
32
|
+
|
|
33
|
+
## Loading
|
|
34
|
+
|
|
35
|
+
Use the `isLoading` prop on the `<Table />` component to display an overlay that prevents user interaction. Useful for when
|
|
36
|
+
table data is being fetched or refreshed.
|
|
37
|
+
|
|
38
|
+
<Canvas of={Stories.Loading} />
|
|
39
|
+
|
|
40
|
+
## Sortable
|
|
41
|
+
|
|
42
|
+
Make table columns sortable by passing the `isSortable` prop as part of the `Column` that you'd like to sort.
|
|
43
|
+
Sorting is completely controlled outside of our library. The table will fire an `onSort` callback when a column is sorted,
|
|
44
|
+
which bubbles up the click or keyboard event, along with a `sortedKey` value. The `sortedKey` refers to the `dataKey` of the column
|
|
45
|
+
that was sorted. E.G: if user clicks to sort the `color` column, then `sortedKey = 'color'` in the sort event.
|
|
46
|
+
|
|
47
|
+
While sorting happens fully outside of the library, meaning that the Table expects sorted data to be passed correctly to it,
|
|
48
|
+
It does expect to know if a column is sorted so that it can update the UI accordingly. If you pass sorted data to the table,
|
|
49
|
+
include the `sortedColumn` prop which comprises the following attributes:
|
|
50
|
+
|
|
51
|
+
`dataKey: string mathching the column key,`
|
|
52
|
+
|
|
53
|
+
`sortDirection: oneOf: 'none', 'ascending', 'descending'`
|
|
54
|
+
|
|
55
|
+
<Canvas of={Stories.Sortable} />
|
|
56
|
+
|
|
57
|
+
## Sortable with Default Sorted Column
|
|
58
|
+
|
|
59
|
+
Having a column be sorted by default is no different than sorting a column, we pass the `sortedColumn` object as a prop on initial
|
|
60
|
+
render rather than only populating it upon user interaction.
|
|
61
|
+
|
|
62
|
+
<Canvas of={Stories.SortablewithDefaultSortedColumn} />
|
|
63
|
+
|
|
64
|
+
## Sortable and Loading
|
|
65
|
+
|
|
66
|
+
Setting the `isLoading` prop to true will disable clicking on the column headers. This prevents a race condition where an attempt to sort is made before data from the previous load is available.
|
|
67
|
+
|
|
68
|
+
<Canvas of={Stories.SortableAndLoading} />
|
|
69
|
+
|
|
70
|
+
## Scrollable
|
|
71
|
+
|
|
72
|
+
If you wish to lock your table into a particular `width` or `height` but render it fully (introducing scrolling) use the
|
|
73
|
+
`scroll` prop. It is an object with the keys:
|
|
74
|
+
|
|
75
|
+
`x: boolean,`
|
|
76
|
+
|
|
77
|
+
`y: boolean`.
|
|
78
|
+
|
|
79
|
+
Given this prop, the table will scroll horizontally, or verically basde on the width of its parent container.
|
|
80
|
+
Note, the table will use the standard `auto` HTML algorithm for sizing columns based on their content, unless a column
|
|
81
|
+
is given a specific width. In the example below we've made the table fit in a parent container that is 300x300 pixels
|
|
82
|
+
with the second column having a fixed width of 300 pixels.
|
|
83
|
+
|
|
84
|
+
<Canvas of={Stories.Scrollable} />
|
|
85
|
+
|
|
86
|
+
## Scrollable with Sticky Header
|
|
87
|
+
|
|
88
|
+
Pass `hasStickyHeader` as a prop to stick the header to the top of the table, and prevent it from scrolling away.
|
|
89
|
+
|
|
90
|
+
<Canvas of={Stories.ScrollablewithStickyHeader} />
|
|
91
|
+
|
|
92
|
+
## Scrollable with First Column Stuck to Left
|
|
93
|
+
|
|
94
|
+
To stick the first column to the left of the table when it scrolls horizontally, add `sticky: 'left` to the column's config.
|
|
95
|
+
|
|
96
|
+
<Canvas of={Stories.ScrollablewithFirstColumnStuckToLeft} />
|
|
97
|
+
|
|
98
|
+
## Scrollable with Sticky Header and Nth Column Stuck to Left
|
|
99
|
+
|
|
100
|
+
Add `sticky: 'left` to any column to stick it to the left of the table when it scrolls horizontally.
|
|
101
|
+
|
|
102
|
+
<Canvas of={Stories.ScrollablewithStickyHeaderAndNthColumnStuckToLeft} />
|
|
103
|
+
|
|
104
|
+
## Scrollable with Last Column Stuck to Right
|
|
105
|
+
|
|
106
|
+
To stick the last, or any, column to the right of the table when it scrolls horizontally, add `sticky: 'right'` to the column's config.
|
|
107
|
+
|
|
108
|
+
<Canvas of={Stories.ScrollableWithLastColumnStuckToRight} />
|
|
109
|
+
|
|
110
|
+
## Scrollable with Sticky Header and First Column Stuck to Left, Striped, and Hoverable
|
|
111
|
+
|
|
112
|
+
To stick the header to the top, and the first column to the left, pass `hasStickyHeader` as a prop, and add `sticky: 'left'` to the column's config.
|
|
113
|
+
|
|
114
|
+
<Canvas of={Stories.ScrollableWithStickyHeaderAndFirstColumnStuckToLeft} />
|
|
115
|
+
|
|
116
|
+
## Scrollable and Loading
|
|
117
|
+
|
|
118
|
+
All interactions, including clicking and scrolling will be disabled when a scrollable table is loading.
|
|
119
|
+
|
|
120
|
+
<Canvas of={Stories.ScrollableAndLoading} />
|
|
121
|
+
|
|
122
|
+
## Fixed-Width Columns
|
|
123
|
+
|
|
124
|
+
If you wish to lock the width of a particular column set the actual column `width` in your column object. Widths are set independently for each column.
|
|
125
|
+
|
|
126
|
+
<Canvas of={Stories.FixedWidthColumns} />
|
|
127
|
+
|
|
128
|
+
## Fixed Table Layout
|
|
129
|
+
|
|
130
|
+
The default layout algorithm for a HTML table is `auto`. Use the `useFixedTableLayout` prop to set the table's layout algorithm to `fixed`.
|
|
131
|
+
|
|
132
|
+
<Canvas of={Stories.FixedTableLayout} />
|
|
133
|
+
|
|
134
|
+
## Truncate Overflow
|
|
135
|
+
|
|
136
|
+
In cases where long text content is expected but displaying it fully isn't required, use the `truncateOverflow` prop on the table.
|
|
137
|
+
This will truncate column content, but only if a fixed width is passed to that column. NOTE: the `truncateOverflow` exists
|
|
138
|
+
in the `Column` object as well, making it possible to set it globally on the table or individually on a column. The column
|
|
139
|
+
value will supersede the global setting.
|
|
140
|
+
|
|
141
|
+
<Canvas of={Stories.TruncateOverflow} />
|
|
142
|
+
|
|
143
|
+
## Custom Actions
|
|
144
|
+
|
|
145
|
+
The `Column` object is equiped with a `render` method. When used, the cells will render any custom JSX returned by this method. This can be used in a completely agnostic way. See `Any custom JSX` column below, where we render the same markup regardless of the cell/row content.
|
|
146
|
+
|
|
147
|
+
The render method also exposes data about the cell and row, namely:
|
|
148
|
+
|
|
149
|
+
`cell: the content in the cell,`
|
|
150
|
+
|
|
151
|
+
`row: the entire row object,`
|
|
152
|
+
|
|
153
|
+
`rowIndex: the index of the row in the table`
|
|
154
|
+
|
|
155
|
+
With this data in the render function it is possible to render complex elements inside of a single cell.
|
|
156
|
+
See `Based on cell/row` example below.
|
|
157
|
+
|
|
158
|
+
<Canvas of={Stories.CustomActions} />
|
|
159
|
+
|
|
160
|
+
## Empty Cell Placeholder
|
|
161
|
+
|
|
162
|
+
The empty cell placeholder can be set on a global level as a prop on `<Table />` or individually per column
|
|
163
|
+
by adding the `emptyCellPlaceholder` to the column configuration object. In cases where both is set, the column
|
|
164
|
+
placeholder takes precedence over the global placeholder. As seen in the example below where the price column uses
|
|
165
|
+
`$0.00` as a placeholder where a price is missing.
|
|
166
|
+
|
|
167
|
+
<Canvas of={Stories.EmptyCellPlaceholder} />
|
|
168
|
+
|
|
169
|
+
## Borderless
|
|
170
|
+
|
|
171
|
+
Render a borderless table by passing `isBorderless` (boolean) prop to the table.
|
|
172
|
+
|
|
173
|
+
<Canvas of={Stories.Borderless} />
|
|
174
|
+
|
|
175
|
+
## Compact
|
|
176
|
+
|
|
177
|
+
Render a compact table by passing `isCompact` (boolean) prop to the table.
|
|
178
|
+
|
|
179
|
+
<Canvas of={Stories.Compact} />
|
|
180
|
+
|
|
181
|
+
## Striped
|
|
182
|
+
|
|
183
|
+
Render a striped table to slightly improve readibility by passing `isStriped` (boolean) prop to the table.
|
|
184
|
+
|
|
185
|
+
<Canvas of={Stories.Striped} />
|
|
186
|
+
|
|
187
|
+
## Hoverable
|
|
188
|
+
|
|
189
|
+
Make rows 'hoverable' by passing `hoverableRows` (boolean) prop to the table.
|
|
190
|
+
|
|
191
|
+
<Canvas of={Stories.Hoverable} />
|
|
192
|
+
|
|
193
|
+
## Striped & Hoverable
|
|
194
|
+
|
|
195
|
+
You can combine any of these boolean props based on your UI needs.
|
|
196
|
+
|
|
197
|
+
<Canvas of={Stories.StripedAndHoverable} />
|
|
198
|
+
|
|
199
|
+
## Aligning Cell Text
|
|
200
|
+
|
|
201
|
+
Align cell content as needed with the `align` prop. Either pass the prop at the `<Table />` level for all columns, or individually
|
|
202
|
+
in a single `Column` object. NOTE: right alignment is best reserved for numerical data display.
|
|
203
|
+
We recommend refraining from specific alignment unless it serves the data, as alignment discrepancies in different columns
|
|
204
|
+
may interrupt the natural reading flow for a user.
|
|
205
|
+
|
|
206
|
+
<Canvas of={Stories.AligningCellText} />
|
|
207
|
+
|
|
208
|
+
The below is an example of setting the `align` prop globally in the `<Table />` and overwriting its value on a specific column
|
|
209
|
+
|
|
210
|
+
<Canvas of={Stories.GlobalAlign} />
|
|
211
|
+
|
|
212
|
+
## Component as Column Header
|
|
213
|
+
|
|
214
|
+
You can use a ReactNode as your table header or cell.
|
|
215
|
+
|
|
216
|
+
<Canvas of={Stories.ComponentAsColumnHeader} />
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
.loading-mask {
|
|
5
|
+
display: flex;
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 0;
|
|
8
|
+
right: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
background: rgb(255 255 255 / 50%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.scroll-container {
|
|
17
|
+
.table {
|
|
18
|
+
background-color: var(--color-background-primary);
|
|
19
|
+
margin-top: 1px;
|
|
20
|
+
cursor: default;
|
|
21
|
+
width: 100%;
|
|
22
|
+
border-collapse: separate;
|
|
23
|
+
border-spacing: 0;
|
|
24
|
+
white-space: normal;
|
|
25
|
+
|
|
26
|
+
&.auto {
|
|
27
|
+
table-layout: auto;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.fixed {
|
|
31
|
+
table-layout: fixed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.borderless {
|
|
36
|
+
border: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.scrollable {
|
|
40
|
+
display: block;
|
|
41
|
+
-webkit-overflow-scrolling: touch;
|
|
42
|
+
|
|
43
|
+
&.scrollable-x {
|
|
44
|
+
overflow-x: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.scrollable-y {
|
|
48
|
+
height: 100%;
|
|
49
|
+
overflow-y: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
> .table-bordered {
|
|
53
|
+
border: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.full-height {
|
|
59
|
+
height: 100%;
|
|
60
|
+
}
|
|
61
|
+
}
|