@helsenorge/designsystem-react 14.2.0 → 14.3.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 (178) 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 +17 -0
  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 +5 -5
  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/LinkList.js +5 -5
  51. package/lib/LinkList.js.map +1 -1
  52. package/lib/List.js +2 -2
  53. package/lib/List.js.map +1 -1
  54. package/lib/ListEditMode.js +4 -4
  55. package/lib/ListEditMode.js.map +1 -1
  56. package/lib/MaxCharacters.js +2 -2
  57. package/lib/MaxCharacters.js.map +1 -1
  58. package/lib/PanelTitle.js +2 -2
  59. package/lib/PanelTitle.js.map +1 -1
  60. package/lib/PopOver.js +2 -2
  61. package/lib/PopOver.js.map +1 -1
  62. package/lib/Select.js +4 -4
  63. package/lib/Select.js.map +1 -1
  64. package/lib/SingleSelectItem.js +3 -3
  65. package/lib/SingleSelectItem.js.map +1 -1
  66. package/lib/Slider.js +4 -4
  67. package/lib/Slider.js.map +1 -1
  68. package/lib/Spacer.js +2 -2
  69. package/lib/Spacer.js.map +1 -1
  70. package/lib/StatusDot.js +4 -4
  71. package/lib/StatusDot.js.map +1 -1
  72. package/lib/StatusDotList.js +2 -2
  73. package/lib/StatusDotList.js.map +1 -1
  74. package/lib/StepButtons.js +5 -5
  75. package/lib/StepButtons.js.map +1 -1
  76. package/lib/TabList.js +8 -8
  77. package/lib/TabList.js.map +1 -1
  78. package/lib/TabPanel.js +2 -2
  79. package/lib/TabPanel.js.map +1 -1
  80. package/lib/TableBody.js +2 -2
  81. package/lib/TableBody.js.map +1 -1
  82. package/lib/TableCell.js +2 -2
  83. package/lib/TableCell.js.map +1 -1
  84. package/lib/TableExpandedRow.js +4 -4
  85. package/lib/TableExpandedRow.js.map +1 -1
  86. package/lib/TableExpanderCell.js +2 -2
  87. package/lib/TableExpanderCell.js.map +1 -1
  88. package/lib/TableHead.js +2 -2
  89. package/lib/TableHead.js.map +1 -1
  90. package/lib/TableHeadCell.js +3 -3
  91. package/lib/TableHeadCell.js.map +1 -1
  92. package/lib/TableRow.js +3 -3
  93. package/lib/TableRow.js.map +1 -1
  94. package/lib/Textarea.js +4 -4
  95. package/lib/Textarea.js.map +1 -1
  96. package/lib/Title.js +2 -2
  97. package/lib/Title.js.map +1 -1
  98. package/lib/Toast.js +3 -3
  99. package/lib/Toast.js.map +1 -1
  100. package/lib/components/ArticleTeaser/index.js +4 -4
  101. package/lib/components/ArticleTeaser/index.js.map +1 -1
  102. package/lib/components/Chip/Chip.d.ts +10 -10
  103. package/lib/components/Chip/index.d.ts +0 -1
  104. package/lib/components/Chip/index.js +30 -42
  105. package/lib/components/Chip/index.js.map +1 -1
  106. package/lib/components/Chip/styles.module.scss +68 -73
  107. package/lib/components/Chip/styles.module.scss.d.ts +5 -12
  108. package/lib/components/Dropdown/index.js +5 -5
  109. package/lib/components/Dropdown/index.js.map +1 -1
  110. package/lib/components/DropdownOld/index.js +3 -3
  111. package/lib/components/DropdownOld/index.js.map +1 -1
  112. package/lib/components/EmptyState/index.js +2 -2
  113. package/lib/components/EmptyState/index.js.map +1 -1
  114. package/lib/components/ExpanderHierarchy/index.js +7 -7
  115. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  116. package/lib/components/ExpanderList/index.js +6 -6
  117. package/lib/components/ExpanderList/index.js.map +1 -1
  118. package/lib/components/FavoriteButton/index.js +2 -2
  119. package/lib/components/FavoriteButton/index.js.map +1 -1
  120. package/lib/components/HelpBubble/index.js +3 -3
  121. package/lib/components/HelpBubble/index.js.map +1 -1
  122. package/lib/components/HelpPanel/index.js +2 -2
  123. package/lib/components/HelpPanel/index.js.map +1 -1
  124. package/lib/components/HelpTriggerInline/index.js +2 -2
  125. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  126. package/lib/components/Icons/Undo.js +35 -1
  127. package/lib/components/Icons/Undo.js.map +1 -0
  128. package/lib/components/Loader/index.js +4 -4
  129. package/lib/components/Loader/index.js.map +1 -1
  130. package/lib/components/Modal/index.js +9 -9
  131. package/lib/components/Modal/index.js.map +1 -1
  132. package/lib/components/NotificationPanel/index.js +6 -6
  133. package/lib/components/NotificationPanel/index.js.map +1 -1
  134. package/lib/components/Panel/index.js +12 -12
  135. package/lib/components/Panel/index.js.map +1 -1
  136. package/lib/components/PanelList/index.js +3 -3
  137. package/lib/components/PanelList/index.js.map +1 -1
  138. package/lib/components/PopMenu/index.js +3 -3
  139. package/lib/components/PopMenu/index.js.map +1 -1
  140. package/lib/components/Progressbar/index.js +2 -2
  141. package/lib/components/Progressbar/index.js.map +1 -1
  142. package/lib/components/PromoPanel/index.js +2 -2
  143. package/lib/components/PromoPanel/index.js.map +1 -1
  144. package/lib/components/ServiceMessage/index.js +5 -5
  145. package/lib/components/ServiceMessage/index.js.map +1 -1
  146. package/lib/components/SharingStatus/index.js +4 -4
  147. package/lib/components/SharingStatus/index.js.map +1 -1
  148. package/lib/components/Step/index.js +2 -2
  149. package/lib/components/Step/index.js.map +1 -1
  150. package/lib/components/Stepper/index.js +2 -2
  151. package/lib/components/Stepper/index.js.map +1 -1
  152. package/lib/components/StickyNote/index.js +8 -8
  153. package/lib/components/StickyNote/index.js.map +1 -1
  154. package/lib/components/Table/index.js +2 -2
  155. package/lib/components/Table/index.js.map +1 -1
  156. package/lib/components/Tabs/index.js +4 -4
  157. package/lib/components/Tabs/index.js.map +1 -1
  158. package/lib/components/Tag/index.js +2 -2
  159. package/lib/components/Tag/index.js.map +1 -1
  160. package/lib/components/Tile/index.js +4 -4
  161. package/lib/components/Tile/index.js.map +1 -1
  162. package/lib/components/Toggle/Toggle.d.ts +1 -1
  163. package/lib/components/Toggle/index.js +24 -18
  164. package/lib/components/Toggle/index.js.map +1 -1
  165. package/lib/components/Toggle/styles.module.scss +25 -0
  166. package/lib/components/Toggle/styles.module.scss.d.ts +1 -0
  167. package/lib/components/Validation/index.js +2 -2
  168. package/lib/components/Validation/index.js.map +1 -1
  169. package/lib/scss/_reset.scss +12 -0
  170. package/lib/utils2.js +7 -7
  171. package/lib/utils2.js.map +1 -1
  172. package/lib/utils3.js +5 -5
  173. package/lib/utils3.js.map +1 -1
  174. package/package.json +1 -1
  175. package/scss/_reset.scss +12 -0
  176. package/lib/Undo.js +0 -36
  177. package/lib/Undo.js.map +0 -1
  178. package/lib/components/Chip/constants.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.js","names":["Textarea: React.FC<TextareaProps>","mergedResources: HNDesignsystemTextArea"],"sources":["../src/resources/HN.Designsystem.TextArea.en-GB.json","../src/resources/HN.Designsystem.TextArea.nb-NO.json","../src/resources/HN.Designsystem.TextArea.nn-NO.json","../src/components/Textarea/resourceHelper.ts","../src/components/Textarea/Textarea.tsx","../src/components/Textarea/index.ts"],"sourcesContent":["{\n \"characters\": \"characters\"\n}\n","{\n \"characters\": \"tegn\"\n}\n","{\n \"characters\": \"teikn\"\n}\n","import type { HNDesignsystemTextArea } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.TextArea.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.TextArea.nb-NO.json';\nimport nnNO from '../../resources/HN.Designsystem.TextArea.nn-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemTextArea => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN_NYNORSK:\n return nnNO;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import { useState, useRef, useLayoutEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport type { HNDesignsystemTextArea } from '../../resources/Resources';\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormOnColor, LanguageLocales } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label/utils';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n | 'value'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n onColor?: keyof typeof FormOnColor;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Resources for component */\n resources?: Partial<HNDesignsystemTextArea>;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLTextAreaElement | null>;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea: React.FC<TextareaProps> = props => {\n const {\n maxCharacters,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n onColor = FormOnColor.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n value,\n resources,\n ref,\n ...rest\n } = props;\n\n const [textareaInput, setTextareaInput] = useState(value || defaultValue || '');\n const [prevDefaultValue, setPrevDefaultValue] = useState(defaultValue);\n const [prevValue, setPrevValue] = useState(value);\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useIdWithFallback(errorTextIdProp);\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemTextArea = {\n ...defaultResources,\n ...resources,\n };\n\n if (defaultValue !== prevDefaultValue) {\n setPrevDefaultValue(defaultValue);\n setTextareaInput(defaultValue || '');\n }\n\n if (value !== prevValue) {\n setPrevValue(value);\n\n if (value) {\n setTextareaInput(value);\n }\n }\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n } else {\n target.rows = currentRows;\n }\n };\n\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = onColor === FormOnColor.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useLayoutEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, [value]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n setTextareaInput(e.target.value);\n\n if (onChange) {\n onChange(e);\n }\n\n if (grow) {\n resizeHeight(e.target);\n }\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel({ label: label, inputId: textareaId, onColor: onColor as FormOnColor })}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n {...rest}\n rows={minRows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n value={value}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={mergedResources.characters}\n onColor={onColor}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n};\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n","import Textarea from './Textarea';\nexport * from './Textarea';\nexport default Textarea;\n"],"mappings":"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"}
