@navikt/ds-react 4.1.6 → 4.2.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 (37) hide show
  1. package/_docs.json +87 -7
  2. package/cjs/chat/Bubble.js +4 -3
  3. package/cjs/chat/Chat.js +13 -10
  4. package/cjs/help-text/HelpText.js +2 -2
  5. package/cjs/timeline/Pin.js +4 -10
  6. package/cjs/timeline/TimelineRow.js +1 -1
  7. package/cjs/timeline/period/ClickablePeriod.js +4 -10
  8. package/esm/chat/Bubble.d.ts +1 -0
  9. package/esm/chat/Bubble.js +4 -3
  10. package/esm/chat/Bubble.js.map +1 -1
  11. package/esm/chat/Chat.d.ts +29 -13
  12. package/esm/chat/Chat.js +13 -10
  13. package/esm/chat/Chat.js.map +1 -1
  14. package/esm/form/error-summary/ErrorSummary.d.ts +12 -0
  15. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  16. package/esm/form/error-summary/ErrorSummaryItem.d.ts +4 -0
  17. package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
  18. package/esm/help-text/HelpText.d.ts +4 -0
  19. package/esm/help-text/HelpText.js +2 -2
  20. package/esm/help-text/HelpText.js.map +1 -1
  21. package/esm/timeline/Pin.js +5 -11
  22. package/esm/timeline/Pin.js.map +1 -1
  23. package/esm/timeline/TimelineRow.js +1 -1
  24. package/esm/timeline/TimelineRow.js.map +1 -1
  25. package/esm/timeline/period/ClickablePeriod.js +5 -11
  26. package/esm/timeline/period/ClickablePeriod.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/chat/Bubble.tsx +9 -5
  29. package/src/chat/Chat.tsx +70 -52
  30. package/src/chat/chat.stories.tsx +148 -126
  31. package/src/form/error-summary/ErrorSummary.tsx +12 -0
  32. package/src/form/error-summary/ErrorSummaryItem.tsx +4 -0
  33. package/src/help-text/HelpText.tsx +6 -1
  34. package/src/help-text/help-text.stories.tsx +34 -1
  35. package/src/timeline/Pin.tsx +6 -25
  36. package/src/timeline/TimelineRow.tsx +1 -0
  37. package/src/timeline/period/ClickablePeriod.tsx +6 -19
package/_docs.json CHANGED
@@ -768,7 +768,7 @@
768
768
  },
769
769
  "backgroundColor": {
770
770
  "defaultValue": null,
771
- "description": "Background color on bubble",
771
+ "description": "Background color on bubble\n@deprecated Use `variant` on Chat instead",
772
772
  "name": "backgroundColor",
773
773
  "parent": {
774
774
  "fileName": "src/chat/Bubble.tsx",
@@ -907,7 +907,7 @@
907
907
  },
908
908
  "avatar": {
909
909
  "defaultValue": null,
910
- "description": "Avatar for messenger. Regular text for initials works to",
910
+ "description": "Avatar for messenger. Regular text for initials works too, but it will be hidden for screen readers.",
911
911
  "name": "avatar",
912
912
  "parent": {
913
913
  "fileName": "src/chat/Chat.tsx",
@@ -919,14 +919,35 @@
919
919
  "name": "ChatProps"
920
920
  }
921
921
  ],
922
- "required": true,
922
+ "required": false,
923
923
  "type": {
924
924
  "name": "ReactNode"
925
925
  }
926
926
  },
