@helsenorge/designsystem-react 15.7.2 → 16.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/lib/Button.js +2 -2
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +2652 -997
- package/lib/Close.js +1 -1
- package/lib/Close.js.map +1 -1
- package/lib/Drawer.js +2 -4
- package/lib/Drawer.js.map +1 -1
- package/lib/DrawerNavigation.js +1 -0
- package/lib/DrawerNavigation.js.map +1 -1
- package/lib/Duolist.js +5 -1
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js.map +1 -1
- package/lib/FilterLinkList.js +1 -1
- package/lib/FilterLinkList.js.map +1 -1
- package/lib/FormGroup.js +3 -3
- package/lib/FormGroup.js.map +1 -1
- package/lib/HelpDetails.js +1 -1
- package/lib/HelpTriggerIcon.js +2 -2
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js +1 -1
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/LazyIcon.js +1 -0
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LazyIllustration.js +2 -0
- package/lib/LazyIllustration.js.map +1 -1
- package/lib/LinkList.js +10 -10
- package/lib/LinkList.js.map +1 -1
- package/lib/ListEditMode.js +1 -1
- package/lib/ListEditMode.js.map +1 -1
- package/lib/PopOver.js +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/Radio.js +65 -55
- package/lib/Radio.js.map +1 -1
- package/lib/Radio2.js +74 -0
- package/lib/Radio2.js.map +1 -0
- package/lib/RadioMarker.js +2 -2
- package/lib/RadioMarker.js.map +1 -1
- package/lib/TabList.js +5 -5
- package/lib/TabList.js.map +1 -1
- package/lib/Toggle.js +2 -2
- package/lib/Toggle.js.map +1 -1
- package/lib/VisualRadio.js +1 -1
- package/lib/VisualRadio.js.map +1 -1
- package/lib/components/AnchorLink/styles.module.scss +3 -4
- package/lib/components/ArticleTeaser/styles.module.scss +12 -12
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/styles.module.scss +111 -60
- package/lib/components/Button/styles.module.scss.d.ts +1 -1
- package/lib/components/Checkbox/CheckboxMarker/styles.module.scss +6 -6
- package/lib/components/Chip/styles.module.scss +2 -3
- package/lib/components/Close/styles.module.scss +2 -3
- package/lib/components/DictionaryTrigger/index.js +26 -1
- package/lib/{DictionaryTrigger.js.map → components/DictionaryTrigger/index.js.map} +1 -1
- package/lib/components/DictionaryTrigger/styles.module.scss +6 -8
- package/lib/components/Drawer/Drawer.d.ts +0 -4
- package/lib/components/Drawer/DrawerBackButton.module.scss +1 -2
- package/lib/components/Drawer/styles.module.scss +6 -3
- package/lib/components/Dropdown/SingleSelect/styles.module.scss +0 -2
- package/lib/components/Dropdown/index.js +9 -17
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Dropdown/styles.module.scss +12 -14
- package/lib/components/Duolist/Duolist.d.ts +14 -2
- package/lib/components/Duolist/styles.module.scss +32 -8
- package/lib/components/Duolist/styles.module.scss.d.ts +3 -0
- package/lib/components/ElementHeader/ElementHeader.d.ts +1 -1
- package/lib/components/ElementHeader/styles.module.scss +1 -1
- package/lib/components/EmptyState/styles.module.scss +1 -2
- package/lib/components/ErrorWrapper/styles.module.scss +3 -3
- package/lib/components/Expander/styles.module.scss +0 -2
- package/lib/components/Expander/styles.module.scss.d.ts +1 -1
- package/lib/components/ExpanderList/index.js +20 -19
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/ExpanderList/styles.module.scss +10 -11
- package/lib/components/FavoriteButton/index.js +3 -3
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/FavoriteButton/styles.module.scss +0 -1
- package/lib/components/Filter/FilterButton/styles.module.scss +5 -6
- package/lib/components/Filter/FilterButtonAndChipsWrapper/styles.module.scss +0 -1
- package/lib/components/Filter/FilterDrawer/styles.module.scss +0 -1
- package/lib/components/Filter/FilterLinkList/FilterLinkList.module.scss +5 -6
- package/lib/components/Filter/FilterOverviewSearch/styles.module.scss +1 -4
- package/lib/components/Filter/FilterSearch/styles.module.scss +14 -15
- package/lib/components/Filter/FilterSort/styles.module.scss +1 -2
- package/lib/components/Filter/FilterStateWrapper/styles.module.scss +0 -2
- package/lib/components/Filter/LoaderSpinner/styles.module.scss +2 -4
- package/lib/components/FormFieldTag/styles.module.scss +0 -1
- package/lib/components/FormGroup/styles.module.scss +0 -1
- package/lib/components/HelpBubble/styles.module.scss +0 -1
- package/lib/components/HelpDetails/styles.module.scss +2 -4
- package/lib/components/HelpDrawer/styles.module.scss +1 -2
- package/lib/components/HelpPanel/HelpPanel.d.ts +2 -2
- package/lib/components/HelpPanel/index.js +1 -17
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpPanel/styles.module.scss +2 -22
- package/lib/components/HelpPanel/styles.module.scss.d.ts +0 -4
- package/lib/components/HelpTeaser/styles.module.scss +7 -9
- package/lib/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +2 -2
- package/lib/components/HelpTriggerIcon/styles.module.scss +20 -22
- package/lib/components/HelpTriggerIcon/styles.module.scss.d.ts +1 -1
- package/lib/components/HelpTriggerInline/styles.module.scss +3 -5
- package/lib/components/HelpTriggerStandalone/styles.module.scss +3 -5
- package/lib/components/HighlightPanel/styles.module.scss +2 -3
- package/lib/components/Icons/AdditionalIconInformation.d.ts +4 -0
- package/lib/components/Icons/AdditionalIconInformation.js +14 -10
- package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/lib/components/Icons/HistoryDocument.js +6 -7
- package/lib/components/Icons/HistoryDocument.js.map +1 -1
- package/lib/components/Icons/IconNames.d.ts +1 -1
- package/lib/components/Icons/IconNames.js +1 -0
- package/lib/components/Icons/IconNames.js.map +1 -1
- package/lib/components/Icons/YesNo.d.ts +3 -0
- package/lib/components/Icons/YesNo.js +53 -0
- package/lib/components/Icons/YesNo.js.map +1 -0
- package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/lib/components/Illustrations/IllustrationNames.js +2 -0
- package/lib/components/Illustrations/IllustrationNames.js.map +1 -1
- package/lib/components/Illustrations/MoveAway.d.ts +11 -0
- package/lib/components/Illustrations/MoveAway.js +18 -0
- package/lib/components/Illustrations/MoveAway.js.map +1 -0
- package/lib/components/Illustrations/MoveAwayMedium.d.ts +3 -0
- package/lib/components/Illustrations/MoveAwayMedium.js +114 -0
- package/lib/components/Illustrations/MoveAwayMedium.js.map +1 -0
- package/lib/components/InfoTeaser/styles.module.scss +6 -8
- package/lib/components/Label/styles.module.scss +1 -1
- package/lib/components/LinkList/LinkList.d.ts +1 -1
- package/lib/components/LinkList/styles.module.scss +9 -11
- package/lib/components/LinkList/styles.module.scss.d.ts +1 -1
- package/lib/components/ListEditMode/styles.module.scss +5 -7
- package/lib/components/Loader/Loader.d.ts +1 -1
- package/lib/components/Loader/index.js +4 -4
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Loader/styles.module.scss +7 -7
- package/lib/components/Loader/styles.module.scss.d.ts +3 -3
- package/lib/components/Modal/constants.d.ts +1 -1
- package/lib/components/Modal/index.js +2 -2
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/Modal/styles.module.scss +14 -19
- package/lib/components/Modal/styles.module.scss.d.ts +2 -3
- package/lib/components/Panel/index.js +1 -1
- package/lib/components/Panel/index.js.map +1 -1
- package/lib/components/Panel/styles.module.scss +15 -16
- package/lib/components/Panel/styles.module.scss.d.ts +1 -1
- package/lib/components/PopMenu/index.js +7 -4
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/PopOver/styles.module.scss +1 -3
- package/lib/components/Progressbar/Progressbar.d.ts +1 -1
- package/lib/components/Progressbar/constants.d.ts +1 -1
- package/lib/components/Progressbar/index.js +4 -4
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/Radio/Radio.d.ts +28 -0
- package/lib/components/Radio/index.d.ts +3 -0
- package/lib/components/Radio/index.js +7 -0
- package/lib/components/Radio/index.js.map +1 -0
- package/lib/components/{RadioButton → Radio}/styles.module.scss +8 -9
- package/lib/components/Radio/styles.module.scss.d.ts +26 -0
- package/lib/components/ServiceMessage/styles.module.scss +20 -22
- package/lib/components/Slider/styles.module.scss +1 -2
- package/lib/components/StatusDot/styles.module.scss +4 -5
- package/lib/components/StickyNote/index.js +2 -2
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/StickyNote/styles.module.scss +9 -10
- package/lib/components/Tabs/TabList/styles.module.scss +20 -18
- package/lib/components/Tabs/TabPanel/styles.module.scss +2 -3
- package/lib/components/Tabs/styles.module.scss +0 -1
- package/lib/components/Tag/styles.module.scss +0 -1
- package/lib/components/Tile/styles.module.scss +5 -7
- package/lib/components/Toast/styles.module.scss +0 -1
- package/lib/components/Toggle/styles.module.scss +9 -10
- package/lib/components/Validation/index.js +2 -2
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/components/VisualCheckboxCloud/Checkbox/styles.module.scss +0 -2
- package/lib/components/VisualCheckboxCloud/styles.module.scss +0 -1
- package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss +0 -2
- package/lib/components/VisualCheckboxGroup/styles.module.scss +0 -1
- package/lib/components/VisualContentgroupWithImage/styles.module.scss +0 -1
- package/lib/components/VisualRadioCloud/Radio/index.js +1 -1
- package/lib/components/VisualRadioCloud/Radio/styles.module.scss +0 -2
- package/lib/components/VisualRadioCloud/index.js +1 -1
- package/lib/components/VisualRadioCloud/styles.module.scss +0 -1
- package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss +0 -2
- package/lib/components/VisualRadioGroup/styles.module.scss +0 -1
- package/lib/constants.d.ts +2 -3
- package/lib/constants.js +2 -3
- package/lib/constants.js.map +1 -1
- package/lib/floating-ui.react.js +1 -458
- package/lib/floating-ui.react.js.map +1 -1
- package/lib/hooks/useDismissablePopover.d.ts +20 -0
- package/lib/hooks/useDismissablePopover.js +66 -0
- package/lib/hooks/useDismissablePopover.js.map +1 -0
- package/lib/hooks/useOutsideEvent.d.ts +3 -0
- package/lib/hooks/useOutsideEvent.js +24 -3
- package/lib/hooks/useOutsideEvent.js.map +1 -1
- package/lib/hooks/useReturnFocusOnClose.d.ts +7 -0
- package/lib/hooks/useReturnFocusOnClose.js +22 -0
- package/lib/hooks/useReturnFocusOnClose.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/scss/_visual-form.scss +47 -47
- package/lib/scss/helsenorge.scss +1 -0
- package/lib/scss/supernova/styles/colors.css +177 -122
- package/lib/scss/supernova/styles/typography.css +58 -51
- package/lib/scss/supernova-legacy/index.css +2 -0
- package/lib/scss/supernova-legacy/styles/legacy-colors.css +111 -0
- package/lib/utils/formSpacing.js +3 -3
- package/lib/utils/formSpacing.js.map +1 -1
- package/package.json +8 -14
- package/scss/_visual-form.scss +47 -47
- package/scss/helsenorge.scss +1 -0
- package/scss/supernova/styles/colors.css +177 -122
- package/scss/supernova/styles/typography.css +58 -51
- package/scss/supernova-legacy/index.css +2 -0
- package/scss/supernova-legacy/styles/legacy-colors.css +111 -0
- package/lib/DictionaryTrigger.js +0 -27
- package/lib/RadioButton.js +0 -84
- package/lib/RadioButton.js.map +0 -1
- package/lib/components/HelpTooltip/HelpTooltip.d.ts +0 -12
- package/lib/components/HelpTooltip/index.d.ts +0 -3
- package/lib/components/HelpTooltip/index.js +0 -48
- package/lib/components/HelpTooltip/index.js.map +0 -1
- package/lib/components/RadioButton/RadioButton.d.ts +0 -28
- package/lib/components/RadioButton/index.d.ts +0 -3
- package/lib/components/RadioButton/index.js +0 -7
- package/lib/components/RadioButton/index.js.map +0 -1
- package/lib/components/RadioButton/styles.module.scss.d.ts +0 -26
- package/lib/designsystem-react.css +0 -273
- /package/lib/components/{RadioButton → Radio}/RadioMarker/RadioMarker.d.ts +0 -0
- /package/lib/components/{RadioButton → Radio}/RadioMarker/styles.module.scss +0 -0
- /package/lib/components/{RadioButton → Radio}/RadioMarker/styles.module.scss.d.ts +0 -0
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
@use '../../scss/palette' as palette;
|
|
4
4
|
@use '../../scss/font-settings' as font-settings;
|
|
5
5
|
@use '../../scss/breakpoints' as breakpoints;
|
|
6
|
-
@import '../../scss/supernova/styles/colors.css';
|
|
7
|
-
@import '../../scss/supernova/styles/spacers.css';
|
|
8
6
|
|
|
9
7
|
.modal-overlay {
|
|
10
8
|
background: var(--color-shadow-pagemask);
|
|
@@ -62,21 +60,6 @@
|
|
|
62
60
|
|
|
63
61
|
&--normal {
|
|
64
62
|
background-color: palette.$white;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&--error {
|
|
68
|
-
background-color: palette.$cherry100;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&--warning {
|
|
72
|
-
background-color: palette.$banana50;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&--success {
|
|
76
|
-
background-color: palette.$kiwi50;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&--large {
|
|
80
63
|
width: calc(100vw - 0.75rem);
|
|
81
64
|
padding-bottom: spacers.getSpacer(l);
|
|
82
65
|
|
|
@@ -100,6 +83,18 @@
|
|
|
100
83
|
}
|
|
101
84
|
}
|
|
102
85
|
|
|
86
|
+
&--error {
|
|
87
|
+
background-color: palette.$cherry100;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&--warning {
|
|
91
|
+
background-color: palette.$banana50;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&--success {
|
|
95
|
+
background-color: palette.$kiwi50;
|
|
96
|
+
}
|
|
97
|
+
|
|
103
98
|
&--medium {
|
|
104
99
|
width: calc(100vw - 0.75rem);
|
|
105
100
|
padding-bottom: spacers.getSpacer(m);
|
|
@@ -178,7 +173,7 @@
|
|
|
178
173
|
}
|
|
179
174
|
|
|
180
175
|
&__scroll {
|
|
181
|
-
&--
|
|
176
|
+
&--normal {
|
|
182
177
|
padding: spacers.getSpacer(xl) spacers.getSpacer(m) spacers.getSpacer(2xs);
|
|
183
178
|
|
|
184
179
|
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
@@ -223,7 +218,7 @@
|
|
|
223
218
|
display: flex;
|
|
224
219
|
gap: var(--core-space-m);
|
|
225
220
|
|
|
226
|
-
&--
|
|
221
|
+
&--normal {
|
|
227
222
|
padding: spacers.getSpacer(l) spacers.getSpacer(m) 0;
|
|
228
223
|
|
|
229
224
|
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
@@ -3,13 +3,13 @@ export type Styles = {
|
|
|
3
3
|
modal: string;
|
|
4
4
|
modal__afterTitleChildren: string;
|
|
5
5
|
'modal__call-to-action': string;
|
|
6
|
-
'modal__call-to-action--large': string;
|
|
7
6
|
'modal__call-to-action--medium': string;
|
|
7
|
+
'modal__call-to-action--normal': string;
|
|
8
8
|
modal__closeWrapper: string;
|
|
9
9
|
modal__closeWrapper__close: string;
|
|
10
10
|
modal__contentWrapper: string;
|
|
11
|
-
'modal__contentWrapper__scroll--large': string;
|
|
12
11
|
'modal__contentWrapper__scroll--medium': string;
|
|
12
|
+
'modal__contentWrapper__scroll--normal': string;
|
|
13
13
|
modal__contentWrapper__title: string;
|
|
14
14
|
modal__description: string;
|
|
15
15
|
modal__iconWrapper: string;
|
|
@@ -20,7 +20,6 @@ export type Styles = {
|
|
|
20
20
|
'modal__title--error': string;
|
|
21
21
|
'modal__title--success': string;
|
|
22
22
|
'modal--error': string;
|
|
23
|
-
'modal--large': string;
|
|
24
23
|
'modal--medium': string;
|
|
25
24
|
'modal--no-actions': string;
|
|
26
25
|
'modal--normal': string;
|
|
@@ -198,7 +198,7 @@ var PanelRoot = ({ layout = PanelLayout.vertical, variant = PanelVariant.fill, c
|
|
|
198
198
|
children: /* @__PURE__ */ jsxs(Button_default, {
|
|
199
199
|
variant: "borderless",
|
|
200
200
|
type: "button",
|
|
201
|
-
size: "
|
|
201
|
+
size: "normal",
|
|
202
202
|
onClick: buttonBottomOnClick,
|
|
203
203
|
"aria-label": buttonBottomAriaLabel,
|
|
204
204
|
children: [buttonBottomText, /* @__PURE__ */ jsx(Icon_default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/resources/HN.Designsystem.Panel.en-GB.json","../../../src/resources/HN.Designsystem.Panel.nb-NO.json","../../../src/components/Panel/resourceHelper.ts","../../../src/components/Panel/Panel.tsx","../../../src/components/Panel/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"See details\",\n \"expandButtonClose\": \"Hide details\"\n}\n","{\n \"expandButtonOpen\": \"Se detaljer\",\n \"expandButtonClose\": \"Skjul detaljer\"\n}\n","import type { HNDesignsystemPanel } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemPanel => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PanelTitleProps } from './PanelTitle';\nimport type { HNDesignsystemPanel } from '../../resources/Resources';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport { LanguageLocales } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nimport PanelTitle from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\nimport { PanelListContext } from '../PanelList/utils';\n\nimport styles from './styles.module.scss';\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport interface PanelProps {\n /** Aria label on call to action button */\n buttonBottomAriaLabel?: string;\n /** Sets the text on the bottom call to action button */\n buttonBottomText?: string;\n /** Sets the action on the bottom call to action button */\n buttonBottomOnClick?: () => void;\n /** Expands or collapses the panel. Only applicable when ExpandedContent is used */\n expanded?: boolean;\n /** Whether the panel can be focused */\n focusable?: boolean;\n /** Sets the layout and order of the content boxes */\n layout?: PanelLayout;\n /** Sets the visual variant of panel */\n variant?: PanelVariant;\n /** Sets the color for panel if it has variant fill */\n color?: PanelColors;\n /** Sets classes on the outermost container of the panel */\n className?: string;\n /** Action called when toggling expansion of ExpandedContent */\n onExpand?: (isExpanded?: boolean) => void;\n /** Sets the stacking order of the content boxes */\n stacking?: PanelStacking;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Children elements to be rendered inside the panel */\n children?: React.ReactNode;\n /** Displays a status on the left side: default normal */\n status?: PanelStatus;\n /** Resources for component */\n resources?: Partial<HNDesignsystemPanel>;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the panel container */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst ExpandButton = ({\n onClick,\n isExpanded,\n resources,\n}: {\n onClick: () => void;\n isExpanded: boolean | undefined;\n resources: Partial<HNDesignsystemPanel>;\n}): React.JSX.Element => {\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n return (\n <Button\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n wrapperClassName={buttonClassName}\n aria-expanded={isExpanded}\n onClick={onClick}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n <span>{isExpanded ? resources.expandButtonClose : resources.expandButtonOpen}</span>\n </Button>\n );\n};\nconst PanelRoot: React.FC<PanelProps> = ({\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n expanded = false,\n focusable,\n status = PanelStatus.none,\n buttonBottomAriaLabel,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n onExpand,\n highlightText,\n ref,\n}: PanelProps) => {\n const panelListContext = React.useContext(PanelListContext);\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const localRef = React.useRef<HTMLDivElement>(null);\n const panelRef = ref ?? localRef;\n const expandedContentRef = React.useRef<HTMLDivElement>(null);\n const defaultScroll = 100;\n\n // Use context values if available, otherwise use props\n const effectiveVariant = panelListContext?.variant ?? variant;\n const effectiveHighlightText = panelListContext?.highlightText ?? highlightText;\n const effectiveClassName = panelListContext?.applyPanelClassName(className) ?? className;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemPanel = {\n ...defaultResources,\n ...resources,\n };\n\n const { preContainer, title, content, expandableContent, hasIcon } = React.useMemo(() => {\n let index = 0;\n let localHasIcon = false;\n const newPreContainer: React.ReactNode[] = [];\n const newTitle: React.ReactNode[] = [];\n const newContent: React.ReactNode[] = [];\n const newExpandableContent: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n const key = child.key ?? `panel-child-${index++}`;\n\n if (child.type === PreContainer) {\n newPreContainer.push(React.cloneElement(child, { key }));\n } else if (isComponent<PanelTitleProps>(child, PanelTitle)) {\n newTitle.push(\n React.cloneElement(child as React.ReactElement<PanelTitleProps>, {\n key,\n highlightText: child.props.highlightText || effectiveHighlightText,\n })\n );\n if (child.props.icon) {\n localHasIcon = true;\n }\n } else if (child.type === A || child.type === B || child.type === C) {\n newContent.push(React.cloneElement(child, { key }));\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(React.cloneElement(child, { key }));\n }\n }\n });\n\n return {\n preContainer: newPreContainer,\n title: newTitle,\n content: newContent,\n expandableContent: newExpandableContent,\n hasIcon: localHasIcon,\n };\n }, [children, effectiveHighlightText]);\n\n React.useEffect(() => {\n if (expanded) {\n // Hvis panel åpnes controlled skal ikke scroll skje\n return;\n }\n // Scroller oppover når expanded content åpnes uncontrolled\n if (isExpanded) {\n if ('current' in panelRef && panelRef.current && expandedContentRef.current) {\n const panelRect = panelRef.current.getBoundingClientRect();\n const expandedContentRect = expandedContentRef.current.getBoundingClientRect();\n\n const scrollAmount = Math.min(defaultScroll, panelRect.top - 20);\n\n // Scroller kun oppover, og kun dersom expandedContent havner utenfor skjermen når åpnet\n if (scrollAmount > 0 && expandedContentRect.bottom > window.innerHeight) {\n const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (prefersReducedMotion) {\n return;\n }\n window.scrollBy({\n top: scrollAmount,\n behavior: 'smooth',\n });\n }\n }\n }\n }, [isExpanded]);\n\n const colorScheme = effectiveVariant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(effectiveClassName, {\n [styles['panel__border--outline--outer']]: effectiveVariant === PanelVariant.outline,\n [styles['panel__border--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: effectiveVariant === PanelVariant.fill && colorScheme === 'neutral',\n [styles['panel__border--fill--new']]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,\n [styles['panel__border--fill--status']]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none,\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel--new']]: status === PanelStatus.new,\n [styles['panel--draft']]: status === PanelStatus.draft,\n [styles['panel--error']]: status === PanelStatus.error,\n [styles['panel--icon']]: hasIcon,\n });\n const contentContainerLayout = classNames(styles['panel__content'], styles[`panel__content--${layout}`], {\n [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst,\n });\n const expanderBorderLayout = classNames({\n [styles['panel__expander__border--expanded']]: isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--line`]]:\n !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line,\n });\n\n const handleExpandClick = (): void => {\n setIsExpanded(!isExpanded);\n };\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n <ExpandButton onClick={handleExpandClick} isExpanded={isExpanded} resources={mergedResources} />\n {isExpanded && (\n <div ref={expandedContentRef} data-testid={testId + '-details'}>\n <div className={styles['panel__expander__separator']} />\n <Highlighter searchText={effectiveHighlightText}>{expandableContent}</Highlighter>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n ) : (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n {buttonBottomText && buttonBottomOnClick && (\n <div className={styles['panel__button-bottom']}>\n <Button variant=\"borderless\" type=\"button\" size=\"medium\" onClick={buttonBottomOnClick} aria-label={buttonBottomAriaLabel}>\n {buttonBottomText}\n <Icon svgIcon={ChevronRight} size={IconSize.XSmall} />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ContentProps {\n /** Children elements to be rendered inside the content box */\n children?: React.ReactNode;\n}\n\nexport const PreContainer: React.FC<ContentProps> = ({ children }) => {\n return <div className={styles['panel__pre-container']}>{children}</div>;\n};\n\nexport const A: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--a']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const B: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--b']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const C: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--c']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const ExpandedContent: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__expander__content']);\n return <div className={styling}>{children}</div>;\n};\n\ntype PanelComponent = typeof PanelRoot & {\n PreContainer: React.FC<ContentProps>;\n Title: React.FC<PanelTitleProps>;\n A: React.FC<ContentProps>;\n B: React.FC<ContentProps>;\n C: React.FC<ContentProps>;\n ExpandedContent: React.FC<ContentProps>;\n};\nPanelRoot.displayName = 'Panel';\nconst Panel = PanelRoot as PanelComponent;\nPanel.PreContainer = PreContainer;\nPanel.Title = PanelTitle;\nPanel.A = A;\nPanel.B = B;\nPanel.C = C;\nPanel.ExpandedContent = ExpandedContent;\n\nexport default Panel;\n","import Panel from './Panel';\nexport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nexport * from './Panel';\nexport default Panel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AEMA,IAAa,gBAAgB,aAAmD;CAC9E,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;;;ACkDA,IAAM,gBAAgB,EACpB,SACA,YACA,gBAKuB;CACvB,MAAM,kBAAkB,WAAW,OAAO,qBAAqB,cAAc,OAAO,6BAA6B;CAEjH,OACE,qBAAC,gBAAD;EACE,SAAQ;EACR,eAAe,OAAO;EACtB,kBAAkB;EAClB,iBAAe;EACN;EALX,UAAA,CAOE,oBAAC,cAAD;GAAM,SAAS,aAAa,YAAY;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AAC,OAAD;EAAK,WAAW;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,mBAA2C,EAAE,eAAe;CACvE,MAAM,UAAU,WAAW,OAAO,2BAA2B;CAC7D,OAAO,oBAAC,OAAD;EAAK,WAAW;EAAU;CAAc,CAAA;AACjD;AAUA,UAAU,cAAc;AACxB,IAAM,QAAQ;AACd,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;;;AC3TxB,IAAA,gBAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/resources/HN.Designsystem.Panel.en-GB.json","../../../src/resources/HN.Designsystem.Panel.nb-NO.json","../../../src/components/Panel/resourceHelper.ts","../../../src/components/Panel/Panel.tsx","../../../src/components/Panel/index.ts"],"sourcesContent":["{\n \"expandButtonOpen\": \"See details\",\n \"expandButtonClose\": \"Hide details\"\n}\n","{\n \"expandButtonOpen\": \"Se detaljer\",\n \"expandButtonClose\": \"Skjul detaljer\"\n}\n","import type { HNDesignsystemPanel } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemPanel => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PanelTitleProps } from './PanelTitle';\nimport type { HNDesignsystemPanel } from '../../resources/Resources';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport { LanguageLocales } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nimport PanelTitle from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport { isComponent } from '../../utils/component';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\nimport { PanelListContext } from '../PanelList/utils';\n\nimport styles from './styles.module.scss';\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport interface PanelProps {\n /** Aria label on call to action button */\n buttonBottomAriaLabel?: string;\n /** Sets the text on the bottom call to action button */\n buttonBottomText?: string;\n /** Sets the action on the bottom call to action button */\n buttonBottomOnClick?: () => void;\n /** Expands or collapses the panel. Only applicable when ExpandedContent is used */\n expanded?: boolean;\n /** Whether the panel can be focused */\n focusable?: boolean;\n /** Sets the layout and order of the content boxes */\n layout?: PanelLayout;\n /** Sets the visual variant of panel */\n variant?: PanelVariant;\n /** Sets the color for panel if it has variant fill */\n color?: PanelColors;\n /** Sets classes on the outermost container of the panel */\n className?: string;\n /** Action called when toggling expansion of ExpandedContent */\n onExpand?: (isExpanded?: boolean) => void;\n /** Sets the stacking order of the content boxes */\n stacking?: PanelStacking;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Children elements to be rendered inside the panel */\n children?: React.ReactNode;\n /** Displays a status on the left side: default normal */\n status?: PanelStatus;\n /** Resources for component */\n resources?: Partial<HNDesignsystemPanel>;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /** Ref passed to the panel container */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nconst ExpandButton = ({\n onClick,\n isExpanded,\n resources,\n}: {\n onClick: () => void;\n isExpanded: boolean | undefined;\n resources: Partial<HNDesignsystemPanel>;\n}): React.JSX.Element => {\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n return (\n <Button\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n wrapperClassName={buttonClassName}\n aria-expanded={isExpanded}\n onClick={onClick}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n <span>{isExpanded ? resources.expandButtonClose : resources.expandButtonOpen}</span>\n </Button>\n );\n};\nconst PanelRoot: React.FC<PanelProps> = ({\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n expanded = false,\n focusable,\n status = PanelStatus.none,\n buttonBottomAriaLabel,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n onExpand,\n highlightText,\n ref,\n}: PanelProps) => {\n const panelListContext = React.useContext(PanelListContext);\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const localRef = React.useRef<HTMLDivElement>(null);\n const panelRef = ref ?? localRef;\n const expandedContentRef = React.useRef<HTMLDivElement>(null);\n const defaultScroll = 100;\n\n // Use context values if available, otherwise use props\n const effectiveVariant = panelListContext?.variant ?? variant;\n const effectiveHighlightText = panelListContext?.highlightText ?? highlightText;\n const effectiveClassName = panelListContext?.applyPanelClassName(className) ?? className;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemPanel = {\n ...defaultResources,\n ...resources,\n };\n\n const { preContainer, title, content, expandableContent, hasIcon } = React.useMemo(() => {\n let index = 0;\n let localHasIcon = false;\n const newPreContainer: React.ReactNode[] = [];\n const newTitle: React.ReactNode[] = [];\n const newContent: React.ReactNode[] = [];\n const newExpandableContent: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n const key = child.key ?? `panel-child-${index++}`;\n\n if (child.type === PreContainer) {\n newPreContainer.push(React.cloneElement(child, { key }));\n } else if (isComponent<PanelTitleProps>(child, PanelTitle)) {\n newTitle.push(\n React.cloneElement(child as React.ReactElement<PanelTitleProps>, {\n key,\n highlightText: child.props.highlightText || effectiveHighlightText,\n })\n );\n if (child.props.icon) {\n localHasIcon = true;\n }\n } else if (child.type === A || child.type === B || child.type === C) {\n newContent.push(React.cloneElement(child, { key }));\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(React.cloneElement(child, { key }));\n }\n }\n });\n\n return {\n preContainer: newPreContainer,\n title: newTitle,\n content: newContent,\n expandableContent: newExpandableContent,\n hasIcon: localHasIcon,\n };\n }, [children, effectiveHighlightText]);\n\n React.useEffect(() => {\n if (expanded) {\n // Hvis panel åpnes controlled skal ikke scroll skje\n return;\n }\n // Scroller oppover når expanded content åpnes uncontrolled\n if (isExpanded) {\n if ('current' in panelRef && panelRef.current && expandedContentRef.current) {\n const panelRect = panelRef.current.getBoundingClientRect();\n const expandedContentRect = expandedContentRef.current.getBoundingClientRect();\n\n const scrollAmount = Math.min(defaultScroll, panelRect.top - 20);\n\n // Scroller kun oppover, og kun dersom expandedContent havner utenfor skjermen når åpnet\n if (scrollAmount > 0 && expandedContentRect.bottom > window.innerHeight) {\n const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (prefersReducedMotion) {\n return;\n }\n window.scrollBy({\n top: scrollAmount,\n behavior: 'smooth',\n });\n }\n }\n }\n }, [isExpanded]);\n\n const colorScheme = effectiveVariant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(effectiveClassName, {\n [styles['panel__border--outline--outer']]: effectiveVariant === PanelVariant.outline,\n [styles['panel__border--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: effectiveVariant === PanelVariant.fill && colorScheme === 'neutral',\n [styles['panel__border--fill--new']]: effectiveVariant === PanelVariant.fill && status === PanelStatus.new,\n [styles['panel__border--fill--status']]: effectiveVariant === PanelVariant.fill && status !== PanelStatus.none,\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: effectiveVariant === PanelVariant.line,\n [styles['panel--new']]: status === PanelStatus.new,\n [styles['panel--draft']]: status === PanelStatus.draft,\n [styles['panel--error']]: status === PanelStatus.error,\n [styles['panel--icon']]: hasIcon,\n });\n const contentContainerLayout = classNames(styles['panel__content'], styles[`panel__content--${layout}`], {\n [styles[`panel__content--b-first`]]: stacking === PanelStacking.bFirst,\n });\n const expanderBorderLayout = classNames({\n [styles['panel__expander__border--expanded']]: isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--${colorScheme}`]]: !isExpanded && status === PanelStatus.none,\n [styles[`panel__expander__border--not-expanded--line`]]:\n !isExpanded && status === PanelStatus.none && effectiveVariant === PanelVariant.line,\n });\n\n const handleExpandClick = (): void => {\n setIsExpanded(!isExpanded);\n };\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n <ExpandButton onClick={handleExpandClick} isExpanded={isExpanded} resources={mergedResources} />\n {isExpanded && (\n <div ref={expandedContentRef} data-testid={testId + '-details'}>\n <div className={styles['panel__expander__separator']} />\n <Highlighter searchText={effectiveHighlightText}>{expandableContent}</Highlighter>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n ) : (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: effectiveVariant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef} tabIndex={focusable ? -1 : undefined}>\n <Highlighter searchText={effectiveHighlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={effectiveHighlightText}>{content}</Highlighter>\n </div>\n {buttonBottomText && buttonBottomOnClick && (\n <div className={styles['panel__button-bottom']}>\n <Button variant=\"borderless\" type=\"button\" size=\"normal\" onClick={buttonBottomOnClick} aria-label={buttonBottomAriaLabel}>\n {buttonBottomText}\n <Icon svgIcon={ChevronRight} size={IconSize.XSmall} />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport interface ContentProps {\n /** Children elements to be rendered inside the content box */\n children?: React.ReactNode;\n}\n\nexport const PreContainer: React.FC<ContentProps> = ({ children }) => {\n return <div className={styles['panel__pre-container']}>{children}</div>;\n};\n\nexport const A: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--a']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const B: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--b']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const C: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__content__item'], styles['panel__content__item--c']);\n return <div className={styling}>{children}</div>;\n};\n\nexport const ExpandedContent: React.FC<ContentProps> = ({ children }) => {\n const styling = classNames(styles['panel__expander__content']);\n return <div className={styling}>{children}</div>;\n};\n\ntype PanelComponent = typeof PanelRoot & {\n PreContainer: React.FC<ContentProps>;\n Title: React.FC<PanelTitleProps>;\n A: React.FC<ContentProps>;\n B: React.FC<ContentProps>;\n C: React.FC<ContentProps>;\n ExpandedContent: React.FC<ContentProps>;\n};\nPanelRoot.displayName = 'Panel';\nconst Panel = PanelRoot as PanelComponent;\nPanel.PreContainer = PreContainer;\nPanel.Title = PanelTitle;\nPanel.A = A;\nPanel.B = B;\nPanel.C = C;\nPanel.ExpandedContent = ExpandedContent;\n\nexport default Panel;\n","import Panel from './Panel';\nexport { PanelLayout, PanelStacking, PanelStatus, PanelVariant } from './constants';\nexport * from './Panel';\nexport default Panel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AEMA,IAAa,gBAAgB,aAAmD;CAC9E,QAAQ,UAAR;EACE,KAAK,gBAAgB,SACnB,OAAO;EACT,KAAK,gBAAgB;EACrB,SACE,OAAO;CACX;AACF;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ACjD;AAEA,IAAa,KAA6B,EAAE,eAAe;CACzD,MAAM,UAAU,WAAW,OAAO,yBAAyB,OAAO,0BAA0B;CAC5F,OAAO,oBAAC,OAAD;EAAK,WAAW;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,KAA6B,EAAE,eAAe;CACzD,MAAM,UAAU,WAAW,OAAO,yBAAyB,OAAO,0BAA0B;CAC5F,OAAO,oBAAC,OAAD;EAAK,WAAW;EAAU;CAAc,CAAA;AACjD;AAEA,IAAa,mBAA2C,EAAE,eAAe;CACvE,MAAM,UAAU,WAAW,OAAO,2BAA2B;CAC7D,OAAO,oBAAC,OAAD;EAAK,WAAW;EAAU;CAAc,CAAA;AACjD;AAUA,UAAU,cAAc;AACxB,IAAM,QAAQ;AACd,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;;;AC3TxB,IAAA,gBAAe"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
@use '../../scss/breakpoints' as breakpoints;
|
|
4
4
|
@use '../../scss/font-settings' as fonts;
|
|
5
5
|
@use '../Button/styles.module' as button;
|
|
6
|
-
@import '../../scss/supernova/styles/colors.css';
|
|
7
6
|
|
|
8
7
|
.panel {
|
|
9
8
|
$panel: &;
|
|
@@ -110,11 +109,11 @@
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
&--white {
|
|
113
|
-
background-color: var(--color-base-background-
|
|
112
|
+
background-color: var(--color-base-background-light);
|
|
114
113
|
}
|
|
115
114
|
|
|
116
115
|
&--neutral {
|
|
117
|
-
background-color: var(--color-base-background-
|
|
116
|
+
background-color: var(--color-base-neutral-background-light);
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
&--line {
|
|
@@ -124,7 +123,7 @@
|
|
|
124
123
|
&__border {
|
|
125
124
|
&--outline {
|
|
126
125
|
&--outer {
|
|
127
|
-
border: 1px solid var(--color-base-border-
|
|
126
|
+
border: 1px solid var(--color-base-neutral-border-light-plus1);
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
&--inner {
|
|
@@ -133,15 +132,15 @@
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
&--line {
|
|
136
|
-
border-top: 1px solid var(--color-base-border-
|
|
137
|
-
border-bottom: 1px solid var(--color-base-border-
|
|
135
|
+
border-top: 1px solid var(--color-base-border-dark);
|
|
136
|
+
border-bottom: 1px solid var(--color-base-border-dark);
|
|
138
137
|
border-right: none;
|
|
139
138
|
border-left: none;
|
|
140
139
|
padding: spacers.getSpacer(xs) 0;
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
&--fill--neutral {
|
|
144
|
-
border: 1px solid var(--color-base-border-
|
|
143
|
+
border: 1px solid var(--color-base-neutral-border-light-plus1);
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
&--fill--new {
|
|
@@ -154,7 +153,7 @@
|
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
&--border {
|
|
157
|
-
border: 2px solid var(--color-base-background-
|
|
156
|
+
border: 2px solid var(--color-base-background-light);
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
&--status {
|
|
@@ -164,31 +163,31 @@
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
&--new {
|
|
167
|
-
border-left-color: var(--color-notification-
|
|
168
|
-
background-color: var(--color-base-background-
|
|
166
|
+
border-left-color: var(--color-notification-info);
|
|
167
|
+
background-color: var(--color-base-blueberry-background-light);
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
&--draft {
|
|
172
|
-
border-left: dotted $status-width var(--color-notification-
|
|
171
|
+
border-left: dotted $status-width var(--color-notification-draft);
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
&--error {
|
|
176
|
-
border-left-color: var(--color-notification-
|
|
175
|
+
border-left-color: var(--color-notification-error);
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
&__expander {
|
|
180
179
|
&__border {
|
|
181
180
|
&--expanded {
|
|
182
|
-
border-left: 2px solid var(--color-base-border-
|
|
181
|
+
border-left: 2px solid var(--color-base-emphasized-border-dark);
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
&--not-expanded {
|
|
186
185
|
&--white {
|
|
187
|
-
border-left: 2px solid var(--color-base-background-
|
|
186
|
+
border-left: 2px solid var(--color-base-background-light);
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
&--neutral {
|
|
191
|
-
border-left: 2px solid var(--color-base-background-
|
|
190
|
+
border-left: 2px solid var(--color-base-neutral-background-light);
|
|
192
191
|
}
|
|
193
192
|
|
|
194
193
|
&--line {
|
|
@@ -200,7 +199,7 @@
|
|
|
200
199
|
&__separator {
|
|
201
200
|
height: 1px;
|
|
202
201
|
width: 40px;
|
|
203
|
-
background-color: var(--color-base-border-
|
|
202
|
+
background-color: var(--color-base-border-dark);
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
&__content {
|
|
@@ -18,7 +18,7 @@ export type Styles = {
|
|
|
18
18
|
'button--large-borderless': string;
|
|
19
19
|
'button--large-non-borderless': string;
|
|
20
20
|
'button--left-icon': string;
|
|
21
|
-
'button--
|
|
21
|
+
'button--normal': string;
|
|
22
22
|
'button--on-dark': string;
|
|
23
23
|
'button--only-icon': string;
|
|
24
24
|
'button--outline': string;
|
|
@@ -5,7 +5,7 @@ import { t as LazyIcon_default } from "../../LazyIcon.js";
|
|
|
5
5
|
import { isComponent } from "../../utils/component.js";
|
|
6
6
|
import { useIsMobileBreakpoint } from "../../hooks/useIsMobileBreakpoint.js";
|
|
7
7
|
import { t as Button_default } from "../../Button.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useDismissablePopover } from "../../hooks/useDismissablePopover.js";
|
|
9
9
|
import X from "../Icons/X.js";
|
|
10
10
|
import { t as PopOver_default } from "../../PopOver.js";
|
|
11
11
|
import VerticalDots from "../Icons/VerticalDots.js";
|
|
@@ -35,13 +35,16 @@ var PopMenu = (props) => {
|
|
|
35
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
36
36
|
const { children, popOverClassName, popMenuClassName, openButtonTestId, closeButtonTestId, popOverTestId, openButtonAriaLabel, closeButtonAriaLabel, svgIcon, labelText, labelTextPosition = PopMenuLabelPosition.right } = props;
|
|
37
37
|
const isMobile = useIsMobileBreakpoint();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const handleClose = useDismissablePopover({
|
|
39
|
+
popoverRef: outerRef,
|
|
40
|
+
triggerRef: triggerButtonRef,
|
|
41
|
+
isOpen,
|
|
42
|
+
onClose: () => setIsOpen(false)
|
|
40
43
|
});
|
|
41
44
|
const { isHovered: triggerButtonIsHovered } = usePseudoClasses(triggerButtonRef);
|
|
42
45
|
const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;
|
|
43
46
|
const handleClick = (cb) => {
|
|
44
|
-
|
|
47
|
+
handleClose();
|
|
45
48
|
if (cb) cb();
|
|
46
49
|
};
|
|
47
50
|
const renderChildren = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/PopMenu/constants.ts","../../../src/components/PopMenu/PopMenu.tsx","../../../src/components/PopMenu/index.ts"],"sourcesContent":["export enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n","import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LinkListProps, LinkProps } from '../LinkList';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/PopMenu/constants.ts","../../../src/components/PopMenu/PopMenu.tsx","../../../src/components/PopMenu/index.ts"],"sourcesContent":["export enum PopMenuVariant {\n onWhite = 'on-white',\n onGray = 'on-gray',\n onBlueberry = 'on-blueberry',\n}\n\nexport enum PopMenuLabelPosition {\n right = 'right',\n left = 'left',\n}\n","import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\nimport type { LinkListProps, LinkProps } from '../LinkList';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useDismissablePopover } from '../../hooks/useDismissablePopover';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { isComponent } from '../../utils/component';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport VerticalDots from '../Icons/VerticalDots';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\nimport LinkList from '../LinkList';\nimport PopOver from '../PopOver';\nimport { PopMenuLabelPosition, type PopMenuVariant } from './constants';\n\nimport styles from './styles.module.scss';\n\nexport interface PopMenuProps {\n /** Content shown inside PopOver. Can only be a LinkList */\n children: React.ReactElement<LinkListProps>;\n /** Adds custom classes to the popover element. */\n popOverClassName?: string;\n /** Adds custom classes to the element. */\n popMenuClassName?: string;\n /** @deprecated Changes responsive design for the trigger buttons. */\n popMenuVariant?: PopMenuVariant;\n /** Sets the data-testid attribute for the button that opens. */\n openButtonTestId?: string;\n /** Sets the data-testid attribute for the button that closes. */\n closeButtonTestId?: string;\n /** Sets the data-testid attribute for the popover. */\n popOverTestId?: string;\n /** Sets the arial-label attribute for the openButton. */\n openButtonAriaLabel?: string;\n /** Sets the arial-label attribute for the closeButton. */\n closeButtonAriaLabel?: string;\n /** Sets the icon on the trigger button. */\n svgIcon?: SvgIcon | IconName;\n /** Optional text next to the trigger button. */\n labelText?: string;\n /** Placement of the label text relative to the trigger button. */\n labelTextPosition?: PopMenuLabelPosition;\n}\n\nexport const PopMenu: React.FC<PopMenuProps> = (props: PopMenuProps) => {\n const triggerButtonRef = useRef<HTMLButtonElement>(null);\n const iconRef = useRef(null);\n const outerRef = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const {\n children,\n popOverClassName,\n popMenuClassName,\n openButtonTestId,\n closeButtonTestId,\n popOverTestId,\n openButtonAriaLabel,\n closeButtonAriaLabel,\n svgIcon,\n labelText,\n labelTextPosition = PopMenuLabelPosition.right,\n } = props;\n const isMobile = useIsMobileBreakpoint();\n\n const handleClose = useDismissablePopover({\n popoverRef: outerRef,\n triggerRef: triggerButtonRef,\n isOpen,\n onClose: () => setIsOpen(false),\n });\n\n const { isHovered: triggerButtonIsHovered } = usePseudoClasses(triggerButtonRef);\n const mobileIconSize = isMobile ? IconSize.XSmall : IconSize.Small;\n\n const handleClick = (cb?: () => void): void => {\n handleClose();\n if (cb) cb();\n };\n\n const renderChildren = (): React.ReactElement | undefined => {\n if (isComponent<LinkListProps>(children, LinkList)) {\n return (\n <PopOver\n testId={popOverTestId}\n className={classNames(styles['pop-menu__pop-over'], popOverClassName)}\n controllerRef={iconRef}\n role=\"dialog\"\n show={isOpen}\n >\n {React.Children.map(children, child =>\n React.cloneElement(child, {\n children: React.Children.map(child.props.children, child =>\n isComponent<LinkProps>(child, LinkList.Link)\n ? React.cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) =>\n handleClick(() => child.props.onClick && child.props.onClick(event)),\n })\n : child\n ),\n })\n )}\n </PopOver>\n );\n }\n };\n\n const toggleOpenOnClick = (): void => {\n setIsOpen(!isOpen);\n };\n\n const iconComponent =\n svgIcon && typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n ) : (\n svgIcon && <Icon svgIcon={svgIcon} size={IconSize.XSmall} isHovered={triggerButtonIsHovered} />\n );\n\n const openIcon = svgIcon ? (\n iconComponent\n ) : (\n <Icon ref={iconRef} svgIcon={svgIcon ?? VerticalDots} size={mobileIconSize} isHovered={triggerButtonIsHovered} />\n );\n\n const closeIcon = <Icon svgIcon={X} ref={iconRef} size={mobileIconSize} isHovered={triggerButtonIsHovered} />;\n\n return (\n <div ref={outerRef} className={classNames(popMenuClassName)} data-analyticsid={AnalyticsId.PopMenu}>\n <Button\n variant=\"borderless\"\n aria-expanded={isOpen}\n onClick={toggleOpenOnClick}\n ref={triggerButtonRef}\n ariaLabel={isOpen ? closeButtonAriaLabel : openButtonAriaLabel}\n testId={isOpen ? closeButtonTestId : openButtonTestId}\n >\n {labelText && labelTextPosition == PopMenuLabelPosition.left && <span>{labelText}</span>}\n {isOpen ? closeIcon : openIcon}\n {labelText && labelTextPosition == PopMenuLabelPosition.right && <span>{labelText}</span>}\n </Button>\n {isOpen && renderChildren()}\n </div>\n );\n};\n\nexport default PopMenu;\n","import PopMenu from './PopMenu';\nexport { PopMenuVariant, PopMenuLabelPosition } from './constants';\nexport * from './PopMenu';\nexport default PopMenu;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,aAAA;CACA,eAAA,YAAA;CACA,eAAA,iBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,uBAAL,yBAAA,sBAAA;CACL,qBAAA,WAAA;CACA,qBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;;;AC0CA,IAAa,WAAmC,UAAwB;CACtE,MAAM,mBAAmB,OAA0B,IAAI;CACvD,MAAM,UAAU,OAAO,IAAI;CAC3B,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,EACJ,UACA,kBACA,kBACA,kBACA,mBACA,eACA,qBACA,sBACA,SACA,WACA,oBAAoB,qBAAqB,UACvC;CACJ,MAAM,WAAW,sBAAsB;CAEvC,MAAM,cAAc,sBAAsB;EACxC,YAAY;EACZ,YAAY;EACZ;EACA,eAAe,UAAU,KAAK;CAChC,CAAC;CAED,MAAM,EAAE,WAAW,2BAA2B,iBAAiB,gBAAgB;CAC/E,MAAM,iBAAiB,WAAW,SAAS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a,qBAAqB,qBAAqB,QAAQ,oBAAC,QAAD,EAAA,UAAO,UAAgB,CAAA;IACtF,SAAS,YAAY;IACrB,aAAa,qBAAqB,qBAAqB,SAAS,oBAAC,QAAD,EAAA,UAAO,UAAgB,CAAA;GAClF;EACP,CAAA,GAAA,UAAU,eAAe,CACvB;;AAET;;;AClJA,IAAA,kBAAe"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
@use '../../scss/font-settings' as font-settings;
|
|
3
3
|
@use '../../scss/font-mixins' as fonts;
|
|
4
4
|
@use '../../scss/breakpoints' as breakpoints;
|
|
5
|
-
@import '../../scss/supernova/styles/colors.css';
|
|
6
|
-
@import '../../scss/supernova/styles/spacers.css';
|
|
7
5
|
|
|
8
6
|
.popover {
|
|
9
7
|
width: max-content;
|
|
@@ -11,7 +9,7 @@
|
|
|
11
9
|
text-align: start;
|
|
12
10
|
background-color: var(--core-color-white);
|
|
13
11
|
z-index: 3;
|
|
14
|
-
box-shadow: 0 0 0 1px var(--color-base-border-
|
|
12
|
+
box-shadow: 0 0 0 1px var(--color-base-border-dark);
|
|
15
13
|
border-radius: 9px;
|
|
16
14
|
filter: drop-shadow(0 4px 16px rgb(0 0 0 / 30%));
|
|
17
15
|
padding: var(--core-space-s);
|
|
@@ -2,7 +2,7 @@ import { Overlay, ProgressBarMode, ProgressbarSize } from './constants';
|
|
|
2
2
|
export interface ProgressbarProps {
|
|
3
3
|
/** The value of the progressbar given in percent. Value between 0 and 100 */
|
|
4
4
|
value: number;
|
|
5
|
-
/** Size of the progressbar. Default is
|
|
5
|
+
/** Size of the progressbar. Default is normal */
|
|
6
6
|
size?: ProgressbarSize;
|
|
7
7
|
/** Changes the visuals of the ProgressBar. Default is onLight */
|
|
8
8
|
mode?: ProgressBarMode;
|
|
@@ -8,7 +8,7 @@ import styles from "./styles.module.scss";
|
|
|
8
8
|
var ProgressbarSize = /* @__PURE__ */ function(ProgressbarSize) {
|
|
9
9
|
ProgressbarSize["small"] = "small";
|
|
10
10
|
ProgressbarSize["medium"] = "medium";
|
|
11
|
-
ProgressbarSize["
|
|
11
|
+
ProgressbarSize["normal"] = "normal";
|
|
12
12
|
return ProgressbarSize;
|
|
13
13
|
}({});
|
|
14
14
|
var ProgressBarMode = /* @__PURE__ */ function(ProgressBarMode) {
|
|
@@ -23,11 +23,11 @@ var Overlay = /* @__PURE__ */ function(Overlay) {
|
|
|
23
23
|
}({});
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/components/Progressbar/Progressbar.tsx
|
|
26
|
-
var Progressbar = ({ value, size = ProgressbarSize.
|
|
26
|
+
var Progressbar = ({ value, size = ProgressbarSize.normal, mode = ProgressBarMode.onlight, overlay, testId, ariaLabel }) => {
|
|
27
27
|
if (overlay) mode = ProgressBarMode.ondark;
|
|
28
28
|
value = Math.max(0, Math.min(value, 100));
|
|
29
29
|
let width;
|
|
30
|
-
if (size === ProgressbarSize.
|
|
30
|
+
if (size === ProgressbarSize.normal) width = 96;
|
|
31
31
|
else if (size === ProgressbarSize.medium) width = 50;
|
|
32
32
|
else width = 44;
|
|
33
33
|
const totalRadius = width / 2;
|
|
@@ -94,7 +94,7 @@ var Progressbar = ({ value, size = ProgressbarSize.large, mode = ProgressBarMode
|
|
|
94
94
|
y: viewBoxCenter,
|
|
95
95
|
textAnchor: "middle",
|
|
96
96
|
alignmentBaseline: "middle",
|
|
97
|
-
children: size === ProgressbarSize.
|
|
97
|
+
children: size === ProgressbarSize.normal && valueText
|
|
98
98
|
})
|
|
99
99
|
]
|
|
100
100
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Progressbar/constants.ts","../../../src/components/Progressbar/Progressbar.tsx","../../../src/components/Progressbar/index.ts"],"sourcesContent":["export enum ProgressbarSize {\n small = 'small',\n medium = 'medium',\n normal = 'normal',\n}\n\nexport enum ProgressBarMode {\n ondark = 'ondark',\n onlight = 'onlight',\n}\n\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n","import { useRef, useEffect } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Overlay, ProgressBarMode, ProgressbarSize } from './constants';\nimport { ZIndex } from '../../constants';\nimport { palette } from '../../theme/palette';\n\nimport styles from './styles.module.scss';\n\nexport interface ProgressbarProps {\n /** The value of the progressbar given in percent. Value between 0 and 100 */\n value: number;\n /** Size of the progressbar. Default is normal */\n size?: ProgressbarSize;\n /** Changes the visuals of the ProgressBar. Default is onLight */\n mode?: ProgressBarMode;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Aria label for the progressbar */\n ariaLabel?: string;\n /** Sets the data-testid attribute */\n testId?: string;\n}\n\nconst Progressbar: React.FC<ProgressbarProps> = ({\n value,\n size = ProgressbarSize.normal,\n mode = ProgressBarMode.onlight,\n overlay,\n testId,\n ariaLabel,\n}: ProgressbarProps) => {\n if (overlay) {\n mode = ProgressBarMode.ondark;\n }\n // Restrict value to be between 0 and 100\n value = Math.max(0, Math.min(value, 100));\n\n let width;\n if (size === ProgressbarSize.normal) {\n width = 96;\n } else if (size === ProgressbarSize.medium) {\n width = 50;\n } else {\n width = 44;\n }\n\n const totalRadius = width / 2;\n const strokeWidth = 8;\n const radius = totalRadius - strokeWidth / 2;\n const viewBoxSize = totalRadius * 2;\n const viewBoxCenter = totalRadius;\n const circleBackgroundColor = mode === ProgressBarMode.onlight ? palette.blueberry100 : palette.neutral700;\n const mainColor = mode === ProgressBarMode.onlight ? palette.blueberry600 : palette.white;\n const circumference = 2 * Math.PI * radius;\n const strokeDashoffset = circumference - (value / 100) * circumference;\n const valueText = `${value}%`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n }\n }, []);\n\n const wrapperClasses = classNames({\n [styles['progressbar--overlay']]: overlay,\n [styles['progressbar--overlay-screen']]: overlay === Overlay.screen,\n [styles['progressbar--overlay-parent']]: overlay === Overlay.parent,\n });\n\n return (\n <>\n <div\n ref={wrapperRef}\n className={wrapperClasses}\n data-testid={testId}\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={value}\n aria-label={ariaLabel}\n style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}\n >\n <svg\n role=\"presentation\"\n width={viewBoxSize}\n height={viewBoxSize}\n viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}\n className={styles['progressbar__svg']}\n >\n <circle cx={viewBoxCenter} cy={viewBoxCenter} r={radius} stroke={circleBackgroundColor} strokeWidth={strokeWidth} fill=\"none\" />\n <circle\n cx={viewBoxCenter}\n cy={viewBoxCenter}\n r={radius}\n stroke={mainColor}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={strokeDashoffset}\n className={styles['progressbar__progress-circle']}\n transform={`rotate(-90 ${viewBoxCenter} ${viewBoxCenter})`}\n />\n <text\n className=\"progress-wheel__text--large\"\n fontSize={'1.5rem'}\n fill={mainColor}\n x={viewBoxCenter}\n y={viewBoxCenter}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {size === ProgressbarSize.normal && valueText}\n </text>\n </svg>\n </div>\n <div className={styles['progressbar__sr-only-text']} aria-live=\"assertive\" aria-atomic=\"true\">\n {valueText}\n </div>\n </>\n );\n};\n\nexport default Progressbar;\n","import Progressbar from './Progressbar';\nexport { ProgressbarSize, ProgressBarMode, Overlay } from './constants';\nexport * from './Progressbar';\nexport default Progressbar;\n"],"mappings":";;;;;;;AAAA,IAAY,kBAAL,yBAAA,iBAAA;CACL,gBAAA,WAAA;CACA,gBAAA,YAA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ACX,eAAa;EACb,MAAK;EACL,iBAAe;EACf,iBAAe;EACf,iBAAe;EACf,cAAY;EACZ,OAAO,YAAY,QAAQ,SAAS,EAAE,QAAQ,OAAO,cAAc,IAAI,CAAC;EAExE,UAAA,qBAAC,OAAD;GACE,MAAK;GACL,OAAO;GACP,QAAQ;GACR,SAAS,OAAO,YAAY,GAAG;GAC/B,WAAW,OAAO;GALpB,UAAA;IAOE,oBAAC,UAAD;KAAQ,IAAI;KAAe,IAAI;KAAe,GAAG;KAAQ,QAAQ;KAAoC;KAAa,MAAK;IAAQ,CAAA;IAC/H,oBAAC,UAAD;KACE,IAAI;KACJ,IAAI;KACJ,GAAG;KACH,QAAQ;KACK;KACb,MAAK;KACL,iBAAiB;KACC;KAClB,WAAW,OAAO;KAClB,WAAW,cAAc,cAAc,GAAG,cAAc;IACzD,CAAA;IACD,oBAAC,QAAD;KACE,WAAU;KACV,UAAU;KACV,MAAM;KACN,GAAG;KACH,GAAG;KACH,YAAW;KACX,mBAAkB;KAEjB,UAAA,SAAS,gBAAgB,UAAU;IAChC,CAAA;GACH;;CACF,CAAA,GACL,oBAAC,OAAD;EAAK,WAAW,OAAO;EAA8B,aAAU;EAAY,eAAY;EACpF,UAAA;CACE,CAAA,CACL,EAAA,CAAA;AAEN;;;ACzHA,IAAA,sBAAe"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ErrorWrapperClassNameProps } from '../ErrorWrapper';
|
|
2
|
+
import { FormOnColor, FormSize } from '../../constants';
|
|
3
|
+
export interface RadioProps extends ErrorWrapperClassNameProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'> {
|
|
4
|
+
/** Adds custom classes to the element. */
|
|
5
|
+
className?: string;
|
|
6
|
+
/** The <Label/> next to the radio - sublabels kan ikke kombineres med large variant */
|
|
7
|
+
label: React.ReactNode;
|
|
8
|
+
/** Adds custom classes to the label element. */
|
|
9
|
+
labelClassNames?: string;
|
|
10
|
+
/** input id of the radio */
|
|
11
|
+
inputId?: string;
|
|
12
|
+
/** Changes the visuals of the radio */
|
|
13
|
+
onColor?: keyof typeof FormOnColor;
|
|
14
|
+
/** Changes the visuals of the radio. Large version only works when used inside a FormGroup wrapper. */
|
|
15
|
+
size?: keyof typeof FormSize;
|
|
16
|
+
/** Activates Error style for the radio - This is can be true while errorText is empty, when in a FormGroup */
|
|
17
|
+
error?: boolean;
|
|
18
|
+
/** Error text to show above the component */
|
|
19
|
+
errorText?: string;
|
|
20
|
+
/** Error text id */
|
|
21
|
+
errorTextId?: string;
|
|
22
|
+
/** Sets the data-testid attribute. */
|
|
23
|
+
testId?: string;
|
|
24
|
+
/** Ref passed to the input element */
|
|
25
|
+
ref?: React.Ref<HTMLInputElement | null>;
|
|
26
|
+
}
|
|
27
|
+
export declare const Radio: React.FC<RadioProps>;
|
|
28
|
+
export default Radio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Radio/index.ts"],"sourcesContent":["import Radio from './Radio';\nexport * from './Radio';\nexport default Radio;\n"],"mappings":";;AAEA,IAAA,gBAAe"}
|
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
@use '../../scss/font-settings' as font-settings;
|
|
4
4
|
@use '../../scss/breakpoints' as breakpoints;
|
|
5
5
|
@use '../../scss/screen-reader' as *;
|
|
6
|
-
@import '../../scss/supernova/styles/spacers';
|
|
7
6
|
|
|
8
7
|
$padding-clickable-area-top-bottom: 8px;
|
|
9
8
|
$padding-clickable-area-left: 8px;
|
|
10
9
|
|
|
11
|
-
.radio-
|
|
10
|
+
.radio-errors {
|
|
12
11
|
font-size: font-settings.$font-size-sm;
|
|
13
12
|
font-weight: 600;
|
|
14
13
|
color: palette.$cherry600;
|
|
15
14
|
margin-top: 0;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
.radio-
|
|
17
|
+
.radio-wrapper {
|
|
19
18
|
margin-left: -$padding-clickable-area-left;
|
|
20
19
|
|
|
21
20
|
&__large {
|
|
@@ -40,7 +39,7 @@ $padding-clickable-area-left: 8px;
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
.radio-
|
|
42
|
+
.radio-label {
|
|
44
43
|
display: flex;
|
|
45
44
|
align-items: flex-start;
|
|
46
45
|
cursor: pointer;
|
|
@@ -71,7 +70,7 @@ $padding-clickable-area-left: 8px;
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
&:has(input:focus-visible) {
|
|
74
|
-
border: 1px solid var(--color-action-border-
|
|
73
|
+
border: 1px solid var(--color-action-border-light-focus);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
&--on-blueberry {
|
|
@@ -173,19 +172,19 @@ $padding-clickable-area-left: 8px;
|
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
.radio
|
|
175
|
+
.radio {
|
|
177
176
|
@include sr-only;
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
.
|
|
179
|
+
.radio__marker-wrapper {
|
|
181
180
|
margin-right: var(--core-space-s);
|
|
182
181
|
}
|
|
183
182
|
|
|
184
|
-
.
|
|
183
|
+
.radio-sublabel-wrapper {
|
|
185
184
|
margin-top: -$padding-clickable-area-top-bottom;
|
|
186
185
|
padding-left: calc(2.8rem + $padding-clickable-area-left);
|
|
187
186
|
}
|
|
188
187
|
|
|
189
|
-
.
|
|
188
|
+
.radio-afterlabelchildren-wrapper {
|
|
190
189
|
padding-top: $padding-clickable-area-top-bottom;
|
|
191
190
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Styles = {
|
|
2
|
+
radio: string;
|
|
3
|
+
'radio__marker-wrapper': string;
|
|
4
|
+
'radio-afterlabelchildren-wrapper': string;
|
|
5
|
+
'radio-errors': string;
|
|
6
|
+
'radio-label': string;
|
|
7
|
+
'radio-label__large': string;
|
|
8
|
+
'radio-label__large--disabled': string;
|
|
9
|
+
'radio-label__large--invalid': string;
|
|
10
|
+
'radio-label__large--on-blueberry': string;
|
|
11
|
+
'radio-label__large--on-grey': string;
|
|
12
|
+
'radio-label--disabled': string;
|
|
13
|
+
'radio-label--invalid': string;
|
|
14
|
+
'radio-label--on-dark': string;
|
|
15
|
+
'radio-sublabel-wrapper': string;
|
|
16
|
+
'radio-wrapper': string;
|
|
17
|
+
'radio-wrapper__large': string;
|
|
18
|
+
'radio-wrapper__large--invalid': string;
|
|
19
|
+
'radio-wrapper__large--on-blueberry': string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ClassNames = keyof Styles;
|
|
23
|
+
|
|
24
|
+
declare const styles: Styles;
|
|
25
|
+
|
|
26
|
+
export default styles;
|