@navikt/ds-react 2.0.14 → 2.0.16

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
@@ -701,6 +701,25 @@
701
701
  "name": "string"
702
702
  }
703
703
  },
704
+ "toptextPosition": {
705
+ "defaultValue": null,
706
+ "description": "Overrides hoizontal position of toptext",
707
+ "name": "toptextPosition",
708
+ "parent": {
709
+ "fileName": "src/chat/Bubble.tsx",
710
+ "name": "BubbleProps"
711
+ },
712
+ "declarations": [
713
+ {
714
+ "fileName": "src/chat/Bubble.tsx",
715
+ "name": "BubbleProps"
716
+ }
717
+ ],
718
+ "required": false,
719
+ "type": {
720
+ "name": "\"left\" | \"right\""
721
+ }
722
+ },
704
723
  "className": {
705
724
  "defaultValue": null,
706
725
  "description": "",
@@ -880,6 +899,27 @@
880
899
  "name": "\"left\" | \"right\""
881
900
  }
882
901
  },
902
+ "toptextPosition": {
903
+ "defaultValue": {
904
+ "value": "Same as chat"
905
+ },
906
+ "description": "Hoizontal position of toptext",
907
+ "name": "toptextPosition",
908
+ "parent": {
909
+ "fileName": "src/chat/Chat.tsx",
910
+ "name": "ChatProps"
911
+ },
912
+ "declarations": [
913
+ {
914
+ "fileName": "src/chat/Chat.tsx",
915
+ "name": "ChatProps"
916
+ }
917
+ ],
918
+ "required": false,
919
+ "type": {
920
+ "name": "\"left\" | \"right\""
921
+ }
922
+ },
883
923
  "className": {
884
924
  "defaultValue": null,
885
925
  "description": "",
@@ -41,9 +41,9 @@ const react_1 = __importStar(require("react"));
41
41
  const clsx_1 = __importDefault(require("clsx"));
42
42
  const typography_1 = require("../typography");
43
43
  const Bubble = (0, react_1.forwardRef)((_a, ref) => {
44
- var { children, className, name, timestamp, backgroundColor } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "backgroundColor"]);
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: "navds-chat__top-text" },
46
+ (timestamp || name) && (react_1.default.createElement("div", { className: (0, clsx_1.default)(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
47
47
  name && react_1.default.createElement(typography_1.Detail, { className: "navds-chat__name" }, name),
48
48
  timestamp && (react_1.default.createElement(typography_1.Detail, { className: "navds-chat__timestamp" }, timestamp)))),
49
49
  children));
package/cjs/chat/Chat.js CHANGED
@@ -43,8 +43,8 @@ const clsx_1 = __importDefault(require("clsx"));
43
43
  const Bubble_1 = __importDefault(require("./Bubble"));
44
44
  const __1 = require("..");
