@helsenorge/designsystem-react 14.0.0 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/lib/AnchorLink.js +2 -2
  2. package/lib/AnchorLink.js.map +1 -1
  3. package/lib/Avatar.js +2 -2
  4. package/lib/Avatar.js.map +1 -1
  5. package/lib/Badge.js +2 -2
  6. package/lib/Badge.js.map +1 -1
  7. package/lib/Button.js +6 -6
  8. package/lib/Button.js.map +1 -1
  9. package/lib/CHANGELOG.md +245 -223
  10. package/lib/Checkbox.js +6 -6
  11. package/lib/Checkbox.js.map +1 -1
  12. package/lib/Close.js +3 -3
  13. package/lib/Close.js.map +1 -1
  14. package/lib/DictionaryTrigger.js +2 -2
  15. package/lib/DictionaryTrigger.js.map +1 -1
  16. package/lib/Drawer.js +13 -7
  17. package/lib/Drawer.js.map +1 -1
  18. package/lib/Duolist.js +5 -5
  19. package/lib/Duolist.js.map +1 -1
  20. package/lib/ElementHeader.js +9 -9
  21. package/lib/ElementHeader.js.map +1 -1
  22. package/lib/ElementHeaderText.js +4 -4
  23. package/lib/ElementHeaderText.js.map +1 -1
  24. package/lib/ErrorWrapper.js +2 -2
  25. package/lib/ErrorWrapper.js.map +1 -1
  26. package/lib/Expander.js +8 -8
  27. package/lib/Expander.js.map +1 -1
  28. package/lib/FormFieldTag.js +2 -2
  29. package/lib/FormFieldTag.js.map +1 -1
  30. package/lib/FormGroup.js +5 -5
  31. package/lib/FormGroup.js.map +1 -1
  32. package/lib/FormLayout.js +3 -3
  33. package/lib/FormLayout.js.map +1 -1
  34. package/lib/HelpDetails.js +3 -3
  35. package/lib/HelpDetails.js.map +1 -1
  36. package/lib/HelpTriggerIcon.js +2 -2
  37. package/lib/HelpTriggerIcon.js.map +1 -1
  38. package/lib/HelpTriggerStandalone.js +2 -2
  39. package/lib/HelpTriggerStandalone.js.map +1 -1
  40. package/lib/HighlightPanel.js +3 -3
  41. package/lib/HighlightPanel.js.map +1 -1
  42. package/lib/HorizontalScroll.js +4 -4
  43. package/lib/HorizontalScroll.js.map +1 -1
  44. package/lib/Icon.js +2 -2
  45. package/lib/Icon.js.map +1 -1
  46. package/lib/InfoTeaser.js +3 -3
  47. package/lib/InfoTeaser.js.map +1 -1
  48. package/lib/Input.js +4 -4
  49. package/lib/Input.js.map +1 -1
  50. package/lib/LazyIcon.js +2 -0
  51. package/lib/LazyIcon.js.map +1 -1
  52. package/lib/LinkList.js +5 -5
  53. package/lib/LinkList.js.map +1 -1
  54. package/lib/List.js +2 -2
  55. package/lib/List.js.map +1 -1
  56. package/lib/ListEditMode.js +4 -4
  57. package/lib/ListEditMode.js.map +1 -1
  58. package/lib/MaxCharacters.js +2 -2
  59. package/lib/MaxCharacters.js.map +1 -1
  60. package/lib/PanelTitle.js +2 -2
  61. package/lib/PanelTitle.js.map +1 -1
  62. package/lib/PopOver.js +2 -2
  63. package/lib/PopOver.js.map +1 -1
  64. package/lib/Select.js +4 -4
  65. package/lib/Select.js.map +1 -1
  66. package/lib/SingleSelectItem.js +3 -3
  67. package/lib/SingleSelectItem.js.map +1 -1
  68. package/lib/Slider.js +4 -4
  69. package/lib/Slider.js.map +1 -1
  70. package/lib/Spacer.js +2 -2
  71. package/lib/Spacer.js.map +1 -1
  72. package/lib/StatusDot.js +4 -4
  73. package/lib/StatusDot.js.map +1 -1
  74. package/lib/StatusDotList.js +2 -2
  75. package/lib/StatusDotList.js.map +1 -1
  76. package/lib/StepButtons.js +5 -5
  77. package/lib/StepButtons.js.map +1 -1
  78. package/lib/TabList.js +8 -8
  79. package/lib/TabList.js.map +1 -1
  80. package/lib/TabPanel.js +2 -2
  81. package/lib/TabPanel.js.map +1 -1
  82. package/lib/TableBody.js +2 -2
  83. package/lib/TableBody.js.map +1 -1
  84. package/lib/TableCell.js +2 -2
  85. package/lib/TableCell.js.map +1 -1
  86. package/lib/TableExpandedRow.js +4 -4
  87. package/lib/TableExpandedRow.js.map +1 -1
  88. package/lib/TableExpanderCell.js +2 -2
  89. package/lib/TableExpanderCell.js.map +1 -1
  90. package/lib/TableHead.js +2 -2
  91. package/lib/TableHead.js.map +1 -1
  92. package/lib/TableHeadCell.js +3 -3
  93. package/lib/TableHeadCell.js.map +1 -1
  94. package/lib/TableRow.js +3 -3
  95. package/lib/TableRow.js.map +1 -1
  96. package/lib/Textarea.js +4 -4
  97. package/lib/Textarea.js.map +1 -1
  98. package/lib/Title.js +2 -2
  99. package/lib/Title.js.map +1 -1
  100. package/lib/Toast.js +3 -3
  101. package/lib/Toast.js.map +1 -1
  102. package/lib/components/ArticleTeaser/index.js +4 -4
  103. package/lib/components/ArticleTeaser/index.js.map +1 -1
  104. package/lib/components/Chip/index.js +2 -2
  105. package/lib/components/Chip/index.js.map +1 -1
  106. package/lib/components/Dropdown/index.js +5 -5
  107. package/lib/components/Dropdown/index.js.map +1 -1
  108. package/lib/components/DropdownOld/index.js +3 -3
  109. package/lib/components/DropdownOld/index.js.map +1 -1
  110. package/lib/components/EmptyState/index.js +2 -2
  111. package/lib/components/EmptyState/index.js.map +1 -1
  112. package/lib/components/ExpanderHierarchy/index.js +7 -7
  113. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  114. package/lib/components/ExpanderList/index.js +6 -6
  115. package/lib/components/ExpanderList/index.js.map +1 -1
  116. package/lib/components/FavoriteButton/index.js +2 -2
  117. package/lib/components/FavoriteButton/index.js.map +1 -1
  118. package/lib/components/HelpBubble/index.js +3 -3
  119. package/lib/components/HelpBubble/index.js.map +1 -1
  120. package/lib/components/HelpPanel/index.js +2 -2
  121. package/lib/components/HelpPanel/index.js.map +1 -1
  122. package/lib/components/HelpTriggerInline/index.js +2 -2
  123. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  124. package/lib/components/Icons/AdditionalIconInformation.d.ts +8 -0
  125. package/lib/components/Icons/AdditionalIconInformation.js +8 -0
  126. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  127. package/lib/components/Icons/Filter.js +27 -9
  128. package/lib/components/Icons/Filter.js.map +1 -1
  129. package/lib/components/Icons/IconNames.d.ts +1 -1
  130. package/lib/components/Icons/IconNames.js +2 -0
  131. package/lib/components/Icons/IconNames.js.map +1 -1
  132. package/lib/components/Icons/MeasuringTape.d.ts +3 -0
  133. package/lib/components/Icons/MeasuringTape.js +8 -0
  134. package/lib/components/Icons/MeasuringTape.js.map +1 -0
  135. package/lib/components/Icons/Search.js +11 -1
  136. package/lib/components/Icons/Search.js.map +1 -1
  137. package/lib/components/Icons/Sort.d.ts +3 -0
  138. package/lib/components/Icons/Sort.js +48 -0
  139. package/lib/components/Icons/Sort.js.map +1 -0
  140. package/lib/components/Loader/index.js +4 -4
  141. package/lib/components/Loader/index.js.map +1 -1
  142. package/lib/components/Modal/index.js +9 -9
  143. package/lib/components/Modal/index.js.map +1 -1
  144. package/lib/components/NotificationPanel/index.js +6 -6
  145. package/lib/components/NotificationPanel/index.js.map +1 -1
  146. package/lib/components/Panel/index.js +12 -12
  147. package/lib/components/Panel/index.js.map +1 -1
  148. package/lib/components/PanelList/index.js +3 -3
  149. package/lib/components/PanelList/index.js.map +1 -1
  150. package/lib/components/PopMenu/index.js +3 -3
  151. package/lib/components/PopMenu/index.js.map +1 -1
  152. package/lib/components/Progressbar/index.js +2 -2
  153. package/lib/components/Progressbar/index.js.map +1 -1
  154. package/lib/components/PromoPanel/index.js +2 -2
  155. package/lib/components/PromoPanel/index.js.map +1 -1
  156. package/lib/components/ServiceMessage/index.js +5 -5
  157. package/lib/components/ServiceMessage/index.js.map +1 -1
  158. package/lib/components/SharingStatus/index.js +4 -4
  159. package/lib/components/SharingStatus/index.js.map +1 -1
  160. package/lib/components/Step/index.js +2 -2
  161. package/lib/components/Step/index.js.map +1 -1
  162. package/lib/components/Stepper/index.js +2 -2
  163. package/lib/components/Stepper/index.js.map +1 -1
  164. package/lib/components/StickyNote/index.js +12 -11
  165. package/lib/components/StickyNote/index.js.map +1 -1
  166. package/lib/components/Table/index.js +2 -2
  167. package/lib/components/Table/index.js.map +1 -1
  168. package/lib/components/Tabs/index.js +4 -4
  169. package/lib/components/Tabs/index.js.map +1 -1
  170. package/lib/components/Tag/index.js +2 -2
  171. package/lib/components/Tag/index.js.map +1 -1
  172. package/lib/components/Tile/index.js +6 -5
  173. package/lib/components/Tile/index.js.map +1 -1
  174. package/lib/components/Toggle/index.js +16 -16
  175. package/lib/components/Toggle/index.js.map +1 -1
  176. package/lib/components/Toggle/styles.module.scss +4 -4
  177. package/lib/components/Validation/index.js +2 -2
  178. package/lib/components/Validation/index.js.map +1 -1
  179. package/lib/declaration.d.ts +9 -0
  180. package/lib/global.d.ts +3 -0
  181. package/lib/resources/HN.Designsystem.Drawer.en-GB.json.d.ts +2 -1
  182. package/lib/resources/HN.Designsystem.Drawer.nb-NO.json.d.ts +2 -1
  183. package/lib/resources/Resources.d.ts +149 -0
  184. package/lib/scss/bootstrap/scss/mixins/_grid.scss +2 -1
  185. package/lib/types.d.ts +1 -0
  186. package/lib/utils2.js +7 -7
  187. package/lib/utils2.js.map +1 -1
  188. package/lib/utils3.js +5 -5
  189. package/lib/utils3.js.map +1 -1
  190. package/package.json +1 -1
  191. package/scss/bootstrap/scss/mixins/_grid.scss +2 -1