927
+ "variant": {
928
+ "defaultValue": {
929
+ "value": "\"subtle\""
930
+ },
931
+ "description": "Changes background color on avatar and bubbles.\nAvoid using the same background as the surface behind Chat.",
932
+ "name": "variant",
933
+ "parent": {
934
+ "fileName": "src/chat/Chat.tsx",
935
+ "name": "ChatProps"
936
+ },
937
+ "declarations": [
938
+ {
939
+ "fileName": "src/chat/Chat.tsx",
940
+ "name": "ChatProps"
941
+ }
942
+ ],
943
+ "required": false,
944
+ "type": {
945
+ "name": "\"subtle\" | \"info\" | \"neutral\""
946
+ }
947
+ },
927
948
  "backgroundColor": {
928
949
  "defaultValue": null,
929
- "description": "Background color on bubbles",
950
+ "description": "Background color on bubbles\n@deprecated Use `variant` instead",
930
951
  "name": "backgroundColor",
931
952
  "parent": {
932
953
  "fileName": "src/chat/Chat.tsx",
@@ -945,7 +966,7 @@
945
966
  },
946
967
  "avatarBgColor": {
947
968
  "defaultValue": null,
948
- "description": "Background color for avatar",
969
+ "description": "Background color for avatar\n@deprecated Use `variant` instead",
949
970
  "name": "avatarBgColor",
950
971
  "parent": {
951
972
  "fileName": "src/chat/Chat.tsx",
@@ -966,7 +987,7 @@
966
987
  "defaultValue": {
967
988
  "value": "\"left\""
968
989
  },
969
- "description": "Positions avatar and Bubbles",
990
+ "description": "Positions avatar and bubbles",
970
991
  "name": "position",
971
992
  "parent": {
972
993
  "fileName": "src/chat/Chat.tsx",
@@ -985,7 +1006,7 @@
985
1006
  },
986
1007
  "toptextPosition": {
987
1008
  "defaultValue": {
988
- "value": "Same as chat"
1009
+ "value": "Same as position"
989
1010
  },
990
1011
  "description": "Hoizontal position of toptext",
991
1012
  "name": "toptextPosition",
@@ -1004,6 +1025,27 @@
1004
1025
  "name": "\"left\" | \"right\""
1005
1026
  }
1006
1027
  },
1028
+ "size": {
1029
+ "defaultValue": {
1030
+ "value": "\"medium\""
1031
+ },
1032
+ "description": "Affects padding and font size in bubbles",
1033
+ "name": "size",
1034
+ "parent": {
1035
+ "fileName": "src/chat/Chat.tsx",
1036
+ "name": "ChatProps"
1037
+ },
1038
+ "declarations": [
1039
+ {
1040
+ "fileName": "src/chat/Chat.tsx",
1041
+ "name": "ChatProps"
1042
+ }
1043
+ ],
1044
+ "required": false,
1045
+ "type": {
1046
+ "name": "\"medium\" | \"small\""
1047
+ }
1048
+ },
1007
1049
  "className": {
1008
1050
  "defaultValue": null,
1009
1051
  "description": "",
@@ -4359,6 +4401,25 @@
4359
4401
  "name": "\"top\" | \"bottom\" | \"right\" | \"left\" | \"top-start\" | \"top-end\" | \"bottom-start\" | \"bottom-end\" | \"right-start\" | \"right-end\" | \"left-start\" | \"left-end\""
4360
4402
  }
4361
4403
  },
4404
+ "wrapperClassName": {
4405
+ "defaultValue": null,
4406
+ "description": "Classname for wrapper",
4407
+ "name": "wrapperClassName",
4408
+ "parent": {
4409
+ "fileName": "src/help-text/HelpText.tsx",
4410
+ "name": "HelpTextProps"
4411
+ },
4412
+ "declarations": [
4413
+ {
4414
+ "fileName": "src/help-text/HelpText.tsx",
4415
+ "name": "HelpTextProps"
4416
+ }
4417
+ ],
4418
+ "required": false,
4419
+ "type": {
4420
+ "name": "string"
4421
+ }
4422
+ },
4362
4423
  "className": {
4363
4424
  "defaultValue": null,
4364
4425
  "description": "",
@@ -13603,6 +13664,25 @@
13603
13664
  "name": "ReactNode"
13604
13665
  }
13605
13666
  },
