@moda/om 21.0.0-next.1 → 21.0.1
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/README.md +0 -1
- package/dist/index.cjs.js +2194 -1983
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2193 -1982
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/src/components/Clickable/Clickable.d.ts +2 -7
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/NavigationPreventer/NavigationPreventer.d.ts +2 -1
- package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/src/components/Popover/Popover.d.ts +1 -1
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +1 -1
- package/dist/src/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/src/components/Select/useSelect.d.ts +3 -3
- package/dist/src/components/Tabs/Tab.d.ts +1 -1
- package/dist/src/components/Text/Text.d.ts +2 -2
- package/dist/src/hooks/useClickOutside.d.ts +1 -1
- package/dist/src/index.d.ts +10 -1
- package/dist/src/utilities/States/State.d.ts +6 -7
- package/dist/src/utilities/States/StateProps.d.ts +7 -0
- package/dist/src/utilities/States/States.d.ts +6 -7
- package/dist/src/utilities/States/Styles.d.ts +14 -0
- package/dist/src/utilities/States/index.d.ts +1 -0
- package/dist/src/utilities/index.d.ts +7 -0
- package/dist/src/utilities/isEmpty.d.ts +1 -0
- package/dist/src/utilities/isRenderProps.d.ts +5 -0
- package/dist/src/utilities/stringifyProps.d.ts +1 -0
- package/dist/src/utilities/truncate.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +71 -69
- package/src/components/AspectRatioBox/AspectRatioBox.stories.tsx +1 -1
- package/src/components/Badge/Badge.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/src/components/Breakpoint/Breakpoint.stories.tsx +3 -6
- package/src/components/Button/Button.stories.tsx +10 -7
- package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Clickable/Clickable.stories.tsx +7 -4
- package/src/components/Clickable/Clickable.tsx +3 -6
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +1 -1
- package/src/components/ControlLink/ControlLink.stories.tsx +12 -7
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +3 -6
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +5 -13
- package/src/components/DefinitionList/DefinitionList.stories.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +1 -1
- package/src/components/Field/Field.stories.tsx +1 -1
- package/src/components/Field/Field.tsx +1 -1
- package/src/components/Label/Label.stories.tsx +1 -1
- package/src/components/LoadingItemsLavenderBlue/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingItemsPinkGreen/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingShapes/LoadingShapes.stories.tsx +1 -1
- package/src/components/LoadingShapesLavenderBlue/LoadingShapesLavenderBlue.stories.tsx +1 -1
- package/src/components/LoadingShapesPinkGreen/LoadingShapesPinkGreen.stories.tsx +1 -1
- package/src/components/NavigationPreventer/NavigationPreventer.tsx +5 -5
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.stories.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
- package/src/components/RadioButton/RadioButton.tsx +1 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +1 -1
- package/src/components/Select/Select.stories.tsx +2 -3
- package/src/components/Select/Select.test.tsx +5 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/Shape/Shape.stories.tsx +1 -1
- package/src/components/Stack/Stack.stories.tsx +1 -1
- package/src/components/Tabs/Tab.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/Text/Text.scss +1 -1
- package/src/components/Text/Text.stories.tsx +1 -1
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +1 -1
- package/src/hooks/useClickOutside.ts +4 -1
- package/src/index.scss +0 -1
- package/src/index.ts +2 -0
- package/src/utilities/States/State.tsx +13 -13
- package/src/utilities/States/StateProps.tsx +28 -0
- package/src/utilities/States/States.tsx +9 -11
- package/src/utilities/States/Styles.tsx +43 -0
- package/src/utilities/States/index.ts +1 -0
- package/src/utilities/index.ts +7 -0
- package/src/utilities/isEmpty.ts +1 -0
- package/src/utilities/isRenderProps.ts +9 -0
- package/src/utilities/{States/stringifyProps.tsx → stringifyProps.ts} +2 -7
- package/src/utilities/truncate.ts +5 -0
- package/dist/src/utilities/States/StatesProps.d.ts +0 -8
- package/dist/src/utilities/States/isRenderProps.d.ts +0 -4
- package/dist/src/utilities/States/stringifyProps.d.ts +0 -1
- package/src/functions/_functions.scss +0 -0
- package/src/utilities/States/State.scss +0 -11
- package/src/utilities/States/States.scss +0 -5
- package/src/utilities/States/StatesProps.scss +0 -24
- package/src/utilities/States/StatesProps.tsx +0 -31
- package/src/utilities/States/isRenderProps.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda/om",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.1",
|
|
4
4
|
"description": "Moda Operandi design system",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "NODE_ENV=production npm run compile && npm run types",
|
|
24
|
-
"build:documentation": "NODE_ENV=production cd documentation && npm run build",
|
|
25
24
|
"build:storybook": "NODE_ENV=storybook storybook build",
|
|
26
25
|
"clean": "rm -rf ./dist",
|
|
27
26
|
"commit": "git-cz",
|
|
@@ -31,14 +30,12 @@
|
|
|
31
30
|
"lint": "eslint src",
|
|
32
31
|
"lint-staged": "lint-staged",
|
|
33
32
|
"postpublish": "pinst --enable",
|
|
34
|
-
"predeploy:documentation": "NODE_ENV=production npm run build && cd documentation && npm install && npm run build",
|
|
35
33
|
"prepare": "husky && echo ''",
|
|
36
34
|
"prepublishOnly": "npm run clean && npm run build && pinst --disable",
|
|
37
35
|
"scaffold:component": "node scripts/scaffold/react Components",
|
|
38
36
|
"scaffold:function": "node scripts/scaffold/sass Functions",
|
|
39
37
|
"scaffold:mixin": "node scripts/scaffold/sass Mixins",
|
|
40
38
|
"semantic-release": "semantic-release",
|
|
41
|
-
"start": "cd documentation && npm run start",
|
|
42
39
|
"storybook": "storybook dev -p 6006",
|
|
43
40
|
"test": "jest -w 1",
|
|
44
41
|
"tsc": "tsc",
|
|
@@ -46,108 +43,113 @@
|
|
|
46
43
|
"unlink-all": "yalc remove --all && npm install"
|
|
47
44
|
},
|
|
48
45
|
"peerDependencies": {
|
|
49
|
-
"react": ">=
|
|
50
|
-
"react-dom": ">=
|
|
51
|
-
"
|
|
46
|
+
"react": ">=19.1.0",
|
|
47
|
+
"react-dom": ">=19.1.0",
|
|
48
|
+
"react-router-dom": "^5.1.2"
|
|
52
49
|
},
|
|
53
50
|
"dependencies": {
|
|
54
|
-
"@moda/icons": "^5.
|
|
55
|
-
"@moda/tokens": "^6.
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
51
|
+
"@moda/icons": "^5.30.1",
|
|
52
|
+
"@moda/tokens": "^6.3.4",
|
|
53
|
+
"@mona-health/react-input-mask": "^3.0.3",
|
|
54
|
+
"@storybook/addon-styling": "^2.0.0",
|
|
58
55
|
"classnames": "^2.5.1",
|
|
59
|
-
"credit-card-type": "^10.0.
|
|
60
|
-
"
|
|
56
|
+
"credit-card-type": "^10.0.2",
|
|
57
|
+
"focus-visible": "^5.2.1",
|
|
61
58
|
"proportional-scale": "^4.0.0",
|
|
62
59
|
"react-focus-on": "^3.9.4",
|
|
63
|
-
"react-input-mask": "^2.0.4",
|
|
64
60
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
65
|
-
"storybook": "^8.
|
|
61
|
+
"storybook": "^8.6.12",
|
|
66
62
|
"use-cursor": "^1.2.3"
|
|
67
63
|
},
|
|
68
64
|
"devDependencies": {
|
|
69
|
-
"@babel/core": "^7.
|
|
70
|
-
"@babel/preset-env": "^7.
|
|
71
|
-
"@babel/preset-react": "^7.
|
|
72
|
-
"@babel/preset-typescript": "^7.
|
|
73
|
-
"@commitlint/cli": "^19.
|
|
74
|
-
"@commitlint/config-conventional": "^19.
|
|
75
|
-
"@eslint/js": "^9.
|
|
65
|
+
"@babel/core": "^7.26.10",
|
|
66
|
+
"@babel/preset-env": "^7.26.9",
|
|
67
|
+
"@babel/preset-react": "^7.26.3",
|
|
68
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
69
|
+
"@commitlint/cli": "^19.8.0",
|
|
70
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
71
|
+
"@eslint/js": "^9.24.0",
|
|
76
72
|
"@moda/rollup-plugin-postcss": "^4.0.1",
|
|
77
73
|
"@rollup/plugin-babel": "^6.0.4",
|
|
78
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
79
|
-
"@rollup/plugin-node-resolve": "^
|
|
80
|
-
"@storybook/addon-actions": "^8.
|
|
81
|
-
"@storybook/addon-essentials": "^8.
|
|
82
|
-
"@storybook/addon-links": "^8.
|
|
83
|
-
"@storybook/addon-mdx-gfm": "^8.3.6",
|
|
74
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
75
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
76
|
+
"@storybook/addon-actions": "^8.6.12",
|
|
77
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
78
|
+
"@storybook/addon-links": "^8.6.12",
|
|
84
79
|
"@storybook/addon-postcss": "^2.0.0",
|
|
85
|
-
"@storybook/addon-viewport": "^8.
|
|
86
|
-
"@storybook/addon-webpack5-compiler-babel": "^3.0.
|
|
80
|
+
"@storybook/addon-viewport": "^8.6.12",
|
|
81
|
+
"@storybook/addon-webpack5-compiler-babel": "^3.0.6",
|
|
87
82
|
"@storybook/addons": "^7.6.17",
|
|
88
|
-
"@storybook/react": "^8.
|
|
89
|
-
"@storybook/react-webpack5": "^8.
|
|
90
|
-
"@testing-library/jest-dom": "^6.6.
|
|
91
|
-
"@testing-library/react": "^16.0
|
|
92
|
-
"@testing-library/user-event": "^14.
|
|
83
|
+
"@storybook/react": "^8.6.12",
|
|
84
|
+
"@storybook/react-webpack5": "^8.6.12",
|
|
85
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
86
|
+
"@testing-library/react": "^16.3.0",
|
|
87
|
+
"@testing-library/user-event": "^14.6.1",
|
|
93
88
|
"@types/cheerio": "^0.22.35",
|
|
89
|
+
"@types/classnames": "^2.3.4",
|
|
94
90
|
"@types/credit-card-type": "^9.0.3",
|
|
95
91
|
"@types/jest": "^29.5.14",
|
|
96
92
|
"@types/ramda": "^0.30.2",
|
|
97
|
-
"@types/react": "^
|
|
98
|
-
"@types/react-dom": "^
|
|
99
|
-
"@types/react-input-mask": "^3.0.
|
|
100
|
-
"@
|
|
101
|
-
"@typescript-eslint/
|
|
102
|
-
"
|
|
103
|
-
"
|
|
93
|
+
"@types/react": "^19.1.2",
|
|
94
|
+
"@types/react-dom": "^19.1.2",
|
|
95
|
+
"@types/react-input-mask": "^3.0.6",
|
|
96
|
+
"@types/react-router-dom": "^5.3.3",
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
98
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
99
|
+
"autoprefixer": "^10.4.21",
|
|
100
|
+
"babel-loader": "^10.0.0",
|
|
104
101
|
"commitizen": "^4.3.1",
|
|
105
102
|
"css-loader": "^7.1.2",
|
|
106
103
|
"cz-conventional-changelog": "^3.3.0",
|
|
107
|
-
"eslint": "^9.
|
|
108
|
-
"eslint-config-prettier": "^
|
|
104
|
+
"eslint": "^9.24.0",
|
|
105
|
+
"eslint-config-prettier": "^10.1.2",
|
|
109
106
|
"eslint-plugin-import": "^2.31.0",
|
|
110
|
-
"eslint-plugin-jest-dom": "^5.
|
|
111
|
-
"eslint-plugin-jsx-a11y": "^6.10.
|
|
107
|
+
"eslint-plugin-jest-dom": "^5.5.0",
|
|
108
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
112
109
|
"eslint-plugin-no-loops": "^0.4.0",
|
|
113
110
|
"eslint-plugin-node": "^11.1.0",
|
|
114
|
-
"eslint-plugin-prettier": "^5.2.
|
|
115
|
-
"eslint-plugin-promise": "^7.1
|
|
116
|
-
"eslint-plugin-react": "^7.37.
|
|
117
|
-
"eslint-plugin-react-hooks": "^5.
|
|
111
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
112
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
113
|
+
"eslint-plugin-react": "^7.37.5",
|
|
114
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
118
115
|
"eslint-plugin-standard": "^5.0.0",
|
|
119
|
-
"eslint-plugin-testing-library": "^
|
|
120
|
-
"globals": "^
|
|
121
|
-
"husky": "^9.1.
|
|
116
|
+
"eslint-plugin-testing-library": "^7.1.1",
|
|
117
|
+
"globals": "^16.0.0",
|
|
118
|
+
"husky": "^9.1.7",
|
|
122
119
|
"identity-obj-proxy": "^3.0.0",
|
|
123
120
|
"ignore-not-found-export-webpack-plugin": "^1.0.2",
|
|
124
121
|
"jest": "^29.7.0",
|
|
125
122
|
"jest-environment-jsdom": "^29.7.0",
|
|
126
123
|
"jest-matchmedia-mock": "^1.1.0",
|
|
127
|
-
"lint-staged": "^15.
|
|
124
|
+
"lint-staged": "^15.5.1",
|
|
128
125
|
"node-sass-package-importer": "^5.3.3",
|
|
129
126
|
"pinst": "^3.0.0",
|
|
130
|
-
"postcss": "^8.
|
|
127
|
+
"postcss": "^8.5.3",
|
|
131
128
|
"postcss-loader": "^8.1.1",
|
|
132
|
-
"prettier": "^3.
|
|
129
|
+
"prettier": "^3.5.3",
|
|
133
130
|
"ramda": "^0.30.1",
|
|
134
|
-
"react": "^
|
|
135
|
-
"react-dom": "^
|
|
136
|
-
"
|
|
131
|
+
"react": "^19.1.0",
|
|
132
|
+
"react-dom": "^19.1.0",
|
|
133
|
+
"react-router-dom": "^5.1.2",
|
|
134
|
+
"rollup": "^4.40.0",
|
|
137
135
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
138
|
-
"rollup-plugin-scss": "^4.0.
|
|
139
|
-
"sass": "^1.
|
|
140
|
-
"sass-loader": "^16.0.
|
|
141
|
-
"semantic-release": "^24.
|
|
136
|
+
"rollup-plugin-scss": "^4.0.1",
|
|
137
|
+
"sass": "^1.86.3",
|
|
138
|
+
"sass-loader": "^16.0.5",
|
|
139
|
+
"semantic-release": "^24.2.3",
|
|
142
140
|
"semantic-release-npm-github": "^5.0.0",
|
|
143
|
-
"storybook-states": "^1.2.0",
|
|
144
141
|
"style-loader": "^4.0.0",
|
|
145
|
-
"ts-jest": "^29.2
|
|
146
|
-
"typescript": "^5.
|
|
147
|
-
"typescript-eslint": "^8.
|
|
142
|
+
"ts-jest": "^29.3.2",
|
|
143
|
+
"typescript": "^5.8.3",
|
|
144
|
+
"typescript-eslint": "^8.30.1",
|
|
148
145
|
"waait": "^1.0.5",
|
|
149
|
-
"webpack": "^5.
|
|
150
|
-
"webpack-cli": "^
|
|
146
|
+
"webpack": "^5.99.5",
|
|
147
|
+
"webpack-cli": "^6.0.1"
|
|
148
|
+
},
|
|
149
|
+
"overrides": {
|
|
150
|
+
"@types/react": "^19.1.2",
|
|
151
|
+
"react": "^19.1.0",
|
|
152
|
+
"react-dom": "^19.1.0"
|
|
151
153
|
},
|
|
152
154
|
"config": {
|
|
153
155
|
"commitizen": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children, cloneElement, isValidElement } from 'react';
|
|
1
|
+
import React, { Children, cloneElement, isValidElement, ReactNode } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
|
|
4
4
|
import './Breadcrumbs.scss';
|
|
@@ -16,7 +16,7 @@ export const Breadcrumbs: React.FC<BreadcrumbsProps> = ({ children, className, .
|
|
|
16
16
|
{...rest}
|
|
17
17
|
>
|
|
18
18
|
{Children.map(children, (child, index) => {
|
|
19
|
-
if (isValidElement(child)) {
|
|
19
|
+
if (isValidElement<{ children?: ReactNode; position: number }>(child)) {
|
|
20
20
|
position = position + 1;
|
|
21
21
|
return cloneElement(
|
|
22
22
|
child,
|
|
@@ -49,12 +49,9 @@ const Watcher: React.FC<{ from: string }> = ({ from }) => {
|
|
|
49
49
|
console.log('<Watcher /> mounted', { from });
|
|
50
50
|
}, [from]);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<div>View console</div>
|
|
56
|
-
</>
|
|
57
|
-
);
|
|
52
|
+
console.log('<Watcher /> rendered', { from });
|
|
53
|
+
|
|
54
|
+
return <div>View console</div>;
|
|
58
55
|
};
|
|
59
56
|
|
|
60
57
|
export const Values = () => (
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
2
3
|
import { action } from '@storybook/addon-actions';
|
|
3
|
-
import { States } from 'storybook-states';
|
|
4
|
-
|
|
5
4
|
import Heart from '@moda/icons/favorite-outline-16';
|
|
5
|
+
|
|
6
|
+
import { States } from '../../utilities';
|
|
6
7
|
import { Stack } from '../Stack';
|
|
7
8
|
import { Button, ButtonProps } from './Button';
|
|
8
9
|
|
|
@@ -63,11 +64,13 @@ export const PrimaryWithHref = () => (
|
|
|
63
64
|
);
|
|
64
65
|
|
|
65
66
|
export const PrimaryAsReactRouterLink = () => (
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
<BrowserRouter>
|
|
68
|
+
<States<ButtonProps> states={[{}, { hover: true }, { focus: true }, { disabled: true }]}>
|
|
69
|
+
<Button to='#href' onClick={action('clicked')}>
|
|
70
|
+
Add to Cart
|
|
71
|
+
</Button>
|
|
72
|
+
</States>
|
|
73
|
+
</BrowserRouter>
|
|
71
74
|
);
|
|
72
75
|
|
|
73
76
|
export const PrimaryWithIcon = () => (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useEffect, JSX } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import CheckmarkIcon from '@moda/icons/checkmark-16';
|
|
4
4
|
import CircleIcon from '@moda/icons/circle-12';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
|
-
import {
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
+
import { States } from '../../utilities';
|
|
4
5
|
import { Clickable, ClickableProps } from './Clickable';
|
|
5
6
|
|
|
6
7
|
export default { title: 'Components/Clickable' };
|
|
@@ -20,7 +21,9 @@ export const Anchor = () => (
|
|
|
20
21
|
);
|
|
21
22
|
|
|
22
23
|
export const Link = () => (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
24
|
+
<BrowserRouter>
|
|
25
|
+
<States<ClickableProps>>
|
|
26
|
+
<Clickable to='#href'>Useful to extend in place of <Link/>. Click me.</Clickable>
|
|
27
|
+
</States>
|
|
28
|
+
</BrowserRouter>
|
|
26
29
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import Link,
|
|
3
|
+
import { Link, LinkProps } from 'react-router-dom';
|
|
4
4
|
|
|
5
5
|
import './Clickable.scss';
|
|
6
6
|
|
|
@@ -12,8 +12,6 @@ export type ClickableProps = {
|
|
|
12
12
|
styleless?: boolean;
|
|
13
13
|
} & (ButtonElProps | AnchorElProps | LinkProps);
|
|
14
14
|
|
|
15
|
-
type LinkProps = NextLinkProps & { to: string; className?: string; children?: ReactNode };
|
|
16
|
-
|
|
17
15
|
const isLink = (props: ButtonElProps | AnchorElProps | LinkProps): props is LinkProps =>
|
|
18
16
|
'to' in props;
|
|
19
17
|
const isAnchor = (props: ButtonElProps | AnchorElProps | LinkProps): props is AnchorElProps =>
|
|
@@ -32,8 +30,7 @@ export const Clickable = React.forwardRef(
|
|
|
32
30
|
disabled
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
if (isLink(props))
|
|
36
|
-
return <Link {...props} href={props.to} ref={ref as React.Ref<HTMLAnchorElement>} />;
|
|
33
|
+
if (isLink(props)) return <Link {...props} ref={ref as React.Ref<HTMLAnchorElement>} />;
|
|
37
34
|
if (isAnchor(props)) return <a {...props} ref={ref as React.Ref<HTMLAnchorElement>} />;
|
|
38
35
|
if (isButton(props)) return <button {...props} ref={ref as React.Ref<HTMLButtonElement>} />;
|
|
39
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
|
-
import { States } from '
|
|
3
|
+
import { States } from '../../utilities';
|
|
4
4
|
import { Stack } from '../Stack';
|
|
5
5
|
import { ColorSwatch, ColorSwatchProps, SKU_COLORS } from '.';
|
|
6
6
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
|
-
import {
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
+
import { States } from '../../utilities';
|
|
4
5
|
import { ControlLink, ControlLinkProps } from './ControlLink';
|
|
5
6
|
|
|
6
7
|
export default { title: 'Components/ControlLink' };
|
|
@@ -14,13 +15,17 @@ const states = [
|
|
|
14
15
|
];
|
|
15
16
|
|
|
16
17
|
export const Underlined = () => (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
18
|
+
<BrowserRouter>
|
|
19
|
+
<States<ControlLinkProps> states={states}>
|
|
20
|
+
<ControlLink>Underlined Control Link</ControlLink>
|
|
21
|
+
</States>
|
|
22
|
+
</BrowserRouter>
|
|
20
23
|
);
|
|
21
24
|
|
|
22
25
|
export const Blank = () => (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
+
<BrowserRouter>
|
|
27
|
+
<States<ControlLinkProps> states={states}>
|
|
28
|
+
<ControlLink underlined={false}>Blank Control Link</ControlLink>
|
|
29
|
+
</States>
|
|
30
|
+
</BrowserRouter>
|
|
26
31
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { States } from '
|
|
2
|
+
import { States } from '../../utilities';
|
|
3
3
|
import { CreditCardNumberInput, CreditCardNumberInputProps } from './CreditCardNumberInput';
|
|
4
4
|
|
|
5
5
|
export default { title: 'Components/CreditCardNumberInput' };
|
|
@@ -10,8 +10,7 @@ describe('credit card number input', () => {
|
|
|
10
10
|
expect(input).toBeInTheDocument();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
xit('does not allow non-numeric characters', async () => {
|
|
13
|
+
it('does not allow non-numeric characters', async () => {
|
|
15
14
|
render(<CreditCardNumberInput label='Card Number' />);
|
|
16
15
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
17
16
|
|
|
@@ -20,8 +19,7 @@ describe('credit card number input', () => {
|
|
|
20
19
|
expect(input.value).toBe('1234 ____ ____ ____');
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
xit('puts spaces between the numbers', async () => {
|
|
22
|
+
it('puts spaces between the numbers', async () => {
|
|
25
23
|
render(<CreditCardNumberInput label='Card Number' />);
|
|
26
24
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
27
25
|
|
|
@@ -30,8 +28,7 @@ describe('credit card number input', () => {
|
|
|
30
28
|
expect(input.value).toBe('5510 0000 0000 0000');
|
|
31
29
|
});
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
xit('does not allow more characters than required', async () => {
|
|
31
|
+
it('does not allow more characters than required', async () => {
|
|
35
32
|
render(<CreditCardNumberInput label='Card Number' />);
|
|
36
33
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
37
34
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
-
import InputMask
|
|
2
|
+
import InputMask from '@mona-health/react-input-mask';
|
|
3
|
+
import { Props as InputMaskProps } from 'react-input-mask';
|
|
3
4
|
import creditCardType from 'credit-card-type';
|
|
4
5
|
import { FieldProps } from '../Field';
|
|
5
|
-
import {
|
|
6
|
-
CreditCardNumberInputField,
|
|
7
|
-
CreditCardNumberInputFieldProps
|
|
8
|
-
} from './CreditCardNumberInputField';
|
|
6
|
+
import { CreditCardNumberInputField } from './CreditCardNumberInputField';
|
|
9
7
|
|
|
10
8
|
export type CreditCardNumberInputProps = Omit<
|
|
11
9
|
InputMaskProps & FieldProps,
|
|
@@ -61,16 +59,10 @@ export const CreditCardNumberInput: React.FC<CreditCardNumberInputProps> = ({
|
|
|
61
59
|
[setValue, onChange]
|
|
62
60
|
);
|
|
63
61
|
|
|
64
|
-
// TODO: get rid of the any, the types of react-input-mask are incorrect here, it should expect a function as a child, but it expects a ReactNode
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
const renderInputField: any = (inputProps: CreditCardNumberInputFieldProps) => (
|
|
67
|
-
<CreditCardNumberInputField {...rest} {...inputProps} />
|
|
68
|
-
);
|
|
69
|
-
|
|
70
62
|
return (
|
|
71
63
|
<InputMask
|
|
72
64
|
mask={mask}
|
|
73
|
-
|
|
65
|
+
maskPlaceholder={maskChar}
|
|
74
66
|
alwaysShowMask={alwaysShowMask}
|
|
75
67
|
disabled={disabled}
|
|
76
68
|
readOnly={readOnly}
|
|
@@ -80,7 +72,7 @@ export const CreditCardNumberInput: React.FC<CreditCardNumberInputProps> = ({
|
|
|
80
72
|
onFocus={onFocus}
|
|
81
73
|
onBlur={onBlur}
|
|
82
74
|
>
|
|
83
|
-
{
|
|
75
|
+
<CreditCardNumberInputField {...rest} />
|
|
84
76
|
</InputMask>
|
|
85
77
|
);
|
|
86
78
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { States } from 'storybook-states';
|
|
3
2
|
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { States } from '../../utilities';
|
|
4
4
|
import { Textarea } from '../Textarea';
|
|
5
5
|
import { Select } from '../Select';
|
|
6
6
|
import { Field, FieldProps } from './Field';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Prompt, PromptProps } from 'react-router-dom';
|
|
2
3
|
import { usePreventNavigation } from './usePreventNavigation';
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
|
-
message?:
|
|
6
|
+
message?: PromptProps['message'];
|
|
6
7
|
enabled: boolean | undefined;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const NavigationPreventer: React.FC<Props> = ({
|
|
10
|
-
enabled = false
|
|
11
|
-
|
|
11
|
+
enabled = false,
|
|
12
|
+
message = 'Changes that you made may not be saved.'
|
|
12
13
|
}) => {
|
|
13
14
|
usePreventNavigation(enabled);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
return null;
|
|
16
|
+
return <Prompt when={enabled} message={message} />;
|
|
17
17
|
};
|