@helsenorge/designsystem-react 13.0.0-workspaces-beta.6 → 13.0.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.
- package/fonts/source-sans-pro-200-extralight-italic.woff +0 -0
- package/fonts/source-sans-pro-200-extralight-italic.woff2 +0 -0
- package/fonts/source-sans-pro-200-extralight.woff +0 -0
- package/fonts/source-sans-pro-200-extralight.woff2 +0 -0
- package/fonts/source-sans-pro-300-light-italic.woff +0 -0
- package/fonts/source-sans-pro-300-light-italic.woff2 +0 -0
- package/fonts/source-sans-pro-300-light.woff +0 -0
- package/fonts/source-sans-pro-300-light.woff2 +0 -0
- package/fonts/source-sans-pro-400-regular-italic.woff +0 -0
- package/fonts/source-sans-pro-400-regular-italic.woff2 +0 -0
- package/fonts/source-sans-pro-400-regular.woff +0 -0
- package/fonts/source-sans-pro-400-regular.woff2 +0 -0
- package/fonts/source-sans-pro-600-semibold-italic.woff +0 -0
- package/fonts/source-sans-pro-600-semibold-italic.woff2 +0 -0
- package/fonts/source-sans-pro-600-semibold.woff +0 -0
- package/fonts/source-sans-pro-600-semibold.woff2 +0 -0
- package/fonts/source-sans-pro-700-bold-italic.woff +0 -0
- package/fonts/source-sans-pro-700-bold-italic.woff2 +0 -0
- package/fonts/source-sans-pro-700-bold.woff +0 -0
- package/fonts/source-sans-pro-700-bold.woff2 +0 -0
- package/fonts/source-sans-pro-900-black-italic.woff +0 -0
- package/fonts/source-sans-pro-900-black-italic.woff2 +0 -0
- package/fonts/source-sans-pro-900-black.woff +0 -0
- package/fonts/source-sans-pro-900-black.woff2 +0 -0
- package/lib/AnchorLink.js +14 -6
- package/lib/AnchorLink.js.map +1 -1
- package/lib/AsChildSlot.js +2 -1
- package/lib/AsChildSlot.js.map +1 -1
- package/lib/Avatar.js +2 -2
- package/lib/Avatar.js.map +1 -1
- package/lib/Badge.js +2 -2
- package/lib/Badge.js.map +1 -1
- package/lib/Button.js +6 -6
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +52 -0
- package/lib/Checkbox.js +7 -7
- package/lib/Checkbox.js.map +1 -1
- package/lib/Close.js +4 -4
- package/lib/Close.js.map +1 -1
- package/lib/DictionaryTrigger.js +2 -2
- package/lib/DictionaryTrigger.js.map +1 -1
- package/lib/Drawer.js +5 -5
- package/lib/Drawer.js.map +1 -1
- package/lib/Duolist.js +5 -5
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js +9 -9
- package/lib/ElementHeader.js.map +1 -1
- package/lib/ElementHeaderText.js +4 -4
- package/lib/ElementHeaderText.js.map +1 -1
- package/lib/ErrorWrapper.js +2 -2
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +7 -7
- package/lib/Expander.js.map +1 -1
- package/lib/FormFieldTag.js +32 -2
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +5 -5
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +3 -3
- package/lib/FormLayout.js.map +1 -1
- package/lib/HelpDetails.js +3 -3
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js +3 -3
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js +3 -3
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/HighlightPanel.js +3 -3
- package/lib/HighlightPanel.js.map +1 -1
- package/lib/HorizontalScroll.js +4 -4
- package/lib/HorizontalScroll.js.map +1 -1
- package/lib/Icon.js +2 -2
- package/lib/Icon.js.map +1 -1
- package/lib/InfoTeaser.js +3 -3
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +5 -6
- package/lib/Input.js.map +1 -1
- package/lib/Label.js +5 -5
- package/lib/Label.js.map +1 -1
- package/lib/LinkList.js +5 -5
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +4 -4
- package/lib/ListEditMode.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/Panel.js +12 -12
- package/lib/Panel.js.map +1 -1
- package/lib/PanelOld.js +14 -14
- package/lib/PanelOld.js.map +1 -1
- package/lib/PanelTitle.js +2 -2
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/RadioButton.js +5 -5
- package/lib/RadioButton.js.map +1 -1
- package/lib/Select.js +4 -4
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js +5 -5
- package/lib/SingleSelectItem.js.map +1 -1
- package/lib/Slider.js +4 -4
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +2 -2
- package/lib/Spacer.js.map +1 -1
- package/lib/StatusDot.js +4 -4
- package/lib/StatusDot.js.map +1 -1
- package/lib/StatusDotList.js +2 -2
- package/lib/StatusDotList.js.map +1 -1
- package/lib/StepButtons.js +5 -5
- package/lib/StepButtons.js.map +1 -1
- package/lib/TabList.js +8 -8
- package/lib/TabList.js.map +1 -1
- package/lib/TabPanel.js +2 -2
- package/lib/TabPanel.js.map +1 -1
- package/lib/Table.js +2 -2
- package/lib/Table.js.map +1 -1
- package/lib/TableBody.js +2 -2
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +2 -2
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +4 -4
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +2 -2
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +2 -2
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +3 -3
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +3 -3
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +4 -4
- package/lib/Textarea.js.map +1 -1
- package/lib/Title.js +2 -2
- package/lib/Title.js.map +1 -1
- package/lib/Toast.js +3 -3
- package/lib/Toast.js.map +1 -1
- package/lib/components/AnchorLink/AnchorLink.d.ts +2 -0
- package/lib/components/AnchorLink/index.js +2 -0
- package/lib/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/AsChildSlot/styles.module.scss +0 -1
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Checkbox/index.js +1 -1
- package/lib/components/Chip/index.js +2 -2
- package/lib/components/Chip/index.js.map +1 -1
- package/lib/components/Close/index.js +1 -1
- package/lib/components/Drawer/index.js +1 -1
- package/lib/components/Dropdown/index.js +7 -7
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/DropdownOld/index.js +4 -4
- package/lib/components/DropdownOld/index.js.map +1 -1
- package/lib/components/ElementHeader/styles.module.scss +1 -5
- package/lib/components/EmptyState/index.js +2 -2
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/index.js +7 -7
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +7 -7
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/FavoriteButton/FavoriteButton.d.ts +1 -1
- package/lib/components/FavoriteButton/index.js +3 -4
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/FormGroup/index.js +1 -1
- package/lib/components/HelpBubble/index.js +5 -4
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpDrawer/index.js +4 -3
- package/lib/components/HelpDrawer/index.js.map +1 -1
- package/lib/components/HelpExpanderStandalone/index.js +2 -2
- package/lib/components/HelpExpanderStandalone/index.js.map +1 -1
- package/lib/components/HelpPanel/index.js +2 -2
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpTriggerInline/index.js +3 -3
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/Input/index.js +1 -1
- package/lib/components/Loader/index.js +4 -4
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Modal/index.js +10 -10
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +7 -7
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/PanelList/index.js +3 -3
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PanelListOld/index.js +2 -2
- package/lib/components/PanelListOld/index.js.map +1 -1
- package/lib/components/PopMenu/index.js +3 -3
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +2 -2
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js +2 -2
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/RadioButton/index.js +1 -1
- package/lib/components/RadioButton/styles.module.scss +0 -23
- package/lib/components/ServiceMessage/index.js +6 -6
- package/lib/components/ServiceMessage/index.js.map +1 -1
- package/lib/components/SharingStatus/index.js +4 -4
- package/lib/components/SharingStatus/index.js.map +1 -1
- package/lib/components/Step/index.js +2 -2
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.js +2 -2
- package/lib/components/Stepper/index.js.map +1 -1
- package/lib/components/StickyNote/index.js +9 -9
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/Tabs/index.js +4 -4
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/Tag/index.js +2 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/Tile/index.js +5 -5
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/Toast/index.js +1 -1
- package/lib/components/Toast/styles.module.scss +1 -1
- package/lib/components/ToastList/index.js +1 -1
- package/lib/components/Toggle/index.js +9 -9
- package/lib/components/Toggle/index.js.map +1 -1
- package/lib/components/Validation/index.js +4 -3
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/hooks/useKeyboardEvent.d.ts +4 -2
- package/lib/hooks/useOutsideEvent.d.ts +4 -2
- package/lib/resources/HN.Designsystem.FormFieldTag.en-GB.json.d.ts +12 -0
- package/lib/resources/HN.Designsystem.FormFieldTag.nn-NO.json.d.ts +12 -0
- package/lib/resources/HN.Designsystem.FormFieldTag.se-NO.json.d.ts +12 -0
- package/lib/resources/index.d.ts +0 -0
- package/lib/scss/_radio-reset.scss +21 -0
- package/lib/scss/helsenorge.scss +1 -0
- package/lib/useKeyboardEvent.js +4 -2
- package/lib/useKeyboardEvent.js.map +1 -1
- package/lib/useOutsideEvent.js +1 -1
- package/lib/useOutsideEvent.js.map +1 -1
- package/lib/uuid.js +2 -1
- package/lib/uuid.js.map +1 -1
- package/package.json +60 -4
- package/scss/_radio-reset.scss +21 -0
- package/scss/helsenorge.scss +1 -0
package/lib/FormFieldTag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldTag.js","names":["FormFieldTag: React.FC<FormFieldTagProps>","mergedResources: HNDesignsystemFormFieldTag"],"sources":["../src/resources/HN.Designsystem.FormFieldTag.nb-NO.json","../src/components/FormFieldTag/resourceHelper.ts","../src/components/FormFieldTag/FormFieldTag.tsx","../src/components/FormFieldTag/index.ts"],"sourcesContent":["{\n \"allRequired\": \"Alle felt må fylles ut\",\n \"requiredField\": \"Må fylles ut\",\n \"optional\": \"Valgfritt\",\n \"allOptional\": \"Alle felt er valgfrie\",\n \"requiredRadiobuttonList\": \"Velg én\",\n \"requiredCheckboxList\": \"Velg én eller flere\",\n \"requiredSingleCheckbox\": \"Må velges\"\n}\n","import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FormFieldTag.nb-NO.json';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFormFieldTag => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\n\nimport styles from './styles.module.scss';\n\nexport type FormFieldTagLevel =\n | 'all-required'\n | 'required-field'\n | 'optional'\n | 'all-optional'\n | 'required-radiobutton-list'\n | 'required-checkbox-list'\n | 'required-single-checkbox';\n\nexport interface FormFieldTagProps {\n /** Id that is placed on the component */\n id?: string;\n /** What level is the required tag, sets the styling and the text. */\n level: FormFieldTagLevel;\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFormFieldTag>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst FormFieldTag: React.FC<FormFieldTagProps> = props => {\n const { id, level, resources, testId } = props;\n const isOptional = level === 'optional' || level === 'all-optional';\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFormFieldTag = {\n ...defaultResources,\n ...resources,\n };\n\n const textMap = {\n 'all-required': mergedResources.allRequired,\n 'required-field': mergedResources.requiredField,\n optional: mergedResources.optional,\n 'all-optional': mergedResources.allOptional,\n 'required-radiobutton-list': mergedResources.requiredRadiobuttonList,\n 'required-checkbox-list': mergedResources.requiredCheckboxList,\n 'required-single-checkbox': mergedResources.requiredSingleCheckbox,\n };\n\n return (\n <span\n id={id}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FormFieldTag}\n className={classNames(styles['form-field-tag'], { [styles['form-field-tag--optional']]: isOptional })}\n >\n {textMap[level]}\n </span>\n );\n};\n\nexport default FormFieldTag;\n","import FormFieldTag from './FormFieldTag';\nexport * from './FormFieldTag';\nexport default FormFieldTag;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormFieldTag.js","names":["FormFieldTag: React.FC<FormFieldTagProps>","mergedResources: HNDesignsystemFormFieldTag"],"sources":["../src/resources/HN.Designsystem.FormFieldTag.en-GB.json","../src/resources/HN.Designsystem.FormFieldTag.nb-NO.json","../src/resources/HN.Designsystem.FormFieldTag.nn-NO.json","../src/resources/HN.Designsystem.FormFieldTag.se-NO.json","../src/components/FormFieldTag/resourceHelper.ts","../src/components/FormFieldTag/FormFieldTag.tsx","../src/components/FormFieldTag/index.ts"],"sourcesContent":["{\n \"allRequired\": \"All fields must be filled out\",\n \"requiredField\": \"Required\",\n \"optional\": \"Optional\",\n \"allOptional\": \"All fields are optional\",\n \"requiredRadiobuttonList\": \"Select one\",\n \"requiredCheckboxList\": \"Select one or more\",\n \"requiredSingleCheckbox\": \"Must be selected\"\n}\n","{\n \"allRequired\": \"Alle felt må fylles ut\",\n \"requiredField\": \"Må fylles ut\",\n \"optional\": \"Valgfritt\",\n \"allOptional\": \"Alle felt er valgfrie\",\n \"requiredRadiobuttonList\": \"Velg én\",\n \"requiredCheckboxList\": \"Velg én eller flere\",\n \"requiredSingleCheckbox\": \"Må velges\"\n}\n","{\n \"allRequired\": \"Alle felt må fyllast ut\",\n \"requiredField\": \"Må fyllast ut\",\n \"optional\": \"Valfritt\",\n \"allOptional\": \"Alle felt er valfrie\",\n \"requiredRadiobuttonList\": \"Vel éin\",\n \"requiredCheckboxList\": \"Vel éin eller fleire\",\n \"requiredSingleCheckbox\": \"Må veljast\"\n}\n","{\n \"allRequired\": \"Buot sajiid ferte deavdit\",\n \"requiredField\": \"Ferte devdojuvvot\",\n \"optional\": \"Válljenláhkái\",\n \"allOptional\": \"Buot sajit eat válljenláhkái\",\n \"requiredRadiobuttonList\": \"Vállje ovtta\",\n \"requiredCheckboxList\": \"Vállje ovtta dahje máŋga\",\n \"requiredSingleCheckbox\": \"Ferte válljejuvvot\"\n}\n","import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.FormFieldTag.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.FormFieldTag.nb-NO.json';\nimport nnNO from '../../resources/HN.Designsystem.FormFieldTag.nn-NO.json';\nimport seNO from '../../resources/HN.Designsystem.FormFieldTag.se-NO.json';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFormFieldTag => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN_NYNORSK:\n return nnNO;\n case LanguageLocales.SAMI_NORTHERN:\n return seNO;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemFormFieldTag } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\n\nimport styles from './styles.module.scss';\n\nexport type FormFieldTagLevel =\n | 'all-required'\n | 'required-field'\n | 'optional'\n | 'all-optional'\n | 'required-radiobutton-list'\n | 'required-checkbox-list'\n | 'required-single-checkbox';\n\nexport interface FormFieldTagProps {\n /** Id that is placed on the component */\n id?: string;\n /** What level is the required tag, sets the styling and the text. */\n level: FormFieldTagLevel;\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFormFieldTag>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst FormFieldTag: React.FC<FormFieldTagProps> = props => {\n const { id, level, resources, testId } = props;\n const isOptional = level === 'optional' || level === 'all-optional';\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFormFieldTag = {\n ...defaultResources,\n ...resources,\n };\n\n const textMap = {\n 'all-required': mergedResources.allRequired,\n 'required-field': mergedResources.requiredField,\n optional: mergedResources.optional,\n 'all-optional': mergedResources.allOptional,\n 'required-radiobutton-list': mergedResources.requiredRadiobuttonList,\n 'required-checkbox-list': mergedResources.requiredCheckboxList,\n 'required-single-checkbox': mergedResources.requiredSingleCheckbox,\n };\n\n return (\n <span\n id={id}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FormFieldTag}\n className={classNames(styles['form-field-tag'], { [styles['form-field-tag--optional']]: isOptional })}\n >\n {textMap[level]}\n </span>\n );\n};\n\nexport default FormFieldTag;\n","import FormFieldTag from './FormFieldTag';\nexport * from './FormFieldTag';\nexport default FormFieldTag;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIOA,MAAa,gBAAgB,aAA0D;AACrF,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB,kBACnB,QAAO;EACT,KAAK,gBAAgB,cACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACcb,IAAMA,gBAA4C,UAAS;CACzD,MAAM,EAAE,IAAI,OAAO,WAAW,WAAW;CACzC,MAAM,aAAa,UAAU,cAAc,UAAU;CAErD,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAG5E,MAAMC,kBAA8C;EAClD,GAHuB,aAAa,SAAS;EAI7C,GAAG;EACJ;CAED,MAAM,UAAU;EACd,gBAAgB,gBAAgB;EAChC,kBAAkB,gBAAgB;EAClC,UAAU,gBAAgB;EAC1B,gBAAgB,gBAAgB;EAChC,6BAA6B,gBAAgB;EAC7C,0BAA0B,gBAAgB;EAC1C,4BAA4B,gBAAgB;EAC7C;AAED,QACE,oBAAC,QAAA;EACK;EACJ,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW,GAAW,OAAO,mBAAmB,GAAG,OAAO,8BAA8B,YAAY,CAAC;YAEpG,QAAQ;GACJ;;AC3DX,IAAA,yBD+De"}
|
package/lib/FormGroup.js
CHANGED
|
@@ -12,7 +12,7 @@ import { t as Select_default } from "./Select.js";
|
|
|
12
12
|
import { t as Slider_default } from "./Slider.js";
|
|
13
13
|
import { t as Textarea_default } from "./Textarea.js";
|
|
14
14
|
import React, { useId, useState } from "react";
|
|
15
|
-
import
|
|
15
|
+
import cn from "classnames";
|
|
16
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
import formGroupStyles from "./components/FormGroup/styles.module.scss";
|
|
18
18
|
const FormGroup = React.forwardRef((props, ref) => {
|
|
@@ -22,10 +22,10 @@ const FormGroup = React.forwardRef((props, ref) => {
|
|
|
22
22
|
const errorTextId = useIdWithFallback(errorTextIdProp);
|
|
23
23
|
const onDark = onColor === FormOnColor.ondark;
|
|
24
24
|
const isLarge = size === FormSize.large;
|
|
25
|
-
const formGroupWrapperClasses =
|
|
26
|
-
const titleClasses =
|
|
27
|
-
const legendClasses =
|
|
28
|
-
const fieldsetClasses =
|
|
25
|
+
const formGroupWrapperClasses = cn(formGroupStyles["form-group-wrapper"], className);
|
|
26
|
+
const titleClasses = cn({ [formGroupStyles["form-group-wrapper__title--on-dark"]]: onDark && !error });
|
|
27
|
+
const legendClasses = cn(formGroupStyles["field-set__legend"], { [formGroupStyles["field-set__legend--on-dark"]]: onDark && !error }, legendClassName);
|
|
28
|
+
const fieldsetClasses = cn(formGroupStyles["field-set"], fieldsetClassName);
|
|
29
29
|
const mapFormComponent = (child, index) => {
|
|
30
30
|
if (isComponent(child, FormLayout_default)) return React.cloneElement(child, {
|
|
31
31
|
size,
|
package/lib/FormGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup.js","names":[],"sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormFieldTag, { FormFieldTagProps } from '../FormFieldTag';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Sets a tag that describes whether the form group is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n ariaLabelledBy,\n className,\n errorTextId: errorTextIdProp,\n fieldsetClassName,\n formFieldTag,\n legendClassName,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useId();\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onDark = onColor === FormOnColor.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextId,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextId,\n labelClassNames: getRadioLabelClasses(radioId, onColor as FormOnColor, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextId,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && (\n <>\n <h5 className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </h5>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && (\n <>\n <legend className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </legend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextId}\n errorMessageRef={ref}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"FormGroup.js","names":[],"sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormFieldTag, { FormFieldTagProps } from '../FormFieldTag';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Slider, { SliderProps } from '../Slider';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Sets a tag that describes whether the form group is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n ariaLabelledBy,\n className,\n errorTextId: errorTextIdProp,\n fieldsetClassName,\n formFieldTag,\n legendClassName,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useId();\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onDark = onColor === FormOnColor.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextId,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextId,\n labelClassNames: getRadioLabelClasses(radioId, onColor as FormOnColor, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextId,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && (\n <>\n <h5 className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </h5>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && (\n <>\n <legend className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </legend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextId}\n errorMessageRef={ref}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"mappings":"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"}
|
package/lib/FormLayout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as FormSize, n as AnalyticsId } from "./constants2.js";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import formGroupStyles from "./components/FormLayout/styles.module.scss";
|
|
6
6
|
let FormLayoutColumns = /* @__PURE__ */ function(FormLayoutColumns$1) {
|
|
@@ -14,8 +14,8 @@ let FormLayoutColumns = /* @__PURE__ */ function(FormLayoutColumns$1) {
|
|
|
14
14
|
const FormLayout = React.forwardRef((props, ref) => {
|
|
15
15
|
const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper } = props;
|
|
16
16
|
const cssVariable = { "--min-col-width": `${colMinWidth}px` };
|
|
17
|
-
const formLayoutContainerClasses =
|
|
18
|
-
const formLayoutChildClasses =
|
|
17
|
+
const formLayoutContainerClasses = cn(formGroupStyles["form-layout-container"], { [formGroupStyles["form-layout-container--large"]]: size === FormSize.large }, className);
|
|
18
|
+
const formLayoutChildClasses = cn(formGroupStyles["form-layout-child"], {
|
|
19
19
|
[formGroupStyles["form-layout-child--two"]]: columns === FormLayoutColumns.two,
|
|
20
20
|
[formGroupStyles["form-layout-child--three"]]: columns === FormLayoutColumns.three,
|
|
21
21
|
[formGroupStyles["form-layout-child--four"]]: columns === FormLayoutColumns.four,
|
package/lib/FormLayout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.js","names":[],"sources":["../src/components/FormLayout/FormLayout.tsx","../src/components/FormLayout/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormSize } from '../../constants';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n}\n\nexport const FormLayout = React.forwardRef((props: FormLayoutProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n","import FormLayout from './FormLayout';\nexport * from './FormLayout';\nexport default FormLayout;\n"],"mappings":";;;;;AAQA,IAAY,oBAAA,yBAAA,qBAAL;AACL,qBAAA,SAAA;AACA,qBAAA,SAAA;AACA,qBAAA,WAAA;AACA,qBAAA,UAAA;AACA,qBAAA,UAAA;;;AAoBF,MAAa,aAAa,MAAM,YAAY,OAAwB,QAA4C;CAC9G,MAAM,EAAE,YAAY,UAAU,kBAAkB,KAAK,cAAc,KAAK,MAAM,WAAW,cAAc;CAEvG,MAAM,cAAc,EAAE,mBAAmB,GAAG,YAAY,KAAK;CAC7D,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"FormLayout.js","names":[],"sources":["../src/components/FormLayout/FormLayout.tsx","../src/components/FormLayout/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormSize } from '../../constants';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n}\n\nexport const FormLayout = React.forwardRef((props: FormLayoutProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n","import FormLayout from './FormLayout';\nexport * from './FormLayout';\nexport default FormLayout;\n"],"mappings":";;;;;AAQA,IAAY,oBAAA,yBAAA,qBAAL;AACL,qBAAA,SAAA;AACA,qBAAA,SAAA;AACA,qBAAA,WAAA;AACA,qBAAA,UAAA;AACA,qBAAA,UAAA;;;AAoBF,MAAa,aAAa,MAAM,YAAY,OAAwB,QAA4C;CAC9G,MAAM,EAAE,YAAY,UAAU,kBAAkB,KAAK,cAAc,KAAK,MAAM,WAAW,cAAc;CAEvG,MAAM,cAAc,EAAE,mBAAmB,GAAG,YAAY,KAAK;CAC7D,MAAM,6BAA6B,GACjC,gBAAgB,0BAChB,GACG,gBAAgB,kCAAkC,SAAS,SAAS,OACtE,EACD,UACD;CACD,MAAM,yBAAyB,GAAW,gBAAgB,sBAAsB;GAC7E,gBAAgB,4BAA4B,YAAY,kBAAkB;GAC1E,gBAAgB,8BAA8B,YAAY,kBAAkB;GAC5E,gBAAgB,6BAA6B,YAAY,kBAAkB;GAC3E,gBAAgB,6BAA6B,YAAY,kBAAkB;EAC7E,CAAC;AAEF,QACE,oBAAC,OAAA;EACC,eAAa,MAAM;EACnB,oBAAkB,YAAY;EAC9B,OAAO;EACP,WAAW;EACN;YAEJ,MAAM,SAAS,IAAI,MAAM,WAAW,OAAwB,UAAkB;AAC7E,UAAO,oBAAC,OAAA;IAAI,WAAW;cAAyB,YAAY,UAAU,OAAO,MAAM,GAAG;KAAY;IAClG;GACE;EAER;AAEF,WAAW,cAAc;AChEzB,IAAA,uBDkEe"}
|
package/lib/HelpDetails.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as autoUpdate, d as arrow, g as size, m as offset, o as useFloating, t as FloatingArrow } from "./floating-ui.react.js";
|
|
2
2
|
import React, { useRef, useState } from "react";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import styles from "./components/HelpDetails/styles.module.scss";
|
|
6
6
|
var BUBBLE_WIDTH_OFFSET = 26;
|
|
@@ -24,8 +24,8 @@ var HelpDetails = React.forwardRef(({ children, controllerRef, testId }, ref) =>
|
|
|
24
24
|
whileElementsMounted: autoUpdate,
|
|
25
25
|
elements: { reference: controllerRef?.current }
|
|
26
26
|
});
|
|
27
|
-
const helpDetailsClasses =
|
|
28
|
-
const contentClasses =
|
|
27
|
+
const helpDetailsClasses = cn(styles["help-details"], controllerRef ? styles["help-details--inline"] : styles["help-details--standalone"]);
|
|
28
|
+
const contentClasses = cn(controllerRef ? styles["help-details__content--inline"] : styles["help-details__content--standalone"]);
|
|
29
29
|
return /* @__PURE__ */ jsxs("div", {
|
|
30
30
|
className: helpDetailsClasses,
|
|
31
31
|
"data-testid": testId,
|
package/lib/HelpDetails.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpDetails.js","names":[],"sources":["../src/components/HelpDetails/HelpDetails.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport { arrow, FloatingArrow, autoUpdate, useFloating, offset, size } from '@floating-ui/react';\nimport classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nconst BUBBLE_WIDTH_OFFSET = 26;\nconst BUBBLE_Y_OFFSET = 1;\n\nexport interface HelpDetailsProps {\n /** Sets the text content of the HelpDetails. */\n children: React.ReactNode;\n /** Ref for the element the HelpDetails is placed upon */\n controllerRef?: React.RefObject<HTMLButtonElement>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpDetails = React.forwardRef<HTMLDivElement, HelpDetailsProps>(({ children, controllerRef, testId }, ref) => {\n const arrowRef = useRef(null);\n const [bubbleMinWidth, setBubbleMinWidth] = React.useState<number | null>(null);\n const [arrowYOffsetValue, setArrowYOffsetValue] = useState<number>();\n\n const { refs, context, floatingStyles } = useFloating({\n middleware: [\n offset(arrowYOffsetValue),\n controllerRef && arrow({ element: arrowRef }),\n size({\n apply({ rects }) {\n // Vi setter minimum bredde på bubble basert på controllerRef sin x posisjon og halve bredden\n setBubbleMinWidth(rects.reference.x + rects.reference.width / 2);\n\n // Vi kalkulerer pilens y-offset basert på avstand mellom controllerRef og bubble\n const { reference, floating } = rects;\n const controllerBottom = reference.y + reference.height;\n const bubbleTop = floating.y;\n const distance = bubbleTop - controllerBottom + BUBBLE_Y_OFFSET;\n setArrowYOffsetValue(distance);\n },\n }),\n ],\n placement: 'bottom',\n whileElementsMounted: autoUpdate,\n elements: {\n reference: controllerRef?.current,\n },\n });\n\n const helpDetailsClasses = classNames(\n styles['help-details'],\n controllerRef ? styles['help-details--inline'] : styles['help-details--standalone']\n );\n const contentClasses = classNames(controllerRef ? styles['help-details__content--inline'] : styles['help-details__content--standalone']);\n\n return (\n <div\n className={helpDetailsClasses}\n data-testid={testId}\n ref={ref}\n style={{ minWidth: bubbleMinWidth ? `${bubbleMinWidth + BUBBLE_WIDTH_OFFSET}px` : undefined }}\n >\n <div style={floatingStyles} ref={refs.setFloating}>\n {controllerRef && typeof arrowYOffsetValue !== 'undefined' && (\n <FloatingArrow\n ref={arrowRef}\n context={context}\n fill={'var(--core-color-plum-50)'}\n stroke={'var(--core-color-plum-400)'}\n strokeWidth={1}\n />\n )}\n </div>\n <div className={contentClasses}>{children}</div>\n </div>\n );\n});\n\nHelpDetails.displayName = 'HelpDetails';\n\nexport default HelpDetails;\n"],"mappings":";;;;;AAOA,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAWxB,IAAM,cAAc,MAAM,YAA8C,EAAE,UAAU,eAAe,UAAU,QAAQ;CACnH,MAAM,WAAW,OAAO,KAAK;CAC7B,MAAM,CAAC,gBAAgB,qBAAqB,MAAM,SAAwB,KAAK;CAC/E,MAAM,CAAC,mBAAmB,wBAAwB,UAAkB;CAEpE,MAAM,EAAE,MAAM,SAAS,mBAAmB,YAAY;EACpD,YAAY;GACV,OAAO,kBAAkB;GACzB,iBAAiB,MAAM,EAAE,SAAS,UAAU,CAAC;GAC7C,KAAK,EACH,MAAM,EAAE,SAAS;AAEf,sBAAkB,MAAM,UAAU,IAAI,MAAM,UAAU,QAAQ,EAAE;IAGhE,MAAM,EAAE,WAAW,aAAa;IAChC,MAAM,mBAAmB,UAAU,IAAI,UAAU;AAGjD,yBAFkB,SAAS,IACE,mBAAmB,gBAClB;MAEjC,CAAC;GACH;EACD,WAAW;EACX,sBAAsB;EACtB,UAAU,EACR,WAAW,eAAe,SAC3B;EACF,CAAC;CAEF,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"HelpDetails.js","names":[],"sources":["../src/components/HelpDetails/HelpDetails.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport { arrow, FloatingArrow, autoUpdate, useFloating, offset, size } from '@floating-ui/react';\nimport classNames from 'classnames';\n\nimport styles from './styles.module.scss';\n\nconst BUBBLE_WIDTH_OFFSET = 26;\nconst BUBBLE_Y_OFFSET = 1;\n\nexport interface HelpDetailsProps {\n /** Sets the text content of the HelpDetails. */\n children: React.ReactNode;\n /** Ref for the element the HelpDetails is placed upon */\n controllerRef?: React.RefObject<HTMLButtonElement>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpDetails = React.forwardRef<HTMLDivElement, HelpDetailsProps>(({ children, controllerRef, testId }, ref) => {\n const arrowRef = useRef(null);\n const [bubbleMinWidth, setBubbleMinWidth] = React.useState<number | null>(null);\n const [arrowYOffsetValue, setArrowYOffsetValue] = useState<number>();\n\n const { refs, context, floatingStyles } = useFloating({\n middleware: [\n offset(arrowYOffsetValue),\n controllerRef && arrow({ element: arrowRef }),\n size({\n apply({ rects }) {\n // Vi setter minimum bredde på bubble basert på controllerRef sin x posisjon og halve bredden\n setBubbleMinWidth(rects.reference.x + rects.reference.width / 2);\n\n // Vi kalkulerer pilens y-offset basert på avstand mellom controllerRef og bubble\n const { reference, floating } = rects;\n const controllerBottom = reference.y + reference.height;\n const bubbleTop = floating.y;\n const distance = bubbleTop - controllerBottom + BUBBLE_Y_OFFSET;\n setArrowYOffsetValue(distance);\n },\n }),\n ],\n placement: 'bottom',\n whileElementsMounted: autoUpdate,\n elements: {\n reference: controllerRef?.current,\n },\n });\n\n const helpDetailsClasses = classNames(\n styles['help-details'],\n controllerRef ? styles['help-details--inline'] : styles['help-details--standalone']\n );\n const contentClasses = classNames(controllerRef ? styles['help-details__content--inline'] : styles['help-details__content--standalone']);\n\n return (\n <div\n className={helpDetailsClasses}\n data-testid={testId}\n ref={ref}\n style={{ minWidth: bubbleMinWidth ? `${bubbleMinWidth + BUBBLE_WIDTH_OFFSET}px` : undefined }}\n >\n <div style={floatingStyles} ref={refs.setFloating}>\n {controllerRef && typeof arrowYOffsetValue !== 'undefined' && (\n <FloatingArrow\n ref={arrowRef}\n context={context}\n fill={'var(--core-color-plum-50)'}\n stroke={'var(--core-color-plum-400)'}\n strokeWidth={1}\n />\n )}\n </div>\n <div className={contentClasses}>{children}</div>\n </div>\n );\n});\n\nHelpDetails.displayName = 'HelpDetails';\n\nexport default HelpDetails;\n"],"mappings":";;;;;AAOA,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAWxB,IAAM,cAAc,MAAM,YAA8C,EAAE,UAAU,eAAe,UAAU,QAAQ;CACnH,MAAM,WAAW,OAAO,KAAK;CAC7B,MAAM,CAAC,gBAAgB,qBAAqB,MAAM,SAAwB,KAAK;CAC/E,MAAM,CAAC,mBAAmB,wBAAwB,UAAkB;CAEpE,MAAM,EAAE,MAAM,SAAS,mBAAmB,YAAY;EACpD,YAAY;GACV,OAAO,kBAAkB;GACzB,iBAAiB,MAAM,EAAE,SAAS,UAAU,CAAC;GAC7C,KAAK,EACH,MAAM,EAAE,SAAS;AAEf,sBAAkB,MAAM,UAAU,IAAI,MAAM,UAAU,QAAQ,EAAE;IAGhE,MAAM,EAAE,WAAW,aAAa;IAChC,MAAM,mBAAmB,UAAU,IAAI,UAAU;AAGjD,yBAFkB,SAAS,IACE,mBAAmB,gBAClB;MAEjC,CAAC;GACH;EACD,WAAW;EACX,sBAAsB;EACtB,UAAU,EACR,WAAW,eAAe,SAC3B;EACF,CAAC;CAEF,MAAM,qBAAqB,GACzB,OAAO,iBACP,gBAAgB,OAAO,0BAA0B,OAAO,4BACzD;CACD,MAAM,iBAAiB,GAAW,gBAAgB,OAAO,mCAAmC,OAAO,qCAAqC;AAExI,QACE,qBAAC,OAAA;EACC,WAAW;EACX,eAAa;EACR;EACL,OAAO,EAAE,UAAU,iBAAiB,GAAG,iBAAiB,oBAAoB,MAAM,KAAA,GAAW;aAE7F,oBAAC,OAAA;GAAI,OAAO;GAAgB,KAAK,KAAK;aACnC,iBAAiB,OAAO,sBAAsB,eAC7C,oBAAC,eAAA;IACC,KAAK;IACI;IACT,MAAM;IACN,QAAQ;IACR,aAAa;KACb;IAEA,EACN,oBAAC,OAAA;GAAI,WAAW;GAAiB;IAAe,CAAA;GAC5C;EAER;AAEF,YAAY,cAAc;AAE1B,IAAA,sBAAe"}
|
package/lib/HelpTriggerIcon.js
CHANGED
|
@@ -3,7 +3,7 @@ import { t as usePseudoClasses } from "./usePseudoClasses.js";
|
|
|
3
3
|
import { n as mergeRefs } from "./refs.js";
|
|
4
4
|
import { n as getAriaLabelAttributes } from "./accessibility.js";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import
|
|
6
|
+
import cn from "classnames";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import styles from "./components/HelpTriggerIcon/styles.module.scss";
|
|
9
9
|
var HelpSign = ({ color, weight }) => {
|
|
@@ -70,13 +70,13 @@ const HelpTriggerIconInternal = React.forwardRef(({ ariaLabel, ariaLabelledById,
|
|
|
70
70
|
label: ariaLabel,
|
|
71
71
|
id: ariaLabelledById
|
|
72
72
|
});
|
|
73
|
-
const { refObject, isHovered: interalIsHovered } = usePseudoClasses(ref
|
|
73
|
+
const { refObject, isHovered: interalIsHovered } = usePseudoClasses(ref);
|
|
74
74
|
const helpIcon = /* @__PURE__ */ jsx(HelpSign_default, {
|
|
75
75
|
color: getIconColor(interalIsHovered || isHovered, weight),
|
|
76
76
|
weight
|
|
77
77
|
});
|
|
78
78
|
const isButton = htmlMarkup === "button";
|
|
79
|
-
const iconClasses =
|
|
79
|
+
const iconClasses = cn(styles["help-trigger-icon"], {
|
|
80
80
|
[styles["help-trigger-icon--strong"]]: weight === "strong",
|
|
81
81
|
[styles["help-trigger-icon--is-button"]]: isButton
|
|
82
82
|
}, styles[`help-trigger-icon--${size}`], className);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpTriggerIcon.js","names":["HelpSign: React.FC<HelpSignProps>"],"sources":["../src/components/HelpTriggerIcon/HelpSign.tsx","../src/components/HelpTriggerIcon/HelpTriggerIcon.tsx","../src/components/HelpTriggerIcon/index.ts"],"sourcesContent":["import React from 'react';\n\nimport { HelpTriggerWeights } from '../HelpTriggerIcon';\n\nexport interface HelpSignProps {\n color?: string;\n weight?: HelpTriggerWeights;\n}\n\nconst HelpSign: React.FC<HelpSignProps> = ({ color, weight }: HelpSignProps): React.ReactElement => {\n const paths =\n weight === 'normal' ? (\n <>\n <defs>\n <clipPath id=\"clipCircle\" clipPathUnits=\"userSpaceOnUse\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.0004 0C4.48644 0 0 4.48565 0 9.99961C0 15.5136 4.48644 20 10.0004 20C15.5144 20 20 15.5136 20 9.99961C20 4.48565 15.5144 0 10.0004 0\"\n />\n </clipPath>\n </defs>\n <path\n d=\"M10.0004 0V-2C3.38207 -2 -2 3.38088 -2 9.99961H0H2C2 5.59043 5.5908 2 10.0004 2V0ZM0 9.99961H-2C-2 16.6181 3.38187 22 10.0004 22V20V18C5.59101 18 2 14.409 2 9.99961H0ZM10.0004 20V22C16.6191 22 22 16.6179 22 9.99961H20H18C18 14.4092 14.4096 18 10.0004 18V20ZM20 9.99961H22C22 3.38108 16.6189 -2 10.0004 -2V0V2C14.4098 2 18 5.59022 18 9.99961H20Z\"\n fill={color}\n clipPath=\"url(#clipCircle)\"\n />\n <path\n d=\"M9.93555 4.40039C12.1061 4.40039 13.2998 5.8386 13.2998 7.35156C13.2997 8.52045 12.2922 9.61789 11.8262 9.94238C11.3601 10.2669 11.209 10.5 11.209 10.5C11.0283 10.6756 10.9117 11.0195 10.8721 11.2715C10.8316 11.5286 10.8476 11.5136 10.8477 11.7998V11.9004H9.20117V11.2715C9.20117 10.8463 9.20556 10.7433 9.31934 10.374C9.43483 9.99921 9.75195 9.54492 10.0928 9.18262C10.4336 8.82031 10.751 8.58105 10.751 8.58105C11.1983 8.25659 11.3818 7.87361 11.3818 7.42285C11.3818 7.07417 11.2638 6.74031 11.0283 6.49414C10.794 6.24916 10.435 6.08301 9.93555 6.08301C8.94209 6.08316 8.41811 6.83977 8.41797 7.60742C8.41797 7.81763 8.44731 8.07481 8.49805 8.21582L8.5498 8.36035L6.7793 8.23535L6.70898 8.23047L6.69043 8.16309C6.63105 7.95321 6.60059 7.71544 6.60059 7.47949C6.60081 6.00363 7.71413 4.40053 9.93555 4.40039Z\"\n fill={color}\n />\n <path\n d=\"M10 12.7998C10.6024 12.7999 11.0996 13.31 11.0996 13.9072C11.0994 14.506 10.6023 14.9999 10 15C9.38173 15 8.8996 14.506 8.89941 13.9072C8.89941 13.31 9.38162 12.7998 10 12.7998Z\"\n fill={color}\n />\n </>\n ) : (\n <>\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.0004 0C4.48644 0 0 4.48565 0 9.99961C0 15.5136 4.48644 20 10.0004 20C15.5144 20 20 15.5136 20 9.99961C20 4.48565 15.5144 0 10.0004 0Z\"\n />\n <path\n d=\"M9.93555 4.40039C12.1061 4.40039 13.2998 5.8386 13.2998 7.35156C13.2997 8.52045 12.2922 9.61789 11.8262 9.94238C11.3601 10.2669 11.209 10.5 11.209 10.5C11.0283 10.6756 10.9117 11.0195 10.8721 11.2715C10.8316 11.5286 10.8476 11.5136 10.8477 11.7998V11.9004H9.20117V11.2715C9.20117 10.8463 9.20556 10.7433 9.31934 10.374C9.43483 9.99921 9.75195 9.54492 10.0928 9.18262C10.4336 8.82031 10.751 8.58105 10.751 8.58105C11.1983 8.25659 11.3818 7.87361 11.3818 7.42285C11.3818 7.07417 11.2638 6.74031 11.0283 6.49414C10.794 6.24916 10.435 6.08301 9.93555 6.08301C8.94209 6.08316 8.41811 6.83977 8.41797 7.60742C8.41797 7.81763 8.44731 8.07481 8.49805 8.21582L8.5498 8.36035L6.7793 8.23535L6.70898 8.23047L6.69043 8.16309C6.63105 7.95321 6.60059 7.71544 6.60059 7.47949C6.60081 6.00363 7.71413 4.40053 9.93555 4.40039Z\"\n fill=\"white\"\n />\n <path\n d=\"M10 12.7998C10.6024 12.7999 11.0996 13.31 11.0996 13.9072C11.0994 14.506 10.6023 14.9999 10 15C9.38173 15 8.8996 14.506 8.89941 13.9072C8.89941 13.31 9.38162 12.7998 10 12.7998Z\"\n fill=\"white\"\n />\n </>\n );\n\n return (\n <svg fill=\"none\" height=\"20\" overflow=\"visible\" role={'presentation'} width=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\">\n {paths}\n </svg>\n );\n};\n\nexport default HelpSign;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HelpSign from './HelpSign';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport type HelpTriggerIconSizes = 'inherit' | 'medium' | 'large' | 'xlarge';\n\nexport type HelpTriggerIconTags = 'button' | 'span';\n\nexport type HelpTriggerWeights = 'normal' | 'strong';\n\nexport interface HelpTriggerIconProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /**\n * Size of the Icon. Default: medium.\n */\n size?: HelpTriggerIconSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /**\n * Sets the colors of the help trigger icon. Default: normal.\n */\n weight?: HelpTriggerWeights;\n}\n\ninterface HelpTriggerIconInternalProps extends HelpTriggerIconProps {\n /**\n * Sets the hover styling of the trigger. Intended for use when wrapped by a parent button.\n */\n isHovered?: boolean;\n /**\n * Only use this if the parent wrapper is a Button!\n * Changes the underlying element of the trigger. If set to span, the trigger will be a non-interactive icon. Default: button\n */\n htmlMarkup?: HelpTriggerIconTags;\n}\n\nconst getIconColor = (hover: boolean, weight: HelpTriggerWeights): string | undefined => {\n if (weight === 'normal') {\n return hover ? 'var(--color-help-graphics-verydark)' : 'var(--color-help-graphics-normal)';\n }\n};\n\nconst HelpTriggerIcon = React.forwardRef<HTMLButtonElement, HelpTriggerIconProps>((props, ref) => {\n return <HelpTriggerIconInternal {...props} ref={ref} />;\n});\n\nexport const HelpTriggerIconInternal = React.forwardRef<HTMLButtonElement, HelpTriggerIconInternalProps>(\n (\n {\n ariaLabel,\n ariaLabelledById,\n className,\n htmlMarkup = 'button',\n isHovered = false,\n size = 'medium',\n testId,\n weight = 'normal',\n ...buttonRest\n },\n ref\n ) => {\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const { refObject, isHovered: interalIsHovered } = usePseudoClasses<HTMLButtonElement>(
|
|
1
|
+
{"version":3,"file":"HelpTriggerIcon.js","names":["HelpSign: React.FC<HelpSignProps>"],"sources":["../src/components/HelpTriggerIcon/HelpSign.tsx","../src/components/HelpTriggerIcon/HelpTriggerIcon.tsx","../src/components/HelpTriggerIcon/index.ts"],"sourcesContent":["import React from 'react';\n\nimport { HelpTriggerWeights } from '../HelpTriggerIcon';\n\nexport interface HelpSignProps {\n color?: string;\n weight?: HelpTriggerWeights;\n}\n\nconst HelpSign: React.FC<HelpSignProps> = ({ color, weight }: HelpSignProps): React.ReactElement => {\n const paths =\n weight === 'normal' ? (\n <>\n <defs>\n <clipPath id=\"clipCircle\" clipPathUnits=\"userSpaceOnUse\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.0004 0C4.48644 0 0 4.48565 0 9.99961C0 15.5136 4.48644 20 10.0004 20C15.5144 20 20 15.5136 20 9.99961C20 4.48565 15.5144 0 10.0004 0\"\n />\n </clipPath>\n </defs>\n <path\n d=\"M10.0004 0V-2C3.38207 -2 -2 3.38088 -2 9.99961H0H2C2 5.59043 5.5908 2 10.0004 2V0ZM0 9.99961H-2C-2 16.6181 3.38187 22 10.0004 22V20V18C5.59101 18 2 14.409 2 9.99961H0ZM10.0004 20V22C16.6191 22 22 16.6179 22 9.99961H20H18C18 14.4092 14.4096 18 10.0004 18V20ZM20 9.99961H22C22 3.38108 16.6189 -2 10.0004 -2V0V2C14.4098 2 18 5.59022 18 9.99961H20Z\"\n fill={color}\n clipPath=\"url(#clipCircle)\"\n />\n <path\n d=\"M9.93555 4.40039C12.1061 4.40039 13.2998 5.8386 13.2998 7.35156C13.2997 8.52045 12.2922 9.61789 11.8262 9.94238C11.3601 10.2669 11.209 10.5 11.209 10.5C11.0283 10.6756 10.9117 11.0195 10.8721 11.2715C10.8316 11.5286 10.8476 11.5136 10.8477 11.7998V11.9004H9.20117V11.2715C9.20117 10.8463 9.20556 10.7433 9.31934 10.374C9.43483 9.99921 9.75195 9.54492 10.0928 9.18262C10.4336 8.82031 10.751 8.58105 10.751 8.58105C11.1983 8.25659 11.3818 7.87361 11.3818 7.42285C11.3818 7.07417 11.2638 6.74031 11.0283 6.49414C10.794 6.24916 10.435 6.08301 9.93555 6.08301C8.94209 6.08316 8.41811 6.83977 8.41797 7.60742C8.41797 7.81763 8.44731 8.07481 8.49805 8.21582L8.5498 8.36035L6.7793 8.23535L6.70898 8.23047L6.69043 8.16309C6.63105 7.95321 6.60059 7.71544 6.60059 7.47949C6.60081 6.00363 7.71413 4.40053 9.93555 4.40039Z\"\n fill={color}\n />\n <path\n d=\"M10 12.7998C10.6024 12.7999 11.0996 13.31 11.0996 13.9072C11.0994 14.506 10.6023 14.9999 10 15C9.38173 15 8.8996 14.506 8.89941 13.9072C8.89941 13.31 9.38162 12.7998 10 12.7998Z\"\n fill={color}\n />\n </>\n ) : (\n <>\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.0004 0C4.48644 0 0 4.48565 0 9.99961C0 15.5136 4.48644 20 10.0004 20C15.5144 20 20 15.5136 20 9.99961C20 4.48565 15.5144 0 10.0004 0Z\"\n />\n <path\n d=\"M9.93555 4.40039C12.1061 4.40039 13.2998 5.8386 13.2998 7.35156C13.2997 8.52045 12.2922 9.61789 11.8262 9.94238C11.3601 10.2669 11.209 10.5 11.209 10.5C11.0283 10.6756 10.9117 11.0195 10.8721 11.2715C10.8316 11.5286 10.8476 11.5136 10.8477 11.7998V11.9004H9.20117V11.2715C9.20117 10.8463 9.20556 10.7433 9.31934 10.374C9.43483 9.99921 9.75195 9.54492 10.0928 9.18262C10.4336 8.82031 10.751 8.58105 10.751 8.58105C11.1983 8.25659 11.3818 7.87361 11.3818 7.42285C11.3818 7.07417 11.2638 6.74031 11.0283 6.49414C10.794 6.24916 10.435 6.08301 9.93555 6.08301C8.94209 6.08316 8.41811 6.83977 8.41797 7.60742C8.41797 7.81763 8.44731 8.07481 8.49805 8.21582L8.5498 8.36035L6.7793 8.23535L6.70898 8.23047L6.69043 8.16309C6.63105 7.95321 6.60059 7.71544 6.60059 7.47949C6.60081 6.00363 7.71413 4.40053 9.93555 4.40039Z\"\n fill=\"white\"\n />\n <path\n d=\"M10 12.7998C10.6024 12.7999 11.0996 13.31 11.0996 13.9072C11.0994 14.506 10.6023 14.9999 10 15C9.38173 15 8.8996 14.506 8.89941 13.9072C8.89941 13.31 9.38162 12.7998 10 12.7998Z\"\n fill=\"white\"\n />\n </>\n );\n\n return (\n <svg fill=\"none\" height=\"20\" overflow=\"visible\" role={'presentation'} width=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\">\n {paths}\n </svg>\n );\n};\n\nexport default HelpSign;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HelpSign from './HelpSign';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport type HelpTriggerIconSizes = 'inherit' | 'medium' | 'large' | 'xlarge';\n\nexport type HelpTriggerIconTags = 'button' | 'span';\n\nexport type HelpTriggerWeights = 'normal' | 'strong';\n\nexport interface HelpTriggerIconProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /**\n * Size of the Icon. Default: medium.\n */\n size?: HelpTriggerIconSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /**\n * Sets the colors of the help trigger icon. Default: normal.\n */\n weight?: HelpTriggerWeights;\n}\n\ninterface HelpTriggerIconInternalProps extends HelpTriggerIconProps {\n /**\n * Sets the hover styling of the trigger. Intended for use when wrapped by a parent button.\n */\n isHovered?: boolean;\n /**\n * Only use this if the parent wrapper is a Button!\n * Changes the underlying element of the trigger. If set to span, the trigger will be a non-interactive icon. Default: button\n */\n htmlMarkup?: HelpTriggerIconTags;\n}\n\nconst getIconColor = (hover: boolean, weight: HelpTriggerWeights): string | undefined => {\n if (weight === 'normal') {\n return hover ? 'var(--color-help-graphics-verydark)' : 'var(--color-help-graphics-normal)';\n }\n};\n\nconst HelpTriggerIcon = React.forwardRef<HTMLButtonElement, HelpTriggerIconProps>((props, ref) => {\n return <HelpTriggerIconInternal {...props} ref={ref} />;\n});\n\nexport const HelpTriggerIconInternal = React.forwardRef<HTMLButtonElement, HelpTriggerIconInternalProps>(\n (\n {\n ariaLabel,\n ariaLabelledById,\n className,\n htmlMarkup = 'button',\n isHovered = false,\n size = 'medium',\n testId,\n weight = 'normal',\n ...buttonRest\n },\n ref\n ) => {\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const { refObject, isHovered: interalIsHovered } = usePseudoClasses<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>);\n const helpIcon = <HelpSign color={getIconColor(interalIsHovered || isHovered, weight)} weight={weight} />;\n const isButton = htmlMarkup === 'button';\n const iconClasses = classNames(\n styles['help-trigger-icon'],\n {\n [styles['help-trigger-icon--strong']]: weight === 'strong',\n [styles['help-trigger-icon--is-button']]: isButton,\n },\n styles[`help-trigger-icon--${size}`],\n className\n );\n\n if (isButton) {\n return (\n <button\n {...ariaLabelAttributes}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.HelpTriggerIcon}\n className={iconClasses}\n ref={mergeRefs([refObject, ref])}\n {...buttonRest}\n >\n {helpIcon}\n </button>\n );\n }\n\n return (\n <span data-testid={testId} data-analyticsid={AnalyticsId.HelpTriggerIcon} className={iconClasses}>\n {helpIcon}\n </span>\n );\n }\n);\n\nHelpTriggerIcon.displayName = 'HelpTriggerIcon';\nHelpTriggerIconInternal.displayName = 'HelpTriggerIconInternal';\n\nexport default HelpTriggerIcon;\n","import HelpTriggerIcon from './HelpTriggerIcon';\nexport * from './HelpTriggerIcon';\nexport default HelpTriggerIcon;\n"],"mappings":";;;;;;;;AASA,IAAMA,YAAqC,EAAE,OAAO,aAAgD;AA6ClG,QACE,oBAAC,OAAA;EAAI,MAAK;EAAO,QAAO;EAAK,UAAS;EAAU,MAAM;EAAgB,OAAM;EAAK,SAAQ;EAAY,OAAM;YA5C3G,WAAW,WACT,qBAAA,UAAA,EAAA,UAAA;GACE,oBAAC,QAAA,EAAA,UACC,oBAAC,YAAA;IAAS,IAAG;IAAa,eAAc;cACtC,oBAAC,QAAA;KACC,UAAS;KACT,UAAS;KACT,GAAE;MACF;KACO,EAAA,CACN;GACP,oBAAC,QAAA;IACC,GAAE;IACF,MAAM;IACN,UAAS;KACT;GACF,oBAAC,QAAA;IACC,GAAE;IACF,MAAM;KACN;GACF,oBAAC,QAAA;IACC,GAAE;IACF,MAAM;KACN;MACD,GAEH,qBAAA,UAAA,EAAA,UAAA;GACE,oBAAC,QAAA;IACC,UAAS;IACT,UAAS;IACT,GAAE;KACF;GACF,oBAAC,QAAA;IACC,GAAE;IACF,MAAK;KACL;GACF,oBAAC,QAAA;IACC,GAAE;IACF,MAAK;KACL;MACD;GAMC;;AAIV,IAAA,mBAAe;ACPf,IAAM,gBAAgB,OAAgB,WAAmD;AACvF,KAAI,WAAW,SACb,QAAO,QAAQ,wCAAwC;;AAI3D,IAAM,kBAAkB,MAAM,YAAqD,OAAO,QAAQ;AAChG,QAAO,oBAAC,yBAAA;EAAwB,GAAI;EAAY;GAAO;EACvD;AAEF,MAAa,0BAA0B,MAAM,YAEzC,EACE,WACA,kBACA,WACA,aAAa,UACb,YAAY,OACZ,OAAO,UACP,QACA,SAAS,UACT,GAAG,cAEL,QACG;CACH,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAkB,CAAC;CAC9F,MAAM,EAAE,WAAW,WAAW,qBAAqB,iBAAoC,IAA0C;CACjI,MAAM,WAAW,oBAAC,kBAAA;EAAS,OAAO,aAAa,oBAAoB,WAAW,OAAO;EAAU;GAAU;CACzG,MAAM,WAAW,eAAe;CAChC,MAAM,cAAc,GAClB,OAAO,sBACP;GACG,OAAO,+BAA+B,WAAW;GACjD,OAAO,kCAAkC;EAC3C,EACD,OAAO,sBAAsB,SAC7B,UACD;AAED,KAAI,SACF,QACE,oBAAC,UAAA;EACC,GAAI;EACJ,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;EAChC,GAAI;YAEH;GACM;AAIb,QACE,oBAAC,QAAA;EAAK,eAAa;EAAQ,oBAAkB,YAAY;EAAiB,WAAW;YAClF;GACI;EAGZ;AAED,gBAAgB,cAAc;AAC9B,wBAAwB,cAAc;ACpHtC,IAAA,4BDsHe"}
|
|
@@ -5,7 +5,7 @@ import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
|
|
|
5
5
|
import { n as getAriaLabelAttributes } from "./accessibility.js";
|
|
6
6
|
import { n as HelpTriggerIconInternal } from "./HelpTriggerIcon.js";
|
|
7
7
|
import React from "react";
|
|
8
|
-
import
|
|
8
|
+
import cn from "classnames";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import styles from "./components/HelpTriggerStandalone/styles.module.scss";
|
|
11
11
|
var HelpTriggerStandalone = React.forwardRef(({ ariaLabel, ariaLabelledById, children, className, testId, weight = "normal", ...rest }, ref) => {
|
|
@@ -14,8 +14,8 @@ var HelpTriggerStandalone = React.forwardRef(({ ariaLabel, ariaLabelledById, chi
|
|
|
14
14
|
label: ariaLabel,
|
|
15
15
|
id: ariaLabelledById
|
|
16
16
|
});
|
|
17
|
-
const helpTriggerStandaloneStyles =
|
|
18
|
-
const { refObject, isHovered } = usePseudoClasses(ref
|
|
17
|
+
const helpTriggerStandaloneStyles = cn(styles["help-trigger-standalone"], className);
|
|
18
|
+
const { refObject, isHovered } = usePseudoClasses(ref);
|
|
19
19
|
return /* @__PURE__ */ jsxs("button", {
|
|
20
20
|
"aria-label": ariaLabel,
|
|
21
21
|
type: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpTriggerStandalone.js","names":[],"sources":["../src/components/HelpTriggerStandalone/HelpTriggerStandalone.tsx","../src/components/HelpTriggerStandalone/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport { HelpTriggerIconInternal, HelpTriggerWeights } from '../HelpTriggerIcon';\n\nimport styles from './styles.module.scss';\n\nexport interface HelpTriggerStandaloneProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Sets the text content of the HelpTriggerStandalone. */\n children: React.ReactNode;\n /**\n * Sets the colors of the help trigger. Default: normal.\n */\n weight?: HelpTriggerWeights;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst HelpTriggerStandalone = React.forwardRef<HTMLButtonElement, HelpTriggerStandaloneProps>(\n ({ ariaLabel, ariaLabelledById, children, className, testId, weight = 'normal', ...rest }, ref) => {\n const isMobile = useIsMobileBreakpoint();\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const helpTriggerStandaloneStyles = classNames(styles['help-trigger-standalone'], className);\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement
|
|
1
|
+
{"version":3,"file":"HelpTriggerStandalone.js","names":[],"sources":["../src/components/HelpTriggerStandalone/HelpTriggerStandalone.tsx","../src/components/HelpTriggerStandalone/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport { HelpTriggerIconInternal, HelpTriggerWeights } from '../HelpTriggerIcon';\n\nimport styles from './styles.module.scss';\n\nexport interface HelpTriggerStandaloneProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Sets the text content of the HelpTriggerStandalone. */\n children: React.ReactNode;\n /**\n * Sets the colors of the help trigger. Default: normal.\n */\n weight?: HelpTriggerWeights;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst HelpTriggerStandalone = React.forwardRef<HTMLButtonElement, HelpTriggerStandaloneProps>(\n ({ ariaLabel, ariaLabelledById, children, className, testId, weight = 'normal', ...rest }, ref) => {\n const isMobile = useIsMobileBreakpoint();\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const helpTriggerStandaloneStyles = classNames(styles['help-trigger-standalone'], className);\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>);\n\n return (\n <button\n aria-label={ariaLabel}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.HelpTriggerStandalone}\n className={helpTriggerStandaloneStyles}\n ref={mergeRefs([refObject, ref])}\n {...ariaLabelAttributes}\n {...rest}\n >\n <HelpTriggerIconInternal weight={weight} size={isMobile ? 'medium' : 'large'} htmlMarkup={'span'} isHovered={isHovered} />\n <span className={styles['help-trigger-standalone__children']}>{children}</span>\n </button>\n );\n }\n);\n\nHelpTriggerStandalone.displayName = 'HelpTriggerStandalone';\n\nexport default HelpTriggerStandalone;\n","import HelpTriggerStandalone from './HelpTriggerStandalone';\nexport * from './HelpTriggerStandalone';\nexport default HelpTriggerStandalone;\n"],"mappings":";;;;;;;;;;AAuCA,IAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,kBAAkB,UAAU,WAAW,QAAQ,SAAS,UAAU,GAAG,QAAQ,QAAQ;CACjG,MAAM,WAAW,uBAAuB;CACxC,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAkB,CAAC;CAC9F,MAAM,8BAA8B,GAAW,OAAO,4BAA4B,UAAU;CAC5F,MAAM,EAAE,WAAW,cAAc,iBAAoC,IAA0C;AAE/G,QACE,qBAAC,UAAA;EACC,cAAY;EACZ,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;EAChC,GAAI;EACJ,GAAI;aAEJ,oBAAC,yBAAA;GAAgC;GAAQ,MAAM,WAAW,WAAW;GAAS,YAAY;GAAmB;IAAa,EAC1H,oBAAC,QAAA;GAAK,WAAW,OAAO;GAAuC;IAAgB,CAAA;GACxE;EAGd;AAED,sBAAsB,cAAc;AC9DpC,IAAA,kCDgEe"}
|
package/lib/HighlightPanel.js
CHANGED
|
@@ -4,13 +4,13 @@ import { t as LazyIcon_default } from "./LazyIcon.js";
|
|
|
4
4
|
import { n as useBreakpoint, t as Breakpoint } from "./useBreakpoint.js";
|
|
5
5
|
import { t as Title_default } from "./Title2.js";
|
|
6
6
|
import React from "react";
|
|
7
|
-
import
|
|
7
|
+
import cn from "classnames";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import styles from "./components/HighlightPanel/styles.module.scss";
|
|
10
10
|
var HighlightPanel = (props) => {
|
|
11
11
|
const { children, color = "white", testId, svgIcon, htmlMarkup = "div", className, variant = "normal", title, titleHtmlMarkup = "h2" } = props;
|
|
12
12
|
const breakpoint = useBreakpoint();
|
|
13
|
-
const containerClassName =
|
|
13
|
+
const containerClassName = cn(styles.highlightpanel, styles[`highlightpanel--${color}`], svgIcon && styles["highlightpanel--has-icon"], className, { [styles["highlightpanel--compact"]]: variant === "compact" });
|
|
14
14
|
const renderContent = () => {
|
|
15
15
|
const titleElement = title && /* @__PURE__ */ jsx(Title_default, {
|
|
16
16
|
testId: "titleId",
|
|
@@ -21,7 +21,7 @@ var HighlightPanel = (props) => {
|
|
|
21
21
|
if (svgIcon) {
|
|
22
22
|
const iconSize = IconSize.Small;
|
|
23
23
|
if (variant === "compact") return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
24
|
-
className:
|
|
24
|
+
className: cn(styles.highlightpanel__icon, styles["highlightpanel__icon--compact"]),
|
|
25
25
|
children: typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
26
26
|
iconName: svgIcon,
|
|
27
27
|
size: iconSize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightPanel.js","names":["HighlightPanel: React.FC<HighlightPanelProps>"],"sources":["../src/components/HighlightPanel/HighlightPanel.tsx","../src/components/HighlightPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint, Breakpoint } from '../..';\nimport { AnalyticsId } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport Icon, { SvgIcon, IconSize } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport LazyIcon from '../LazyIcon';\nimport Title, { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type HighlightPanelColors = Extract<PaletteNames, 'white' | 'neutral' | 'blueberry' | 'cherry'>;\n\nexport type HighlightPanelTags = Exclude<\n keyof HTMLElementTagNameMap,\n 'dir' | 'font' | 'frame' | 'frameset' | 'marquee' | 'applet' | 'basefont' | 'search'\n>;\n\nexport type HighlightPanelVariants = 'normal' | 'compact';\n\nexport interface HighlightPanelProps {\n /** What's in the box? */\n children: React.ReactNode;\n /** Changes the background color. Default: white */\n color?: HighlightPanelColors;\n /** Adds an icon to the highlightpanel. */\n svgIcon?: SvgIcon | IconName;\n /** Changes the underlying element. Default: div */\n htmlMarkup?: HighlightPanelTags;\n /** Adds custom classes to the element. */\n className?: string;\n /** Uses the compact styling if set to compact */\n variant?: HighlightPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Element that is set after the icon-element in the DOM, often a title-element */\n title?: string;\n /** Markup props for title */\n titleHtmlMarkup?: TitleTags;\n}\n\nconst HighlightPanel: React.FC<HighlightPanelProps> = props => {\n const {\n children,\n color = 'white',\n testId,\n svgIcon,\n htmlMarkup = 'div',\n className,\n variant = 'normal',\n title,\n titleHtmlMarkup = 'h2',\n } = props;\n const breakpoint = useBreakpoint();\n\n const containerClassName = classNames(\n styles.highlightpanel,\n styles[`highlightpanel--${color}`],\n svgIcon && styles['highlightpanel--has-icon'],\n className,\n { [styles['highlightpanel--compact']]: variant === 'compact' }\n );\n\n const renderContent = (): React.ReactNode => {\n const titleElement = title && (\n <Title testId=\"titleId\" htmlMarkup={titleHtmlMarkup} appearance={variant === 'compact' ? 'title6' : 'title4'}>\n {title}\n </Title>\n );\n\n if (svgIcon) {\n const iconSize = IconSize.Small;\n\n if (variant === 'compact') {\n return (\n <>\n <div className={classNames(styles.highlightpanel__icon, styles['highlightpanel__icon--compact'])}>\n {typeof svgIcon === 'string' ? <LazyIcon iconName={svgIcon} size={iconSize} /> : <Icon svgIcon={svgIcon} size={iconSize} />}\n </div>\n <div className={(styles.highlightpanel__content, styles['highlightpanel__content--compact'])}>\n {title && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n <div className={styles['highlightpanel__content__children--compact']}>{children}</div>\n </div>\n </>\n );\n }\n\n return (\n <>\n <div className={styles.highlightpanel__icon}>\n {typeof svgIcon === 'string' ? <LazyIcon iconName={svgIcon} size={iconSize} /> : <Icon svgIcon={svgIcon} size={iconSize} />}\n {title && breakpoint < Breakpoint.md && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n </div>\n <div className={styles.highlightpanel__content}>\n {title && breakpoint >= Breakpoint.md && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n {children}\n </div>\n </>\n );\n }\n\n return (\n <>\n {title && (\n <div className={styles.highlightpanel__content}>\n <div>{titleElement}</div>\n </div>\n )}\n {children}\n </>\n );\n };\n\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={containerClassName} data-testid={testId} data-analyticsid={AnalyticsId.HighlightPanel}>\n {renderContent()}\n </CustomTag>\n );\n};\n\nexport default HighlightPanel;\n","import HighlightPanel from './HighlightPanel';\nexport * from './HighlightPanel';\nexport default HighlightPanel;\n"],"mappings":";;;;;;;;;AA4CA,IAAMA,kBAAgD,UAAS;CAC7D,MAAM,EACJ,UACA,QAAQ,SACR,QACA,SACA,aAAa,OACb,WACA,UAAU,UACV,OACA,kBAAkB,SAChB;CACJ,MAAM,aAAa,eAAe;CAElC,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"HighlightPanel.js","names":["HighlightPanel: React.FC<HighlightPanelProps>"],"sources":["../src/components/HighlightPanel/HighlightPanel.tsx","../src/components/HighlightPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { useBreakpoint, Breakpoint } from '../..';\nimport { AnalyticsId } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport Icon, { SvgIcon, IconSize } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport LazyIcon from '../LazyIcon';\nimport Title, { TitleTags } from '../Title';\n\nimport styles from './styles.module.scss';\n\nexport type HighlightPanelColors = Extract<PaletteNames, 'white' | 'neutral' | 'blueberry' | 'cherry'>;\n\nexport type HighlightPanelTags = Exclude<\n keyof HTMLElementTagNameMap,\n 'dir' | 'font' | 'frame' | 'frameset' | 'marquee' | 'applet' | 'basefont' | 'search'\n>;\n\nexport type HighlightPanelVariants = 'normal' | 'compact';\n\nexport interface HighlightPanelProps {\n /** What's in the box? */\n children: React.ReactNode;\n /** Changes the background color. Default: white */\n color?: HighlightPanelColors;\n /** Adds an icon to the highlightpanel. */\n svgIcon?: SvgIcon | IconName;\n /** Changes the underlying element. Default: div */\n htmlMarkup?: HighlightPanelTags;\n /** Adds custom classes to the element. */\n className?: string;\n /** Uses the compact styling if set to compact */\n variant?: HighlightPanelVariants;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Element that is set after the icon-element in the DOM, often a title-element */\n title?: string;\n /** Markup props for title */\n titleHtmlMarkup?: TitleTags;\n}\n\nconst HighlightPanel: React.FC<HighlightPanelProps> = props => {\n const {\n children,\n color = 'white',\n testId,\n svgIcon,\n htmlMarkup = 'div',\n className,\n variant = 'normal',\n title,\n titleHtmlMarkup = 'h2',\n } = props;\n const breakpoint = useBreakpoint();\n\n const containerClassName = classNames(\n styles.highlightpanel,\n styles[`highlightpanel--${color}`],\n svgIcon && styles['highlightpanel--has-icon'],\n className,\n { [styles['highlightpanel--compact']]: variant === 'compact' }\n );\n\n const renderContent = (): React.ReactNode => {\n const titleElement = title && (\n <Title testId=\"titleId\" htmlMarkup={titleHtmlMarkup} appearance={variant === 'compact' ? 'title6' : 'title4'}>\n {title}\n </Title>\n );\n\n if (svgIcon) {\n const iconSize = IconSize.Small;\n\n if (variant === 'compact') {\n return (\n <>\n <div className={classNames(styles.highlightpanel__icon, styles['highlightpanel__icon--compact'])}>\n {typeof svgIcon === 'string' ? <LazyIcon iconName={svgIcon} size={iconSize} /> : <Icon svgIcon={svgIcon} size={iconSize} />}\n </div>\n <div className={(styles.highlightpanel__content, styles['highlightpanel__content--compact'])}>\n {title && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n <div className={styles['highlightpanel__content__children--compact']}>{children}</div>\n </div>\n </>\n );\n }\n\n return (\n <>\n <div className={styles.highlightpanel__icon}>\n {typeof svgIcon === 'string' ? <LazyIcon iconName={svgIcon} size={iconSize} /> : <Icon svgIcon={svgIcon} size={iconSize} />}\n {title && breakpoint < Breakpoint.md && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n </div>\n <div className={styles.highlightpanel__content}>\n {title && breakpoint >= Breakpoint.md && <div className={styles['highlightpanel__title-wrapper']}>{titleElement}</div>}\n {children}\n </div>\n </>\n );\n }\n\n return (\n <>\n {title && (\n <div className={styles.highlightpanel__content}>\n <div>{titleElement}</div>\n </div>\n )}\n {children}\n </>\n );\n };\n\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={containerClassName} data-testid={testId} data-analyticsid={AnalyticsId.HighlightPanel}>\n {renderContent()}\n </CustomTag>\n );\n};\n\nexport default HighlightPanel;\n","import HighlightPanel from './HighlightPanel';\nexport * from './HighlightPanel';\nexport default HighlightPanel;\n"],"mappings":";;;;;;;;;AA4CA,IAAMA,kBAAgD,UAAS;CAC7D,MAAM,EACJ,UACA,QAAQ,SACR,QACA,SACA,aAAa,OACb,WACA,UAAU,UACV,OACA,kBAAkB,SAChB;CACJ,MAAM,aAAa,eAAe;CAElC,MAAM,qBAAqB,GACzB,OAAO,gBACP,OAAO,mBAAmB,UAC1B,WAAW,OAAO,6BAClB,WACA,GAAG,OAAO,6BAA6B,YAAY,WAAW,CAC/D;CAED,MAAM,sBAAuC;EAC3C,MAAM,eAAe,SACnB,oBAAC,eAAA;GAAM,QAAO;GAAU,YAAY;GAAiB,YAAY,YAAY,YAAY,WAAW;aACjG;IACK;AAGV,MAAI,SAAS;GACX,MAAM,WAAW,SAAS;AAE1B,OAAI,YAAY,UACd,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAA;IAAI,WAAW,GAAW,OAAO,sBAAsB,OAAO,iCAAiC;cAC7F,OAAO,YAAY,WAAW,oBAAC,kBAAA;KAAS,UAAU;KAAS,MAAM;MAAY,GAAG,oBAAC,cAAA;KAAc;KAAS,MAAM;MAAY;KACvH,EACN,qBAAC,OAAA;IAAI,YAAY,OAAO,yBAAyB,OAAO;eACrD,SAAS,oBAAC,OAAA;KAAI,WAAW,OAAO;eAAmC;MAAmB,EACvF,oBAAC,OAAA;KAAI,WAAW,OAAO;KAAgD;MAAe,CAAA;KAClF,CAAA,EAAA,CACL;AAIP,UACE,qBAAA,UAAA,EAAA,UAAA,CACE,qBAAC,OAAA;IAAI,WAAW,OAAO;eACpB,OAAO,YAAY,WAAW,oBAAC,kBAAA;KAAS,UAAU;KAAS,MAAM;MAAY,GAAG,oBAAC,cAAA;KAAc;KAAS,MAAM;MAAY,EAC1H,SAAS,aAAa,WAAW,MAAM,oBAAC,OAAA;KAAI,WAAW,OAAO;eAAmC;MAAmB,CAAA;KACjH,EACN,qBAAC,OAAA;IAAI,WAAW,OAAO;eACpB,SAAS,cAAc,WAAW,MAAM,oBAAC,OAAA;KAAI,WAAW,OAAO;eAAmC;MAAmB,EACrH,SAAA;KACG,CAAA,EAAA,CACL;;AAIP,SACE,qBAAA,UAAA,EAAA,UAAA,CACG,SACC,oBAAC,OAAA;GAAI,WAAW,OAAO;aACrB,oBAAC,OAAA,EAAA,UAAK,cAAA,CAAmB;IACrB,EAEP,SAAA,EAAA,CACA;;AAMP,QACE,oBAHgB,YAGf;EAAU,WAAW;EAAoB,eAAa;EAAQ,oBAAkB,YAAY;YAC1F,eAAe;GACN;;ACvHhB,IAAA,2BD2He"}
|
package/lib/HorizontalScroll.js
CHANGED
|
@@ -2,7 +2,7 @@ import { t as useIsVisible } from "./useIsVisible.js";
|
|
|
2
2
|
import { t as useSize } from "./useSize.js";
|
|
3
3
|
import { t as useStopPropagation } from "./usestopPropagation.js";
|
|
4
4
|
import React, { useRef } from "react";
|
|
5
|
-
import
|
|
5
|
+
import cn from "classnames";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import styles from "./components/HorizontalScroll/styles.module.scss";
|
|
8
8
|
var ROOT_MARGIN_OFFSET = "3px";
|
|
@@ -20,7 +20,7 @@ const HorizontalScroll = ({ children, childWidth, testId, ...rest }) => {
|
|
|
20
20
|
}, true);
|
|
21
21
|
const { width: viewPortWidth = 0 } = useSize(viewportRef) || {};
|
|
22
22
|
const isOverflowing = childWidth > viewPortWidth;
|
|
23
|
-
const viewportClasses =
|
|
23
|
+
const viewportClasses = cn(styles.horizontalscroll__viewport, isOverflowing && styles["horizontalscroll__viewport--overflow"]);
|
|
24
24
|
const hasAriaAttributes = rest["aria-label"] || rest["aria-labelledby"];
|
|
25
25
|
useStopPropagation(viewportRef, ["touchstart", "touchmove"]);
|
|
26
26
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -33,8 +33,8 @@ const HorizontalScroll = ({ children, childWidth, testId, ...rest }) => {
|
|
|
33
33
|
role: hasAriaAttributes ? "region" : void 0,
|
|
34
34
|
...rest,
|
|
35
35
|
children: [
|
|
36
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
37
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
36
|
+
/* @__PURE__ */ jsx("div", { className: cn(styles.horizontalscroll__indicator, styles["horizontalscroll__indicator--left"], !leftIsVisible && styles["horizontalscroll__indicator--visible"]) }),
|
|
37
|
+
/* @__PURE__ */ jsx("div", { className: cn(styles.horizontalscroll__indicator, styles["horizontalscroll__indicator--right"], !rightIsVisible && styles["horizontalscroll__indicator--visible"]) }),
|
|
38
38
|
/* @__PURE__ */ jsx("div", { ref: leftRef }),
|
|
39
39
|
children,
|
|
40
40
|
/* @__PURE__ */ jsx("div", { ref: rightRef })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalScroll.js","names":["HorizontalScroll: React.FC<HorizontalScrollProps & AriaLabelAttributes>"],"sources":["../src/components/HorizontalScroll/HorizontalScroll.tsx","../src/components/HorizontalScroll/index.ts"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useSize } from '../../hooks/useSize';\nimport { useStopPropagation } from '../../hooks/usestopPropagation';\nimport { AriaLabelAttributes } from '../../utils/accessibility';\n\nimport styles from './styles.module.scss';\n\n// Scrolle-indikator vises/skjules når det er x px igjen til venstre eller høyre side\nconst ROOT_MARGIN_OFFSET = '3px';\n\ninterface HorizontalScrollProps {\n children?: React.ReactNode;\n /**\n * Bredden på elementet som potensielt vil scrolle horisontalt i px\n */\n childWidth: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const HorizontalScroll: React.FC<HorizontalScrollProps & AriaLabelAttributes> = ({ children, childWidth, testId, ...rest }) => {\n const viewportRef = useRef<HTMLDivElement>(null);\n const leftRef = useRef<HTMLDivElement>(null);\n const rightRef = useRef<HTMLDivElement>(null);\n const leftIsVisible = useIsVisible(leftRef, 1, { root: viewportRef?.current, rootMargin: ROOT_MARGIN_OFFSET }, true);\n const rightIsVisible = useIsVisible(rightRef, 1, { root: viewportRef?.current, rootMargin: ROOT_MARGIN_OFFSET }, true);\n const { width: viewPortWidth = 0 } = useSize(viewportRef) || {};\n\n const isOverflowing = childWidth > viewPortWidth;\n const viewportClasses = classNames(styles.horizontalscroll__viewport, isOverflowing && styles['horizontalscroll__viewport--overflow']);\n const hasAriaAttributes = rest['aria-label'] || rest['aria-labelledby'];\n\n useStopPropagation(viewportRef, ['touchstart', 'touchmove']);\n\n return (\n <div className={styles.horizontalscroll} data-testid={testId}>\n {/* viewport-diven må ta tabIndex for å løse et annet UU-problem, at div med overflow: scroll må kunne navigeres med keyboard. */}\n {/* Enten aria-label eller aria-labelledbyid må settes */}\n <div\n className={viewportClasses}\n ref={viewportRef}\n tabIndex={hasAriaAttributes ? 0 : undefined}\n role={hasAriaAttributes ? 'region' : undefined}\n {...rest}\n >\n <div\n className={classNames(\n styles.horizontalscroll__indicator,\n styles['horizontalscroll__indicator--left'],\n !leftIsVisible && styles['horizontalscroll__indicator--visible']\n )}\n />\n <div\n className={classNames(\n styles.horizontalscroll__indicator,\n styles['horizontalscroll__indicator--right'],\n !rightIsVisible && styles['horizontalscroll__indicator--visible']\n )}\n />\n <div ref={leftRef} />\n {children}\n <div ref={rightRef} />\n </div>\n </div>\n );\n};\n\nexport default HorizontalScroll;\n","import HorizontalScroll from './HorizontalScroll';\nexport * from './HorizontalScroll';\nexport default HorizontalScroll;\n"],"mappings":";;;;;;;AAYA,IAAM,qBAAqB;AAY3B,MAAaA,oBAA2E,EAAE,UAAU,YAAY,QAAQ,GAAG,WAAW;CACpI,MAAM,cAAc,OAAuB,KAAK;CAChD,MAAM,UAAU,OAAuB,KAAK;CAC5C,MAAM,WAAW,OAAuB,KAAK;CAC7C,MAAM,gBAAgB,aAAa,SAAS,GAAG;EAAE,MAAM,aAAa;EAAS,YAAY;EAAoB,EAAE,KAAK;CACpH,MAAM,iBAAiB,aAAa,UAAU,GAAG;EAAE,MAAM,aAAa;EAAS,YAAY;EAAoB,EAAE,KAAK;CACtH,MAAM,EAAE,OAAO,gBAAgB,MAAM,QAAQ,YAAY,IAAI,EAAE;CAE/D,MAAM,gBAAgB,aAAa;CACnC,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"HorizontalScroll.js","names":["HorizontalScroll: React.FC<HorizontalScrollProps & AriaLabelAttributes>"],"sources":["../src/components/HorizontalScroll/HorizontalScroll.tsx","../src/components/HorizontalScroll/index.ts"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useSize } from '../../hooks/useSize';\nimport { useStopPropagation } from '../../hooks/usestopPropagation';\nimport { AriaLabelAttributes } from '../../utils/accessibility';\n\nimport styles from './styles.module.scss';\n\n// Scrolle-indikator vises/skjules når det er x px igjen til venstre eller høyre side\nconst ROOT_MARGIN_OFFSET = '3px';\n\ninterface HorizontalScrollProps {\n children?: React.ReactNode;\n /**\n * Bredden på elementet som potensielt vil scrolle horisontalt i px\n */\n childWidth: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const HorizontalScroll: React.FC<HorizontalScrollProps & AriaLabelAttributes> = ({ children, childWidth, testId, ...rest }) => {\n const viewportRef = useRef<HTMLDivElement>(null);\n const leftRef = useRef<HTMLDivElement>(null);\n const rightRef = useRef<HTMLDivElement>(null);\n const leftIsVisible = useIsVisible(leftRef, 1, { root: viewportRef?.current, rootMargin: ROOT_MARGIN_OFFSET }, true);\n const rightIsVisible = useIsVisible(rightRef, 1, { root: viewportRef?.current, rootMargin: ROOT_MARGIN_OFFSET }, true);\n const { width: viewPortWidth = 0 } = useSize(viewportRef) || {};\n\n const isOverflowing = childWidth > viewPortWidth;\n const viewportClasses = classNames(styles.horizontalscroll__viewport, isOverflowing && styles['horizontalscroll__viewport--overflow']);\n const hasAriaAttributes = rest['aria-label'] || rest['aria-labelledby'];\n\n useStopPropagation(viewportRef, ['touchstart', 'touchmove']);\n\n return (\n <div className={styles.horizontalscroll} data-testid={testId}>\n {/* viewport-diven må ta tabIndex for å løse et annet UU-problem, at div med overflow: scroll må kunne navigeres med keyboard. */}\n {/* Enten aria-label eller aria-labelledbyid må settes */}\n <div\n className={viewportClasses}\n ref={viewportRef}\n tabIndex={hasAriaAttributes ? 0 : undefined}\n role={hasAriaAttributes ? 'region' : undefined}\n {...rest}\n >\n <div\n className={classNames(\n styles.horizontalscroll__indicator,\n styles['horizontalscroll__indicator--left'],\n !leftIsVisible && styles['horizontalscroll__indicator--visible']\n )}\n />\n <div\n className={classNames(\n styles.horizontalscroll__indicator,\n styles['horizontalscroll__indicator--right'],\n !rightIsVisible && styles['horizontalscroll__indicator--visible']\n )}\n />\n <div ref={leftRef} />\n {children}\n <div ref={rightRef} />\n </div>\n </div>\n );\n};\n\nexport default HorizontalScroll;\n","import HorizontalScroll from './HorizontalScroll';\nexport * from './HorizontalScroll';\nexport default HorizontalScroll;\n"],"mappings":";;;;;;;AAYA,IAAM,qBAAqB;AAY3B,MAAaA,oBAA2E,EAAE,UAAU,YAAY,QAAQ,GAAG,WAAW;CACpI,MAAM,cAAc,OAAuB,KAAK;CAChD,MAAM,UAAU,OAAuB,KAAK;CAC5C,MAAM,WAAW,OAAuB,KAAK;CAC7C,MAAM,gBAAgB,aAAa,SAAS,GAAG;EAAE,MAAM,aAAa;EAAS,YAAY;EAAoB,EAAE,KAAK;CACpH,MAAM,iBAAiB,aAAa,UAAU,GAAG;EAAE,MAAM,aAAa;EAAS,YAAY;EAAoB,EAAE,KAAK;CACtH,MAAM,EAAE,OAAO,gBAAgB,MAAM,QAAQ,YAAY,IAAI,EAAE;CAE/D,MAAM,gBAAgB,aAAa;CACnC,MAAM,kBAAkB,GAAW,OAAO,4BAA4B,iBAAiB,OAAO,wCAAwC;CACtI,MAAM,oBAAoB,KAAK,iBAAiB,KAAK;AAErD,oBAAmB,aAAa,CAAC,cAAc,YAAY,CAAC;AAE5D,QACE,oBAAC,OAAA;EAAI,WAAW,OAAO;EAAkB,eAAa;YAGpD,qBAAC,OAAA;GACC,WAAW;GACX,KAAK;GACL,UAAU,oBAAoB,IAAI,KAAA;GAClC,MAAM,oBAAoB,WAAW,KAAA;GACrC,GAAI;;IAEJ,oBAAC,OAAA,EACC,WAAW,GACT,OAAO,6BACP,OAAO,sCACP,CAAC,iBAAiB,OAAO,wCAC1B,EAAA,CACD;IACF,oBAAC,OAAA,EACC,WAAW,GACT,OAAO,6BACP,OAAO,uCACP,CAAC,kBAAkB,OAAO,wCAC3B,EAAA,CACD;IACF,oBAAC,OAAA,EAAI,KAAK,SAAA,CAAW;IACpB;IACD,oBAAC,OAAA,EAAI,KAAK,UAAA,CAAY;;IAClB;GACF;;ACjEV,IAAA,6BDqEe"}
|
package/lib/Icon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as IconSize, n as AnalyticsId } from "./constants2.js";
|
|
2
2
|
import React, { useId } from "react";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
const getIcon = ({ size, isHovered, normal, normalHover, xSmall, xSmallHover, xxSmall, xxSmallHover }) => {
|
|
6
6
|
if (size <= IconSize.XXSmall && xxSmall && xxSmallHover) return isHovered ? xxSmallHover : xxSmall;
|
|
@@ -20,7 +20,7 @@ const Icon = React.forwardRef((props, ref) => {
|
|
|
20
20
|
"data-testid": testId,
|
|
21
21
|
"data-analyticsid": AnalyticsId.Icon,
|
|
22
22
|
ref,
|
|
23
|
-
className:
|
|
23
|
+
className: cn(`hnds-style-icon`, className),
|
|
24
24
|
role: ariaLabel ? "img" : "presentation",
|
|
25
25
|
"aria-labelledby": ariaLabel ? titleId : void 0,
|
|
26
26
|
focusable: false,
|
package/lib/Icon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","names":[],"sources":["../src/components/Icon/Icon.tsx","../src/components/Icon/index.ts"],"sourcesContent":["import React, { useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, IconSize } from '../../constants';\nimport { StatusDotOnColor } from '../StatusDot';\n\nexport type SvgIcon = React.FC<SvgPathProps>;\n\nexport interface BaseIconProps {\n /* aria-label for the <svg> element. Used as <title> tag. */\n ariaLabel?: string;\n /* Changes the size of the icon. */\n size?: number;\n /* Changes the color of the icon. */\n color?: string;\n /* Changes the hover color of the icon. */\n hoverColor?: string;\n /* Adds custom classes to the element. */\n className?: string;\n /* Swaps the displayed icon to the hover version and changes its color. */\n isHovered?: boolean;\n /** Defines the color of the icon */\n onColor?: keyof typeof FormOnColor | StatusDotOnColor;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport interface IconProps extends BaseIconProps {\n /* Sets which icon should be displayed. */\n svgIcon: SvgIcon;\n}\n\nexport interface SvgPathProps {\n size: IconSize;\n isHovered: boolean;\n onColor?: keyof typeof FormOnColor | StatusDotOnColor;\n}\n\ninterface IconConfig {\n size: IconSize;\n isHovered: boolean;\n normal: React.ReactElement;\n normalHover: React.ReactElement;\n xSmall?: React.ReactElement;\n xSmallHover?: React.ReactElement;\n xxSmall?: React.ReactElement;\n xxSmallHover?: React.ReactElement;\n}\n\nexport const getIcon = ({\n size,\n isHovered,\n normal,\n normalHover,\n xSmall,\n xSmallHover,\n xxSmall,\n xxSmallHover,\n}: IconConfig): React.ReactElement => {\n if (size <= IconSize.XXSmall && xxSmall && xxSmallHover) {\n return isHovered ? xxSmallHover : xxSmall;\n }\n if (size <= IconSize.XSmall && xSmall && xSmallHover) {\n return isHovered ? xSmallHover : xSmall;\n }\n\n return isHovered ? normalHover : normal;\n};\n\nexport const Icon = React.forwardRef((props: IconProps, ref: React.ForwardedRef<SVGSVGElement>) => {\n const {\n svgIcon,\n ariaLabel,\n className = '',\n size = IconSize.Small,\n color = 'black',\n hoverColor = color || 'black',\n isHovered = false,\n onColor,\n testId,\n ...other\n } = props;\n\n const svgRaw = React.createElement(svgIcon, {\n size,\n isHovered,\n onColor,\n });\n\n const titleId = useId();\n const svgColor = isHovered ? hoverColor : color;\n\n return (\n <svg\n data-testid={testId}\n data-analyticsid={AnalyticsId.Icon}\n ref={ref}\n className={classNames(`hnds-style-icon`, className)}\n role={ariaLabel ? 'img' : 'presentation'}\n aria-labelledby={ariaLabel ? titleId : undefined}\n focusable={false}\n aria-hidden={ariaLabel ? undefined : true}\n viewBox=\"0 0 48 48\"\n style={{ minWidth: size, minHeight: size }}\n width={size}\n height={size}\n fill={svgColor}\n color={svgColor}\n {...other}\n >\n {ariaLabel && <title id={titleId}>{ariaLabel}</title>}\n {svgRaw}\n </svg>\n );\n});\n\nIcon.displayName = 'Icon';\n\nexport default Icon;\n","export * from './Icon';\nexport { IconSize } from '../../constants';\n\nimport { Icon } from './Icon';\nexport default Icon;\n"],"mappings":";;;;AAkDA,MAAa,WAAW,EACtB,MACA,WACA,QACA,aACA,QACA,aACA,SACA,mBACoC;AACpC,KAAI,QAAQ,SAAS,WAAW,WAAW,aACzC,QAAO,YAAY,eAAe;AAEpC,KAAI,QAAQ,SAAS,UAAU,UAAU,YACvC,QAAO,YAAY,cAAc;AAGnC,QAAO,YAAY,cAAc;;AAGnC,MAAa,OAAO,MAAM,YAAY,OAAkB,QAA2C;CACjG,MAAM,EACJ,SACA,WACA,YAAY,IACZ,OAAO,SAAS,OAChB,QAAQ,SACR,aAAa,SAAS,SACtB,YAAY,OACZ,SACA,QACA,GAAG,UACD;CAEJ,MAAM,SAAS,MAAM,cAAc,SAAS;EAC1C;EACA;EACA;EACD,CAAC;CAEF,MAAM,UAAU,OAAO;CACvB,MAAM,WAAW,YAAY,aAAa;AAE1C,QACE,qBAAC,OAAA;EACC,eAAa;EACb,oBAAkB,YAAY;EACzB;EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"Icon.js","names":[],"sources":["../src/components/Icon/Icon.tsx","../src/components/Icon/index.ts"],"sourcesContent":["import React, { useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormOnColor, IconSize } from '../../constants';\nimport { StatusDotOnColor } from '../StatusDot';\n\nexport type SvgIcon = React.FC<SvgPathProps>;\n\nexport interface BaseIconProps {\n /* aria-label for the <svg> element. Used as <title> tag. */\n ariaLabel?: string;\n /* Changes the size of the icon. */\n size?: number;\n /* Changes the color of the icon. */\n color?: string;\n /* Changes the hover color of the icon. */\n hoverColor?: string;\n /* Adds custom classes to the element. */\n className?: string;\n /* Swaps the displayed icon to the hover version and changes its color. */\n isHovered?: boolean;\n /** Defines the color of the icon */\n onColor?: keyof typeof FormOnColor | StatusDotOnColor;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport interface IconProps extends BaseIconProps {\n /* Sets which icon should be displayed. */\n svgIcon: SvgIcon;\n}\n\nexport interface SvgPathProps {\n size: IconSize;\n isHovered: boolean;\n onColor?: keyof typeof FormOnColor | StatusDotOnColor;\n}\n\ninterface IconConfig {\n size: IconSize;\n isHovered: boolean;\n normal: React.ReactElement;\n normalHover: React.ReactElement;\n xSmall?: React.ReactElement;\n xSmallHover?: React.ReactElement;\n xxSmall?: React.ReactElement;\n xxSmallHover?: React.ReactElement;\n}\n\nexport const getIcon = ({\n size,\n isHovered,\n normal,\n normalHover,\n xSmall,\n xSmallHover,\n xxSmall,\n xxSmallHover,\n}: IconConfig): React.ReactElement => {\n if (size <= IconSize.XXSmall && xxSmall && xxSmallHover) {\n return isHovered ? xxSmallHover : xxSmall;\n }\n if (size <= IconSize.XSmall && xSmall && xSmallHover) {\n return isHovered ? xSmallHover : xSmall;\n }\n\n return isHovered ? normalHover : normal;\n};\n\nexport const Icon = React.forwardRef((props: IconProps, ref: React.ForwardedRef<SVGSVGElement>) => {\n const {\n svgIcon,\n ariaLabel,\n className = '',\n size = IconSize.Small,\n color = 'black',\n hoverColor = color || 'black',\n isHovered = false,\n onColor,\n testId,\n ...other\n } = props;\n\n const svgRaw = React.createElement(svgIcon, {\n size,\n isHovered,\n onColor,\n });\n\n const titleId = useId();\n const svgColor = isHovered ? hoverColor : color;\n\n return (\n <svg\n data-testid={testId}\n data-analyticsid={AnalyticsId.Icon}\n ref={ref}\n className={classNames(`hnds-style-icon`, className)}\n role={ariaLabel ? 'img' : 'presentation'}\n aria-labelledby={ariaLabel ? titleId : undefined}\n focusable={false}\n aria-hidden={ariaLabel ? undefined : true}\n viewBox=\"0 0 48 48\"\n style={{ minWidth: size, minHeight: size }}\n width={size}\n height={size}\n fill={svgColor}\n color={svgColor}\n {...other}\n >\n {ariaLabel && <title id={titleId}>{ariaLabel}</title>}\n {svgRaw}\n </svg>\n );\n});\n\nIcon.displayName = 'Icon';\n\nexport default Icon;\n","export * from './Icon';\nexport { IconSize } from '../../constants';\n\nimport { Icon } from './Icon';\nexport default Icon;\n"],"mappings":";;;;AAkDA,MAAa,WAAW,EACtB,MACA,WACA,QACA,aACA,QACA,aACA,SACA,mBACoC;AACpC,KAAI,QAAQ,SAAS,WAAW,WAAW,aACzC,QAAO,YAAY,eAAe;AAEpC,KAAI,QAAQ,SAAS,UAAU,UAAU,YACvC,QAAO,YAAY,cAAc;AAGnC,QAAO,YAAY,cAAc;;AAGnC,MAAa,OAAO,MAAM,YAAY,OAAkB,QAA2C;CACjG,MAAM,EACJ,SACA,WACA,YAAY,IACZ,OAAO,SAAS,OAChB,QAAQ,SACR,aAAa,SAAS,SACtB,YAAY,OACZ,SACA,QACA,GAAG,UACD;CAEJ,MAAM,SAAS,MAAM,cAAc,SAAS;EAC1C;EACA;EACA;EACD,CAAC;CAEF,MAAM,UAAU,OAAO;CACvB,MAAM,WAAW,YAAY,aAAa;AAE1C,QACE,qBAAC,OAAA;EACC,eAAa;EACb,oBAAkB,YAAY;EACzB;EACL,WAAW,GAAW,mBAAmB,UAAU;EACnD,MAAM,YAAY,QAAQ;EAC1B,mBAAiB,YAAY,UAAU,KAAA;EACvC,WAAW;EACX,eAAa,YAAY,KAAA,IAAY;EACrC,SAAQ;EACR,OAAO;GAAE,UAAU;GAAM,WAAW;GAAM;EAC1C,OAAO;EACP,QAAQ;EACR,MAAM;EACN,OAAO;EACP,GAAI;aAEH,aAAa,oBAAC,SAAA;GAAM,IAAI;aAAU;IAAkB,EACpD,OAAA;GACG;EAER;AAEF,KAAK,cAAc;ACjHnB,IAAA,eAAe"}
|
package/lib/InfoTeaser.js
CHANGED
|
@@ -4,7 +4,7 @@ import { r as useLanguage } from "./language.js";
|
|
|
4
4
|
import { t as LazyIcon_default } from "./LazyIcon.js";
|
|
5
5
|
import { t as Title_default } from "./Title2.js";
|
|
6
6
|
import React, { useId, useState } from "react";
|
|
7
|
-
import
|
|
7
|
+
import cn from "classnames";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import styles from "./components/InfoTeaser/styles.module.scss";
|
|
10
10
|
var HN_Designsystem_InfoTeaser_en_GB_default = {
|
|
@@ -37,7 +37,7 @@ var InfoTeaser = (props) => {
|
|
|
37
37
|
"data-testid": testId,
|
|
38
38
|
"data-analyticsid": AnalyticsId.InfoTeaser,
|
|
39
39
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
40
|
-
className:
|
|
40
|
+
className: cn(styles.infoteaser, className, { [styles["infoteaser--collapsed"]]: !expanded }),
|
|
41
41
|
children: [
|
|
42
42
|
svgIcon && (typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
43
43
|
iconName: svgIcon,
|
|
@@ -64,7 +64,7 @@ var InfoTeaser = (props) => {
|
|
|
64
64
|
]
|
|
65
65
|
}), /* @__PURE__ */ jsx("button", {
|
|
66
66
|
type: "button",
|
|
67
|
-
className:
|
|
67
|
+
className: cn(styles.infoteaser__button, buttonClassName),
|
|
68
68
|
onClick: () => {
|
|
69
69
|
setExpanded(!expanded);
|
|
70
70
|
},
|
package/lib/InfoTeaser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTeaser.js","names":["InfoTeaser: React.FC<InfoTeaserProps>","mergedResources: HNDesignsystemInfoTeaser"],"sources":["../src/resources/HN.Designsystem.InfoTeaser.en-GB.json","../src/resources/HN.Designsystem.InfoTeaser.nb-NO.json","../src/components/InfoTeaser/resourceHelper.ts","../src/components/InfoTeaser/InfoTeaser.tsx","../src/components/InfoTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"Show less\",\n \"expandButtonClose\": \"Show more\"\n}\n","{\n \"expandButtonOpen\": \"Vis mindre\",\n \"expandButtonClose\": \"Vis mer\"\n}\n","import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.InfoTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.InfoTeaser.nb-NO.json';\nimport { HNDesignsystemInfoTeaser } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemInfoTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemInfoTeaser } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport LazyIcon from '../LazyIcon';\nimport Title, { TitleTags } from '../Title';\nimport { getResources } from './resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport type InfoTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface InfoTeaserProps {\n /** For overriding styling on the button */\n buttonClassName?: string;\n /** What's in the box? */\n children: React.ReactNode;\n /** For overriding styling on infoteaser box */\n className?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: InfoTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemInfoTeaser>;\n /** Adds an icon */\n svgIcon?: SvgIcon | IconName;\n /** Sets the data-testid attribute */\n testId?: string;\n /** Title on top of the component */\n title: string;\n /** Markup props for title */\n titleHtmlMarkup?: TitleTags;\n}\n\nconst InfoTeaser: React.FC<InfoTeaserProps> = props => {\n const { buttonClassName, children, className, htmlMarkup = 'div', resources, svgIcon, testId, title, titleHtmlMarkup = 'h2' } = props;\n const [expanded, setExpanded] = useState(false);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const infoteaserTextId = useId();\n\n const mergedResources: HNDesignsystemInfoTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n const WrapperTag = htmlMarkup;\n\n return (\n <WrapperTag className={styles.wrapper} data-testid={testId} data-analyticsid={AnalyticsId.InfoTeaser}>\n <div\n className={classNames(styles.infoteaser, className, {\n [styles['infoteaser--collapsed']]: !expanded,\n })}\n >\n {svgIcon &&\n (typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.Small} className={styles.infoteaser__icon} />\n ) : (\n <Icon svgIcon={svgIcon} size={IconSize.Small} className={styles.infoteaser__icon} />\n ))}\n <Title testId=\"titleId\" htmlMarkup={titleHtmlMarkup} appearance=\"title4\" className={styles.infoteaser__title}>\n {title}\n </Title>\n <div className={styles.infoteaser__text} aria-hidden={expanded ? false : true} id={infoteaserTextId}>\n {children}\n </div>\n </div>\n <button\n type=\"button\"\n className={classNames(styles.infoteaser__button, buttonClassName)}\n onClick={() => {\n setExpanded(!expanded);\n }}\n aria-expanded={expanded}\n aria-controls={infoteaserTextId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default InfoTeaser;\n","import InfoTeaser from './InfoTeaser';\nexport * from './InfoTeaser';\nexport default InfoTeaser;\n"],"mappings":";;;;;;;;;;;;;;;;;AEKA,MAAa,gBAAgB,aAAwD;AACnF,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;AC2Bb,IAAMA,cAAwC,UAAS;CACrD,MAAM,EAAE,iBAAiB,UAAU,WAAW,aAAa,OAAO,WAAW,SAAS,QAAQ,OAAO,kBAAkB,SAAS;CAChI,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM;CAC/C,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAC5E,MAAM,mBAAmB,aAAa,SAAS;CAC/C,MAAM,mBAAmB,OAAO;CAEhC,MAAMC,kBAA4C;EAChD,GAAG;EACH,GAAG;EACJ;AAID,QACE,qBAHiB,YAGhB;EAAW,WAAW,OAAO;EAAS,eAAa;EAAQ,oBAAkB,YAAY;aACxF,qBAAC,OAAA;GACC,WAAW,
|
|
1
|
+
{"version":3,"file":"InfoTeaser.js","names":["InfoTeaser: React.FC<InfoTeaserProps>","mergedResources: HNDesignsystemInfoTeaser"],"sources":["../src/resources/HN.Designsystem.InfoTeaser.en-GB.json","../src/resources/HN.Designsystem.InfoTeaser.nb-NO.json","../src/components/InfoTeaser/resourceHelper.ts","../src/components/InfoTeaser/InfoTeaser.tsx","../src/components/InfoTeaser/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"Show less\",\n \"expandButtonClose\": \"Show more\"\n}\n","{\n \"expandButtonOpen\": \"Vis mindre\",\n \"expandButtonClose\": \"Vis mer\"\n}\n","import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.InfoTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.InfoTeaser.nb-NO.json';\nimport { HNDesignsystemInfoTeaser } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemInfoTeaser => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemInfoTeaser } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport LazyIcon from '../LazyIcon';\nimport Title, { TitleTags } from '../Title';\nimport { getResources } from './resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport type InfoTeaserTags = 'div' | 'section' | 'aside' | 'article';\n\nexport interface InfoTeaserProps {\n /** For overriding styling on the button */\n buttonClassName?: string;\n /** What's in the box? */\n children: React.ReactNode;\n /** For overriding styling on infoteaser box */\n className?: string;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: InfoTeaserTags;\n /** Resources for component */\n resources?: Partial<HNDesignsystemInfoTeaser>;\n /** Adds an icon */\n svgIcon?: SvgIcon | IconName;\n /** Sets the data-testid attribute */\n testId?: string;\n /** Title on top of the component */\n title: string;\n /** Markup props for title */\n titleHtmlMarkup?: TitleTags;\n}\n\nconst InfoTeaser: React.FC<InfoTeaserProps> = props => {\n const { buttonClassName, children, className, htmlMarkup = 'div', resources, svgIcon, testId, title, titleHtmlMarkup = 'h2' } = props;\n const [expanded, setExpanded] = useState(false);\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const infoteaserTextId = useId();\n\n const mergedResources: HNDesignsystemInfoTeaser = {\n ...defaultResources,\n ...resources,\n };\n\n const WrapperTag = htmlMarkup;\n\n return (\n <WrapperTag className={styles.wrapper} data-testid={testId} data-analyticsid={AnalyticsId.InfoTeaser}>\n <div\n className={classNames(styles.infoteaser, className, {\n [styles['infoteaser--collapsed']]: !expanded,\n })}\n >\n {svgIcon &&\n (typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.Small} className={styles.infoteaser__icon} />\n ) : (\n <Icon svgIcon={svgIcon} size={IconSize.Small} className={styles.infoteaser__icon} />\n ))}\n <Title testId=\"titleId\" htmlMarkup={titleHtmlMarkup} appearance=\"title4\" className={styles.infoteaser__title}>\n {title}\n </Title>\n <div className={styles.infoteaser__text} aria-hidden={expanded ? false : true} id={infoteaserTextId}>\n {children}\n </div>\n </div>\n <button\n type=\"button\"\n className={classNames(styles.infoteaser__button, buttonClassName)}\n onClick={() => {\n setExpanded(!expanded);\n }}\n aria-expanded={expanded}\n aria-controls={infoteaserTextId}\n >\n {expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose}\n </button>\n </WrapperTag>\n );\n};\n\nexport default InfoTeaser;\n","import InfoTeaser from './InfoTeaser';\nexport * from './InfoTeaser';\nexport default InfoTeaser;\n"],"mappings":";;;;;;;;;;;;;;;;;AEKA,MAAa,gBAAgB,aAAwD;AACnF,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;AC2Bb,IAAMA,cAAwC,UAAS;CACrD,MAAM,EAAE,iBAAiB,UAAU,WAAW,aAAa,OAAO,WAAW,SAAS,QAAQ,OAAO,kBAAkB,SAAS;CAChI,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM;CAC/C,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAC5E,MAAM,mBAAmB,aAAa,SAAS;CAC/C,MAAM,mBAAmB,OAAO;CAEhC,MAAMC,kBAA4C;EAChD,GAAG;EACH,GAAG;EACJ;AAID,QACE,qBAHiB,YAGhB;EAAW,WAAW,OAAO;EAAS,eAAa;EAAQ,oBAAkB,YAAY;aACxF,qBAAC,OAAA;GACC,WAAW,GAAW,OAAO,YAAY,WAAW,GACjD,OAAO,2BAA2B,CAAC,UACrC,CAAC;;IAED,YACE,OAAO,YAAY,WAClB,oBAAC,kBAAA;KAAS,UAAU;KAAS,MAAM,SAAS;KAAO,WAAW,OAAO;MAAoB,GAEzF,oBAAC,cAAA;KAAc;KAAS,MAAM,SAAS;KAAO,WAAW,OAAO;MAAoB;IAExF,oBAAC,eAAA;KAAM,QAAO;KAAU,YAAY;KAAiB,YAAW;KAAS,WAAW,OAAO;eACxF;MACK;IACR,oBAAC,OAAA;KAAI,WAAW,OAAO;KAAkB,eAAa,WAAW,QAAQ;KAAM,IAAI;KAChF;MACG;;IACF,EACN,oBAAC,UAAA;GACC,MAAK;GACL,WAAW,GAAW,OAAO,oBAAoB,gBAAgB;GACjE,eAAe;AACb,gBAAY,CAAC,SAAS;;GAExB,iBAAe;GACf,iBAAe;aAEd,WAAW,gBAAgB,mBAAmB,gBAAgB;IACxD,CAAA;GACE;;ACjFjB,IAAA,uBDqFe"}
|
package/lib/Input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as IconSize, i as FormSize, n as AnalyticsId, r as FormOnColor, t as AVERAGE_CHARACTER_WIDTH_PX } from "./constants2.js";
|
|
2
2
|
import { t as getColor } from "./color.js";
|
|
3
|
-
import { t as Icon_default } from "./Icon.js";
|
|
4
3
|
import { n as mergeRefs } from "./refs.js";
|
|
4
|
+
import { t as Icon_default } from "./Icon.js";
|
|
5
5
|
import { t as LazyIcon_default } from "./LazyIcon.js";
|
|
6
6
|
import { n as useBreakpoint, t as Breakpoint } from "./useBreakpoint.js";
|
|
7
7
|
import { t as useIdWithFallback } from "./useIdWithFallback.js";
|
|
@@ -10,7 +10,7 @@ import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
|
|
|
10
10
|
import { r as renderLabel } from "./Label.js";
|
|
11
11
|
import { t as MaxCharacters_default } from "./MaxCharacters.js";
|
|
12
12
|
import React, { useEffect, useRef, useState } from "react";
|
|
13
|
-
import
|
|
13
|
+
import cn from "classnames";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import styles from "./components/Input/styles.module.scss";
|
|
16
16
|
let InputTypes = /* @__PURE__ */ function(InputTypes$1) {
|
|
@@ -49,18 +49,17 @@ var Input = React.forwardRef((props, ref) => {
|
|
|
49
49
|
const onError = onColor === FormOnColor.oninvalid || !!errorText || !!error || maxCharactersExceeded;
|
|
50
50
|
const isLarge = size === FormSize.large;
|
|
51
51
|
const isTransparent = transparent && onColor !== FormOnColor.ondark && !onError;
|
|
52
|
-
const inputWrapperClass =
|
|
53
|
-
const inputContainer =
|
|
52
|
+
const inputWrapperClass = cn(styles["input-wrapper"], className);
|
|
53
|
+
const inputContainer = cn(styles["input-container"], {
|
|
54
54
|
[styles["input-container--transparent"]]: isTransparent,
|
|
55
55
|
[styles["input-container--on-blueberry"]]: onBlueberry,
|
|
56
56
|
[styles["input-container--on-dark"]]: onDark,
|
|
57
57
|
[styles["input-container--invalid"]]: onError,
|
|
58
|
-
[styles["input-container--large"]]: isLarge,
|
|
59
58
|
[styles["input-container--disabled"]]: disabled,
|
|
60
59
|
[styles["input-container--with-icon"]]: icon,
|
|
61
60
|
[styles["input-container--with-icon--right"]]: icon && iconRight
|
|
62
61
|
});
|
|
63
|
-
const inputClass =
|
|
62
|
+
const inputClass = cn(styles["input-container__input"], {
|
|
64
63
|
[styles["input-container__input--large"]]: isLarge,
|
|
65
64
|
[styles["input-container__input--disabled"]]: disabled
|
|
66
65
|
});
|