13667
+ "href": {
13668
+ "defaultValue": null,
13669
+ "description": "Link to errormessage",
13670
+ "name": "href",
13671
+ "parent": {
13672
+ "fileName": "src/form/error-summary/ErrorSummaryItem.tsx",
13673
+ "name": "ErrorSummaryItemProps"
13674
+ },
13675
+ "declarations": [
13676
+ {
13677
+ "fileName": "src/form/error-summary/ErrorSummaryItem.tsx",
13678
+ "name": "ErrorSummaryItemProps"
13679
+ }
13680
+ ],
13681
+ "required": false,
13682
+ "type": {
13683
+ "name": "string"
13684
+ }
13685
+ },
13606
13686
  "className": {
13607
13687
  "defaultValue": null,
13608
13688
  "description": "",
@@ -43,9 +43,10 @@ const typography_1 = require("../typography");
43
43
  const Bubble = (0, react_1.forwardRef)((_a, ref) => {
44
44
  var { children, className, name, timestamp, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "backgroundColor", "toptextPosition"]);
45
45
  return (react_1.default.createElement("div", Object.assign({ ref: ref, className: (0, clsx_1.default)("navds-chat__bubble", className), style: { backgroundColor: backgroundColor } }, rest),
46
- (timestamp || name) && (react_1.default.createElement("div", { className: (0, clsx_1.default)(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
47
- name && react_1.default.createElement(typography_1.Detail, { className: "navds-chat__name" }, name),
48
- timestamp && (react_1.default.createElement(typography_1.Detail, { className: "navds-chat__timestamp" }, timestamp)))),
46
+ (timestamp || name) && (react_1.default.createElement("h3", { className: (0, clsx_1.default)(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
47
+ name && react_1.default.createElement(typography_1.Detail, { as: "span" }, name),
48
+ name && timestamp && (react_1.default.createElement(typography_1.Detail, { as: "span", "aria-hidden": true }, "\u2022")),
49
+ timestamp && react_1.default.createElement(typography_1.Detail, { as: "span" }, timestamp))),
49
50
  children));
50
51
  });
51
52
  exports.default = Bubble;
package/cjs/chat/Chat.js CHANGED
@@ -37,34 +37,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.Chat = void 0;
40
+ exports.Chat = exports.SIZES = exports.POSITIONS = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
42
  const clsx_1 = __importDefault(require("clsx"));
43
43
  const Bubble_1 = __importDefault(require("./Bubble"));
44
44
  const typography_1 = require("../typography");
45
+ exports.POSITIONS = ["left", "right"];
46
+ exports.SIZES = ["medium", "small"];
45
47
  /**
46
- * A component for displaying chat messages.
48
+ * A component for communicating dialogs between two parties.
47
49
  *
48
50
  * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/chat)
49
51
  * @see 🏷️ {@link ChatProps}
50
52
  *
51
53
  * @example
52
54
  * ```jsx
53
- * <Chat>
54
- * <Chat.Bubble avatar="A" name="Alice">Hello!</Chat.Bubble>
55
+ * <Chat avatar="A" name="Alice" timestamp="01.01.21 14:00">
56
+ * <Chat.Bubble>Hello!</Chat.Bubble>
57
+ * <Chat.Bubble>How can I help you?</Chat.Bubble>
55
58
  * </Chat>
56
- * <Chat>
57
- * <Chat.Bubble avatar="B" name="Bob">Hi there!</Chat.Bubble>
59
+ * <Chat avatar="B" name="Bob" timestamp="01.01.21 14:01" position="right">
60
+ * <Chat.Bubble>Hi there!</Chat.Bubble>
58
61
  * </Chat>
59
62
  * ```
60
63
  */
61
64
  exports.Chat = (0, react_1.forwardRef)((_a, ref) => {
62
- var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor", "toptextPosition"]);
63
- return (react_1.default.createElement("div", Object.assign({ ref: ref, className: (0, clsx_1.default)("navds-chat", className, `navds-chat--${position} navds-chat--top-text-${toptextPosition !== null && toptextPosition !== void 0 ? toptextPosition : position}`) }, rest),
64
- react_1.default.createElement(typography_1.BodyShort, { as: "div", className: "navds-chat__avatar", style: { backgroundColor: avatarBgColor } }, avatar),
65
+ var { children, className, name, timestamp, avatar, position = "left", variant = "subtle", avatarBgColor, backgroundColor, toptextPosition, size = "medium" } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "variant", "avatarBgColor", "backgroundColor", "toptextPosition", "size"]);
66
+ return (react_1.default.createElement("div", Object.assign({ ref: ref, className: (0, clsx_1.default)("navds-chat", className, `navds-chat--${position}`, `navds-chat--top-text-${toptextPosition !== null && toptextPosition !== void 0 ? toptextPosition : position}`, `navds-chat--${size}`, `navds-chat--${variant}`) }, rest),
67
+ avatar && (react_1.default.createElement("div", { className: "navds-chat__avatar", "aria-hidden": true, style: { backgroundColor: avatarBgColor } }, avatar)),
65
68
  react_1.default.createElement("ol", { className: "navds-chat__bubble-wrapper" }, react_1.default.Children.map(children, (child, i) => {
66
69
  if (react_1.default.isValidElement(child)) {
67
- return (react_1.default.createElement(typography_1.BodyLong, { as: "li" }, react_1.default.cloneElement(child, Object.assign({ name: name && i === 0 ? name : undefined, timestamp: timestamp && i === 0 ? timestamp : undefined, backgroundColor }, child.props))));
70
+ return (react_1.default.createElement(typography_1.BodyLong, { as: "li", size: size }, react_1.default.cloneElement(child, Object.assign({ name: name && i === 0 ? name : undefined, timestamp: timestamp && i === 0 ? timestamp : undefined, backgroundColor }, child.props))));
68
71
  }
69
72
  }))));
70
73
  });
@@ -56,11 +56,11 @@ const HelpTextIcon_1 = require("./HelpTextIcon");
56
56
  * ```
57
57
  */
58
58
  exports.HelpText = (0, react_1.forwardRef)((_a, ref) => {
59
- var { className, children, placement = "top", strategy = "absolute", title = "hjelp", onClick } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title", "onClick"]);
59
+ var { className, children, placement = "top", strategy = "absolute", title = "hjelp", onClick, wrapperClassName } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title", "onClick", "wrapperClassName"]);
60
60
  const buttonRef = (0, react_1.useRef)(null);
61
61
  const mergedRef = (0, react_1.useMemo)(() => (0, __1.mergeRefs)([buttonRef, ref]), [ref]);
62
62
  const [open, setOpen] = (0, react_1.useState)(false);
63
- return (react_1.default.createElement("div", { className: "navds-help-text" },
63
+ return (react_1.default.createElement("div", { className: (0, clsx_1.default)("navds-help-text", wrapperClassName) },
64
64
  react_1.default.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (e) => {
65
65
  setOpen((x) => !x);
66
66
  onClick === null || onClick === void 0 ? void 0 : onClick(e);
@@ -36,9 +36,9 @@ var __rest = (this && this.__rest) || function (s, e) {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.Pin = void 0;
38
38
  const react_1 = require("@floating-ui/react");
39
- const util_1 = require("../util");
40
39
  const date_fns_1 = require("date-fns");
41
40
  const react_2 = __importStar(require("react"));
41
+ const util_1 = require("../util");
42
42
  const useTimelineContext_1 = require("./hooks/useTimelineContext");
43
43
  const calc_1 = require("./utils/calc");
44
44
  exports.Pin = (0, react_2.forwardRef)((_a, ref) => {
@@ -68,15 +68,6 @@ exports.Pin = (0, react_2.forwardRef)((_a, ref) => {
68
68
  (0, react_1.useDismiss)(context),
69
69
  ]);
70
70
  const mergedRef = (0, react_2.useMemo)(() => (0, util_1.mergeRefs)([refs.setReference, ref]), [ref, refs.setReference]);
71
- (0, util_1.useEventListener)("focusin", (0, react_2.useCallback)((e) => {
72
- var _a;
73
- if (![
74
- refs.reference.current,
75
- (_a = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _a === void 0 ? void 0 : _a.current,
76
- ].some((element) => element === null || element === void 0 ? void 0 : element.contains(e.target))) {
77
- open && setOpen(false);
78
- }
79
- }, [open, refs.reference, refs === null || refs === void 0 ? void 0 : refs.floating]));
80
71
  const staticSide = {
81
72
  top: "bottom",
82
73
  right: "left",
@@ -99,6 +90,9 @@ exports.Pin = (0, react_2.forwardRef)((_a, ref) => {
99
90
  })))),
100
91
  children && (react_2.default.createElement("div", Object.assign({ className: "navds-timeline__popover", "data-placement": placement, "aria-hidden": !open, ref: refs.setFloating }, getFloatingProps({
101
92
  tabIndex: -1,
93
+ onBlur: (e) => e.target.previousSibling !== document.activeElement &&
94
+ open &&
95
+ setOpen(false),
102
96
  }), { style: Object.assign(Object.assign({}, floatingStyles), { display: open ? undefined : "none" }) }),
103
97
  react_2.default.createElement("div", { className: "navds-timeline__popover-content" }, children),
104
98
  react_2.default.createElement("div", { ref: (node) => {
@@ -64,7 +64,7 @@ exports.TimelineRow = (0, react_1.forwardRef)((_a, ref) => {
64
64
  react_1.default.createElement("div", { className: (0, clsx_1.default)("navds-timeline__row", {
65
65
  "navds-timeline__row--active": active,
66
66
  }) },
67
- react_1.default.createElement("ol", Object.assign({}, rest, { ref: ref, "aria-label": periods.length === 0
67
+ react_1.default.createElement("ol", Object.assign({}, rest, { tabIndex: -1, ref: ref, "aria-label": periods.length === 0
68
68
  ? "Ingen perioder"
69
69
  : `${(0, date_fns_1.format)(earliest.start, "dd.MM.yyyy")} til ${(0, date_fns_1.format)(latest.end, "dd.MM.yyyy")}`, className: (0, clsx_1.default)("navds-timeline__row-periods", className), onKeyDown: (e) => {
70
70
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = require("@floating-ui/react");
30
- const util_1 = require("../../util");
31
30
  const clsx_1 = __importDefault(require("clsx"));
32
31
  const react_2 = __importStar(require("react"));
32
+ const util_1 = require("../../util");
33
33
  const usePeriodContext_1 = require("../hooks/usePeriodContext");
34
34
  const useRowContext_1 = require("../hooks/useRowContext");
35
35
  const useTimelineContext_1 = require("../hooks/useTimelineContext");
@@ -62,15 +62,6 @@ const ClickablePeriod = react_2.default.memo(({ onSelectPeriod, start, end, stat
62
62
  (0, react_1.useDismiss)(context),
63
63
  ]);
64
64
  const mergedRef = (0, react_2.useMemo)(() => (0, util_1.mergeRefs)([refs.setReference, periodRef]), [periodRef, refs.setReference]);
65
- (0, util_1.useEventListener)("focusin", (0, react_2.useCallback)((e) => {
66
- var _a;
67
- if (![
68
- refs.reference.current,
69
- (_a = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _a === void 0 ? void 0 : _a.current,
70
- ].some((element) => element === null || element === void 0 ? void 0 : element.contains(e.target))) {
71
- open && setOpen(false);
72
- }
73
- }, [open, refs.reference, refs === null || refs === void 0 ? void 0 : refs.floating]));
74
65
  const staticSide = {
75
66
  top: "bottom",
76
67
  right: "left",
@@ -114,6 +105,9 @@ const ClickablePeriod = react_2.default.memo(({ onSelectPeriod, start, end, stat
114
105
  react_2.default.createElement("span", { className: "navds-timeline__period--inner" }, icon)),
115
106
  children && (react_2.default.createElement("div", Object.assign({ className: "navds-timeline__popover", "data-placement": placement, "aria-hidden": !open, ref: refs.setFloating }, getFloatingProps({
116
107
  tabIndex: -1,
108
+ onBlur: (e) => e.target.previousSibling !== document.activeElement &&
109
+ open &&
110
+ setOpen(false),
117
111
  }), { style: Object.assign(Object.assign({}, floatingStyles), { display: open ? undefined : "none" }) }),
118
112
  react_2.default.createElement("div", { className: "navds-timeline__popover-content" }, children),
119
113
  react_2.default.createElement("div", { ref: (node) => {
@@ -14,6 +14,7 @@ export interface BubbleProps extends HTMLAttributes<HTMLDivElement> {
14
14
  timestamp?: string;
15
15
  /**
16
16
  * Background color on bubble
17
+ * @deprecated Use `variant` on Chat instead
17
18
  */
18
19
  backgroundColor?: string;
19
20
  /**
@@ -15,9 +15,10 @@ import { Detail } from "../typography";
15
15
  const Bubble = forwardRef((_a, ref) => {
16
16
  var { children, className, name, timestamp, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "backgroundColor", "toptextPosition"]);
17
17
  return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-chat__bubble", className), style: { backgroundColor: backgroundColor } }, rest),
18
- (timestamp || name) && (React.createElement("div", { className: cl(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
19
- name && React.createElement(Detail, { className: "navds-chat__name" }, name),
20
- timestamp && (React.createElement(Detail, { className: "navds-chat__timestamp" }, timestamp)))),
18
+ (timestamp || name) && (React.createElement("h3", { className: cl(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
19
+ name && React.createElement(Detail, { as: "span" }, name),
20
+ name && timestamp && (React.createElement(Detail, { as: "span", "aria-hidden": true }, "\u2022")),
21
+ timestamp && React.createElement(Detail, { as: "span" }, timestamp))),
21
22
  children));
22
23
  });
23
24
  export default Bubble;
@@ -1 +1 @@
1
- {"version":3,"file":"Bubble.js","sourceRoot":"","sources":["../../src/chat/Bubble.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAyBvC,MAAM,MAAM,GAAG,UAAU,CACvB,CACE,EAQC,EACD,GAAG,EACH,EAAE;QAVF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,eAAe,EACf,eAAe,OAEhB,EADI,IAAI,cAPT,oFAQC,CADQ;IAIT,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC9C,KAAK,EAAE,EAAE,eAAe,EAAE,eAAe,EAAE,IACvC,IAAI;QAEP,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CACtB,6BACE,SAAS,EAAE,EAAE,CACX,sBAA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AU,CACjD,CACN;QACA,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import React, { HTMLAttributes } from "react";
2
- import { BubbleProps } from "./Bubble";
2
+ import Bubble from "./Bubble";
3
+ export declare const POSITIONS: readonly ["left", "right"];
4
+ export declare const SIZES: readonly ["medium", "small"];
3
5
  export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
4
6
  /**
5
7
  * Children of type <Chat.Bubble />
@@ -14,47 +16,61 @@ export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
14
16
  */
15
17
  timestamp?: string;
16
18
  /**
17
- * Avatar for messenger. Regular text for initials works to
19
+ * Avatar for messenger. Regular text for initials works too, but it will be hidden for screen readers.
18
20
  */
19
- avatar: React.ReactNode;
21
+ avatar?: React.ReactNode;
22
+ /**
23
+ * Changes background color on avatar and bubbles.
24
+ * Avoid using the same background as the surface behind Chat.
25
+ * @default "subtle"
26
+ */
27
+ variant?: "subtle" | "info" | "neutral";
20
28
  /**
21
29
  * Background color on bubbles
30
+ * @deprecated Use `variant` instead
22
31
  */
23
32
  backgroundColor?: string;
24
33
  /**
25
34
  * Background color for avatar
35
+ * @deprecated Use `variant` instead
26
36
  */
27
37
  avatarBgColor?: string;
28
38
  /**
29
- * Positions avatar and Bubbles
39
+ * Positions avatar and bubbles
30
40
  * @default "left"
31
41
  */
32
- position?: "left" | "right";
42
+ position?: (typeof POSITIONS)[number];
33
43
  /**
34
44
  * Hoizontal position of toptext
35
- * @default Same as chat
45
+ * @default Same as position
46
+ */
47
+ toptextPosition?: (typeof POSITIONS)[number];
48
+ /**
49
+ * Affects padding and font size in bubbles
50
+ * @default "medium"
36
51
  */
37
- toptextPosition?: "left" | "right";
52
+ size?: (typeof SIZES)[number];
38
53
  }
39
54
  interface ChatComponent extends React.ForwardRefExoticComponent<ChatProps & React.RefAttributes<HTMLDivElement>> {
40
55
  /**
41
56
  * @see 🏷️ {@link BubbleProps}
42
57
  */
43
- Bubble: React.ForwardRefExoticComponent<BubbleProps & React.RefAttributes<HTMLDivElement>>;
58
+ Bubble: typeof Bubble;
44
59
  }
45
60
  /**
46
- * A component for displaying chat messages.
61
+ * A component for communicating dialogs between two parties.
47
62
  *
48
63
  * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/chat)
49
64
  * @see 🏷️ {@link ChatProps}
50
65
  *
51
66
  * @example
52
67
  * ```jsx
53
- * <Chat>
54
- * <Chat.Bubble avatar="A" name="Alice">Hello!</Chat.Bubble>
68
+ * <Chat avatar="A" name="Alice" timestamp="01.01.21 14:00">
69
+ * <Chat.Bubble>Hello!</Chat.Bubble>
70
+ * <Chat.Bubble>How can I help you?</Chat.Bubble>
55
71
  * </Chat>
56
- * <Chat>
57
- * <Chat.Bubble avatar="B" name="Bob">Hi there!</Chat.Bubble>
72
+ * <Chat avatar="B" name="Bob" timestamp="01.01.21 14:01" position="right">
73
+ * <Chat.Bubble>Hi there!</Chat.Bubble>
58
74
  * </Chat>
59
75
  * ```
60
76
  */
package/esm/chat/Chat.js CHANGED
@@ -12,30 +12,33 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import React, { forwardRef } from "react";
13
13
  import cl from "clsx";
14
14
  import Bubble from "./Bubble";
15
- import { BodyLong, BodyShort } from "../typography";
15
+ import { BodyLong } from "../typography";
16
+ export const POSITIONS = ["left", "right"];
17
+ export const SIZES = ["medium", "small"];
16
18
  /**
17
- * A component for displaying chat messages.
19
+ * A component for communicating dialogs between two parties.
18
20
  *
19
21
  * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/chat)
20
22
  * @see 🏷️ {@link ChatProps}
21
23
  *
22
24
  * @example
23
25
  * ```jsx
24
- * <Chat>
25
- * <Chat.Bubble avatar="A" name="Alice">Hello!</Chat.Bubble>
26
+ * <Chat avatar="A" name="Alice" timestamp="01.01.21 14:00">
27
+ * <Chat.Bubble>Hello!</Chat.Bubble>
28
+ * <Chat.Bubble>How can I help you?</Chat.Bubble>
26
29
  * </Chat>
27
- * <Chat>
28
- * <Chat.Bubble avatar="B" name="Bob">Hi there!</Chat.Bubble>
30
+ * <Chat avatar="B" name="Bob" timestamp="01.01.21 14:01" position="right">
31
+ * <Chat.Bubble>Hi there!</Chat.Bubble>
29
32
  * </Chat>
30
33
  * ```
31
34
  */
32
35
  export const Chat = forwardRef((_a, ref) => {
33
- var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor", "toptextPosition"]);
34
- return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-chat", className, `navds-chat--${position} navds-chat--top-text-${toptextPosition !== null && toptextPosition !== void 0 ? toptextPosition : position}`) }, rest),
35
- React.createElement(BodyShort, { as: "div", className: "navds-chat__avatar", style: { backgroundColor: avatarBgColor } }, avatar),
36
+ var { children, className, name, timestamp, avatar, position = "left", variant = "subtle", avatarBgColor, backgroundColor, toptextPosition, size = "medium" } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "variant", "avatarBgColor", "backgroundColor", "toptextPosition", "size"]);
37
+ return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-chat", className, `navds-chat--${position}`, `navds-chat--top-text-${toptextPosition !== null && toptextPosition !== void 0 ? toptextPosition : position}`, `navds-chat--${size}`, `navds-chat--${variant}`) }, rest),
38
+ avatar && (React.createElement("div", { className: "navds-chat__avatar", "aria-hidden": true, style: { backgroundColor: avatarBgColor } }, avatar)),
36
39
  React.createElement("ol", { className: "navds-chat__bubble-wrapper" }, React.Children.map(children, (child, i) => {
37
40
  if (React.isValidElement(child)) {
38
- return (React.createElement(BodyLong, { as: "li" }, React.cloneElement(child, Object.assign({ name: name && i === 0 ? name : undefined, timestamp: timestamp && i === 0 ? timestamp : undefined, backgroundColor }, child.props))));
41
+ return (React.createElement(BodyLong, { as: "li", size: size }, React.cloneElement(child, Object.assign({ name: name && i === 0 ? name : undefined, timestamp: timestamp && i === 0 ? timestamp : undefined, backgroundColor }, child.props))));
39
42
  }
40
43
  }))));
41
44
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../src/chat/Chat.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,MAAuB,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAmDpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CACE,EAWC,EACD,GAAG,EACH,EAAE;QAbF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,aAAa,EACb,eAAe,EACf,eAAe,OAEhB,EADI,IAAI,cAVT,2HAWC,CADQ;IAIT,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,YAAY,EACZ,SAAS,EACT,eAAe,QAAQ,yBACrB,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,QACrB,EAAE,CACH,IACG,IAAI;QAER,oBAAC,SAAS,IACR,EAAE,EAAC,KAAK,EACR,SAAS,EAAC,oBAAoB,EAC9B,KAAK,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,IAExC,MAAM,CACG;QACZ,4BAAI,SAAS,EAAC,4BAA4B,IACvC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC/B,OAAO,CACL,oBAAC,QAAQ,IAAC,EAAE,EAAC,IAAI,IACd,KAAK,CAAC,YAAY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e,QAAQ,EAAE,EACzB,wBAAwB,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,QAAQ,EAAE,EACrD,eAAe,IAAI,EAAE,EACrB,eAAe,OAAO,EAAE,CACzB,IACG,IAAI;QAEP,MAAM,IAAI,CACT,6BACE,SAAS,EAAC,oBAAoB,uBAE9B,KAAK,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,IAExC,MAAM,CACH,CACP;QACD,4BAAI,SAAS,EAAC,4BAA4B,IACvC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC/B,OAAO,CACL,oBAAC,QAAQ,IAAC,EAAE,EAAC,IAAI,EAAC,IAAI,EAAE,IAAI,IACzB,KAAK,CAAC,YAAY,CAAC,KAAK,kBACvB,IAAI,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACxC,SAAS,EAAE,SAAS,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACvD,eAAe,IACZ,KAAK,CAAC,KAAK,EACd,CACO,CACZ,CAAC;aACH;QACH,CAAC,CAAC,CACC,CACD,CACP,CAAA;CAAA,CACe,CAAC;AAEnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAErB,eAAe,IAAI,CAAC"}
@@ -21,6 +21,18 @@ export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
21
21
  headingTag?: React.ElementType<any>;
22
22
  }
23
23
  interface ErrorSummaryComponent extends React.ForwardRefExoticComponent<ErrorSummaryProps & React.RefAttributes<HTMLDivElement>> {
24
+ /**
25
+ * Link to error
26
+ *
27
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
28
+ *
29
+ * @example
30
+ * ```jsx
31
+ * <ErrorSummary.Item href="#1">
32
+ * Felt må fylles ut med alder
33
+ * </ErrorSummary.Item>
34
+ * ```
35
+ */
24
36
  Item: ErrorSummaryItemType;
25
37
  }
26
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,gBAA0C,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA8BnC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,IAAI,EACjB,OAAO,OAER,EADI,IAAI,cANT,0DAOC,CADQ;IAIT,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAE1B,OAAO,CACL,+CACE,GAAG,EAAE,GAAG,IACJ,IAAI,IACR,SAAS,EAAE,EAAE,CACX,SAAS,EACT,qBAAqB,EACrB,wBAAwB,IAAI,EAAE,CAC/B,EACD,QAAQ,EAAE,CAAC,CAAC,eACF,QAAQ,mBACJ,KAAK,qBACF,SAAS;QAE1B,oBAAC,OAAO,IACN,SAAS,EAAC,8BAA8B,EACxC,EAAE,EAAE,UAAU,EACd,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,SAAS,IAEZ,OAAO,CACA;QACV,oBAAC,SAAS,IAAC,EAAE,EAAC,IAAI,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,2BAA2B,IACjE,KAAK,CAAC,QAAQ,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EAAE,SAAS,IAEZ,OAAO,CACA;QACV,oBAAC,SAAS,IAAC,EAAE,EAAC,IAAI,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,2BAA2B,IACjE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACtC,OAAO,4BAAI,GAAG,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,IAAG,KAAK,CAAM,CAAC;QAClD,CAAC,CAAC,CACQ,CACJ,CACX,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,YAAY,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAErC,eAAe,YAAY,CAAC"}
@@ -5,6 +5,10 @@ export interface ErrorSummaryItemProps extends React.AnchorHTMLAttributes<HTMLAn
5
5
  * Link text
6
6
  */
7
7
  children: React.ReactNode;
8
+ /**
9
+ * Link to errormessage
10
+ */
11
+ href?: string;
8
12
  }
9
13
  export type ErrorSummaryItemType = OverridableComponent<ErrorSummaryItemProps, HTMLAnchorElement>;
10
14
  export declare const ErrorSummaryItem: ErrorSummaryItemType;
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAgBtB,MAAM,CAAC,MAAM,gBAAgB,GAAyB,UAAU,CAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ErrorSummaryItem.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummaryItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAoBtB,MAAM,CAAC,MAAM,gBAAgB,GAAyB,UAAU,CAC9D,CAAC,EAAqD,EAAE,GAAG,EAAE,EAAE;QAA9D,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,OAAW,EAAN,IAAI,cAAnD,+BAAqD,CAAF;IAClD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,YAAY,CAAC,KAElE,QAAQ,CACC,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -12,6 +12,10 @@ export interface HelpTextProps extends React.ButtonHTMLAttributes<HTMLButtonElem
12
12
  * @default "top"
13
13
  */
14
14
  placement?: "top" | "bottom" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end";
15
+ /**
16
+ * Classname for wrapper
17
+ */
18
+ wrapperClassName?: string;
15
19
  }
16
20
  /**
17
21
  * A component that displays a help text button with a popover.
@@ -27,11 +27,11 @@ import { HelpTextIcon } from "./HelpTextIcon";
27
27
  * ```
28
28
  */
29
29
  export const HelpText = forwardRef((_a, ref) => {
30
- var { className, children, placement = "top", strategy = "absolute", title = "hjelp", onClick } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title", "onClick"]);
30
+ var { className, children, placement = "top", strategy = "absolute", title = "hjelp", onClick, wrapperClassName } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title", "onClick", "wrapperClassName"]);
31
31
  const buttonRef = useRef(null);
32
32
  const mergedRef = useMemo(() => mergeRefs([buttonRef, ref]), [ref]);
33
33
  const [open, setOpen] = useState(false);
34
- return (React.createElement("div", { className: "navds-help-text" },
34
+ return (React.createElement("div", { className: cl("navds-help-text", wrapperClassName) },
35
35
  React.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (e) => {
36
36
  setOpen((x) => !x);
37
37
  onClick === null || onClick === void 0 ? void 0 : onClick(e);
@@ -1 +1 @@
1
- {"version":3,"file":"HelpText.js","sourceRoot":"","sources":["../../src/help-text/HelpText.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,OAAO,EAAgB,SAAS,EAAE,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AA8B9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EAQC,EACD,GAAG,EACH,EAAE;QAVF,EACE,SAAS,EACT,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,UAAU,EACrB,KAAK,GAAG,OAAO,EACf,OAAO,OAER,EADI,IAAI,cAPT,sEAQC,CADQ;IAIT,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CA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;YAElB,oBAAC,OAAO,CAAC,OAAO,IAAC,SAAS,EAAC,kBAAkB,IAC1C,QAAQ,CACO,CACV,CACN,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -10,9 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { autoUpdate, arrow as flArrow, flip, offset, safePolygon, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, } from "@floating-ui/react";
13
- import { useEventListener, mergeRefs } from "../util";
14
13
  import { format } from "date-fns";
15
- import React, { forwardRef, useCallback, useMemo, useRef, useState, } from "react";
14
+ import React, { forwardRef, useMemo, useRef, useState } from "react";
15
+ import { mergeRefs } from "../util";
16
16
  import { useTimelineContext } from "./hooks/useTimelineContext";
17
17
  import { position } from "./utils/calc";
18
18
  export const Pin = forwardRef((_a, ref) => {
@@ -42,15 +42,6 @@ export const Pin = forwardRef((_a, ref) => {
42
42
  useDismiss(context),
43
43
  ]);
44
44
  const mergedRef = useMemo(() => mergeRefs([refs.setReference, ref]), [ref, refs.setReference]);
45
- useEventListener("focusin", useCallback((e) => {
46
- var _a;
47
- if (![
48
- refs.reference.current,
49
- (_a = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _a === void 0 ? void 0 : _a.current,
50
- ].some((element) => element === null || element === void 0 ? void 0 : element.contains(e.target))) {
51
- open && setOpen(false);
52
- }
53
- }, [open, refs.reference, refs === null || refs === void 0 ? void 0 : refs.floating]));
54
45
  const staticSide = {
55
46
  top: "bottom",
56
47
  right: "left",
@@ -73,6 +64,9 @@ export const Pin = forwardRef((_a, ref) => {
73
64
  })))),
74
65
  children && (React.createElement("div", Object.assign({ className: "navds-timeline__popover", "data-placement": placement, "aria-hidden": !open, ref: refs.setFloating }, getFloatingProps({
75
66
  tabIndex: -1,
67
+ onBlur: (e) => e.target.previousSibling !== document.activeElement &&
68
+ open &&
69
+ setOpen(false),
76
70
  }), { style: Object.assign(Object.assign({}, floatingStyles), { display: open ? undefined : "none" }) }),
77
71
  React.createElement("div", { className: "navds-timeline__popover-content" }, children),
78
72
  React.createElement("div", { ref: (node) => {