@navikt/ds-react 4.12.1 → 5.0.0-rc.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.
Files changed (137) hide show
  1. package/_docs.json +489 -1169
  2. package/cjs/badge/Badge.js +47 -0
  3. package/cjs/badge/NotificationBadge.js +61 -0
  4. package/cjs/badge/index.js +8 -0
  5. package/cjs/badge/package.json +6 -0
  6. package/cjs/date/datepicker/DatePicker.js +1 -1
  7. package/cjs/date/hooks/useEscape.js +6 -1
  8. package/cjs/dropdown/Menu/GroupedList/Heading.js +47 -0
  9. package/cjs/dropdown/Menu/GroupedList/Item.js +54 -0
  10. package/cjs/grid/ContentContainer.js +47 -0
  11. package/cjs/layout/box/Box.js +47 -0
  12. package/cjs/layout/box/index.js +5 -0
  13. package/cjs/layout/box/package.json +6 -0
  14. package/cjs/modal/Modal.js +85 -46
  15. package/cjs/modal/ModalBody.js +46 -0
  16. package/cjs/modal/ModalContext.js +8 -0
  17. package/cjs/modal/ModalFooter.js +46 -0
  18. package/cjs/modal/ModalHeader.js +56 -0
  19. package/cjs/modal/ModalUtils.js +40 -0
  20. package/cjs/modal/dialog-polyfill.js +833 -0
  21. package/cjs/popover/Popover.js +5 -2
  22. package/cjs/status-badge/NotificationBadge.js +52 -0
  23. package/cjs/status-badge/index.js +8 -0
  24. package/cjs/status-badge/package.json +6 -0
  25. package/cjs/table/DataCell.js +1 -3
  26. package/cjs/table/ExpandableRow.js +2 -1
  27. package/cjs/table/HeaderCell.js +1 -4
  28. package/cjs/table/Table.js +1 -1
  29. package/cjs/tag/CounterTag.js +69 -0
  30. package/cjs/tag/NotificationTag.js +53 -0
  31. package/cjs/timeline/demo.js +120 -0
  32. package/esm/badge/Badge.d.ts +6 -0
  33. package/esm/badge/Badge.js +19 -0
  34. package/esm/badge/Badge.js.map +1 -0
  35. package/esm/badge/NotificationBadge.d.ts +14 -0
  36. package/esm/badge/NotificationBadge.js +33 -0
  37. package/esm/badge/NotificationBadge.js.map +1 -0
  38. package/esm/badge/index.d.ts +1 -0
  39. package/esm/badge/index.js +2 -0
  40. package/esm/badge/index.js.map +1 -0
  41. package/esm/date/datepicker/DatePicker.d.ts +2 -2
  42. package/esm/date/datepicker/DatePicker.js +1 -1
  43. package/esm/date/datepicker/DatePicker.js.map +1 -1
  44. package/esm/date/hooks/useEscape.d.ts +2 -1
  45. package/esm/date/hooks/useEscape.js +6 -1
  46. package/esm/date/hooks/useEscape.js.map +1 -1
  47. package/esm/dropdown/Menu/GroupedList/Heading.d.ts +9 -0
  48. package/esm/dropdown/Menu/GroupedList/Heading.js +19 -0
  49. package/esm/dropdown/Menu/GroupedList/Heading.js.map +1 -0
  50. package/esm/dropdown/Menu/GroupedList/Item.d.ts +10 -0
  51. package/esm/dropdown/Menu/GroupedList/Item.js +26 -0
  52. package/esm/dropdown/Menu/GroupedList/Item.js.map +1 -0
  53. package/esm/form/Fieldset/useFieldset.d.ts +1 -1
  54. package/esm/form/checkbox/useCheckbox.d.ts +1 -1
  55. package/esm/form/combobox/Combobox.d.ts +1 -1
  56. package/esm/form/radio/useRadio.d.ts +1 -1
  57. package/esm/grid/ContentContainer.d.ts +9 -0
  58. package/esm/grid/ContentContainer.js +19 -0
  59. package/esm/grid/ContentContainer.js.map +1 -0
  60. package/esm/layout/box/Box.d.ts +8 -0
  61. package/esm/layout/box/Box.js +19 -0
  62. package/esm/layout/box/Box.js.map +1 -0
  63. package/esm/layout/box/index.d.ts +1 -0
  64. package/esm/layout/box/index.js +2 -0
  65. package/esm/layout/box/index.js.map +1 -0
  66. package/esm/modal/Modal.d.ts +76 -51
  67. package/esm/modal/Modal.js +87 -48
  68. package/esm/modal/Modal.js.map +1 -1
  69. package/esm/modal/ModalBody.d.ts +6 -0
  70. package/esm/modal/ModalBody.js +19 -0
  71. package/esm/modal/ModalBody.js.map +1 -0
  72. package/esm/modal/ModalContext.d.ts +6 -0
  73. package/esm/modal/ModalContext.js +3 -0
  74. package/esm/modal/ModalContext.js.map +1 -0
  75. package/esm/modal/ModalFooter.d.ts +6 -0
  76. package/esm/modal/ModalFooter.js +19 -0
  77. package/esm/modal/ModalFooter.js.map +1 -0
  78. package/esm/modal/ModalHeader.d.ts +11 -0
  79. package/esm/modal/ModalHeader.js +29 -0
  80. package/esm/modal/ModalHeader.js.map +1 -0
  81. package/esm/modal/ModalUtils.d.ts +4 -0
  82. package/esm/modal/ModalUtils.js +33 -0
  83. package/esm/modal/ModalUtils.js.map +1 -0
  84. package/esm/modal/dialog-polyfill.d.ts +5 -0
  85. package/esm/modal/dialog-polyfill.js +832 -0
  86. package/esm/modal/dialog-polyfill.js.map +1 -0
  87. package/esm/modal/index.d.ts +3 -1
  88. package/esm/popover/Popover.js +6 -3
  89. package/esm/popover/Popover.js.map +1 -1
  90. package/esm/provider/Provider.d.ts +1 -6
  91. package/esm/provider/Provider.js.map +1 -1
  92. package/esm/status-badge/NotificationBadge.d.ts +13 -0
  93. package/esm/status-badge/NotificationBadge.js +24 -0
  94. package/esm/status-badge/NotificationBadge.js.map +1 -0
  95. package/esm/status-badge/index.d.ts +1 -0
  96. package/esm/status-badge/index.js +2 -0
  97. package/esm/status-badge/index.js.map +1 -0
  98. package/esm/table/DataCell.js +2 -4
  99. package/esm/table/DataCell.js.map +1 -1
  100. package/esm/table/ExpandableRow.js +2 -1
  101. package/esm/table/ExpandableRow.js.map +1 -1
  102. package/esm/table/HeaderCell.js +1 -4
  103. package/esm/table/HeaderCell.js.map +1 -1
  104. package/esm/table/Table.d.ts +2 -3
  105. package/esm/table/Table.js +1 -1
  106. package/esm/table/Table.js.map +1 -1
  107. package/esm/tag/CounterTag.d.ts +31 -0
  108. package/esm/tag/CounterTag.js +41 -0
  109. package/esm/tag/CounterTag.js.map +1 -0
  110. package/esm/tag/NotificationTag.d.ts +11 -0
  111. package/esm/tag/NotificationTag.js +25 -0
  112. package/esm/tag/NotificationTag.js.map +1 -0
  113. package/esm/timeline/demo.d.ts +3 -0
  114. package/esm/timeline/demo.js +96 -0
  115. package/esm/timeline/demo.js.map +1 -0
  116. package/esm/util/index.d.ts +1 -1
  117. package/package.json +3 -6
  118. package/src/date/datepicker/DatePicker.tsx +3 -3
  119. package/src/date/hooks/useEscape.tsx +8 -3
  120. package/src/modal/Modal.tsx +171 -121
  121. package/src/modal/ModalBody.tsx +14 -0
  122. package/src/modal/ModalContext.ts +6 -0
  123. package/src/modal/ModalFooter.tsx +14 -0
  124. package/src/modal/ModalHeader.tsx +42 -0
  125. package/src/modal/ModalUtils.ts +37 -0
  126. package/src/modal/dialog-polyfill.ts +980 -0
  127. package/src/modal/index.ts +3 -1
  128. package/src/modal/modal.stories.tsx +142 -59
  129. package/src/popover/Popover.tsx +6 -2
  130. package/src/provider/Provider.tsx +1 -6
  131. package/src/table/DataCell.tsx +1 -5
  132. package/src/table/ExpandableRow.tsx +2 -1
  133. package/src/table/HeaderCell.tsx +1 -5
  134. package/src/table/Table.tsx +3 -4
  135. package/src/table/stories/table-expandable.stories.tsx +37 -1
  136. package/src/table/stories/table.stories.tsx +4 -1
  137. package/src/modal/ModalContent.tsx +0 -26
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const react_1 = __importStar(require("react"));
41
+ const clsx_1 = __importDefault(require("clsx"));
42
+ const aksel_icons_1 = require("@navikt/aksel-icons");
43
+ const button_1 = require("../button");
44
+ const ModalContext_1 = require("./ModalContext");
45
+ const ModalHeader = (0, react_1.forwardRef)((_a, ref) => {
46
+ var { children, className, closeButton = true } = _a, rest = __rest(_a, ["children", "className", "closeButton"]);
47
+ const context = (0, react_1.useContext)(ModalContext_1.ModalContext);
48
+ if (context === null) {
49
+ console.error("<Modal.Header> has to be used within a <Modal>");
50
+ return null;
51
+ }
52
+ return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-modal__header", className) }),
53
+ context.closeHandler && closeButton && (react_1.default.createElement(button_1.Button, { type: "button", className: "navds-modal__button", size: "small", variant: "tertiary-neutral", onClick: context.closeHandler, icon: react_1.default.createElement(aksel_icons_1.XMarkIcon, { title: "Lukk modalvindu" }) })),
54
+ children));
55
+ });
56
+ exports.default = ModalHeader;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useBodyScrollLock = exports.getCloseHandler = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ function getCloseHandler(modalRef, header, onBeforeClose) {
9
+ if (header && header.closeButton === false)
10
+ return undefined;
11
+ if (onBeforeClose) {
12
+ return () => { var _a; return onBeforeClose() !== false && ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close()); };
13
+ }
14
+ return () => { var _a; return (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); };
15
+ }
16
+ exports.getCloseHandler = getCloseHandler;
17
+ function useBodyScrollLock(modalRef, bodyClass) {
18
+ react_1.default.useEffect(() => {
19
+ if (!modalRef.current)
20
+ return;
21
+ if (modalRef.current.open)
22
+ document.body.classList.add(bodyClass); // In case `open` is true initially
23
+ const observer = new MutationObserver(() => {
24
+ var _a;
25
+ if ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.open)
26
+ document.body.classList.add(bodyClass);
27
+ else
28
+ document.body.classList.remove(bodyClass);
29
+ });
30
+ observer.observe(modalRef.current, {
31
+ attributes: true,
32
+ attributeFilter: ["open"],
33
+ });
34
+ return () => {
35
+ observer.disconnect();
36
+ document.body.classList.remove(bodyClass); // In case modal is unmounted before it's closed
37
+ };
38
+ }, [modalRef, bodyClass]);
39
+ }
40
+ exports.useBodyScrollLock = useBodyScrollLock;