1
+ {"version":3,"file":"Textarea.js","names":["Textarea: React.FC<TextareaProps>","mergedResources: HNDesignsystemTextArea"],"sources":["../src/resources/HN.Designsystem.TextArea.en-GB.json","../src/resources/HN.Designsystem.TextArea.nb-NO.json","../src/resources/HN.Designsystem.TextArea.nn-NO.json","../src/components/Textarea/resourceHelper.ts","../src/components/Textarea/Textarea.tsx","../src/components/Textarea/index.ts"],"sourcesContent":["{\n \"characters\": \"characters\"\n}\n","{\n \"characters\": \"tegn\"\n}\n","{\n \"characters\": \"teikn\"\n}\n","import type { HNDesignsystemTextArea } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.TextArea.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.TextArea.nb-NO.json';\nimport nnNO from '../../resources/HN.Designsystem.TextArea.nn-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemTextArea => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN_NYNORSK:\n return nnNO;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import { useState, useRef, useLayoutEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport type { HNDesignsystemTextArea } from '../../resources/Resources';\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormOnColor, LanguageLocales } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label/utils';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n | 'value'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n onColor?: keyof typeof FormOnColor;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Resources for component */\n resources?: Partial<HNDesignsystemTextArea>;\n /** Ref passed to the component */\n ref?: React.Ref<HTMLTextAreaElement | null>;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea: React.FC<TextareaProps> = props => {\n const {\n maxCharacters,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n onColor = FormOnColor.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n value,\n resources,\n ref,\n ...rest\n } = props;\n\n const [textareaInput, setTextareaInput] = useState(value || defaultValue || '');\n const [prevDefaultValue, setPrevDefaultValue] = useState(defaultValue);\n const [prevValue, setPrevValue] = useState(value);\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useIdWithFallback(errorTextIdProp);\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemTextArea = {\n ...defaultResources,\n ...resources,\n };\n\n if (defaultValue !== prevDefaultValue) {\n setPrevDefaultValue(defaultValue);\n setTextareaInput(defaultValue || '');\n }\n\n if (value !== prevValue) {\n setPrevValue(value);\n\n if (value) {\n setTextareaInput(value);\n }\n }\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n } else {\n target.rows = currentRows;\n }\n };\n\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = onColor === FormOnColor.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useLayoutEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, [value]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n setTextareaInput(e.target.value);\n\n if (onChange) {\n onChange(e);\n }\n\n if (grow) {\n resizeHeight(e.target);\n }\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel({ label: label, inputId: textareaId, onColor: onColor as FormOnColor })}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n {...rest}\n rows={minRows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n value={value}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={mergedResources.characters}\n onColor={onColor}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n};\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n","import Textarea from './Textarea';\nexport * from './Textarea';\nexport default Textarea;\n"],"mappings":"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"}
package/lib/Title.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as AnalyticsId } from "./constants2.js";
2
- import cn from "classnames";
2
+ import classNames from "classnames";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import titleStyles from "./components/Title/styles.module.scss";
5
5
  const instanceOfTitleMargin = (margin) => {
@@ -9,7 +9,7 @@ const Title = (props) => {
9
9
  const { id, children, className, htmlMarkup = "h1", appearance = "title1", margin = 0, testId, ref } = props;
10
10
  return /* @__PURE__ */ jsx(htmlMarkup, {
11
11
  id,
12
- className: cn(titleStyles.title, {
12
+ className: classNames(titleStyles.title, {
13
13
  [titleStyles["title--feature"]]: appearance === "titleFeature",
14
14
  [titleStyles["title--title1"]]: appearance === "title1",
15
15
  [titleStyles["title--title2"]]: appearance === "title2",
package/lib/Title.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Title.js","names":["Title: React.FC<TitleProps>"],"sources":["../src/components/Title/utils.ts","../src/components/Title/Title.tsx"],"sourcesContent":["import type { TitleMargin } from './Title';\n\nexport const instanceOfTitleMargin = (margin: unknown): margin is TitleMargin => {\n return Object.prototype.hasOwnProperty.call(margin, 'marginTop') && Object.prototype.hasOwnProperty.call(margin, 'marginBottom');\n};\n","import classNames from 'classnames';\n\nimport { instanceOfTitleMargin } from './utils';\nimport { AnalyticsId } from '../../constants';\n\nimport titleStyles from './styles.module.scss';\n\nexport type TitleTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';\nexport type TitleAppearances = 'titleFeature' | 'title1' | 'title2' | 'title3' | 'title4' | 'title5' | 'title6';\n\nexport interface TitleProps {\n children: React.ReactNode;\n /** Gives a unique id to the title */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds top and bottom margin in rem. */\n margin?: number | TitleMargin;\n /** Changes the underlying element of the title. */\n htmlMarkup?: TitleTags;\n /** Changes the appearance of the title. */\n appearance?: TitleAppearances;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the heading element */\n ref?: React.Ref<HTMLHeadingElement | null>;\n}\n\nexport const Title: React.FC<TitleProps> = (props: TitleProps) => {\n const { id, children, className, htmlMarkup = 'h1', appearance = 'title1', margin = 0, testId, ref } = props;\n const titleClasses = classNames(\n titleStyles.title,\n {\n [titleStyles['title--feature']]: appearance === 'titleFeature',\n [titleStyles['title--title1']]: appearance === 'title1',\n [titleStyles['title--title2']]: appearance === 'title2',\n [titleStyles['title--title3']]: appearance === 'title3',\n [titleStyles['title--title4']]: appearance === 'title4',\n [titleStyles['title--title5']]: appearance === 'title5',\n [titleStyles['title--title6']]: appearance === 'title6',\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n const inlineStyle = instanceOfTitleMargin(margin)\n ? { marginTop: `${margin.marginTop}rem`, marginBottom: `${margin.marginBottom}rem` }\n : { marginTop: `${margin}rem`, marginBottom: `${margin}rem` };\n\n return (\n <CustomTag id={id} className={titleClasses} style={inlineStyle} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Title}>\n {children}\n </CustomTag>\n );\n};\n\nexport interface TitleMargin {\n marginTop: number;\n marginBottom: number;\n}\n\nexport default Title;\n"],"mappings":";;;;AAEA,MAAa,yBAAyB,WAA2C;AAC/E,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,YAAY,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,eAAe;;ACyBlI,MAAaA,SAA+B,UAAsB;CAChE,MAAM,EAAE,IAAI,UAAU,WAAW,aAAa,MAAM,aAAa,UAAU,SAAS,GAAG,QAAQ,QAAQ;AAoBvG,QACE,oBAPgB,YAOf;EAAc;EAAI,WApBA,GACnB,YAAY,OACZ;IACG,YAAY,oBAAoB,eAAe;IAC/C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;GAChD,EACD,UACD;EAQ6C,OAL1B,sBAAsB,OAAO,GAC7C;GAAE,WAAW,GAAG,OAAO,UAAU;GAAM,cAAc,GAAG,OAAO,aAAa;GAAM,GAClF;GAAE,WAAW,GAAG,OAAO;GAAM,cAAc,GAAG,OAAO;GAAM;EAGQ;EAAK,eAAa;EAAQ,oBAAkB,YAAY;EAC1H;GACS;;AAShB,IAAA,gBAAe"}
1
+ {"version":3,"file":"Title.js","names":["Title: React.FC<TitleProps>"],"sources":["../src/components/Title/utils.ts","../src/components/Title/Title.tsx"],"sourcesContent":["import type { TitleMargin } from './Title';\n\nexport const instanceOfTitleMargin = (margin: unknown): margin is TitleMargin => {\n return Object.prototype.hasOwnProperty.call(margin, 'marginTop') && Object.prototype.hasOwnProperty.call(margin, 'marginBottom');\n};\n","import classNames from 'classnames';\n\nimport { instanceOfTitleMargin } from './utils';\nimport { AnalyticsId } from '../../constants';\n\nimport titleStyles from './styles.module.scss';\n\nexport type TitleTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';\nexport type TitleAppearances = 'titleFeature' | 'title1' | 'title2' | 'title3' | 'title4' | 'title5' | 'title6';\n\nexport interface TitleProps {\n children: React.ReactNode;\n /** Gives a unique id to the title */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds top and bottom margin in rem. */\n margin?: number | TitleMargin;\n /** Changes the underlying element of the title. */\n htmlMarkup?: TitleTags;\n /** Changes the appearance of the title. */\n appearance?: TitleAppearances;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the heading element */\n ref?: React.Ref<HTMLHeadingElement | null>;\n}\n\nexport const Title: React.FC<TitleProps> = (props: TitleProps) => {\n const { id, children, className, htmlMarkup = 'h1', appearance = 'title1', margin = 0, testId, ref } = props;\n const titleClasses = classNames(\n titleStyles.title,\n {\n [titleStyles['title--feature']]: appearance === 'titleFeature',\n [titleStyles['title--title1']]: appearance === 'title1',\n [titleStyles['title--title2']]: appearance === 'title2',\n [titleStyles['title--title3']]: appearance === 'title3',\n [titleStyles['title--title4']]: appearance === 'title4',\n [titleStyles['title--title5']]: appearance === 'title5',\n [titleStyles['title--title6']]: appearance === 'title6',\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n const inlineStyle = instanceOfTitleMargin(margin)\n ? { marginTop: `${margin.marginTop}rem`, marginBottom: `${margin.marginBottom}rem` }\n : { marginTop: `${margin}rem`, marginBottom: `${margin}rem` };\n\n return (\n <CustomTag id={id} className={titleClasses} style={inlineStyle} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Title}>\n {children}\n </CustomTag>\n );\n};\n\nexport interface TitleMargin {\n marginTop: number;\n marginBottom: number;\n}\n\nexport default Title;\n"],"mappings":";;;;AAEA,MAAa,yBAAyB,WAA2C;AAC/E,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,YAAY,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,eAAe;;ACyBlI,MAAaA,SAA+B,UAAsB;CAChE,MAAM,EAAE,IAAI,UAAU,WAAW,aAAa,MAAM,aAAa,UAAU,SAAS,GAAG,QAAQ,QAAQ;AAoBvG,QACE,oBAPgB,YAOf;EAAc;EAAI,WApBA,WACnB,YAAY,OACZ;IACG,YAAY,oBAAoB,eAAe;IAC/C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;IAC9C,YAAY,mBAAmB,eAAe;GAChD,EACD,UACD;EAQ6C,OAL1B,sBAAsB,OAAO,GAC7C;GAAE,WAAW,GAAG,OAAO,UAAU;GAAM,cAAc,GAAG,OAAO,aAAa;GAAM,GAClF;GAAE,WAAW,GAAG,OAAO;GAAM,cAAc,GAAG,OAAO;GAAM;EAGQ;EAAK,eAAa;EAAQ,oBAAkB,YAAY;EAC1H;GACS;;AAShB,IAAA,gBAAe"}
package/lib/Toast.js CHANGED
@@ -3,7 +3,7 @@ import { t as Icon_default } from "./Icon.js";
3
3
  import { t as CheckFill_default } from "./CheckFill.js";
4
4
  import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
5
5
  import { t as Close_default } from "./Close.js";
6
- import cn from "classnames";
6
+ import classNames from "classnames";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import styles from "./components/Toast/styles.module.scss";
9
9
  var Toast = ({ testId, title, message, onClose }) => {
@@ -18,7 +18,7 @@ var Toast = ({ testId, title, message, onClose }) => {
18
18
  /* @__PURE__ */ jsx(Icon_default, {
19
19
  size: isMobile ? IconSize.XSmall : IconSize.Small,
20
20
  svgIcon: CheckFill_default,
21
- className: cn(styles["toast__icon"], styles["toast__icon--check"])
21
+ className: classNames(styles["toast__icon"], styles["toast__icon--check"])
22
22
  }),
23
23
  /* @__PURE__ */ jsxs("div", {
24
24
  className: styles["toast__text-container"],
@@ -33,7 +33,7 @@ var Toast = ({ testId, title, message, onClose }) => {
33
33
  /* @__PURE__ */ jsx(Close_default, {
34
34
  onClick: handleClose,
35
35
  color: "black",
36
- className: cn(styles["toast__icon"], styles["toast__icon--close"]),
36
+ className: classNames(styles["toast__icon"], styles["toast__icon--close"]),
37
37
  testId: `${testId}-close`
38
38
  })
39
39
  ]
package/lib/Toast.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","names":["Toast: React.FC<ToastProps>"],"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\n\nimport styles from './styles.module.scss';\n\nexport interface ToastProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** The title to display in the toast */\n title: string;\n /** The message to display in the toast */\n message?: string;\n /** Callback when toast is closed */\n onClose?: () => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ testId, title, message, onClose }) => {\n const isMobile = useIsMobileBreakpoint();\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n }\n };\n\n return (\n <output className={styles['toast']} data-testid={testId}>\n <Icon\n size={isMobile ? IconSize.XSmall : IconSize.Small}\n svgIcon={CheckFill}\n className={classNames(styles['toast__icon'], styles['toast__icon--check'])}\n />\n <div className={styles['toast__text-container']}>\n <span className={styles['toast__title']}>{title}</span>\n {message && <span className={styles['toast__description']}>{message}</span>}\n </div>\n <Close\n onClick={handleClose}\n color=\"black\"\n className={classNames(styles['toast__icon'], styles['toast__icon--close'])}\n testId={`${testId}-close`}\n />\n </output>\n );\n};\n\nexport default Toast;\n"],"mappings":";;;;;;;;AAoBA,IAAMA,SAA+B,EAAE,QAAQ,OAAO,SAAS,cAAc;CAC3E,MAAM,WAAW,uBAAuB;CAExC,MAAM,oBAA0B;AAC9B,MAAI,QACF,UAAS;;AAIb,QACE,qBAAC,UAAA;EAAO,WAAW,OAAO;EAAU,eAAa;;GAC/C,oBAAC,cAAA;IACC,MAAM,WAAW,SAAS,SAAS,SAAS;IAC5C,SAAS;IACT,WAAW,GAAW,OAAO,gBAAgB,OAAO,sBAAsB;KAC1E;GACF,qBAAC,OAAA;IAAI,WAAW,OAAO;eACrB,oBAAC,QAAA;KAAK,WAAW,OAAO;eAAkB;MAAa,EACtD,WAAW,oBAAC,QAAA;KAAK,WAAW,OAAO;eAAwB;MAAe,CAAA;KACvE;GACN,oBAAC,eAAA;IACC,SAAS;IACT,OAAM;IACN,WAAW,GAAW,OAAO,gBAAgB,OAAO,sBAAsB;IAC1E,QAAQ,GAAG,OAAO;KAClB;;GACK;;AAIb,IAAA,gBAAe"}
1
+ {"version":3,"file":"Toast.js","names":["Toast: React.FC<ToastProps>"],"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport CheckFill from '../Icons/CheckFill';\n\nimport styles from './styles.module.scss';\n\nexport interface ToastProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** The title to display in the toast */\n title: string;\n /** The message to display in the toast */\n message?: string;\n /** Callback when toast is closed */\n onClose?: () => void;\n}\n\nconst Toast: React.FC<ToastProps> = ({ testId, title, message, onClose }) => {\n const isMobile = useIsMobileBreakpoint();\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n }\n };\n\n return (\n <output className={styles['toast']} data-testid={testId}>\n <Icon\n size={isMobile ? IconSize.XSmall : IconSize.Small}\n svgIcon={CheckFill}\n className={classNames(styles['toast__icon'], styles['toast__icon--check'])}\n />\n <div className={styles['toast__text-container']}>\n <span className={styles['toast__title']}>{title}</span>\n {message && <span className={styles['toast__description']}>{message}</span>}\n </div>\n <Close\n onClick={handleClose}\n color=\"black\"\n className={classNames(styles['toast__icon'], styles['toast__icon--close'])}\n testId={`${testId}-close`}\n />\n </output>\n );\n};\n\nexport default Toast;\n"],"mappings":";;;;;;;;AAoBA,IAAMA,SAA+B,EAAE,QAAQ,OAAO,SAAS,cAAc;CAC3E,MAAM,WAAW,uBAAuB;CAExC,MAAM,oBAA0B;AAC9B,MAAI,QACF,UAAS;;AAIb,QACE,qBAAC,UAAA;EAAO,WAAW,OAAO;EAAU,eAAa;;GAC/C,oBAAC,cAAA;IACC,MAAM,WAAW,SAAS,SAAS,SAAS;IAC5C,SAAS;IACT,WAAW,WAAW,OAAO,gBAAgB,OAAO,sBAAsB;KAC1E;GACF,qBAAC,OAAA;IAAI,WAAW,OAAO;eACrB,oBAAC,QAAA;KAAK,WAAW,OAAO;eAAkB;MAAa,EACtD,WAAW,oBAAC,QAAA;KAAK,WAAW,OAAO;eAAwB;MAAe,CAAA;KACvE;GACN,oBAAC,eAAA;IACC,SAAS;IACT,OAAM;IACN,WAAW,WAAW,OAAO,gBAAgB,OAAO,sBAAsB;IAC1E,QAAQ,GAAG,OAAO;KAClB;;GACK;;AAIb,IAAA,gBAAe"}
@@ -1,6 +1,6 @@
1
1
  import { n as AnalyticsId, s as LanguageLocales } from "../../constants2.js";
2
2
  import { n as useLanguage } from "../../useLanguage.js";
3
- import cn from "classnames";
3
+ import classNames from "classnames";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import styles from "./styles.module.scss";
6
6
  var HN_Designsystem_ArticleTeaser_en_GB_default = {
@@ -27,16 +27,16 @@ var ArticleTeaser = (props) => {
27
27
  ...resources
28
28
  };
29
29
  return /* @__PURE__ */ jsxs(WrapperTag, {
30
- className: cn(styles.articleteaser),
30
+ className: classNames(styles.articleteaser),
31
31
  "data-testid": testId,
32
32
  "data-analyticsid": AnalyticsId.ArticleTeaser,
33
33
  children: [/* @__PURE__ */ jsx("div", {
34
- className: cn(styles["articleteaser__content"], { [styles["articleteaser__content--collapsed"]]: !expanded }),
34
+ className: classNames(styles["articleteaser__content"], { [styles["articleteaser__content--collapsed"]]: !expanded }),
35
35
  style: { maxHeight: expanded ? "none" : props.heightCollapsed },
36
36
  children
37
37
  }), /* @__PURE__ */ jsx("button", {
38
38
  type: "button",
39
- className: cn(styles["articleteaser__button"], { [styles["articleteaser__button--expanded"]]: expanded }),
39
+ className: classNames(styles["articleteaser__button"], { [styles["articleteaser__button--expanded"]]: expanded }),
40
40
  onClick: onExpand,
41
41
  "aria-expanded": expanded,
42
42
  "aria-controls": contentId,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ArticleTeaser: React.FC<ArticleTeaserProps>","mergedResources: HNDesignsystemArticleTeaser"],"sources":["../../../src/resources/HN.Designsystem.ArticleTeaser.en-GB.json","../../../src/resources/HN.Designsystem.ArticleTeaser.nb-NO.json","../../../src/components/ArticleTeaser/resourceHelper.ts","../../../src/components/ArticleTeaser/ArticleTeaser.tsx","../../../src/components/ArticleTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonClose\": \"Show more\",\n \"expandButtonOpen\": \"Show less\"\n}\n","{\n \"expandButtonClose\": \"Vis mer\",\n \"expandButtonOpen\": \"Vis mindre\"\n}\n","import type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.ArticleTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.ArticleTeaser.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemArticleTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import classNames from 'classnames';\n\nimport type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useLanguage } from '../../hooks/useLanguage';\n\nimport styles from './styles.module.scss';\n\nexport type ArticleTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface ArticleTeaserProps {\n /** Callback for the button. Should be used for setting the expanded boolean */\n onExpand: () => void;\n /** What's in the box? */\n children: React.ReactNode;\n /** Id of the content, used to set aria-controls */\n contentId: string;\n /** If the component is expanded or not */\n expanded: boolean;\n /** For overriding the height of the collapsed teaser */\n heightCollapsed?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: ArticleTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemArticleTeaser>;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst ArticleTeaser: React.FC<ArticleTeaserProps> = props => {\n const { onExpand, children, contentId, expanded, htmlMarkup = 'div', resources, testId } = props;\n const WrapperTag = htmlMarkup;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemArticleTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n return (\n <WrapperTag className={classNames(styles.articleteaser)} data-testid={testId} data-analyticsid={AnalyticsId.ArticleTeaser}>\n <div\n className={classNames(styles['articleteaser__content'], {\n [styles['articleteaser__content--collapsed']]: !expanded,\n })}\n style={{\n maxHeight: expanded ? 'none' : props.heightCollapsed,\n }}\n >\n {children}\n </div>\n <button\n type=\"button\"\n className={classNames(styles['articleteaser__button'], {\n [styles['articleteaser__button--expanded']]: expanded,\n })}\n onClick={onExpand}\n aria-expanded={expanded}\n aria-controls={contentId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default ArticleTeaser;\n","import ArticleTeaser from './ArticleTeaser';\nexport * from './ArticleTeaser';\nexport default ArticleTeaser;\n"],"mappings":";;;;;;;;;;;;;AEMA,MAAa,gBAAgB,aAA2D;AACtF,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACmBb,IAAMA,iBAA8C,UAAS;CAC3D,MAAM,EAAE,UAAU,UAAU,WAAW,UAAU,aAAa,OAAO,WAAW,WAAW;CAC3F,MAAM,aAAa;CAEnB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAG5E,MAAMC,kBAA+C;EACnD,GAHuB,aAAa,SAAS;EAI7C,GAAG;EACJ;AAED,QACE,qBAAC,YAAA;EAAW,WAAW,GAAW,OAAO,cAAc;EAAE,eAAa;EAAQ,oBAAkB,YAAY;aAC1G,oBAAC,OAAA;GACC,WAAW,GAAW,OAAO,2BAA2B,GACrD,OAAO,uCAAuC,CAAC,UACjD,CAAC;GACF,OAAO,EACL,WAAW,WAAW,SAAS,MAAM,iBACtC;GAEA;IACG,EACN,oBAAC,UAAA;GACC,MAAK;GACL,WAAW,GAAW,OAAO,0BAA0B,GACpD,OAAO,qCAAqC,UAC9C,CAAC;GACF,SAAS;GACT,iBAAe;GACf,iBAAe;aAEd,WAAW,gBAAgB,mBAAmB,gBAAgB;IACxD,CAAA;GACE;;AChEjB,IAAA,wBDoEe"}
1
+ {"version":3,"file":"index.js","names":["ArticleTeaser: React.FC<ArticleTeaserProps>","mergedResources: HNDesignsystemArticleTeaser"],"sources":["../../../src/resources/HN.Designsystem.ArticleTeaser.en-GB.json","../../../src/resources/HN.Designsystem.ArticleTeaser.nb-NO.json","../../../src/components/ArticleTeaser/resourceHelper.ts","../../../src/components/ArticleTeaser/ArticleTeaser.tsx","../../../src/components/ArticleTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonClose\": \"Show more\",\n \"expandButtonOpen\": \"Show less\"\n}\n","{\n \"expandButtonClose\": \"Vis mer\",\n \"expandButtonOpen\": \"Vis mindre\"\n}\n","import type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.ArticleTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.ArticleTeaser.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemArticleTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import classNames from 'classnames';\n\nimport type { HNDesignsystemArticleTeaser } from '../../resources/Resources';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useLanguage } from '../../hooks/useLanguage';\n\nimport styles from './styles.module.scss';\n\nexport type ArticleTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface ArticleTeaserProps {\n /** Callback for the button. Should be used for setting the expanded boolean */\n onExpand: () => void;\n /** What's in the box? */\n children: React.ReactNode;\n /** Id of the content, used to set aria-controls */\n contentId: string;\n /** If the component is expanded or not */\n expanded: boolean;\n /** For overriding the height of the collapsed teaser */\n heightCollapsed?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: ArticleTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemArticleTeaser>;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst ArticleTeaser: React.FC<ArticleTeaserProps> = props => {\n const { onExpand, children, contentId, expanded, htmlMarkup = 'div', resources, testId } = props;\n const WrapperTag = htmlMarkup;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemArticleTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n return (\n <WrapperTag className={classNames(styles.articleteaser)} data-testid={testId} data-analyticsid={AnalyticsId.ArticleTeaser}>\n <div\n className={classNames(styles['articleteaser__content'], {\n [styles['articleteaser__content--collapsed']]: !expanded,\n })}\n style={{\n maxHeight: expanded ? 'none' : props.heightCollapsed,\n }}\n >\n {children}\n </div>\n <button\n type=\"button\"\n className={classNames(styles['articleteaser__button'], {\n [styles['articleteaser__button--expanded']]: expanded,\n })}\n onClick={onExpand}\n aria-expanded={expanded}\n aria-controls={contentId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default ArticleTeaser;\n","import ArticleTeaser from './ArticleTeaser';\nexport * from './ArticleTeaser';\nexport default ArticleTeaser;\n"],"mappings":";;;;;;;;;;;;;AEMA,MAAa,gBAAgB,aAA2D;AACtF,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACmBb,IAAMA,iBAA8C,UAAS;CAC3D,MAAM,EAAE,UAAU,UAAU,WAAW,UAAU,aAAa,OAAO,WAAW,WAAW;CAC3F,MAAM,aAAa;CAEnB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAG5E,MAAMC,kBAA+C;EACnD,GAHuB,aAAa,SAAS;EAI7C,GAAG;EACJ;AAED,QACE,qBAAC,YAAA;EAAW,WAAW,WAAW,OAAO,cAAc;EAAE,eAAa;EAAQ,oBAAkB,YAAY;aAC1G,oBAAC,OAAA;GACC,WAAW,WAAW,OAAO,2BAA2B,GACrD,OAAO,uCAAuC,CAAC,UACjD,CAAC;GACF,OAAO,EACL,WAAW,WAAW,SAAS,MAAM,iBACtC;GAEA;IACG,EACN,oBAAC,UAAA;GACC,MAAK;GACL,WAAW,WAAW,OAAO,0BAA0B,GACpD,OAAO,qCAAqC,UAC9C,CAAC;GACF,SAAS;GACT,iBAAe;GACf,iBAAe;aAEd,WAAW,gBAAgB,mBAAmB,gBAAgB;IACxD,CAAA;GACE;;AChEjB,IAAA,wBDoEe"}
@@ -1,16 +1,16 @@
1
- import { PaletteNames } from '../../theme/palette';
2
- import { ChipSize, ChipAction, ChipVariant } from './constants';
3
- export type ChipColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;
4
1
  export interface ChipProps {
5
2
  /** Sets the text of the chip */
6
3
  children: string;
7
- /** Sets the size of the chip. Default: medium */
8
- size?: keyof typeof ChipSize;
9
- /** Sets the background of the chip. Not used if action is "undo". Default: blueberry */
10
- color?: ChipColors;
11
- variant?: keyof typeof ChipVariant;
12
- action: keyof typeof ChipAction;
13
- onClick: () => void;
4
+ /** Wether or not to have a close button */
5
+ withCloseButton?: boolean;
6
+ /** onClick handler for text-part of the chip */
7
+ onChipClick?: () => void;
8
+ /** Button props for main chip button */
9
+ chipButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
10
+ /** onClick handler for close button */
11
+ onCloseClick?: () => void;
12
+ /** Button props for the close button */
13
+ closeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
14
14
  /** Sets the data-testid attribute on the expander button. */
15
15
  testId?: string;
16
16
  }
@@ -1,4 +1,3 @@
1
1
  import { default as Chip } from './Chip';
2
- export { ChipSize, ChipAction, ChipVariant } from './constants';
3
2
  export * from './Chip';
4
3
  export default Chip;
@@ -1,54 +1,42 @@
1
1
  import { a as IconSize, n as AnalyticsId } from "../../constants2.js";
2
- import { t as usePseudoClasses } from "../../usePseudoClasses.js";
3
- import { t as palette } from "../../palette.js";
4
2
  import { t as Icon_default } from "../../Icon.js";
5
- import { t as Undo_default } from "../../Undo.js";
6
3
  import { t as X_default } from "../../X.js";
7
- import cn from "classnames";
4
+ import classNames from "classnames";
8
5
  import { jsx, jsxs } from "react/jsx-runtime";
9
6
  import styles from "./styles.module.scss";
10
- let ChipSize = /* @__PURE__ */ function(ChipSize$1) {
11
- ChipSize$1["medium"] = "medium";
12
- ChipSize$1["large"] = "large";
13
- return ChipSize$1;
14
- }({});
15
- let ChipAction = /* @__PURE__ */ function(ChipAction$1) {
16
- ChipAction$1["remove"] = "remove";
17
- ChipAction$1["undo"] = "undo";
18
- return ChipAction$1;
19
- }({});
20
- let ChipVariant = /* @__PURE__ */ function(ChipVariant$1) {
21
- ChipVariant$1["normal"] = "normal";
22
- ChipVariant$1["oncolor"] = "oncolor";
23
- ChipVariant$1["emphasised"] = "emphasised";
24
- return ChipVariant$1;
25
- }({});
26
7
  var Chip = (props) => {
27
- const { children, size = ChipSize.medium, color = "blueberry", variant = "normal", action, onClick, testId } = props;
28
- const { refObject, isHovered } = usePseudoClasses();
29
- const chipClasses = cn(styles.chip, styles[`chip--${size}`], styles[`chip--${color}`], styles[`chip--${variant}`], { [styles[`chip--undo`]]: action === "undo" });
30
- const getActionIcon = () => {
31
- switch (action) {
32
- case "undo": return Undo_default;
33
- case "remove": return X_default;
34
- }
35
- };
36
- return /* @__PURE__ */ jsxs("button", {
37
- className: chipClasses,
38
- onClick,
39
- ref: refObject,
40
- type: "button",
41
- "data-testid": testId,
42
- "data-analyticsid": AnalyticsId.Tag,
43
- children: [children, /* @__PURE__ */ jsx(Icon_default, {
44
- svgIcon: getActionIcon(),
45
- size: IconSize.XXSmall,
46
- color: palette[`${color}800`],
47
- isHovered
8
+ const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true } = props;
9
+ return /* @__PURE__ */ jsxs("div", {
10
+ className: styles["chip"],
11
+ children: [/* @__PURE__ */ jsx("button", {
12
+ ...chipButtonProps,
13
+ className: classNames(styles["chip__chip"]),
14
+ onClick: onChipClick,
15
+ type: "button",
16
+ "data-testid": testId,
17
+ "data-analyticsid": AnalyticsId.Tag,
18
+ children: /* @__PURE__ */ jsx("span", {
19
+ className: classNames(styles["chip__chip__inner"], { [styles["chip__chip__inner--without-close"]]: !withCloseButton }),
20
+ children
21
+ })
22
+ }), withCloseButton && /* @__PURE__ */ jsx("button", {
23
+ ...closeButtonProps,
24
+ className: classNames(styles["chip__close"]),
25
+ onClick: onCloseClick,
26
+ type: "button",
27
+ "data-testid": `${testId}-close`,
28
+ "data-analyticsid": AnalyticsId.Tag,
29
+ children: /* @__PURE__ */ jsx("span", {
30
+ className: styles["chip__close__inner"],
31
+ children: /* @__PURE__ */ jsx(Icon_default, {
32
+ svgIcon: X_default,
33
+ size: IconSize.XXSmall
34
+ })
35
+ })
48
36
  })]
49
37
  });
50
38
  };
51
39
  var Chip_default = Chip;
52
- export { ChipAction, ChipSize, ChipVariant, Chip_default as default };
40
+ export { Chip_default as default };
53
41
 
54
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Chip: React.FC<ChipProps>"],"sources":["../../../src/components/Chip/constants.ts","../../../src/components/Chip/Chip.tsx","../../../src/components/Chip/index.ts"],"sourcesContent":["export enum ChipSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ChipAction {\n remove = 'remove',\n undo = 'undo',\n}\n\nexport enum ChipVariant {\n normal = 'normal',\n oncolor = 'oncolor',\n emphasised = 'emphasised',\n}\n","import cn from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { SvgIcon } from '../Icon';\n\nimport { ChipSize, type ChipAction, type ChipVariant } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { palette } from '../../theme/palette';\nimport Icon, { IconSize } from '../Icon';\nimport Undo from '../Icons/Undo';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport type ChipColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;\n\nexport interface ChipProps {\n /** Sets the text of the chip */\n children: string;\n /** Sets the size of the chip. Default: medium */\n size?: keyof typeof ChipSize;\n /** Sets the background of the chip. Not used if action is \"undo\". Default: blueberry */\n color?: ChipColors;\n /* Changes the appearance of the chip. Not used if action is \"undo\". Default: normal */\n variant?: keyof typeof ChipVariant;\n /* Makes the chip a clickable button that performs an action. onClick must also be set. */\n action: keyof typeof ChipAction;\n /* Called when action is set and the chip is clicked on. action must also be set. */\n onClick: () => void;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst Chip: React.FC<ChipProps> = props => {\n const { children, size = ChipSize.medium, color = 'blueberry', variant = 'normal', action, onClick, testId } = props;\n\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement>();\n\n const chipClasses = cn(styles.chip, styles[`chip--${size}`], styles[`chip--${color}`], styles[`chip--${variant}`], {\n [styles[`chip--undo`]]: action === 'undo',\n });\n\n const getActionIcon = (): SvgIcon => {\n switch (action) {\n case 'undo':\n return Undo;\n case 'remove':\n return X;\n }\n };\n\n return (\n <button className={chipClasses} onClick={onClick} ref={refObject} type=\"button\" data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {children}\n <Icon svgIcon={getActionIcon()} size={IconSize.XXSmall} color={palette[`${color}800`]} isHovered={isHovered} />\n </button>\n );\n};\n\nexport default Chip;\n","import Chip from './Chip';\nexport { ChipSize, ChipAction, ChipVariant } from './constants';\nexport * from './Chip';\nexport default Chip;\n"],"mappings":";;;;;;;;;AAAA,IAAY,WAAA,yBAAA,YAAL;AACL,YAAA,YAAA;AACA,YAAA,WAAA;;;AAGF,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,YAAA;AACA,cAAA,UAAA;;;AAGF,IAAY,cAAA,yBAAA,eAAL;AACL,eAAA,YAAA;AACA,eAAA,aAAA;AACA,eAAA,gBAAA;;;ACqBF,IAAMA,QAA4B,UAAS;CACzC,MAAM,EAAE,UAAU,OAAO,SAAS,QAAQ,QAAQ,aAAa,UAAU,UAAU,QAAQ,SAAS,WAAW;CAE/G,MAAM,EAAE,WAAW,cAAc,kBAAqC;CAEtE,MAAM,cAAc,GAAG,OAAO,MAAM,OAAO,SAAS,SAAS,OAAO,SAAS,UAAU,OAAO,SAAS,YAAY,GAChH,OAAO,gBAAgB,WAAW,QACpC,CAAC;CAEF,MAAM,sBAA+B;AACnC,UAAQ,QAAR;GACE,KAAK,OACH,QAAO;GACT,KAAK,SACH,QAAO;;;AAIb,QACE,qBAAC,UAAA;EAAO,WAAW;EAAsB;EAAS,KAAK;EAAW,MAAK;EAAS,eAAa;EAAQ,oBAAkB,YAAY;aAChI,UACD,oBAAC,cAAA;GAAK,SAAS,eAAe;GAAE,MAAM,SAAS;GAAS,OAAO,QAAQ,GAAG,MAAM;GAAkB;IAAa,CAAA;GACxG;;ACrDb,IAAA,eDyDe"}
1
+ {"version":3,"file":"index.js","names":["Chip: React.FC<ChipProps>"],"sources":["../../../src/components/Chip/Chip.tsx","../../../src/components/Chip/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport Icon, { IconSize } from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface ChipProps {\n /** Sets the text of the chip */\n children: string;\n /** Wether or not to have a close button */\n withCloseButton?: boolean;\n /** onClick handler for text-part of the chip */\n onChipClick?: () => void;\n /** Button props for main chip button */\n chipButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** onClick handler for close button */\n onCloseClick?: () => void;\n /** Button props for the close button */\n closeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst Chip: React.FC<ChipProps> = props => {\n const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true } = props;\n\n return (\n <div className={styles['chip']}>\n <button\n {...chipButtonProps}\n className={classNames(styles['chip__chip'])}\n onClick={onChipClick}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span\n className={classNames(styles['chip__chip__inner'], {\n [styles['chip__chip__inner--without-close']]: !withCloseButton,\n })}\n >\n {children}\n </span>\n </button>\n {withCloseButton && (\n <button\n {...closeButtonProps}\n className={classNames(styles['chip__close'])}\n onClick={onCloseClick}\n type=\"button\"\n data-testid={`${testId}-close`}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span className={styles['chip__close__inner']}>\n <Icon svgIcon={X} size={IconSize.XXSmall} />\n </span>\n </button>\n )}\n </div>\n );\n};\n\nexport default Chip;\n","import Chip from './Chip';\nexport * from './Chip';\nexport default Chip;\n"],"mappings":";;;;;;AAyBA,IAAMA,QAA4B,UAAS;CACzC,MAAM,EAAE,UAAU,aAAa,cAAc,iBAAiB,kBAAkB,QAAQ,kBAAkB,SAAS;AAEnH,QACE,qBAAC,OAAA;EAAI,WAAW,OAAO;aACrB,oBAAC,UAAA;GACC,GAAI;GACJ,WAAW,WAAW,OAAO,cAAc;GAC3C,SAAS;GACT,MAAK;GACL,eAAa;GACb,oBAAkB,YAAY;aAE9B,oBAAC,QAAA;IACC,WAAW,WAAW,OAAO,sBAAsB,GAChD,OAAO,sCAAsC,CAAC,iBAChD,CAAC;IAED;KACI;IACA,EACR,mBACC,oBAAC,UAAA;GACC,GAAI;GACJ,WAAW,WAAW,OAAO,eAAe;GAC5C,SAAS;GACT,MAAK;GACL,eAAa,GAAG,OAAO;GACvB,oBAAkB,YAAY;aAE9B,oBAAC,QAAA;IAAK,WAAW,OAAO;cACtB,oBAAC,cAAA;KAAK,SAAS;KAAG,MAAM,SAAS;MAAW;KACvC;IACA,CAAA;GAEP;;AC1DV,IAAA,eD8De"}
@@ -1,96 +1,91 @@
1
1
  @use 'sass:map';
2
- @use '../../scss/spacers' as spacers;
3
- @use '../../scss/palette' as palette;
2
+ @use '../../scss/breakpoints' as breakpoints;
3
+ @import '../../scss/supernova/styles/colors.css';
4
4
 
5
5
  .chip {
6
- $chip: &;
6
+ display: flex;
7
+ flex-flow: row nowrap;
8
+ height: 2.75rem;
7
9
 
8
- display: inline-flex;
9
- justify-content: space-between;
10
- align-items: center;
11
- text-transform: uppercase;
12
- border-width: 1px;
13
- border-style: solid;
14
- background-color: transparent;
10
+ .chip__chip:focus-visible,
11
+ .chip__close:focus-visible {
12
+ z-index: 1;
13
+ }
15
14
 
16
- // komponenten bruker ekstra liten font-size og line-height
17
- font-size: 0.875rem;
18
- line-height: 1.125rem;
19
- font-weight: 600;
20
- border-radius: 100px;
21
- cursor: pointer;
22
- font-family: inherit;
15
+ &__chip,
16
+ &__close {
17
+ height: 2.75rem;
18
+ background-color: transparent;
19
+ align-self: flex-start;
20
+ padding: 0;
21
+ border: unset;
22
+ outline: unset;
23
+ cursor: pointer;
23
24
 
24
- $colors: 'blueberry', 'neutral', 'cherry', 'banana', 'kiwi', 'plum';
25
+ &__inner {
26
+ display: block;
27
+ box-sizing: border-box;
28
+ height: 1.625rem;
29
+ line-height: 1.25rem;
30
+ background-color: var(--core-color-blueberry-50);
31
+ border: 1px solid var(--core-color-blueberry-500);
25
32
 
26
- @each $color in $colors {
27
- &--#{$color},
28
- // Sørg for at fargene overstyrer dersom chip har type=button
29
- &--#{$color}[type='button'] {
30
- // banana og kiwi har unntak fra hovedregelen
31
- @if $color == 'banana' {
32
- color: map.get(palette.$palette-map, #{$color}900);
33
- border-color: map.get(palette.$palette-map, #{$color}300);
34
- } @else if $color == 'kiwi' {
35
- color: map.get(palette.$palette-map, #{$color}900);
36
- border-color: map.get(palette.$palette-map, #{$color}200);
37
- } @else {
38
- color: map.get(palette.$palette-map, #{$color}800);
39
- border-color: map.get(palette.$palette-map, #{$color}200);
33
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
34
+ height: 1.875rem;
40
35
  }
41
36
 
42
- &#{$chip}--normal {
43
- &:hover {
44
- background-color: rgba-to-rgb(rgba(map.get(palette.$palette-map, #{$color}200), 0.2));
45
- }
37
+ .chip__chip:hover &,
38
+ .chip__close:hover & {
39
+ background-color: var(--core-color-blueberry-100);
46
40
  }
47
41
 
48
- &#{$chip}--oncolor {
49
- background-color: transparent;
50
-
51
- &:hover {
52
- background-color: map.get(palette.$palette-map, #{$color}100);
53
- border-color: map.get(palette.$palette-map, #{$color}100);
54
- }
55
-
56
- &:focus {
57
- background-color: palette.$white;
58
- border-color: palette.$white;
59
- box-shadow: 0 0 0 3px palette.$black;
60
- }
42
+ .chip__chip:active &,
43
+ .chip__close:active & {
44
+ background-color: var(--core-color-blueberry-200);
61
45
  }
62
46
 
63
- &#{$chip}--emphasised {
64
- background-color: map.get(palette.$palette-map, #{$color}50);
65
-
66
- &:hover {
67
- @if $color == 'banana' {
68
- background-color: rgba-to-rgb(rgba(map.get(palette.$palette-map, #{$color}300), 0.5));
69
- } @else {
70
- background-color: rgba-to-rgb(rgba(map.get(palette.$palette-map, #{$color}200), 0.5));
71
- }
72
- }
47
+ .chip__chip:focus-visible &,
48
+ .chip__close:focus-visible & {
49
+ outline: 3px solid var(--color-action-border-onlight-focus);
73
50
  }
74
51
  }
75
52
  }
76
53
 
77
- &:focus {
78
- outline: none;
79
- border-color: palette.$black;
80
- box-shadow: inset 0 0 0 2px palette.$black;
81
- }
54
+ &__chip {
55
+ &__inner {
56
+ border-radius: 100px 0 0 100px;
57
+ padding-right: 0.375rem;
58
+ padding-left: 0.75rem;
59
+ padding-top: 0.1875rem;
60
+ text-transform: uppercase;
61
+ font-size: 0.875rem;
62
+ font-weight: 600;
63
+ color: var(--core-color-blueberry-800);
64
+ text-wrap: nowrap;
82
65
 
83
- &#{$chip}--undo {
84
- text-decoration: line-through;
85
- }
66
+ @media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
67
+ padding-top: 0.3125rem;
68
+ font-size: 1rem;
69
+ }
86
70
 
87
- &--medium {
88
- padding: 0 spacers.getSpacer(3xs) 0 spacers.getSpacer(xs);
89
- min-height: 1.875rem;
71
+ &--without-close {
72
+ border-radius: 100px;
73
+ padding-right: 0.75rem;
74
+ }
75
+ }
90
76
  }
91
77
 
92
- &--large {
93
- padding: spacers.getSpacer(4xs) spacers.getSpacer(3xs) spacers.getSpacer(4xs) spacers.getSpacer(xs);
94
- min-height: 2.125rem;
78
+ &__close {
79
+ &__inner {
80
+ border-radius: 0 100px 100px 0;
81
+ border-left: 0;
82
+ padding-right: 0.25rem;
83
+ display: flex;
84
+ align-items: center;
85
+
86
+ svg {
87
+ fill: var(--color-action-graphics-onlight);
88
+ }
89
+ }
95
90
  }
96
91
  }
@@ -1,17 +1,10 @@
1
1
  export type Styles = {
2
2
  chip: string;
3
- 'chip--banana': string;
4
- 'chip--blueberry': string;
5
- 'chip--cherry': string;
6
- 'chip--emphasised': string;
7
- 'chip--kiwi': string;
8
- 'chip--large': string;
9
- 'chip--medium': string;
10
- 'chip--neutral': string;
11
- 'chip--normal': string;
12
- 'chip--oncolor': string;
13
- 'chip--plum': string;
14
- 'chip--undo': string;
3
+ chip__chip: string;
4
+ chip__chip__inner: string;
5
+ 'chip__chip__inner--without-close': string;
6
+ chip__close: string;
7
+ chip__close__inner: string;
15
8
  };
16
9
 
17
10
  export type ClassNames = keyof Styles;
@@ -18,7 +18,7 @@ import { t as ChevronDown_default } from "../../ChevronDown.js";
18
18
  import { t as ChevronUp_default } from "../../ChevronUp.js";
19
19
  import { t as PlusSmall_default } from "../../PlusSmall.js";
20
20
  import { t as Label_default } from "../../Label.js";
21
- import cn from "classnames";
21
+ import classNames from "classnames";
22
22
  import React, { useEffect, useId, useRef } from "react";
23
23
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
24
  import { clamp } from "motion/react";
@@ -81,14 +81,14 @@ const DropdownBase = (props) => {
81
81
  ...getResources(language),
82
82
  ...resources
83
83
  };
84
- const toggleClasses = cn(styles.dropdown__toggle, {
84
+ const toggleClasses = classNames(styles.dropdown__toggle, {
85
85
  [styles["dropdown__toggle--open"]]: isOpen && !disabled,
86
86
  [styles["dropdown__toggle--with-icon"]]: typeof svgIcon !== "undefined",
87
87
  [styles["dropdown__toggle--transparent"]]: variant === "transparent",
88
88
  [styles["dropdown__toggle--borderless"]]: variant === "borderless"
89
89
  });
90
- const contentClasses = cn(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
91
- const listItemClasses = cn(styles["dropdown__list-item"], { [styles["dropdown__list-item--single-select"]]: isSingleSelect });
90
+ const contentClasses = classNames(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
91
+ const listItemClasses = classNames(styles["dropdown__list-item"], { [styles["dropdown__list-item--single-select"]]: isSingleSelect });
92
92
  const { refs, floatingStyles } = useFloating({
93
93
  strategy: "fixed",
94
94
  placement: "bottom-start",
@@ -185,7 +185,7 @@ const DropdownBase = (props) => {
185
185
  const label = element.props.label;
186
186
  if (React.isValidElement(label) && isComponent(label, Label_default)) return React.cloneElement(element, {
187
187
  ref: mergeRefs([element.props.ref, childrenRefList.current[index]]),
188
- label: React.cloneElement(label, { labelClassName: cn(label.props?.labelClassName, styles["dropdown__multiselect-item"]) })
188
+ label: React.cloneElement(label, { labelClassName: classNames(label.props?.labelClassName, styles["dropdown__multiselect-item"]) })
189
189
  });
190
190
  }
191
191
  return React.cloneElement(child, { ref: mergeRefs([element.props.ref, childrenRefList.current[index]]) });