@navikt/ds-react 4.1.7 → 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.
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": "",
@@ -13622,6 +13664,25 @@
13622
13664
  "name": "ReactNode"
13623
13665
  }
13624
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
+ },
13625
13686
  "className": {
13626
13687
  "defaultValue": null,
13627
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
  });
@@ -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,sBAAsB,EACtB,eAAe,IAAI,yBAAyB,eAAe,EAAE,CAC9D;YAEA,IAAI,IAAI,oBAAC,MAAM,IAAC,SAAS,EAAC,kBAAkB,IAAE,IAAI,CAAU;YAC5D,SAAS,IAAI,CACZ,oBAAC,MAAM,IAAC,SAAS,EAAC,uBAAuB,IAAE,SAAS,CAAU,CAC/D,CACG,CACP;QACA,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
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;AA0BvC,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,4BACE,SAAS,EAAE,EAAE,CACX,sBAAsB,EACtB,eAAe,IAAI,yBAAyB,eAAe,EAAE,CAC9D;YAEA,IAAI,IAAI,oBAAC,MAAM,IAAC,EAAE,EAAC,MAAM,IAAE,IAAI,CAAU;YACzC,IAAI,IAAI,SAAS,IAAI,CACpB,oBAAC,MAAM,IAAC,EAAE,EAAC,MAAM,kCAER,CACV;YACA,SAAS,IAAI,oBAAC,MAAM,IAAC,EAAE,EAAC,MAAM,IAAE,SAAS,CAAU,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,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E,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,SAA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AAY,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "4.1.7",
3
+ "version": "4.2.0",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@floating-ui/react": "0.24.1",
41
- "@navikt/aksel-icons": "^4.1.7",
41
+ "@navikt/aksel-icons": "^4.2.0",
42
42
  "@radix-ui/react-tabs": "1.0.0",
43
43
  "@radix-ui/react-toggle-group": "1.0.0",
44
44
  "clsx": "^1.2.1",
@@ -17,6 +17,7 @@ export interface BubbleProps extends HTMLAttributes<HTMLDivElement> {
17
17
  timestamp?: string;
18
18
  /**
19
19
  * Background color on bubble
20
+ * @deprecated Use `variant` on Chat instead
20
21
  */
21
22
  backgroundColor?: string;
22
23
  /**
@@ -46,17 +47,20 @@ const Bubble = forwardRef<HTMLDivElement, BubbleProps>(
46
47
  {...rest}
47
48
  >
48
49
  {(timestamp || name) && (
49
- <div
50
+ <h3
50
51
  className={cl(
51
52
  `navds-chat__top-text`,
52
53
  toptextPosition && `navds-chat__top-text--${toptextPosition}`
53
54
  )}
54
55
  >
55
- {name && <Detail className="navds-chat__name">{name}</Detail>}
56
- {timestamp && (
57
- <Detail className="navds-chat__timestamp">{timestamp}</Detail>
56
+ {name && <Detail as="span">{name}</Detail>}
57
+ {name && timestamp && (
58
+ <Detail as="span" aria-hidden>
59
+ &bull;
60
+ </Detail>
58
61
  )}
59
- </div>
62
+ {timestamp && <Detail as="span">{timestamp}</Detail>}
63
+ </h3>
60
64
  )}
61
65
  {children}
62
66
  </div>
package/src/chat/Chat.tsx CHANGED
@@ -1,7 +1,10 @@
1
1
  import React, { forwardRef, HTMLAttributes } from "react";
2
2
  import cl from "clsx";
3
- import Bubble, { BubbleProps } from "./Bubble";
4
- import { BodyLong, BodyShort } from "../typography";
3
+ import Bubble from "./Bubble";
4
+ import { BodyLong } from "../typography";
5
+
6
+ export const POSITIONS = ["left", "right"] as const;
7
+ export const SIZES = ["medium", "small"] as const;
5
8
 
6
9
  export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
7
10
  /**
@@ -17,27 +20,40 @@ export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
17
20
  */
18
21
  timestamp?: string;
19
22
  /**
20
- * Avatar for messenger. Regular text for initials works to
23
+ * Avatar for messenger. Regular text for initials works too, but it will be hidden for screen readers.
24
+ */
25
+ avatar?: React.ReactNode;
26
+ /**
27
+ * Changes background color on avatar and bubbles.
28
+ * Avoid using the same background as the surface behind Chat.
29
+ * @default "subtle"
21
30
  */
22
- avatar: React.ReactNode;
31
+ variant?: "subtle" | "info" | "neutral";
23
32
  /**
24
33
  * Background color on bubbles
34
+ * @deprecated Use `variant` instead
25
35
  */
26
36
  backgroundColor?: string;
27
37
  /**
28
38
  * Background color for avatar
39
+ * @deprecated Use `variant` instead
29
40
  */
30
41
  avatarBgColor?: string;
31
42
  /**
32
- * Positions avatar and Bubbles
43
+ * Positions avatar and bubbles
33
44
  * @default "left"
34
45
  */
35
- position?: "left" | "right";
46
+ position?: (typeof POSITIONS)[number];
36
47
  /**
37
48
  * Hoizontal position of toptext
38
- * @default Same as chat
49
+ * @default Same as position
50
+ */
51
+ toptextPosition?: (typeof POSITIONS)[number];
52
+ /**
53
+ * Affects padding and font size in bubbles
54
+ * @default "medium"
39
55
  */
40
- toptextPosition?: "left" | "right";
56
+ size?: (typeof SIZES)[number];
41
57
  }
