@navikt/ds-react 0.14.10 → 0.14.11

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.
@@ -41,7 +41,7 @@ const ds_icons_1 = require("@navikt/ds-icons");
41
41
  const __1 = require("..");
42
42
  const ModalContent_1 = __importDefault(require("./ModalContent"));
43
43
  const Modal = (0, react_1.forwardRef)((_a, ref) => {
44
- var { children, open, onClose, className, shouldCloseOnOverlayClick = true } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick"]);
44
+ var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton"]);
45
45
  const modalRef = (0, react_1.useRef)(null);
46
46
  const mergedRef = (0, react_merge_refs_1.default)([modalRef, ref]);
47
47
  const buttonRef = (0, react_1.useRef)(null);
@@ -55,10 +55,10 @@ const Modal = (0, react_1.forwardRef)((_a, ref) => {
55
55
  };
56
56
  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) }),
57
57
  children,
58
- react_1.default.createElement(__1.Button, { className: (0, classnames_1.default)("navds-modal__button", {
58
+ closeButton && (react_1.default.createElement(__1.Button, { className: (0, classnames_1.default)("navds-modal__button", {
59
59
  "navds-modal__button--shake": shouldCloseOnOverlayClick,
60
- }), size: "small", variant: "secondary", ref: buttonRef, "aria-label": "lukk modalvindu", onClick: onClose },
61
- react_1.default.createElement(ds_icons_1.Close, { title: "X-ikon for \u00E5 lukke modal" }))));
60
+ }), size: "small", variant: "tertiary", ref: buttonRef, onClick: onClose },
61
+ react_1.default.createElement(ds_icons_1.Close, { title: "Lukk modalvindu" })))));
62
62
  });
63
63
  Modal.setAppElement = (element) => react_modal_1.default.setAppElement(element);
64
64
  Modal.Content = ModalContent_1.default;
@@ -23,6 +23,11 @@ export interface ModalProps {
23
23
  * User defined classname for modal
24
24
  */
25
25
  className?: string;
26
+ /**
27
+ * Toggles addition of a X-button on modal
28
+ * @default true
29
+ */
30
+ closeButton?: boolean;
26
31
  }
27
32
  interface ModalComponent extends ModalLifecycle, React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ReactModal>> {
28
33
  Content: ModalContentType;
@@ -17,7 +17,7 @@ import { Close } from "@navikt/ds-icons";
17
17
  import { Button } from "..";
18
18
  import ModalContent from "./ModalContent";
19
19
  const Modal = forwardRef((_a, ref) => {
20
- var { children, open, onClose, className, shouldCloseOnOverlayClick = true } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick"]);
20
+ var { children, open, onClose, className, shouldCloseOnOverlayClick = true, closeButton = true } = _a, rest = __rest(_a, ["children", "open", "onClose", "className", "shouldCloseOnOverlayClick", "closeButton"]);
21
21
  const modalRef = useRef(null);
22
22
  const mergedRef = mergeRefs([modalRef, ref]);
23
23
  const buttonRef = useRef(null);
@@ -31,10 +31,10 @@ const Modal = forwardRef((_a, ref) => {
31
31
  };
32
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) }),
33
33
  children,
34
- React.createElement(Button, { className: cl("navds-modal__button", {
34
+ closeButton && (React.createElement(Button, { className: cl("navds-modal__button", {
35
35
  "navds-modal__button--shake": shouldCloseOnOverlayClick,
36
- }), size: "small", variant: "secondary", ref: buttonRef, "aria-label": "lukk modalvindu", onClick: onClose },
37
- React.createElement(Close, { title: "X-ikon for \u00E5 lukke modal" }))));
36
+ }), size: "small", variant: "tertiary", ref: buttonRef, onClick: onClose },
37
+ React.createElement(Close, { title: "Lukk modalvindu" })))));
38
38
  });
39
39
  Modal.setAppElement = (element) => ReactModal.setAppElement(element);
40
40
  Modal.Content = ModalContent;
