@helsenorge/designsystem-react 12.3.0 → 12.5.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 (88) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/Checkbox.js +2 -4
  3. package/Checkbox.js.map +1 -1
  4. package/Drawer.js +33 -8
  5. package/Drawer.js.map +1 -1
  6. package/ElementHeader.js +5 -4
  7. package/ElementHeader.js.map +1 -1
  8. package/FormGroup.js +8 -3
  9. package/FormGroup.js.map +1 -1
  10. package/HelpTriggerIcon.js +13 -2
  11. package/HelpTriggerIcon.js.map +1 -1
  12. package/Input.js +2 -3
  13. package/Input.js.map +1 -1
  14. package/LazyIcon.js +1 -1
  15. package/LazyIcon.js.map +1 -1
  16. package/LinkList.js +81 -47
  17. package/LinkList.js.map +1 -1
  18. package/ListEditMode.js +42 -0
  19. package/ListEditMode.js.map +1 -0
  20. package/PanelOld.js.map +1 -1
  21. package/RadioButton.js +1 -1
  22. package/RadioButton.js.map +1 -1
  23. package/Select.js +1 -1
  24. package/Select.js.map +1 -1
  25. package/components/Drawer/Drawer.d.ts +6 -1
  26. package/components/Drawer/resourceHelper.d.ts +3 -0
  27. package/components/ElementHeader/styles.module.scss +7 -9
  28. package/components/ElementHeader/styles.module.scss.d.ts +2 -1
  29. package/components/ExpanderList/ExpanderList.d.ts +8 -1
  30. package/components/ExpanderList/index.js +51 -20
  31. package/components/ExpanderList/index.js.map +1 -1
  32. package/components/ExpanderList/styles.module.scss +37 -33
  33. package/components/FavoriteButton/FavoriteButton.d.ts +19 -0
  34. package/components/FavoriteButton/FavoriteButton.test.d.ts +1 -0
  35. package/components/FavoriteButton/StarIcon.d.ts +4 -0
  36. package/components/FavoriteButton/index.d.ts +3 -0
  37. package/components/FavoriteButton/index.js +209 -0
  38. package/components/FavoriteButton/index.js.map +1 -0
  39. package/components/FavoriteButton/resourceHelper.d.ts +3 -0
  40. package/components/FavoriteButton/stories.module.scss +22 -0
  41. package/components/FavoriteButton/stories.module.scss.d.ts +10 -0
  42. package/components/FavoriteButton/styles.module.scss +48 -0
  43. package/components/FavoriteButton/styles.module.scss.d.ts +10 -0
  44. package/components/FormGroup/FormGroup.d.ts +2 -0
  45. package/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +2 -0
  46. package/components/HelpTriggerIcon/styles.module.scss +22 -1
  47. package/components/Icons/AdditionalIconInformation.d.ts +4 -0
  48. package/components/Icons/AdditionalIconInformation.js +2 -1
  49. package/components/Icons/AdditionalIconInformation.js.map +1 -1
  50. package/components/Icons/Feedback.d.ts +4 -0
  51. package/components/Icons/Feedback.js +25 -0
  52. package/components/Icons/Feedback.js.map +1 -0
  53. package/components/Icons/IconNames.d.ts +1 -1
  54. package/components/Icons/IconNames.js +1 -0
  55. package/components/Icons/IconNames.js.map +1 -1
  56. package/components/LinkList/LinkList.d.ts +8 -1
  57. package/components/LinkList/index.js +2 -0
  58. package/components/LinkList/index.js.map +1 -1
  59. package/components/LinkList/styles.module.scss +30 -22
  60. package/components/List/stories.module.scss +7 -0
  61. package/components/List/stories.module.scss.d.ts +9 -0
  62. package/components/ListEditMode/ListEditMode.d.ts +29 -0
  63. package/components/ListEditMode/index.d.ts +3 -0
  64. package/components/ListEditMode/index.js +9 -0
  65. package/components/ListEditMode/index.js.map +1 -0
  66. package/components/ListEditMode/styles.module.scss +79 -0
  67. package/components/ListEditMode/styles.module.scss.d.ts +18 -0
  68. package/components/Panel/styles.module.scss +5 -2
  69. package/components/PopMenu/index.js +1 -1
  70. package/components/PopMenu/index.js.map +1 -1
  71. package/components/PopMenu/styles.module.scss +4 -0
  72. package/components/PopMenu/styles.module.scss.d.ts +1 -0
  73. package/components/RadioButton/styles.module.scss +22 -4
  74. package/components/StatusDot/styles.module.scss +6 -0
  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/package.json +1 -1
  83. package/resources/HN.Designsystem.Drawer.en-GB.json.d.ts +6 -0
  84. package/resources/HN.Designsystem.Drawer.nb-NO.json.d.ts +6 -0
  85. package/resources/HN.Designsystem.FavoriteButton.nb-NO.json.d.ts +6 -0
  86. package/resources/HN.Designsystem.Tabs.en-GB.json.d.ts +7 -0
  87. package/resources/HN.Designsystem.Tabs.nb-NO.json.d.ts +7 -0
  88. package/components/Tabs/TabsDocs.d.ts +0 -1