42
58
 
43
59
  interface ChatComponent
@@ -47,24 +63,23 @@ interface ChatComponent
47
63
  /**
48
64
  * @see 🏷️ {@link BubbleProps}
49
65
  */
50
- Bubble: React.ForwardRefExoticComponent<
51
- BubbleProps & React.RefAttributes<HTMLDivElement>
52
- >;
66
+ Bubble: typeof Bubble;
53
67
  }
54
68
 
55
69
  /**
56
- * A component for displaying chat messages.
70
+ * A component for communicating dialogs between two parties.
57
71
  *
58
72
  * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/chat)
59
73
  * @see 🏷️ {@link ChatProps}
60
74
  *
61
75
  * @example
62
76
  * ```jsx
63
- * <Chat>
64
- * <Chat.Bubble avatar="A" name="Alice">Hello!</Chat.Bubble>
77
+ * <Chat avatar="A" name="Alice" timestamp="01.01.21 14:00">
78
+ * <Chat.Bubble>Hello!</Chat.Bubble>
79
+ * <Chat.Bubble>How can I help you?</Chat.Bubble>
65
80
  * </Chat>
66
- * <Chat>
67
- * <Chat.Bubble avatar="B" name="Bob">Hi there!</Chat.Bubble>
81
+ * <Chat avatar="B" name="Bob" timestamp="01.01.21 14:01" position="right">
82
+ * <Chat.Bubble>Hi there!</Chat.Bubble>
68
83
  * </Chat>
69
84
  * ```
70
85
  */
@@ -77,51 +92,54 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
77
92
  timestamp,
78
93
  avatar,
79
94
  position = "left",
95
+ variant = "subtle",
80
96
  avatarBgColor,
81
97
  backgroundColor,
82
98
  toptextPosition,
99
+ size = "medium",
83
100
  ...rest
84
- },
101
+ }: ChatProps,
85
102
  ref
86
- ) => {
87
- return (
88
- <div
89
- ref={ref}
90
- className={cl(
91
- "navds-chat",
92
- className,
93
- `navds-chat--${position} navds-chat--top-text-${
94
- toptextPosition ?? position
95
- }`
96
- )}
97
- {...rest}
98
- >
99
- <BodyShort
100
- as="div"
103
+ ) => (
104
+ <div
105
+ ref={ref}
106
+ className={cl(
107
+ "navds-chat",
108
+ className,
109
+ `navds-chat--${position}`,
110
+ `navds-chat--top-text-${toptextPosition ?? position}`,
111
+ `navds-chat--${size}`,
112
+ `navds-chat--${variant}`
113
+ )}
114
+ {...rest}
115
+ >
116
+ {avatar && (
117
+ <div
101
118
  className="navds-chat__avatar"
119
+ aria-hidden
102
120
  style={{ backgroundColor: avatarBgColor }}
103
121
  >
104
122
  {avatar}
105
- </BodyShort>
106
- <ol className="navds-chat__bubble-wrapper">
107
- {React.Children.map(children, (child, i) => {
108
- if (React.isValidElement(child)) {
109
- return (
110
- <BodyLong as="li">
111
- {React.cloneElement(child, {
112
- name: name && i === 0 ? name : undefined,
113
- timestamp: timestamp && i === 0 ? timestamp : undefined,
114
- backgroundColor,
115
- ...child.props,
116
- })}
117
- </BodyLong>
118
- );
119
- }
120
- })}
121
- </ol>
122
- </div>
123
- );
124
- }
123
+ </div>
124
+ )}
125
+ <ol className="navds-chat__bubble-wrapper">
126
+ {React.Children.map(children, (child, i) => {
127
+ if (React.isValidElement(child)) {
128
+ return (
129
+ <BodyLong as="li" size={size}>
130
+ {React.cloneElement(child, {
131
+ name: name && i === 0 ? name : undefined,
132
+ timestamp: timestamp && i === 0 ? timestamp : undefined,
133
+ backgroundColor,
134
+ ...child.props,
135
+ })}
136
+ </BodyLong>
137
+ );
138
+ }
139
+ })}
140
+ </ol>
141
+ </div>
142
+ )
125
143
  ) as ChatComponent;
