@moda/om 21.7.1 → 21.8.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/dist/index.cjs.js +50 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +50 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/Field/Field.stories.d.ts +2 -0
- package/dist/src/components/Tabs/TabList.d.ts +1 -0
- package/dist/src/components/Tabs/Tabs.d.ts +1 -0
- package/package.json +52 -52
- package/src/components/Field/Field.stories.tsx +42 -1
- package/src/components/Field/Field.tsx +14 -2
- package/src/components/Tabs/TabList.tsx +15 -9
- package/src/components/Tabs/Tabs.tsx +8 -1
- package/src/components/TextInput/TextInput.tsx +1 -0
|
@@ -4,6 +4,6 @@ import './Field.scss';
|
|
|
4
4
|
export type FieldProps = TextInputProps & {
|
|
5
5
|
children?: JSX.Element;
|
|
6
6
|
};
|
|
7
|
-
export declare const Field: React.ForwardRefExoticComponent<import("
|
|
7
|
+
export declare const Field: React.ForwardRefExoticComponent<import("..").InputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
|
|
8
8
|
children?: JSX.Element;
|
|
9
9
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -6,3 +6,5 @@ export default _default;
|
|
|
6
6
|
export declare const Default: () => React.JSX.Element;
|
|
7
7
|
export declare const AribitraryChildren: () => React.JSX.Element;
|
|
8
8
|
export declare const SelectChildren: () => React.JSX.Element;
|
|
9
|
+
export declare const AccessibilityErrorState: () => React.JSX.Element;
|
|
10
|
+
export declare const AccessibilityDynamicValidation: () => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda/om",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.8.0",
|
|
4
4
|
"description": "Moda Operandi design system",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -53,106 +53,106 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@moda/icons": "^6.
|
|
57
|
-
"@moda/tokens": "^6.
|
|
56
|
+
"@moda/icons": "^6.2.34",
|
|
57
|
+
"@moda/tokens": "^6.6.46",
|
|
58
58
|
"@mona-health/react-input-mask": "^3.0.3",
|
|
59
59
|
"@storybook/addon-styling": "^2.0.0",
|
|
60
60
|
"classnames": "^2.5.1",
|
|
61
|
-
"credit-card-type": "^10.0
|
|
61
|
+
"credit-card-type": "^10.1.0",
|
|
62
62
|
"focus-visible": "^5.2.1",
|
|
63
63
|
"proportional-scale": "^4.0.0",
|
|
64
|
-
"react-focus-on": "^3.10.
|
|
64
|
+
"react-focus-on": "^3.10.2",
|
|
65
65
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
66
|
-
"storybook": "^
|
|
66
|
+
"storybook": "^10.1.11",
|
|
67
67
|
"use-cursor": "^1.2.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@babel/core": "^7.28.
|
|
71
|
-
"@babel/preset-env": "^7.28.
|
|
72
|
-
"@babel/preset-react": "^7.
|
|
73
|
-
"@babel/preset-typescript": "^7.
|
|
74
|
-
"@commitlint/cli": "^20.
|
|
75
|
-
"@commitlint/config-conventional": "^20.
|
|
76
|
-
"@eslint/js": "^9.
|
|
70
|
+
"@babel/core": "^7.28.5",
|
|
71
|
+
"@babel/preset-env": "^7.28.5",
|
|
72
|
+
"@babel/preset-react": "^7.28.5",
|
|
73
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
74
|
+
"@commitlint/cli": "^20.3.0",
|
|
75
|
+
"@commitlint/config-conventional": "^20.3.0",
|
|
76
|
+
"@eslint/js": "^9.39.2",
|
|
77
77
|
"@moda/rollup-plugin-postcss": "^4.0.1",
|
|
78
|
-
"@rollup/plugin-babel": "^6.0
|
|
78
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
79
79
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
80
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
81
|
-
"@storybook/addon-links": "^
|
|
80
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
81
|
+
"@storybook/addon-links": "^10.1.11",
|
|
82
82
|
"@storybook/addon-postcss": "^2.0.0",
|
|
83
83
|
"@storybook/addon-webpack5-compiler-babel": "^4.0.0",
|
|
84
84
|
"@storybook/addons": "^7.6.17",
|
|
85
|
-
"@storybook/react": "^
|
|
86
|
-
"@storybook/react-webpack5": "^
|
|
87
|
-
"@testing-library/jest-dom": "^6.
|
|
88
|
-
"@testing-library/react": "^16.3.
|
|
85
|
+
"@storybook/react": "^10.1.11",
|
|
86
|
+
"@storybook/react-webpack5": "^10.1.11",
|
|
87
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
88
|
+
"@testing-library/react": "^16.3.1",
|
|
89
89
|
"@testing-library/user-event": "^14.6.1",
|
|
90
|
-
"@types/chai": "^5.2.
|
|
90
|
+
"@types/chai": "^5.2.3",
|
|
91
91
|
"@types/cheerio": "^1.0.0",
|
|
92
92
|
"@types/classnames": "^2.3.4",
|
|
93
93
|
"@types/credit-card-type": "^9.0.3",
|
|
94
94
|
"@types/jest": "^30.0.0",
|
|
95
|
-
"@types/ramda": "^0.31.
|
|
96
|
-
"@types/react": "^19.
|
|
97
|
-
"@types/react-dom": "^19.
|
|
95
|
+
"@types/ramda": "^0.31.1",
|
|
96
|
+
"@types/react": "^19.2.7",
|
|
97
|
+
"@types/react-dom": "^19.2.3",
|
|
98
98
|
"@types/react-input-mask": "^3.0.6",
|
|
99
99
|
"@types/react-router-dom": "^5.3.3",
|
|
100
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
101
|
-
"@typescript-eslint/parser": "^8.
|
|
102
|
-
"autoprefixer": "^10.4.
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "^8.52.0",
|
|
101
|
+
"@typescript-eslint/parser": "^8.52.0",
|
|
102
|
+
"autoprefixer": "^10.4.23",
|
|
103
103
|
"babel-loader": "^10.0.0",
|
|
104
104
|
"commitizen": "^4.3.1",
|
|
105
105
|
"css-loader": "^7.1.2",
|
|
106
106
|
"cz-conventional-changelog": "^3.3.0",
|
|
107
|
-
"eslint": "^9.
|
|
108
|
-
"eslint-config-prettier": "^10.1.
|
|
107
|
+
"eslint": "^9.39.2",
|
|
108
|
+
"eslint-config-prettier": "^10.1.8",
|
|
109
109
|
"eslint-plugin-import": "^2.32.0",
|
|
110
110
|
"eslint-plugin-jest-dom": "^5.5.0",
|
|
111
111
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
112
112
|
"eslint-plugin-no-loops": "^0.4.0",
|
|
113
113
|
"eslint-plugin-node": "^11.1.0",
|
|
114
|
-
"eslint-plugin-prettier": "^5.5.
|
|
114
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
115
115
|
"eslint-plugin-promise": "^7.2.1",
|
|
116
116
|
"eslint-plugin-react": "^7.37.5",
|
|
117
|
-
"eslint-plugin-react-hooks": "^7.0.
|
|
117
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
118
118
|
"eslint-plugin-standard": "^5.0.0",
|
|
119
|
-
"eslint-plugin-testing-library": "^7.
|
|
120
|
-
"globals": "^
|
|
119
|
+
"eslint-plugin-testing-library": "^7.15.4",
|
|
120
|
+
"globals": "^17.0.0",
|
|
121
121
|
"husky": "^9.1.7",
|
|
122
122
|
"identity-obj-proxy": "^3.0.0",
|
|
123
123
|
"ignore-not-found-export-webpack-plugin": "^1.0.2",
|
|
124
|
-
"jest": "^30.0
|
|
125
|
-
"jest-environment-jsdom": "^30.0
|
|
124
|
+
"jest": "^30.2.0",
|
|
125
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
126
126
|
"jest-matchmedia-mock": "^1.1.0",
|
|
127
|
-
"lint-staged": "^16.
|
|
127
|
+
"lint-staged": "^16.2.7",
|
|
128
128
|
"node-sass-package-importer": "^5.3.3",
|
|
129
129
|
"pinst": "^3.0.0",
|
|
130
130
|
"postcss": "^8.5.6",
|
|
131
|
-
"postcss-loader": "^8.
|
|
132
|
-
"prettier": "^3.
|
|
131
|
+
"postcss-loader": "^8.2.0",
|
|
132
|
+
"prettier": "^3.7.4",
|
|
133
133
|
"ramda": "^0.32.0",
|
|
134
|
-
"react": "^19.
|
|
135
|
-
"react-dom": "^19.
|
|
134
|
+
"react": "^19.2.3",
|
|
135
|
+
"react-dom": "^19.2.3",
|
|
136
136
|
"react-router-dom": "^5.1.2",
|
|
137
|
-
"rollup": "^4.
|
|
137
|
+
"rollup": "^4.55.1",
|
|
138
138
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
139
139
|
"rollup-plugin-scss": "^4.0.1",
|
|
140
|
-
"sass": "^1.
|
|
141
|
-
"sass-loader": "^16.0.
|
|
142
|
-
"semantic-release": "^25.0.
|
|
143
|
-
"semantic-release-npm-github": "^
|
|
140
|
+
"sass": "^1.97.2",
|
|
141
|
+
"sass-loader": "^16.0.6",
|
|
142
|
+
"semantic-release": "^25.0.2",
|
|
143
|
+
"semantic-release-npm-github": "^6.0.0",
|
|
144
144
|
"style-loader": "^4.0.0",
|
|
145
|
-
"ts-jest": "^29.4.
|
|
146
|
-
"typescript": "^5.
|
|
147
|
-
"typescript-eslint": "^8.
|
|
145
|
+
"ts-jest": "^29.4.6",
|
|
146
|
+
"typescript": "^5.9.3",
|
|
147
|
+
"typescript-eslint": "^8.52.0",
|
|
148
148
|
"waait": "^1.0.5",
|
|
149
|
-
"webpack": "^5.
|
|
149
|
+
"webpack": "^5.104.1",
|
|
150
150
|
"webpack-cli": "^6.0.1"
|
|
151
151
|
},
|
|
152
152
|
"overrides": {
|
|
153
|
-
"@types/react": "^19.
|
|
154
|
-
"react": "^19.
|
|
155
|
-
"react-dom": "^19.
|
|
153
|
+
"@types/react": "^19.2.7",
|
|
154
|
+
"react": "^19.2.3",
|
|
155
|
+
"react-dom": "^19.2.3"
|
|
156
156
|
},
|
|
157
157
|
"config": {
|
|
158
158
|
"commitizen": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { action } from 'storybook/actions';
|
|
3
3
|
import { States } from '../../utilities';
|
|
4
4
|
import { Textarea } from '../Textarea';
|
|
@@ -75,3 +75,44 @@ export const SelectChildren = () => {
|
|
|
75
75
|
</States>
|
|
76
76
|
);
|
|
77
77
|
};
|
|
78
|
+
|
|
79
|
+
export const AccessibilityErrorState = () => (
|
|
80
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '300px' }}>
|
|
81
|
+
<Field
|
|
82
|
+
label='Email address'
|
|
83
|
+
placeholder='Enter your email'
|
|
84
|
+
error='Please enter a valid email address'
|
|
85
|
+
defaultValue='invalid-email'
|
|
86
|
+
/>
|
|
87
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
88
|
+
Inspect the input to see: aria-invalid="true", aria-describedby linking to the
|
|
89
|
+
error, and role="alert" on the error message for screen reader announcements.
|
|
90
|
+
</p>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export const AccessibilityDynamicValidation = () => {
|
|
95
|
+
const [value, setValue] = useState('');
|
|
96
|
+
const [touched, setTouched] = useState(false);
|
|
97
|
+
|
|
98
|
+
const isValidEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
99
|
+
const error =
|
|
100
|
+
touched && value && !isValidEmail(value) ? 'Please enter a valid email address' : undefined;
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '300px' }}>
|
|
104
|
+
<Field
|
|
105
|
+
label='Email address'
|
|
106
|
+
placeholder='Enter your email'
|
|
107
|
+
error={error}
|
|
108
|
+
value={value}
|
|
109
|
+
onChange={setValue}
|
|
110
|
+
onBlur={() => setTouched(true)}
|
|
111
|
+
/>
|
|
112
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
113
|
+
Type an invalid email and blur the field. Screen readers will announce the error via
|
|
114
|
+
role="alert" when it appears.
|
|
115
|
+
</p>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { JSX, useMemo } from 'react';
|
|
1
|
+
import React, { JSX, useId, useMemo } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import WarningIcon from '@moda/icons/warning-16';
|
|
4
4
|
import { TextInput, TextInputProps } from '../TextInput';
|
|
@@ -16,8 +16,14 @@ export const Field = React.forwardRef(
|
|
|
16
16
|
{ className, children, error, label, placeholder, ...rest }: FieldProps,
|
|
17
17
|
ref: React.Ref<HTMLInputElement>
|
|
18
18
|
) => {
|
|
19
|
+
const id = useId();
|
|
20
|
+
const errorId = `${id}-error`;
|
|
19
21
|
const fieldContextValue = useMemo(() => ({ displaysError: Boolean(error) }), [error]);
|
|
20
22
|
|
|
23
|
+
// Combine any existing aria-describedby with our error ID
|
|
24
|
+
const ariaDescribedBy =
|
|
25
|
+
[rest['aria-describedby'], error ? errorId : null].filter(Boolean).join(' ') || undefined;
|
|
26
|
+
|
|
21
27
|
return (
|
|
22
28
|
<FormControlContext.Provider value={fieldContextValue}>
|
|
23
29
|
<label className={classNames('Field', className)}>
|
|
@@ -33,6 +39,7 @@ export const Field = React.forwardRef(
|
|
|
33
39
|
placeholder,
|
|
34
40
|
label,
|
|
35
41
|
shiftIconLeftwards: error && children.type === Select,
|
|
42
|
+
'aria-describedby': ariaDescribedBy,
|
|
36
43
|
...rest,
|
|
37
44
|
...children.props
|
|
38
45
|
})}
|
|
@@ -50,6 +57,7 @@ export const Field = React.forwardRef(
|
|
|
50
57
|
placeholder={placeholder}
|
|
51
58
|
label={label}
|
|
52
59
|
error={error}
|
|
60
|
+
aria-describedby={ariaDescribedBy}
|
|
53
61
|
{...rest}
|
|
54
62
|
/>
|
|
55
63
|
{error && (
|
|
@@ -61,7 +69,11 @@ export const Field = React.forwardRef(
|
|
|
61
69
|
)}
|
|
62
70
|
</span>
|
|
63
71
|
|
|
64
|
-
{error &&
|
|
72
|
+
{error && (
|
|
73
|
+
<span id={errorId} className='Field__error' role='alert'>
|
|
74
|
+
{error}
|
|
75
|
+
</span>
|
|
76
|
+
)}
|
|
65
77
|
</label>
|
|
66
78
|
</FormControlContext.Provider>
|
|
67
79
|
);
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
import { Tab } from './Tab';
|
|
4
|
+
|
|
3
5
|
import './TabList.scss';
|
|
4
6
|
|
|
5
7
|
export type TabListProps = {
|
|
6
8
|
tabs: Tab[];
|
|
7
9
|
onTabSelected(tabName: string): void;
|
|
8
10
|
activePanel: string;
|
|
11
|
+
className?: string;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
|
-
export const TabList: React.FC<TabListProps> = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
export const TabList: React.FC<TabListProps> = ({
|
|
15
|
+
tabs,
|
|
16
|
+
onTabSelected,
|
|
17
|
+
activePanel,
|
|
18
|
+
className
|
|
19
|
+
}) => (
|
|
20
|
+
<div className={classNames('TabList', className)}>
|
|
21
|
+
{tabs.map(tab => (
|
|
22
|
+
<Tab key={tab.name} tab={tab} onTabChosen={onTabSelected} activeTab={activePanel} />
|
|
23
|
+
))}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
@@ -10,6 +10,7 @@ export type TabsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
10
10
|
onTabClicked?: (tabName: string) => void;
|
|
11
11
|
defaultActiveTab?: string;
|
|
12
12
|
activeTab?: string;
|
|
13
|
+
tabListClassName?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export const Tabs: React.FC<TabsProps> = ({
|
|
@@ -18,6 +19,7 @@ export const Tabs: React.FC<TabsProps> = ({
|
|
|
18
19
|
defaultActiveTab,
|
|
19
20
|
activeTab,
|
|
20
21
|
className,
|
|
22
|
+
tabListClassName,
|
|
21
23
|
...rest
|
|
22
24
|
}) => {
|
|
23
25
|
const [activePanel, setActivePanel] = useState(activeTab || defaultActiveTab || tabs[0].name);
|
|
@@ -33,7 +35,12 @@ export const Tabs: React.FC<TabsProps> = ({
|
|
|
33
35
|
|
|
34
36
|
return (
|
|
35
37
|
<div className={classNames('Tabs', className)} {...rest}>
|
|
36
|
-
<TabList
|
|
38
|
+
<TabList
|
|
39
|
+
tabs={tabs}
|
|
40
|
+
onTabSelected={handleTabClick}
|
|
41
|
+
activePanel={activePanel}
|
|
42
|
+
className={tabListClassName}
|
|
43
|
+
/>
|
|
37
44
|
<TabPanels panels={tabs} activePanel={activePanel} />
|
|
38
45
|
</div>
|
|
39
46
|
);
|