@helsenorge/designsystem-react 12.4.0 → 12.7.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 (91) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/Drawer.js +33 -8
  3. package/Drawer.js.map +1 -1
  4. package/FormFieldTag.js +48 -0
  5. package/FormFieldTag.js.map +1 -0
  6. package/FormGroup.js +19 -6
  7. package/FormGroup.js.map +1 -1
  8. package/HelpTriggerIcon.js +13 -2
  9. package/HelpTriggerIcon.js.map +1 -1
  10. package/Label.js +3 -0
  11. package/Label.js.map +1 -1
  12. package/LazyIcon.js +1 -1
  13. package/LazyIcon.js.map +1 -1
  14. package/LinkList.js +81 -47
  15. package/LinkList.js.map +1 -1
  16. package/ListEditMode.js +42 -0
  17. package/ListEditMode.js.map +1 -0
  18. package/components/Drawer/Drawer.d.ts +6 -1
  19. package/components/Drawer/resourceHelper.d.ts +3 -0
  20. package/components/ExpanderList/ExpanderList.d.ts +8 -1
  21. package/components/ExpanderList/index.js +51 -20
  22. package/components/ExpanderList/index.js.map +1 -1
  23. package/components/ExpanderList/styles.module.scss +37 -33
  24. package/components/FavoriteButton/StarIcon.d.ts +4 -4
  25. package/components/FavoriteButton/index.js +23 -18
  26. package/components/FavoriteButton/index.js.map +1 -1
  27. package/components/FavoriteButton/styles.module.scss +8 -0
  28. package/components/FavoriteButton/styles.module.scss.d.ts +1 -0
  29. package/components/FormFieldTag/FormFieldTag.d.ts +15 -0
  30. package/components/FormFieldTag/FormFieldTag.test.d.ts +1 -0
  31. package/components/FormFieldTag/index.d.ts +3 -0
  32. package/components/FormFieldTag/index.js +5 -0
  33. package/components/FormFieldTag/index.js.map +1 -0
  34. package/components/FormFieldTag/resourceHelper.d.ts +3 -0
  35. package/components/FormFieldTag/styles.module.scss +23 -0
  36. package/components/FormFieldTag/styles.module.scss.d.ts +10 -0
  37. package/components/FormGroup/FormGroup.d.ts +4 -0
  38. package/components/FormGroup/styles.module.scss +3 -0
  39. package/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +2 -0
  40. package/components/HelpTriggerIcon/styles.module.scss +1 -1
  41. package/components/Icons/AdditionalIconInformation.d.ts +4 -0
  42. package/components/Icons/AdditionalIconInformation.js +2 -1
  43. package/components/Icons/AdditionalIconInformation.js.map +1 -1
  44. package/components/Icons/Feedback.d.ts +4 -0
  45. package/components/Icons/Feedback.js +25 -0
  46. package/components/Icons/Feedback.js.map +1 -0
  47. package/components/Icons/IconNames.d.ts +1 -1
  48. package/components/Icons/IconNames.js +1 -0
  49. package/components/Icons/IconNames.js.map +1 -1
  50. package/components/Label/Label.d.ts +2 -0
  51. package/components/LinkList/LinkList.d.ts +8 -1
  52. package/components/LinkList/index.js +2 -0
  53. package/components/LinkList/index.js.map +1 -1
  54. package/components/LinkList/styles.module.scss +30 -22
  55. package/components/List/stories.module.scss +7 -0
  56. package/components/List/stories.module.scss.d.ts +9 -0
  57. package/components/ListEditMode/ListEditMode.d.ts +29 -0
  58. package/components/ListEditMode/index.d.ts +3 -0
  59. package/components/ListEditMode/index.js +9 -0
  60. package/components/ListEditMode/index.js.map +1 -0
  61. package/components/ListEditMode/styles.module.scss +79 -0
  62. package/components/ListEditMode/styles.module.scss.d.ts +18 -0
  63. package/components/Panel/styles.module.scss +5 -2
  64. package/components/PopMenu/index.js +1 -1
  65. package/components/PopMenu/index.js.map +1 -1
  66. package/components/PopMenu/styles.module.scss +4 -0
  67. package/components/PopMenu/styles.module.scss.d.ts +1 -0
  68. package/components/RadioButton/styles.module.scss +22 -4
  69. package/components/StickyNote/Close.d.ts +11 -0
  70. package/components/StickyNote/Triangle.d.ts +5 -1
  71. package/components/StickyNote/index.js +100 -49
  72. package/components/StickyNote/index.js.map +1 -1
  73. package/components/StickyNote/styles.module.scss +106 -34
  74. package/components/StickyNote/styles.module.scss.d.ts +6 -1
  75. package/components/Tabs/Tabs.d.ts +6 -3
  76. package/components/Tabs/index.js +38 -4
  77. package/components/Tabs/index.js.map +1 -1
  78. package/components/Tabs/resourceHelper.d.ts +3 -0
  79. package/constants.d.ts +1 -0
  80. package/constants.js +1 -0
  81. package/constants.js.map +1 -1
  82. package/designsystem-react.css +136 -98
  83. package/package.json +1 -1
  84. package/resources/HN.Designsystem.Drawer.en-GB.json.d.ts +6 -0
  85. package/resources/HN.Designsystem.Drawer.nb-NO.json.d.ts +6 -0
  86. package/resources/HN.Designsystem.FormFieldTag.nb-NO.json.d.ts +8 -0
  87. package/resources/HN.Designsystem.Tabs.en-GB.json.d.ts +7 -0
  88. package/resources/HN.Designsystem.Tabs.nb-NO.json.d.ts +7 -0
  89. package/scss/supernova/styles/colors.css +136 -98
  90. package/scss/supernova/styles/typography.css +2 -2
  91. package/components/Tabs/TabsDocs.d.ts +0 -1
@@ -11,11 +11,30 @@ $padding-clickable-area-left: 8px;
11
11
 
12
12
  @mixin dashed-border() {
13
13
  box-shadow: none;
14
+ position: relative;
14
15
 
15
- $encoded-color: string.slice(meta.inspect(palette.$neutral600), 2);
16
+ &::after {
17
+ position: absolute;
18
+ content: '';
16
19
 
17
- background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='100' ry='100' stroke='%23" + $encoded-color + "' stroke-width='4' stroke-dasharray='0.5, 7' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
18
- border-radius: 100px;
20
+ $encoded-color: string.slice(meta.inspect(palette.$neutral600), 2);
21
+
22
+ // Variabler for å lettere styre dashen i background-imaget under
23
+ $stroke: 4;
24
+ $dash: 0.2;
25
+ $gap: 7;
26
+ $scale: 1;
27
+ $stroke-scaled: $stroke * $scale;
28
+ $dash-scaled: $dash * $scale;
29
+ $gap-scaled: $gap * $scale;
30
+
31
+ border-radius: 100px;
32
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' rx='100' ry='100' stroke='%23#{$encoded-color}' stroke-width='#{$stroke-scaled}' stroke-dasharray='#{$dash-scaled},#{$gap-scaled}' stroke-linecap='square'/%3E%3C/svg%3E");
33
+ background-repeat: no-repeat;
34
+ width: 28px;
35
+ height: 28px;
36
+ inset: -2px;
37
+ }
19
38
  }
20
39
 
