@helsenorge/designsystem-react 12.4.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 (64) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/Drawer.js +33 -8
  3. package/Drawer.js.map +1 -1
  4. package/FormGroup.js +8 -3
  5. package/FormGroup.js.map +1 -1
  6. package/HelpTriggerIcon.js +13 -2
  7. package/HelpTriggerIcon.js.map +1 -1
  8. package/LazyIcon.js +1 -1
  9. package/LazyIcon.js.map +1 -1
  10. package/LinkList.js +81 -47
  11. package/LinkList.js.map +1 -1
  12. package/ListEditMode.js +42 -0
  13. package/ListEditMode.js.map +1 -0
  14. package/components/Drawer/Drawer.d.ts +6 -1
  15. package/components/Drawer/resourceHelper.d.ts +3 -0
  16. package/components/ExpanderList/ExpanderList.d.ts +8 -1
  17. package/components/ExpanderList/index.js +51 -20
  18. package/components/ExpanderList/index.js.map +1 -1
  19. package/components/ExpanderList/styles.module.scss +37 -33
  20. package/components/FavoriteButton/StarIcon.d.ts +4 -4
  21. package/components/FavoriteButton/index.js +23 -18
  22. package/components/FavoriteButton/index.js.map +1 -1
  23. package/components/FavoriteButton/styles.module.scss +8 -0
  24. package/components/FavoriteButton/styles.module.scss.d.ts +1 -0
  25. package/components/FormGroup/FormGroup.d.ts +2 -0
  26. package/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +2 -0
  27. package/components/HelpTriggerIcon/styles.module.scss +1 -1
  28. package/components/Icons/AdditionalIconInformation.d.ts +4 -0
  29. package/components/Icons/AdditionalIconInformation.js +2 -1
  30. package/components/Icons/AdditionalIconInformation.js.map +1 -1
  31. package/components/Icons/Feedback.d.ts +4 -0
  32. package/components/Icons/Feedback.js +25 -0
  33. package/components/Icons/Feedback.js.map +1 -0
  34. package/components/Icons/IconNames.d.ts +1 -1
  35. package/components/Icons/IconNames.js +1 -0
  36. package/components/Icons/IconNames.js.map +1 -1
  37. package/components/LinkList/LinkList.d.ts +8 -1
  38. package/components/LinkList/index.js +2 -0
  39. package/components/LinkList/index.js.map +1 -1
  40. package/components/LinkList/styles.module.scss +30 -22
  41. package/components/List/stories.module.scss +7 -0
  42. package/components/List/stories.module.scss.d.ts +9 -0
  43. package/components/ListEditMode/ListEditMode.d.ts +29 -0
  44. package/components/ListEditMode/index.d.ts +3 -0
  45. package/components/ListEditMode/index.js +9 -0
  46. package/components/ListEditMode/index.js.map +1 -0
  47. package/components/ListEditMode/styles.module.scss +79 -0
  48. package/components/ListEditMode/styles.module.scss.d.ts +18 -0
  49. package/components/Panel/styles.module.scss +5 -2
  50. package/components/PopMenu/index.js +1 -1
  51. package/components/PopMenu/index.js.map +1 -1
  52. package/components/PopMenu/styles.module.scss +4 -0
  53. package/components/PopMenu/styles.module.scss.d.ts +1 -0
  54. package/components/RadioButton/styles.module.scss +22 -4
  55. package/components/Tabs/Tabs.d.ts +6 -3
  56. package/components/Tabs/index.js +38 -4
  57. package/components/Tabs/index.js.map +1 -1
  58. package/components/Tabs/resourceHelper.d.ts +3 -0
  59. package/package.json +1 -1
  60. package/resources/HN.Designsystem.Drawer.en-GB.json.d.ts +6 -0
  61. package/resources/HN.Designsystem.Drawer.nb-NO.json.d.ts +6 -0
  62. package/resources/HN.Designsystem.Tabs.en-GB.json.d.ts +7 -0
  63. package/resources/HN.Designsystem.Tabs.nb-NO.json.d.ts +7 -0
  64. package/components/Tabs/TabsDocs.d.ts +0 -1
@@ -11,6 +11,7 @@ import { r as renderElementHeader } from "../../ElementHeader.js";
11
11
  import { H as Highlighter } from "../../Highlighter.js";
12
12
  import ChevronDown from "../Icons/ChevronDown.js";
13
13
  import ChevronUp from "../Icons/ChevronUp.js";
14
+ import { l as listEditModeWrapperClassnames, L as ListEditModeItem } from "../../ListEditMode.js";
14
15
  import expanderListStyles from "./styles.module.scss";