45
45
  exports.Chat = (0, react_1.forwardRef)((_a, ref) => {
46
- var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor"]);
47
- return (react_1.default.createElement("div", Object.assign({ ref: ref, className: (0, clsx_1.default)("navds-chat", className, `navds-chat--${position}`) }, rest),
46
+ var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor", "toptextPosition"]);
47
+ 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),
48
48
  react_1.default.createElement(__1.BodyShort, { as: "div", className: "navds-chat__avatar", style: { backgroundColor: avatarBgColor } }, avatar),
49
49
  react_1.default.createElement("ol", { className: "navds-chat__bubble-wrapper" }, react_1.default.Children.map(children, (child, i) => {
50
50
  if (react_1.default.isValidElement(child)) {
@@ -16,6 +16,10 @@ export interface BubbleProps extends HTMLAttributes<HTMLDivElement> {
16
16
  * Background color on bubble
17
17
  */
18
18
  backgroundColor?: string;
19
+ /**
20
+ * Overrides hoizontal position of toptext
21
+ */
22
+ toptextPosition?: "left" | "right";
19
23
  }
20
24
  export type BubbleType = React.ForwardRefExoticComponent<BubbleProps & React.RefAttributes<HTMLDivElement>>;
21
25
  declare const Bubble: BubbleType;
@@ -13,9 +13,9 @@ import React, { forwardRef } from "react";
13
13
  import cl from "clsx";
14
14
  import { Detail } from "../typography";
15
15
  const Bubble = forwardRef((_a, ref) => {
16
- var { children, className, name, timestamp, backgroundColor } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "backgroundColor"]);
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: "navds-chat__top-text" },
18
+ (timestamp || name) && (React.createElement("div", { className: cl(`navds-chat__top-text`, toptextPosition && `navds-chat__top-text--${toptextPosition}`) },
19
19
  name && React.createElement(Detail, { className: "navds-chat__name" }, name),
20
20
  timestamp && (React.createElement(Detail, { className: "navds-chat__timestamp" }, timestamp)))),
21
21
  children));
@@ -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,GAAe,UAAU,CACnC,CAAC,EAAkE,EAAE,GAAG,EAAE,EAAE;QAA3E,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,eA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D;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"}
@@ -30,6 +30,11 @@ export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
30
30
  * @default "left"
31
31
  */
32
32
  position?: "left" | "right";
33
+ /**
34
+ * Hoizontal position of toptext
35
+ * @default Same as chat
36
+ */
37
+ toptextPosition?: "left" | "right";
33
38
  }
34
39
  interface ChatComponent extends React.ForwardRefExoticComponent<ChatProps & React.RefAttributes<HTMLDivElement>> {
35
40
  Bubble: BubbleType;
package/esm/chat/Chat.js CHANGED
@@ -14,8 +14,8 @@ import cl from "clsx";
14
14
  import Bubble from "./Bubble";
15
15
  import { BodyLong, BodyShort } from "..";
16
16
  export const Chat = forwardRef((_a, ref) => {
17
- var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor"]);
18
- return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-chat", className, `navds-chat--${position}`) }, rest),
17
+ var { children, className, name, timestamp, avatar, position = "left", avatarBgColor, backgroundColor, toptextPosition } = _a, rest = __rest(_a, ["children", "className", "name", "timestamp", "avatar", "position", "avatarBgColor", "backgroundColor", "toptextPosition"]);
18
+ 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),
19
19
  React.createElement(BodyShort, { as: "div", className: "navds-chat__avatar", style: { backgroundColor: avatarBgColor } }, avatar),
20
20
  React.createElement("ol", { className: "navds-chat__bubble-wrapper" }, React.Children.map(children, (child, i) => {
21
21
  if (React.isValidElement(child)) {
@@ -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,MAAsB,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAyCzC,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CACE,EAUC,EACD,GAAG,EACH,EAAE;QAZF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,aAAa,EACb,eAAe,OAEhB,EADI,IAAI,cATT,wGAUC,CADQ;IAIT,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,eAAe,QAAQ,EAAE,CAAC,IAC7D,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,CAAC,KAAK,kBACvB,IAAI,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACxC,SAAS,EAAE,SAAS,IAAI,CAA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CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC/B,OAAO,CACL,oBAAC,QAAQ,IAAC,EAAE,EAAC,IAAI,IACd,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,CAAC;AACJ,CAAC,CACe,CAAC;AAEnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAErB,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@floating-ui/react": "0.17.0",
40
- "@navikt/ds-icons": "^2.0.14",
40
+ "@navikt/ds-icons": "^2.0.16",
41
41
  "@radix-ui/react-tabs": "1.0.0",
42
42
  "@radix-ui/react-toggle-group": "1.0.0",
43
43
  "clsx": "^1.2.1",
@@ -19,6 +19,10 @@ export interface BubbleProps extends HTMLAttributes<HTMLDivElement> {
19
19
  * Background color on bubble
20
20
  */
21
21
  backgroundColor?: string;
22
+ /**
23
+ * Overrides hoizontal position of toptext
24
+ */
25
+ toptextPosition?: "left" | "right";
22
26
  }
23
27
 
24
28
  export type BubbleType = React.ForwardRefExoticComponent<
@@ -26,7 +30,18 @@ export type BubbleType = React.ForwardRefExoticComponent<
26
30
  >;
27
31
 
28
32
  const Bubble: BubbleType = forwardRef(
29
- ({ children, className, name, timestamp, backgroundColor, ...rest }, ref) => {
33
+ (
34
+ {
35
+ children,
36
+ className,
37
+ name,
38
+ timestamp,
39
+ backgroundColor,
40
+ toptextPosition,
41
+ ...rest
42
+ },
43
+ ref
44
+ ) => {
30
45
  return (
31
46
  <div
32
47
  ref={ref}
@@ -35,7 +50,12 @@ const Bubble: BubbleType = forwardRef(
35
50
  {...rest}
36
51
  >
37
52
  {(timestamp || name) && (
38
- <div className="navds-chat__top-text">
53
+ <div
54
+ className={cl(
55
+ `navds-chat__top-text`,
56
+ toptextPosition && `navds-chat__top-text--${toptextPosition}`
57
+ )}
58
+ >
39
59
  {name && <Detail className="navds-chat__name">{name}</Detail>}
40
60
  {timestamp && (
41
61
  <Detail className="navds-chat__timestamp">{timestamp}</Detail>
package/src/chat/Chat.tsx CHANGED
@@ -33,6 +33,11 @@ export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
33
33
  * @default "left"
34
34
  */
35
35
  position?: "left" | "right";
36
+ /**
37
+ * Hoizontal position of toptext
38
+ * @default Same as chat
39
+ */
40
+ toptextPosition?: "left" | "right";
36
41
  }
37
42
 
38
43
  interface ChatComponent
@@ -53,6 +58,7 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
53
58
  position = "left",
54
59
  avatarBgColor,
55
60
  backgroundColor,
61
+ toptextPosition,
56
62
  ...rest
57
63
  },
58
64
  ref
@@ -60,7 +66,13 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
60
66
  return (
61
67
  <div
62
68
  ref={ref}
63
- className={cl("navds-chat", className, `navds-chat--${position}`)}
69
+ className={cl(
70
+ "navds-chat",
71
+ className,
72
+ `navds-chat--${position} navds-chat--top-text-${
73
+ toptextPosition ?? position
74
+ }`
75
+ )}
64
76
  {...rest}
65
77
  >
66
78
  <BodyShort
@@ -116,6 +116,57 @@ export const Position = () => {
116
116
  );
117
117
  };
118
118
 
119
+ export const ToptextPosition = () => {
120
+ return (
121
+ <div className="colgap">
122
+ <Chat
123
+ avatar="ON"
124
+ name="Ola Normann"
125
+ timestamp="01.01.21 14:00"
126
+ backgroundColor="rgba(255, 249, 240, 1)"
127
+ avatarBgColor="rgba(255, 236, 204, 1)"
128
+ toptextPosition="right"
129
+ >
130
+ <Chat.Bubble>
131
+ Adipisicing laborum est eu laborum est sit in commodo enim sint
132
+ laboris labore nisi ut.
133
+ </Chat.Bubble>
134
+ </Chat>
135
+ <Chat
136
+ avatar="KH"
137
+ name="Kari Høyli"
138
+ timestamp="01.01.21 14:32"
139
+ position="right"
140
+ backgroundColor="rgba(230, 240, 255, 1)"
141
+ avatarBgColor="rgba(204, 225, 255, 1)"
142
+ toptextPosition="left"
143
+ >
144
+ <Chat.Bubble>
145
+ Reprehenderit pariatur officia exercitation laboris.
146
+ </Chat.Bubble>
147
+ <Chat.Bubble>
148
+ Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit
149
+ est dolore incididunt. Occaecat cupidatat magna.
150
+ </Chat.Bubble>
151
+ </Chat>
152
+ <Chat
153
+ avatar="ON"
154
+ name="Ola Normann"
155
+ timestamp="01.01.21 15:00"
156
+ backgroundColor="rgba(255, 249, 240, 1)"
157
+ avatarBgColor="rgba(255, 236, 204, 1)"
158
+ >
159
+ <Chat.Bubble toptextPosition="right">
160
+ Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
161
+ dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo
162
+ ea esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
163
+ labore sunt aute.
164
+ </Chat.Bubble>
165
+ </Chat>
166
+ </div>
167
+ );
168
+ };
169
+
119
170
  export const Avatar = () => {
120
171
  return (
121
172
  <Chat avatar={<Illustration />} timestamp="01.01.21 14:00">