21
40
  .radio-button-errors {
@@ -26,7 +45,6 @@ $padding-clickable-area-left: 8px;
26
45
  }
27
46
 
28
47
  .radio-button-wrapper {
29
- cursor: pointer;
30
48
  margin-left: -$padding-clickable-area-left;
31
49
 
32
50
  &__large {
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export interface CloseProps {
3
+ /** Function is called when user clicks the button */
4
+ onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
5
+ /** Sets the aria-label of the button */
6
+ ariaLabel?: string;
7
+ /** Sets the data-testid attribute. */
8
+ testId?: string;
9
+ }
10
+ declare const Close: React.ForwardRefExoticComponent<CloseProps & React.RefAttributes<HTMLButtonElement>>;
11
+ export default Close;
@@ -1,5 +1,9 @@
1
+ import { default as React } from 'react';
1
2
  interface TriangleProps {
2
- type: 'default' | 'active' | 'error';
3
+ isHover: boolean;
4
+ isFocus: boolean;
5
+ isActive: boolean;
6
+ isError: boolean;
3
7
  }
4
8
  export interface Palette {
5
9
  border: string;
@@ -1,46 +1,107 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useRef, useLayoutEffect } from "react";
1
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
+ import React__default, { useRef, useLayoutEffect } from "react";
3
3
  import classNames from "classnames";
4
4
  import { useHover } from "../../hooks/useHover.js";
5
- import { usePseudoClasses } from "../../hooks/usePseudoClasses.js";
5
+ import { useIsMobileBreakpoint } from "../../hooks/useIsMobileBreakpoint.js";
6
+ import { mergeRefs } from "../../utils/refs.js";
6
7
  import { I as Icon } from "../../Icon.js";
7
- import { IconSize } from "../../constants.js";
8
- import { useUuid } from "../../hooks/useUuid.js";
9
- import { getAriaDescribedBy } from "../../utils/accessibility.js";
10
8
  import X from "../Icons/X.js";
11
9
  import styles from "./styles.module.scss";
12
- const Triangle = ({ type }) => {
10
+ import { usePseudoClasses } from "../../hooks/usePseudoClasses.js";
11
+ import { useUuid } from "../../hooks/useUuid.js";
12
+ import { getAriaDescribedBy } from "../../utils/accessibility.js";
13
+ const Close = React__default.forwardRef(function ButtonForwardedRef(props, ref) {
14
+ const { testId, ariaLabel = "Lukk", onClick } = props;
15
+ const { hoverRef, isHovered } = useHover();
16
+ const iconSize = useIsMobileBreakpoint() ? 38 : 48;
17
+ const closeClasses = classNames(styles.close);
18
+ return /* @__PURE__ */ jsx(
19
+ "button",
20
+ {
21
+ ref: mergeRefs([ref, hoverRef]),
22
+ "data-testid": testId,
23
+ className: closeClasses,
24
+ "aria-label": ariaLabel,
25
+ onClick,
26
+ type: "button",
27
+ children: /* @__PURE__ */ jsx("span", { className: classNames(styles["close__inner-container"]), children: /* @__PURE__ */ jsx(Icon, { svgIcon: X, color: "black", size: iconSize, isHovered }) })
28
+ }
29
+ );
30
+ });
31
+ const Triangle = ({ isHover, isFocus, isActive, isError }) => {
13
32
  const palette = (() => {
14
- switch (type) {
15
- case "active":
16
- return {
17
- border: "#C59302",
18
- background: "#F5E080"
19
- };
20
- case "error":
21
- return {
22
- border: "#C83521",
23
- background: "#EEC0A5"
24
- };
25
- default:
26
- return {
27
- border: "#F5E080",
28
- background: "#F5E080"
29
- };
33
+ const colors = {
34
+ border: "var(--component-stickynote-border-normal)",
35
+ background: "var(--component-stickynote-background-fold-normal-light)"
36
+ };
37
+ if (!isError) {
38
+ if (isHover) {
39
+ colors.background = "var(--component-stickynote-background-fold-normal-medium)";
40
+ }
41
+ if (isFocus) {
42
+ colors.border = "var(--color-action-border-onlight-focus)";
43
+ colors.background = "var(--component-stickynote-background-fold-normal-medium)";
44
+ }
45
+ if (isActive) {
46
+ colors.background = "var(--component-stickynote-background-fold-normal-dark)";
47
+ }
48
+ } else {
49
+ colors.border = "var(--component-stickynote-border-error)";
50
+ colors.background = "var(--component-stickynote-background-fold-error-light)";
51
+ if (isHover) {
52
+ colors.background = "var(--component-stickynote-background-fold-error-medium)";
53
+ }
54
+ if (isFocus) {
55
+ colors.border = "var(--color-action-border-onlight-focus)";
56
+ colors.background = "var(--component-stickynote-background-fold-error-medium)";
57
+ }
58
+ if (isActive) {
59
+ colors.background = "var(--component-stickynote-background-fold-error-dark)";
60
+ }
30
61
  }
62
+ return colors;
31
63
  })();
32
- return /* @__PURE__ */ jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
33
- /* @__PURE__ */ jsx("mask", { id: "path-1-inside-1_1_44", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M22 0L1.80043e-06 22L2.83099e-06 -8.97354e-07L22 0Z" }) }),
34
- /* @__PURE__ */ jsx("path", { d: "M22 0L1.80043e-06 22L2.83099e-06 -8.97354e-07L22 0Z", fill: palette.background }),
35
- /* @__PURE__ */ jsx(
36
- "path",
37
- {
38
- d: "M22 0L22.7071 0.707107L24.4142 -1L22 -1L22 0ZM1.80043e-06 22L-0.999998 22L-0.999998 24.4142L0.707109 22.7071L1.80043e-06 22ZM2.83099e-06 -8.97354e-07L2.87783e-06 -1L-0.999997 -1L-0.999997 -9.38143e-07L2.83099e-06 -8.97354e-07ZM21.2929 -0.707107L-0.707105 21.2929L0.707109 22.7071L22.7071 0.707107L21.2929 -0.707107ZM1 22L1 -8.56565e-07L-0.999997 -9.38143e-07L-0.999998 22L1 22ZM2.78414e-06 0.999999L22 1L22 -1L2.87783e-06 -1L2.78414e-06 0.999999Z",
39
- fill: palette.border,
40
- mask: "url(#path-1-inside-1_1_44)"
41
- }
42
- )
43
- ] });
64
+ let svg;
65
+ if (isFocus) {
66
+ svg = /* @__PURE__ */ jsxs("svg", { width: "21", height: "21", viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
67
+ /* @__PURE__ */ jsx("mask", { id: "path-1-inside-1_7753_1401", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M0.493163 20.9211L0.276366 20.9211L0.276367 0.921142L20.2764 0.921143L20.2764 1.13794L0.493163 20.9211Z" }) }),
68
+ /* @__PURE__ */ jsx(
69
+ "path",
70
+ {
71
+ d: "M0.493163 20.9211L0.276366 20.9211L0.276367 0.921142L20.2764 0.921143L20.2764 1.13794L0.493163 20.9211Z",
72
+ fill: palette.background
73
+ }
74
+ ),
75
+ /* @__PURE__ */ jsx(
76
+ "path",
77
+ {
78
+ d: "M0.493163 20.9211L0.493163 22.9211L1.32159 22.9211L1.90738 22.3354L0.493163 20.9211ZM0.276366 20.9211L-1.72363 20.9211L-1.72363 22.9211L0.276366 22.9211L0.276366 20.9211ZM0.276367 0.921142L0.276367 -1.07886L-1.72363 -1.07886L-1.72363 0.921142L0.276367 0.921142ZM20.2764 0.921143L22.2764 0.921143L22.2764 -1.07886L20.2764 -1.07886L20.2764 0.921143ZM20.2764 1.13794L21.6906 2.55215L22.2764 1.96637L22.2764 1.13794L20.2764 1.13794ZM0.493163 20.9211L0.493163 18.9211L0.276366 18.9211L0.276366 20.9211L0.276366 22.9211L0.493163 22.9211L0.493163 20.9211ZM0.276366 20.9211L2.27637 20.9211L2.27637 0.921142L0.276367 0.921142L-1.72363 0.921142L-1.72363 20.9211L0.276366 20.9211ZM0.276367 0.921142L0.276367 2.92114L20.2764 2.92114L20.2764 0.921143L20.2764 -1.07886L0.276367 -1.07886L0.276367 0.921142ZM20.2764 0.921143L18.2764 0.921142L18.2764 1.13794L20.2764 1.13794L22.2764 1.13794L22.2764 0.921143L20.2764 0.921143ZM20.2764 1.13794L18.8622 -0.276274L-0.92105 19.5069L0.493163 20.9211L1.90738 22.3354L21.6906 2.55215L20.2764 1.13794Z",
79
+ fill: palette.border,
80
+ mask: "url(#path-1-inside-1_7753_1401)"
81
+ }
82
+ )
83
+ ] });
84
+ } else {
85
+ svg = /* @__PURE__ */ jsxs("svg", { width: "21", height: "21", viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
86
+ /* @__PURE__ */ jsx("mask", { id: "path-1-inside-1_7717_293537", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M0.923827 20.9211L0.70703 20.9211L0.707031 0.921142L20.707 0.921143L20.707 1.13794L0.923827 20.9211Z" }) }),
87
+ /* @__PURE__ */ jsx(
88
+ "path",
89
+ {
90
+ d: "M0.923827 20.9211L0.70703 20.9211L0.707031 0.921142L20.707 0.921143L20.707 1.13794L0.923827 20.9211Z",
91
+ fill: palette.background
92
+ }
93
+ ),
94
+ /* @__PURE__ */ jsx(
95
+ "path",
96
+ {
97
+ d: "M0.923827 20.9211L0.923827 21.9211L1.33804 21.9211L1.63093 21.6282L0.923827 20.9211ZM0.70703 20.9211L-0.29297 20.9211L-0.29297 21.9211L0.70703 21.9211L0.70703 20.9211ZM0.707031 0.921142L0.707031 -0.0788582L-0.292969 -0.0788583L-0.292969 0.921142L0.707031 0.921142ZM20.707 0.921143L21.707 0.921143L21.707 -0.0788574L20.707 -0.0788574L20.707 0.921143ZM20.707 1.13794L21.4141 1.84505L21.707 1.55215L21.707 1.13794L20.707 1.13794ZM0.923827 20.9211L0.923827 19.9211L0.70703 19.9211L0.70703 20.9211L0.70703 21.9211L0.923827 21.9211L0.923827 20.9211ZM0.70703 20.9211L1.70703 20.9211L1.70703 0.921142L0.707031 0.921142L-0.292969 0.921142L-0.29297 20.9211L0.70703 20.9211ZM0.707031 0.921142L0.707031 1.92114L20.707 1.92114L20.707 0.921143L20.707 -0.0788574L0.707031 -0.0788582L0.707031 0.921142ZM20.707 0.921143L19.707 0.921143L19.707 1.13794L20.707 1.13794L21.707 1.13794L21.707 0.921143L20.707 0.921143ZM20.707 1.13794L19.9999 0.430833L0.21672 20.214L0.923827 20.9211L1.63093 21.6282L21.4141 1.84505L20.707 1.13794Z",
98
+ fill: palette.border,
99
+ mask: "url(#path-1-inside-1_7717_293537)"
100
+ }
101
+ )
102
+ ] });
103
+ }
104
+ return /* @__PURE__ */ jsx(Fragment, { children: svg });
44
105
  };
45
106
  const StickyNote = (props) => {
46
107
  const {
@@ -60,8 +121,7 @@ const StickyNote = (props) => {
60
121
  const stickynoteRef = useRef(null);
61
122
  const textareaRef = useRef(null);
62
123
  const { isFocused: isTextareaFocused } = usePseudoClasses(textareaRef);
63
- const { isHovered } = useHover(stickynoteRef);
64
- const triangleType = error ? "error" : isTextareaFocused ? "active" : "default";
124
+ const { isHovered, isActive } = usePseudoClasses(stickynoteRef);
65
125
  const handleWrapperClick = (event) => {
66
126
  var _a;
67
127
  if (event.target.closest("button")) {
@@ -99,6 +159,7 @@ const StickyNote = (props) => {
99
159
  ref: stickynoteRef,
100
160
  className: classNames(styles["sticky-note"], wrapperClassName, {
101
161
  [styles["sticky-note--focused"]]: isTextareaFocused,
162
+ [styles["sticky-note--active"]]: isActive,
102
163
  [styles["sticky-note--hovered"]]: isHovered && !isTextareaFocused && !textareaProps.disabled,
103
164
  [styles["sticky-note--error"]]: error
104
165
  }),
@@ -123,19 +184,9 @@ const StickyNote = (props) => {
123
184
  "aria-describedby": getAriaDescribedBy(props, errorTextUuid)
124
185
  }
125
186
  ),
126
- /* @__PURE__ */ jsx(
127
- "button",
128
- {
129
- onClick: onXButtonClick,
130
- "aria-label": arialabelXButton,
131
- "data-testid": "closeButton",
132
- className: classNames(styles["sticky-note__x-button"]),
133
- type: "button",
134
- children: /* @__PURE__ */ jsx(Icon, { svgIcon: X, color: "black", size: IconSize.XXSmall })
135
- }
136
- ),
187
+ /* @__PURE__ */ jsx(Close, { onClick: onXButtonClick, ariaLabel: arialabelXButton, testId: "closeButton" }),
137
188
  /* @__PURE__ */ jsx("div", { className: classNames(styles["sticky-note__footer"]), children: footerText && /* @__PURE__ */ jsx("span", { children: footerText }) }),
138
- /* @__PURE__ */ jsx("div", { className: classNames(styles["sticky-note__triangle"]), children: /* @__PURE__ */ jsx(Triangle, { type: triangleType }) })
189
+ /* @__PURE__ */ jsx("div", { className: classNames(styles["sticky-note__triangle"]), children: /* @__PURE__ */ jsx(Triangle, { isHover: isHovered, isActive, isFocus: isTextareaFocused, isError: !!error }) })
139
190
  ]
140
191
  }
141
192
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/StickyNote/Triangle.tsx","../../../src/components/StickyNote/StickyNote.tsx"],"sourcesContent":["interface TriangleProps {\n type: 'default' | 'active' | 'error';\n}\n\nexport interface Palette {\n border: string;\n background: string;\n}\n\nconst Triangle: React.FC<TriangleProps> = ({ type }) => {\n const palette = ((): Palette => {\n switch (type) {\n case 'active':\n return {\n border: '#C59302',\n background: '#F5E080',\n };\n case 'error':\n return {\n border: '#C83521',\n background: '#EEC0A5',\n };\n default:\n return {\n border: '#F5E080',\n background: '#F5E080',\n };\n }\n })();\n return (\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <mask id=\"path-1-inside-1_1_44\" fill=\"white\">\n <path d=\"M22 0L1.80043e-06 22L2.83099e-06 -8.97354e-07L22 0Z\" />\n </mask>\n <path d=\"M22 0L1.80043e-06 22L2.83099e-06 -8.97354e-07L22 0Z\" fill={palette.background} />\n <path\n d=\"M22 0L22.7071 0.707107L24.4142 -1L22 -1L22 0ZM1.80043e-06 22L-0.999998 22L-0.999998 24.4142L0.707109 22.7071L1.80043e-06 22ZM2.83099e-06 -8.97354e-07L2.87783e-06 -1L-0.999997 -1L-0.999997 -9.38143e-07L2.83099e-06 -8.97354e-07ZM21.2929 -0.707107L-0.707105 21.2929L0.707109 22.7071L22.7071 0.707107L21.2929 -0.707107ZM1 22L1 -8.56565e-07L-0.999997 -9.38143e-07L-0.999998 22L1 22ZM2.78414e-06 0.999999L22 1L22 -1L2.87783e-06 -1L2.78414e-06 0.999999Z\"\n fill={palette.border}\n mask=\"url(#path-1-inside-1_1_44)\"\n />\n </svg>\n );\n};\n\nexport default Triangle;\n","import React, { useLayoutEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useHover } from '../../hooks/useHover';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport Icon, { IconSize } from '../Icon';\nimport Triangle from './Triangle';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface StickyNoteProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Aria label for the delete/close button */\n arialabelXButton: string;\n /** Activates the error styling */\n error?: boolean;\n /** Error text to show below the note */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Text shown under the textarea */\n footerText?: string;\n /** Function run when clicking the delete/close button */\n onXButtonClick?: () => void;\n /** Function run if user clicks the component while it is disabled */\n onClickWhileDisabled?: () => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Timestamp shown over the textarea */\n timestamp: string;\n /** Classname for the outer wrapper */\n wrapperClassName?: string;\n}\n\nconst StickyNote: React.FC<StickyNoteProps> = (props: StickyNoteProps) => {\n const {\n wrapperClassName,\n timestamp,\n onXButtonClick,\n arialabelXButton,\n footerText,\n error,\n errorText,\n errorTextId,\n onClickWhileDisabled,\n testId,\n ...textareaProps\n } = props;\n const errorTextUuid = useUuid(errorTextId);\n const stickynoteRef = useRef<HTMLDivElement>(null);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const { isFocused: isTextareaFocused } = usePseudoClasses<HTMLTextAreaElement>(textareaRef);\n const { isHovered } = useHover<HTMLDivElement>(stickynoteRef);\n const triangleType = error ? 'error' : isTextareaFocused ? 'active' : 'default';\n\n const handleWrapperClick = (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>): void => {\n if ((event.target as HTMLElement).closest('button')) {\n return;\n }\n if (textareaProps.disabled) {\n if (onClickWhileDisabled) onClickWhileDisabled();\n return;\n }\n textareaRef.current?.focus();\n };\n\n const resizeTextarea = (): void => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n resizeTarget(textarea);\n };\n\n const resizeTarget = (target: HTMLTextAreaElement): void => {\n // Reset field height\n target.style.height = 'inherit';\n // Set new height\n target.style.height = `${target.scrollHeight}px`;\n };\n\n useLayoutEffect(() => {\n resizeTextarea();\n // Must run after the shadow DOM has been set up to work on microweb\n setTimeout(() => resizeTextarea(), 1000);\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n const textarea = e.target as HTMLTextAreaElement;\n resizeTarget(textarea);\n if (textareaProps.onChange) textareaProps.onChange(e);\n };\n\n return (\n <div>\n <div\n data-testid={testId}\n ref={stickynoteRef}\n className={classNames(styles['sticky-note'], wrapperClassName, {\n [styles['sticky-note--focused']]: isTextareaFocused,\n [styles['sticky-note--hovered']]: isHovered && !isTextareaFocused && !textareaProps.disabled,\n [styles['sticky-note--error']]: error,\n })}\n onClick={handleWrapperClick}\n role=\"textbox\"\n tabIndex={-1}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n handleWrapperClick(e as React.KeyboardEvent<HTMLDivElement>);\n }\n }}\n >\n <div className={classNames(styles['sticky-note__header'])}>\n {timestamp && <span className={styles['sticky-note__header__timestamp']}>{timestamp}</span>}\n </div>\n <textarea\n ref={textareaRef}\n data-testid={`${testId}-textarea`}\n className={classNames(styles['sticky-note__textarea'], textareaProps.className)}\n {...textareaProps}\n onChange={handleChange}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n />\n <button\n onClick={onXButtonClick}\n aria-label={arialabelXButton}\n data-testid=\"closeButton\"\n className={classNames(styles['sticky-note__x-button'])}\n type=\"button\"\n >\n <Icon svgIcon={X} color=\"black\" size={IconSize.XXSmall} />\n </button>\n <div className={classNames(styles['sticky-note__footer'])}>{footerText && <span>{footerText}</span>}</div>\n <div className={classNames(styles['sticky-note__triangle'])}>\n <Triangle type={triangleType} />\n </div>\n </div>\n {error && (\n <p className={styles['sticky-note__error-text']} id={errorTextId}>\n {errorText}\n </p>\n )}\n </div>\n );\n};\n\nexport default StickyNote;\n"],"names":[],"mappings":";;;;;;;;;;;AASA,MAAM,WAAoC,CAAC,EAAE,WAAW;AACtD,QAAM,WAAW,MAAe;AAC9B,YAAQ,MAAA;AAAA,MACN,KAAK;AACH,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,YAAY;AAAA,QAAA;AAAA,MAEhB,KAAK;AACH,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,YAAY;AAAA,QAAA;AAAA,MAEhB;AACE,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,YAAY;AAAA,QAAA;AAAA,IACd;AAAA,EAEN,GAAA;AACA,SACE,qBAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,OAAM,8BAChE,UAAA;AAAA,IAAA,oBAAC,QAAA,EAAK,IAAG,wBAAuB,MAAK,SACnC,UAAA,oBAAC,QAAA,EAAK,GAAE,sDAAA,CAAsD,EAAA,CAChE;AAAA,wBACC,QAAA,EAAK,GAAE,uDAAsD,MAAM,QAAQ,YAAY;AAAA,IACxF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,GAAE;AAAA,QACF,MAAM,QAAQ;AAAA,QACd,MAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EACP,GACF;AAEJ;ACLA,MAAM,aAAwC,CAAC,UAA2B;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AACJ,QAAM,gBAAgB,QAAQ,WAAW;AACzC,QAAM,gBAAgB,OAAuB,IAAI;AACjD,QAAM,cAAc,OAA4B,IAAI;AACpD,QAAM,EAAE,WAAW,sBAAsB,iBAAsC,WAAW;AAC1F,QAAM,EAAE,UAAA,IAAc,SAAyB,aAAa;AAC5D,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AAA,oBAAC,OAAA,EAAI,WAAW,WAAW,OAAO,qBAAqB,CAAC,GACrD,UAAA,aAAa,oBAAC,UAAK,WAAW,OAAO,gCAAgC,GAAI,qBAAU,GACtF;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,eAAa,GAAG,MAAM;AAAA,cACtB,WAAW,WAAW,OAAO,uBAAuB,GAAG,cAAc,SAAS;AAAA,cAC7E,GAAG;AAAA,cACJ,UAAU;AAAA,cACV,oBAAkB,mBAAmB,OAAO,aAAa;AAAA,YAAA;AAAA,UAAA;AAAA,UAE3D;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,cAAY;AAAA,cACZ,eAAY;AAAA,cACZ,WAAW,WAAW,OAAO,uBAAuB,CAAC;AAAA,cACrD,MAAK;AAAA,cAEL,UAAA,oBAAC,QAAK,SAAS,GAAG,OAAM,SAAQ,MAAM,SAAS,QAAA,CAAS;AAAA,YAAA;AAAA,UAAA;AAAA,UAE1D,oBAAC,OAAA,EAAI,WAAW,WAAW,OAAO,qBAAqB,CAAC,GAAI,UAAA,cAAc,oBAAC,QAAA,EAAM,UAAA,WAAA,CAAW,GAAQ;AAAA,UACpG,oBAAC,OAAA,EAAI,WAAW,WAAW,OAAO,uBAAuB,CAAC,GACxD,UAAA,oBAAC,UAAA,EAAS,MAAM,aAAA,CAAc,EAAA,CAChC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAED,6BACE,KAAA,EAAE,WAAW,OAAO,yBAAyB,GAAG,IAAI,aAClD,UAAA,UAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/StickyNote/Close.tsx","../../../src/components/StickyNote/Triangle.tsx","../../../src/components/StickyNote/StickyNote.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { useHover } from '../../hooks/useHover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface CloseProps {\n /** Function is called when user clicks the button */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Sets the aria-label of the button */\n ariaLabel?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\n/*\n Denne er kopiert fra Close-komponent. \n Det er for å kunne ha en egen lokal variant for StickyNote. \n Likt som i Figma.\n */\n\nconst Close = React.forwardRef(function ButtonForwardedRef(props: CloseProps, ref: React.ForwardedRef<HTMLButtonElement>) {\n const { testId, ariaLabel = 'Lukk', onClick } = props;\n const { hoverRef, isHovered } = useHover();\n\n const iconSize = useIsMobileBreakpoint() ? 38 : 48;\n\n const closeClasses = classNames(styles.close);\n\n return (\n <button\n ref={mergeRefs([ref, hoverRef])}\n data-testid={testId}\n className={closeClasses}\n aria-label={ariaLabel}\n onClick={onClick}\n type=\"button\"\n >\n <span className={classNames(styles['close__inner-container'])}>\n <Icon svgIcon={X} color=\"black\" size={iconSize} isHovered={isHovered} />\n </span>\n </button>\n );\n});\n\nexport default Close;\n","import React from 'react';\n\ninterface TriangleProps {\n isHover: boolean;\n isFocus: boolean;\n isActive: boolean;\n isError: boolean;\n}\n\nexport interface Palette {\n border: string;\n background: string;\n}\n\nconst Triangle: React.FC<TriangleProps> = ({ isHover, isFocus, isActive, isError }) => {\n const palette = ((): Palette => {\n const colors: Palette = {\n border: 'var(--component-stickynote-border-normal)',\n background: 'var(--component-stickynote-background-fold-normal-light)',\n };\n\n if (!isError) {\n if (isHover) {\n colors.background = 'var(--component-stickynote-background-fold-normal-medium)';\n }\n if (isFocus) {\n colors.border = 'var(--color-action-border-onlight-focus)';\n colors.background = 'var(--component-stickynote-background-fold-normal-medium)';\n }\n if (isActive) {\n colors.background = 'var(--component-stickynote-background-fold-normal-dark)';\n }\n } else {\n colors.border = 'var(--component-stickynote-border-error)';\n colors.background = 'var(--component-stickynote-background-fold-error-light)';\n if (isHover) {\n colors.background = 'var(--component-stickynote-background-fold-error-medium)';\n }\n if (isFocus) {\n colors.border = 'var(--color-action-border-onlight-focus)';\n colors.background = 'var(--component-stickynote-background-fold-error-medium)';\n }\n if (isActive) {\n colors.background = 'var(--component-stickynote-background-fold-error-dark)';\n }\n }\n return colors;\n })();\n\n let svg: React.ReactNode;\n\n if (isFocus) {\n svg = (\n <svg width=\"21\" height=\"21\" viewBox=\"0 0 21 21\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <mask id=\"path-1-inside-1_7753_1401\" fill=\"white\">\n <path d=\"M0.493163 20.9211L0.276366 20.9211L0.276367 0.921142L20.2764 0.921143L20.2764 1.13794L0.493163 20.9211Z\" />\n </mask>\n <path\n d=\"M0.493163 20.9211L0.276366 20.9211L0.276367 0.921142L20.2764 0.921143L20.2764 1.13794L0.493163 20.9211Z\"\n fill={palette.background}\n />\n <path\n d=\"M0.493163 20.9211L0.493163 22.9211L1.32159 22.9211L1.90738 22.3354L0.493163 20.9211ZM0.276366 20.9211L-1.72363 20.9211L-1.72363 22.9211L0.276366 22.9211L0.276366 20.9211ZM0.276367 0.921142L0.276367 -1.07886L-1.72363 -1.07886L-1.72363 0.921142L0.276367 0.921142ZM20.2764 0.921143L22.2764 0.921143L22.2764 -1.07886L20.2764 -1.07886L20.2764 0.921143ZM20.2764 1.13794L21.6906 2.55215L22.2764 1.96637L22.2764 1.13794L20.2764 1.13794ZM0.493163 20.9211L0.493163 18.9211L0.276366 18.9211L0.276366 20.9211L0.276366 22.9211L0.493163 22.9211L0.493163 20.9211ZM0.276366 20.9211L2.27637 20.9211L2.27637 0.921142L0.276367 0.921142L-1.72363 0.921142L-1.72363 20.9211L0.276366 20.9211ZM0.276367 0.921142L0.276367 2.92114L20.2764 2.92114L20.2764 0.921143L20.2764 -1.07886L0.276367 -1.07886L0.276367 0.921142ZM20.2764 0.921143L18.2764 0.921142L18.2764 1.13794L20.2764 1.13794L22.2764 1.13794L22.2764 0.921143L20.2764 0.921143ZM20.2764 1.13794L18.8622 -0.276274L-0.92105 19.5069L0.493163 20.9211L1.90738 22.3354L21.6906 2.55215L20.2764 1.13794Z\"\n fill={palette.border}\n mask=\"url(#path-1-inside-1_7753_1401)\"\n />\n </svg>\n );\n } else {\n svg = (\n <svg width=\"21\" height=\"21\" viewBox=\"0 0 21 21\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <mask id=\"path-1-inside-1_7717_293537\" fill=\"white\">\n <path d=\"M0.923827 20.9211L0.70703 20.9211L0.707031 0.921142L20.707 0.921143L20.707 1.13794L0.923827 20.9211Z\" />\n </mask>\n <path\n d=\"M0.923827 20.9211L0.70703 20.9211L0.707031 0.921142L20.707 0.921143L20.707 1.13794L0.923827 20.9211Z\"\n fill={palette.background}\n />\n <path\n d=\"M0.923827 20.9211L0.923827 21.9211L1.33804 21.9211L1.63093 21.6282L0.923827 20.9211ZM0.70703 20.9211L-0.29297 20.9211L-0.29297 21.9211L0.70703 21.9211L0.70703 20.9211ZM0.707031 0.921142L0.707031 -0.0788582L-0.292969 -0.0788583L-0.292969 0.921142L0.707031 0.921142ZM20.707 0.921143L21.707 0.921143L21.707 -0.0788574L20.707 -0.0788574L20.707 0.921143ZM20.707 1.13794L21.4141 1.84505L21.707 1.55215L21.707 1.13794L20.707 1.13794ZM0.923827 20.9211L0.923827 19.9211L0.70703 19.9211L0.70703 20.9211L0.70703 21.9211L0.923827 21.9211L0.923827 20.9211ZM0.70703 20.9211L1.70703 20.9211L1.70703 0.921142L0.707031 0.921142L-0.292969 0.921142L-0.29297 20.9211L0.70703 20.9211ZM0.707031 0.921142L0.707031 1.92114L20.707 1.92114L20.707 0.921143L20.707 -0.0788574L0.707031 -0.0788582L0.707031 0.921142ZM20.707 0.921143L19.707 0.921143L19.707 1.13794L20.707 1.13794L21.707 1.13794L21.707 0.921143L20.707 0.921143ZM20.707 1.13794L19.9999 0.430833L0.21672 20.214L0.923827 20.9211L1.63093 21.6282L21.4141 1.84505L20.707 1.13794Z\"\n fill={palette.border}\n mask=\"url(#path-1-inside-1_7717_293537)\"\n />\n </svg>\n );\n }\n\n return <>{svg}</>;\n};\n\nexport default Triangle;\n","import React, { useLayoutEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Close from './Close';\nimport Triangle from './Triangle';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\n\nimport styles from './styles.module.scss';\n\nexport interface StickyNoteProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Aria label for the delete/close button */\n arialabelXButton: string;\n /** Activates the error styling */\n error?: boolean;\n /** Error text to show below the note */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Text shown under the textarea */\n footerText?: string;\n /** Function run when clicking the delete/close button */\n onXButtonClick?: () => void;\n /** Function run if user clicks the component while it is disabled */\n onClickWhileDisabled?: () => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Timestamp shown over the textarea */\n timestamp: string;\n /** Classname for the outer wrapper */\n wrapperClassName?: string;\n}\n\nconst StickyNote: React.FC<StickyNoteProps> = (props: StickyNoteProps) => {\n const {\n wrapperClassName,\n timestamp,\n onXButtonClick,\n arialabelXButton,\n footerText,\n error,\n errorText,\n errorTextId,\n onClickWhileDisabled,\n testId,\n ...textareaProps\n } = props;\n const errorTextUuid = useUuid(errorTextId);\n const stickynoteRef = useRef<HTMLDivElement>(null);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const { isFocused: isTextareaFocused } = usePseudoClasses<HTMLTextAreaElement>(textareaRef);\n const { isHovered, isActive } = usePseudoClasses<HTMLDivElement>(stickynoteRef);\n\n const handleWrapperClick = (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>): void => {\n if ((event.target as HTMLElement).closest('button')) {\n return;\n }\n if (textareaProps.disabled) {\n if (onClickWhileDisabled) onClickWhileDisabled();\n return;\n }\n textareaRef.current?.focus();\n };\n\n const resizeTextarea = (): void => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n resizeTarget(textarea);\n };\n\n const resizeTarget = (target: HTMLTextAreaElement): void => {\n // Reset field height\n target.style.height = 'inherit';\n // Set new height\n target.style.height = `${target.scrollHeight}px`;\n };\n\n useLayoutEffect(() => {\n resizeTextarea();\n // Must run after the shadow DOM has been set up to work on microweb\n setTimeout(() => resizeTextarea(), 1000);\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n const textarea = e.target as HTMLTextAreaElement;\n resizeTarget(textarea);\n if (textareaProps.onChange) textareaProps.onChange(e);\n };\n\n return (\n <div>\n <div\n data-testid={testId}\n ref={stickynoteRef}\n className={classNames(styles['sticky-note'], wrapperClassName, {\n [styles['sticky-note--focused']]: isTextareaFocused,\n [styles['sticky-note--active']]: isActive,\n [styles['sticky-note--hovered']]: isHovered && !isTextareaFocused && !textareaProps.disabled,\n [styles['sticky-note--error']]: error,\n })}\n onClick={handleWrapperClick}\n role=\"textbox\"\n tabIndex={-1}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n handleWrapperClick(e as React.KeyboardEvent<HTMLDivElement>);\n }\n }}\n >\n <div className={classNames(styles['sticky-note__header'])}>\n {timestamp && <span className={styles['sticky-note__header__timestamp']}>{timestamp}</span>}\n </div>\n <textarea\n ref={textareaRef}\n data-testid={`${testId}-textarea`}\n className={classNames(styles['sticky-note__textarea'], textareaProps.className)}\n {...textareaProps}\n onChange={handleChange}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n />\n <Close onClick={onXButtonClick} ariaLabel={arialabelXButton} testId=\"closeButton\" />\n <div className={classNames(styles['sticky-note__footer'])}>{footerText && <span>{footerText}</span>}</div>\n <div className={classNames(styles['sticky-note__triangle'])}>\n <Triangle isHover={isHovered} isActive={isActive} isFocus={isTextareaFocused} isError={!!error} />\n </div>\n </div>\n {error && (\n <p className={styles['sticky-note__error-text']} id={errorTextId}>\n {errorText}\n </p>\n )}\n </div>\n );\n};\n\nexport default StickyNote;\n"],"names":["React"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,QAAQA,eAAM,WAAW,SAAS,mBAAmB,OAAmB,KAA4C;AACxH,QAAM,EAAE,QAAQ,YAAY,QAAQ,YAAY;AAChD,QAAM,EAAE,UAAU,UAAA,IAAc,SAAA;AAEhC,QAAM,WAAW,0BAA0B,KAAK;AAEhD,QAAM,eAAe,WAAW,OAAO,KAAK;AAE5C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK,UAAU,CAAC,KAAK,QAAQ,CAAC;AAAA,MAC9B,eAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAY;AAAA,MACZ;AAAA,MACA,MAAK;AAAA,MAEL,8BAAC,QAAA,EAAK,WAAW,WAAW,OAAO,wBAAwB,CAAC,GAC1D,UAAA,oBAAC,MAAA,EAAK,SAAS,GAAG,OAAM,SAAQ,MAAM,UAAU,WAAsB,EAAA,CACxE;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;ACnCD,MAAM,WAAoC,CAAC,EAAE,SAAS,SAAS,UAAU,cAAc;AACrF,QAAM,WAAW,MAAe;AAC9B,UAAM,SAAkB;AAAA,MACtB,QAAQ;AAAA,MACR,YAAY;AAAA,IAAA;AAGd,QAAI,CAAC,SAAS;AACZ,UAAI,SAAS;AACX,eAAO,aAAa;AAAA,MACtB;AACA,UAAI,SAAS;AACX,eAAO,SAAS;AAChB,eAAO,aAAa;AAAA,MACtB;AACA,UAAI,UAAU;AACZ,eAAO,aAAa;AAAA,MACtB;AAAA,IACF,OAAO;AACL,aAAO,SAAS;AAChB,aAAO,aAAa;AACpB,UAAI,SAAS;AACX,eAAO,aAAa;AAAA,MACtB;AACA,UAAI,SAAS;AACX,eAAO,SAAS;AAChB,eAAO,aAAa;AAAA,MACtB;AACA,UAAI,UAAU;AACZ,eAAO,aAAa;AAAA,MACtB;A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AAS;AAAA,QACT,MAAK;AAAA,QACL,UAAU;AAAA,QACV,WAAW,CAAA,MAAK;AACd,cAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,+BAAmB,CAAwC;AAAA,UAC7D;AAAA,QACF;AAAA,QAEA,UAAA;AAAA,UAAA,oBAAC,OAAA,EAAI,WAAW,WAAW,OAAO,qBAAqB,CAAC,GACrD,UAAA,aAAa,oBAAC,UAAK,WAAW,OAAO,gCAAgC,GAAI,qBAAU,GACtF;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,eAAa,GAAG,MAAM;AAAA,cACtB,WAAW,WAAW,OAAO,uBAAuB,GAAG,cAAc,SAAS;AAAA,cAC7E,GAAG;AAAA,cACJ,UAAU;AAAA,cACV,oBAAkB,mBAAmB,OAAO,aAAa;AAAA,YAAA;AAAA,UAAA;AAAA,8BAE1D,OAAA,EAAM,SAAS,gBAAgB,WAAW,kBAAkB,QAAO,eAAc;AAAA,UAClF,oBAAC,OAAA,EAAI,WAAW,WAAW,OAAO,qBAAqB,CAAC,GAAI,UAAA,cAAc,oBAAC,QAAA,EAAM,UAAA,WAAA,CAAW,GAAQ;AAAA,8BACnG,OAAA,EAAI,WAAW,WAAW,OAAO,uBAAuB,CAAC,GACxD,UAAA,oBAAC,YAAS,SAAS,WAAW,UAAoB,SAAS,mBAAmB,SAAS,CAAC,CAAC,OAAO,EAAA,CAClG;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAED,6BACE,KAAA,EAAE,WAAW,OAAO,yBAAyB,GAAG,IAAI,aAClD,UAAA,UAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1,52 +1,51 @@
1
+ @use 'sass:map';
1
2
  @use '../../scss/font-settings' as font-settings;
3
+ @use '../../scss/font-mixins' as fonts;
4
+ @use '../../scss/breakpoints' as breakpoints;
2
5
  @import '../../scss/supernova/styles/colors.css';
3
6
 
4
7
  .sticky-note {
8
+ $sticky-note: &;
9
+
5
10
  position: relative;
6
- background-color: var(--core-color-banana-50);
11
+ background-color: var(--component-stickynote-background-normal-light);
7
12
  width: 100%;
8
- border: var(--core-color-banana-300) 1px solid;
13
+ max-width: 32rem;
14
+ border: var(--component-stickynote-border-normal) 1px solid;
9
15
  padding: 12px;
10
16
  overflow: hidden;
11
17
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
12
18
 
13
19
  &--focused {
14
- background-color: var(--core-color-banana-50);
15
- border-color: var(--core-color-banana-600);
20
+ box-shadow: inset 0 0 0 1px var(--color-action-border-onlight-focus);
21
+ border-color: var(--color-action-border-onlight-focus);
22
+ background-color: var(--component-stickynote-background-normal-medium);
16
23
  }
17
24
 
18
25
  &--hovered {
19
- background-color: var(--core-color-banana-100);
20
- border: var(--core-color-banana-100) 1px solid;
26
+ background-color: var(--component-stickynote-background-normal-medium);
21
27
  }
22
28
 
23
- &--error {
24
- background-color: var(--core-color-cherry-50);
25
- border: var(--core-color-cherry-300) 1px solid;
29
+ &--active {
30
+ background-color: var(--component-stickynote-background-normal-dark);
26
31
  }
27
32
 
28
- &__x-button {
29
- cursor: pointer;
30
- background-color: transparent;
31
- color: var(--color-base-text-onlight);
32
- border: 0;
33
- width: 2.75rem;
34
- height: 2.75rem;
35
- display: flex;
36
- justify-content: center;
37
- align-items: center;
38
- position: absolute;
39
- top: 2px;
40
- right: 2px;
33
+ &--error {
34
+ background-color: var(--component-stickynote-background-error-light);
35
+ border: var(--component-stickynote-border-error) 1px solid;
36
+
37
+ &#{$sticky-note}--hovered {
38
+ background-color: var(--component-stickynote-background-error-medium);
39
+ }
41
40
 
42
- &:hover {
43
- background-color: var(--core-color-banana-200); // todo: bestem farge her
44
- outline: 1px solid var(--core-color-banana-500); // todo: bestem farge her
41
+ &#{$sticky-note}--focused {
42
+ box-shadow: inset 0 0 0 1px var(--color-action-border-onlight-focus);
43
+ border-color: var(--color-action-border-onlight-focus);
44
+ background-color: var(--component-stickynote-background-error-medium);
45
45
  }
46
46
 
47
- &:focus-visible {
48
- background-color: var(--color-action-background-transparent-onlight-hoverselected);
49
- outline: 2px solid var(--color-action-border-onlight-focus);
47
+ &#{$sticky-note}--active {
48
+ background-color: var(--component-stickynote-background-error-dark);
50
49
  }
51
50
  }
52
51
 
@@ -57,8 +56,9 @@
57
56
  align-items: center;
58
57
 
59
58
  &__timestamp {
59
+ @include fonts.compact-data;
60
+
60
61
  color: var(--color-placeholder-text-onlight);
61
- font-size: 1rem;
62
62
  }
63
63
  }
64
64
 
@@ -79,9 +79,9 @@
79
79
  }
80
80
 
81
81
  &__footer {
82
+ @include fonts.image-credit;
83
+
82
84
  color: var(--color-placeholder-text-onlight);
83
- font-size: 0.75rem;
84
- font-style: italic;
85
85
  }
86
86
 
87
87
  &__triangle {
@@ -93,9 +93,81 @@
93
93
  }
94
94
 
95
95
  &__error-text {
96
+ @include fonts.sublabel-subdued;
97
+
96
98
  color: var(--color-notification-status-error);
97
- line-height: 1.875rem;
98
- font-size: font-settings.$font-size-sm;
99
- margin-top: 0.75rem;
99
+ margin-top: 0.5rem;
100
+ }
101
+ }
102
+
103
+ $desktop-size: 3rem;
104
+ $mobile-inner-size: 2.375rem;
105
+ $mobile-outer-size: 2.75rem;
106
+
107
+ .close {
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: center;
111
+ position: absolute;
112
+ top: 2px;
113
+ right: 2px;
114
+ height: $mobile-outer-size;
115
+ width: $mobile-outer-size;
116
+ padding: 0;
117
+ border: 0;
118
+ background-color: transparent;
119
+ cursor: pointer;
120
+
121
+ &:focus-visible {
122
+ outline: none;
123
+ }
124
+
125
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
126
+ height: $desktop-size;
127
+ width: $desktop-size;
128
+ }
129
+
130
+ &--small {
131
+ height: $mobile-outer-size;
132
+ width: $mobile-outer-size;
133
+ }
134
+
135
+ &__inner-container {
136
+ width: $mobile-inner-size;
137
+ height: $mobile-inner-size;
138
+
139
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
140
+ height: $desktop-size;
141
+ width: $desktop-size;
142
+ }
143
+
144
+ &--small {
145
+ width: $mobile-inner-size;
146
+ height: $mobile-inner-size;
147
+ }
148
+
149
+ :hover > & {
150
+ background-color: var(--component-stickynote-background-transparent-onlight-hover);
151
+ }
152
+
153
+ :active > & {
154
+ background-color: var(--component-stickynote-background-transparent-onlight-active);
155
+ }
156
+
157
+ :focus-visible > & {
158
+ outline: 3px solid var(--color-action-border-onlight-focus);
159
+ border-radius: 0;
160
+ border: 0;
161
+ }
162
+
163
+ &--error {
164
+ :hover > & {
165
+ background-color: var(--component-stickynote-background-transparent-error-hover);
166
+ }
167
+
168
+ :active > & {
169
+ background-color: var(--component-stickynote-background-transparent-error-active);
170
+ }
171
+ }
100
172
  }
101
173
  }
@@ -1,4 +1,9 @@
1
1
  export type Styles = {
2
+ close: string;
3
+ 'close__inner-container': string;
4
+ 'close__inner-container--error': string;
5
+ 'close__inner-container--small': string;
6
+ 'close--small': string;
2
7
  'sticky-note': string;
3
8
  'sticky-note__error-text': string;
4
9
  'sticky-note__footer': string;
@@ -6,7 +11,7 @@ export type Styles = {
6
11
  'sticky-note__header__timestamp': string;
7
12
  'sticky-note__textarea': string;
8
13
  'sticky-note__triangle': string;
9
- 'sticky-note__x-button': string;
14
+ 'sticky-note--active': string;
10
15
  'sticky-note--error': string;
11
16
  'sticky-note--focused': string;
12
17
  'sticky-note--hovered': string;
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { default as Tab } from './Tab';
3
+ import { HNDesignsystemTabs } from '../../resources/Resources';
3
4
  import { PaletteNames } from '../../theme/palette';
4
5
  export type { TabProps } from './Tab';
5
6
  export type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;
@@ -20,14 +21,16 @@ export interface TabsProps {
20
21
  sticky?: boolean;
21
22
  /** Sets the data-testid attribute. */
22
23
  testId?: string;
23
- /** Sets aria label on the "scroll to the right" button in TabList */
24
+ /** @deprecated Sets aria label on the "scroll to the right" button in TabList */
24
25
  ariaLabelRightButton?: string;
25
- /** Sets aria label on the "scroll to the left" button in TabList */
26
+ /** @deprecated Sets aria label on the "scroll to the left" button in TabList */
26
27
  ariaLabelLeftButton?: string;
28
+ /** Resources for component */
29
+ resources?: Partial<HNDesignsystemTabs>;
27
30
  /** Overrides the default z-index of the tabs header */
28
31
  zIndex?: number;
29
32
  }
30
- declare const TabsRoot: React.FC<TabsProps>;
33
+ export declare const TabsRoot: React.FC<TabsProps>;
31
34
  type TabsComponent = typeof TabsRoot & {
32
35
  Tab: typeof Tab;
33
36
  };
@@ -1,10 +1,33 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import React__default, { useState, useRef } from "react";
3
3
  import classNames from "classnames";
4
+ import { LanguageLocales } from "../../constants.js";
4
5
  import { T as TabList, a as Tab } from "../../TabList.js";
5
6
  import { T as TabPanel } from "../../TabPanel.js";
6
7
  import designsystemlayout from "../../scss/layout.module.scss";
8
+ import { useLanguage } from "../../utils/language.js";
7
9
  import styles from "./styles.module.scss";
10
+ const ariaLabelRightButton$1 = "Scroll right";
11
+ const ariaLabelLeftButton$1 = "Scroll left";
12
+ const enGB = {
13
+ ariaLabelRightButton: ariaLabelRightButton$1,
14
+ ariaLabelLeftButton: ariaLabelLeftButton$1
15
+ };
16
+ const ariaLabelRightButton = "Scroll til høyre";
17
+ const ariaLabelLeftButton = "Scroll til venstre";
18
+ const nbNO = {
19
+ ariaLabelRightButton,
20
+ ariaLabelLeftButton
21
+ };
22
+ const getResources = (language) => {
23
+ switch (language) {
24
+ case LanguageLocales.ENGLISH:
25
+ return enGB;
26
+ case LanguageLocales.NORWEGIAN:
27
+ default:
28
+ return nbNO;
29
+ }
30
+ };
8
31
  const TabsRoot = ({
9
32
  activeTab,
10
33
  children,
@@ -14,8 +37,9 @@ const TabsRoot = ({
14
37
  onColor = "onwhite",
15
38
  sticky = true,
16
39
  testId,
17
- ariaLabelRightButton,
18
- ariaLabelLeftButton,
40
+ ariaLabelRightButton: ariaLabelRightButton2,
41
+ ariaLabelLeftButton: ariaLabelLeftButton2,
42
+ resources,
19
43
  zIndex
20
44
  }) => {
21
45
  const isControlled = activeTab !== void 0;
@@ -23,6 +47,14 @@ const TabsRoot = ({
23
47
  const tabsRef = useRef(null);
24
48
  const tabPanelRef = useRef(null);
25
49
  const tabListRef = useRef(null);
50
+ const { language } = useLanguage(LanguageLocales.NORWEGIAN);
51
+ const defaultResources = getResources(language);
52
+ const mergedResources = {
53
+ ...defaultResources,
54
+ ...resources,
55
+ ariaLabelRightButton: ariaLabelRightButton2 || (resources == null ? void 0 : resources.ariaLabelRightButton) || defaultResources.ariaLabelRightButton,
56
+ ariaLabelLeftButton: ariaLabelLeftButton2 || (resources == null ? void 0 : resources.ariaLabelLeftButton) || defaultResources.ariaLabelLeftButton
57
+ };
26
58
  let onColorUsed = "onwhite";
27
59
  if (color === "white") {
28
60
  onColorUsed = onColor;
@@ -52,8 +84,8 @@ const TabsRoot = ({
52
84
  selectedTab: activeTabIndex,
53
85
  color,
54
86
  onColor: onColorUsed,
55
- ariaLabelLeftButton,
56
- ariaLabelRightButton,
87
+ ariaLabelLeftButton: mergedResources.ariaLabelLeftButton,
88
+ ariaLabelRightButton: mergedResources.ariaLabelRightButton,
57
89
  children
58
90
  }
59
91
  ),
@@ -65,10 +97,12 @@ const TabsRoot = ({
65
97
  ] });
66
98
  };
67
99
  const Tabs = TabsRoot;
100
+ TabsRoot.displayName = "Tabs";
68
101
  Tabs.displayName = "Tabs";
69
102
  Tabs.Tab = Tab;
70
103
  Tabs.Tab.displayName = "Tabs.Tab";
71
104
  export {
105
+ TabsRoot,
72
106
  Tabs as default
73
107
  };
74
108
  //# sourceMappingURL=index.js.map