@navikt/ds-react 0.19.24 → 0.19.27

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/_docs.json CHANGED
@@ -3309,6 +3309,25 @@
3309
3309
  "name": "boolean"
3310
3310
  }
3311
3311
  },
3312
+ "style": {
3313
+ "defaultValue": null,
3314
+ "description": "Allows custom styling of ReactModal, in accordance with their typing",
3315
+ "name": "style",
3316
+ "parent": {
3317
+ "fileName": "src/modal/Modal.tsx",
3318
+ "name": "ModalProps"
3319
+ },
3320
+ "declarations": [
3321
+ {
3322
+ "fileName": "src/modal/Modal.tsx",
3323
+ "name": "ModalProps"
3324
+ }
3325
+ ],
3326
+ "required": false,
3327
+ "type": {
3328
+ "name": "Styles"
3329
+ }
3330
+ },
3312
3331
  "parentSelector": {
3313
3332
  "defaultValue": null,
3314
3333
  "description": "Callback for setting parent element modal will attach to",
@@ -46,7 +46,7 @@ const ds_icons_1 = require("@navikt/ds-icons");
46
46
  const __1 = require("..");
47
47
  const ModalContent_1 = __importDefault(require("./ModalContent"));
48
48
  exports.Modal = (0, react_1.forwardRef)((_a, ref) => {
49
- var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true, "aria-describedby": ariaDescribedBy, "aria-labelledby": ariaLabelledBy, "aria-modal": ariaModal, "aria-label": contentLabel } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton", "aria-describedby", "aria-labelledby", "aria-modal", "aria-label"]);
49
+ var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true, "aria-describedby": ariaDescribedBy, "aria-labelledby": ariaLabelledBy, "aria-modal": ariaModal, "aria-label": contentLabel, style } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton", "aria-describedby", "aria-labelledby", "aria-modal", "aria-label", "style"]);
50
50
  const modalRef = (0, react_1.useRef)(null);
51
51
  const mergedRef = (0, react_merge_refs_1.default)([modalRef, ref]);
52
52
  const buttonRef = (0, react_1.useRef)(null);
@@ -58,7 +58,7 @@ exports.Modal = (0, react_1.forwardRef)((_a, ref) => {
58
58
  buttonRef.current.focus();
59
59
  }
60
60
  };
61
- return (react_1.default.createElement(react_modal_1.default, Object.assign({}, rest, { isOpen: open, ref: mergedRef, className: (0, classnames_1.default)("navds-modal", className), overlayClassName: "navds-modal__overlay", shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, onRequestClose: (e) => onModalCloseRequest(e), aria: {
61
+ return (react_1.default.createElement(react_modal_1.default, Object.assign({}, rest, { style: style, isOpen: open, ref: mergedRef, className: (0, classnames_1.default)("navds-modal", className), overlayClassName: "navds-modal__overlay", shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, onRequestClose: (e) => onModalCloseRequest(e), aria: {
62
62
  describedby: ariaDescribedBy,
63
63
  labelledby: ariaLabelledBy,
64
64
  modal: ariaModal,
@@ -28,6 +28,10 @@ export interface ModalProps {
28
28
  * @default true
29
29
  */
30
30
  closeButton?: boolean;
31
+ /**
32
+ * Allows custom styling of ReactModal, in accordance with their typing
33
+ */
34
+ style?: ReactModal.Styles;
31
35
  /**
32
36
  * Callback for setting parent element modal will attach to
33
37
  */
@@ -17,7 +17,7 @@ import { Close } from "@navikt/ds-icons";
17
17
  import { Button } from "..";
18
18
  import ModalContent from "./ModalContent";
19
19
  export const Modal = forwardRef((_a, ref) => {
20
- var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true, "aria-describedby": ariaDescribedBy, "aria-labelledby": ariaLabelledBy, "aria-modal": ariaModal, "aria-label": contentLabel } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton", "aria-describedby", "aria-labelledby", "aria-modal", "aria-label"]);
20
+ var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true, "aria-describedby": ariaDescribedBy, "aria-labelledby": ariaLabelledBy, "aria-modal": ariaModal, "aria-label": contentLabel, style } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton", "aria-describedby", "aria-labelledby", "aria-modal", "aria-label", "style"]);
21
21
  const modalRef = useRef(null);
22
22
  const mergedRef = mergeRefs([modalRef, ref]);
23
23
  const buttonRef = useRef(null);
@@ -29,7 +29,7 @@ export const Modal = forwardRef((_a, ref) => {
29
29
  buttonRef.current.focus();
30
30
  }
31
31
  };
32
- return (React.createElement(ReactModal, Object.assign({}, rest, { isOpen: open, ref: mergedRef, className: cl("navds-modal", className), overlayClassName: "navds-modal__overlay", shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, onRequestClose: (e) => onModalCloseRequest(e), aria: {
32
+ return (React.createElement(ReactModal, Object.assign({}, rest, { style: style, isOpen: open, ref: mergedRef, className: cl("navds-modal", className), overlayClassName: "navds-modal__overlay", shouldCloseOnOverlayClick: shouldCloseOnOverlayClick, onRequestClose: (e) => onModalCloseRequest(e), aria: {
33
33
  describedby: ariaDescribedBy,
34
34
  labelledby: ariaLabelledBy,
35
35
  modal: ariaModal,
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,YAAkC,MAAM,gBAAgB,CAAC;AAuDhE,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EAYC,EACD,GAAG,EACH,EAAE;QAdF,EACE,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,SAAS,EACT,yBAAyB,GAAG,IAA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"version": "0.19.24",
3
+ "version": "0.19.27",
4
4
  "description": "NAV designsystem react components",
5
5
  "author": "NAV Designsystem team",
6
6
  "license": "MIT",
@@ -37,10 +37,10 @@
37
37
  "dependencies": {
38
38
  "@floating-ui/react-dom": "0.6.0",
39
39
  "@material-ui/core": "^4.12.3",
40
- "@navikt/ds-icons": "^0.8.19",
40
+ "@navikt/ds-icons": "^0.8.20",
41
41
  "@popperjs/core": "^2.10.1",
42
- "@radix-ui/react-tabs": "0.1.5",
43
- "@radix-ui/react-toggle-group": "0.1.5",
42
+ "@radix-ui/react-tabs": "^1.0.0",
43
+ "@radix-ui/react-toggle-group": "^1.0.0",
44
44
  "classnames": "^2.2.6",
45
45
  "react-collapse": "^5.1.0",
46
46
  "react-merge-refs": "^1.1.0",
@@ -76,5 +76,5 @@
76
76
  "@types/react": "^17.0.30 || ^18.0.0",
77
77
  "react": "^17.0.0 || ^18.0.0"
78
78
  },
79
- "gitHead": "0b8f9a9d4b1a958254064ec76ac9bdbf6e27a3a6"
79
+ "gitHead": "dd2167dab58b556cb88845c3de93bb77c3f68c23"
80
80
  }
@@ -33,6 +33,10 @@ export interface ModalProps {
33
33
  * @default true
34
34
  */
35
35
  closeButton?: boolean;
36
+ /**
37
+ * Allows custom styling of ReactModal, in accordance with their typing
38
+ */
39
+ style?: ReactModal.Styles;
36
40
  /**
37
41
  * Callback for setting parent element modal will attach to
38
42
  */
@@ -72,6 +76,7 @@ export const Modal = forwardRef<ReactModal, ModalProps>(
72
76
  "aria-labelledby": ariaLabelledBy,
73
77
  "aria-modal": ariaModal,
74
78
  "aria-label": contentLabel,
79
+ style,
75
80
  ...rest
76
81
  },
77
82
  ref
@@ -91,6 +96,7 @@ export const Modal = forwardRef<ReactModal, ModalProps>(
91
96
  return (
92
97
  <ReactModal
93
98
  {...rest}
99
+ style={style}
94
100
  isOpen={open}
95
101
  ref={mergedRef}
96
102
  className={cl("navds-modal", className)}
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { BodyLong, Button, Heading, Modal } from "../..";
2
+ import { BodyLong, Button, Heading } from "../..";
3
+ import Modal from "./Modal";
3
4
 
4
5
  export default {
5
6
  title: "ds-react/Modal",
@@ -13,16 +14,23 @@ export const Default = (props) => {
13
14
  const [open, setOpen] = useState(false);
14
15
 
15
16
  useEffect(() => {
16
- Modal.setAppElement("#root");
17
+ Modal.setAppElement?.("#root");
17
18
  }, []);
18
19
 
19
20
  return (
20
21
  <>
21
- <Button onClick={() => setOpen(true)}>Open</Button>
22
+ <Button onClick={() => setOpen(true)}>Open Modal</Button>
23
+ <p>
24
+ We can also custom style the modal by passing in a react-modal style
25
+ object. Here the backdrop is red.
26
+ </p>
22
27
  <Modal
23
28
  open={open}
24
29
  onClose={() => setOpen(false)}
25
30
  aria-labelledby="header123"
31
+ style={{
32
+ overlay: { backgroundColor: "#ff0000aa" },
33
+ }}
26
34
  {...props}
27
35
  >
28
36
  <Modal.Content>
@@ -43,62 +51,3 @@ Default.args = {
43
51
  shouldCloseOnOverlayClick: true,
44
52
  closeButton: true,
45
53
  };
46
-
47
- export const Open = () => {
48
- const [open, setOpen] = useState(null);
49
-
50
- useEffect(() => {
51
- Modal.setAppElement("#root");
52
- }, []);
53
-
54
- return (
55
- <>
56
- <Button onClick={() => setOpen(true)}>Open</Button>
57
- <Modal
58
- open={open ?? true}
59
- onClose={() => setOpen(false)}
60
- aria-labelledby="header123"
61
- >
62
- <Modal.Content>
63
- <Heading spacing id="header123" level="1" size="large">
64
- Header
65
- </Heading>
66
- <Heading spacing level="2" size="medium">
67
- Header
68
- </Heading>
69
- <BodyLong>Voluptate laboris mollit dolore qui. Magna elit.</BodyLong>
70
- </Modal.Content>
71
- </Modal>
72
- </>
73
- );
74
- };
75
-
76
- export const CloseButton = () => {
77
- const [open, setOpen] = useState(true);
78
-
79
- useEffect(() => {
80
- Modal.setAppElement("#root");
81
- }, []);
82
-
83
- return (
84
- <>
85
- <Button onClick={() => setOpen(true)}>Open</Button>
86
- <Modal
87
- open={open}
88
- onClose={() => setOpen(false)}
89
- aria-labelledby="header123"
90
- closeButton={false}
91
- >
92
- <Modal.Content>
93
- <Heading spacing id="header123" level="1" size="large">
94
- Header
95
- </Heading>
96
- <Heading spacing level="2" size="medium">
97
- Header
98
- </Heading>
99
- <BodyLong>Voluptate laboris mollit dolore qui. Magna elit.</BodyLong>
100
- </Modal.Content>
101
- </Modal>
102
- </>
103
- );
104
- };