126
144
 
127
145
  Chat.Bubble = Bubble;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { Chat } from "../index";
3
3
  import { Meta } from "@storybook/react";
4
+ import { POSITIONS, SIZES } from "./Chat";
4
5
 
5
6
  export default {
6
7
  title: "ds-react/Chat",
@@ -16,19 +17,25 @@ export default {
16
17
  type: "text",
17
18
  },
18
19
  },
20
+ position: {
21
+ control: { type: "radio" },
22
+ options: POSITIONS,
23
+ },
24
+ toptextPosition: {
25
+ control: { type: "radio" },
26
+ options: POSITIONS,
27
+ },
28
+ size: {
29
+ control: { type: "radio" },
30
+ options: SIZES,
31
+ },
19
32
  },
20
- } as Meta;
33
+ } satisfies Meta<typeof Chat>;
21
34
 
22
35
  export const Default = {
23
36
  render: (props) => {
24
37
  return (
25
- <Chat
26
- avatar={props?.avatar ?? "ON"}
27
- name={props?.name ?? "Ola Normann"}
28
- timestamp={props?.timestamp ?? "01.01.21 14:00"}
29
- avatarBgColor={props?.avatarBgColor}
30
- backgroundColor={props?.backgroundColor}
31
- >
38
+ <Chat {...props}>
32
39
  <Chat.Bubble>
33
40
  Aute minim nisi sunt mollit duis sunt nulla minim non proident.
34
41
  </Chat.Bubble>
@@ -48,141 +55,156 @@ export const Default = {
48
55
  },
49
56
  };
50
57
 
51
- export const Farger = () => {
52
- return (
53
- <Chat
54
- avatar="ON"
55
- name="Ola Normann"
56
- timestamp="01.01.21 14:00"
57
- avatarBgColor="var(--a-lightblue-200)"
58
- backgroundColor="var(--a-lightblue-100)"
59
- >
58
+ export const Small = () => (
59
+ <Chat avatar="ON" name="Ola Normann" timestamp="01.01.21 14:00" size="small">
60
+ <Chat.Bubble>
61
+ Aute minim nisi sunt mollit duis sunt nulla minim non proident.
62
+ </Chat.Bubble>
63
+ <Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
64
+ <Chat.Bubble>
65
+ Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
66
+ labore nisi ut.
67
+ </Chat.Bubble>
68
+ </Chat>
69
+ );
70
+
71
+ export const Colors = () => (
72
+ <Chat
73
+ avatar="NAV"
74
+ name="NAV"
75
+ timestamp="01.01.21 14:00"
76
+ avatarBgColor="var(--a-surface-alt-1-subtle)"
77
+ backgroundColor="var(--a-surface-warning-subtle)"
78
+ >
79
+ <Chat.Bubble>
80
+ Aute minim nisi sunt mollit duis sunt nulla minim non proident.
81
+ </Chat.Bubble>
82
+ <Chat.Bubble backgroundColor="lightYellow">
83
+ Tempor fugiat amet eu sint in in ullamco.
84
+ </Chat.Bubble>
85
+ <Chat.Bubble>
86
+ Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
87
+ labore nisi ut.
88
+ </Chat.Bubble>
89
+ </Chat>
90
+ );
91
+
92
+ export const Variants = () => (
93
+ <div className="colgap">
94
+ <Chat avatar="NAV" name="NAV" timestamp="01.01.21 14:00" variant="info">
60
95
  <Chat.Bubble>
61
96
  Aute minim nisi sunt mollit duis sunt nulla minim non proident.
62
97
  </Chat.Bubble>
98
+ </Chat>
99
+ <Chat
100
+ avatar="KN"
101
+ name="Kari Nordmann"
102
+ timestamp="01.01.21 14:03"
103
+ variant="neutral"
104
+ position="right"
105
+ >
63
106
  <Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
107
+ </Chat>
108
+ <Chat
109
+ avatar="ON"
110
+ name="Ola Nordmann"
111
+ timestamp="01.01.21 14:07"
112
+ variant="subtle"
113
+ position="right"
114
+ >
64
115
  <Chat.Bubble>
65
116
  Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
66
117
  labore nisi ut.
67
118
  </Chat.Bubble>
68
119
  </Chat>
69
- );
70
- };
71
-
72
- export const Position = () => {
73
- return (
74
- <div className="colgap">
75
- <Chat
76
- avatar="ON"
77
- name="Ola Normann"
78
- timestamp="01.01.21 14:00"
79
- backgroundColor="rgba(255, 249, 240, 1)"
80
- avatarBgColor="rgba(255, 236, 204, 1)"
81
- >
82
- <Chat.Bubble>
83
- Adipisicing laborum est eu laborum est sit in commodo enim sint
84
- laboris labore nisi ut.
85
- </Chat.Bubble>
86
- </Chat>
87
- <Chat
88
- avatar="KH"
89
- name="Kari Høyli"
90
- timestamp="01.01.21 14:32"
91
- position="right"
92
- backgroundColor="rgba(230, 240, 255, 1)"
93
- avatarBgColor="rgba(204, 225, 255, 1)"
94
- >
95
- <Chat.Bubble>
96
- Reprehenderit pariatur officia exercitation laboris.
97
- </Chat.Bubble>
98
- <Chat.Bubble>
99
- Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit
100
- est dolore incididunt. Occaecat cupidatat magna.
101
- </Chat.Bubble>
102
- </Chat>
103
- <Chat
104
- avatar="ON"
105
- name="Ola Normann"
106
- timestamp="01.01.21 15:00"
107
- backgroundColor="rgba(255, 249, 240, 1)"
108
- avatarBgColor="rgba(255, 236, 204, 1)"
109
- >
110
- <Chat.Bubble>
111
- Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
112
- dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo
113
- ea esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
114
- labore sunt aute.
115
- </Chat.Bubble>
116
- </Chat>
117
- </div>
118
- );
119
- };
120
-
121
- export const ToptextPosition = () => {
122
- return (
123
- <div className="colgap">
124
- <Chat
125
- avatar="ON"
126
- name="Ola Normann"
127
- timestamp="01.01.21 14:00"
128
- backgroundColor="rgba(255, 249, 240, 1)"
129
- avatarBgColor="rgba(255, 236, 204, 1)"
130
- toptextPosition="right"
131
- >
132
- <Chat.Bubble>
133
- Adipisicing laborum est eu laborum est sit in commodo enim sint
134
- laboris labore nisi ut.
135
- </Chat.Bubble>
136
- </Chat>
137
- <Chat
138
- avatar="KH"
139
- name="Kari Høyli"
140
- timestamp="01.01.21 14:32"
141
- position="right"
142
- backgroundColor="rgba(230, 240, 255, 1)"
143
- avatarBgColor="rgba(204, 225, 255, 1)"
144
- toptextPosition="left"
145
- >
146
- <Chat.Bubble>
147
- Reprehenderit pariatur officia exercitation laboris.
148
- </Chat.Bubble>
149
- <Chat.Bubble>
150
- Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit
151
- est dolore incididunt. Occaecat cupidatat magna.
152
- </Chat.Bubble>
153
- </Chat>
154
- <Chat
155
- avatar="ON"
156
- name="Ola Normann"
157
- timestamp="01.01.21 15:00"
158
- backgroundColor="rgba(255, 249, 240, 1)"
159
- avatarBgColor="rgba(255, 236, 204, 1)"
160
- >
161
- <Chat.Bubble toptextPosition="right">
162
- Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
163
- dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo
164
- ea esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
165
- labore sunt aute.
166
- </Chat.Bubble>
167
- </Chat>
168
- </div>
169
- );
170
- };
120
+ </div>
121
+ );
171
122
 
172
- export const Avatar = () => {
173
- return (
174
- <Chat avatar={<Illustration />} timestamp="01.01.21 14:00">
123
+ export const Position = () => (
124
+ <div className="colgap">
125
+ <Chat avatar="ON" name="Ola Normann" timestamp="01.01.21 14:00">
175
126
  <Chat.Bubble>
176
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
127
+ Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
128
+ labore nisi ut.
177
129
  </Chat.Bubble>
178
- <Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
130
+ </Chat>
131
+ <Chat
132
+ avatar="KH"
133
+ name="Kari Høyli"
134
+ timestamp="01.01.21 14:32"
135
+ position="right"
136
+ variant="info"
137
+ >
138
+ <Chat.Bubble>
139
+ Reprehenderit pariatur officia exercitation laboris.
140
+ </Chat.Bubble>
141
+ <Chat.Bubble>
142
+ Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit est
143
+ dolore incididunt. Occaecat cupidatat magna.
144
+ </Chat.Bubble>
145
+ </Chat>
146
+ <Chat avatar="ON" name="Ola Normann" timestamp="01.01.21 15:00">
147
+ <Chat.Bubble>
148
+ Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
149
+ dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo ea
150
+ esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
151
+ labore sunt aute.
152
+ </Chat.Bubble>
153
+ </Chat>
154
+ </div>
155
+ );
156
+
157
+ export const ToptextPosition = () => (
158
+ <div className="colgap">
159
+ <Chat
160
+ avatar="ON"
161
+ name="Ola Normann"
162
+ timestamp="01.01.21 14:00"
163
+ toptextPosition="right"
164
+ >
179
165
  <Chat.Bubble>
180
166
  Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
181
167
  labore nisi ut.
182
168
  </Chat.Bubble>
183
169
  </Chat>
184
- );
185
- };
170
+ <Chat
171
+ name="Kari Høyli"
172
+ timestamp="01.01.21 14:32"
173
+ position="right"
174
+ variant="info"
175
+ toptextPosition="left"
176
+ >
177
+ <Chat.Bubble>
178
+ Reprehenderit pariatur officia exercitation laboris.
179
+ </Chat.Bubble>
180
+ <Chat.Bubble>
181
+ Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit est
182
+ dolore incididunt. Occaecat cupidatat magna.
183
+ </Chat.Bubble>
184
+ </Chat>
185
+ <Chat avatar="ON" name="Ola Normann" timestamp="01.01.21 15:00">
186
+ <Chat.Bubble toptextPosition="right">
187
+ Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
188
+ dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo ea
189
+ esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
190
+ labore sunt aute.
191
+ </Chat.Bubble>
192
+ </Chat>
193
+ </div>
194
+ );
195
+
196
+ export const Avatar = () => (
197
+ <Chat avatar={<Illustration />} timestamp="01.01.21 14:00">
198
+ <Chat.Bubble>
199
+ Aute minim nisi sunt mollit duis sunt nulla minim non proident.
200
+ </Chat.Bubble>
201
+ <Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
202
+ <Chat.Bubble>
203
+ Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
204
+ labore nisi ut.
205
+ </Chat.Bubble>
206
+ </Chat>
207
+ );
186
208
 
187
209
  const Illustration = () => (
188
210
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 93">
@@ -29,6 +29,18 @@ interface ErrorSummaryComponent
29
29
  extends React.ForwardRefExoticComponent<
30
30
  ErrorSummaryProps & React.RefAttributes<HTMLDivElement>
31
31
  > {
32
+ /**
33
+ * Link to error
34
+ *
35
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
36
+ *
37
+ * @example
38
+ * ```jsx
39
+ * <ErrorSummary.Item href="#1">
40
+ * Felt må fylles ut med alder
41
+ * </ErrorSummary.Item>
42
+ * ```
43
+ */
32
44
  Item: ErrorSummaryItemType;
33
45
  }
34
46
 
@@ -8,6 +8,10 @@ export interface ErrorSummaryItemProps
8
8
  * Link text
9
9
  */
10
10
  children: React.ReactNode;
11
+ /**
12
+ * Link to errormessage
13
+ */
14
+ href?: string;
11
15
  }
12
16
 
13
17
  export type ErrorSummaryItemType = OverridableComponent<