@@ -88,7 +88,11 @@
88
88
  min-height: 4rem;
89
89
  text-decoration: none;
90
90
  color: var(--color-base-text-onlight);
91
- cursor: pointer;
91
+
92
+ // listeelement settes til div om man er i edit mode, og skal da ikke ha interactive effekter
93
+ &:not(div) {
94
+ cursor: pointer;
95
+ }
92
96
 
93
97
  &--button {
94
98
  width: 100%;
@@ -118,9 +122,16 @@
118
122
  }
119
123
  }
120
124
 
125
+ &--fill-negative {
126
+ background-color: var(--color-base-background-white);
127
+ }
128
+
121
129
  &--fill,
122
130
  &--fill-negative {
123
- margin-top: spacers.getSpacer(s);
131
+ // listeelement settes til div om man er i edit mode, og styles da via ListEditMode
132
+ &:not(div) {
133
+ margin-top: spacers.getSpacer(s);
134
+ }
124
135
 
125
136
  &--blueberry {
126
137
  border: 1px solid var(--core-color-blueberry-500);
@@ -140,10 +151,6 @@
140
151
  }
141
152
  }
142
153
 
143
- &--fill-negative {
144
- background-color: var(--color-base-background-white);
145
- }
146
-
147
154
  &--small {
148
155
  font-size: font-settings.$font-size-xs;
149
156
  line-height: font-settings.$lineheight-size-xs;
@@ -177,41 +184,42 @@
177
184
  }
178
185
 