@@ -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;AAsChE,MAAM,KAAK,GAAG,UAAU,CACtB,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,SAAS,EACT,yBAAyB,GAAG,IAAI,OAEjC,EADI,IAAI,cANT,yEAOC,CADQ;IAIT,MAAM,QAAQ,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAG,CAAC,CAAC,EAAE,EAAE;QAChC,IAAI,yBAAyB,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE;YACrD,OAAO,EAAE,CAAC;SACX;aAAM,IAAI,SAAS,CAAC,OAAO,EAAE;YAC5B,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SAC3B;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,UAAU,oBACL,IAAI,IACR,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,EAAE,CAAC,a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CAAC;AAE7B,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "0.14.10",
3
+ "version": "0.14.11",
4
4
  "private": false,
5
5
  "description": "NAV designsystem react components",
6
6
  "author": "NAV Designsystem team",
@@ -64,5 +64,5 @@
64
64
  "@types/react": "^17.0.30",
65
65
  "react": "^17.0.0"
66
66
  },
67
- "gitHead": "ebb04c4a564d7524e5815a87be7690a64f7a7c8f"
67
+ "gitHead": "236feb37e8107c8ed6752496e387ea76dc798c6d"
68
68
  }
@@ -28,6 +28,11 @@ export interface ModalProps {
28
28
  * User defined classname for modal
29
29
  */
30
30
  className?: string;
31
+ /**
32
+ * Toggles addition of a X-button on modal
33
+ * @default true
34
+ */
35
+ closeButton?: boolean;
31
36
  }
32
37
 
33
38
  interface ModalComponent
@@ -50,6 +55,7 @@ const Modal = forwardRef<ReactModal, ModalProps>(
50
55
  onClose,
51
56
  className,
52
57
  shouldCloseOnOverlayClick = true,
58
+ closeButton = true,
53
59
  ...rest
54
60
  },
55
61
  ref
@@ -77,18 +83,19 @@ const Modal = forwardRef<ReactModal, ModalProps>(
77
83
  onRequestClose={(e) => onModalCloseRequest(e)}
78
84
  >
79
85
  {children}
80
- <Button
81
- className={cl("navds-modal__button", {
82
- "navds-modal__button--shake": shouldCloseOnOverlayClick,
83
- })}
84
- size="small"
85
- variant="secondary"
86
- ref={buttonRef}
87
- aria-label="lukk modalvindu"
88
- onClick={onClose}
89
- >
90
- <Close title="X-ikon for å lukke modal" />
91
- </Button>
86
+ {closeButton && (
87
+ <Button
88
+ className={cl("navds-modal__button", {
89
+ "navds-modal__button--shake": shouldCloseOnOverlayClick,
90
+ })}
91
+ size="small"
92
+ variant="tertiary"
93
+ ref={buttonRef}
94
+ onClick={onClose}
95
+ >
96
+ <Close title="Lukk modalvindu" />
97
+ </Button>
98
+ )}
92
99
  </ReactModal>
93
100
  );
94
101
  }
@@ -11,6 +11,7 @@ Modal.setAppElement("#root");
11
11
  export const All = () => {
12
12
  const [open, setOpen] = useState(true);
13
13
  const [openTwo, setOpenTwo] = useState(false);
14
+ const [openThree, setOpenThree] = useState(false);
14
15
 
15
16
  return (
16
17
  <>
@@ -46,6 +47,21 @@ export const All = () => {
46
47
  </p>
47
48
  </Modal.Content>
48
49
  </Modal>
50
+ <button onClick={() => setOpenThree(true)}>
51
+ Open modal without x-button
52
+ </button>
53
+ <Modal
54
+ open={openThree}
55
+ closeButton={false}
56
+ onClose={() => setOpenThree(false)}
57
+ >
58
+ <Modal.Content>
59
+ <h1>Header</h1>
60
+ <h2>subheader</h2>
61
+ <p>Cupidatat irure ipsum veniam ad in esse.</p>
62
+ <p>Cillum tempor pariatur amet ut laborum Lorem enim enim.</p>
63
+ </Modal.Content>
64
+ </Modal>
49
65
  </>
50
66
  );
51
67
  };