@hyphen/hyphen-components 7.3.2 → 7.3.3
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 +5717 -5021
- 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 +5618 -4846
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +2693 -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/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
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -14,25 +14,24 @@
|
|
|
14
14
|
"src"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "cross-env
|
|
18
|
-
"rollup": "cross-env-shell BABEL_ENV=build IS_PUBLISHING=true \"dts build\"",
|
|
17
|
+
"build": "cross-env IS_PUBLISHING=true tsup && node scripts/create-cjs-shim.js && cross-env IS_PUBLISHING=true webpack --config webpack.config.js",
|
|
19
18
|
"build-storybook": "storybook build",
|
|
20
19
|
"build-storybook-docs": "storybook build --docs",
|
|
21
20
|
"storybook-docs": "storybook dev --docs",
|
|
22
|
-
"lint": "
|
|
23
|
-
"lint-fix": "
|
|
21
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
22
|
+
"lint-fix": "eslint src --ext .ts,.tsx --fix",
|
|
24
23
|
"size": "size-limit",
|
|
25
|
-
"start": "
|
|
24
|
+
"start": "tsup --watch",
|
|
26
25
|
"storybook": "storybook dev -p 6006",
|
|
27
|
-
"test": "
|
|
28
|
-
"test-watch": "
|
|
26
|
+
"test": "jest --passWithNoTests",
|
|
27
|
+
"test-watch": "jest --coverage --watch",
|
|
29
28
|
"semantic-release": "semantic-release",
|
|
30
29
|
"prepare": "npm run build",
|
|
31
30
|
"chromatic": "npx chromatic --project-token=chpt_8fddffb5556f0b7 --only-changed"
|
|
32
31
|
},
|
|
33
32
|
"husky": {
|
|
34
33
|
"hooks": {
|
|
35
|
-
"pre-commit": "
|
|
34
|
+
"pre-commit": "eslint src --ext .ts,.tsx"
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
"prettier": {
|
|
@@ -41,9 +40,6 @@
|
|
|
41
40
|
"singleQuote": true,
|
|
42
41
|
"trailingComma": "es5"
|
|
43
42
|
},
|
|
44
|
-
"jest": {
|
|
45
|
-
"testEnvironment": "jsdom"
|
|
46
|
-
},
|
|
47
43
|
"peerDependencies": {
|
|
48
44
|
"react": ">=16"
|
|
49
45
|
},
|
|
@@ -62,7 +58,7 @@
|
|
|
62
58
|
],
|
|
63
59
|
"dependencies": {
|
|
64
60
|
"@emotion/react": "^11.14.0",
|
|
65
|
-
"@hyphen/hyphen-design-tokens": "^
|
|
61
|
+
"@hyphen/hyphen-design-tokens": "^7.0.1",
|
|
66
62
|
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
67
63
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
68
64
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
@@ -98,10 +94,13 @@
|
|
|
98
94
|
"@testing-library/user-event": "^14.6.1",
|
|
99
95
|
"@tsconfig/recommended": "^1.0.7",
|
|
100
96
|
"@tsconfig/vite-react": "^3.0.2",
|
|
97
|
+
"@types/jest": "^30.0.0",
|
|
101
98
|
"@types/node": "^22.9.0",
|
|
102
99
|
"@types/react": "^18.3.5",
|
|
103
100
|
"@types/react-dom": "^18.3.0",
|
|
104
101
|
"@types/react-modal": "^3.16.3",
|
|
102
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
103
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
105
104
|
"autoprefixer": "^10.4.20",
|
|
106
105
|
"babel-loader": "^9.1.3",
|
|
107
106
|
"chromatic": "^13.3.4",
|
|
@@ -111,17 +110,19 @@
|
|
|
111
110
|
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
112
111
|
"cssnano": "^6.1.2",
|
|
113
112
|
"csstype": "^3.1.3",
|
|
114
|
-
"
|
|
113
|
+
"eslint-config-prettier": "^9.0.0",
|
|
114
|
+
"eslint-plugin-import": "^2.32.0",
|
|
115
|
+
"eslint-plugin-react": "^7.34.0",
|
|
116
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
115
117
|
"husky": "^8.0.3",
|
|
116
118
|
"identity-obj-proxy": "^3.0.0",
|
|
119
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
117
120
|
"jest-preview": "^0.3.1",
|
|
118
121
|
"mini-css-extract-plugin": "^2.9.1",
|
|
119
122
|
"postcss-loader": "^7.3.4",
|
|
120
123
|
"react": "^18.3.1",
|
|
121
124
|
"react-dom": "^18.3.1",
|
|
122
125
|
"react-is": "^18.3.1",
|
|
123
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
124
|
-
"rollup-plugin-scss": "^4.0.0",
|
|
125
126
|
"sass": "^1.77.8",
|
|
126
127
|
"sass-loader": "^13.3.3",
|
|
127
128
|
"semantic-release": "^25.0.2",
|
|
@@ -129,14 +130,12 @@
|
|
|
129
130
|
"storybook": "^9.1.3",
|
|
130
131
|
"ts-jest": "^29.4.6",
|
|
131
132
|
"tslib": "^2.8.1",
|
|
133
|
+
"tsup": "^8.0.0",
|
|
132
134
|
"typescript": "^5.9.3",
|
|
133
135
|
"url-loader": "^4.1.1",
|
|
134
136
|
"vite": "^5.4.19",
|
|
135
137
|
"webpack": "^5.94.0",
|
|
136
138
|
"webpack-cli": "^5.1.4",
|
|
137
139
|
"webpack-fix-style-only-entries": "^0.6.1"
|
|
138
|
-
},
|
|
139
|
-
"optionalDependencies": {
|
|
140
|
-
"@rollup/rollup-linux-x64-gnu": "^4.34.6"
|
|
141
140
|
}
|
|
142
141
|
}
|
|
@@ -93,6 +93,12 @@
|
|
|
93
93
|
color: var(--color-base-white);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
&.orange {
|
|
97
|
+
background: var(--color-background-brand-orange);
|
|
98
|
+
border-color: var(--color-border-brand-orange);
|
|
99
|
+
color: var(--color-base-white);
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
&.hyphen {
|
|
97
103
|
background: var(--color-background-brand-gradient);
|
|
98
104
|
border-color: var(--color-base-yellow-500);
|
|
@@ -11,6 +11,7 @@ export const BADGE_VARIANTS: BadgeVariant[] = [
|
|
|
11
11
|
'blue',
|
|
12
12
|
'red',
|
|
13
13
|
'purple',
|
|
14
|
+
'orange',
|
|
14
15
|
'hyphen',
|
|
15
16
|
];
|
|
16
17
|
|
|
@@ -25,7 +26,7 @@ describe('Badge', () => {
|
|
|
25
26
|
|
|
26
27
|
describe('Variants', () => {
|
|
27
28
|
BADGE_VARIANTS.map((variant) =>
|
|
28
|
-
describe(`${
|
|
29
|
+
describe(`${variant}`, () => {
|
|
29
30
|
test(`it has a ${variant} class applied to it`, () => {
|
|
30
31
|
render(<Badge variant={variant} message={`${variant} Badge`} />);
|
|
31
32
|
const badge = screen.getByText(`${variant} Badge`);
|
|
@@ -38,7 +39,7 @@ describe('Badge', () => {
|
|
|
38
39
|
|
|
39
40
|
describe('Sizes', () => {
|
|
40
41
|
BADGE_SIZES.map((size) =>
|
|
41
|
-
describe(`${
|
|
42
|
+
describe(`${size}`, () => {
|
|
42
43
|
test(`it has a ${size} class applied to it`, () => {
|
|
43
44
|
render(<Badge size={size} message={`${size} Badge`} />);
|
|
44
45
|
const badge = screen.getByText(`${size} Badge`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, forwardRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import {
|
|
3
|
+
import { ResponsiveProp } from '../../types';
|
|
4
4
|
import { generateResponsiveClasses } from '../../lib/generateResponsiveClasses';
|
|
5
5
|
import styles from './Badge.module.scss';
|
|
6
6
|
import { Box, BoxProps } from '../Box/Box';
|
|
@@ -16,16 +16,16 @@ export type BadgeVariant =
|
|
|
16
16
|
| 'blue'
|
|
17
17
|
| 'red'
|
|
18
18
|
| 'purple'
|
|
19
|
+
| 'orange'
|
|
19
20
|
| 'hyphen';
|
|
20
21
|
|
|
21
|
-
export type BadgeSizeAttributes = { fontSize: FontSize; padding: BaseSpacing };
|
|
22
22
|
export interface BadgeProps extends BoxProps {
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated Use children instead. The text message or ReactNode to be rendered in the badge.
|
|
25
25
|
*/
|
|
26
26
|
message?: string | ReactNode;
|
|
27
27
|
/**
|
|
28
|
-
* The size of the
|
|
28
|
+
* The size of the badge.
|
|
29
29
|
*/
|
|
30
30
|
size?: BadgeSize | ResponsiveProp<BadgeSize>;
|
|
31
31
|
/**
|
|
@@ -73,3 +73,5 @@ export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
|
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
|
+
|
|
77
|
+
Badge.displayName = 'Badge';
|
|
@@ -549,8 +549,8 @@ export const Box: FC<BoxProps> = forwardRef(
|
|
|
549
549
|
'base',
|
|
550
550
|
];
|
|
551
551
|
|
|
552
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
553
552
|
const findMatchingBreakpoint = (
|
|
553
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
554
554
|
responsiveObj: ResponsiveProp<any>,
|
|
555
555
|
key: BreakpointSizeWithBase
|
|
556
556
|
): string => {
|
|
@@ -589,10 +589,11 @@ export const Box: FC<BoxProps> = forwardRef(
|
|
|
589
589
|
/**
|
|
590
590
|
* Shallow merges existing classes of child node with a className based on the childGap value.
|
|
591
591
|
*/
|
|
592
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
593
592
|
const decorateChildren = (
|
|
593
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
594
594
|
child: string | number | ReactElement<any>,
|
|
595
595
|
i: number,
|
|
596
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
596
597
|
array: ReactElement<any>[]
|
|
597
598
|
) => {
|
|
598
599
|
if (
|
|
@@ -643,6 +644,8 @@ export const Box: FC<BoxProps> = forwardRef(
|
|
|
643
644
|
}
|
|
644
645
|
);
|
|
645
646
|
|
|
647
|
+
Box.displayName = 'Box';
|
|
648
|
+
|
|
646
649
|
export const boxPropsKeys: (keyof Pick<BoxProps, KnownKeys<BoxProps>>)[] = [
|
|
647
650
|
'as',
|
|
648
651
|
'alignItems',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import '@hyphen/hyphen-design-tokens/build/scss/variables';
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
|
-
--button-box-shadow-focus: 0 0 0 4px var(--color-base-
|
|
4
|
+
--button-box-shadow-focus: 0 0 0 4px var(--color-base-grey-300);
|
|
5
5
|
--button-neutral-box-shadow-focus: 0 0 0 4px var(--color-base-grey-200);
|
|
6
6
|
--button-danger-box-shadow-focus: 0 0 0 4px var(--color-base-danger-200);
|
|
7
7
|
}
|
|
@@ -18,7 +18,7 @@ describe('Button', () => {
|
|
|
18
18
|
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
19
19
|
expect(button).toBeDisabled();
|
|
20
20
|
|
|
21
|
-
rerender(<Button isLoading={false}
|
|
21
|
+
rerender(<Button isLoading={false}>Loading Button</Button>);
|
|
22
22
|
expect(button).not.toHaveAttribute('aria-disabled');
|
|
23
23
|
expect(button).not.toBeDisabled();
|
|
24
24
|
});
|
|
@@ -32,7 +32,7 @@ describe('Button', () => {
|
|
|
32
32
|
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
33
33
|
expect(button).toBeDisabled();
|
|
34
34
|
|
|
35
|
-
rerender(<Button isDisabled={false}
|
|
35
|
+
rerender(<Button isDisabled={false}>Disabled Button</Button>);
|
|
36
36
|
expect(button).not.toHaveAttribute('aria-disabled');
|
|
37
37
|
expect(button).not.toBeDisabled();
|
|
38
38
|
});
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { Calendar } from './Calendar';
|
|
4
|
+
|
|
5
|
+
describe('Calendar', () => {
|
|
6
|
+
describe('Rendering', () => {
|
|
7
|
+
test('renders the calendar component', () => {
|
|
8
|
+
render(<Calendar />);
|
|
9
|
+
expect(screen.getByRole('grid')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('renders with default class names when no className provided', () => {
|
|
13
|
+
const { container } = render(<Calendar />);
|
|
14
|
+
const calendarRoot = container.querySelector('.rdp-root');
|
|
15
|
+
expect(calendarRoot).toHaveClass('p-lg', 'bw-sm', 'br-sm');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('renders with custom className when provided', () => {
|
|
19
|
+
const { container } = render(<Calendar className="custom-calendar" />);
|
|
20
|
+
const calendarRoot = container.querySelector('.rdp-root');
|
|
21
|
+
expect(calendarRoot).toHaveClass('custom-calendar');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('renders navigation buttons', () => {
|
|
25
|
+
render(<Calendar />);
|
|
26
|
+
const prevButton = screen.getByRole('button', { name: /previous/i });
|
|
27
|
+
const nextButton = screen.getByRole('button', { name: /next/i });
|
|
28
|
+
expect(prevButton).toBeInTheDocument();
|
|
29
|
+
expect(nextButton).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('renders weekday headers', () => {
|
|
33
|
+
render(<Calendar />);
|
|
34
|
+
// Check for some weekday abbreviations
|
|
35
|
+
expect(screen.getByText('Su')).toBeInTheDocument();
|
|
36
|
+
expect(screen.getByText('Mo')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByText('Tu')).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('Navigation', () => {
|
|
42
|
+
test('navigates to previous month when clicking previous button', () => {
|
|
43
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
44
|
+
render(<Calendar defaultMonth={testDate} />);
|
|
45
|
+
|
|
46
|
+
expect(screen.getByText('June 2024')).toBeInTheDocument();
|
|
47
|
+
|
|
48
|
+
const prevButton = screen.getByRole('button', { name: /previous/i });
|
|
49
|
+
fireEvent.click(prevButton);
|
|
50
|
+
|
|
51
|
+
expect(screen.getByText('May 2024')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('navigates to next month when clicking next button', () => {
|
|
55
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
56
|
+
render(<Calendar defaultMonth={testDate} />);
|
|
57
|
+
|
|
58
|
+
expect(screen.getByText('June 2024')).toBeInTheDocument();
|
|
59
|
+
|
|
60
|
+
const nextButton = screen.getByRole('button', { name: /next/i });
|
|
61
|
+
fireEvent.click(nextButton);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByText('July 2024')).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('Selection', () => {
|
|
68
|
+
test('calls onSelect when a day is clicked (single mode)', () => {
|
|
69
|
+
const handleSelect = jest.fn();
|
|
70
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
71
|
+
render(
|
|
72
|
+
<Calendar
|
|
73
|
+
mode="single"
|
|
74
|
+
defaultMonth={testDate}
|
|
75
|
+
onSelect={handleSelect}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// In react-day-picker v9, we need to click the button inside the day cell
|
|
80
|
+
const dayButton = screen.getByRole('button', { name: /June 16th/i });
|
|
81
|
+
fireEvent.click(dayButton);
|
|
82
|
+
|
|
83
|
+
expect(handleSelect).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('supports range selection mode', () => {
|
|
87
|
+
const handleSelect = jest.fn();
|
|
88
|
+
const testDate = new Date(2024, 5, 1); // June 2024
|
|
89
|
+
render(
|
|
90
|
+
<Calendar
|
|
91
|
+
mode="range"
|
|
92
|
+
defaultMonth={testDate}
|
|
93
|
+
onSelect={handleSelect}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const day10 = screen.getByRole('button', { name: /June 10th/i });
|
|
98
|
+
const day18 = screen.getByRole('button', { name: /June 18th/i });
|
|
99
|
+
|
|
100
|
+
fireEvent.click(day10);
|
|
101
|
+
fireEvent.click(day18);
|
|
102
|
+
|
|
103
|
+
expect(handleSelect).toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('supports multiple selection mode', () => {
|
|
107
|
+
const handleSelect = jest.fn();
|
|
108
|
+
const testDate = new Date(2024, 5, 1); // June 2024
|
|
109
|
+
render(
|
|
110
|
+
<Calendar
|
|
111
|
+
mode="multiple"
|
|
112
|
+
defaultMonth={testDate}
|
|
113
|
+
onSelect={handleSelect}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const day6 = screen.getByRole('button', { name: /June 6th/i });
|
|
118
|
+
const day12 = screen.getByRole('button', { name: /June 12th/i });
|
|
119
|
+
|
|
120
|
+
fireEvent.click(day6);
|
|
121
|
+
fireEvent.click(day12);
|
|
122
|
+
|
|
123
|
+
expect(handleSelect).toHaveBeenCalledTimes(2);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('Controlled selection', () => {
|
|
128
|
+
test('renders with selected date in single mode', () => {
|
|
129
|
+
const selectedDate = new Date(2024, 5, 16); // June 16, 2024
|
|
130
|
+
const { container } = render(
|
|
131
|
+
<Calendar mode="single" selected={selectedDate} month={selectedDate} />
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// The selected day should have the selected class
|
|
135
|
+
const selectedDay = container.querySelector('[data-selected="true"]');
|
|
136
|
+
expect(selectedDay).toBeInTheDocument();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('Disabled dates', () => {
|
|
141
|
+
test('disables specific dates via disabled prop', () => {
|
|
142
|
+
const testDate = new Date(2024, 5, 1); // June 2024
|
|
143
|
+
const disabledDate = new Date(2024, 5, 11); // June 11, 2024
|
|
144
|
+
const { container } = render(
|
|
145
|
+
<Calendar defaultMonth={testDate} disabled={[disabledDate]} />
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// The disabled day cell should have the disabled data attribute
|
|
149
|
+
const disabledCell = container.querySelector('[data-disabled="true"]');
|
|
150
|
+
expect(disabledCell).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('disables dates before a specific date', () => {
|
|
154
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
155
|
+
const { container } = render(
|
|
156
|
+
<Calendar
|
|
157
|
+
defaultMonth={testDate}
|
|
158
|
+
disabled={{ before: new Date(2024, 5, 10) }}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
// Multiple dates should be disabled
|
|
163
|
+
const disabledCells = container.querySelectorAll(
|
|
164
|
+
'[data-disabled="true"]'
|
|
165
|
+
);
|
|
166
|
+
expect(disabledCells.length).toBeGreaterThan(0);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe('Caption layout', () => {
|
|
171
|
+
test('defaults to label caption layout', () => {
|
|
172
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
173
|
+
render(<Calendar defaultMonth={testDate} />);
|
|
174
|
+
expect(screen.getByText('June 2024')).toBeInTheDocument();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('supports dropdown caption layout', () => {
|
|
178
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
179
|
+
render(
|
|
180
|
+
<Calendar
|
|
181
|
+
defaultMonth={testDate}
|
|
182
|
+
captionLayout="dropdown"
|
|
183
|
+
startMonth={new Date(2020, 0)}
|
|
184
|
+
endMonth={new Date(2030, 11)}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// With dropdown, month and year should be selectable
|
|
189
|
+
expect(
|
|
190
|
+
screen.getByRole('combobox', { name: /month/i })
|
|
191
|
+
).toBeInTheDocument();
|
|
192
|
+
expect(
|
|
193
|
+
screen.getByRole('combobox', { name: /year/i })
|
|
194
|
+
).toBeInTheDocument();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('Number of months', () => {
|
|
199
|
+
test('can display multiple months', () => {
|
|
200
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
201
|
+
render(<Calendar defaultMonth={testDate} numberOfMonths={2} />);
|
|
202
|
+
|
|
203
|
+
expect(screen.getByText('June 2024')).toBeInTheDocument();
|
|
204
|
+
expect(screen.getByText('July 2024')).toBeInTheDocument();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('Custom styling', () => {
|
|
209
|
+
test('applies custom CSS variables for theming', () => {
|
|
210
|
+
const { container } = render(<Calendar />);
|
|
211
|
+
const calendarRoot = container.querySelector('.rdp-root');
|
|
212
|
+
|
|
213
|
+
expect(calendarRoot).toHaveStyle({
|
|
214
|
+
'--rdp-accent-color': 'var(--color-font-base)',
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('Chevron icons', () => {
|
|
220
|
+
test('renders chevron icon for previous navigation', () => {
|
|
221
|
+
render(<Calendar />);
|
|
222
|
+
const prevButton = screen.getByRole('button', { name: /previous/i });
|
|
223
|
+
// The Icon component renders an SVG
|
|
224
|
+
const icon = prevButton.querySelector('svg');
|
|
225
|
+
expect(icon).toBeInTheDocument();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('renders chevron icon for next navigation', () => {
|
|
229
|
+
render(<Calendar />);
|
|
230
|
+
const nextButton = screen.getByRole('button', { name: /next/i });
|
|
231
|
+
// The Icon component renders an SVG
|
|
232
|
+
const icon = nextButton.querySelector('svg');
|
|
233
|
+
expect(icon).toBeInTheDocument();
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe('Props passthrough', () => {
|
|
238
|
+
test('passes additional props to DayPicker', () => {
|
|
239
|
+
const handleMonthChange = jest.fn();
|
|
240
|
+
const testDate = new Date(2024, 5, 15); // June 2024
|
|
241
|
+
render(
|
|
242
|
+
<Calendar defaultMonth={testDate} onMonthChange={handleMonthChange} />
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
const nextButton = screen.getByRole('button', { name: /next/i });
|
|
246
|
+
fireEvent.click(nextButton);
|
|
247
|
+
|
|
248
|
+
expect(handleMonthChange).toHaveBeenCalled();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe('Today indicator', () => {
|
|
253
|
+
test('renders today with bold font weight class', () => {
|
|
254
|
+
const today = new Date();
|
|
255
|
+
render(<Calendar defaultMonth={today} />);
|
|
256
|
+
|
|
257
|
+
// The calendar should have today's date styled
|
|
258
|
+
const calendarGrid = screen.getByRole('grid');
|
|
259
|
+
expect(calendarGrid).toBeInTheDocument();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
&:focus {
|
|
15
15
|
outline: 0;
|
|
16
|
-
box-shadow: 0 0 0 2px var(--color-base-
|
|
16
|
+
box-shadow: 0 0 0 2px var(--color-base-grey-200);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//Show focus styles on keyboard focus.
|
|
20
20
|
&:focus-visible {
|
|
21
21
|
outline: 0;
|
|
22
|
-
box-shadow: 0 0 0 2px var(--color-base-
|
|
22
|
+
box-shadow: 0 0 0 2px var(--color-base-grey-200);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Hide focus styles if they are not needed, for example,
|
|
@@ -240,7 +240,7 @@ export const Width = () => {
|
|
|
240
240
|
<DrawerProvider defaultIsOpen={false}>
|
|
241
241
|
<Box gap="md" direction="row">
|
|
242
242
|
{widths.map((width: string) => (
|
|
243
|
-
<DrawerTrigger asChild>
|
|
243
|
+
<DrawerTrigger asChild key={width}>
|
|
244
244
|
<Button
|
|
245
245
|
variant="primary"
|
|
246
246
|
onClick={() => handleClick(width as WidthSize)}
|