179
186
  &--white:not(.link-list__anchor--outline) {
180
- &:hover {
187
+ // listeelement settes til div om man er i edit mode, og skal da ikke ha hover/active effekter
188
+ &:hover:not(div) {
181
189
  background-color: var(--core-color-neutral-50);
182
190
  }
183
191
 
184
- &:active {
192
+ &:active:not(div) {
185
193
  background-color: var(--core-color-neutral-100);
186
194
  }
187
195
  }
188
196
 
189
197
  &--blueberry:not(.link-list__anchor--outline) {
190
- &:hover {
198
+ &:hover:not(div) {
191
199
  background-color: var(--core-color-blueberry-100);
192
200
  }
193
201
 
194
- &:active {
202
+ &:active:not(div) {
195
203
  background-color: var(--color-action-background-ondark-hoverselected);
196
204
  }
197
205
  }
198
206
 
199
207
  &--cherry:not(.link-list__anchor--outline) {
200
- &:hover {
208
+ &:hover:not(div) {
201
209
  background-color: var(--core-color-cherry-100);
202
210
  }
203
211
 
204
- &:active {
212
+ &:active:not(div) {
205
213
  background-color: var(--core-color-cherry-200);
206
214
  }
207
215
  }
208
216
 
209
217
  &--neutral:not(.link-list__anchor--outline) {
210
- &:hover {
218
+ &:hover:not(div) {
211
219
  background-color: var(--core-color-neutral-100);
212
220
  }
213
221
 
214
- &:active {
222
+ &:active:not(div) {
215
223
  background-color: var(--core-color-neutral-200);
216
224
  }
217
225
  }
@@ -234,11 +242,11 @@
234
242
  &--blueberry {
235
243
  border-bottom: 1px solid var(--core-color-blueberry-500);
236
244
 
237
- &:hover {
245
+ &:hover:not(div) {
238
246
  background-color: var(--core-color-blueberry-50);
239
247
  }
240
248
 
241
- &:active {
249
+ &:active:not(div) {
242
250
  background-color: var(--core-color-blueberry-100);
243
251
  }
244
252
  }
@@ -246,11 +254,11 @@
246
254
  &--cherry {
247
255
  border-bottom: 1px solid var(--core-color-cherry-400);
248
256
 
249
- &:hover {
257
+ &:hover:not(div) {
250
258
  background-color: var(--core-color-cherry-50);
251
259
  }
252
260
 
253
- &:active {
261
+ &:active:not(div) {
254
262
  background-color: var(--core-color-cherry-100);
255
263
  }
256
264
  }
@@ -258,11 +266,11 @@
258
266
  &--neutral {
259
267
  border-bottom: 1px solid var(--color-base-border-onlight);
260
268
 
261
- &:hover {
269
+ &:hover:not(div) {
262
270
  background-color: var(--core-color-neutral-50);
263
271
  }
264
272
 
265
- &:active {
273
+ &:active:not(div) {
266
274
  background-color: var(--core-color-neutral-100);
267
275
  }
268
276
  }
@@ -271,11 +279,11 @@
271
279
  &--new {
272
280
  background-color: var(--core-color-blueberry-50) !important;
273
281
 
274
- &:hover {
282
+ &:hover:not(div) {
275
283
  background-color: var(--core-color-blueberry-100) !important;
276
284
  }
277
285
 
278
- &:active {
286
+ &:active:not(div) {
279
287
  background-color: var(--core-color-blueberry-200) !important;
280
288
  }
281
289
  }
@@ -0,0 +1,7 @@
1
+ .list-anchorlink {
2
+ li {
3
+ button {
4
+ vertical-align: top;
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ export type Styles = {
2
+ 'list-anchorlink': string;
3
+ };
4
+
5
+ export type ClassNames = keyof Styles;
6
+
7
+ declare const styles: Styles;
8
+
9
+ export default styles;
@@ -0,0 +1,29 @@
1
+ import { default as React } from 'react';
2
+ import { ExpanderListColors, ExpanderListVariant } from '../ExpanderList';
3
+ import { SvgIcon } from '../Icon';
4
+ import { LinkListColors, LinkListVariant } from '../LinkList';
5
+ export interface ListEditModeProps extends ListEditModeItemProps {
6
+ /** Items in the ListEditMode */
7
+ children: React.ReactNode;
8
+ /** Sets visual priority */
9
+ variant?: LinkListVariant | ExpanderListVariant;
10
+ /** Sets color */
11
+ color?: LinkListColors | ExpanderListColors;
12
+ }
13
+ export interface ListEditModeItemProps {
14
+ /** Enables ListEditMode */
15
+ editMode?: boolean;
16
+ /** Callback for delete button */
17
+ onDelete?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
18
+ }
19
+ export declare const listEditModeWrapperClassnames: string;
20
+ export declare const IconButton: ({ icon, color, onClick, }: {
21
+ icon: SvgIcon;
22
+ color: "red" | "blue";
23
+ onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
24
+ }) => React.JSX.Element;
25
+ export declare const ListEditModeItem: {
26
+ (props: ListEditModeProps): React.JSX.Element;
27
+ displayName: string;
28
+ };
29
+ export default ListEditModeItem;
@@ -0,0 +1,3 @@
1
+ import { default as ListEditModeItem } from './ListEditMode';
2
+ export * from './ListEditMode';
3
+ export default ListEditModeItem;
@@ -0,0 +1,9 @@
1
+ import { L as ListEditModeItem } from "../../ListEditMode.js";
2
+ import { I, l } from "../../ListEditMode.js";
3
+ export {
4
+ I as IconButton,
5
+ ListEditModeItem,
6
+ ListEditModeItem as default,
7
+ l as listEditModeWrapperClassnames
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,79 @@
1
+ @use 'sass:map';
2
+ @use '../../scss/spacers' as spacers;
3
+ @use '../../scss/font-settings' as font-settings;
4
+ @use '../../scss/palette' as palette;
5
+ @use '../../scss/breakpoints' as breakpoints;
6
+ @import '../../scss/supernova/styles/colors.css';
7
+ @import '../../scss/supernova/styles/spacers.css';
8
+
9
+ .list-edit-mode {
10
+ border: none !important;
11
+
12
+ &__icon-button {
13
+ background: none;
14
+ border: none;
15
+ height: 3rem;
16
+ width: 3rem;
17
+ background-color: transparent;
18
+ outline: none;
19
+ padding: 0;
20
+ margin: 4px;
21
+
22
+ &:focus-visible {
23
+ outline: 4px solid var(--color-action-border-onlight-focus);
24
+ }
25
+ }
26
+
27
+ &__item {
28
+ display: flex;
29
+ flex-flow: row;
30
+ width: 100%;
31
+ align-items: center;
32
+
33
+ li {
34
+ width: 100%;
35
+ }
36
+
37
+ &--neutral,
38
+ &--white {
39
+ border-bottom: 1px solid var(--color-base-border-onlight);
40
+
41
+ &:first-of-type {
42
+ border-top: 1px solid var(--color-base-border-onlight);
43
+ }
44
+ }
45
+
46
+ &--cherry {
47
+ border-bottom: 1px solid var(--core-color-cherry-400);
48
+
49
+ &:first-of-type {
50
+ border-top: 1px solid var(--core-color-cherry-400);
51
+ }
52
+ }
53
+
54
+ &--blueberry {
55
+ border-bottom: 1px solid var(--core-color-blueberry-500);
56
+
57
+ &:first-of-type {
58
+ border-top: 1px solid var(--core-color-blueberry-500);
59
+ }
60
+ }
61
+
62
+ &--line {
63
+ li {
64
+ border: none !important;
65
+ }
66
+ }
67
+
68
+ &--fill {
69
+ li {
70
+ margin-top: 8px;
71
+ margin-bottom: 8px;
72
+ }
73
+ }
74
+
75
+ &__link {
76
+ margin: 0;
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,18 @@
1
+ export type Styles = {
2
+ 'list-edit-mode': string;
3
+ 'list-edit-mode__icon-button': string;
4
+ 'list-edit-mode__item': string;
5
+ 'list-edit-mode__item__link': string;
6
+ 'list-edit-mode__item--blueberry': string;
7
+ 'list-edit-mode__item--cherry': string;
8
+ 'list-edit-mode__item--fill': string;
9
+ 'list-edit-mode__item--line': string;
10
+ 'list-edit-mode__item--neutral': string;
11
+ 'list-edit-mode__item--white': string;
12
+ };
13
+
14
+ export type ClassNames = keyof Styles;
15
+
16
+ declare const styles: Styles;
17
+
18
+ export default styles;
@@ -7,10 +7,12 @@
7
7
 
8
8
  .panel {
9
9
  $panel: &;
10
+ $status-width: 6px;
10
11
 
11
12
  display: flex;
12
13
  flex-flow: column;
13
14
  padding: spacers.getSpacer(s);
15
+ padding-left: calc(spacers.getSpacer(s) - $status-width);
14
16
 
15
17
  & > *:not(:last-child) {
16
18
  // because of a problem with gap this margin gives space between elements
@@ -19,6 +21,7 @@
19
21
 
20
22
  @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
21
23
  padding: spacers.getSpacer(m);
24
+ padding-left: calc(spacers.getSpacer(m) - $status-width);
22
25
  }
23
26
 
24
27
  &--icon {
@@ -155,7 +158,7 @@
155
158
  }
156
159
 
157
160
  &--status {
158
- border-left: 6px;
161
+ border-left: $status-width;
159
162
  border-left-style: solid;
160
163
  border-left-color: transparent;
161
164
  }
@@ -166,7 +169,7 @@
166
169
  }
167
170
 
168
171
  &--draft {
169
- border-left: dotted 6px var(--color-notification-status-draft);
172
+ border-left: dotted $status-width var(--color-notification-status-draft);
170
173
  }
171
174
 
172
175
  &--error {
@@ -102,7 +102,7 @@ const PopMenu = (props) => {
102
102
  type: "button",
103
103
  children: [
104
104
  labelText && labelTextPosition == "left" && /* @__PURE__ */ jsx("span", { children: labelText }),
105
- /* @__PURE__ */ jsx("div", { ref: iconRef, children: isOpen ? closeIcon : openIcon }),
105
+ /* @__PURE__ */ jsx("div", { className: styles["pop-menu-button__icon-wrapper"], ref: iconRef, children: isOpen ? closeIcon : openIcon }),
106
106
  labelText && labelTextPosition == "right" && /* @__PURE__ */ jsx("span", { children: labelText })
107
107
  ]
108
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { isComponent } from '../../utils/component';\nimport Icon, { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList, { LinkListProps, LinkProps } from '../LinkList';\nimport PopOver from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n popMenuVariant = PopMenuVariant.onWhite,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const buttonClasses = classNames(styles['pop-menu-button'], {\n [styles[`pop-menu-button--${popMenuVariant}`]]: popMenuVariant,\n });\n const isMobile = useIsMobileBreakpoint();\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = useHover(triggerButtonRef);\n const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n if (cb) cb();\n };\n\n const renderChildren = (): React.ReactElement | undefined => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n controllerRef={iconRef}\n role=\"dialog\"\n show={isOpen}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (e?: React.MouseEvent<HTMLElement, MouseEvent>): void => {\n if (e) e.stopPropagation();\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon svgIcon={svgIcon ?? VerticalDots} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n const triggerButton = (\n <button\n ref={triggerButtonRef}\n data-testid={isOpen ? closeButtonTestId : openButtonTestId}\n className={buttonClasses}\n aria-label={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n type=\"button\"\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {<div ref={iconRef}>{isOpen ? closeIcon : openIcon}</div>}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </button>\n );\n\n return (\n <div ref={outerRef} className={classNames(styles['pop-menu-button'], popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n {triggerButton}\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n"],"names":["PopMenuVariant","PopMenuLabelPosition","React","child"],"mappings":";;;;;;;;;;;;;;;;AAoBO,IAAK,mCAAAA,oBAAL;AACLA,kBAAA,SAAA,IAAU;AACVA,kBAAA,QAAA,IAAS;AACTA,kBAAA,aAAA,IAAc;AAHJ,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;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A;AAAA,EAAA;AAItF,SACE,qBAAC,OAAA,EAAI,KAAK,UAAU,WAAW,WAAW,OAAO,iBAAiB,GAAG,gBAAgB,GAAG,oBAAkB,YAAY,SACnH,UAAA;AAAA,IAAA;AAAA,IACA,UAAU,eAAA;AAAA,EAAe,GAC5B;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/PopMenu/PopMenu.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { useOutsideEvent } from '../../hooks/useOutsideEvent';\nimport { getColor } from '../../theme/currys';\nimport { isComponent } from '../../utils/component';\nimport Icon, { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList, { LinkListProps, LinkProps } from '../LinkList';\nimport PopOver from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n popMenuVariant = PopMenuVariant.onWhite,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const buttonClasses = classNames(styles['pop-menu-button'], {\n [styles[`pop-menu-button--${popMenuVariant}`]]: popMenuVariant,\n });\n const isMobile = useIsMobileBreakpoint();\n\n useOutsideEvent(outerRef, () => {\n setIsOpen(false);\n });\n\n const { isHovered: triggerButtonIsHovered } = useHover(triggerButtonRef);\n const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n setIsOpen(false);\n if (cb) cb();\n };\n\n const renderChildren = (): React.ReactElement | undefined => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n controllerRef={iconRef}\n role=\"dialog\"\n show={isOpen}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (e?: React.MouseEvent<HTMLElement, MouseEvent>): void => {\n if (e) e.stopPropagation();\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon svgIcon={svgIcon ?? VerticalDots} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} color={getColor('black')} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n const triggerButton = (\n <button\n ref={triggerButtonRef}\n data-testid={isOpen ? closeButtonTestId : openButtonTestId}\n className={buttonClasses}\n aria-label={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n type=\"button\"\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {\n <div className={styles['pop-menu-button__icon-wrapper']} ref={iconRef}>\n {isOpen ? closeIcon : openIcon}\n </div>\n }\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </button>\n );\n\n return (\n <div ref={outerRef} className={classNames(styles['pop-menu-button'], popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n {triggerButton}\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n"],"names":["PopMenuVariant","PopMenuLabelPosition","React","child"],"mappings":";;;;;;;;;;;;;;;;AAoBO,IAAK,mCAAAA,oBAAL;AACLA,kBAAA,SAAA,IAAU;AACVA,kBAAA,QAAA,IAAS;AACTA,kBAAA,aAAA,IAAc;AAHJ,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAML,IAAK,yCAAAC,0BAAL;AACLA,wBAAA,OAAA,IAAQ;AACRA,wBAAA,MAAA,IAAO;AAFG,SAAAA;AAAA,GAAA,wB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,OAAO,iBAAiB,GAAG,gBAAgB,GAAG,oBAAkB,YAAY,SACnH,UAAA;AAAA,IAAA;AAAA,IACA,UAAU,eAAA;AAAA,EAAe,GAC5B;AAEJ;"}
@@ -18,6 +18,10 @@
18
18
  box-shadow: none;
19
19
  outline: none;
20
20
  }
21
+
22
+ &__icon-wrapper {
23
+ display: flex;
24
+ }
21
25
  }
22
26
 
23
27
  html :focus > .pop-menu-button {
@@ -1,6 +1,7 @@
1
1
  export type Styles = {
2
2
  'pop-menu__pop-over': string;
3
3
  'pop-menu-button': string;
4
+ 'pop-menu-button__icon-wrapper': string;
4
5
  'pop-menu-button--on-blueberry': string;
5
6
  'pop-menu-button--on-gray': string;
6
7
  'pop-menu-button--on-white': string;
@@ -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 {
@@ -10,6 +10,7 @@
10
10
  $status-dot-size: 1rem;
11
11
 
12
12
  .statusdot {
13
+ min-height: 1.75rem;
13
14
  position: relative;
14
15
  display: inline-flex;
15
16
  align-items: center;
@@ -29,6 +30,7 @@ $status-dot-size: 1rem;
29
30
  &--active {
30
31
  fill: var(--color-notification-graphics-success);
31
32
  }
33
+
32
34
  &--success#{&}--on-dark,
33
35
  &--active#{&}--on-dark {
34
36
  fill: var(--core-color-kiwi-200);
@@ -41,6 +43,7 @@ $status-dot-size: 1rem;
41
43
  &--pending {
42
44
  fill: var(--color-notification-graphics-warning);
43
45
  }
46
+
44
47
  &--inprocess#{&}--on-dark,
45
48
  &--exception#{&}--on-dark,
46
49
  &--unknown#{&}--on-dark,
@@ -54,6 +57,7 @@ $status-dot-size: 1rem;
54
57
  &--inactive {
55
58
  fill: var(--color-notification-graphics-error);
56
59
  }
60
+
57
61
  &--cancelled#{&}--on-dark,
58
62
  &--alert#{&}--on-dark,
59
63
  &--inactive#{&}--on-dark {
@@ -63,6 +67,7 @@ $status-dot-size: 1rem;
63
67
  &--info {
64
68
  fill: var(--core-color-blueberry-500);
65
69
  }
70
+
66
71
  &--info#{&}--on-dark {
67
72
  fill: var(--core-color-blueberry-200);
68
73
  }
@@ -70,6 +75,7 @@ $status-dot-size: 1rem;
70
75
  &--transparent {
71
76
  fill: var(--color-disabled-border);
72
77
  }
78
+
73
79
  &--transparent#{&}--on-dark,
74
80
  &--group#{&}--on-dark,
75
81
  &--recurring#{&}--on-dark,
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Tab from './Tab';\nimport TabList from './TabList';\nimport TabPanel from './TabPanel';\nimport designsystemlayout from '../../scss/layout.module.scss';\nimport { PaletteNames } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport type { TabProps } from './Tab';\nexport type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;\nexport type TabsOnColor = 'onblueberry' | 'onneutral' | 'onwhite';\n\nexport interface TabsProps {\n children?: React.ReactNode;\n /** Controlled state for Tabs component */\n activeTab?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the color of the tabs. Default: white */\n color?: TabsColors;\n /** Sets wether the component should use the container-breakout class. Default: true */\n containerBreakout?: boolean;\n /** Sets the background color of the tabs. Can only be used when the color is set to white. Default: onwhite */\n onColor?: TabsOnColor;\n /** Whether the tab list should be sticky */\n sticky?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets aria label on the \"scroll to the right\" button in TabList */\n ariaLabelRightButton?: string;\n /** Sets aria label on the \"scroll to the left\" button in TabList */\n ariaLabelLeftButton?: string;\n /** Overrides the default z-index of the tabs header */\n zIndex?: number;\n}\n\nconst TabsRoot: React.FC<TabsProps> = ({\n activeTab,\n children,\n className,\n color = 'white',\n containerBreakout = true,\n onColor = 'onwhite',\n sticky = true,\n testId,\n ariaLabelRightButton,\n ariaLabelLeftButton,\n zIndex,\n}) => {\n const isControlled = activeTab !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(0);\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabPanelRef = useRef<HTMLDivElement>(null);\n const tabListRef = useRef<HTMLDivElement>(null);\n\n let onColorUsed: TabsOnColor = 'onwhite';\n if (color === 'white') {\n onColorUsed = onColor;\n }\n\n const onValueChange = (newValue: number): void => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n };\n\n const activeTabIndex = isControlled ? activeTab : uncontrolledValue;\n\n return (\n <div className={classNames(className, containerBreakout && designsystemlayout['container-breakout'])} data-testid={testId}>\n <div\n ref={tabListRef}\n className={classNames(styles['tab-list-wrapper'], {\n [styles['tab-list-wrapper--sticky']]: sticky,\n })}\n style={{\n zIndex: zIndex,\n }}\n >\n <TabList\n onTabListClick={(index: number) => onValueChange(index)}\n selectedTab={activeTabIndex}\n color={color}\n onColor={onColorUsed}\n ariaLabelLeftButton={ariaLabelLeftButton}\n ariaLabelRightButton={ariaLabelRightButton}\n >\n {children}\n </TabList>\n <div className={classNames(styles['panel-wrapper'], styles[`panel-wrapper--${color}`])}></div>\n </div>\n <div ref={tabsRef} style={{ marginTop: '-50px' }}>\n <TabPanel ref={tabPanelRef} color={color} isFirst={activeTabIndex == 0}>\n {React.Children.toArray(children)[activeTabIndex]}\n </TabPanel>\n </div>\n </div>\n );\n};\n\ntype TabsComponent = typeof TabsRoot & {\n Tab: typeof Tab;\n};\nconst Tabs = TabsRoot as TabsComponent;\nTabs.displayName = 'Tabs';\nTabs.Tab = Tab;\nTabs.Tab.displayName = 'Tabs.Tab';\n\nexport default Tabs;\n"],"names":["React"],"mappings":";;;;;;;AAwCA,MAAM,WAAgC,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,UAAU;AAAA,EACV,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,cAAc;AACnC,QAAM,CAAC,mBAA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b,KAAK,cAAc;AACnB,KAAK,MAAM;AACX,KAAK,IAAI,cAAc;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Tabs/resourceHelper.ts","../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Tabs.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Tabs.nb-NO.json';\nimport { HNDesignsystemTabs } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemTabs => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport Tab from './Tab';\nimport TabList from './TabList';\nimport TabPanel from './TabPanel';\nimport { LanguageLocales } from '../../constants';\nimport { HNDesignsystemTabs } from '../../resources/Resources';\nimport designsystemlayout from '../../scss/layout.module.scss';\nimport { PaletteNames } from '../../theme/palette';\nimport { useLanguage } from '../../utils/language';\n\nimport styles from './styles.module.scss';\n\nexport type { TabProps } from './Tab';\nexport type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;\nexport type TabsOnColor = 'onblueberry' | 'onneutral' | 'onwhite';\n\nexport interface TabsProps {\n children?: React.ReactNode;\n /** Controlled state for Tabs component */\n activeTab?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the color of the tabs. Default: white */\n color?: TabsColors;\n /** Sets wether the component should use the container-breakout class. Default: true */\n containerBreakout?: boolean;\n /** Sets the background color of the tabs. Can only be used when the color is set to white. Default: onwhite */\n onColor?: TabsOnColor;\n /** Whether the tab list should be sticky */\n sticky?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** @deprecated Sets aria label on the \"scroll to the right\" button in TabList */\n ariaLabelRightButton?: string;\n /** @deprecated Sets aria label on the \"scroll to the left\" button in TabList */\n ariaLabelLeftButton?: string;\n /** Resources for component */\n resources?: Partial<HNDesignsystemTabs>;\n /** Overrides the default z-index of the tabs header */\n zIndex?: number;\n}\n\nexport const TabsRoot: React.FC<TabsProps> = ({\n activeTab,\n children,\n className,\n color = 'white',\n containerBreakout = true,\n onColor = 'onwhite',\n sticky = true,\n testId,\n ariaLabelRightButton,\n ariaLabelLeftButton,\n resources,\n zIndex,\n}) => {\n const isControlled = activeTab !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(0);\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabPanelRef = useRef<HTMLDivElement>(null);\n const tabListRef = useRef<HTMLDivElement>(null);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemTabs = {\n ...defaultResources,\n ...resources,\n ariaLabelRightButton: ariaLabelRightButton || resources?.ariaLabelRightButton || defaultResources.ariaLabelRightButton,\n ariaLabelLeftButton: ariaLabelLeftButton || resources?.ariaLabelLeftButton || defaultResources.ariaLabelLeftButton,\n };\n\n let onColorUsed: TabsOnColor = 'onwhite';\n if (color === 'white') {\n onColorUsed = onColor;\n }\n\n const onValueChange = (newValue: number): void => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n };\n\n const activeTabIndex = isControlled ? activeTab : uncontrolledValue;\n\n return (\n <div className={classNames(className, containerBreakout && designsystemlayout['container-breakout'])} data-testid={testId}>\n <div\n ref={tabListRef}\n className={classNames(styles['tab-list-wrapper'], {\n [styles['tab-list-wrapper--sticky']]: sticky,\n })}\n style={{\n zIndex: zIndex,\n }}\n >\n <TabList\n onTabListClick={(index: number) => onValueChange(index)}\n selectedTab={activeTabIndex}\n color={color}\n onColor={onColorUsed}\n ariaLabelLeftButton={mergedResources.ariaLabelLeftButton}\n ariaLabelRightButton={mergedResources.ariaLabelRightButton}\n >\n {children}\n </TabList>\n <div className={classNames(styles['panel-wrapper'], styles[`panel-wrapper--${color}`])}></div>\n </div>\n <div ref={tabsRef} style={{ marginTop: '-50px' }}>\n <TabPanel ref={tabPanelRef} color={color} isFirst={activeTabIndex == 0}>\n {React.Children.toArray(children)[activeTabIndex]}\n </TabPanel>\n </div>\n </div>\n );\n};\n\ntype TabsComponent = typeof TabsRoot & {\n Tab: typeof Tab;\n};\nconst Tabs = TabsRoot as TabsComponent;\nTabsRoot.displayName = 'Tabs';\nTabs.displayName = 'Tabs';\nTabs.Tab = Tab;\nTabs.Tab.displayName = 'Tabs.Tab';\n\nexport default Tabs;\n"],"names":["ariaLabelRightButton","ariaLabelLeftButton","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,eAAe,CAAC,aAAkD;AAC7E,UAAQ,UAAA;AAAA,IACN,KAAK,gBAAgB;AACnB,aAAO;AAAA,IACT,KAAK,gBAAgB;AAAA,IACrB;AACE,aAAO;AAAA,EAAA;AAEb;ACiCO,MAAM,WAAgC,CAAC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,UAAU;AAAA,EACV,SAAS;AAAA,EACT;AAAA,EACA,sBAAAA;AAAA,EACA,qBAAAC;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,cAAc;AACnC,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,CAAC;AAC5D,QAAM,UAAU,OAAuB,IAAI;AAC3C,QAAM,cAAc,OAAuB,IAAI;AAC/C,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,EAAE,SAAA,IAAa,YAA6B,gBAAgB,SAAS;AAC3E,QAAM,mBAAmB,aAAa,QAAQ;AAE9C,QAAM,kBAAsC;AAAA,IAC1C,GAAG;AAAA,IACH,GAAG;AAAA,IACH,sBAAsBD,0BAAwB,uCAAW,yBAAwB,iBAAiB;AAAA,IAClG,qBAAqBC,yBAAuB,uCAAW,wBAAuB,iBAAiB;AAAA,EAAA;AAGjG,MAAI,cAA2B;AAC/B,MAAI,UA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{ HNDesignsystemTabs } from '../../resources/Resources';
3
+ export declare const getResources: (language: LanguageLocales) => HNDesignsystemTabs;