@moda/om 16.2.0 → 17.0.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/CHANGELOG.md +26 -0
- package/dist/index.cjs.js +349 -299
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +348 -298
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Expandable/Expandable.d.ts +1 -0
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/src/components/Select/SelectOption.d.ts +1 -0
- package/dist/src/components/Select/SelectOptions.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +18 -8
- package/src/components/AspectRatioBox/AspectRatioBox.tsx +4 -4
- package/src/components/AspectRatioBox/index.ts +1 -1
- package/src/components/Badge/Badge.stories.tsx +5 -5
- package/src/components/Badge/Badge.test.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumb/Breadcrumb.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Breakpoint/Breakpoint.stories.tsx +10 -9
- package/src/components/Breakpoint/Breakpoint.test.tsx +2 -2
- package/src/components/Breakpoint/generateMediaQuery.ts +5 -4
- package/src/components/Button/Button.stories.tsx +4 -4
- package/src/components/Checkbox/Checkbox.stories.tsx +5 -5
- package/src/components/Checkbox/Checkbox.test.tsx +3 -3
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Clickable/Clickable.stories.tsx +3 -3
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +11 -11
- package/src/components/ColorSwatch/ColorSwatch.test.tsx +1 -1
- package/src/components/ColorSwatch/ColorSwatch.tsx +1 -1
- package/src/components/Constrain/Constrain.stories.tsx +1 -1
- package/src/components/Constrain/ExceedConstrain.stories.tsx +2 -2
- package/src/components/ControlLink/ControlLink.stories.tsx +1 -1
- package/src/components/ControlLink/index.ts +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +4 -4
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +1 -0
- package/src/components/DefinitionList/DefinitionList.stories.tsx +3 -3
- package/src/components/DefinitionList/DefinitionList.test.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +4 -4
- package/src/components/Divider/Divider.test.tsx +1 -1
- package/src/components/Divider/Divider.tsx +1 -1
- package/src/components/Divider/NoLineDivider.tsx +1 -1
- package/src/components/Divider/TwoLineDivider.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +8 -8
- package/src/components/Expandable/Expandable.test.tsx +1 -1
- package/src/components/Expandable/Expandable.tsx +12 -5
- package/src/components/Field/Field.stories.tsx +4 -4
- package/src/components/Field/Field.test.tsx +7 -7
- package/src/components/Field/Field.tsx +5 -5
- package/src/components/Field/index.ts +1 -0
- package/src/components/Loading/Loading.test.tsx +1 -1
- package/src/components/Loading/Loading.tsx +2 -1
- package/src/components/Modal/Modal.test.tsx +2 -2
- package/src/components/ModalOverlay/ModalOverlay.test.tsx +2 -2
- package/src/components/ModalOverlay/ModalOverlay.tsx +2 -2
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- package/src/components/Paginator/Paginator.tsx +3 -3
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.tsx +6 -6
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +10 -7
- package/src/components/PromoBanner/PromoBanner.stories.tsx +9 -9
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +2 -2
- package/src/components/RadioButton/RadioButton.tsx +4 -4
- package/src/components/SearchInput/SearchInput.stories.tsx +2 -2
- package/src/components/SearchInput/SearchInput.test.tsx +1 -1
- package/src/components/SearchInput/SearchInput.tsx +3 -3
- package/src/components/Select/MultiSelect.tsx +7 -7
- package/src/components/Select/Select.stories.tsx +15 -14
- package/src/components/Select/Select.test.tsx +13 -13
- package/src/components/Select/Select.tsx +11 -7
- package/src/components/Select/SelectOption.tsx +5 -2
- package/src/components/Select/SelectOptions.tsx +8 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/Shape/ArcWindow.tsx +10 -10
- package/src/components/Shape/Bradley.tsx +4 -4
- package/src/components/Shape/Brancusi.tsx +4 -4
- package/src/components/Shape/Circle.tsx +10 -10
- package/src/components/Shape/Diamond.tsx +10 -10
- package/src/components/Shape/Keyhole.tsx +4 -4
- package/src/components/Shape/Mirror.tsx +4 -4
- package/src/components/Shape/Oval.tsx +4 -4
- package/src/components/Shape/Triangle.tsx +7 -7
- package/src/components/Shape/Window.tsx +4 -4
- package/src/components/Stack/Stack.stories.tsx +3 -3
- package/src/components/Stack/Stack.test.tsx +1 -1
- package/src/components/Tabs/TabList.tsx +1 -1
- package/src/components/Tabs/TabPanel.tsx +1 -1
- package/src/components/Tabs/TabPanels.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +2 -2
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +7 -1
- package/src/components/Tag/Tag.tsx +6 -5
- package/src/components/Text/Text.stories.tsx +5 -5
- package/src/components/Text/Text.test.tsx +1 -1
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/TextInput/TextInput.test.tsx +1 -1
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.test.tsx +3 -3
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/Toast/Toast.test.tsx +1 -1
- package/src/components/Toast/Toast.tsx +6 -6
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +3 -3
- package/src/components/VerticalDivider/VerticalDivider.test.tsx +2 -2
- package/src/hooks/useKeyboardListNavigation.spec.ts +2 -1
- package/src/hooks/useKeyboardListNavigation.ts +2 -0
- package/src/hooks/useUpdateEffect.ts +1 -0
- package/src/index.ts +2 -2
- package/src/mixins/font-smoothing/font-smoothing.stories.tsx +8 -8
- package/src/mixins/overflow-scroll/overflow-scroll.stories.tsx +2 -2
- package/src/mixins/stack/stack.stories.tsx +5 -6
- package/src/mixins/thin-underline/thin-underline.stories.tsx +1 -1
- package/src/mixins/visually-hidden/visually-hidden.stories.tsx +1 -1
- package/src/utilities/States/State.tsx +3 -2
- package/src/utilities/States/States.tsx +4 -3
- package/src/utilities/States/StatesProps.tsx +5 -2
- package/src/utilities/States/isRenderProps.ts +1 -0
- package/src/utilities/States/stringifyProps.tsx +1 -0
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
|
|
4
4
|
import { States } from 'storybook-states';
|
|
5
|
-
import { SelectableButton, SelectableButtonProps } from './SelectableButton';
|
|
6
5
|
import { Stack } from '../Stack';
|
|
6
|
+
import { SelectableButton, SelectableButtonProps } from './SelectableButton';
|
|
7
7
|
|
|
8
8
|
export default { title: 'Components/SelectableButton' };
|
|
9
9
|
|
|
@@ -3,18 +3,18 @@ import { ShapeProps } from './Shape';
|
|
|
3
3
|
|
|
4
4
|
export const ArcWindow: React.FC<ShapeProps> = () => (
|
|
5
5
|
<svg
|
|
6
|
-
className=
|
|
7
|
-
width=
|
|
8
|
-
height=
|
|
9
|
-
viewBox=
|
|
10
|
-
fill=
|
|
11
|
-
xmlns=
|
|
6
|
+
className="ArcWindow"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
13
|
<path
|
|
14
|
-
fillRule=
|
|
15
|
-
clipRule=
|
|
16
|
-
d=
|
|
17
|
-
fill=
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M20.1097 24V11.6273V8.8331V8.81993C20.1018 3.96884 16.4806 0 12.0536 0C7.6291 0 4.00527 3.96884 4 8.81993V8.8331V11.6273V24H20.1097Z"
|
|
17
|
+
fill="#003728"
|
|
18
18
|
/>
|
|
19
19
|
</svg>
|
|
20
20
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Bradley: React.FC<ShapeProps> =
|
|
4
|
+
export const Bradley: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 110 211"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M110 .336H0v210h45.11v-52.595h19.78v52.595H110V105.147z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Brancusi: React.FC<ShapeProps> =
|
|
4
|
+
export const Brancusi: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 111 210"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M110.575 210l-27.5-105 27.5-105h-110l27.501 105L.575 210z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -3,18 +3,18 @@ import { ShapeProps } from './Shape';
|
|
|
3
3
|
|
|
4
4
|
export const Circle: React.FC<ShapeProps> = () => (
|
|
5
5
|
<svg
|
|
6
|
-
className=
|
|
7
|
-
width=
|
|
8
|
-
height=
|
|
9
|
-
viewBox=
|
|
10
|
-
fill=
|
|
11
|
-
xmlns=
|
|
6
|
+
className="Circle"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
13
|
<path
|
|
14
|
-
fillRule=
|
|
15
|
-
clipRule=
|
|
16
|
-
d=
|
|
17
|
-
fill=
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M24 12C24 18.6282 18.6282 24 12 24C5.37184 24 0 18.6282 0 12C0 5.37184 5.37184 0 12 0C18.6282 0 24 5.37184 24 12Z"
|
|
17
|
+
fill="#D7B3D0"
|
|
18
18
|
/>
|
|
19
19
|
</svg>
|
|
20
20
|
);
|
|
@@ -3,18 +3,18 @@ import { ShapeProps } from './Shape';
|
|
|
3
3
|
|
|
4
4
|
export const Diamond: React.FC<ShapeProps> = () => (
|
|
5
5
|
<svg
|
|
6
|
-
className=
|
|
7
|
-
width=
|
|
8
|
-
height=
|
|
9
|
-
viewBox=
|
|
10
|
-
fill=
|
|
11
|
-
xmlns=
|
|
6
|
+
className="Diamond"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
13
|
<path
|
|
14
|
-
fillRule=
|
|
15
|
-
clipRule=
|
|
16
|
-
d=
|
|
17
|
-
fill=
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M12 24.0026L0 12.0026L12 0L24 12.0026L12 24.0026Z"
|
|
17
|
+
fill="#C44CB0"
|
|
18
18
|
/>
|
|
19
19
|
</svg>
|
|
20
20
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Keyhole: React.FC<ShapeProps> =
|
|
4
|
+
export const Keyhole: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 111 210"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M.8 210h110V86.403h-9.317c5.88-8.833 9.317-19.46 9.317-30.902C110.8 24.85 86.175 0 55.8 0S.8 24.85.8 55.501c0 11.441 3.436 22.069 9.315 30.902H.8V210z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Mirror: React.FC<ShapeProps> =
|
|
4
|
+
export const Mirror: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 111 210"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M110.03 105c0-22.7-3.786-43.7-10.2-60.874V15.97H84.176C75.724 5.862 65.739 0 55.03 0 44.323 0 34.336 5.862 25.885 15.969H10.23v28.157C3.817 61.3.03 82.3.03 105c0 22.7 3.787 43.7 10.2 60.874v28.157h15.655C34.336 204.138 44.323 210 55.03 210c10.708 0 20.693-5.862 29.146-15.969h15.652v-28.157C106.244 148.7 110.03 127.7 110.03 105z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Oval: React.FC<ShapeProps> =
|
|
4
|
+
export const Oval: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 110 210"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M110 105C110 47.01 85.376 0 55 0S0 47.01 0 105s24.624 105 55 105 55-47.01 55-105z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -3,13 +3,13 @@ import { ShapeProps } from './Shape';
|
|
|
3
3
|
|
|
4
4
|
export const Triangle: React.FC<ShapeProps> = () => (
|
|
5
5
|
<svg
|
|
6
|
-
className=
|
|
7
|
-
width=
|
|
8
|
-
height=
|
|
9
|
-
viewBox=
|
|
10
|
-
fill=
|
|
11
|
-
xmlns=
|
|
6
|
+
className="Triangle"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
|
-
<path fillRule=
|
|
13
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M11.9986 0L0 24H24L11.9986 0Z" fill="#D56B27" />
|
|
14
14
|
</svg>
|
|
15
15
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShapeProps } from './Shape';
|
|
3
3
|
|
|
4
|
-
export const Window: React.FC<ShapeProps> =
|
|
4
|
+
export const Window: React.FC<ShapeProps> = props => (
|
|
5
5
|
<svg
|
|
6
6
|
style={{ fill: 'currentcolor' }}
|
|
7
|
-
xmlns=
|
|
8
|
-
viewBox=
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
viewBox="0 0 110 210"
|
|
9
9
|
{...props}
|
|
10
10
|
>
|
|
11
|
-
<path d=
|
|
11
|
+
<path d="M110 187.673V21.948H98.87C88.873 8.64 73.08 0 55.247 0 37.412 0 21.619 8.64 11.622 21.948H0v165.725h11.34C21.32 201.198 37.245 210 55.248 210c18 0 33.924-8.802 43.904-22.327H110z" />
|
|
12
12
|
</svg>
|
|
13
13
|
);
|
|
@@ -6,7 +6,7 @@ import { Stack, StackProps } from './Stack';
|
|
|
6
6
|
export default { title: 'Components/Stack' };
|
|
7
7
|
|
|
8
8
|
export const Vertical = () => (
|
|
9
|
-
<States<StackProps> states={space.scale.map((_,
|
|
9
|
+
<States<StackProps> states={space.scale.map((_, index) => ({ space: index }))}>
|
|
10
10
|
<Stack space={0}>
|
|
11
11
|
<div style={{ backgroundColor: 'yellow' }}>One</div>
|
|
12
12
|
<div style={{ backgroundColor: 'yellow' }}>Two</div>
|
|
@@ -17,8 +17,8 @@ export const Vertical = () => (
|
|
|
17
17
|
|
|
18
18
|
export const Horizontal = () => (
|
|
19
19
|
<States<StackProps>
|
|
20
|
-
states={space.scale.map((_,
|
|
21
|
-
space:
|
|
20
|
+
states={space.scale.map((_, index) => ({
|
|
21
|
+
space: index,
|
|
22
22
|
direction: 'horizontal'
|
|
23
23
|
}))}
|
|
24
24
|
>
|
|
@@ -10,7 +10,7 @@ export type TabListProps = {
|
|
|
10
10
|
|
|
11
11
|
export const TabList: React.FC<TabListProps> = ({ tabs, onTabSelected, activePanel }) => {
|
|
12
12
|
return (
|
|
13
|
-
<div className=
|
|
13
|
+
<div className="TabList">
|
|
14
14
|
{tabs.map(tab => (
|
|
15
15
|
<Tab key={tab.name} tab={tab} onTabChosen={onTabSelected} activeTab={activePanel} />
|
|
16
16
|
))}
|
|
@@ -9,7 +9,7 @@ export type TabPanelsProps = {
|
|
|
9
9
|
|
|
10
10
|
export const TabPanels: React.FC<TabPanelsProps> = ({ panels, activePanel }) => {
|
|
11
11
|
return (
|
|
12
|
-
<div className=
|
|
12
|
+
<div className="TabPanels">
|
|
13
13
|
{panels
|
|
14
14
|
.filter(tab => tab.name === activePanel)
|
|
15
15
|
.map(tab => (
|
|
@@ -47,9 +47,9 @@ export const WithCallback = () => {
|
|
|
47
47
|
return (
|
|
48
48
|
<States<TabsProps>>
|
|
49
49
|
<>
|
|
50
|
-
<Text treatment=
|
|
50
|
+
<Text treatment="h5">Selected Tab:</Text>
|
|
51
51
|
<Text> {tabName} </Text>
|
|
52
|
-
<Tabs tabs={TAB_LIST} onTabClicked={handleTabClick} activeTab="tab2"/>
|
|
52
|
+
<Tabs tabs={TAB_LIST} onTabClicked={handleTabClick} activeTab="tab2" />
|
|
53
53
|
</>
|
|
54
54
|
</States>
|
|
55
55
|
);
|
|
@@ -8,12 +8,12 @@ describe('Tabs', () => {
|
|
|
8
8
|
{
|
|
9
9
|
name: 'tab1',
|
|
10
10
|
title: 'Tab 1',
|
|
11
|
-
panel: <div className=
|
|
11
|
+
panel: <div className="test">I am a panel</div>
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
name: 'tab2',
|
|
15
15
|
title: 'Tab 2',
|
|
16
|
-
panel: <div className=
|
|
16
|
+
panel: <div className="test">I am also a panel</div>
|
|
17
17
|
}
|
|
18
18
|
];
|
|
19
19
|
|
|
@@ -9,7 +9,13 @@ export type TabsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
9
9
|
activeTab?: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const Tabs: React.FC<TabsProps> = ({
|
|
12
|
+
export const Tabs: React.FC<TabsProps> = ({
|
|
13
|
+
tabs,
|
|
14
|
+
onTabClicked,
|
|
15
|
+
activeTab,
|
|
16
|
+
className,
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
13
19
|
const [activePanel, setActivePanel] = useState(activeTab || tabs[0].name);
|
|
14
20
|
const handleTabClick = (tabName: string) => {
|
|
15
21
|
setActivePanel(tabName);
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { Clickable } from '../Clickable';
|
|
4
3
|
import ExitIcon from '@moda/icons/exit-16';
|
|
4
|
+
import { Clickable } from '../Clickable';
|
|
5
5
|
import './Tag.scss';
|
|
6
6
|
|
|
7
|
-
export type TagProps = {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type TagProps = {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onRemove?: () => void;
|
|
10
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
10
11
|
|
|
11
12
|
export const Tag: React.FC<TagProps> = ({ className, disabled, onRemove, children, ...rest }) => (
|
|
12
13
|
<div className={classNames('Tag', className, { 'Tag--disabled': disabled })} {...rest}>
|
|
13
14
|
<div>{children}</div>
|
|
14
15
|
{onRemove && (
|
|
15
|
-
<Clickable disabled={disabled} aria-label=
|
|
16
|
+
<Clickable disabled={disabled} aria-label="Remove" onClick={onRemove}>
|
|
16
17
|
<ExitIcon />
|
|
17
18
|
</Clickable>
|
|
18
19
|
)}
|
|
@@ -23,24 +23,24 @@ export const Treatments = () => (
|
|
|
23
23
|
|
|
24
24
|
export const Colors = () => (
|
|
25
25
|
<States<Partial<TextProps>> states={COLORS}>
|
|
26
|
-
<Text treatment=
|
|
26
|
+
<Text treatment="h5">Moda Operandi</Text>
|
|
27
27
|
</States>
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
export const Families = () => (
|
|
31
31
|
<States<Partial<TextProps>> states={FAMILIES}>
|
|
32
|
-
<Text treatment=
|
|
32
|
+
<Text treatment="h5">Moda Operandi</Text>
|
|
33
33
|
</States>
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
export const Complex = () => (
|
|
37
37
|
<Text>
|
|
38
|
-
<Text treatment=
|
|
38
|
+
<Text treatment="h6" color="fuchsia" family="serif">
|
|
39
39
|
Moda Operandi
|
|
40
40
|
</Text>
|
|
41
41
|
{' — '}
|
|
42
|
-
<Text color=
|
|
43
|
-
Happy <Text color=
|
|
42
|
+
<Text color="money-good" treatment="eyebrow">
|
|
43
|
+
Happy <Text color="code-red">Holidays</Text>
|
|
44
44
|
</Text>
|
|
45
45
|
</Text>
|
|
46
46
|
);
|
|
@@ -5,7 +5,7 @@ import { TextInput } from './TextInput';
|
|
|
5
5
|
|
|
6
6
|
describe('TextInput', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
render(<TextInput placeholder=
|
|
8
|
+
render(<TextInput placeholder="Hello" />);
|
|
9
9
|
expect(screen.getByRole('textbox')).toHaveValue('');
|
|
10
10
|
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Hello');
|
|
11
11
|
});
|
|
@@ -5,14 +5,14 @@ import { Textarea } from './Textarea';
|
|
|
5
5
|
|
|
6
6
|
describe('Textarea', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
render(<Textarea placeholder=
|
|
8
|
+
render(<Textarea placeholder="Placeholder" defaultValue="Hello" />);
|
|
9
9
|
|
|
10
10
|
expect(screen.getByRole('textbox')).toHaveValue('Hello');
|
|
11
11
|
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Placeholder');
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('renders with an error', () => {
|
|
15
|
-
render(<Textarea placeholder=
|
|
15
|
+
render(<Textarea placeholder="Placeholder" defaultValue="Hello" label="Label" error="Error" />);
|
|
16
16
|
|
|
17
17
|
expect(screen.getByRole('textbox')).toHaveValue('Hello');
|
|
18
18
|
expect(screen.getByRole('textbox')).toHaveClass('Textarea--error');
|
|
@@ -20,7 +20,7 @@ describe('Textarea', () => {
|
|
|
20
20
|
|
|
21
21
|
it('renders with a className', () => {
|
|
22
22
|
render(
|
|
23
|
-
<Textarea className=
|
|
23
|
+
<Textarea className="Custom" placeholder="Placeholder" defaultValue="Hello" label="Label" />
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
expect(screen.getByRole('textbox')).toHaveValue('Hello');
|
|
@@ -7,7 +7,7 @@ export default { title: 'Components/Toast' };
|
|
|
7
7
|
|
|
8
8
|
export const Default = () => (
|
|
9
9
|
<States<ToastProps> states={[{ theme: 'success' }, { theme: 'warning' }, { theme: 'error' }]}>
|
|
10
|
-
<Toast theme=
|
|
10
|
+
<Toast theme="success" onRemove={() => action('removed')}>
|
|
11
11
|
This is a toast notification.
|
|
12
12
|
</Toast>
|
|
13
13
|
</States>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import ExitIcon from '@moda/icons/exit-16';
|
|
3
4
|
import { Clickable } from '../Clickable';
|
|
4
5
|
import { Text } from '../Text';
|
|
5
6
|
import { Stack, StackProps } from '../Stack';
|
|
6
|
-
import ExitIcon from '@moda/icons/exit-16';
|
|
7
7
|
import './Toast.scss';
|
|
8
8
|
|
|
9
9
|
export type ToastProps = {
|
|
@@ -14,17 +14,17 @@ export type ToastProps = {
|
|
|
14
14
|
export const Toast: React.FC<ToastProps> = ({ theme, className, onRemove, children, ...rest }) => (
|
|
15
15
|
<Stack
|
|
16
16
|
className={classNames('Toast', `Toast--${theme}`, className)}
|
|
17
|
-
direction=
|
|
17
|
+
direction="horizontal"
|
|
18
18
|
space={2}
|
|
19
|
-
alignItems=
|
|
20
|
-
justifyContent=
|
|
19
|
+
alignItems="center"
|
|
20
|
+
justifyContent="space-between"
|
|
21
21
|
{...rest}
|
|
22
22
|
>
|
|
23
|
-
<Text treatment=
|
|
23
|
+
<Text treatment="bold1" color="snow">
|
|
24
24
|
{children}
|
|
25
25
|
</Text>
|
|
26
26
|
{onRemove && (
|
|
27
|
-
<Clickable aria-label=
|
|
27
|
+
<Clickable aria-label="Remove" onClick={onRemove}>
|
|
28
28
|
<ExitIcon />
|
|
29
29
|
</Clickable>
|
|
30
30
|
)}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
-
import { VerticalDivider } from './VerticalDivider';
|
|
5
4
|
import { Stack } from '../Stack';
|
|
5
|
+
import { VerticalDivider } from './VerticalDivider';
|
|
6
6
|
|
|
7
7
|
export default { title: 'Components/VerticalDivider' };
|
|
8
8
|
|
|
9
9
|
export const Default = () => (
|
|
10
10
|
<States>
|
|
11
|
-
<Stack direction=
|
|
11
|
+
<Stack direction="horizontal" space={4}>
|
|
12
12
|
<div> Lorem ipsum dolor sit amet</div>
|
|
13
13
|
|
|
14
14
|
<VerticalDivider />
|
|
@@ -20,7 +20,7 @@ export const Default = () => (
|
|
|
20
20
|
|
|
21
21
|
export const Double = () => (
|
|
22
22
|
<States>
|
|
23
|
-
<Stack direction=
|
|
23
|
+
<Stack direction="horizontal" space={4}>
|
|
24
24
|
<div> Lorem ipsum dolor sit amet</div>
|
|
25
25
|
|
|
26
26
|
<VerticalDivider double />
|
|
@@ -5,13 +5,13 @@ import { VerticalDivider } from './VerticalDivider';
|
|
|
5
5
|
|
|
6
6
|
describe('VerticalDivider', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
render(<VerticalDivider aria-label=
|
|
8
|
+
render(<VerticalDivider aria-label="Divider" />);
|
|
9
9
|
|
|
10
10
|
expect(screen.getByLabelText('Divider')).toBeVisible();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('renders correctly - double', () => {
|
|
14
|
-
render(<VerticalDivider aria-label=
|
|
14
|
+
render(<VerticalDivider aria-label="Divider" double />);
|
|
15
15
|
|
|
16
16
|
expect(screen.getByLabelText('Divider')).toBeVisible();
|
|
17
17
|
expect(screen.getByLabelText('Divider')).toHaveClass('VerticalDivider--double');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
1
2
|
import { renderHook, fireEvent } from '@testing-library/react';
|
|
2
|
-
import { useKeyboardListNavigation } from './useKeyboardListNavigation';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
|
+
import { useKeyboardListNavigation } from './useKeyboardListNavigation';
|
|
4
5
|
|
|
5
6
|
describe('useKeyboardListNavigation', () => {
|
|
6
7
|
const list = ['first', 'second', 'third', 'fourth'];
|
|
@@ -56,6 +56,7 @@ export type UseKeyboardListNavigationProps<T> = {
|
|
|
56
56
|
index: number;
|
|
57
57
|
}): void;
|
|
58
58
|
extractValue?(item: T): string;
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
60
|
ref?: React.MutableRefObject<any>;
|
|
60
61
|
};
|
|
61
62
|
|
|
@@ -138,6 +139,7 @@ export const useKeyboardListNavigation = <T>({
|
|
|
138
139
|
};
|
|
139
140
|
}, [handleKeyDown, ref, idleTimeout]);
|
|
140
141
|
|
|
142
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
143
|
useEffect(() => dispatch({ type: 'RESET', payload: { defaultCursor } }), [list.length]);
|
|
142
144
|
|
|
143
145
|
const interactiveIndex = waitForInteractive && !state.interactive ? -1 : index;
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ import 'focus-visible';
|
|
|
2
2
|
|
|
3
3
|
import { colors, typography, space, breakpoints } from '@moda/tokens';
|
|
4
4
|
|
|
5
|
+
import { States } from './utilities';
|
|
6
|
+
|
|
5
7
|
export const tokens = {
|
|
6
8
|
colors,
|
|
7
9
|
typography,
|
|
@@ -14,6 +16,4 @@ export { FocusOn } from 'react-focus-on';
|
|
|
14
16
|
export * from './components';
|
|
15
17
|
export * from './hooks';
|
|
16
18
|
|
|
17
|
-
import { States } from './utilities';
|
|
18
|
-
|
|
19
19
|
export const Utilities = { States };
|