15
16
  const Expander = React__default.forwardRef((props, ref) => {
16
17
  const {
@@ -31,7 +32,8 @@ const Expander = React__default.forwardRef((props, ref) => {
31
32
  variant = "line",
32
33
  zIndex = 0,
33
34
  highlightText,
34
- status = "none"
35
+ status = "none",
36
+ editMode = false
35
37
  } = props;
36
38
  const [isExpanded] = useExpand(expanded, onExpand);
37
39
  const expanderRef = useRef(null);
@@ -80,7 +82,15 @@ const Expander = React__default.forwardRef((props, ref) => {
80
82
  });
81
83
  return /* @__PURE__ */ jsxs("li", { className: itemClasses, ref: mergeRefs([ref, expanderRef]), children: [
82
84
  status !== "none" && /* @__PURE__ */ jsx("div", { className: statusMarkerClasses }),
83
- /* @__PURE__ */ jsx(
85
+ editMode ? /* @__PURE__ */ jsx("div", { id, "data-testid": testId, "data-analyticsid": AnalyticsId.ExpanderListExpander, className: expanderClasses, children: renderElementHeader(title, {
86
+ titleHtmlMarkup,
87
+ isHovered: false,
88
+ size: large ? "large" : "medium",
89
+ parentType: "expanderlist",
90
+ chevronIcon: void 0,
91
+ icon,
92
+ highlightText
93
+ }) }) : /* @__PURE__ */ jsx(
84
94
  "button",
85
95
  {
86
96
  type: "button",
@@ -105,7 +115,7 @@ const Expander = React__default.forwardRef((props, ref) => {
105
115
  })
106
116
  }
107
117
  ),
108
- renderContent()
118
+ !editMode && renderContent()
109
119
  ] });
110
120
  });
111
121
  const isExpanderComponent = (element) => React__default.isValidElement(element) && element.type === Expander;
@@ -121,14 +131,16 @@ const ExpanderList = React__default.forwardRef((props, ref) => {
121
131
  testId,
122
132
  variant,
123
133
  zIndex,
124
- highlightText
134
+ highlightText,
135
+ editMode = false
125
136
  } = props;
126
137
  const [activeExpander, setActiveExpander] = useState();
127
138
  const [latestExpander, setLatestExpander] = useState();
128
139
  const uuid = useUuid();
129
140
  const expanderListClasses = classNames(expanderListStyles["expander-list"], className, {
130
141
  [expanderListStyles[`expander-list--outline--${color}`]]: variant === "outline",
131
- [expanderListStyles[`expander-list--fill`]]: variant === "fill" || variant === "fill-negative"
142
+ [expanderListStyles[`expander-list--fill`]]: variant === "fill" || variant === "fill-negative",
143
+ [listEditModeWrapperClassnames]: editMode
132
144
  });
133
145
  function handleExpanderClick(event, id) {
134
146
  setActiveExpander((prevState) => accordion ? { [id]: !(prevState == null ? void 0 : prevState[id]) } : { ...prevState, [id]: !(prevState == null ? void 0 : prevState[id]) });
@@ -159,21 +171,39 @@ const ExpanderList = React__default.forwardRef((props, ref) => {
159
171
  const id = getExpanderId(index);
160
172
  const expanded = activeExpander == null ? void 0 : activeExpander[id];
161
173
  const highlightTextChild = child.props.highlightText || highlightText;
162
- return React__default.cloneElement(child, {
163
- id,
164
- key: index,
165
- expanded,
166
- padding: childPadding,
167
- color,
168
- large,
169
- "aria-expanded": expanded,
170
- className: expanderListStyles["expander-list__item"],
171
- handleExpanderClick: (event) => handleExpanderClick(event, `${uuid}-${index}`),
172
- renderChildrenWhenClosed,
173
- variant,
174
- zIndex,
175
- highlightText: highlightTextChild
176
- });
174
+ if (editMode) {
175
+ return /* @__PURE__ */ jsx(ListEditModeItem, { color, variant, onDelete: child.props.onDelete, children: React__default.cloneElement(child, {
176
+ id,
177
+ key: index,
178
+ expanded,
179
+ padding: childPadding,
180
+ color,
181
+ large,
182
+ "aria-expanded": false,
183
+ className: expanderListStyles["expander-list__item"],
184
+ renderChildrenWhenClosed: false,
185
+ variant,
186
+ zIndex,
187
+ highlightText: highlightTextChild,
188
+ editMode: true
189
+ }) });
190
+ } else {
191
+ return React__default.cloneElement(child, {
192
+ id,
193
+ key: index,
194
+ expanded,
195
+ padding: childPadding,
196
+ color,
197
+ large,
198
+ "aria-expanded": expanded,
199
+ className: expanderListStyles["expander-list__item"],
200
+ handleExpanderClick: (event) => handleExpanderClick(event, `${uuid}-${index}`),
201
+ renderChildrenWhenClosed,
202
+ variant,
203
+ zIndex,
204
+ highlightText: highlightTextChild
205
+ });
206
+ }
177
207
  }
178
208
  return child;
179
209
  }) });
@@ -182,6 +212,7 @@ ExpanderList.displayName = "ExpanderList";
182
212
  ExpanderList.Expander = Expander;
183
213
  Expander.displayName = "ExpanderList.Expander";
184
214
  export {
215
+ Expander,
185
216
  ExpanderList,
186
217
  ExpanderList as default
187
218
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/ExpanderList/ExpanderList.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { PaletteNames } from '../../theme/palette';\nimport { mergeRefs } from '../../utils/refs';\nimport { isElementInViewport } from '../../utils/viewport';\nimport { ElementHeaderType, renderElementHeader } from '../ElementHeader/ElementHeader';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport { TitleTags } from '../Title';\n\nimport expanderListStyles from './styles.module.scss';\n\nexport type ExpanderListColors = Extract<PaletteNames, 'white' | 'blueberry' | 'cherry' | 'neutral'>;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ElementHeader?: ElementHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill' | 'fill-negative';\n\nexport type ExpanderListStatus = 'none' | 'new';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the colors of the list. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Override if different from list. */\n highlightText?: string;\n /** Displays a status on the left side: default none */\n status?: ExpanderListStatus;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'variant'>;\n\nconst Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n zIndex = 0,\n highlightText,\n status = 'none',\n } = props;\n const [isExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered, isFocused } = usePseudoClasses(triggerRef);\n\n const isFill = variant === 'fill';\n const isFillNegative = variant === 'fill-negative';\n const isOutline = variant === 'outline';\n const isLine = variant === 'line';\n\n const itemClasses = classNames(className, expanderListStyles['expander-list__item'], {\n [expanderListStyles[`expander-list__item--fill`]]: isFill,\n [expanderListStyles[`expander-list__item--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list__item--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list__item--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list__item--outline']]: isOutline,\n [expanderListStyles[`expander-list__item--outline--${color}`]]: isOutline,\n [expanderListStyles['expander-list__item--line']]: isLine,\n [expanderListStyles[`expander-list__item--line--${color}`]]: isLine,\n [expanderListStyles[`expander-list__item--new`]]: status === 'new',\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles[`expander-list-link--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list-link--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list-link--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list-link--outline']]: isOutline,\n [expanderListStyles[`expander-list-link--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link--line--${color}`]]: isLine,\n [expanderListStyles['expander-list-link--open']]: isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles[`expander-list-link--new`]]: status === 'new',\n });\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(expanderListStyles['expander-list-link__main-content'], {\n [expanderListStyles['expander-list-link__main-content--expanded']]: isExpanded,\n [expanderListStyles['expander-list-link__main-content--padding']]: padding,\n [expanderListStyles[`expander-list-link__main-content--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link__main-content--new`]]: status === 'new',\n });\n\n return (\n <div className={mainContentClasses} data-state={isExpanded ? 'open' : 'closed'}>\n <Highlighter searchText={highlightText}>{children}</Highlighter>\n </div>\n );\n };\n\n const statusMarkerClasses = classNames(expanderListStyles['expander-list__item__status-marker'], {\n [expanderListStyles['expander-list__item__status-marker--new']]: status === 'new',\n });\n\n return (\n <li className={itemClasses} ref={mergeRefs([ref, expanderRef])}>\n {status !== 'none' && <div className={statusMarkerClasses}></div>}\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isFocused ? zIndex + 1 : zIndex,\n }}\n >\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: isHovered || isFocused,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: isExpanded ? ChevronUp : ChevronDown,\n icon,\n highlightText,\n })}\n </button>\n {renderContent()}\n </li>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: unknown | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n renderChildrenWhenClosed = false,\n color = 'white',\n className = '',\n accordion = false,\n testId,\n variant,\n zIndex,\n highlightText,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const uuid = useUuid();\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className, {\n [expanderListStyles[`expander-list--outline--${color}`]]: variant === 'outline',\n [expanderListStyles[`expander-list--fill`]]: variant === 'fill' || variant === 'fill-negative',\n });\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n const getExpanderId = (index: number): string => `${uuid}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const highlightTextChild: string | undefined = child.props.highlightText || highlightText;\n\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': expanded,\n className: expanderListStyles['expander-list__item'],\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${uuid}-${index}`),\n renderChildrenWhenClosed,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n });\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.displayName = 'ExpanderList';\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;AAuFA,MAAM,WAAyBA,eAAM,WAAyC,CAAC,OAAO,QAAQ;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,kBAAkB;AAAA,IAClB,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,EAAA,IACP;AACJ,QAAM,CAAC,UAAU,IAAI,UAAU,UAAU,QAAQ;AACjD,QAAM,cAAc,OAAsB,IAAI;AAC9C,QAAM,aAAa,OAA0B,IAAI;AACjD,QAAM,EAAE,WAAW,cAAc,iBAAiB,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AAAA,IACF,CAAC,MAJyBA,mBAItB,OAAO,CAAC,KAAK,OAAO,UAAU;AAEhC,UAAI,OAAO,MAAM,MAAM,aAAa,aAAa;AAC/C,YAAI,cAAc,KAAK,CAAC,IAAI,MAAM,MAAM;AAAA,MAC1C;AACA,aAAO;AAAA,IACT,GAAG,CAAA;AAEH,sBAAkB,EAAE,GAAG,gBAAgB,GAAG,mBAAmB;AAAA,EAC/D,GAAG,CAAC,QAAQ,CAAC;AAEb,6BACG,MAAA,EAAG,WAAW,qBAAqB,KAAU,eAAa,QAAQ,oBAAkB,YAAY,cAC9F,yBAAM,SAAS,IAAI,UAAU,CAAC,OAAO,UAAU;AAC9C,QAAI,oBAAoB,KAAK,GAAG;AAC9B,YAAM,KAAK,cAAc,KAAK;AAC9B,YAAM,WAAW,iDAAiB;AAClC,YAAM,qBAAyC,MAAM,MAAM,iBAAiB;AAE5E,aAAOA,eAAM,aAAa,OAA4C;AAAA,QACpE;AAAA,QACA,KAAK;AAAA,QACL;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA,iBAAiB;AAAA,QACjB,WAAW,mBAAmB,qBAAqB;AAAA,QACnD,qBAAqB,CAAC,UAAyC,oBAAoB,OAAO,GAAG,IAAI,IAAI,KAAK,EAAE;AAAA,QAC5G;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,MAAA,CAChB;AAAA,IACH;AACA,WAAO;AAAA,EACT,CAAC,EAAA,CACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAC3B,aAAa,WAAW;AACxB,SAAS,cAAc;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/ExpanderList/ExpanderList.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { PaletteNames } from '../../theme/palette';\nimport { mergeRefs } from '../../utils/refs';\nimport { isElementInViewport } from '../../utils/viewport';\nimport { ElementHeaderType, renderElementHeader } from '../ElementHeader/ElementHeader';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ListEditModeItem, { ListEditModeItemProps, listEditModeWrapperClassnames } from '../ListEditMode';\nimport { TitleTags } from '../Title';\n\nimport expanderListStyles from './styles.module.scss';\n\nexport type ExpanderListColors = Extract<PaletteNames, 'white' | 'blueberry' | 'cherry' | 'neutral'>;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ElementHeader?: ElementHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill' | 'fill-negative';\n\nexport type ExpanderListStatus = 'none' | 'new';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the colors of the list. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /**\n * @experimental This prop is experimental and may change in the future.\n * Enables ListEditMode\n */\n editMode?: boolean;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Override if different from list. */\n highlightText?: string;\n /** Displays a status on the left side: default none */\n status?: ExpanderListStatus;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'variant'> &\n ListEditModeItemProps;\n\nexport const Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n zIndex = 0,\n highlightText,\n status = 'none',\n editMode = false,\n } = props;\n const [isExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered, isFocused } = usePseudoClasses(triggerRef);\n\n const isFill = variant === 'fill';\n const isFillNegative = variant === 'fill-negative';\n const isOutline = variant === 'outline';\n const isLine = variant === 'line';\n\n const itemClasses = classNames(className, expanderListStyles['expander-list__item'], {\n [expanderListStyles[`expander-list__item--fill`]]: isFill,\n [expanderListStyles[`expander-list__item--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list__item--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list__item--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list__item--outline']]: isOutline,\n [expanderListStyles[`expander-list__item--outline--${color}`]]: isOutline,\n [expanderListStyles['expander-list__item--line']]: isLine,\n [expanderListStyles[`expander-list__item--line--${color}`]]: isLine,\n [expanderListStyles[`expander-list__item--new`]]: status === 'new',\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles[`expander-list-link--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list-link--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list-link--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list-link--outline']]: isOutline,\n [expanderListStyles[`expander-list-link--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link--line--${color}`]]: isLine,\n [expanderListStyles['expander-list-link--open']]: isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles[`expander-list-link--new`]]: status === 'new',\n });\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(expanderListStyles['expander-list-link__main-content'], {\n [expanderListStyles['expander-list-link__main-content--expanded']]: isExpanded,\n [expanderListStyles['expander-list-link__main-content--padding']]: padding,\n [expanderListStyles[`expander-list-link__main-content--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link__main-content--new`]]: status === 'new',\n });\n\n return (\n <div className={mainContentClasses} data-state={isExpanded ? 'open' : 'closed'}>\n <Highlighter searchText={highlightText}>{children}</Highlighter>\n </div>\n );\n };\n\n const statusMarkerClasses = classNames(expanderListStyles['expander-list__item__status-marker'], {\n [expanderListStyles['expander-list__item__status-marker--new']]: status === 'new',\n });\n\n return (\n <li className={itemClasses} ref={mergeRefs([ref, expanderRef])}>\n {status !== 'none' && <div className={statusMarkerClasses}></div>}\n {editMode ? (\n <div id={id} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderListExpander} className={expanderClasses}>\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: false,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: undefined,\n icon,\n highlightText,\n })}\n </div>\n ) : (\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isFocused ? zIndex + 1 : zIndex,\n }}\n >\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: isHovered || isFocused,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: isExpanded ? ChevronUp : ChevronDown,\n icon,\n highlightText,\n })}\n </button>\n )}\n {!editMode && renderContent()}\n </li>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: unknown | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n renderChildrenWhenClosed = false,\n color = 'white',\n className = '',\n accordion = false,\n testId,\n variant,\n zIndex,\n highlightText,\n editMode = false,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const uuid = useUuid();\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className, {\n [expanderListStyles[`expander-list--outline--${color}`]]: variant === 'outline',\n [expanderListStyles[`expander-list--fill`]]: variant === 'fill' || variant === 'fill-negative',\n [listEditModeWrapperClassnames]: editMode,\n });\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n const getExpanderId = (index: number): string => `${uuid}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const highlightTextChild: string | undefined = child.props.highlightText || highlightText;\n\n if (editMode) {\n return (\n <ListEditModeItem color={color} variant={variant} onDelete={child.props.onDelete}>\n {React.cloneElement(child, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': false,\n className: expanderListStyles['expander-list__item'],\n renderChildrenWhenClosed: false,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n editMode: true,\n })}\n </ListEditModeItem>\n );\n } else {\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': expanded,\n className: expanderListStyles['expander-list__item'],\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${uuid}-${index}`),\n renderChildrenWhenClosed,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n });\n }\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.displayName = 'ExpanderList';\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;AA8FO,MAAM,WAAyBA,eAAM,WAAyC,CAAC,OAAO,QAAQ;AACnG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,YAAY;AAAA,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I,UAAU;AACZ,eACE,oBAAC,kBAAA,EAAiB,OAAc,SAAkB,UAAU,MAAM,MAAM,UACrE,UAAAA,eAAM,aAAa,OAAO;AAAA,UACzB;AAAA,UACA,KAAK;AAAA,UACL;AAAA,UACA,SAAS;AAAA,UACT;AAAA,UACA;AAAA,UACA,iBAAiB;AAAA,UACjB,WAAW,mBAAmB,qBAAqB;AAAA,UACnD,0BAA0B;AAAA,UAC1B;AAAA,UACA;AAAA,UACA,eAAe;AAAA,UACf,UAAU;AAAA,QAAA,CACX,GACH;AAAA,MAEJ,OAAO;AACL,eAAOA,eAAM,aAAa,OAA4C;AAAA,UACpE;AAAA,UACA,KAAK;AAAA,UACL;AAAA,UACA,SAAS;AAAA,UACT;AAAA,UACA;AAAA,UACA,iBAAiB;AAAA,UACjB,WAAW,mBAAmB,qBAAqB;AAAA,UACnD,qBAAqB,CAAC,UAAyC,oBAAoB,OAAO,GAAG,IAAI,IAAI,KAAK,EAAE;AAAA,UAC5G;AAAA,UACA;AAAA,UACA;AAAA,UACA,eAAe;AAAA,QAAA,CAChB;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT,CAAC,EAAA,CACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAC3B,aAAa,WAAW;AACxB,SAAS,cAAc;"}
@@ -187,7 +187,6 @@
187
187
  font-size: font-settings.$font-size-sm;
188
188
  line-height: font-settings.$lineheight-size-sm;
189
189
  display: flex;
190
- cursor: pointer;
191
190
  font-family: inherit;
192
191
  text-decoration: none;
193
192
  justify-content: space-between;
@@ -200,6 +199,10 @@
200
199
  grid-area: header;
201
200
  padding-left: var(--statusmarker-left-space);
202
201
 
202
+ &:not(div) {
203
+ cursor: pointer;
204
+ }
205
+
203
206
  @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
204
207
  font-size: font-settings.$font-size-md;
205
208
  line-height: font-settings.$lineheight-size-md;
@@ -223,11 +226,12 @@
223
226
 
224
227
  &--white:not(.expander-list-link--outline, .expander-list-link--fill-negative) {
225
228
  &[aria-expanded='false'] {
226
- &:hover {
229
+ // expander settes til div om man er i edit mode, og skal da ikke ha hover/active effekter
230
+ &:hover:not(div) {
227
231
  background-color: var(--core-color-neutral-50);
228
232
  }
229
233
 
230
- &:active {
234
+ &:active:not(div) {
231
235
  background-color: var(--core-color-neutral-100);
232
236
  }
233
237
  }
@@ -235,11 +239,11 @@
235
239
  &[aria-expanded='true'] {
236
240
  background-color: var(--core-color-neutral-50);
237
241
 
238
- &:hover {
242
+ &:hover:not(div) {
239
243
  background-color: var(--core-color-neutral-100);
240
244
  }
241
245
 
242
- &:active {
246
+ &:active:not(div) {
243
247
  background-color: var(--core-color-neutral-200);
244
248
  }
245
249
  }
@@ -247,11 +251,11 @@
247
251
 
248
252
  &--blueberry:not(.expander-list-link--outline, .expander-list-link--fill-negative) {
249
253
  &[aria-expanded='false'] {
250
- &:hover {
254
+ &:hover:not(div) {
251
255
  background-color: var(--core-color-blueberry-100);
252
256
  }
253
257
 
254
- &:active {
258
+ &:active:not(div) {
255
259
  background-color: var(--color-action-background-ondark-hoverselected);
256
260
  }
257
261
  }
@@ -259,11 +263,11 @@
259
263
  &[aria-expanded='true'] {
260
264
  background-color: var(--core-color-blueberry-100);
261
265
 
262
- &:hover {
266
+ &:hover:not(div) {
263
267
  background-color: var(--core-color-blueberry-200);
264
268
  }
265
269
 
266
- &:active {
270
+ &:active:not(div) {
267
271
  background-color: var(--core-color-blueberry-300);
268
272
  }
269
273
  }
@@ -271,11 +275,11 @@
271
275
 
272
276
  &--cherry:not(.expander-list-link--outline, .expander-list-link--fill-negative) {
273
277
  &[aria-expanded='false'] {
274
- &:hover {
278
+ &:hover:not(div) {
275
279
  background-color: var(--core-color-cherry-100);
276
280
  }
277
281
 
278
- &:active {
282
+ &:active:not(div) {
279
283
  background-color: var(--core-color-cherry-200);
280
284
  }
281
285
  }
@@ -283,11 +287,11 @@
283
287
  &[aria-expanded='true'] {
284
288
  background-color: var(--core-color-cherry-100);
285
289
 
286
- &:hover {
290
+ &:hover:not(div) {
287
291
  background-color: var(--core-color-cherry-200);
288
292
  }
289
293
 
290
- &:active {
294
+ &:active:not(div) {
291
295
  background-color: var(--core-color-cherry-300);
292
296
  }
293
297
  }
@@ -295,11 +299,11 @@
295
299
 
296
300
  &--neutral:not(.expander-list-link--outline, .expander-list-link--fill-negative) {
297
301
  &[aria-expanded='false'] {
298
- &:hover {
302
+ &:hover:not(div) {
299
303
  background-color: var(--core-color-neutral-100);
300
304
  }
301
305
 
302
- &:active {
306
+ &:active:not(div) {
303
307
  background-color: var(--core-color-neutral-200);
304
308
  }
305
309
  }
@@ -307,11 +311,11 @@
307
311
  &[aria-expanded='true'] {
308
312
  background-color: var(--core-color-neutral-100);
309
313
 
310
- &:hover {
314
+ &:hover:not(div) {
311
315
  background-color: var(--core-color-neutral-200);
312
316
  }
313
317
 
314
- &:active {
318
+ &:active:not(div) {
315
319
  background-color: var(--core-color-neutral-300);
316
320
  }
317
321
  }
@@ -349,11 +353,11 @@
349
353
 
350
354
  &--blueberry {
351
355
  &[aria-expanded='false'] {
352
- &:hover {
356
+ &:hover:not(div) {
353
357
  background-color: var(--core-color-blueberry-50);
354
358
  }
355
359
 
356
- &:active {
360
+ &:active:not(div) {
357
361
  background-color: var(--core-color-blueberry-100);
358
362
  }
359
363
  }
@@ -361,11 +365,11 @@
361
365
  &[aria-expanded='true'] {
362
366
  background-color: var(--core-color-blueberry-50);
363
367
 
364
- &:hover {
368
+ &:hover:not(div) {
365
369
  background-color: var(--core-color-blueberry-100);
366
370
  }
367
371
 
368
- &:active {
372
+ &:active:not(div) {
369
373
  background-color: var(--core-color-blueberry-200);
370
374
  }
371
375
  }
@@ -373,11 +377,11 @@
373
377
 
374
378
  &--cherry {
375
379
  &[aria-expanded='false'] {
376
- &:hover {
380
+ &:hover:not(div) {
377
381
  background-color: var(--core-color-cherry-50);
378
382
  }
379
383
 
380
- &:active {
384
+ &:active:not(div) {
381
385
  background-color: var(--core-color-cherry-100);
382
386
  }
383
387
  }
@@ -385,11 +389,11 @@
385
389
  &[aria-expanded='true'] {
386
390
  background-color: var(--core-color-cherry-50);
387
391
 
388
- &:hover {
392
+ &:hover:not(div) {
389
393
  background-color: var(--core-color-cherry-100);
390
394
  }
391
395
 
392
- &:active {
396
+ &:active:not(div) {
393
397
  background-color: var(--core-color-cherry-200);
394
398
  }
395
399
  }
@@ -398,11 +402,11 @@
398
402
  &--neutral,
399
403
  &--white {
400
404
  &[aria-expanded='false'] {
401
- &:hover {
405
+ &:hover:not(div) {
402
406
  background-color: var(--core-color-neutral-50);
403
407
  }
404
408
 
405
- &:active {
409
+ &:active:not(div) {
406
410
  background-color: var(--core-color-neutral-100);
407
411
  }
408
412
  }
@@ -410,11 +414,11 @@
410
414
  &[aria-expanded='true'] {
411
415
  background-color: var(--core-color-neutral-50);
412
416
 
413
- &:hover {
417
+ &:hover:not(div) {
414
418
  background-color: var(--core-color-neutral-100);
415
419
  }
416
420
 
417
- &:active {
421
+ &:active:not(div) {
418
422
  background-color: var(--core-color-neutral-200);
419
423
  }
420
424
  }
@@ -429,22 +433,22 @@
429
433
  &--new {
430
434
  background-color: var(--core-color-blueberry-50) !important;
431
435
 
432
- &:hover {
436
+ &:hover:not(div) {
433
437
  background-color: var(--core-color-blueberry-100) !important;
434
438
  }
435
439
 
436
- &:active {
440
+ &:active:not(div) {
437
441
  background-color: var(--core-color-blueberry-200) !important;
438
442
  }
439
443
 
440
444
  &[aria-expanded='true'] {
441
445
  background-color: var(--core-color-blueberry-100) !important;
442
446
 
443
- &:hover {
447
+ &:hover:not(div) {
444
448
  background-color: var(--core-color-blueberry-200) !important;
445
449
  }
446
450
 
447
- &:active {
451
+ &:active:not(div) {
448
452
  background-color: var(--core-color-blueberry-300) !important;
449
453
  }
450
454
  }
@@ -1,4 +1,4 @@
1
- export declare const starIconNormalMobile: (isFocused: boolean, isChecked: boolean, isActive: boolean) => React.JSX.Element;
2
- export declare const starIconHoverMobile: (isFocused: boolean, isChecked: boolean, isActive: boolean) => React.JSX.Element;
3
- export declare const starIconNormalDesktop: (isFocused: boolean, isChecked: boolean, isActive: boolean) => React.JSX.Element;
4
- export declare const starIconHoverDesktop: (isFocused: boolean, isChecked: boolean, isActive: boolean) => React.JSX.Element;
1
+ export declare const starIconNormalMobile: (isChecked: boolean, isActive: boolean) => React.JSX.Element;
2
+ export declare const starIconHoverMobile: (isChecked: boolean, isActive: boolean) => React.JSX.Element;
3
+ export declare const starIconNormalDesktop: (isChecked: boolean, isActive: boolean) => React.JSX.Element;
4
+ export declare const starIconHoverDesktop: (isChecked: boolean, isActive: boolean) => React.JSX.Element;
@@ -2,11 +2,11 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
3
  import classNames from "classnames";
4
4
  import { LanguageLocales, AnalyticsId } from "../../constants.js";
5
+ import styles from "./styles.module.scss";
5
6
  import { useBreakpoint, Breakpoint } from "../../hooks/useBreakpoint.js";
6
7
  import { usePseudoClasses } from "../../hooks/usePseudoClasses.js";
7
8
  import { useLanguage } from "../../utils/language.js";
8
9
  import { isMutableRefObject } from "../../utils/refs.js";
9
- import styles from "./styles.module.scss";
10
10
  const ariaLabel = "Favorittmarkering";
11
11
  const nbNO = {
12
12
  ariaLabel
@@ -53,16 +53,18 @@ const strokeColor = (isActive, isHovered) => {
53
53
  }
54
54
  }
55
55
  };
56
- const starIconNormalMobile = (isFocused, isChecked, isActive) => {
56
+ const starIconNormalMobile = (isChecked, isActive) => {
57
57
  return /* @__PURE__ */ jsxs(Fragment, { children: [
58
- isFocused && /* @__PURE__ */ jsx(
58
+ /* @__PURE__ */ jsx(
59
59
  "path",
60
60
  {
61
61
  d: "M20.1026 31.1787L13.4007 34.7023C10.833 36.0523 7.83185 33.8719 8.32233 31.0126L9.60261 23.5492L4.17653 18.2675C2.09656 16.2428 3.24317 12.712 6.11581 12.2956L13.5982 11.2112L16.9493 4.42107C18.2332 1.81969 21.9426 1.81969 23.2265 4.42107L26.5776 11.2112L34.06 12.2956C36.9326 12.712 38.0792 16.2428 35.9993 18.2675L30.5732 23.5492L31.852 31.0044C32.3428 33.8651 29.3386 36.0456 26.7708 34.6925L20.1026 31.1787Z",
62
62
  stroke: "black",
63
63
  fill: "transparent",
64
64
  strokeWidth: "3",
65
- strokeLinecap: "round"
65
+ strokeLinecap: "round",
66
+ className: styles["favoritebutton__star-icon--focus"],
67
+ display: "block"
66
68
  }
67
69
  ),
68
70
  /* @__PURE__ */ jsx(
@@ -78,15 +80,16 @@ const starIconNormalMobile = (isFocused, isChecked, isActive) => {
78
80
  )
79
81
  ] });
80
82
  };
81
- const starIconHoverMobile = (isFocused, isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
82
- isFocused && /* @__PURE__ */ jsx(
83
+ const starIconHoverMobile = (isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
84
+ /* @__PURE__ */ jsx(
83
85
  "path",
84
86
  {
85
87
  d: "M22.2128 31.4832L16.2246 36.117C13.9303 37.8924 10.5961 36.2662 10.5826 33.3653L10.5475 25.7929L4.28665 21.5336C1.88672 19.9009 2.40278 16.2246 5.15948 15.3158L12.3399 12.9486L14.461 5.67964C15.2736 2.89484 18.9267 2.2507 20.6428 4.58962L25.1221 10.6947L32.6791 10.4633C35.5804 10.3745 37.3227 13.6526 35.6259 16.0077L31.1994 22.1514L33.7534 29.2712C34.7335 32.0033 32.1536 34.6724 29.3898 33.7857L22.2128 31.4832Z",
86
88
  stroke: "black",
87
89
  fill: "transparent",
88
90
  strokeWidth: "3",
89
- strokeLinecap: "round"
91
+ strokeLinecap: "round",
92
+ className: styles["favoritebutton__star-icon--focus"]
90
93
  }
91
94
  ),
92
95
  /* @__PURE__ */ jsx(
@@ -102,15 +105,16 @@ const starIconHoverMobile = (isFocused, isChecked, isActive) => /* @__PURE__ */
102
105
  }
103
106
  )
104
107
  ] });
105
- const starIconNormalDesktop = (isFocused, isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
106
- isFocused && /* @__PURE__ */ jsx(
108
+ const starIconNormalDesktop = (isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
109
+ /* @__PURE__ */ jsx(
107
110
  "path",
108
111
  {
109
112
  d: "M30.1061 44.1854L20.3139 49.3338C17.7461 50.6838 14.745 48.5034 15.2355 45.6441L17.1061 34.7394L9.17653 27.0207C7.09656 24.9961 8.24318 21.4653 11.1158 21.0489L22.053 19.4638L26.9493 9.54278C28.2331 6.9414 31.9426 6.94139 33.2265 9.54278L38.1227 19.4638L49.06 21.0489C51.9326 21.4653 53.0792 24.9961 50.9993 27.0207L43.0697 34.7394L44.9389 45.6359C45.4296 48.4966 42.4254 50.6772 39.8576 49.324L30.1061 44.1854Z",
110
113
  stroke: "black",
111
114
  fill: "transparent",
112
115
  strokeWidth: "3",
113
- strokeLinecap: "round"
116
+ strokeLinecap: "round",
117
+ className: styles["favoritebutton__star-icon--focus"]
114
118
  }
115
119
  ),
116
120
  /* @__PURE__ */ jsx(
@@ -125,15 +129,16 @@ const starIconNormalDesktop = (isFocused, isChecked, isActive) => /* @__PURE__ *
125
129
  }
126
130
  )
127
131
  ] });
128
- const starIconHoverDesktop = (isFocused, isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
129
- isFocused && /* @__PURE__ */ jsx(
132
+ const starIconHoverDesktop = (isChecked, isActive) => /* @__PURE__ */ jsxs(Fragment, { children: [
133
+ /* @__PURE__ */ jsx(
130
134
  "path",
131
135
  {
132
136
  d: "M33.1609 44.7458L24.4114 51.5164C22.1171 53.2918 18.783 51.6656 18.7695 48.7646L18.7181 37.7007L9.56864 31.4763C7.1687 29.8436 7.68476 26.1672 10.4415 25.2584L20.9373 21.7982L24.0364 11.1776C24.849 8.39281 28.5021 7.74867 30.2182 10.0876L36.7629 19.0077L47.8092 18.6695C50.7105 18.5807 52.4528 21.8588 50.756 24.2138L44.2872 33.1922L48.0201 43.5985C49.0002 46.3306 46.4203 48.9997 43.6565 48.113L33.1609 44.7458Z",
133
137
  stroke: "black",
134
138
  fill: "transparent",
135
139
  strokeWidth: "3",
136
- strokeLinecap: "round"
140
+ strokeLinecap: "round",
141
+ className: styles["favoritebutton__star-icon--focus"]
137
142
  }
138
143
  ),
139
144
  /* @__PURE__ */ jsx(
@@ -152,7 +157,7 @@ const starIconHoverDesktop = (isFocused, isChecked, isActive) => /* @__PURE__ */
152
157
  const FavoriteButton = React__default.forwardRef(function FavoriteButtonForwardedRef(props, ref) {
153
158
  const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;
154
159
  const buttonWrapperClasses = classNames(styles.favoritebutton);
155
- const { refObject, isFocused, isHovered, isActive } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
160
+ const { refObject, isHovered, isActive } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
156
161
  const breakpoint = useBreakpoint();
157
162
  const { language } = useLanguage(LanguageLocales.NORWEGIAN);
158
163
  const defaultResources = getResources(language);
@@ -165,15 +170,15 @@ const FavoriteButton = React__default.forwardRef(function FavoriteButtonForwarde
165
170
  const starIcon = (() => {
166
171
  if (isMobile) {
167
172
  if (isHovered) {
168
- return starIconHoverMobile(isFocused, checked, isActive);
173
+ return starIconHoverMobile(checked, isActive);
169
174
  } else {
170
- return starIconNormalMobile(isFocused, checked, isActive);
175
+ return starIconNormalMobile(checked, isActive);
171
176
  }
172
177
  } else {
173
178
  if (isHovered) {
174
- return starIconHoverDesktop(isFocused, checked, isActive);
179
+ return starIconHoverDesktop(checked, isActive);
175
180
  } else {
176
- return starIconNormalDesktop(isFocused, checked, isActive);
181
+ return starIconNormalDesktop(checked, isActive);
177
182
  }
178
183
  }
179
184
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/FavoriteButton/resourceHelper.ts","../../../src/components/FavoriteButton/StarIcon.tsx","../../../src/components/FavoriteButton/FavoriteButton.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FavoriteButton.nb-NO.json';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFavoriteButton => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","const normalStroke = 'var(--color-action-graphics-onlight)';\nconst normalFill = 'transparent';\nconst hoverFill = '#126F8721'; // kan ikke bruke transparent token på svg\nconst hoverStroke = 'var(--color-action-graphics-onlight-hover)';\nconst activeStroke = 'var(--core-color-blueberry-800)';\n\nconst fillColor = (isChecked: boolean, isActive: boolean, isHovered: boolean): string => {\n if (isChecked) {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n } else {\n if (isHovered) {\n return hoverFill;\n } else {\n return normalFill;\n }\n }\n};\n\nconst strokeColor = (isActive: boolean, isHovered: boolean): string => {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n};\n\nexport const starIconNormalMobile = (isFocused: boolean, isChecked: boolean, isActive: boolean): React.JSX.Element => {\n return (\n <>\n {isFocused && (\n <path\n d=\"M20.1026 31.1787L13.4007 34.7023C10.833 36.0523 7.83185 33.8719 8.32233 31.0126L9.60261 23.5492L4.17653 18.2675C2.09656 16.2428 3.24317 12.712 6.11581 12.2956L13.5982 11.2112L16.9493 4.42107C18.2332 1.81969 21.9426 1.81969 23.2265 4.42107L26.5776 11.2112L34.06 12.2956C36.9326 12.712 38.0792 16.2428 35.9993 18.2675L30.5732 23.5492L31.852 31.0044C32.3428 33.8651 29.3386 36.0456 26.7708 34.6925L20.1026 31.1787Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n />\n )}\n <path\n d=\"M20.0961 26.5515L12.6372 30.4731L14.0621 22.1671L8.01953 16.2853L16.3582 15.0768L20.0877 7.52002L23.8171 15.0768L32.1558 16.2853L26.1133 22.1671L27.5381 30.4731L20.0961 26.5515Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n );\n};\n\nexport const starIconHoverMobile = (isFocused: boolean, isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n {isFocused && (\n <path\n d=\"M22.2128 31.4832L16.2246 36.117C13.9303 37.8924 10.5961 36.2662 10.5826 33.3653L10.5475 25.7929L4.28665 21.5336C1.88672 19.9009 2.40278 16.2246 5.15948 15.3158L12.3399 12.9486L14.461 5.67964C15.2736 2.89484 18.9267 2.2507 20.6428 4.58962L25.1221 10.6947L32.6791 10.4633C35.5804 10.3745 37.3227 13.6526 35.6259 16.0077L31.1994 22.1514L33.7534 29.2712C34.7335 32.0033 32.1536 34.6724 29.3898 33.7857L22.2128 31.4832Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n />\n )}\n <path\n d=\"M21.4079 26.8365L14.7433 31.9937L14.7041 23.5664L7.73204 18.8233L15.7342 16.1851L18.0947 8.09555L23.0798 14.8899L31.5016 14.6321L26.5722 21.4738L29.4178 29.4062L21.4079 26.8365Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\nexport const starIconNormalDesktop = (isFocused: boolean, isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n {isFocused && (\n <path\n d=\"M30.1061 44.1854L20.3139 49.3338C17.7461 50.6838 14.745 48.5034 15.2355 45.6441L17.1061 34.7394L9.17653 27.0207C7.09656 24.9961 8.24318 21.4653 11.1158 21.0489L22.053 19.4638L26.9493 9.54278C28.2331 6.9414 31.9426 6.94139 33.2265 9.54278L38.1227 19.4638L49.06 21.0489C51.9326 21.4653 53.0792 24.9961 50.9993 27.0207L43.0697 34.7394L44.9389 45.6359C45.4296 48.4966 42.4254 50.6772 39.8576 49.324L30.1061 44.1854Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n />\n )}\n <path\n d=\"M30.0998 39.4723L19.5927 44.9966L21.5998 33.2961L13.0879 25.0106L24.8343 23.3082L30.0879 12.6632L35.3414 23.3082L47.0879 25.0106L38.576 33.2961L40.5831 44.9966L30.0998 39.4723Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n\nexport const starIconHoverDesktop = (isFocused: boolean, isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n {isFocused && (\n <path\n d=\"M33.1609 44.7458L24.4114 51.5164C22.1171 53.2918 18.783 51.6656 18.7695 48.7646L18.7181 37.7007L9.56864 31.4763C7.1687 29.8436 7.68476 26.1672 10.4415 25.2584L20.9373 21.7982L24.0364 11.1776C24.849 8.39281 28.5021 7.74867 30.2182 10.0876L36.7629 19.0077L47.8092 18.6695C50.7105 18.5807 52.4528 21.8588 50.756 24.2138L44.2872 33.1922L48.0201 43.5985C49.0002 46.3306 46.4203 48.9997 43.6565 48.113L33.1609 44.7458Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n />\n )}\n <path\n d=\"M32.3991 40.1029L23.0108 47.3678L22.9557 35.4965L13.1343 28.815L24.4067 25.0987L27.732 13.7031L34.7542 23.2741L46.6178 22.9109L39.674 32.5486L43.6823 43.7228L32.3991 40.1029Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n","import React, { AriaAttributes } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { starIconHoverDesktop, starIconHoverMobile, starIconNormalDesktop, starIconNormalMobile } from './StarIcon';\nimport { AnalyticsId, HTMLButtonProps, LanguageLocales } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport { isMutableRefObject } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport interface FavoriteButtonProps extends HTMLButtonProps, AriaAttributes {\n /** Determines if the FavoriteButton is checked */\n checked: boolean;\n /** Gives a unique id to the button */\n id?: string;\n /** Function that is called when clicked */\n onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Resources for component */\n resources?: Partial<HNDesignsystemFavoriteButton>;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const FavoriteButton = React.forwardRef(function FavoriteButtonForwardedRef(\n props: FavoriteButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement>\n) {\n const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;\n\n const buttonWrapperClasses = classNames(styles.favoritebutton);\n const { refObject, isFocused, isHovered, isActive } = usePseudoClasses<HTMLButtonElement>(isMutableRefObject(ref) ? ref : null);\n const breakpoint = useBreakpoint();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFavoriteButton = {\n ...defaultResources,\n ...resources,\n ariaLabel: other['aria-label'] || resources?.ariaLabel || defaultResources.ariaLabel,\n };\n\n const isMobile = breakpoint <= Breakpoint.sm;\n\n const starIcon = ((): React.JSX.Element => {\n if (isMobile) {\n if (isHovered) {\n return starIconHoverMobile(isFocused, checked, isActive);\n } else {\n return starIconNormalMobile(isFocused, checked, isActive);\n }\n } else {\n if (isHovered) {\n return starIconHoverDesktop(isFocused, checked, isActive);\n } else {\n return starIconNormalDesktop(isFocused, checked, isActive);\n }\n }\n })();\n\n return (\n <button\n id={id}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FavoriteButton}\n className={buttonWrapperClasses}\n ref={refObject}\n tabIndex={tabIndex}\n role=\"switch\"\n aria-checked={checked}\n type=\"button\"\n aria-label={mergedResources.ariaLabel}\n {...other}\n >\n <svg focusable={false} overflow=\"visible\" role=\"presentation\" viewBox={isMobile ? '0 0 41 41' : '0 0 61 61'} {...other}>\n {starIcon}\n </svg>\n </button>\n );\n});\n\nFavoriteButton.displayName = 'FavoriteButton';\n\nexport default FavoriteButton;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AAIO,MAAM,eAAe,CAAC,aAA4D;AACvF,UAAQ,UAAA;AAAA,IACN,KAAK,gBAAgB;AAAA,IACrB;AACE,aAAO;AAAA,EAAA;AAEb;ACVA,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,eAAe;AAErB,MAAM,YAAY,CAAC,WAAoB,UAAmB,cAA+B;AACvF,MAAI,WAAW;AACb,QAAI,UAAU;AACZ,aAAO;AAAA,IACT,OAAO;AACL,UAAI,WAAW;AACb,eAAO;AAAA,MACT,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,OAAO;AACL,QAAI,WAAW;AACb,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,MAAM,cAAc,CAAC,UAAmB,cAA+B;AACrE,MAAI,UAAU;AACZ,WAAO;AAAA,EACT,OAAO;AACL,QAAI,WAAW;AACb,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,uBAAuB,CAAC,WAAoB,WAAoB,aAAyC;AACpH,SACE,qBAAA,UAAA,EACG,UAAA;AAAA,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,MAC1D;AAAA,IACF,OAAO;AACL,UAAI,WAAW;AACb,eAAO,qBAAqB,WAAW,SAAS,QAAQ;AAAA,MAC1D,OAAO;AACL,eAAO,sBAAsB,WAAW,SAAS,QAAQ;AAAA,MAC3D;AAAA,IACF;AAAA,EACF,GAAA;AAEA,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,eAAa;AAAA,MACb,oBAAkB,YAAY;AAAA,MAC9B,WAAW;AAAA,MACX,KAAK;AAAA,MACL;AAAA,MACA,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,MAAK;AAAA,MACL,cAAY,gBAAgB;AAAA,MAC3B,GAAG;AAAA,MAEJ,UAAA,oBAAC,OAAA,EAAI,WAAW,OAAO,UAAS,WAAU,MAAK,gBAAe,SAAS,WAAW,cAAc,aAAc,GAAG,OAC9G,UAAA,SAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AAED,eAAe,cAAc;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/FavoriteButton/resourceHelper.ts","../../../src/components/FavoriteButton/StarIcon.tsx","../../../src/components/FavoriteButton/FavoriteButton.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FavoriteButton.nb-NO.json';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFavoriteButton => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import styles from './styles.module.scss';\n\nconst normalStroke = 'var(--color-action-graphics-onlight)';\nconst normalFill = 'transparent';\nconst hoverFill = '#126F8721'; // kan ikke bruke transparent token på svg\nconst hoverStroke = 'var(--color-action-graphics-onlight-hover)';\nconst activeStroke = 'var(--core-color-blueberry-800)';\n\nconst fillColor = (isChecked: boolean, isActive: boolean, isHovered: boolean): string => {\n if (isChecked) {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n } else {\n if (isHovered) {\n return hoverFill;\n } else {\n return normalFill;\n }\n }\n};\n\nconst strokeColor = (isActive: boolean, isHovered: boolean): string => {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n};\n\nexport const starIconNormalMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => {\n return (\n <>\n <path\n d=\"M20.1026 31.1787L13.4007 34.7023C10.833 36.0523 7.83185 33.8719 8.32233 31.0126L9.60261 23.5492L4.17653 18.2675C2.09656 16.2428 3.24317 12.712 6.11581 12.2956L13.5982 11.2112L16.9493 4.42107C18.2332 1.81969 21.9426 1.81969 23.2265 4.42107L26.5776 11.2112L34.06 12.2956C36.9326 12.712 38.0792 16.2428 35.9993 18.2675L30.5732 23.5492L31.852 31.0044C32.3428 33.8651 29.3386 36.0456 26.7708 34.6925L20.1026 31.1787Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n display=\"block\"\n />\n <path\n d=\"M20.0961 26.5515L12.6372 30.4731L14.0621 22.1671L8.01953 16.2853L16.3582 15.0768L20.0877 7.52002L23.8171 15.0768L32.1558 16.2853L26.1133 22.1671L27.5381 30.4731L20.0961 26.5515Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n );\n};\n\nexport const starIconHoverMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M22.2128 31.4832L16.2246 36.117C13.9303 37.8924 10.5961 36.2662 10.5826 33.3653L10.5475 25.7929L4.28665 21.5336C1.88672 19.9009 2.40278 16.2246 5.15948 15.3158L12.3399 12.9486L14.461 5.67964C15.2736 2.89484 18.9267 2.2507 20.6428 4.58962L25.1221 10.6947L32.6791 10.4633C35.5804 10.3745 37.3227 13.6526 35.6259 16.0077L31.1994 22.1514L33.7534 29.2712C34.7335 32.0033 32.1536 34.6724 29.3898 33.7857L22.2128 31.4832Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M21.4079 26.8365L14.7433 31.9937L14.7041 23.5664L7.73204 18.8233L15.7342 16.1851L18.0947 8.09555L23.0798 14.8899L31.5016 14.6321L26.5722 21.4738L29.4178 29.4062L21.4079 26.8365Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\nexport const starIconNormalDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M30.1061 44.1854L20.3139 49.3338C17.7461 50.6838 14.745 48.5034 15.2355 45.6441L17.1061 34.7394L9.17653 27.0207C7.09656 24.9961 8.24318 21.4653 11.1158 21.0489L22.053 19.4638L26.9493 9.54278C28.2331 6.9414 31.9426 6.94139 33.2265 9.54278L38.1227 19.4638L49.06 21.0489C51.9326 21.4653 53.0792 24.9961 50.9993 27.0207L43.0697 34.7394L44.9389 45.6359C45.4296 48.4966 42.4254 50.6772 39.8576 49.324L30.1061 44.1854Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M30.0998 39.4723L19.5927 44.9966L21.5998 33.2961L13.0879 25.0106L24.8343 23.3082L30.0879 12.6632L35.3414 23.3082L47.0879 25.0106L38.576 33.2961L40.5831 44.9966L30.0998 39.4723Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n\nexport const starIconHoverDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M33.1609 44.7458L24.4114 51.5164C22.1171 53.2918 18.783 51.6656 18.7695 48.7646L18.7181 37.7007L9.56864 31.4763C7.1687 29.8436 7.68476 26.1672 10.4415 25.2584L20.9373 21.7982L24.0364 11.1776C24.849 8.39281 28.5021 7.74867 30.2182 10.0876L36.7629 19.0077L47.8092 18.6695C50.7105 18.5807 52.4528 21.8588 50.756 24.2138L44.2872 33.1922L48.0201 43.5985C49.0002 46.3306 46.4203 48.9997 43.6565 48.113L33.1609 44.7458Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M32.3991 40.1029L23.0108 47.3678L22.9557 35.4965L13.1343 28.815L24.4067 25.0987L27.732 13.7031L34.7542 23.2741L46.6178 22.9109L39.674 32.5486L43.6823 43.7228L32.3991 40.1029Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n","import React, { AriaAttributes } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { starIconHoverDesktop, starIconHoverMobile, starIconNormalDesktop, starIconNormalMobile } from './StarIcon';\nimport { AnalyticsId, HTMLButtonProps, LanguageLocales } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport { isMutableRefObject } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport interface FavoriteButtonProps extends HTMLButtonProps, AriaAttributes {\n /** Determines if the FavoriteButton is checked */\n checked: boolean;\n /** Gives a unique id to the button */\n id?: string;\n /** Function that is called when clicked */\n onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Resources for component */\n resources?: Partial<HNDesignsystemFavoriteButton>;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const FavoriteButton = React.forwardRef(function FavoriteButtonForwardedRef(\n props: FavoriteButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement>\n) {\n const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;\n\n const buttonWrapperClasses = classNames(styles.favoritebutton);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLButtonElement>(isMutableRefObject(ref) ? ref : null);\n const breakpoint = useBreakpoint();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFavoriteButton = {\n ...defaultResources,\n ...resources,\n ariaLabel: other['aria-label'] || resources?.ariaLabel || defaultResources.ariaLabel,\n };\n\n const isMobile = breakpoint <= Breakpoint.sm;\n\n const starIcon = ((): React.JSX.Element => {\n if (isMobile) {\n if (isHovered) {\n return starIconHoverMobile(checked, isActive);\n } else {\n return starIconNormalMobile(checked, isActive);\n }\n } else {\n if (isHovered) {\n return starIconHoverDesktop(checked, isActive);\n } else {\n return starIconNormalDesktop(checked, isActive);\n }\n }\n })();\n\n return (\n <button\n id={id}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FavoriteButton}\n className={buttonWrapperClasses}\n ref={refObject}\n tabIndex={tabIndex}\n role=\"switch\"\n aria-checked={checked}\n type=\"button\"\n aria-label={mergedResources.ariaLabel}\n {...other}\n >\n <svg focusable={false} overflow=\"visible\" role=\"presentation\" viewBox={isMobile ? '0 0 41 41' : '0 0 61 61'} {...other}>\n {starIcon}\n </svg>\n </button>\n );\n});\n\nFavoriteButton.displayName = 'Favori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