@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.
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { LinkProps } from 'react-router-dom';
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 {};
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { PromptProps } from 'react-router-dom';
3
2
  interface Props {
4
- message?: PromptProps['message'];
3
+ message?: string;
5
4
  enabled: boolean | undefined;
6
5
  }
7
6
  export declare const NavigationPreventer: React.FC<Props>;
@@ -1,4 +1,3 @@
1
- import 'focus-visible';
2
1
  export declare const tokens: {
3
2
  colors: {
4
3
  all: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/om",
3
- "version": "20.2.0",
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
- "react-router-dom": "^5.1.2"
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
- "focus-visible": "^5.2.1",
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
- <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>
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
- <BrowserRouter>
25
- <States<ClickableProps>>
26
- <Clickable to='#href'>Useful to extend in place of &lt;Link/&gt;. Click me.</Clickable>
27
- </States>
28
- </BrowserRouter>
23
+ <States<ClickableProps>>
24
+ <Clickable to='#href'>Useful to extend in place of &lt;Link/&gt;. 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 { Link, LinkProps } from 'react-router-dom';
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)) return <Link {...props} ref={ref as React.Ref<HTMLAnchorElement>} />;
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
- <BrowserRouter>
19
- <States<ControlLinkProps> states={states}>
20
- <ControlLink>Underlined Control Link</ControlLink>
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
- <BrowserRouter>
27
- <States<ControlLinkProps> states={states}>
28
- <ControlLink underlined={false}>Blank Control Link</ControlLink>
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?: PromptProps['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
- return <Prompt when={enabled} message={message} />;
15
+ // TODO: implement this with next.js https://github.com/vercel/next.js/discussions/32231
16
+ return null;
17
17
  };
package/src/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- import 'focus-visible';
2
-
3
1
  import { colors, typography, space, breakpoints } from '@moda/tokens';
4
2
 
5
3
  import { States } from './utilities';