@helsenorge/designsystem-react 15.5.0 → 15.6.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/lib/AnchorLink.js.map +1 -1
- package/lib/Avatar.js.map +1 -1
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +21 -0
- package/lib/Checkbox.js +5 -3
- package/lib/Checkbox.js.map +1 -1
- package/lib/Checkbox2.js.map +1 -1
- package/lib/CheckboxMarker.js.map +1 -1
- package/lib/Chip.js.map +1 -1
- package/lib/Close.js.map +1 -1
- package/lib/Drawer.js.map +1 -1
- package/lib/DrawerNavigation.js.map +1 -1
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js.map +1 -1
- package/lib/ElementHeaderText.js.map +1 -1
- package/lib/ErrorWrapper.js +2 -1
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +2 -1
- package/lib/Expander.js.map +1 -1
- package/lib/FilterButton.js.map +1 -1
- package/lib/FilterButtonAndChipsWrapper.js.map +1 -1
- package/lib/FilterDrawer.js.map +1 -1
- package/lib/FilterLinkList.js +2 -1
- package/lib/FilterLinkList.js.map +1 -1
- package/lib/FilterOverviewSearch.js.map +1 -1
- package/lib/FilterResultCountAndSortWrapper.js.map +1 -1
- package/lib/FilterSearch.js.map +1 -1
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +9 -2
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +9 -1
- package/lib/FormLayout.js.map +1 -1
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/Highlighter.js.map +1 -1
- package/lib/HorizontalScroll.js.map +1 -1
- package/lib/Icon.js.map +1 -1
- package/lib/Illustration.js.map +1 -1
- package/lib/Input.js.map +1 -1
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LazyIllustration.js.map +1 -1
- package/lib/LinkList.js +31 -28
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +4 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +5 -4
- package/lib/ListEditMode.js.map +1 -1
- package/lib/LoaderSpinner.js.map +1 -1
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +5 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/Radio.js.map +1 -1
- package/lib/RadioButton.js.map +1 -1
- package/lib/RadioMarker.js +11 -10
- package/lib/RadioMarker.js.map +1 -1
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js.map +1 -1
- package/lib/Slider.js +0 -2
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +16 -15
- package/lib/Spacer.js.map +1 -1
- package/lib/StatusDot.js.map +1 -1
- package/lib/StatusDotList.js.map +1 -1
- package/lib/StepButtons.js.map +1 -1
- package/lib/TabList.js.map +1 -1
- package/lib/TabPanel.js +2 -1
- package/lib/TabPanel.js.map +1 -1
- package/lib/TableBody.js +2 -1
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +2 -1
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +6 -3
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +2 -1
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +7 -6
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +7 -5
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js.map +1 -1
- package/lib/Title.js +20 -17
- package/lib/Title.js.map +1 -1
- package/lib/Toast.js.map +1 -1
- package/lib/Toggle.js +176 -0
- package/lib/Toggle.js.map +1 -0
- package/lib/VisualCheckbox.js.map +1 -1
- package/lib/VisualRadio.js.map +1 -1
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Close/styles.module.scss +2 -2
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/DropdownOld/index.js.map +1 -1
- package/lib/components/EmptyState/index.js +1 -3
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/index.js +2 -1
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +7 -6
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/EyebrowHeader/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +9 -7
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/FormGroup/styles.module.scss +15 -3
- package/lib/components/FormGroup/styles.module.scss.d.ts +2 -0
- package/lib/components/FormLayout/styles.module.scss +9 -1
- package/lib/components/FormLayout/styles.module.scss.d.ts +2 -0
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpExpanderInline/index.js.map +1 -1
- package/lib/components/HelpExpanderStandalone/index.js.map +1 -1
- package/lib/components/HelpPanel/HelpPanel.d.ts +2 -2
- package/lib/components/HelpPanel/index.js +49 -9
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpPanel/styles.module.scss +66 -2
- package/lib/components/HelpPanel/styles.module.scss.d.ts +8 -0
- package/lib/components/HelpTeaser/HelpTeaser.d.ts +5 -2
- package/lib/components/HelpTeaser/index.js +59 -14
- package/lib/components/HelpTeaser/index.js.map +1 -1
- package/lib/components/HelpTeaser/styles.module.scss +105 -2
- package/lib/components/HelpTeaser/styles.module.scss.d.ts +6 -0
- package/lib/components/HelpTooltip/index.js +6 -3
- package/lib/components/HelpTooltip/index.js.map +1 -1
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/HighlightPanel/index.js +79 -1
- package/lib/components/HighlightPanel/index.js.map +1 -0
- package/lib/components/Icons/AlarmClock.js.map +1 -1
- package/lib/components/Icons/Bus.js.map +1 -1
- package/lib/components/Illustrations/BabyMobile.js +5 -4
- package/lib/components/Illustrations/BabyMobile.js.map +1 -1
- package/lib/components/Illustrations/BabyMobileMedium.js.map +1 -1
- package/lib/components/Illustrations/Child.js +5 -4
- package/lib/components/Illustrations/Child.js.map +1 -1
- package/lib/components/Illustrations/ChildMedium.js.map +1 -1
- package/lib/components/Illustrations/Doctor.js +10 -8
- package/lib/components/Illustrations/Doctor.js.map +1 -1
- package/lib/components/Illustrations/DoctorMedium.js.map +1 -1
- package/lib/components/Illustrations/DoctorSmall.js.map +1 -1
- package/lib/components/Illustrations/EyeContact.js +5 -4
- package/lib/components/Illustrations/EyeContact.js.map +1 -1
- package/lib/components/Illustrations/EyeContactMedium.js.map +1 -1
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js +5 -4
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js.map +1 -1
- package/lib/components/Illustrations/FacialRecognitionFingerprintMedium.js.map +1 -1
- package/lib/components/Illustrations/GiveBabyFood.js +5 -4
- package/lib/components/Illustrations/GiveBabyFood.js.map +1 -1
- package/lib/components/Illustrations/GiveBabyFoodMedium.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnel.js +10 -8
- package/lib/components/Illustrations/HealthcarePersonnel.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnelMedium.js.map +1 -1
- package/lib/components/Illustrations/HealthcarePersonnelSmall.js.map +1 -1
- package/lib/components/Illustrations/ReadLetters.js +5 -4
- package/lib/components/Illustrations/ReadLetters.js.map +1 -1
- package/lib/components/Illustrations/ReadLettersMedium.js.map +1 -1
- package/lib/components/Illustrations/SkinToSkin.js +5 -4
- package/lib/components/Illustrations/SkinToSkin.js.map +1 -1
- package/lib/components/Illustrations/SkinToSkinMedium.js.map +1 -1
- package/lib/components/Illustrations/Stork.js +5 -4
- package/lib/components/Illustrations/Stork.js.map +1 -1
- package/lib/components/Illustrations/StorkMedium.js.map +1 -1
- package/lib/components/Illustrations/Stroller.js +5 -4
- package/lib/components/Illustrations/Stroller.js.map +1 -1
- package/lib/components/Illustrations/StrollerMedium.js.map +1 -1
- package/lib/components/Illustrations/Support2.js +5 -4
- package/lib/components/Illustrations/Support2.js.map +1 -1
- package/lib/components/Illustrations/Support2Medium.js.map +1 -1
- package/lib/components/Illustrations/Thinking.js +5 -4
- package/lib/components/Illustrations/Thinking.js.map +1 -1
- package/lib/components/Illustrations/ThinkingMedium.js.map +1 -1
- package/lib/components/InfoTeaser/index.js +71 -1
- package/lib/components/InfoTeaser/index.js.map +1 -0
- package/lib/components/Loader/index.js +14 -13
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Logo/index.js.map +1 -1
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +7 -4
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +17 -16
- package/lib/components/Panel/index.js.map +1 -1
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +6 -5
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/RadioButton/styles.module.scss +6 -6
- package/lib/components/ServiceMessage/index.js +2 -1
- package/lib/components/ServiceMessage/index.js.map +1 -1
- package/lib/components/SharingStatus/index.js.map +1 -1
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.js +4 -2
- package/lib/components/Stepper/index.js.map +1 -1
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/Table/index.js +2 -5
- package/lib/components/Table/index.js.map +1 -1
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/Tag/index.js +2 -1
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/TagList/index.js.map +1 -1
- package/lib/components/Tile/index.js +5 -4
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/ToastList/index.js +2 -1
- package/lib/components/ToastList/index.js.map +1 -1
- package/lib/components/Toggle/index.js +1 -172
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/components/VisualCheckboxCloud/index.js.map +1 -1
- package/lib/components/VisualCheckboxGroup/index.js.map +1 -1
- package/lib/components/VisualContentgroupWithImage/index.js.map +1 -1
- package/lib/components/VisualRadioCloud/index.js.map +1 -1
- package/lib/components/VisualRadioGroup/index.js.map +1 -1
- package/lib/floating-ui.react.js +91 -111
- package/lib/floating-ui.react.js.map +1 -1
- package/lib/getFilterChips.js.map +1 -1
- package/lib/resourceHelper2.js +22 -0
- package/lib/resourceHelper2.js.map +1 -0
- package/lib/theme/spacers.js +2 -2
- package/lib/theme/spacers.js.map +1 -1
- package/lib/utils/formSpacing.d.ts +3 -0
- package/lib/utils/formSpacing.js +16 -0
- package/lib/utils/formSpacing.js.map +1 -0
- package/lib/utils2.js.map +1 -1
- package/package.json +1 -1
- package/lib/HighlightPanel.js +0 -80
- package/lib/HighlightPanel.js.map +0 -1
- package/lib/InfoTeaser.js +0 -89
- package/lib/InfoTeaser.js.map +0 -1
- package/lib/components/Toggle/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilterChips.js","names":[],"sources":["../src/components/Filter/getFilterChips/getFilterChips.tsx","../src/components/Filter/getFilterChips/index.ts"],"sourcesContent":["import type { FilterValues, UseFilterReturn } from '../useFilter';\n\nimport Chip from '../../Chip';\n\nexport interface GetFilterChipsArgs<T extends FilterValues> {\n /** The filter instance from useFilter */\n filter: UseFilterReturn<T>;\n /** Look up the display label for a filter key + value */\n getLabel: (key: keyof T, value: unknown) => string;\n /** Called when a chip is clicked (f.ex. to open the drawer at that filter category) */\n onChipClick: (key: keyof T, value: unknown) => void;\n /** Called when a chip's close button is clicked. If not provided, defaults to filter.removeFilter */\n onChipRemove?: (key: keyof T, value: unknown) => void;\n /** Called when the overflow chip is clicked */\n onOverflowChipClick: () => void;\n /** Function for mapping if close button is shown on chip or not */\n willShowCloseButton?: (key: keyof T, value?: unknown) => boolean;\n}\n\nfunction getFilterChips<T extends FilterValues>({\n filter,\n getLabel,\n onChipClick,\n onChipRemove,\n onOverflowChipClick,\n willShowCloseButton,\n}: GetFilterChipsArgs<T>): React.ReactNode[] {\n const maxVisible = 5;\n\n const allChips = Object.entries(filter.filters).flatMap(([key, raw]) => {\n const values = [raw ?? []].flat();\n return values.map(v => ({ key, value: v }));\n });\n\n const visibleChips = allChips.slice(0, maxVisible);\n const overflowCount = allChips.length - maxVisible;\n\n return [\n ...visibleChips.map(({ key, value: v }) => (\n <Chip\n key={`${key}-${v}`}\n onChipClick={() => onChipClick(key as keyof T, v)}\n onCloseClick={() => {\n if (onChipRemove) {\n onChipRemove(key as keyof T, v);\n } else {\n filter.removeFilter(key, v);\n }\n }}\n withCloseButton={willShowCloseButton?.(key, v)}\n >\n {getLabel(key as keyof T, v)}\n </Chip>\n )),\n ...(overflowCount > 0\n ? [<Chip key=\"overflow\" onChipClick={onOverflowChipClick} withCloseButton={false}>{`+${overflowCount}`}</Chip>]\n : []),\n ];\n}\n\nexport default getFilterChips;\n","import getFilterChips from './getFilterChips';\nexport * from './getFilterChips';\nexport default getFilterChips;\n"],"mappings":";;;AAmBA,SAAS,eAAuC,EAC9C,QACA,UACA,aACA,cACA,qBACA,uBAC2C;CAC3C,MAAM,aAAa;CAEnB,MAAM,WAAW,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS;EAEtE,OADe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KACpB,CAAA,CAAO,KAAI,OAAM;GAAE;GAAK,OAAO;EAAE,EAAE;CAC5C,CAAC;CAED,MAAM,eAAe,SAAS,MAAM,GAAG,UAAU;CACjD,MAAM,gBAAgB,SAAS,SAAS;CAExC,OAAO,CACL,GAAG,aAAa,KAAK,EAAE,KAAK,OAAO,QACjC,oBAAC,cAAD;EAEE,mBAAmB,YAAY,KAAgB,CAAC;EAChD,oBAAoB;GAClB,IAAI,cACF,aAAa,KAAgB,CAAC;QAE9B,OAAO,aAAa,KAAK,CAAC;EAE9B;EACA,iBAAiB,sBAAsB,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"getFilterChips.js","names":[],"sources":["../src/components/Filter/getFilterChips/getFilterChips.tsx","../src/components/Filter/getFilterChips/index.ts"],"sourcesContent":["import type { FilterValues, UseFilterReturn } from '../useFilter';\n\nimport Chip from '../../Chip';\n\nexport interface GetFilterChipsArgs<T extends FilterValues> {\n /** The filter instance from useFilter */\n filter: UseFilterReturn<T>;\n /** Look up the display label for a filter key + value */\n getLabel: (key: keyof T, value: unknown) => string;\n /** Called when a chip is clicked (f.ex. to open the drawer at that filter category) */\n onChipClick: (key: keyof T, value: unknown) => void;\n /** Called when a chip's close button is clicked. If not provided, defaults to filter.removeFilter */\n onChipRemove?: (key: keyof T, value: unknown) => void;\n /** Called when the overflow chip is clicked */\n onOverflowChipClick: () => void;\n /** Function for mapping if close button is shown on chip or not */\n willShowCloseButton?: (key: keyof T, value?: unknown) => boolean;\n}\n\nfunction getFilterChips<T extends FilterValues>({\n filter,\n getLabel,\n onChipClick,\n onChipRemove,\n onOverflowChipClick,\n willShowCloseButton,\n}: GetFilterChipsArgs<T>): React.ReactNode[] {\n const maxVisible = 5;\n\n const allChips = Object.entries(filter.filters).flatMap(([key, raw]) => {\n const values = [raw ?? []].flat();\n return values.map(v => ({ key, value: v }));\n });\n\n const visibleChips = allChips.slice(0, maxVisible);\n const overflowCount = allChips.length - maxVisible;\n\n return [\n ...visibleChips.map(({ key, value: v }) => (\n <Chip\n key={`${key}-${v}`}\n onChipClick={() => onChipClick(key as keyof T, v)}\n onCloseClick={() => {\n if (onChipRemove) {\n onChipRemove(key as keyof T, v);\n } else {\n filter.removeFilter(key, v);\n }\n }}\n withCloseButton={willShowCloseButton?.(key, v)}\n >\n {getLabel(key as keyof T, v)}\n </Chip>\n )),\n ...(overflowCount > 0\n ? [<Chip key=\"overflow\" onChipClick={onOverflowChipClick} withCloseButton={false}>{`+${overflowCount}`}</Chip>]\n : []),\n ];\n}\n\nexport default getFilterChips;\n","import getFilterChips from './getFilterChips';\nexport * from './getFilterChips';\nexport default getFilterChips;\n"],"mappings":";;;AAmBA,SAAS,eAAuC,EAC9C,QACA,UACA,aACA,cACA,qBACA,uBAC2C;CAC3C,MAAM,aAAa;CAEnB,MAAM,WAAW,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS;EAEtE,OADe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KACpB,CAAA,CAAO,KAAI,OAAM;GAAE;GAAK,OAAO;EAAE,EAAE;CAC5C,CAAC;CAED,MAAM,eAAe,SAAS,MAAM,GAAG,UAAU;CACjD,MAAM,gBAAgB,SAAS,SAAS;CAExC,OAAO,CACL,GAAG,aAAa,KAAK,EAAE,KAAK,OAAO,QACjC,oBAAC,cAAD;EAEE,mBAAmB,YAAY,KAAgB,CAAC;EAChD,oBAAoB;GAClB,IAAI,cACF,aAAa,KAAgB,CAAC;QAE9B,OAAO,aAAa,KAAK,CAAC;EAE9B;EACA,iBAAiB,sBAAsB,KAAK,CAAC;EAE5C,UAAA,SAAS,KAAgB,CAAC;CACvB,GAZC,GAAG,IAAI,GAAG,GAYX,CACP,GACD,GAAI,gBAAgB,IAChB,CAAC,oBAAC,cAAD;EAAqB,aAAa;EAAqB,iBAAiB;EAAQ,UAAA,IAAI;CAAsB,GAAhG,UAAgG,CAAC,IAC5G,CAAC,CACP;AACF;;;ACxDA,IAAA,yBAAe"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LanguageLocales } from "./constants.js";
|
|
2
|
+
var HN_Designsystem_InfoTeaser_en_GB_default = {
|
|
3
|
+
expandButtonOpen: "Show less",
|
|
4
|
+
expandButtonClose: "Show more"
|
|
5
|
+
};
|
|
6
|
+
var HN_Designsystem_InfoTeaser_nb_NO_default = {
|
|
7
|
+
expandButtonOpen: "Vis mindre",
|
|
8
|
+
expandButtonClose: "Vis mer"
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/components/InfoTeaser/resourceHelper.ts
|
|
12
|
+
var getResources = (language) => {
|
|
13
|
+
switch (language) {
|
|
14
|
+
case LanguageLocales.ENGLISH: return HN_Designsystem_InfoTeaser_en_GB_default;
|
|
15
|
+
case LanguageLocales.NORWEGIAN:
|
|
16
|
+
default: return HN_Designsystem_InfoTeaser_nb_NO_default;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getResources as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=resourceHelper2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceHelper2.js","names":[],"sources":["../src/resources/HN.Designsystem.InfoTeaser.en-GB.json","../src/resources/HN.Designsystem.InfoTeaser.nb-NO.json","../src/components/InfoTeaser/resourceHelper.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"Show less\",\n \"expandButtonClose\": \"Show more\"\n}\n","{\n \"expandButtonOpen\": \"Vis mindre\",\n \"expandButtonClose\": \"Vis mer\"\n}\n","import type { HNDesignsystemInfoTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.InfoTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.InfoTeaser.nb-NO.json';\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"],"mappings":";;;;;;;;;;;AEMA,IAAa,gBAAgB,aAAwD;CACnF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF"}
|
package/lib/theme/spacers.js
CHANGED
package/lib/theme/spacers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacers.js","names":[],"sources":["../../src/theme/spacers.ts"],"sourcesContent":["export type SpacerSizes = '4xs' | '3xs' | '2xs' | 'xs' | 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';\n\nexport const spacer = 1;\n\nexport const spacers = {\n 0: 0,\n 1: spacer / 8,\n 2: spacer / 4,\n 3: spacer / 2,\n 4: spacer * 0.75,\n 5: spacer * 1,\n 6: spacer * 1.5,\n 7: spacer * 2,\n 8: spacer * 3,\n 9: spacer * 4,\n 10: spacer * 5,\n 11: spacer * 6,\n 12: spacer * 7,\n 13: spacer * 8,\n};\n"],"mappings":";AAEA,IAAa,SAAS;AAEtB,IAAa,UAAU;CACrB,GAAG;CACH,GAAA,IAAY;CACZ,GAAA,IAAY;CACZ,GAAA,IAAY;CACZ,GAAA,
|
|
1
|
+
{"version":3,"file":"spacers.js","names":[],"sources":["../../src/theme/spacers.ts"],"sourcesContent":["export type SpacerSizes = '4xs' | '3xs' | '2xs' | 'xs' | 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';\n\nexport const spacer = 1;\n\nexport const spacers = {\n 0: 0,\n 1: spacer / 8,\n 2: spacer / 4,\n 3: spacer / 2,\n 4: spacer * 0.75,\n 5: spacer * 1,\n 6: spacer * 1.5,\n 7: spacer * 2,\n 8: spacer * 3,\n 9: spacer * 4,\n 10: spacer * 5,\n 11: spacer * 6,\n 12: spacer * 7,\n 13: spacer * 8,\n};\n"],"mappings":";AAEA,IAAa,SAAS;AAEtB,IAAa,UAAU;CACrB,GAAG;CACH,GAAA,IAAY;CACZ,GAAA,IAAY;CACZ,GAAA,IAAY;CACZ,GAAA;CACA,GAAG;CACH,GAAA;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isComponent } from "./component.js";
|
|
2
|
+
import { t as Checkbox } from "../Checkbox.js";
|
|
3
|
+
import { t as RadioButton } from "../RadioButton.js";
|
|
4
|
+
import { t as Toggle_default } from "../Toggle.js";
|
|
5
|
+
import React from "react";
|
|
6
|
+
//#region src/utils/formSpacing.ts
|
|
7
|
+
var isCompactComponent = (child) => isComponent(child, Checkbox) || isComponent(child, RadioButton) || isComponent(child, Toggle_default);
|
|
8
|
+
var hasSublabel = (child) => {
|
|
9
|
+
if (isComponent(child, Checkbox) || isComponent(child, RadioButton)) return React.isValidElement(child.props.label) && !!child.props.label.props.sublabel;
|
|
10
|
+
if (isComponent(child, Toggle_default)) return !!child.props.subLabel;
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { hasSublabel, isCompactComponent };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=formSpacing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formSpacing.js","names":[],"sources":["../../src/utils/formSpacing.ts"],"sourcesContent":["import React from 'react';\n\nimport type { CheckboxProps } from '../components/Checkbox/Checkbox';\nimport type { LabelProps } from '../components/Label';\nimport type { RadioButtonProps } from '../components/RadioButton/RadioButton';\nimport type { ToggleProps } from '../components/Toggle';\n\nimport { isComponent } from './component';\nimport Checkbox from '../components/Checkbox/Checkbox';\nimport RadioButton from '../components/RadioButton/RadioButton';\nimport Toggle from '../components/Toggle';\n\nexport const isCompactComponent = (child: React.ReactNode): boolean =>\n isComponent<CheckboxProps>(child, Checkbox) ||\n isComponent<RadioButtonProps>(child, RadioButton) ||\n isComponent<ToggleProps>(child, Toggle);\n\nexport const hasSublabel = (child: React.ReactNode): boolean => {\n if (isComponent<CheckboxProps>(child, Checkbox) || isComponent<RadioButtonProps>(child, RadioButton)) {\n return React.isValidElement<LabelProps>(child.props.label) && !!child.props.label.props.sublabel;\n }\n if (isComponent<ToggleProps>(child, Toggle)) {\n return !!child.props.subLabel;\n }\n return false;\n};\n"],"mappings":";;;;;;AAYA,IAAa,sBAAsB,UACjC,YAA2B,OAAO,QAAQ,KAC1C,YAA8B,OAAO,WAAW,KAChD,YAAyB,OAAO,cAAM;AAExC,IAAa,eAAe,UAAoC;CAC9D,IAAI,YAA2B,OAAO,QAAQ,KAAK,YAA8B,OAAO,WAAW,GACjG,OAAO,MAAM,eAA2B,MAAM,MAAM,KAAK,KAAK,CAAC,CAAC,MAAM,MAAM,MAAM,MAAM;CAE1F,IAAI,YAAyB,OAAO,cAAM,GACxC,OAAO,CAAC,CAAC,MAAM,MAAM;CAEvB,OAAO;AACT"}
|
package/lib/utils2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils2.js","names":[],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n className?: string;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n className: props.className,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'normal' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n className={props.className}\n />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AAwBA,IAAa,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;EACxE,OACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,WAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;GACzD,CAAC;GACD,OACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAD;IAAM,WAAW;cACd,aAAa;GACV,GAF8B,KAE9B;EAGZ,CAAC;CAEL;CAEA,MAAM,YAAY,aAAa;CAC/B,MAAM,sBAAsB,aAAa,IAAI;CAE7C,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,gBAAD,EAAQ,MAAM,MAAQ,CAAA;GACpB,aAAa,aACb,qBAAC,OAAD;GAAgB;GAAe;GAAI,eAAa;GAAQ,oBAAkB,YAAY;aAAtF,CACG,WACA,QACE;;EAEN,uBACC,oBAAC,OAAD;GAAgB;GAAW,eAAa;aACrC;EACE,CAAA;CAEP,EAAA,CAAA;AAEN;;;ACFA,IAAM,SAAwC,EAC5C,oBACA,UACA,WACA,cACA,SACA,aAAa,SACb,gBACA,oBACA,SACA,YACA,UA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MAAM,MAAM;GAAO,MAAM;EAAU,CAAC;EACnD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;CACF,CAAA,EAEb,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"utils2.js","names":[],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n className?: string;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n className: props.className,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'normal' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n className={props.className}\n />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AAwBA,IAAa,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;EACxE,OACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,WAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;GACzD,CAAC;GACD,OACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAD;IAAM,WAAW;IACd,UAAA,aAAa;GACV,GAF8B,KAE9B;EAGZ,CAAC;CAEL;CAEA,MAAM,YAAY,aAAa;CAC/B,MAAM,sBAAsB,aAAa,IAAI;CAE7C,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,gBAAD,EAAQ,MAAM,MAAQ,CAAA;GACpB,aAAa,aACb,qBAAC,OAAD;GAAgB;GAAe;GAAI,eAAa;GAAQ,oBAAkB,YAAY;GAAtF,UAAA,CACG,WACA,QACE;;EAEN,uBACC,oBAAC,OAAD;GAAgB;GAAW,eAAa;GACrC,UAAA;EACE,CAAA;CAEP,EAAA,CAAA;AAEN;;;ACFA,IAAM,SAAwC,EAC5C,oBACA,UACA,WACA,cACA,SACA,aAAa,SACb,gBACA,oBACA,SACA,YACA,UAAU,YAAY,SACtB,WACA,UACA,0BACA,QACA,kCAC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C,OAAD;EACE,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;EAAU,CAAC;EACnD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;EAElC,UAAA,MAAM;CACF,CAAA,EAEb,CAAA;AAEN"}
|
package/package.json
CHANGED
package/lib/HighlightPanel.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { AnalyticsId, IconSize } from "./constants.js";
|
|
2
|
-
import { t as Icon_default } from "./Icon.js";
|
|
3
|
-
import { t as LazyIcon_default } from "./LazyIcon.js";
|
|
4
|
-
import { Breakpoint, useBreakpoint } from "./hooks/useBreakpoint.js";
|
|
5
|
-
import Title_default from "./components/Title/index.js";
|
|
6
|
-
import classNames from "classnames";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import styles from "./components/HighlightPanel/styles.module.scss";
|
|
9
|
-
//#region src/components/HighlightPanel/HighlightPanel.tsx
|
|
10
|
-
var HighlightPanel = (props) => {
|
|
11
|
-
const { children, color = "white", testId, svgIcon, htmlMarkup = "div", className, variant = "normal", title, titleHtmlMarkup = "h2" } = props;
|
|
12
|
-
const breakpoint = useBreakpoint();
|
|
13
|
-
const containerClassName = classNames(styles.highlightpanel, styles[`highlightpanel--${color}`], svgIcon && styles["highlightpanel--has-icon"], className, { [styles["highlightpanel--compact"]]: variant === "compact" });
|
|
14
|
-
const renderContent = () => {
|
|
15
|
-
const titleElement = title && /* @__PURE__ */ jsx(Title_default, {
|
|
16
|
-
testId: "titleId",
|
|
17
|
-
htmlMarkup: titleHtmlMarkup,
|
|
18
|
-
appearance: variant === "compact" ? "title6" : "title4",
|
|
19
|
-
children: title
|
|
20
|
-
});
|
|
21
|
-
if (svgIcon) {
|
|
22
|
-
const iconSize = IconSize.Small;
|
|
23
|
-
if (variant === "compact") return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
24
|
-
className: classNames(styles.highlightpanel__icon, styles["highlightpanel__icon--compact"]),
|
|
25
|
-
children: typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
26
|
-
iconName: svgIcon,
|
|
27
|
-
size: iconSize
|
|
28
|
-
}) : /* @__PURE__ */ jsx(Icon_default, {
|
|
29
|
-
svgIcon,
|
|
30
|
-
size: iconSize
|
|
31
|
-
})
|
|
32
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
33
|
-
className: classNames(styles.highlightpanel__content, styles["highlightpanel__content--compact"]),
|
|
34
|
-
children: [title && /* @__PURE__ */ jsx("div", {
|
|
35
|
-
className: styles["highlightpanel__title-wrapper"],
|
|
36
|
-
children: titleElement
|
|
37
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
38
|
-
className: styles["highlightpanel__content__children--compact"],
|
|
39
|
-
children
|
|
40
|
-
})]
|
|
41
|
-
})] });
|
|
42
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
43
|
-
className: styles.highlightpanel__icon,
|
|
44
|
-
children: [typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
45
|
-
iconName: svgIcon,
|
|
46
|
-
size: iconSize
|
|
47
|
-
}) : /* @__PURE__ */ jsx(Icon_default, {
|
|
48
|
-
svgIcon,
|
|
49
|
-
size: iconSize
|
|
50
|
-
}), title && breakpoint < Breakpoint.md && /* @__PURE__ */ jsx("div", {
|
|
51
|
-
className: styles["highlightpanel__title-wrapper"],
|
|
52
|
-
children: titleElement
|
|
53
|
-
})]
|
|
54
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
55
|
-
className: styles.highlightpanel__content,
|
|
56
|
-
children: [title && breakpoint >= Breakpoint.md && /* @__PURE__ */ jsx("div", {
|
|
57
|
-
className: styles["highlightpanel__title-wrapper"],
|
|
58
|
-
children: titleElement
|
|
59
|
-
}), children]
|
|
60
|
-
})] });
|
|
61
|
-
}
|
|
62
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [title && /* @__PURE__ */ jsx("div", {
|
|
63
|
-
className: styles.highlightpanel__content,
|
|
64
|
-
children: /* @__PURE__ */ jsx("div", { children: titleElement })
|
|
65
|
-
}), children] });
|
|
66
|
-
};
|
|
67
|
-
return /* @__PURE__ */ jsx(htmlMarkup, {
|
|
68
|
-
className: containerClassName,
|
|
69
|
-
"data-testid": testId,
|
|
70
|
-
"data-analyticsid": AnalyticsId.HighlightPanel,
|
|
71
|
-
children: renderContent()
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/components/HighlightPanel/index.ts
|
|
76
|
-
var HighlightPanel_default = HighlightPanel;
|
|
77
|
-
//#endregion
|
|
78
|
-
export { HighlightPanel_default as t };
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=HighlightPanel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightPanel.js","names":[],"sources":["../src/components/HighlightPanel/HighlightPanel.tsx","../src/components/HighlightPanel/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { TitleTags } from '../Title';\n\nimport { useBreakpoint, Breakpoint } from '../..';\nimport { AnalyticsId } from '../../constants';\nimport Icon, { IconSize } from '../Icon';\nimport LazyIcon from '../LazyIcon';\nimport Title 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={classNames(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":";;;;;;;;;AA6CA,IAAM,kBAAgD,UAAS;CAC7D,MAAM,EACJ,UACA,QAAQ,SACR,QACA,SACA,aAAa,OACb,WACA,UAAU,UACV,OACA,kBAAkB,SAChB;CACJ,MAAM,aAAa,cAAc;CAEjC,MAAM,qBAAqB,WACzB,OAAO,gBACP,OAAO,mBAAmB,UAC1B,WAAW,OAAO,6BAClB,WACA,GAAG,OAAO,6BAA6B,YAAY,UAAU,CAC/D;CAEA,MAAM,sBAAuC;EAC3C,MAAM,eAAe,SACnB,oBAAC,eAAD;GAAO,QAAO;GAAU,YAAY;GAAiB,YAAY,YAAY,YAAY,WAAW;aACjG;EACI,CAAA;EAGT,IAAI,SAAS;GACX,MAAM,WAAW,SAAS;GAE1B,IAAI,YAAY,WACd,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAD;IAAK,WAAW,WAAW,OAAO,sBAAsB,OAAO,gCAAgC;cAC5F,OAAO,YAAY,WAAW,oBAAC,kBAAD;KAAU,UAAU;KAAS,MAAM;IAAW,CAAA,IAAI,oBAAC,cAAD;KAAe;KAAS,MAAM;IAAW,CAAA;GACvH,CAAA,GACL,qBAAC,OAAD;IAAK,WAAW,WAAW,OAAO,yBAAyB,OAAO,mCAAmC;cAArG,CACG,SAAS,oBAAC,OAAD;KAAK,WAAW,OAAO;eAAmC;IAAkB,CAAA,GACtF,oBAAC,OAAD;KAAK,WAAW,OAAO;KAAgD;IAAc,CAAA,CAClF;KACL,EAAA,CAAA;GAIN,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,qBAAC,OAAD;IAAK,WAAW,OAAO;cAAvB,CACG,OAAO,YAAY,WAAW,oBAAC,kBAAD;KAAU,UAAU;KAAS,MAAM;IAAW,CAAA,IAAI,oBAAC,cAAD;KAAe;KAAS,MAAM;IAAW,CAAA,GACzH,SAAS,aAAa,WAAW,MAAM,oBAAC,OAAD;KAAK,WAAW,OAAO;eAAmC;IAAkB,CAAA,CACjH;OACL,qBAAC,OAAD;IAAK,WAAW,OAAO;cAAvB,CACG,SAAS,cAAc,WAAW,MAAM,oBAAC,OAAD;KAAK,WAAW,OAAO;eAAmC;IAAkB,CAAA,GACpH,QACE;KACL,EAAA,CAAA;EAEN;EAEA,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,SACC,oBAAC,OAAD;GAAK,WAAW,OAAO;aACrB,oBAAC,OAAD,EAAA,UAAM,aAAkB,CAAA;EACrB,CAAA,GAEN,QACD,EAAA,CAAA;CAEN;CAIA,OACE,oBAAC,YAAD;EAAW,WAAW;EAAoB,eAAa;EAAQ,oBAAkB,YAAY;YAC1F,cAAc;CACN,CAAA;AAEf;;;AC1HA,IAAA,yBAAe"}
|
package/lib/InfoTeaser.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { AnalyticsId, IconSize, LanguageLocales } from "./constants.js";
|
|
2
|
-
import { t as Icon_default } from "./Icon.js";
|
|
3
|
-
import { useLanguage } from "./hooks/useLanguage.js";
|
|
4
|
-
import { t as LazyIcon_default } from "./LazyIcon.js";
|
|
5
|
-
import Title_default from "./components/Title/index.js";
|
|
6
|
-
import { useExpand } from "./hooks/useExpand.js";
|
|
7
|
-
import classNames from "classnames";
|
|
8
|
-
import { useId } from "react";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import styles from "./components/InfoTeaser/styles.module.scss";
|
|
11
|
-
var HN_Designsystem_InfoTeaser_en_GB_default = {
|
|
12
|
-
expandButtonOpen: "Show less",
|
|
13
|
-
expandButtonClose: "Show more"
|
|
14
|
-
};
|
|
15
|
-
var HN_Designsystem_InfoTeaser_nb_NO_default = {
|
|
16
|
-
expandButtonOpen: "Vis mindre",
|
|
17
|
-
expandButtonClose: "Vis mer"
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/components/InfoTeaser/resourceHelper.ts
|
|
21
|
-
var getResources = (language) => {
|
|
22
|
-
switch (language) {
|
|
23
|
-
case LanguageLocales.ENGLISH: return HN_Designsystem_InfoTeaser_en_GB_default;
|
|
24
|
-
case LanguageLocales.NORWEGIAN:
|
|
25
|
-
default: return HN_Designsystem_InfoTeaser_nb_NO_default;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/components/InfoTeaser/InfoTeaser.tsx
|
|
30
|
-
var InfoTeaser = (props) => {
|
|
31
|
-
const { buttonClassName, children, className, expanded = false, htmlMarkup = "div", onExpand, resources, svgIcon, testId, title, titleHtmlMarkup = "h2", collapsedMaxHeight } = props;
|
|
32
|
-
const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);
|
|
33
|
-
const { language } = useLanguage(LanguageLocales.NORWEGIAN);
|
|
34
|
-
const defaultResources = getResources(language);
|
|
35
|
-
const infoteaserTextId = useId();
|
|
36
|
-
const mergedResources = {
|
|
37
|
-
...defaultResources,
|
|
38
|
-
...resources
|
|
39
|
-
};
|
|
40
|
-
return /* @__PURE__ */ jsxs(htmlMarkup, {
|
|
41
|
-
className: styles.wrapper,
|
|
42
|
-
"data-testid": testId,
|
|
43
|
-
"data-analyticsid": AnalyticsId.InfoTeaser,
|
|
44
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
45
|
-
className: classNames(styles.infoteaser, className, { [styles["infoteaser--collapsed"]]: !isExpanded }),
|
|
46
|
-
style: { maxHeight: !isExpanded ? collapsedMaxHeight ? collapsedMaxHeight : "12.25rem" : void 0 },
|
|
47
|
-
children: [
|
|
48
|
-
svgIcon && (typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
49
|
-
iconName: svgIcon,
|
|
50
|
-
size: IconSize.Small,
|
|
51
|
-
className: styles.infoteaser__icon
|
|
52
|
-
}) : /* @__PURE__ */ jsx(Icon_default, {
|
|
53
|
-
svgIcon,
|
|
54
|
-
size: IconSize.Small,
|
|
55
|
-
className: styles.infoteaser__icon
|
|
56
|
-
})),
|
|
57
|
-
title && typeof title !== "undefined" && /* @__PURE__ */ jsx(Title_default, {
|
|
58
|
-
testId: "titleId",
|
|
59
|
-
htmlMarkup: titleHtmlMarkup,
|
|
60
|
-
appearance: "title4",
|
|
61
|
-
className: styles.infoteaser__title,
|
|
62
|
-
children: title
|
|
63
|
-
}),
|
|
64
|
-
/* @__PURE__ */ jsx("div", {
|
|
65
|
-
className: styles.infoteaser__text,
|
|
66
|
-
"aria-hidden": isExpanded ? false : true,
|
|
67
|
-
id: infoteaserTextId,
|
|
68
|
-
children
|
|
69
|
-
})
|
|
70
|
-
]
|
|
71
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
72
|
-
type: "button",
|
|
73
|
-
className: classNames(styles.infoteaser__button, buttonClassName),
|
|
74
|
-
onClick: () => {
|
|
75
|
-
setIsExpanded(!isExpanded);
|
|
76
|
-
},
|
|
77
|
-
"aria-expanded": isExpanded,
|
|
78
|
-
"aria-controls": infoteaserTextId,
|
|
79
|
-
children: isExpanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/components/InfoTeaser/index.ts
|
|
85
|
-
var InfoTeaser_default = InfoTeaser;
|
|
86
|
-
//#endregion
|
|
87
|
-
export { InfoTeaser_default as t };
|
|
88
|
-
|
|
89
|
-
//# sourceMappingURL=InfoTeaser.js.map
|
package/lib/InfoTeaser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTeaser.js","names":[],"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 type { HNDesignsystemInfoTeaser } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.InfoTeaser.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.InfoTeaser.nb-NO.json';\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 { useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemInfoTeaser } from '../../resources/Resources';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { TitleTags } from '../Title';\n\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport Icon, { IconSize } from '../Icon';\nimport LazyIcon from '../LazyIcon';\nimport Title 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 /** Override the default max height for collapsed teaser. Default is 12.25rem */\n collapsedMaxHeight?: string;\n /** For overriding styling on infoteaser box */\n className?: string;\n /** Opens or closes the teaser */\n expanded?: boolean;\n /** Changes the underlying element of the wrapper */\n htmlMarkup?: InfoTeaserTags;\n /** Called when the teaser is expanded/collapsed. */\n onExpand?: (isExpanded: boolean) => void;\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 {\n buttonClassName,\n children,\n className,\n expanded = false,\n htmlMarkup = 'div',\n onExpand,\n resources,\n svgIcon,\n testId,\n title,\n titleHtmlMarkup = 'h2',\n collapsedMaxHeight,\n } = props;\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\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']]: !isExpanded,\n })}\n style={{ maxHeight: !isExpanded ? (collapsedMaxHeight ? collapsedMaxHeight : '12.25rem') : undefined }}\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 && typeof title !== 'undefined' && (\n <Title testId=\"titleId\" htmlMarkup={titleHtmlMarkup} appearance=\"title4\" className={styles.infoteaser__title}>\n {title}\n </Title>\n )}\n <div className={styles.infoteaser__text} aria-hidden={isExpanded ? 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 setIsExpanded(!isExpanded);\n }}\n aria-expanded={isExpanded}\n aria-controls={infoteaserTextId}\n >\n {isExpanded ? 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":";;;;;;;;;;;;;;;;;;;;AEMA,IAAa,gBAAgB,aAAwD;CACnF,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACkCA,IAAM,cAAwC,UAAS;CACrD,MAAM,EACJ,iBACA,UACA,WACA,WAAW,OACX,aAAa,OACb,UACA,WACA,SACA,QACA,OACA,kBAAkB,MAClB,uBACE;CACJ,MAAM,CAAC,YAAY,iBAAiB,UAAU,UAAU,QAAQ;CAChE,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAC3E,MAAM,mBAAmB,aAAa,QAAQ;CAC9C,MAAM,mBAAmB,MAAM;CAE/B,MAAM,kBAA4C;EAChD,GAAG;EACH,GAAG;CACL;CAIA,OACE,qBAAC,YAAD;EAAY,WAAW,OAAO;EAAS,eAAa;EAAQ,oBAAkB,YAAY;YAA1F,CACE,qBAAC,OAAD;GACE,WAAW,WAAW,OAAO,YAAY,WAAW,GACjD,OAAO,2BAA2B,CAAC,WACtC,CAAC;GACD,OAAO,EAAE,WAAW,CAAC,aAAc,qBAAqB,qBAAqB,aAAc,KAAA,EAAU;aAJvG;IAMG,YACE,OAAO,YAAY,WAClB,oBAAC,kBAAD;KAAU,UAAU;KAAS,MAAM,SAAS;KAAO,WAAW,OAAO;IAAmB,CAAA,IAExF,oBAAC,cAAD;KAAe;KAAS,MAAM,SAAS;KAAO,WAAW,OAAO;IAAmB,CAAA;IAEtF,SAAS,OAAO,UAAU,eACzB,oBAAC,eAAD;KAAO,QAAO;KAAU,YAAY;KAAiB,YAAW;KAAS,WAAW,OAAO;eACxF;IACI,CAAA;IAET,oBAAC,OAAD;KAAK,WAAW,OAAO;KAAkB,eAAa,aAAa,QAAQ;KAAM,IAAI;KAClF;IACE,CAAA;GACF;MACL,oBAAC,UAAD;GACE,MAAK;GACL,WAAW,WAAW,OAAO,oBAAoB,eAAe;GAChE,eAAe;IACb,cAAc,CAAC,UAAU;GAC3B;GACA,iBAAe;GACf,iBAAe;aAEd,aAAa,gBAAgB,mBAAmB,gBAAgB;EAC3D,CAAA,CACE;;AAEhB;;;AC7GA,IAAA,qBAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Toggle/constants.ts","../../../src/components/Toggle/Toggle.tsx","../../../src/components/Toggle/index.ts"],"sourcesContent":["export enum TogglePosition {\n left = 'left',\n right = 'right',\n}\n\nexport enum ToggleOnColor {\n onwhite = 'onwhite',\n onneutral = 'onneutral',\n onblueberry = 'onblueberry',\n}\n","import React, { useState, useEffect, useId } from 'react';\n\nimport classNames from 'classnames';\nimport { useAnimate } from 'motion/react';\n\nimport { ToggleOnColor, TogglePosition } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\n\nimport styles from './styles.module.scss';\n\nimport '../../scss/supernova/styles/colors.css';\n\nexport type LabelText = {\n text: string;\n type?: 'subdued' | 'normal';\n};\n\nexport type StatusTextType = {\n checked: string;\n unchecked: string;\n};\n\nexport interface ToggleProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'disabled'> {\n /** Determines if the Toggle is checked */\n checked?: boolean;\n /** Sets the label of the Toggle */\n label: LabelText[];\n /** Defines the color of the toggle */\n onColor?: keyof typeof ToggleOnColor;\n /** A text that is shown under the Toggle switch */\n statusText?: StatusTextType;\n /** Sets the sublabel of the Toggle */\n subLabel?: string;\n /** Sets the position of the toggle relative to the label */\n togglePosition?: keyof typeof TogglePosition;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst Toggle: React.FC<ToggleProps> = ({\n checked = false,\n disabled,\n label,\n onChange,\n onColor = ToggleOnColor.onwhite,\n statusText,\n subLabel,\n togglePosition = TogglePosition.left,\n testId,\n}: ToggleProps) => {\n const [checkedState, setCheckedState] = useState(checked);\n const [showToggleAnimation, setShowToggleAnimation] = useState(false);\n const [scope, animate] = useAnimate();\n const baseId = useId();\n const toggleId = 'toggle-' + baseId;\n const inputId = 'input-' + baseId;\n const labelId = 'label-' + baseId;\n const subLabelId = 'sublabel-' + baseId;\n const toggleRef = React.useRef<HTMLSpanElement>(null);\n const toggleDotRef = React.useRef<HTMLSpanElement>(null);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLLabelElement>(scope);\n const showHoveredStyling = isHovered && !showToggleAnimation;\n const isOnWhite = onColor === ToggleOnColor.onwhite;\n const animationDuration = disabled ? 0 : 0.2;\n const dotBackgroundColor = disabled\n ? 'var(--color-disabled-graphics)'\n : checkedState\n ? 'var(--color-action-graphics-ondark)'\n : 'var(--core-color-neutral-700)';\n\n const getBackgroundColor = (): string => {\n if (disabled) {\n return 'transparent';\n } else if (checkedState && isActive) {\n return 'var(--core-color-blueberry-800)';\n } else if (checkedState) {\n return showHoveredStyling ? 'var(--color-action-graphics-onlight-hover)' : 'var(--color-action-graphics-onlight)';\n } else if (isOnWhite && isActive) {\n return 'var(--core-color-neutral-400)';\n } else if (isOnWhite) {\n return showHoveredStyling ? 'var(--core-color-neutral-200)' : 'var(--core-color-neutral-50)';\n } else if (isActive) {\n return 'var(--core-color-neutral-200)';\n } else {\n return showHoveredStyling ? 'var(--core-color-neutral-50)' : 'var(--core-color-white)';\n }\n };\n\n useEffect(() => {\n if (showToggleAnimation) {\n const timer = setTimeout(() => setShowToggleAnimation(false), 300);\n return (): void => clearTimeout(timer);\n }\n }, [showToggleAnimation]);\n\n useEffect(() => {\n setCheckedState(checked);\n }, [checked]);\n\n useEffect(() => {\n if (!toggleRef.current || !toggleDotRef.current) return;\n animate(toggleRef.current, { background: getBackgroundColor() }, { duration: animationDuration, ease: 'easeInOut' });\n animate(\n toggleDotRef.current,\n {\n background: dotBackgroundColor,\n },\n { duration: animationDuration, ease: 'easeInOut' }\n );\n animate(toggleDotRef.current, { x: checkedState ? 16 : 0 }, { duration: animationDuration, ease: 'easeInOut' });\n animate('svg', { opacity: checkedState ? 1 : 0 }, { duration: animationDuration, ease: 'easeInOut' });\n }, [checkedState, showHoveredStyling, isActive, disabled]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setCheckedState(event.target.checked);\n setShowToggleAnimation(true);\n onChange?.(event);\n };\n\n const toggleContainerClassNames = classNames(styles['toggle-container'], {\n [styles['toggle-container--position-right']]: togglePosition === TogglePosition.right,\n [styles['toggle-container--with-status']]: statusText !== undefined && statusText !== null,\n [styles['toggle-container--disabled']]: disabled,\n });\n\n const subLabelClassNames = classNames(styles['toggle-container__sublabel']);\n\n const statusTextClassNames = classNames(styles['toggle-container__status'], {\n [styles['toggle-container__status--checked']]: checkedState,\n });\n\n const toggleClassNames = classNames(styles['toggle-container__toggle'], {\n [styles['toggle-container__toggle--ignore-hover']]: showToggleAnimation,\n [styles['toggle-container__toggle--on-white']]: onColor === ToggleOnColor.onwhite,\n });\n\n const toggleDotClassNames = classNames(styles['toggle-container__toggle__dot'], {\n [styles['toggle-container__toggle__dot--ignore-hover']]: showToggleAnimation,\n });\n\n const renderToggle = (): React.ReactElement => (\n <div className={styles['toggle-container__outer-toggle']}>\n <label ref={refObject} className={styles['toggle-container__toggle-group']}>\n <input\n disabled={disabled}\n id={inputId}\n type=\"checkbox\"\n checked={checkedState}\n onChange={handleChange}\n className={styles['toggle-container__input']}\n aria-label={label.map(l => l.text).join(' ')}\n aria-describedby={[subLabel ? subLabelId : null, statusText ? toggleId + '-status' : null].filter(Boolean).join(' ') || undefined}\n role=\"switch\"\n />\n <span id={toggleId} ref={toggleRef} className={toggleClassNames} aria-hidden=\"true\">\n <span ref={toggleDotRef} className={toggleDotClassNames} aria-hidden=\"true\">\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={styles['toggle-container__toggle__dot__icon']}\n >\n <path d=\"M11 2.65247L4.69877 9.34741L1 5.41836\" strokeWidth=\"2.2\" />\n </svg>\n </span>\n </span>\n </label>\n {statusText && (\n <span className={statusTextClassNames} id={toggleId + '-status'}>\n {checkedState ? statusText.checked : statusText.unchecked}\n </span>\n )}\n </div>\n );\n\n const renderLabelText = (): React.ReactElement => {\n return (\n <div className={styles['toggle-container__outer-label']}>\n <span id={labelId} className={styles['toggle-container__label']}>\n {label.map(labelText => {\n const labelClassNames = classNames({\n [styles['toggle-container__label__text--subdued']]: labelText.type === 'subdued',\n });\n\n return (\n <span key={labelId + labelText.text} className={labelClassNames}>\n {labelText.text}\n </span>\n );\n })}\n </span>\n {subLabel && (\n <div id={subLabelId} className={subLabelClassNames}>\n {subLabel}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div className={toggleContainerClassNames} data-testid={testId} data-analyticsid={AnalyticsId.Toggle}>\n {togglePosition === TogglePosition.left && (\n <>\n {renderToggle()}\n {renderLabelText()}\n </>\n )}\n {togglePosition === TogglePosition.right && (\n <>\n {renderLabelText()}\n {renderToggle()}\n </>\n )}\n </div>\n );\n};\n\nexport default Toggle;\n","import Toggle from './Toggle';\nexport { TogglePosition, ToggleOnColor } from './constants';\nexport * from './Toggle';\nexport default Toggle;\n"],"mappings":";;;;;;;;AAAA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,UAAA;CACA,eAAA,WAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,gBAAL,yBAAA,eA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