@@ -2,16 +2,17 @@ import { a as IconSize, n as AnalyticsId } from "../../constants2.js";
2
2
  import { t as usePseudoClasses } from "../../usePseudoClasses.js";
3
3
  import { n as mergeRefs } from "../../refs.js";
4
4
  import { t as Icon_default } from "../../Icon.js";
5
+ import { t as LazyIcon_default } from "../../LazyIcon.js";
5
6
  import { t as isComponent } from "../../component.js";
6
7
  import { n as useBreakpoint, t as Breakpoint } from "../../useBreakpoint.js";
7
- import classNames from "classnames";
8
+ import cn from "classnames";
8
9
  import React from "react";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  import tileStyles from "./styles.module.scss";
11
12
  var Title = (props) => {
12
13
  const { compact, children, className, htmlMarkup = "span", highlighted, ref } = props;
13
14
  return /* @__PURE__ */ jsx(htmlMarkup, {
14
- className: classNames(tileStyles["tile__title"], {
15
+ className: cn(tileStyles["tile__title"], {
15
16
  [tileStyles["tile__title--highlighted"]]: highlighted,
16
17
  [tileStyles["tile__title--compact"]]: compact
17
18
  }, className),
@@ -25,12 +26,12 @@ const Tile = (props) => {
25
26
  const { refObject, isHovered } = usePseudoClasses();
26
27
  const mobile = useBreakpoint() < Breakpoint.md;
27
28
  const compact = variant === "compact";
28
- const tileClasses = classNames(tileStyles.tile, {
29
+ const tileClasses = cn(tileStyles.tile, {
29
30
  [tileStyles["tile--fixed"]]: fixed,
30
31
  [tileStyles["tile--compact"]]: compact,
31
32
  [tileStyles["tile--highlighted"]]: highlighted
32
33
  }, className);
33
- const tileTitleWrapperClasses = classNames(tileStyles["title-wrapper"], { [tileStyles["title-wrapper--compact"]]: compact });
34
+ const tileTitleWrapperClasses = cn(tileStyles["title-wrapper"], { [tileStyles["title-wrapper--compact"]]: compact });
34
35
  return /* @__PURE__ */ jsxs("a", {
35
36
  ref: mergeRefs([ref, refObject]),
36
37
  href,
@@ -43,7 +44,7 @@ const Tile = (props) => {
43
44
  children: [
44
45
  /* @__PURE__ */ jsxs("div", {
45
46
  className: tileTitleWrapperClasses,
46
- children: [isComponent(icon, Icon_default) && React.cloneElement(icon, {
47
+ children: [(isComponent(icon, Icon_default) || isComponent(icon, LazyIcon_default)) && React.cloneElement(icon, {
47
48
  size: mobile ? IconSize.Small : IconSize.Medium,
48
49
  isHovered,
49
50
  color: highlighted ? "white" : "black"
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Title: React.FC<TileTitleProps>","Tile: TileCompound"],"sources":["../../../src/components/Tile/Tile.tsx","../../../src/components/Tile/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { TitleTags } from './../Title/Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { useBreakpoint, Breakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { isComponent } from '../../utils/component';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon, { IconSize, type IconProps } from '../Icon';\n\nimport tileStyles from './styles.module.scss';\n\nexport type TileVariants = 'normal' | 'compact';\n\ninterface TileProps extends Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick' | 'rel'> {\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /**\tSets the icon to be displayed inside the tile. */\n icon: React.ReactElement;\n /**\tSets the title to be displayed inside the tile. */\n title: React.ReactElement;\n /** Toggles the highlighted style of the tile. */\n highlighted?: boolean;\n /** Sets the description to be displayed inside the tile. */\n description?: string;\n /** Sets a fixed max and min width for the tile. */\n fixed?: boolean;\n /** Sets the visual variant of the component */\n variant?: TileVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLAnchorElement | null>;\n}\n\ninterface TileTitleProps {\n children: React.ReactNode;\n className?: string;\n htmlMarkup?: TitleTags;\n highlighted?: boolean;\n compact?: boolean;\n /** Ref passed to the title element */\n ref?: React.Ref<HTMLHeadingElement | null>;\n}\n\nexport interface TileCompound extends React.FC<TileProps> {\n Title: React.FC<TileTitleProps>;\n}\n\nconst Title: React.FC<TileTitleProps> = props => {\n const { compact, children, className, htmlMarkup = 'span', highlighted, ref } = props;\n const titleClasses = classNames(\n tileStyles['tile__title'],\n {\n [tileStyles['tile__title--highlighted']]: highlighted,\n [tileStyles['tile__title--compact']]: compact,\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={titleClasses} ref={ref}>\n {children}\n </CustomTag>\n );\n};\n\nTitle.displayName = 'Title';\n\nexport const Tile: TileCompound = props => {\n const {\n children,\n icon,\n title,\n className = '',\n description,\n fixed = false,\n highlighted = false,\n testId,\n target,\n rel,\n variant = 'normal',\n href,\n onClick,\n ref,\n } = props;\n const { refObject, isHovered } = usePseudoClasses<HTMLAnchorElement>();\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < Breakpoint.md;\n const compact = variant === 'compact';\n const tileClasses = classNames(\n tileStyles.tile,\n {\n [tileStyles['tile--fixed']]: fixed,\n [tileStyles['tile--compact']]: compact,\n [tileStyles['tile--highlighted']]: highlighted,\n },\n className\n );\n const tileTitleWrapperClasses = classNames(tileStyles['title-wrapper'], {\n [tileStyles['title-wrapper--compact']]: compact,\n });\n\n return (\n <a\n ref={mergeRefs([ref, refObject])}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : rel}\n className={tileClasses}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tile}\n onClick={onClick}\n >\n <div className={tileTitleWrapperClasses}>\n {isComponent<IconProps>(icon, Icon) &&\n React.cloneElement(icon, { size: mobile ? IconSize.Small : IconSize.Medium, isHovered, color: highlighted ? 'white' : 'black' })}\n {isComponent<TileTitleProps>(title, Tile.Title) && React.cloneElement(title, { highlighted: highlighted, compact: compact })}\n </div>\n {!compact && !mobile && <p className={tileStyles.tile__description}>{description}</p>}\n {children && <div className={tileStyles.tile__children}>{children}</div>}\n </a>\n );\n};\n\nTile.displayName = 'Tile';\nTile.Title = Title;\n\nexport default Tile;\n","import Tile from './Tile';\nexport * from './Tile';\nexport default Tile;\n"],"mappings":";;;;;;;;;;AAqDA,IAAMA,SAAkC,UAAS;CAC/C,MAAM,EAAE,SAAS,UAAU,WAAW,aAAa,QAAQ,aAAa,QAAQ;AAWhF,QACE,oBAHgB,YAGf;EAAU,WAXQ,WACnB,WAAW,gBACX;IACG,WAAW,8BAA8B;IACzC,WAAW,0BAA0B;GACvC,EACD,UACD;EAI0C;EACtC;GACS;;AAIhB,MAAM,cAAc;AAEpB,MAAaC,QAAqB,UAAS;CACzC,MAAM,EACJ,UACA,MACA,OACA,YAAY,IACZ,aACA,QAAQ,OACR,cAAc,OACd,QACA,QACA,KACA,UAAU,UACV,MACA,SACA,QACE;CACJ,MAAM,EAAE,WAAW,cAAc,kBAAqC;CAEtE,MAAM,SADa,eAAe,GACN,WAAW;CACvC,MAAM,UAAU,YAAY;CAC5B,MAAM,cAAc,WAClB,WAAW,MACX;GACG,WAAW,iBAAiB;GAC5B,WAAW,mBAAmB;GAC9B,WAAW,uBAAuB;EACpC,EACD,UACD;CACD,MAAM,0BAA0B,WAAW,WAAW,kBAAkB,GACrE,WAAW,4BAA4B,SACzC,CAAC;AAEF,QACE,qBAAC,KAAA;EACC,KAAK,UAAU,CAAC,KAAK,UAAU,CAAC;EAC1B;EACE;EACR,KAAK,WAAW,WAAW,wBAAwB;EACnD,WAAW;EACX,eAAa;EACb,oBAAkB,YAAY;EACrB;;GAET,qBAAC,OAAA;IAAI,WAAW;eACb,YAAuB,MAAM,aAAK,IACjC,MAAM,aAAa,MAAM;KAAE,MAAM,SAAS,SAAS,QAAQ,SAAS;KAAQ;KAAW,OAAO,cAAc,UAAU;KAAS,CAAC,EACjI,YAA4B,OAAO,KAAK,MAAM,IAAI,MAAM,aAAa,OAAO;KAAe;KAAsB;KAAS,CAAC,CAAA;KACxH;GACL,CAAC,WAAW,CAAC,UAAU,oBAAC,KAAA;IAAE,WAAW,WAAW;cAAoB;KAAgB;GACpF,YAAY,oBAAC,OAAA;IAAI,WAAW,WAAW;IAAiB;KAAe;;GACtE;;AAIR,KAAK,cAAc;AACnB,KAAK,QAAQ;ACjIb,IAAA,eDmIe"}
1
+ {"version":3,"file":"index.js","names":["Title: React.FC<TileTitleProps>","Tile: TileCompound"],"sources":["../../../src/components/Tile/Tile.tsx","../../../src/components/Tile/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { TitleTags } from './../Title/Title';\n\nimport { AnalyticsId } from '../../constants';\nimport { useBreakpoint, Breakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { isComponent } from '../../utils/component';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon, { IconSize, type BaseIconProps, type IconProps } from '../Icon';\nimport LazyIcon from '../LazyIcon';\n\nimport tileStyles from './styles.module.scss';\n\nexport type TileVariants = 'normal' | 'compact';\n\ninterface TileProps extends Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick' | 'rel'> {\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /**\tSets the icon to be displayed inside the tile. */\n icon: React.ReactElement;\n /**\tSets the title to be displayed inside the tile. */\n title: React.ReactElement;\n /** Toggles the highlighted style of the tile. */\n highlighted?: boolean;\n /** Sets the description to be displayed inside the tile. */\n description?: string;\n /** Sets a fixed max and min width for the tile. */\n fixed?: boolean;\n /** Sets the visual variant of the component */\n variant?: TileVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLAnchorElement | null>;\n}\n\ninterface TileTitleProps {\n children: React.ReactNode;\n className?: string;\n htmlMarkup?: TitleTags;\n highlighted?: boolean;\n compact?: boolean;\n /** Ref passed to the title element */\n ref?: React.Ref<HTMLHeadingElement | null>;\n}\n\nexport interface TileCompound extends React.FC<TileProps> {\n Title: React.FC<TileTitleProps>;\n}\n\nconst Title: React.FC<TileTitleProps> = props => {\n const { compact, children, className, htmlMarkup = 'span', highlighted, ref } = props;\n const titleClasses = classNames(\n tileStyles['tile__title'],\n {\n [tileStyles['tile__title--highlighted']]: highlighted,\n [tileStyles['tile__title--compact']]: compact,\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={titleClasses} ref={ref}>\n {children}\n </CustomTag>\n );\n};\n\nTitle.displayName = 'Title';\n\nexport const Tile: TileCompound = props => {\n const {\n children,\n icon,\n title,\n className = '',\n description,\n fixed = false,\n highlighted = false,\n testId,\n target,\n rel,\n variant = 'normal',\n href,\n onClick,\n ref,\n } = props;\n const { refObject, isHovered } = usePseudoClasses<HTMLAnchorElement>();\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < Breakpoint.md;\n const compact = variant === 'compact';\n const tileClasses = classNames(\n tileStyles.tile,\n {\n [tileStyles['tile--fixed']]: fixed,\n [tileStyles['tile--compact']]: compact,\n [tileStyles['tile--highlighted']]: highlighted,\n },\n className\n );\n const tileTitleWrapperClasses = classNames(tileStyles['title-wrapper'], {\n [tileStyles['title-wrapper--compact']]: compact,\n });\n\n return (\n <a\n ref={mergeRefs([ref, refObject])}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : rel}\n className={tileClasses}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tile}\n onClick={onClick}\n >\n <div className={tileTitleWrapperClasses}>\n {(isComponent<IconProps>(icon, Icon) || isComponent<LazyIconProps>(icon, LazyIcon)) &&\n React.cloneElement(icon as React.ReactElement<BaseIconProps>, {\n size: mobile ? IconSize.Small : IconSize.Medium,\n isHovered,\n color: highlighted ? 'white' : 'black',\n })}\n {isComponent<TileTitleProps>(title, Tile.Title) && React.cloneElement(title, { highlighted: highlighted, compact: compact })}\n </div>\n {!compact && !mobile && <p className={tileStyles.tile__description}>{description}</p>}\n {children && <div className={tileStyles.tile__children}>{children}</div>}\n </a>\n );\n};\n\nTile.displayName = 'Tile';\nTile.Title = Title;\n\nexport default Tile;\n","import Tile from './Tile';\nexport * from './Tile';\nexport default Tile;\n"],"mappings":";;;;;;;;;;;AAuDA,IAAMA,SAAkC,UAAS;CAC/C,MAAM,EAAE,SAAS,UAAU,WAAW,aAAa,QAAQ,aAAa,QAAQ;AAWhF,QACE,oBAHgB,YAGf;EAAU,WAXQ,GACnB,WAAW,gBACX;IACG,WAAW,8BAA8B;IACzC,WAAW,0BAA0B;GACvC,EACD,UACD;EAI0C;EACtC;GACS;;AAIhB,MAAM,cAAc;AAEpB,MAAaC,QAAqB,UAAS;CACzC,MAAM,EACJ,UACA,MACA,OACA,YAAY,IACZ,aACA,QAAQ,OACR,cAAc,OACd,QACA,QACA,KACA,UAAU,UACV,MACA,SACA,QACE;CACJ,MAAM,EAAE,WAAW,cAAc,kBAAqC;CAEtE,MAAM,SADa,eAAe,GACN,WAAW;CACvC,MAAM,UAAU,YAAY;CAC5B,MAAM,cAAc,GAClB,WAAW,MACX;GACG,WAAW,iBAAiB;GAC5B,WAAW,mBAAmB;GAC9B,WAAW,uBAAuB;EACpC,EACD,UACD;CACD,MAAM,0BAA0B,GAAW,WAAW,kBAAkB,GACrE,WAAW,4BAA4B,SACzC,CAAC;AAEF,QACE,qBAAC,KAAA;EACC,KAAK,UAAU,CAAC,KAAK,UAAU,CAAC;EAC1B;EACE;EACR,KAAK,WAAW,WAAW,wBAAwB;EACnD,WAAW;EACX,eAAa;EACb,oBAAkB,YAAY;EACrB;;GAET,qBAAC,OAAA;IAAI,WAAW;gBACZ,YAAuB,MAAM,aAAK,IAAI,YAA2B,MAAM,iBAAS,KAChF,MAAM,aAAa,MAA2C;KAC5D,MAAM,SAAS,SAAS,QAAQ,SAAS;KACzC;KACA,OAAO,cAAc,UAAU;KAChC,CAAC,EACH,YAA4B,OAAO,KAAK,MAAM,IAAI,MAAM,aAAa,OAAO;KAAe;KAAsB;KAAS,CAAC,CAAA;KACxH;GACL,CAAC,WAAW,CAAC,UAAU,oBAAC,KAAA;IAAE,WAAW,WAAW;cAAoB;KAAgB;GACpF,YAAY,oBAAC,OAAA;IAAI,WAAW,WAAW;IAAiB;KAAe;;GACtE;;AAIR,KAAK,cAAc;AACnB,KAAK,QAAQ;ACvIb,IAAA,eDyIe"}
@@ -1,6 +1,6 @@
1
1
  import { n as AnalyticsId } from "../../constants2.js";
2
2
  import { t as usePseudoClasses } from "../../usePseudoClasses.js";
3
- import classNames from "classnames";
3
+ import cn from "classnames";
4
4
  import React, { useEffect, useId, useState } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { useAnimate } from "motion/react";
@@ -57,7 +57,7 @@ var Toggle = ({ checked = false, label, onChange, onColor = ToggleOnColor.onwhit
57
57
  duration: .2,
58
58
  ease: "easeInOut"
59
59
  });
60
- animate(toggleDotRef.current, { x: showHoveredStyling ? 9 : checkedState ? 18 : 0 }, {
60
+ animate(toggleDotRef.current, { x: checkedState ? 16 : 0 }, {
61
61
  duration: .2,
62
62
  ease: "easeInOut"
63
63
  });
@@ -75,22 +75,22 @@ var Toggle = ({ checked = false, label, onChange, onColor = ToggleOnColor.onwhit
75
75
  setShowToggleAnimation(true);
76
76
  onChange?.(event);
77
77
  };
78
- const toggleContainerClassNames = classNames(styles["toggle-container"], {
78
+ const toggleContainerClassNames = cn(styles["toggle-container"], {
79
79
  [styles["toggle-container--position-right"]]: togglePosition === TogglePosition.right,
80
80
  [styles["toggle-container--with-status"]]: statusText !== void 0 && statusText !== null
81
81
  });
82
- const subLabelClassNames = classNames(styles["toggle-container__sublabel"]);
83
- const statusTextClassNames = classNames(styles["toggle-container__status"], { [styles["toggle-container__status--checked"]]: checkedState });
84
- const toggleClassNames = classNames(styles["toggle-container__toggle"], {
82
+ const subLabelClassNames = cn(styles["toggle-container__sublabel"]);
83
+ const statusTextClassNames = cn(styles["toggle-container__status"], { [styles["toggle-container__status--checked"]]: checkedState });
84
+ const toggleClassNames = cn(styles["toggle-container__toggle"], {
85
85
  [styles["toggle-container__toggle--ignore-hover"]]: showToggleAnimation,
86
86
  [styles["toggle-container__toggle--on-white"]]: onColor === ToggleOnColor.onwhite
87
87
  });
88
- const toggleDotClassNames = classNames(styles["toggle-container__toggle__dot"], { [styles["toggle-container__toggle__dot--ignore-hover"]]: showToggleAnimation });
88
+ const toggleDotClassNames = cn(styles["toggle-container__toggle__dot"], { [styles["toggle-container__toggle__dot--ignore-hover"]]: showToggleAnimation });
89
89
  const renderToggle = () => /* @__PURE__ */ jsxs("div", {
90
90
  className: styles["toggle-container__outer-toggle"],
91
91
  children: [/* @__PURE__ */ jsxs("label", {
92
92
  ref: refObject,
93
- className: classNames(styles["toggle-container__toggle-group"]),
93
+ className: cn(styles["toggle-container__toggle-group"]),
94
94
  children: [/* @__PURE__ */ jsx("input", {
95
95
  id: inputId,
96
96
  type: "checkbox",
@@ -110,15 +110,15 @@ var Toggle = ({ checked = false, label, onChange, onColor = ToggleOnColor.onwhit
110
110
  className: toggleDotClassNames,
111
111
  "aria-hidden": "true",
112
112
  children: /* @__PURE__ */ jsx("svg", {
113
- width: "17",
114
- height: "13",
115
- viewBox: "0 0 17 13",
113
+ width: "12",
114
+ height: "12",
115
+ viewBox: "0 0 12 12",
116
+ fill: "none",
116
117
  xmlns: "http://www.w3.org/2000/svg",
117
118
  className: styles["toggle-container__toggle__dot__icon"],
118
119
  children: /* @__PURE__ */ jsx("path", {
119
- d: "M15 2L6.80839 10.548L2 5.53145",
120
- fill: "none",
121
- strokeWidth: "3"
120
+ d: "M11 2.65247L4.69877 9.34741L1 5.41836",
121
+ strokeWidth: "2.2"
122
122
  })
123
123
  })
124
124
  })
@@ -134,10 +134,10 @@ var Toggle = ({ checked = false, label, onChange, onColor = ToggleOnColor.onwhit
134
134
  className: styles["toggle-container__outer-label"],
135
135
  children: [/* @__PURE__ */ jsx("span", {
136
136
  id: labelId,
137
- className: classNames(styles["toggle-container__label"]),
137
+ className: cn(styles["toggle-container__label"]),
138
138
  children: label.map((labelText) => {
139
139
  return /* @__PURE__ */ jsx("span", {
140
- className: classNames({ [styles["toggle-container__label__text--subdued"]]: labelText.type === "subdued" }),
140
+ className: cn({ [styles["toggle-container__label__text--subdued"]]: labelText.type === "subdued" }),
141
141
  children: labelText.text
142
142
  }, labelId + labelText.text);
143
143
  })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Toggle: React.FC<ToggleProps>"],"sources":["../../../src/components/Toggle/constants.ts","../../../src/components/Toggle/Toggle.tsx","../../../src/components/Toggle/index.ts"],"sourcesContent":["export enum TogglePosition {\n left = 'left',\n right = 'right',\n}\n\nexport enum ToggleOnColor {\n onwhite = 'onwhite',\n onneutral = 'onneutral',\n onblueberry = 'onblueberry',\n}\n","import React, { useState, useEffect, useId } from 'react';\n\nimport classNames from 'classnames';\nimport { useAnimate } from 'motion/react';\n\nimport { ToggleOnColor, TogglePosition } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\n\nimport styles from './styles.module.scss';\n\nimport '../../scss/supernova/styles/colors.css';\n\nexport type LabelText = {\n text: string;\n type?: 'subdued' | 'normal';\n};\n\nexport type StatusTextType = {\n checked: string;\n unchecked: string;\n};\n\nexport interface ToggleProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /** Determines if the Toggle is checked */\n checked?: boolean;\n /** Sets the label of the Toggle */\n label: LabelText[];\n /** Defines the color of the toggle */\n onColor?: keyof typeof ToggleOnColor;\n /** A text that is shown under the Toggle switch */\n statusText?: StatusTextType;\n /** Sets the sublabel of the Toggle */\n subLabel?: string;\n /** Sets the position of the toggle relative to the label */\n togglePosition?: keyof typeof TogglePosition;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst Toggle: React.FC<ToggleProps> = ({\n checked = false,\n label,\n onChange,\n onColor = ToggleOnColor.onwhite,\n statusText,\n subLabel,\n togglePosition = TogglePosition.left,\n testId,\n}: ToggleProps) => {\n const [checkedState, setCheckedState] = useState(checked);\n const [showToggleAnimation, setShowToggleAnimation] = useState(false);\n const [scope, animate] = useAnimate();\n const baseId = useId();\n const toggleId = 'toggle-' + baseId;\n const inputId = 'input-' + baseId;\n const labelId = 'label-' + baseId;\n const subLabelId = 'sublabel-' + baseId;\n const toggleRef = React.useRef<HTMLSpanElement>(null);\n const toggleDotRef = React.useRef<HTMLSpanElement>(null);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLLabelElement>(scope);\n const showHoveredStyling = isHovered && !showToggleAnimation;\n const isOnWhite = onColor === ToggleOnColor.onwhite;\n\n const getBackgroundColor = (): string => {\n if (checkedState && isActive) {\n return 'var(--core-color-blueberry-800)';\n } else if (checkedState) {\n return showHoveredStyling ? 'var(--color-action-graphics-onlight-hover)' : 'var(--color-action-graphics-onlight)';\n } else if (isOnWhite && isActive) {\n return 'var(--core-color-neutral-400)';\n } else if (isOnWhite) {\n return showHoveredStyling ? 'var(--core-color-neutral-200)' : 'var(--core-color-neutral-50)';\n } else if (isActive) {\n return 'var(--core-color-neutral-200)';\n } else {\n return showHoveredStyling ? 'var(--core-color-neutral-50)' : 'var(--core-color-white)';\n }\n };\n\n useEffect(() => {\n if (showToggleAnimation) {\n const timer = setTimeout(() => setShowToggleAnimation(false), 300);\n return (): void => clearTimeout(timer);\n }\n }, [showToggleAnimation]);\n\n useEffect(() => {\n setCheckedState(checked);\n }, [checked]);\n\n useEffect(() => {\n if (!toggleRef.current || !toggleDotRef.current) return;\n animate(toggleRef.current, { background: getBackgroundColor() }, { duration: 0.2, ease: 'easeInOut' });\n animate(\n toggleDotRef.current,\n { background: checkedState ? 'var(--color-action-graphics-ondark)' : 'var(--core-color-neutral-700)' },\n { duration: 0.2, ease: 'easeInOut' }\n );\n animate(toggleDotRef.current, { x: showHoveredStyling ? 9 : checkedState ? 18 : 0 }, { duration: 0.2, ease: 'easeInOut' });\n animate('svg', { opacity: checkedState ? 1 : 0 }, { duration: 0.2, ease: 'easeInOut' });\n }, [checkedState, showHoveredStyling, isActive]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setCheckedState(event.target.checked);\n setShowToggleAnimation(true);\n onChange?.(event);\n };\n\n const toggleContainerClassNames = classNames(styles['toggle-container'], {\n [styles['toggle-container--position-right']]: togglePosition === TogglePosition.right,\n [styles['toggle-container--with-status']]: statusText !== undefined && statusText !== null,\n });\n\n const subLabelClassNames = classNames(styles['toggle-container__sublabel']);\n\n const statusTextClassNames = classNames(styles['toggle-container__status'], {\n [styles['toggle-container__status--checked']]: checkedState,\n });\n\n const toggleClassNames = classNames(styles['toggle-container__toggle'], {\n [styles['toggle-container__toggle--ignore-hover']]: showToggleAnimation,\n [styles['toggle-container__toggle--on-white']]: onColor === ToggleOnColor.onwhite,\n });\n\n const toggleDotClassNames = classNames(styles['toggle-container__toggle__dot'], {\n [styles['toggle-container__toggle__dot--ignore-hover']]: showToggleAnimation,\n });\n\n const renderToggle = (): React.ReactElement => (\n <div className={styles['toggle-container__outer-toggle']}>\n <label ref={refObject} className={classNames(styles['toggle-container__toggle-group'])}>\n <input\n id={inputId}\n type=\"checkbox\"\n checked={checkedState}\n onChange={handleChange}\n className={styles['toggle-container__input']}\n aria-label={label.map(l => l.text).join(' ')}\n aria-describedby={[subLabel ? subLabelId : null, statusText ? toggleId + '-status' : null].filter(Boolean).join(' ') || undefined}\n role=\"switch\"\n />\n <span id={toggleId} ref={toggleRef} className={toggleClassNames} aria-hidden=\"true\">\n <span ref={toggleDotRef} className={toggleDotClassNames} aria-hidden=\"true\">\n <svg\n width=\"17\"\n height=\"13\"\n viewBox=\"0 0 17 13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={styles['toggle-container__toggle__dot__icon']}\n >\n <path d=\"M15 2L6.80839 10.548L2 5.53145\" fill=\"none\" strokeWidth=\"3\" />\n </svg>\n </span>\n </span>\n </label>\n {statusText && (\n <span className={statusTextClassNames} id={toggleId + '-status'}>\n {checkedState ? statusText.checked : statusText.unchecked}\n </span>\n )}\n </div>\n );\n\n const renderLabelText = (): React.ReactElement => {\n return (\n <div className={styles['toggle-container__outer-label']}>\n <span id={labelId} className={classNames(styles['toggle-container__label'])}>\n {label.map(labelText => {\n const labelClassNames = classNames({\n [styles['toggle-container__label__text--subdued']]: labelText.type === 'subdued',\n });\n\n return (\n <span key={labelId + labelText.text} className={labelClassNames}>\n {labelText.text}\n </span>\n );\n })}\n </span>\n {subLabel && (\n <div id={subLabelId} className={subLabelClassNames}>\n {subLabel}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div className={toggleContainerClassNames} data-testid={testId} data-analyticsid={AnalyticsId.Toggle}>\n {togglePosition === TogglePosition.left && (\n <>\n {renderToggle()}\n {renderLabelText()}\n </>\n )}\n {togglePosition === TogglePosition.right && (\n <>\n {renderLabelText()}\n {renderToggle()}\n </>\n )}\n </div>\n );\n};\n\nexport default Toggle;\n","import Toggle from './Toggle';\nexport { TogglePosition, ToggleOnColor } from './constants';\nexport * from './Toggle';\nexport default Toggle;\n"],"mappings":";;;;;;;AAAA,IAAY,iBAAA,yBAAA,kBAAL;AACL,kBAAA,UAAA;AACA,kBAAA,WAAA;;;AAGF,IAAY,gBAAA,yBAAA,iBAAL;AACL,iBAAA,aAAA;AACA,iBAAA,eAAA;AACA,iBAAA,iBAAA;;;ACgCF,IAAMA,UAAiC,EACrC,UAAU,OACV,OACA,UACA,UAAU,cAAc,SACxB,YACA,UACA,iBAAiB,eAAe,MAChC,aACiB;CACjB,MAAM,CAAC,cAAc,mBAAmB,SAAS,QAAQ;CACzD,MAAM,CAAC,qBAAqB,0BAA0B,SAAS,MAAM;CACrE,MAAM,CAAC,OAAO,WAAW,YAAY;CACrC,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,WAAW;CAC3B,MAAM,UAAU,WAAW;CAC3B,MAAM,aAAa,cAAc;CACjC,MAAM,YAAY,MAAM,OAAwB,KAAK;CACrD,MAAM,eAAe,MAAM,OAAwB,KAAK;CACxD,MAAM,EAAE,WAAW,WAAW,aAAa,iBAAmC,MAAM;CACpF,MAAM,qBAAqB,aAAa,CAAC;CACzC,MAAM,YAAY,YAAY,cAAc;CAE5C,MAAM,2BAAmC;AACvC,MAAI,gBAAgB,SAClB,QAAO;WACE,aACT,QAAO,qBAAqB,+CAA+C;WAClE,aAAa,SACtB,QAAO;WACE,UACT,QAAO,qBAAqB,kCAAkC;WACrD,SACT,QAAO;MAEP,QAAO,qBAAqB,iCAAiC;;AAIjE,iBAAgB;AACd,MAAI,qBAAqB;GACvB,MAAM,QAAQ,iBAAiB,uBAAuB,MAAM,EAAE,IAAI;AAClE,gBAAmB,aAAa,MAAM;;IAEvC,CAAC,oBAAoB,CAAC;AAEzB,iBAAgB;AACd,kBAAgB,QAAQ;IACvB,CAAC,QAAQ,CAAC;AAEb,iBAAgB;AACd,MAAI,CAAC,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["Toggle: React.FC<ToggleProps>"],"sources":["../../../src/components/Toggle/constants.ts","../../../src/components/Toggle/Toggle.tsx","../../../src/components/Toggle/index.ts"],"sourcesContent":["export enum TogglePosition {\n left = 'left',\n right = 'right',\n}\n\nexport enum ToggleOnColor {\n onwhite = 'onwhite',\n onneutral = 'onneutral',\n onblueberry = 'onblueberry',\n}\n","import React, { useState, useEffect, useId } from 'react';\n\nimport classNames from 'classnames';\nimport { useAnimate } from 'motion/react';\n\nimport { ToggleOnColor, TogglePosition } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\n\nimport styles from './styles.module.scss';\n\nimport '../../scss/supernova/styles/colors.css';\n\nexport type LabelText = {\n text: string;\n type?: 'subdued' | 'normal';\n};\n\nexport type StatusTextType = {\n checked: string;\n unchecked: string;\n};\n\nexport interface ToggleProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {\n /** Determines if the Toggle is checked */\n checked?: boolean;\n /** Sets the label of the Toggle */\n label: LabelText[];\n /** Defines the color of the toggle */\n onColor?: keyof typeof ToggleOnColor;\n /** A text that is shown under the Toggle switch */\n statusText?: StatusTextType;\n /** Sets the sublabel of the Toggle */\n subLabel?: string;\n /** Sets the position of the toggle relative to the label */\n togglePosition?: keyof typeof TogglePosition;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst Toggle: React.FC<ToggleProps> = ({\n checked = false,\n label,\n onChange,\n onColor = ToggleOnColor.onwhite,\n statusText,\n subLabel,\n togglePosition = TogglePosition.left,\n testId,\n}: ToggleProps) => {\n const [checkedState, setCheckedState] = useState(checked);\n const [showToggleAnimation, setShowToggleAnimation] = useState(false);\n const [scope, animate] = useAnimate();\n const baseId = useId();\n const toggleId = 'toggle-' + baseId;\n const inputId = 'input-' + baseId;\n const labelId = 'label-' + baseId;\n const subLabelId = 'sublabel-' + baseId;\n const toggleRef = React.useRef<HTMLSpanElement>(null);\n const toggleDotRef = React.useRef<HTMLSpanElement>(null);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLLabelElement>(scope);\n const showHoveredStyling = isHovered && !showToggleAnimation;\n const isOnWhite = onColor === ToggleOnColor.onwhite;\n\n const getBackgroundColor = (): string => {\n if (checkedState && isActive) {\n return 'var(--core-color-blueberry-800)';\n } else if (checkedState) {\n return showHoveredStyling ? 'var(--color-action-graphics-onlight-hover)' : 'var(--color-action-graphics-onlight)';\n } else if (isOnWhite && isActive) {\n return 'var(--core-color-neutral-400)';\n } else if (isOnWhite) {\n return showHoveredStyling ? 'var(--core-color-neutral-200)' : 'var(--core-color-neutral-50)';\n } else if (isActive) {\n return 'var(--core-color-neutral-200)';\n } else {\n return showHoveredStyling ? 'var(--core-color-neutral-50)' : 'var(--core-color-white)';\n }\n };\n\n useEffect(() => {\n if (showToggleAnimation) {\n const timer = setTimeout(() => setShowToggleAnimation(false), 300);\n return (): void => clearTimeout(timer);\n }\n }, [showToggleAnimation]);\n\n useEffect(() => {\n setCheckedState(checked);\n }, [checked]);\n\n useEffect(() => {\n if (!toggleRef.current || !toggleDotRef.current) return;\n animate(toggleRef.current, { background: getBackgroundColor() }, { duration: 0.2, ease: 'easeInOut' });\n animate(\n toggleDotRef.current,\n { background: checkedState ? 'var(--color-action-graphics-ondark)' : 'var(--core-color-neutral-700)' },\n { duration: 0.2, ease: 'easeInOut' }\n );\n animate(toggleDotRef.current, { x: checkedState ? 16 : 0 }, { duration: 0.2, ease: 'easeInOut' });\n animate('svg', { opacity: checkedState ? 1 : 0 }, { duration: 0.2, ease: 'easeInOut' });\n }, [checkedState, showHoveredStyling, isActive]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setCheckedState(event.target.checked);\n setShowToggleAnimation(true);\n onChange?.(event);\n };\n\n const toggleContainerClassNames = classNames(styles['toggle-container'], {\n [styles['toggle-container--position-right']]: togglePosition === TogglePosition.right,\n [styles['toggle-container--with-status']]: statusText !== undefined && statusText !== null,\n });\n\n const subLabelClassNames = classNames(styles['toggle-container__sublabel']);\n\n const statusTextClassNames = classNames(styles['toggle-container__status'], {\n [styles['toggle-container__status--checked']]: checkedState,\n });\n\n const toggleClassNames = classNames(styles['toggle-container__toggle'], {\n [styles['toggle-container__toggle--ignore-hover']]: showToggleAnimation,\n [styles['toggle-container__toggle--on-white']]: onColor === ToggleOnColor.onwhite,\n });\n\n const toggleDotClassNames = classNames(styles['toggle-container__toggle__dot'], {\n [styles['toggle-container__toggle__dot--ignore-hover']]: showToggleAnimation,\n });\n\n const renderToggle = (): React.ReactElement => (\n <div className={styles['toggle-container__outer-toggle']}>\n <label ref={refObject} className={classNames(styles['toggle-container__toggle-group'])}>\n <input\n id={inputId}\n type=\"checkbox\"\n checked={checkedState}\n onChange={handleChange}\n className={styles['toggle-container__input']}\n aria-label={label.map(l => l.text).join(' ')}\n aria-describedby={[subLabel ? subLabelId : null, statusText ? toggleId + '-status' : null].filter(Boolean).join(' ') || undefined}\n role=\"switch\"\n />\n <span id={toggleId} ref={toggleRef} className={toggleClassNames} aria-hidden=\"true\">\n <span ref={toggleDotRef} className={toggleDotClassNames} aria-hidden=\"true\">\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={styles['toggle-container__toggle__dot__icon']}\n >\n <path d=\"M11 2.65247L4.69877 9.34741L1 5.41836\" strokeWidth=\"2.2\" />\n </svg>\n </span>\n </span>\n </label>\n {statusText && (\n <span className={statusTextClassNames} id={toggleId + '-status'}>\n {checkedState ? statusText.checked : statusText.unchecked}\n </span>\n )}\n </div>\n );\n\n const renderLabelText = (): React.ReactElement => {\n return (\n <div className={styles['toggle-container__outer-label']}>\n <span id={labelId} className={classNames(styles['toggle-container__label'])}>\n {label.map(labelText => {\n const labelClassNames = classNames({\n [styles['toggle-container__label__text--subdued']]: labelText.type === 'subdued',\n });\n\n return (\n <span key={labelId + labelText.text} className={labelClassNames}>\n {labelText.text}\n </span>\n );\n })}\n </span>\n {subLabel && (\n <div id={subLabelId} className={subLabelClassNames}>\n {subLabel}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div className={toggleContainerClassNames} data-testid={testId} data-analyticsid={AnalyticsId.Toggle}>\n {togglePosition === TogglePosition.left && (\n <>\n {renderToggle()}\n {renderLabelText()}\n </>\n )}\n {togglePosition === TogglePosition.right && (\n <>\n {renderLabelText()}\n {renderToggle()}\n </>\n )}\n </div>\n );\n};\n\nexport default Toggle;\n","import Toggle from './Toggle';\nexport { TogglePosition, ToggleOnColor } from './constants';\nexport * from './Toggle';\nexport default Toggle;\n"],"mappings":";;;;;;;AAAA,IAAY,iBAAA,yBAAA,kBAAL;AACL,kBAAA,UAAA;AACA,kBAAA,WAAA;;;AAGF,IAAY,gBAAA,yBAAA,iBAAL;AACL,iBAAA,aAAA;AACA,iBAAA,eAAA;AACA,iBAAA,iBAAA;;;ACgCF,IAAMA,UAAiC,EACrC,UAAU,OACV,OACA,UACA,UAAU,cAAc,SACxB,YACA,UACA,iBAAiB,eAAe,MAChC,aACiB;CACjB,MAAM,CAAC,cAAc,mBAAmB,SAAS,QAAQ;CACzD,MAAM,CAAC,qBAAqB,0BAA0B,SAAS,MAAM;CACrE,MAAM,CAAC,OAAO,WAAW,YAAY;CACrC,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,WAAW;CAC3B,MAAM,UAAU,WAAW;CAC3B,MAAM,aAAa,cAAc;CACjC,MAAM,YAAY,MAAM,OAAwB,KAAK;CACrD,MAAM,eAAe,MAAM,OAAwB,KAAK;CACxD,MAAM,EAAE,WAAW,WAAW,aAAa,iBAAmC,MAAM;CACpF,MAAM,qBAAqB,aAAa,CAAC;CACzC,MAAM,YAAY,YAAY,cAAc;CAE5C,MAAM,2BAAmC;AACvC,MAAI,gBAAgB,SAClB,QAAO;WACE,aACT,QAAO,qBAAqB,+CAA+C;WAClE,aAAa,SACtB,QAAO;WACE,UACT,QAAO,qB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A2B,eAAa;EAAQ,oBAAkB,YAAY;aAC3F,mBAAmB,eAAe,QACjC,qBAAA,UAAA,EAAA,UAAA,CACG,cAAc,EACd,iBAAiB,CAAA,EAAA,CACjB,EAEJ,mBAAmB,eAAe,SACjC,qBAAA,UAAA,EAAA,UAAA,CACG,iBAAiB,EACjB,cAAc,CAAA,EAAA,CACd,CAAA;GAED;;ACzMV,IAAA,iBD6Me"}
@@ -100,8 +100,8 @@
100
100
  &__toggle {
101
101
  position: relative;
102
102
  display: inline-block;
103
- width: 3.125rem;
104
- height: 2rem;
103
+ width: 2.75rem;
104
+ height: 1.75rem;
105
105
  background-color: var(--color-base-background-white);
106
106
  border-radius: 60px;
107
107
  border: 2px solid var(--color-base-border-onlight-emphasized);
@@ -117,8 +117,8 @@
117
117
  &__dot {
118
118
  content: '';
119
119
  position: absolute;
120
- width: 1.375rem;
121
- height: 1.375rem;
120
+ width: 1.125rem;
121
+ height: 1.125rem;
122
122
  left: 3px;
123
123
  bottom: 3px;
124
124
  background-color: var(--brandcolor-neutral-dark);
@@ -10,7 +10,7 @@ import { n as FormGroup_default } from "../../FormGroup.js";
10
10
  import { t as Input_default } from "../../Input2.js";
11
11
  import { t as List_default } from "../../List.js";
12
12
  import { t as RadioButton_default } from "../../RadioButton.js";
13
- import classNames from "classnames";
13
+ import cn from "classnames";
14
14
  import React, { useId } from "react";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
16
  import styles from "./styles.module.scss";
@@ -37,7 +37,7 @@ var ValidationSummary = (props) => {
37
37
  const titleId = useId();
38
38
  const hasErrors = !!props.errors && Object.entries(props.errors).length > 0;
39
39
  const visuallyHidden = props.visuallyHidden;
40
- const summaryClasses = classNames(styles["validation__summary"], {
40
+ const summaryClasses = cn(styles["validation__summary"], {
41
41
  [styles["validation__summary--visible"]]: hasErrors && !visuallyHidden,
42
42
  [styles["validation__summary--sr-only"]]: visuallyHidden
43
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ErrorListItem: React.FC<ErrorElementProps>","ErrorList: React.FC<ErrorListProps>","ValidationSummary: React.FC<ValidationSummaryProps>","Validation: React.FC<ValidationProps>"],"sources":["../../../src/components/Validation/ErrorListItem.tsx","../../../src/components/Validation/ErrorList.tsx","../../../src/components/Validation/ValidationSummary.tsx","../../../src/components/Validation/Validation.tsx","../../../src/components/Validation/index.ts"],"sourcesContent":["import type { ErrorDetails, FocusableElement } from './types';\nimport type { AnchorLinkOnClickEvent } from '../AnchorLink';\n\nimport AnchorLink from '../AnchorLink';\n\ninterface ErrorElementProps {\n name: string;\n error: ErrorDetails;\n}\n\nconst ErrorListItem: React.FC<ErrorElementProps> = props => {\n const handleClick = (event?: AnchorLinkOnClickEvent, element?: FocusableElement): void => {\n event?.preventDefault();\n if (element?.focus) element?.focus();\n };\n\n if (props.error.ref) {\n return (\n <AnchorLink href={`#${props.name}`} onClick={(e): void => handleClick(e, props.error.ref)}>\n {props.error.message}\n </AnchorLink>\n );\n }\n\n return <>{props.error.message}</>;\n};\n\nexport default ErrorListItem;\n","import type { ValidationErrors } from './types';\n\nimport ErrorListItem from './ErrorListItem';\nimport List from '../List';\n\ninterface ErrorListProps {\n errors: ValidationErrors;\n}\n\nconst ErrorList: React.FC<ErrorListProps> = props => (\n <List>\n {Object.entries(props.errors).map(([name, error]) => (\n <List.Item key={name}>\n <ErrorListItem name={name} error={error} />\n </List.Item>\n ))}\n </List>\n);\n\nexport default ErrorList;\n","import { useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ValidationErrors } from './types';\nimport type { TitleTags } from '../Title';\n\nimport ErrorList from './ErrorList';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationSummaryProps {\n /** Error summary title */\n errorTitle?: string;\n /** Error list */\n errors?: ValidationErrors;\n /** Markup props for error summary title. Default: h2 */\n errorTitleHtmlMarkup?: TitleTags;\n /** Will be shown last */\n children?: React.ReactNode;\n /** Hides the list visually - summary is still announced by screen readers */\n visuallyHidden?: boolean;\n}\n\nconst ValidationSummary: React.FC<ValidationSummaryProps> = props => {\n const { errorTitleHtmlMarkup = 'h2' } = props;\n const titleId = useId();\n\n const hasErrors = !!props.errors && Object.entries(props.errors).length > 0;\n const visuallyHidden = props.visuallyHidden;\n\n const summaryClasses = classNames(styles['validation__summary'], {\n [styles['validation__summary--visible']]: hasErrors && !visuallyHidden,\n [styles['validation__summary--sr-only']]: visuallyHidden,\n });\n\n return (\n <div\n role={'status'}\n aria-atomic={'true'}\n aria-live={'polite'}\n aria-relevant={'all'}\n aria-labelledby={hasErrors && props.errorTitle ? titleId : undefined}\n className={summaryClasses}\n >\n {hasErrors && (\n <>\n {props.errorTitle && (\n <Title appearance=\"title4\" id={titleId} htmlMarkup={errorTitleHtmlMarkup} margin={{ marginTop: 0, marginBottom: 1 }}>\n {props.errorTitle}\n </Title>\n )}\n <ErrorList errors={props.errors!} />\n </>\n )}\n {props.children}\n </div>\n );\n};\n\nexport default ValidationSummary;\n","import React from 'react';\n\nimport type { ValidationErrors } from './types';\nimport type { FormSize } from '../../constants';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport type { FormGroupProps } from '../FormGroup/FormGroup';\nimport type { InputProps } from '../Input';\nimport type { RadioButtonProps } from '../RadioButton';\nimport type { SelectProps } from '../Select';\nimport type { SliderProps } from '../Slider';\nimport type { TextareaProps } from '../Textarea';\n\nimport ValidationSummary from './ValidationSummary';\nimport { AnalyticsId } from '../../constants';\nimport { isComponent, isComponentWithDisplayName } from '../../utils/component';\nimport Checkbox from '../Checkbox';\nimport FormGroup from '../FormGroup/FormGroup';\nimport Input from '../Input';\nimport RadioButton from '../RadioButton';\nimport Select from '../Select';\nimport Slider from '../Slider';\nimport Textarea from '../Textarea';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationProps {\n /** Error summary title */\n errorTitle?: string;\n /** Validation errors. If errors include references to HTML elements, the errors will be rendered as links with an onClick handler to focus the element. */\n errors?: ValidationErrors;\n /** Items in the Validation compontent */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Hides the ValidationSummary list visually - summary is still announced by screen readers */\n visuallyHiddenSummary?: boolean;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const Validation: React.FC<ValidationProps> = (props: ValidationProps) => {\n const validationErrorClass = styles['validation__error-wrapper'];\n\n const cloneFormElement = <T extends ErrorWrapperClassNameProps>(child: React.ReactElement<T>): React.ReactElement<T> => {\n return React.cloneElement(child, {\n ...child.props,\n errorWrapperClassName: validationErrorClass,\n });\n };\n\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (\n isComponent<FormGroupProps>(child, FormGroup) ||\n isComponent<CheckboxProps>(child, Checkbox) ||\n isComponent<RadioButtonProps>(child, RadioButton) ||\n isComponent<TextareaProps>(child, Textarea) ||\n isComponent<InputProps>(child, Input) ||\n isComponent<SelectProps>(child, Select) ||\n isComponent<SliderProps>(child, Slider) ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTimePickerWrapper') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DatePicker') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTime')\n ) {\n return cloneFormElement<ErrorWrapperClassNameProps>(child);\n }\n if (isComponent<React.FragmentProps>(child, React.Fragment)) {\n return React.Children.map(child.props.children, (child: React.ReactNode) => {\n return renderChild(child);\n });\n }\n\n return child;\n };\n\n return (\n <>\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.Validation} className={props.className} ref={props.ref}>\n {React.Children.map(props.children, (child: React.ReactNode) => renderChild(child))}\n </div>\n <ValidationSummary errorTitle={props.errorTitle} errors={props.errors} visuallyHidden={props.visuallyHiddenSummary} />\n </>\n );\n};\n\nValidation.displayName = 'Validation';\n\nexport default Validation;\n","import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EAEV,oBAAC,mBAAA,EAAU,QAAQ,MAAM,QAAA,CAAW,CAAA,EAAA,CACnC,EAEJ,MAAM,SAAA;GACH;;AAIV,IAAA,4BAAe;AChBf,MAAaC,cAAyC,UAA2B;CAC/E,MAAM,uBAAuB,OAAO;CAEpC,MAAM,oBAA0D,UAAwD;AACtH,SAAO,MAAM,aAAa,OAAO;GAC/B,GAAG,MAAM;GACT,uBAAuB;GACxB,CAAC;;CAGJ,MAAM,eAAe,UAA4C;AAC/D,MACE,YAA4B,OAAO,kBAAU,IAC7C,YAA2B,OAAO,iBAAS,IAC3C,YAA8B,OAAO,oBAAY,IACjD,YAA2B,OAAO,iBAAS,IAC3C,YAAwB,OAAO,cAAM,IACrC,YAAyB,OAAO,eAAO,IACvC,YAAyB,OAAO,eAAO,IACvC,2BAAuD,OAAO,wBAAwB,IACtF,2BAAuD,OAAO,aAAa,IAC3E,2BAAuD,OAAO,WAAW,CAEzE,QAAO,iBAA6C,MAAM;AAE5D,MAAI,YAAiC,OAAO,MAAM,SAAS,CACzD,QAAO,MAAM,SAAS,IAAI,MAAM,MAAM,WAAW,YAA2B;AAC1E,UAAO,YAAY,QAAM;IACzB;AAGJ,SAAO;;AAGT,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAA;EAAI,eAAa,MAAM;EAAQ,oBAAkB,YAAY;EAAY,WAAW,MAAM;EAAW,KAAK,MAAM;YAC9G,MAAM,SAAS,IAAI,MAAM,WAAW,UAA2B,YAAY,MAAM,CAAC;GAC/E,EACN,oBAAC,2BAAA;EAAkB,YAAY,MAAM;EAAY,QAAQ,MAAM;EAAQ,gBAAgB,MAAM;GAAyB,CAAA,EAAA,CACrH;;AAIP,WAAW,cAAc;ACvFzB,IAAA,qBDyFe"}
1
+ {"version":3,"file":"index.js","names":["ErrorListItem: React.FC<ErrorElementProps>","ErrorList: React.FC<ErrorListProps>","ValidationSummary: React.FC<ValidationSummaryProps>","Validation: React.FC<ValidationProps>"],"sources":["../../../src/components/Validation/ErrorListItem.tsx","../../../src/components/Validation/ErrorList.tsx","../../../src/components/Validation/ValidationSummary.tsx","../../../src/components/Validation/Validation.tsx","../../../src/components/Validation/index.ts"],"sourcesContent":["import type { ErrorDetails, FocusableElement } from './types';\nimport type { AnchorLinkOnClickEvent } from '../AnchorLink';\n\nimport AnchorLink from '../AnchorLink';\n\ninterface ErrorElementProps {\n name: string;\n error: ErrorDetails;\n}\n\nconst ErrorListItem: React.FC<ErrorElementProps> = props => {\n const handleClick = (event?: AnchorLinkOnClickEvent, element?: FocusableElement): void => {\n event?.preventDefault();\n if (element?.focus) element?.focus();\n };\n\n if (props.error.ref) {\n return (\n <AnchorLink href={`#${props.name}`} onClick={(e): void => handleClick(e, props.error.ref)}>\n {props.error.message}\n </AnchorLink>\n );\n }\n\n return <>{props.error.message}</>;\n};\n\nexport default ErrorListItem;\n","import type { ValidationErrors } from './types';\n\nimport ErrorListItem from './ErrorListItem';\nimport List from '../List';\n\ninterface ErrorListProps {\n errors: ValidationErrors;\n}\n\nconst ErrorList: React.FC<ErrorListProps> = props => (\n <List>\n {Object.entries(props.errors).map(([name, error]) => (\n <List.Item key={name}>\n <ErrorListItem name={name} error={error} />\n </List.Item>\n ))}\n </List>\n);\n\nexport default ErrorList;\n","import { useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ValidationErrors } from './types';\nimport type { TitleTags } from '../Title';\n\nimport ErrorList from './ErrorList';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationSummaryProps {\n /** Error summary title */\n errorTitle?: string;\n /** Error list */\n errors?: ValidationErrors;\n /** Markup props for error summary title. Default: h2 */\n errorTitleHtmlMarkup?: TitleTags;\n /** Will be shown last */\n children?: React.ReactNode;\n /** Hides the list visually - summary is still announced by screen readers */\n visuallyHidden?: boolean;\n}\n\nconst ValidationSummary: React.FC<ValidationSummaryProps> = props => {\n const { errorTitleHtmlMarkup = 'h2' } = props;\n const titleId = useId();\n\n const hasErrors = !!props.errors && Object.entries(props.errors).length > 0;\n const visuallyHidden = props.visuallyHidden;\n\n const summaryClasses = classNames(styles['validation__summary'], {\n [styles['validation__summary--visible']]: hasErrors && !visuallyHidden,\n [styles['validation__summary--sr-only']]: visuallyHidden,\n });\n\n return (\n <div\n role={'status'}\n aria-atomic={'true'}\n aria-live={'polite'}\n aria-relevant={'all'}\n aria-labelledby={hasErrors && props.errorTitle ? titleId : undefined}\n className={summaryClasses}\n >\n {hasErrors && (\n <>\n {props.errorTitle && (\n <Title appearance=\"title4\" id={titleId} htmlMarkup={errorTitleHtmlMarkup} margin={{ marginTop: 0, marginBottom: 1 }}>\n {props.errorTitle}\n </Title>\n )}\n <ErrorList errors={props.errors!} />\n </>\n )}\n {props.children}\n </div>\n );\n};\n\nexport default ValidationSummary;\n","import React from 'react';\n\nimport type { ValidationErrors } from './types';\nimport type { FormSize } from '../../constants';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport type { FormGroupProps } from '../FormGroup/FormGroup';\nimport type { InputProps } from '../Input';\nimport type { RadioButtonProps } from '../RadioButton';\nimport type { SelectProps } from '../Select';\nimport type { SliderProps } from '../Slider';\nimport type { TextareaProps } from '../Textarea';\n\nimport ValidationSummary from './ValidationSummary';\nimport { AnalyticsId } from '../../constants';\nimport { isComponent, isComponentWithDisplayName } from '../../utils/component';\nimport Checkbox from '../Checkbox';\nimport FormGroup from '../FormGroup/FormGroup';\nimport Input from '../Input';\nimport RadioButton from '../RadioButton';\nimport Select from '../Select';\nimport Slider from '../Slider';\nimport Textarea from '../Textarea';\n\nimport styles from './styles.module.scss';\n\ninterface ValidationProps {\n /** Error summary title */\n errorTitle?: string;\n /** Validation errors. If errors include references to HTML elements, the errors will be rendered as links with an onClick handler to focus the element. */\n errors?: ValidationErrors;\n /** Items in the Validation compontent */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Hides the ValidationSummary list visually - summary is still announced by screen readers */\n visuallyHiddenSummary?: boolean;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const Validation: React.FC<ValidationProps> = (props: ValidationProps) => {\n const validationErrorClass = styles['validation__error-wrapper'];\n\n const cloneFormElement = <T extends ErrorWrapperClassNameProps>(child: React.ReactElement<T>): React.ReactElement<T> => {\n return React.cloneElement(child, {\n ...child.props,\n errorWrapperClassName: validationErrorClass,\n });\n };\n\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (\n isComponent<FormGroupProps>(child, FormGroup) ||\n isComponent<CheckboxProps>(child, Checkbox) ||\n isComponent<RadioButtonProps>(child, RadioButton) ||\n isComponent<TextareaProps>(child, Textarea) ||\n isComponent<InputProps>(child, Input) ||\n isComponent<SelectProps>(child, Select) ||\n isComponent<SliderProps>(child, Slider) ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTimePickerWrapper') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DatePicker') ||\n isComponentWithDisplayName<ErrorWrapperClassNameProps>(child, 'DateTime')\n ) {\n return cloneFormElement<ErrorWrapperClassNameProps>(child);\n }\n if (isComponent<React.FragmentProps>(child, React.Fragment)) {\n return React.Children.map(child.props.children, (child: React.ReactNode) => {\n return renderChild(child);\n });\n }\n\n return child;\n };\n\n return (\n <>\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.Validation} className={props.className} ref={props.ref}>\n {React.Children.map(props.children, (child: React.ReactNode) => renderChild(child))}\n </div>\n <ValidationSummary errorTitle={props.errorTitle} errors={props.errors} visuallyHidden={props.visuallyHiddenSummary} />\n </>\n );\n};\n\nValidation.displayName = 'Validation';\n\nexport default Validation;\n","import Validation from './Validation';\nexport * from './Validation';\nexport default Validation;\n"],"mappings":";;;;;;;;;;;;;;;;AAUA,IAAMA,iBAA6C,UAAS;CAC1D,MAAM,eAAe,OAAg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Bf,MAAaC,cAAyC,UAA2B;CAC/E,MAAM,uBAAuB,OAAO;CAEpC,MAAM,oBAA0D,UAAwD;AACtH,SAAO,MAAM,aAAa,OAAO;GAC/B,GAAG,MAAM;GACT,uBAAuB;GACxB,CAAC;;CAGJ,MAAM,eAAe,UAA4C;AAC/D,MACE,YAA4B,OAAO,kBAAU,IAC7C,YAA2B,OAAO,iBAAS,IAC3C,YAA8B,OAAO,oBAAY,IACjD,YAA2B,OAAO,iBAAS,IAC3C,YAAwB,OAAO,cAAM,IACrC,YAAyB,OAAO,eAAO,IACvC,YAAyB,OAAO,eAAO,IACvC,2BAAuD,OAAO,wBAAwB,IACtF,2BAAuD,OAAO,aAAa,IAC3E,2BAAuD,OAAO,WAAW,CAEzE,QAAO,iBAA6C,MAAM;AAE5D,MAAI,YAAiC,OAAO,MAAM,SAAS,CACzD,QAAO,MAAM,SAAS,IAAI,MAAM,MAAM,WAAW,YAA2B;AAC1E,UAAO,YAAY,QAAM;IACzB;AAGJ,SAAO;;AAGT,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAA;EAAI,eAAa,MAAM;EAAQ,oBAAkB,YAAY;EAAY,WAAW,MAAM;EAAW,KAAK,MAAM;YAC9G,MAAM,SAAS,IAAI,MAAM,WAAW,UAA2B,YAAY,MAAM,CAAC;GAC/E,EACN,oBAAC,2BAAA;EAAkB,YAAY,MAAM;EAAY,QAAQ,MAAM;EAAQ,gBAAgB,MAAM;GAAyB,CAAA,EAAA,CACrH;;AAIP,WAAW,cAAc;ACvFzB,IAAA,qBDyFe"}
@@ -0,0 +1,9 @@
1
+ declare module '*.scss' {
2
+ const styles: { [className: string]: string };
3
+ export default styles;
4
+ }
5
+
6
+ declare module '*.svg' {
7
+ const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
8
+ export default content;
9
+ }
@@ -0,0 +1,3 @@
1
+ // This file is for typescript global SCRIPTS. This shall not contain any import/export
2
+
3
+ declare module '*.scss';
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
- "ariaLabelCloseBtn": "Close"
2
+ "ariaLabelCloseBtn": "Close",
3
+ "ariaLabelBackButton": "Go back"
3
4
  }
4
5
  ;
5
6
 
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
- "ariaLabelCloseBtn": "Lukk"
2
+ "ariaLabelCloseBtn": "Lukk",
3
+ "ariaLabelBackButton": "Gå tilbake"
3
4
  }
4
5
  ;
5
6
 
@@ -0,0 +1,149 @@
1
+ /* eslint:disable */
2
+ /*
3
+ * This file is automatically generated by SOT
4
+ *
5
+ * This file is for typings support only, it will not supply the actual text, you will still need to download the correct culture spesific .resx file.
6
+ */
7
+ export type HNDesignsystemDropdown = {
8
+ /**
9
+ * Lukk
10
+ */
11
+ closeText: string;
12
+ };
13
+
14
+ export type HNDesignsystemPanel = {
15
+ /**
16
+ * Se detaljer
17
+ */
18
+ expandButtonOpen: string;
19
+ /**
20
+ * Skjul detaljer
21
+ */
22
+ expandButtonClose: string;
23
+ };
24
+
25
+ export type HNDesignsystemClose = {
26
+ /**
27
+ * Lukk
28
+ */
29
+ ariaLabel: string;
30
+ };
31
+
32
+ export type HNDesignsystemInfoTeaser = {
33
+ /**
34
+ * Vis mindre
35
+ */
36
+ expandButtonOpen: string;
37
+ /**
38
+ * Vis mer
39
+ */
40
+ expandButtonClose: string;
41
+ };
42
+
43
+ export type HNDesignsystemArticleTeaser = {
44
+ /**
45
+ * Vis mer
46
+ */
47
+ expandButtonClose: string;
48
+ /**
49
+ * Vis mindre
50
+ */
51
+ expandButtonOpen: string;
52
+ };
53
+
54
+ export type HNDesignsystemHelpBubble = {
55
+ /**
56
+ * Hjelpetekst
57
+ */
58
+ ariaLabel: string;
59
+ };
60
+
61
+ export type HNDesignsystemHelpDrawer = {
62
+ /**
63
+ * Hjelpetekst
64
+ */
65
+ ariaLabel: string;
66
+ };
67
+
68
+ export type HNDesignsystemFavoriteButton = {
69
+ /**
70
+ * Favorittmarkering
71
+ */
72
+ ariaLabel: string;
73
+ };
74
+
75
+ export type HNDesignsystemTabs = {
76
+ /**
77
+ * Scroll til høyre
78
+ */
79
+ ariaLabelRightButton: string;
80
+ /**
81
+ * Scroll til venstre
82
+ */
83
+ ariaLabelLeftButton: string;
84
+ };
85
+
86
+ export type HNDesignsystemDrawer = {
87
+ /**
88
+ * Lukk
89
+ */
90
+ ariaLabelCloseBtn: string;
91
+ /**
92
+ * Gå tilbake
93
+ */
94
+ ariaLabelBackButton: string;
95
+ };
96
+
97
+ export type HNDesignsystemFormFieldTag = {
98
+ /**
99
+ * Alle felt må fylles ut
100
+ */
101
+ allRequired: string;
102
+ /**
103
+ * Må fylles ut
104
+ */
105
+ requiredField: string;
106
+ /**
107
+ * Valgfritt
108
+ */
109
+ optional: string;
110
+ /**
111
+ * Alle felt er valgfrie
112
+ */
113
+ allOptional: string;
114
+ /**
115
+ * Velg én
116
+ */
117
+ requiredRadiobuttonList: string;
118
+ /**
119
+ * Velg én eller flere
120
+ */
121
+ requiredCheckboxList: string;
122
+ /**
123
+ * Må velges
124
+ */
125
+ requiredSingleCheckbox: string;
126
+ };
127
+
128
+ export type HNDesignsystemTextArea = {
129
+ /**
130
+ * tegn
131
+ */
132
+ characters: string;
133
+ };
134
+
135
+ export type HNDesignsystemLinkList = {
136
+ /**
137
+ * Slett
138
+ */
139
+ editMode_deleteButtonAriaLabel: string;
140
+ };
141
+
142
+ export type HNDesignsystemInput = {
143
+ /**
144
+ * tegn
145
+ */
146
+ characters: string;
147
+ };
148
+
149
+ /* eslint:enable */
@@ -28,7 +28,8 @@
28
28
  }
29
29
  }
30
30
 
31
- @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
31
+ // fjerner denne i vår kopi
32
+ // @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
32
33
  }
33
34
 
34
35
  @mixin make-col-ready($gutter: $grid-gutter-width) {
package/lib/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ type PickByValue<T, V> = Pick<T, { [K in keyof T]: T[K] extends V ? K : never }[keyof T]>;
package/lib/utils2.js CHANGED
@@ -3,14 +3,14 @@ import { t as isComponent } from "./component.js";
3
3
  import { t as Spacer_default } from "./Spacer.js";
4
4
  import { t as FormFieldTag_default } from "./FormFieldTag.js";
5
5
  import { t as StatusDot_default } from "./StatusDot.js";
6
- import classNames from "classnames";
6
+ import cn from "classnames";
7
7
  import React from "react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import styles from "./components/Label/styles.module.scss";
10
10
  const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) => {
11
11
  const mapSublabels = (hideFromScreenReader) => {
12
12
  return sublabelTexts && sublabelTexts.map((sublabelText, index) => {
13
- const labelClasses = classNames(styles.label, styles["sublabel"], {
13
+ const labelClasses = cn(styles.label, styles["sublabel"], {
14
14
  [styles["sublabel--subdued"]]: sublabelText.type === "subdued",
15
15
  [styles["sublabel--on-dark"]]: onColor === FormOnColor.ondark
16
16
  });
@@ -40,13 +40,13 @@ const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) =
40
40
  };
41
41
  var Label = ({ afterLabelChildren, children, className, formFieldTag, htmlFor, htmlMarkup = "label", labelClassName, labelTextClassName, labelId, labelTexts, onColor = FormOnColor.onwhite, statusDot, sublabel, sublabelWrapperClassName, testId, afterLabelChildrenClassName }) => {
42
42
  const hasChildren = children && typeof children !== "undefined";
43
- const labelWrapperClasses = classNames(styles["label-wrapper"], { [styles["label-wrapper--no-bottom-margin"]]: hasChildren }, className);
44
- const mainLabelWrapperClasses = classNames({ [styles["label-wrapper--after-label-children"]]: afterLabelChildren });
45
- const afterLabelChildrenClasses = classNames(styles["after-label-children"], afterLabelChildrenClassName);
43
+ const labelWrapperClasses = cn(styles["label-wrapper"], { [styles["label-wrapper--no-bottom-margin"]]: hasChildren }, className);
44
+ const mainLabelWrapperClasses = cn({ [styles["label-wrapper--after-label-children"]]: afterLabelChildren });
45
+ const afterLabelChildrenClasses = cn(styles["after-label-children"], afterLabelChildrenClassName);
46
46
  const mapLabels = () => {
47
47
  if (typeof labelTexts === "undefined") return null;
48
48
  return labelTexts.map((labelText, index) => {
49
- const labelClasses = classNames(styles.label, {
49
+ const labelClasses = cn(styles.label, {
50
50
  [styles["label--subdued"]]: labelText.type === "subdued",
51
51
  [styles["label--on-dark"]]: onColor === FormOnColor.ondark
52
52
  }, labelTextClassName);
@@ -115,7 +115,7 @@ const renderLabelAsParent = (props) => {
115
115
  htmlFor: props.inputId,
116
116
  onColor: props.onColor,
117
117
  children: props.children,
118
- labelClassName: classNames(props.labelClassName, props.label.props.labelClassName),
118
+ labelClassName: cn(props.labelClassName, props.label.props.labelClassName),
119
119
  labelTextClassName: props.labelTextClassName,
120
120
  htmlMarkup: props.markup || "label",
121
121
  sublabelWrapperClassName: props.sublabelWrapperClassName,
package/lib/utils2.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;AACxE,SACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,WAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;IACxD,CAAC;AACF,UACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAA;IAAK,WAAW;cACd,aAAa;MADoB,MAE7B;IAGX;;CAIN,MAAM,YAAY,cAAc;CAChC,MAAM,sBAAsB,aAAa,KAAK;AAE9C,QACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,gBAAA,EAAO,MAAM,OAAA,CAAS;GACrB,aAAa,aACb,qBAAC,OAAA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M,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACvD,6BAA6B,MAAM;EACpC,CAAC,GACF,OAAO,MAAM,UAAU,YACrB,oBAAC,eAAA;EACC,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;GAAW,CAAC;EACpD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;GACD,EAAA,CAEb"}
1
+ {"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;AACxE,SACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,GAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;IACxD,CAAC;AACF,UACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAA;IAAK,WAAW;cACd,aAAa;MADoB,MAE7B;IAGX;;CAIN,MAAM,YAAY,cAAc;CAChC,MAAM,sBAAsB,aAAa,KAAK;AAE9C,QACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,gBAAA,EAAO,MAAM,OAAA,CAAS;GACrB,aAAa,aACb,qBAAC,OAAA;GAAe;GAAe;GAAI,eAAa;GAAQ,oBAAkB,YAAY;cACnF,WACA,SAAA;IACG;EAEP,uBACC,oBAAC,OAAA;GAAe;GAAW,eAAa;aACrC;IACG;KAEP;;ACAP,IAAMC,SAAwC,EAC5C,oBACA,UACA,WACA,cACA,SACA,aAAa,SACb,gBACA,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