@moda/om 20.2.0 → 21.0.0-next.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/dist/index.cjs.js +7 -307
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +6 -306
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Clickable/Clickable.d.ts +7 -2
- package/dist/src/components/NavigationPreventer/NavigationPreventer.d.ts +1 -2
- package/dist/src/index.d.ts +0 -1
- package/package.json +3 -5
- package/src/components/Button/Button.stories.tsx +5 -8
- package/src/components/Clickable/Clickable.stories.tsx +3 -6
- package/src/components/Clickable/Clickable.tsx +6 -3
- package/src/components/ControlLink/ControlLink.stories.tsx +6 -11
- package/src/components/NavigationPreventer/NavigationPreventer.tsx +5 -5
- package/src/index.ts +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { LinkProps } from '
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { LinkProps as NextLinkProps } from 'next/link';
|
|
3
3
|
import './Clickable.scss';
|
|
4
4
|
type ButtonElProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
5
5
|
type AnchorElProps = React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
@@ -7,5 +7,10 @@ export type ClickableProps = {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
styleless?: boolean;
|
|
9
9
|
} & (ButtonElProps | AnchorElProps | LinkProps);
|
|
10
|
+
type LinkProps = NextLinkProps & {
|
|
11
|
+
to: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
};
|
|
10
15
|
export declare const Clickable: React.ForwardRefExoticComponent<ClickableProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
11
16
|
export {};
|
package/dist/src/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda/om",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0-next.1",
|
|
4
4
|
"description": "Moda Operandi design system",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">=18.1.0",
|
|
50
50
|
"react-dom": ">=18.1.0",
|
|
51
|
-
"
|
|
51
|
+
"next": ">=15.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@moda/icons": "^5.29.9",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/classnames": "^2.3.4",
|
|
58
58
|
"classnames": "^2.5.1",
|
|
59
59
|
"credit-card-type": "^10.0.1",
|
|
60
|
-
"
|
|
60
|
+
"next": "^15.0.2",
|
|
61
61
|
"proportional-scale": "^4.0.0",
|
|
62
62
|
"react-focus-on": "^3.9.4",
|
|
63
63
|
"react-input-mask": "^2.0.4",
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
"@types/react": "^18.3.12",
|
|
98
98
|
"@types/react-dom": "^18.3.1",
|
|
99
99
|
"@types/react-input-mask": "^3.0.5",
|
|
100
|
-
"@types/react-router-dom": "^5.3.3",
|
|
101
100
|
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
102
101
|
"@typescript-eslint/parser": "^8.11.0",
|
|
103
102
|
"autoprefixer": "^10.4.20",
|
|
@@ -134,7 +133,6 @@
|
|
|
134
133
|
"ramda": "^0.30.1",
|
|
135
134
|
"react": "^18.3.1",
|
|
136
135
|
"react-dom": "^18.3.1",
|
|
137
|
-
"react-router-dom": "^5.1.2",
|
|
138
136
|
"rollup": "^4.24.0",
|
|
139
137
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
140
138
|
"rollup-plugin-scss": "^4.0.0",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
3
2
|
import { action } from '@storybook/addon-actions';
|
|
4
3
|
import { States } from 'storybook-states';
|
|
5
4
|
|
|
@@ -64,13 +63,11 @@ export const PrimaryWithHref = () => (
|
|
|
64
63
|
);
|
|
65
64
|
|
|
66
65
|
export const PrimaryAsReactRouterLink = () => (
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</States>
|
|
73
|
-
</BrowserRouter>
|
|
66
|
+
<States<ButtonProps> states={[{}, { hover: true }, { focus: true }, { disabled: true }]}>
|
|
67
|
+
<Button to='#href' onClick={action('clicked')}>
|
|
68
|
+
Add to Cart
|
|
69
|
+
</Button>
|
|
70
|
+
</States>
|
|
74
71
|
);
|
|
75
72
|
|
|
76
73
|
export const PrimaryWithIcon = () => (
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
5
4
|
import { Clickable, ClickableProps } from './Clickable';
|
|
6
5
|
|
|
7
6
|
export default { title: 'Components/Clickable' };
|
|
@@ -21,9 +20,7 @@ export const Anchor = () => (
|
|
|
21
20
|
);
|
|
22
21
|
|
|
23
22
|
export const Link = () => (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</States>
|
|
28
|
-
</BrowserRouter>
|
|
23
|
+
<States<ClickableProps>>
|
|
24
|
+
<Clickable to='#href'>Useful to extend in place of <Link/>. Click me.</Clickable>
|
|
25
|
+
</States>
|
|
29
26
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import
|
|
3
|
+
import Link, { LinkProps as NextLinkProps } from 'next/link';
|
|
4
4
|
|
|
5
5
|
import './Clickable.scss';
|
|
6
6
|
|
|
@@ -12,6 +12,8 @@ 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
|
+
|
|
15
17
|
const isLink = (props: ButtonElProps | AnchorElProps | LinkProps): props is LinkProps =>
|
|
16
18
|
'to' in props;
|
|
17
19
|
const isAnchor = (props: ButtonElProps | AnchorElProps | LinkProps): props is AnchorElProps =>
|
|
@@ -30,7 +32,8 @@ export const Clickable = React.forwardRef(
|
|
|
30
32
|
disabled
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
if (isLink(props))
|
|
35
|
+
if (isLink(props))
|
|
36
|
+
return <Link {...props} href={props.to} ref={ref as React.Ref<HTMLAnchorElement>} />;
|
|
34
37
|
if (isAnchor(props)) return <a {...props} ref={ref as React.Ref<HTMLAnchorElement>} />;
|
|
35
38
|
if (isButton(props)) return <button {...props} ref={ref as React.Ref<HTMLButtonElement>} />;
|
|
36
39
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
5
4
|
import { ControlLink, ControlLinkProps } from './ControlLink';
|
|
6
5
|
|
|
7
6
|
export default { title: 'Components/ControlLink' };
|
|
@@ -15,17 +14,13 @@ const states = [
|
|
|
15
14
|
];
|
|
16
15
|
|
|
17
16
|
export const Underlined = () => (
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
</States>
|
|
22
|
-
</BrowserRouter>
|
|
17
|
+
<States<ControlLinkProps> states={states}>
|
|
18
|
+
<ControlLink>Underlined Control Link</ControlLink>
|
|
19
|
+
</States>
|
|
23
20
|
);
|
|
24
21
|
|
|
25
22
|
export const Blank = () => (
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
</States>
|
|
30
|
-
</BrowserRouter>
|
|
23
|
+
<States<ControlLinkProps> states={states}>
|
|
24
|
+
<ControlLink underlined={false}>Blank Control Link</ControlLink>
|
|
25
|
+
</States>
|
|
31
26
|
);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Prompt, PromptProps } from 'react-router-dom';
|
|
3
2
|
import { usePreventNavigation } from './usePreventNavigation';
|
|
4
3
|
|
|
5
4
|
interface Props {
|
|
6
|
-
message?:
|
|
5
|
+
message?: string;
|
|
7
6
|
enabled: boolean | undefined;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export const NavigationPreventer: React.FC<Props> = ({
|
|
11
|
-
enabled = false
|
|
12
|
-
message = 'Changes that you made may not be saved.'
|
|
10
|
+
enabled = false
|
|
11
|
+
// message = 'Changes that you made may not be saved.'
|
|
13
12
|
}) => {
|
|
14
13
|
usePreventNavigation(enabled);
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
// TODO: implement this with next.js https://github.com/vercel/next.js/discussions/32231
|
|
16
|
+
return null;
|
|
17
17
|
};
|