@helsenorge/designsystem-react 12.0.0-beta.1 → 12.0.0-beta.2
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/CHANGELOG.md +90 -9
- package/Checkbox.js +1 -1
- package/Checkbox.js.map +1 -1
- package/Duolist.js +92 -0
- package/Duolist.js.map +1 -0
- package/ElementHeader.js +150 -0
- package/ElementHeader.js.map +1 -0
- package/ElementHeaderText.js +35 -0
- package/ElementHeaderText.js.map +1 -0
- package/HelpDetails.js +1 -1
- package/HelpDetails.js.map +1 -1
- package/HelpTriggerIcon.js +4 -4
- package/HelpTriggerIcon.js.map +1 -1
- package/HelpTriggerStandalone.js +5 -2
- package/HelpTriggerStandalone.js.map +1 -1
- package/Highlighter.js +44 -0
- package/Highlighter.js.map +1 -0
- package/LazyIcon.js +1 -1
- package/LazyIcon.js.map +1 -1
- package/LinkList.js +47 -9
- package/LinkList.js.map +1 -1
- package/NotificationBadge.js +1 -1
- package/NotificationBadge.js.map +1 -1
- package/Panel.js +38 -18
- package/Panel.js.map +1 -1
- package/PanelTitle.js +3 -2
- package/PanelTitle.js.map +1 -1
- package/PopOver.js +6 -0
- package/PopOver.js.map +1 -1
- package/StatusDot.js +15 -6
- package/StatusDot.js.map +1 -1
- package/StatusDotMultiComposition.js +27 -0
- package/StatusDotMultiComposition.js.map +1 -0
- package/components/AnchorLink/styles.module.scss +7 -7
- package/components/ArticleTeaser/styles.module.scss +7 -3
- package/components/Checkbox/styles.module.scss +7 -1
- package/components/Checkbox/styles.module.scss.d.ts +1 -0
- package/components/Close/styles.module.scss +10 -6
- package/components/DictionaryTrigger/styles.module.scss +12 -5
- package/components/Dropdown/styles.module.scss +9 -1
- package/components/Duolist/index.js +3 -88
- package/components/Duolist/index.js.map +1 -1
- package/components/ElementHeader/ElementHeader.d.ts +59 -0
- package/components/ElementHeader/ElementHeaderText/ElementHeaderText.d.ts +25 -0
- package/components/ElementHeader/ElementHeaderText/index.d.ts +3 -0
- package/components/ElementHeader/ElementHeaderText/index.js +6 -0
- package/components/ElementHeader/StatusDotMultiComposition/StatusDotMultiComposition.d.ts +23 -0
- package/components/ElementHeader/StatusDotMultiComposition/index.d.ts +3 -0
- package/components/ElementHeader/StatusDotMultiComposition/index.js +6 -0
- package/components/{ListHeader → ElementHeader/StatusDotMultiComposition}/index.js.map +1 -1
- package/components/ElementHeader/StatusDotMultiComposition/styles.module.scss +28 -0
- package/components/ElementHeader/StatusDotMultiComposition/styles.module.scss.d.ts +11 -0
- package/components/ElementHeader/index.d.ts +3 -0
- package/components/ElementHeader/index.js +9 -0
- package/components/ElementHeader/index.js.map +1 -0
- package/components/{ListHeader → ElementHeader}/styles.module.scss +46 -9
- package/components/ElementHeader/styles.module.scss.d.ts +22 -0
- package/components/ExpanderList/ExpanderList.d.ts +9 -2
- package/components/ExpanderList/index.js +40 -23
- package/components/ExpanderList/index.js.map +1 -1
- package/components/ExpanderList/styles.module.scss +288 -47
- package/components/ExpanderList/styles.module.scss.d.ts +22 -2
- package/components/HelpBubble/HelpBubble.d.ts +7 -0
- package/components/HelpBubble/index.js +43 -8
- package/components/HelpBubble/index.js.map +1 -1
- package/components/HelpBubble/resourceHelper.d.ts +3 -0
- package/components/HelpBubble/styles.module.scss +0 -2
- package/components/HelpDetails/styles.module.scss +3 -2
- package/components/HelpDrawer/HelpDrawer.d.ts +3 -0
- package/components/HelpDrawer/index.js +31 -1
- package/components/HelpDrawer/index.js.map +1 -1
- package/components/HelpDrawer/resourceHelper.d.ts +3 -0
- package/components/HelpDrawer/styles.module.scss +1 -11
- package/components/HelpDrawer/styles.module.scss.d.ts +0 -1
- package/components/HelpPanel/styles.module.scss +2 -2
- package/components/HelpTeaser/styles.module.scss +5 -5
- package/components/HelpTooltip/HelpTooltip.d.ts +2 -2
- package/components/HelpTooltip/index.js.map +1 -1
- package/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +4 -0
- package/components/HelpTriggerIcon/styles.module.scss +10 -10
- package/components/HelpTriggerInline/index.js +5 -2
- package/components/HelpTriggerInline/index.js.map +1 -1
- package/components/HelpTriggerInline/styles.module.scss +8 -4
- package/components/HelpTriggerStandalone/styles.module.scss +8 -4
- package/components/Highlighter/Highlighter.d.ts +7 -0
- package/components/Highlighter/Highlighter.test.d.ts +1 -0
- package/components/Highlighter/index.d.ts +3 -0
- package/components/Highlighter/index.js +6 -0
- package/components/Highlighter/index.js.map +1 -0
- package/components/Highlighter/styles.module.scss +4 -0
- package/components/Highlighter/styles.module.scss.d.ts +9 -0
- package/components/Icons/AdditionalIconInformation.d.ts +4 -0
- package/components/Icons/AdditionalIconInformation.js +2 -1
- package/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/components/Icons/DotActive.d.ts +4 -0
- package/components/Icons/DotActive.js +16 -0
- package/components/Icons/DotActive.js.map +1 -0
- package/components/Icons/DotInactive.d.ts +4 -0
- package/components/Icons/DotInactive.js +30 -0
- package/components/Icons/DotInactive.js.map +1 -0
- package/components/Icons/DotPending.d.ts +4 -0
- package/components/Icons/DotPending.js +16 -0
- package/components/Icons/DotPending.js.map +1 -0
- package/components/Icons/IconNames.d.ts +1 -1
- package/components/Icons/IconNames.js +4 -0
- package/components/Icons/IconNames.js.map +1 -1
- package/components/Icons/TreatmentAids.d.ts +4 -0
- package/components/Icons/TreatmentAids.js +41 -0
- package/components/Icons/TreatmentAids.js.map +1 -0
- package/components/LinkList/LinkList.d.ts +9 -2
- package/components/LinkList/styles.module.scss +70 -0
- package/components/LinkList/styles.module.scss.d.ts +11 -0
- package/components/NotificationPanel/styles.module.scss +1 -1
- package/components/Panel/Panel.d.ts +16 -8
- package/components/Panel/PanelTitle/PanelTitle.d.ts +3 -1
- package/components/Panel/styles.module.scss +10 -1
- package/components/Panel/styles.module.scss.d.ts +2 -0
- package/components/PanelList/PanelList.d.ts +2 -0
- package/components/PanelList/index.js +3 -2
- package/components/PanelList/index.js.map +1 -1
- package/components/PopOver/PopOver.d.ts +4 -0
- package/components/PopOver/styles.module.scss +6 -3
- package/components/PopOver/styles.module.scss.d.ts +1 -0
- package/components/RadioButton/styles.module.scss +7 -1
- package/components/StatusDot/StatusDot.d.ts +6 -2
- package/components/StatusDot/index.js +3 -3
- package/components/StatusDot/styles.module.scss +12 -6
- package/components/StatusDot/styles.module.scss.d.ts +3 -0
- package/components/Step/Step.d.ts +4 -0
- package/components/Step/index.js +5 -2
- package/components/Step/index.js.map +1 -1
- package/components/Toggle/index.js +2 -1
- package/components/Toggle/index.js.map +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/constants.js.map +1 -1
- package/designsystem-react.css +1 -1
- package/package.json +1 -1
- package/resources/HN.Designsystem.HelpBubble.nb-NO.json.d.ts +6 -0
- package/resources/HN.Designsystem.HelpDrawer.nb-NO.json.d.ts +6 -0
- package/scss/helsenorge.scss +2 -0
- package/scss/supernova/styles/colors.css +1 -1
- package/scss/typography.stories.tsx +1 -1
- package/ListHeader.js +0 -94
- package/ListHeader.js.map +0 -1
- package/ListHeaderText.js +0 -39
- package/ListHeaderText.js.map +0 -1
- package/components/ListHeader/ListHeader.d.ts +0 -43
- package/components/ListHeader/ListHeaderText/ListHeaderText.d.ts +0 -26
- package/components/ListHeader/ListHeaderText/index.d.ts +0 -3
- package/components/ListHeader/ListHeaderText/index.js +0 -6
- package/components/ListHeader/index.d.ts +0 -4
- package/components/ListHeader/index.js +0 -11
- package/components/ListHeader/styles.module.scss.d.ts +0 -21
- /package/components/{ListHeader/ListHeaderText → ElementHeader/ElementHeaderText}/index.js.map +0 -0
package/Panel.js
CHANGED
|
@@ -6,6 +6,7 @@ import { B as Button } from "./Button.js";
|
|
|
6
6
|
import { I as Icon } from "./Icon.js";
|
|
7
7
|
import { P as PanelTitle } from "./PanelTitle.js";
|
|
8
8
|
import { useLanguage } from "./utils/language.js";
|
|
9
|
+
import { H as Highlighter } from "./Highlighter.js";
|
|
9
10
|
import ChevronDown from "./components/Icons/ChevronDown.js";
|
|
10
11
|
import ChevronRight from "./components/Icons/ChevronRight.js";
|
|
11
12
|
import ChevronUp from "./components/Icons/ChevronUp.js";
|
|
@@ -77,7 +78,7 @@ const ExpandButton = ({
|
|
|
77
78
|
}
|
|
78
79
|
);
|
|
79
80
|
};
|
|
80
|
-
const
|
|
81
|
+
const PanelRoot = React__default.forwardRef(function PanelForwardedRef({
|
|
81
82
|
layout = "vertical",
|
|
82
83
|
variant = "fill",
|
|
83
84
|
color = "neutral",
|
|
@@ -85,18 +86,22 @@ const Panel = ({
|
|
|
85
86
|
testId,
|
|
86
87
|
children,
|
|
87
88
|
status = "none",
|
|
89
|
+
buttonBottomAriaLabel,
|
|
88
90
|
buttonBottomOnClick,
|
|
89
91
|
buttonBottomText,
|
|
90
92
|
className,
|
|
91
|
-
resources
|
|
92
|
-
|
|
93
|
+
resources,
|
|
94
|
+
onExpand,
|
|
95
|
+
highlightText
|
|
96
|
+
}, ref) {
|
|
93
97
|
const [preContainer, setPreContainer] = React__default.useState([]);
|
|
94
98
|
const [title, setTitle] = React__default.useState([]);
|
|
95
99
|
const [content, setContent] = React__default.useState([]);
|
|
96
100
|
const [expandableContent, setExpandableContent] = React__default.useState([]);
|
|
97
101
|
const [hasIcon, setHasIcon] = React__default.useState(false);
|
|
98
102
|
const [isExpanded, setIsExpanded] = React__default.useState(false);
|
|
99
|
-
const
|
|
103
|
+
const localRef = React__default.useRef(null);
|
|
104
|
+
const panelRef = ref ?? localRef;
|
|
100
105
|
const expandedContentRef = React__default.useRef(null);
|
|
101
106
|
const defaultScroll = 100;
|
|
102
107
|
const { language } = useLanguage(LanguageLocales.NORWEGIAN);
|
|
@@ -116,7 +121,9 @@ const Panel = ({
|
|
|
116
121
|
if (child.type === PreContainer) {
|
|
117
122
|
newPreContainer.push(child);
|
|
118
123
|
} else if (child.type === PanelTitle) {
|
|
119
|
-
newTitle.push(
|
|
124
|
+
newTitle.push(
|
|
125
|
+
React__default.cloneElement(child, { highlightText: child.props.highlightText || highlightText })
|
|
126
|
+
);
|
|
120
127
|
if (child.props.icon) {
|
|
121
128
|
localHasIcon = true;
|
|
122
129
|
}
|
|
@@ -135,7 +142,7 @@ const Panel = ({
|
|
|
135
142
|
}, [children]);
|
|
136
143
|
React__default.useEffect(() => {
|
|
137
144
|
if (isExpanded) {
|
|
138
|
-
if (panelRef.current && expandedContentRef.current) {
|
|
145
|
+
if ("current" in panelRef && panelRef.current && expandedContentRef.current) {
|
|
139
146
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
140
147
|
const expandedContentRect = expandedContentRef.current.getBoundingClientRect();
|
|
141
148
|
const scrollAmount = Math.min(defaultScroll, panelRect.top - 20);
|
|
@@ -156,7 +163,10 @@ const Panel = ({
|
|
|
156
163
|
const outerClassnames = classNames(className, {
|
|
157
164
|
[styles["panel__border--outline--outer"]]: variant === "outline",
|
|
158
165
|
[styles["panel__border--line"]]: variant === "line",
|
|
159
|
-
[styles["panel__border--fill--neutral"]]: variant === "fill" && colorScheme === "neutral"
|
|
166
|
+
[styles["panel__border--fill--neutral"]]: variant === "fill" && colorScheme === "neutral",
|
|
167
|
+
[styles["panel__border--fill--new"]]: variant === "fill" && status === "new",
|
|
168
|
+
[styles["panel__border--fill--status"]]: variant === "fill" && status !== "none"
|
|
169
|
+
/* none */
|
|
160
170
|
});
|
|
161
171
|
const panelClassnames = classNames(styles["panel"], styles[`panel--${colorScheme}`], styles["panel--status"], {
|
|
162
172
|
[styles["panel--line"]]: variant === "line",
|
|
@@ -175,31 +185,39 @@ const Panel = ({
|
|
|
175
185
|
[styles[`panel__expander__border--not-expanded--line`]]: !isExpanded && status === "none" && variant === "line"
|
|
176
186
|
/* line */
|
|
177
187
|
});
|
|
188
|
+
const handleExpandClick = () => {
|
|
189
|
+
setIsExpanded(!isExpanded);
|
|
190
|
+
onExpand && onExpand();
|
|
191
|
+
};
|
|
178
192
|
return expandableContent.length > 0 ? /* @__PURE__ */ jsx("div", { className: outerClassnames, children: /* @__PURE__ */ jsx("div", { className: classNames({
|
|
179
193
|
[styles["panel__border--outline--inner"]]: variant === "outline"
|
|
180
194
|
/* outline */
|
|
181
195
|
}), children: /* @__PURE__ */ jsx("div", { className: expanderBorderLayout, children: /* @__PURE__ */ jsxs("div", { className: panelClassnames, "data-testid": testId, ref: panelRef, children: [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
196
|
+
/* @__PURE__ */ jsxs(Highlighter, { searchText: highlightText, children: [
|
|
197
|
+
preContainer,
|
|
198
|
+
title
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsx("div", { className: contentContainerLayout, children: /* @__PURE__ */ jsx(Highlighter, { searchText: highlightText, children: content }) }),
|
|
201
|
+
/* @__PURE__ */ jsx(ExpandButton, { onClick: handleExpandClick, isExpanded, resources: mergedResources }),
|
|
202
|
+
isExpanded && /* @__PURE__ */ jsxs("div", { ref: expandedContentRef, "data-testid": testId + "-details", children: [
|
|
187
203
|
/* @__PURE__ */ jsx("div", { className: styles["panel__expander__separator"] }),
|
|
188
|
-
expandableContent
|
|
204
|
+
/* @__PURE__ */ jsx(Highlighter, { searchText: highlightText, children: expandableContent })
|
|
189
205
|
] })
|
|
190
206
|
] }) }) }) }) : /* @__PURE__ */ jsx("div", { className: outerClassnames, children: /* @__PURE__ */ jsx("div", { className: classNames({
|
|
191
207
|
[styles["panel__border--outline--inner"]]: variant === "outline"
|
|
192
208
|
/* outline */
|
|
193
209
|
}), children: /* @__PURE__ */ jsxs("div", { className: panelClassnames, "data-testid": testId, ref: panelRef, children: [
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
/* @__PURE__ */ jsxs(Highlighter, { searchText: highlightText, children: [
|
|
211
|
+
preContainer,
|
|
212
|
+
title
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsx("div", { className: contentContainerLayout, children: /* @__PURE__ */ jsx(Highlighter, { searchText: highlightText, children: content }) }),
|
|
215
|
+
buttonBottomText && buttonBottomOnClick && /* @__PURE__ */ jsx("div", { className: styles["panel__button-bottom"], children: /* @__PURE__ */ jsxs(Button, { variant: "borderless", type: "button", size: "medium", onClick: buttonBottomOnClick, "aria-label": buttonBottomAriaLabel, children: [
|
|
198
216
|
buttonBottomText,
|
|
199
217
|
/* @__PURE__ */ jsx(Icon, { svgIcon: ChevronRight, size: IconSize.XSmall })
|
|
200
218
|
] }) })
|
|
201
219
|
] }) }) });
|
|
202
|
-
};
|
|
220
|
+
});
|
|
203
221
|
const PreContainer = ({ children }) => {
|
|
204
222
|
return /* @__PURE__ */ jsx("div", { className: styles["panel__pre-container"], children });
|
|
205
223
|
};
|
|
@@ -219,6 +237,8 @@ const ExpandedContent = ({ children }) => {
|
|
|
219
237
|
const styling = classNames(styles["panel__expander__content"]);
|
|
220
238
|
return /* @__PURE__ */ jsx("div", { className: styling, children });
|
|
221
239
|
};
|
|
240
|
+
PanelRoot.displayName = "Panel";
|
|
241
|
+
const Panel = PanelRoot;
|
|
222
242
|
Panel.PreContainer = PreContainer;
|
|
223
243
|
Panel.Title = PanelTitle;
|
|
224
244
|
Panel.A = A;
|
package/Panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.js","sources":["../src/components/Panel/resourceHelper.ts","../src/components/Panel/Panel.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\nimport { HNDesignsystemPanel } from '../../resources/Resources';\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 { LanguageLocales } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport PanelTitle, { PanelTitleProps } from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { HNDesignsystemPanel } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\n\nimport styles from './styles.module.scss';\n\nexport enum PanelLayout {\n vertical = 'vertical',\n horizontal = 'horizontal',\n combined = 'combined',\n bAsRightCol = 'bAsRightCol',\n}\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport enum PanelVariant {\n fill = 'fill',\n line = 'line',\n outline = 'outline',\n}\n\nexport enum PanelStacking {\n default = 'default',\n bFirst = 'bFirst',\n}\n\nexport enum PanelStatus {\n none = 'none',\n new = 'new',\n error = 'error',\n draft = 'draft',\n}\n\nexport interface PanelProps {\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 /** 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 /** 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}\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};\n\nconst Panel: React.FC<PanelProps> & {\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} = ({\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n status = PanelStatus.none,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n}: PanelProps) => {\n const [preContainer, setPreContainer] = React.useState<React.ReactNode[]>([]);\n const [title, setTitle] = React.useState<React.ReactNode[]>([]);\n const [content, setContent] = React.useState<React.ReactNode[]>([]);\n const [expandableContent, setExpandableContent] = React.useState<React.ReactNode[]>([]);\n const [hasIcon, setHasIcon] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const expandedContentRef = React.useRef<HTMLDivElement>(null);\n const defaultScroll = 100;\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 React.useEffect(() => {\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 if (child.type === PreContainer) {\n newPreContainer.push(child);\n } else if (child.type === PanelTitle) {\n newTitle.push(child);\n if (child.props.icon) {\n localHasIcon = true;\n }\n } else if (child.type === A || child.type === B || child.type === C) {\n newContent.push(child);\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(child);\n }\n }\n });\n\n setPreContainer(newPreContainer);\n setTitle(newTitle);\n setContent(newContent);\n setExpandableContent(newExpandableContent);\n setHasIcon(localHasIcon);\n }, [children]);\n\n React.useEffect(() => {\n // Scroller oppover når expanded content åpnes\n if (isExpanded) {\n if (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 = variant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(className, {\n [styles['panel__border--outline--outer']]: variant === PanelVariant.outline,\n [styles['panel__border--line']]: variant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: variant === PanelVariant.fill && colorScheme === 'neutral',\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: variant === 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`]]: !isExpanded && status === PanelStatus.none && variant === PanelVariant.line,\n });\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: variant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef}>\n {preContainer}\n {title}\n <div className={contentContainerLayout}>{content}</div>\n <ExpandButton onClick={() => setIsExpanded(!isExpanded)} isExpanded={isExpanded} resources={mergedResources} />\n {isExpanded && (\n <div ref={expandedContentRef}>\n <div className={styles['panel__expander__separator']} />\n {expandableContent}\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']]: variant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef}>\n {preContainer}\n {title}\n <div className={contentContainerLayout}>{content}</div>\n {buttonBottomText && buttonBottomOnClick && (\n <div className={styles['panel__button-bottom']}>\n <Button variant=\"borderless\" type=\"button\" size=\"medium\" onClick={buttonBottomOnClick}>\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\nPanel.PreContainer = PreContainer;\nPanel.Title = PanelTitle;\nPanel.A = A;\nPanel.B = B;\nPanel.C = C;\nPanel.ExpandedContent = ExpandedContent;\n\nexport default Panel;\n"],"names":["PanelLayout","PanelVariant","PanelStacking","PanelStatus","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKa,MAAA,eAAe,CAAC,aAAmD;AAC9E,UAAQ,UAAU;AAAA,IAChB,KAAK,gBAAgB;AACZ,aAAA;AAAA,IACT,KAAK,gBAAgB;AAAA,IACrB;AACS,aAAA;AAAA,EAAA;AAEb;ACKY,IAAA,gCAAAA,iBAAL;AACLA,eAAA,UAAW,IAAA;AACXA,eAAA,YAAa,IAAA;AACbA,eAAA,UAAW,IAAA;AACXA,eAAA,aAAc,IAAA;AAJJA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AASA,IAAA,iCAAAC,kBAAL;AACLA,gBAAA,MAAO,IAAA;AACPA,gBAAA,MAAO,IAAA;AACPA,gBAAA,SAAU,IAAA;AAHAA,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;AAMA,IAAA,kCAAAC,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAKA,IAAA,gCAAAC,iBAAL;AACLA,eAAA,MAAO,IAAA;AACPA,eAAA,KAAM,IAAA;AACNA,eAAA,OAAQ,IAAA;AACRA,eAAA,OAAQ,IAAA;AAJEA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAgCZ,MAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACF,MAIyB;AACjB,QAAA,kBAAkB,WAAW,OAAO,kBAAkB,GAAG,cAAc,OAAO,4BAA4B,CAAC;AAG/G,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,eAAe,OAAO,wBAAwB;AAAA,MAC9C,kBAAkB;AAAA,MAClB,iBAAe;AAAA,MACf;AAAA,MAEA,UAAA;AAAA,QAAA,oB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AI,WAAW,SAAU,SAAS,CAAA;AAC5C;AAEO,MAAM,IAA4B,CAAC,EAAE,eAAe;AACzD,QAAM,UAAU,WAAW,OAAO,sBAAsB,GAAG,OAAO,yBAAyB,CAAC;AAC5F,SAAQ,oBAAA,OAAA,EAAI,WAAW,SAAU,SAAS,CAAA;AAC5C;AAEO,MAAM,kBAA0C,CAAC,EAAE,eAAe;AACvE,QAAM,UAAU,WAAW,OAAO,0BAA0B,CAAC;AAC7D,SAAQ,oBAAA,OAAA,EAAI,WAAW,SAAU,SAAS,CAAA;AAC5C;AAEA,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;"}
|
|
1
|
+
{"version":3,"file":"Panel.js","sources":["../src/components/Panel/resourceHelper.ts","../src/components/Panel/Panel.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Panel.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Panel.nb-NO.json';\nimport { HNDesignsystemPanel } from '../../resources/Resources';\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 { LanguageLocales } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport PanelTitle, { PanelTitleProps } from './PanelTitle';\nimport { getResources } from './resourceHelper';\nimport { HNDesignsystemPanel } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronRight from '../Icons/ChevronRight';\nimport ChevronUp from '../Icons/ChevronUp';\n\nimport styles from './styles.module.scss';\n\nexport enum PanelLayout {\n vertical = 'vertical',\n horizontal = 'horizontal',\n combined = 'combined',\n bAsRightCol = 'bAsRightCol',\n}\n\nexport type PanelColors = Extract<PaletteNames, 'white' | 'neutral'>;\n\nexport enum PanelVariant {\n fill = 'fill',\n line = 'line',\n outline = 'outline',\n}\n\nexport enum PanelStacking {\n default = 'default',\n bFirst = 'bFirst',\n}\n\nexport enum PanelStatus {\n none = 'none',\n new = 'new',\n error = 'error',\n draft = 'draft',\n}\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 /** 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?: () => 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}\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.forwardRef(function PanelForwardedRef(\n {\n layout = PanelLayout.vertical,\n variant = PanelVariant.fill,\n color = 'neutral',\n stacking = PanelStacking.default,\n testId,\n children,\n status = PanelStatus.none,\n buttonBottomAriaLabel,\n buttonBottomOnClick,\n buttonBottomText,\n className,\n resources,\n onExpand,\n highlightText,\n }: PanelProps,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const [preContainer, setPreContainer] = React.useState<React.ReactNode[]>([]);\n const [title, setTitle] = React.useState<React.ReactNode[]>([]);\n const [content, setContent] = React.useState<React.ReactNode[]>([]);\n const [expandableContent, setExpandableContent] = React.useState<React.ReactNode[]>([]);\n const [hasIcon, setHasIcon] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\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 const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemPanel = {\n ...defaultResources,\n ...resources,\n };\n\n React.useEffect(() => {\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 if (child.type === PreContainer) {\n newPreContainer.push(child);\n } else if (child.type === PanelTitle) {\n newTitle.push(\n React.cloneElement(child as React.ReactElement<PanelTitleProps>, { highlightText: child.props.highlightText || highlightText })\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(child);\n } else if (child.type === ExpandedContent) {\n newExpandableContent.push(child);\n }\n }\n });\n\n setPreContainer(newPreContainer);\n setTitle(newTitle);\n setContent(newContent);\n setExpandableContent(newExpandableContent);\n setHasIcon(localHasIcon);\n }, [children]);\n\n React.useEffect(() => {\n // Scroller oppover når expanded content åpnes\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 = variant === PanelVariant.fill ? color : 'white';\n\n const outerClassnames = classNames(className, {\n [styles['panel__border--outline--outer']]: variant === PanelVariant.outline,\n [styles['panel__border--line']]: variant === PanelVariant.line,\n [styles['panel__border--fill--neutral']]: variant === PanelVariant.fill && colorScheme === 'neutral',\n [styles['panel__border--fill--new']]: variant === PanelVariant.fill && status === PanelStatus.new,\n [styles['panel__border--fill--status']]: variant === PanelVariant.fill && status !== PanelStatus.none,\n });\n const panelClassnames = classNames(styles['panel'], styles[`panel--${colorScheme}`], styles['panel--status'], {\n [styles['panel--line']]: variant === 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`]]: !isExpanded && status === PanelStatus.none && variant === PanelVariant.line,\n });\n\n const handleExpandClick = (): void => {\n setIsExpanded(!isExpanded);\n onExpand && onExpand();\n };\n\n return expandableContent.length > 0 ? (\n <div className={outerClassnames}>\n <div className={classNames({ [styles['panel__border--outline--inner']]: variant === PanelVariant.outline })}>\n <div className={expanderBorderLayout}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef}>\n <Highlighter searchText={highlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={highlightText}>{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={highlightText}>{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']]: variant === PanelVariant.outline })}>\n <div className={panelClassnames} data-testid={testId} ref={panelRef}>\n <Highlighter searchText={highlightText}>\n {preContainer}\n {title}\n </Highlighter>\n <div className={contentContainerLayout}>\n <Highlighter searchText={highlightText}>{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"],"names":["PanelLayout","PanelVariant","PanelStacking","PanelStatus","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKa,MAAA,eAAe,CAAC,aAAmD;AAC9E,UAAQ,UAAU;AAAA,IAChB,KAAK,gBAAgB;AACZ,aAAA;AAAA,IACT,KAAK,gBAAgB;AAAA,IACrB;AACS,aAAA;AAAA,EAAA;AAEb;ACMY,IAAA,gCAAAA,iBAAL;AACLA,eAAA,UAAW,IAAA;AACXA,eAAA,YAAa,IAAA;AACbA,eAAA,UAAW,IAAA;AACXA,eAAA,aAAc,IAAA;AAJJA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AASA,IAAA,iCAAAC,kBAAL;AACLA,gBAAA,MAAO,IAAA;AACPA,gBAAA,MAAO,IAAA;AACPA,gBAAA,SAAU,IAAA;AAHAA,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;AAMA,IAAA,kCAAAC,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAKA,IAAA,gCAAAC,iBAAL;A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yBAAyB,CAAC;AAC5F,SAAQ,oBAAA,OAAA,EAAI,WAAW,SAAU,SAAS,CAAA;AAC5C;AAEO,MAAM,kBAA0C,CAAC,EAAE,eAAe;AACvE,QAAM,UAAU,WAAW,OAAO,0BAA0B,CAAC;AAC7D,SAAQ,oBAAA,OAAA,EAAI,WAAW,SAAU,SAAS,CAAA;AAC5C;AAUA,UAAU,cAAc;AACxB,MAAM,QAAQ;AACd,MAAM,eAAe;AACrB,MAAM,QAAQ;AACd,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,kBAAkB;"}
|
package/PanelTitle.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
+
import { H as Highlighter } from "./Highlighter.js";
|
|
3
4
|
import { T as Title } from "./Title.js";
|
|
4
5
|
import styles from "./components/Panel/PanelTitle/styles.module.scss";
|
|
5
6
|
const PanelTitle = (props) => {
|
|
6
|
-
const { testId, icon, badge, title, titleMarkup = "h3" } = props;
|
|
7
|
+
const { testId, icon, badge, title, titleMarkup = "h3", highlightText } = props;
|
|
7
8
|
return /* @__PURE__ */ jsxs("div", { className: classNames(styles["paneltitle"], { [styles["paneltitle--has-icon"]]: icon }), "data-testid": testId, children: [
|
|
8
9
|
icon && /* @__PURE__ */ jsx("div", { className: styles["paneltitle__icon"], children: icon }),
|
|
9
10
|
title && /* @__PURE__ */ jsxs("div", { className: styles["paneltitle__title"], children: [
|
|
10
|
-
/* @__PURE__ */ jsx(Title, { appearance: "title3", htmlMarkup: titleMarkup, children: title }),
|
|
11
|
+
/* @__PURE__ */ jsx(Title, { appearance: "title3", htmlMarkup: titleMarkup, children: /* @__PURE__ */ jsx(Highlighter, { searchText: highlightText, children: title }) }),
|
|
11
12
|
badge && /* @__PURE__ */ jsx("div", { className: styles["paneltitle__badge"], children: badge })
|
|
12
13
|
] })
|
|
13
14
|
] });
|
package/PanelTitle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelTitle.js","sources":["../src/components/Panel/PanelTitle/PanelTitle.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport Title from '../../Title';\n\nimport styles from './styles.module.scss';\n\nexport interface PanelTitleProps {\n /** Badge displayed in title */\n badge?: React.ReactNode;\n /** Icon displayed in title. Only IconSize Small is supported */\n icon?: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Title text */\n title: string;\n /** Title HTML markup */\n titleMarkup?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n}\n\nconst PanelTitle: React.FC<PanelTitleProps> = (props: PanelTitleProps) => {\n const { testId, icon, badge, title, titleMarkup = 'h3' } = props;\n return (\n <div className={classNames(styles['paneltitle'], { [styles['paneltitle--has-icon']]: icon })} data-testid={testId}>\n {icon && <div className={styles['paneltitle__icon']}>{icon}</div>}\n {title && (\n <div className={styles['paneltitle__title']}>\n <Title appearance=\"title3\" htmlMarkup={titleMarkup}>\n {title}
|
|
1
|
+
{"version":3,"file":"PanelTitle.js","sources":["../src/components/Panel/PanelTitle/PanelTitle.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport Highlighter from '../../Highlighter';\nimport Title from '../../Title';\n\nimport styles from './styles.module.scss';\n\nexport interface PanelTitleProps {\n /** Badge displayed in title */\n badge?: React.ReactNode;\n /** Icon displayed in title. Only IconSize Small is supported */\n icon?: React.ReactNode;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Title text */\n title: string | React.ReactNode;\n /** Title HTML markup */\n titleMarkup?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n}\n\nconst PanelTitle: React.FC<PanelTitleProps> = (props: PanelTitleProps) => {\n const { testId, icon, badge, title, titleMarkup = 'h3', highlightText } = props;\n return (\n <div className={classNames(styles['paneltitle'], { [styles['paneltitle--has-icon']]: icon })} data-testid={testId}>\n {icon && <div className={styles['paneltitle__icon']}>{icon}</div>}\n {title && (\n <div className={styles['paneltitle__title']}>\n <Title appearance=\"title3\" htmlMarkup={titleMarkup}>\n <Highlighter searchText={highlightText}>{title}</Highlighter>\n </Title>\n {badge && <div className={styles['paneltitle__badge']}>{badge}</div>}\n </div>\n )}\n </div>\n );\n};\n\nexport default PanelTitle;\n"],"names":[],"mappings":";;;;;AAwBM,MAAA,aAAwC,CAAC,UAA2B;AAClE,QAAA,EAAE,QAAQ,MAAM,OAAO,OAAO,cAAc,MAAM,kBAAkB;AAC1E,8BACG,OAAI,EAAA,WAAW,WAAW,OAAO,YAAY,GAAG,EAAE,CAAC,OAAO,sBAAsB,CAAC,GAAG,MAAM,GAAG,eAAa,QACxG,UAAA;AAAA,IAAA,4BAAS,OAAI,EAAA,WAAW,OAAO,kBAAkB,GAAI,UAAK,MAAA;AAAA,IAC1D,SACE,qBAAA,OAAA,EAAI,WAAW,OAAO,mBAAmB,GACxC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,YAAW,UAAS,YAAY,aACrC,8BAAC,aAAY,EAAA,YAAY,eAAgB,UAAA,MAAM,CAAA,GACjD;AAAA,MACC,SAAU,oBAAA,OAAA,EAAI,WAAW,OAAO,mBAAmB,GAAI,UAAM,MAAA,CAAA;AAAA,IAAA,EAChE,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
package/PopOver.js
CHANGED
|
@@ -3,6 +3,7 @@ import React__default, { useRef } from "react";
|
|
|
3
3
|
import { u as useFloating, a as useClick, b as useDismiss, c as useInteractions, d as useMergeRefs, F as FloatingFocusManager, e as FloatingArrow, f as autoUpdate, o as offset, g as flip, s as shift, h as hide, i as arrow } from "./floating-ui.react.js";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import { ZIndex, AnalyticsId } from "./constants.js";
|
|
6
|
+
import { getAriaLabelAttributes } from "./utils/accessibility.js";
|
|
6
7
|
import styles from "./components/PopOver/styles.module.scss";
|
|
7
8
|
var PopOverVariant = /* @__PURE__ */ ((PopOverVariant2) => {
|
|
8
9
|
PopOverVariant2["positionautomatic"] = "positionautomatic";
|
|
@@ -13,6 +14,8 @@ var PopOverVariant = /* @__PURE__ */ ((PopOverVariant2) => {
|
|
|
13
14
|
const PopOver = React__default.forwardRef((props, ref) => {
|
|
14
15
|
var _a;
|
|
15
16
|
const {
|
|
17
|
+
ariaLabel,
|
|
18
|
+
ariaLabelledById,
|
|
16
19
|
id,
|
|
17
20
|
children,
|
|
18
21
|
controllerRef,
|
|
@@ -24,6 +27,7 @@ const PopOver = React__default.forwardRef((props, ref) => {
|
|
|
24
27
|
zIndex = ZIndex.PopOver,
|
|
25
28
|
placement
|
|
26
29
|
} = props;
|
|
30
|
+
const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });
|
|
27
31
|
const placementProp = placement ?? (variant === "positionabove" ? "top" : "bottom");
|
|
28
32
|
const arrowRef = useRef(null);
|
|
29
33
|
const { refs, floatingStyles, context, middlewareData } = useFloating({
|
|
@@ -50,12 +54,14 @@ const PopOver = React__default.forwardRef((props, ref) => {
|
|
|
50
54
|
role,
|
|
51
55
|
"data-testid": testId,
|
|
52
56
|
"data-analyticsid": AnalyticsId.PopOver,
|
|
57
|
+
...ariaLabelAttributes,
|
|
53
58
|
children: [
|
|
54
59
|
children,
|
|
55
60
|
/* @__PURE__ */ jsx(
|
|
56
61
|
FloatingArrow,
|
|
57
62
|
{
|
|
58
63
|
ref: arrowRef,
|
|
64
|
+
className: styles["popover__arrow"],
|
|
59
65
|
context,
|
|
60
66
|
fill: "var(--core-color-white)",
|
|
61
67
|
stroke: "var(--color-base-border-onlight)",
|
package/PopOver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopOver.js","sources":["../src/components/PopOver/PopOver.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport {\n autoUpdate,\n flip,\n offset,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n FloatingArrow,\n arrow,\n hide,\n FloatingFocusManager,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport enum PopOverVariant {\n positionautomatic = 'positionautomatic',\n positionbelow = 'positionbelow',\n positionabove = 'positionabove',\n}\n\nexport type PopOverRole = 'tooltip' | 'dialog';\n\nexport type PopOverPlacement = 'top' | 'bottom';\n\nexport interface PopOverProps {\n /** Id of the PopOver */\n id?: string;\n /** Content shown inside PopOver. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the PopOver is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Show the popover. Only applies when role=tooltip. Default: false. */\n show?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** @deprecated Adds custom classes to the arrow element. */\n arrowClassName?: string;\n /** @deprecated use placement instead. Determines the placement of the popover. Default: automatic positioning. */\n variant?: keyof typeof PopOverVariant;\n /** Sets the placement of the popover relative to the trigger if there is space, otherwise automatic. */\n placement?: PopOverPlacement;\n /** Sets role of the PopOver element */\n role?: PopOverRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Overrides the default z-index of PopOver */\n zIndex?: number;\n}\n\nconst PopOver = React.forwardRef<HTMLDivElement | SVGSVGElement | HTMLElement, PopOverProps>((props, ref) => {\n const {\n id,\n children,\n controllerRef,\n show = false,\n className = '',\n variant = PopOverVariant.positionautomatic,\n role = 'dialog',\n testId,\n zIndex = ZIndex.PopOver,\n placement,\n } = props;\n\n const placementProp = placement ?? (variant === PopOverVariant.positionabove ? 'top' : 'bottom');\n\n const arrowRef = useRef(null);\n const { refs, floatingStyles, context, middlewareData } = useFloating({\n middleware: [offset(10), flip(), shift({ padding: 8 }), hide(), arrow({ element: arrowRef })],\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {\n reference: controllerRef.current,\n },\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n\n const { getFloatingProps } = useInteractions([click, dismiss]);\n\n const isVisible = show && !middlewareData.hide?.referenceHidden;\n\n const mergedRef = useMergeRefs<HTMLElement | SVGSVGElement>([refs.setFloating, ref]);\n\n return (\n <FloatingFocusManager context={context} modal={false}>\n <div\n id={id}\n ref={mergedRef}\n style={{ ...floatingStyles, visibility: isVisible ? 'visible' : 'hidden', zIndex: zIndex }}\n className={classNames(styles.popover, className)}\n {...getFloatingProps()}\n role={role}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PopOver}\n >\n {children}\n <FloatingArrow\n ref={arrowRef}\n context={context}\n fill={'var(--core-color-white)'}\n stroke={'var(--color-base-border-onlight)'}\n strokeWidth={1}\n />\n </div>\n </FloatingFocusManager>\n );\n});\n\nPopOver.displayName = 'PopOver';\n\nexport default PopOver;\n"],"names":["PopOverVariant","React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PopOver.js","sources":["../src/components/PopOver/PopOver.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport {\n autoUpdate,\n flip,\n offset,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n FloatingArrow,\n arrow,\n hide,\n FloatingFocusManager,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\n\nimport styles from './styles.module.scss';\n\nexport enum PopOverVariant {\n positionautomatic = 'positionautomatic',\n positionbelow = 'positionbelow',\n positionabove = 'positionabove',\n}\n\nexport type PopOverRole = 'tooltip' | 'dialog';\n\nexport type PopOverPlacement = 'top' | 'bottom';\n\nexport interface PopOverProps {\n /** Sets aria-label of the bubble. If role is set to dialog ariaLabel or ariaLabelledById MUST be set! */\n ariaLabel?: string;\n /** Sets aria-labelledby of the bubble. If role is set to dialog ariaLabel or ariaLabelledById MUST be set! */\n ariaLabelledById?: string;\n /** Id of the PopOver */\n id?: string;\n /** Content shown inside PopOver. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the PopOver is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Show the popover. Only applies when role=tooltip. Default: false. */\n show?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** @deprecated Adds custom classes to the arrow element. */\n arrowClassName?: string;\n /** @deprecated use placement instead. Determines the placement of the popover. Default: automatic positioning. */\n variant?: keyof typeof PopOverVariant;\n /** Sets the placement of the popover relative to the trigger if there is space, otherwise automatic. */\n placement?: PopOverPlacement;\n /** Sets role of the PopOver element */\n role?: PopOverRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Overrides the default z-index of PopOver */\n zIndex?: number;\n}\n\nconst PopOver = React.forwardRef<HTMLDivElement | SVGSVGElement | HTMLElement, PopOverProps>((props, ref) => {\n const {\n ariaLabel,\n ariaLabelledById,\n id,\n children,\n controllerRef,\n show = false,\n className = '',\n variant = PopOverVariant.positionautomatic,\n role = 'dialog',\n testId,\n zIndex = ZIndex.PopOver,\n placement,\n } = props;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n\n const placementProp = placement ?? (variant === PopOverVariant.positionabove ? 'top' : 'bottom');\n\n const arrowRef = useRef(null);\n const { refs, floatingStyles, context, middlewareData } = useFloating({\n middleware: [offset(10), flip(), shift({ padding: 8 }), hide(), arrow({ element: arrowRef })],\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {\n reference: controllerRef.current,\n },\n });\n\n const click = useClick(context);\n const dismiss = useDismiss(context);\n\n const { getFloatingProps } = useInteractions([click, dismiss]);\n\n const isVisible = show && !middlewareData.hide?.referenceHidden;\n\n const mergedRef = useMergeRefs<HTMLElement | SVGSVGElement>([refs.setFloating, ref]);\n\n return (\n <FloatingFocusManager context={context} modal={false}>\n <div\n id={id}\n ref={mergedRef}\n style={{ ...floatingStyles, visibility: isVisible ? 'visible' : 'hidden', zIndex: zIndex }}\n className={classNames(styles.popover, className)}\n {...getFloatingProps()}\n role={role}\n data-testid={testId}\n data-analyticsid={AnalyticsId.PopOver}\n {...ariaLabelAttributes}\n >\n {children}\n <FloatingArrow\n ref={arrowRef}\n className={styles['popover__arrow']}\n context={context}\n fill={'var(--core-color-white)'}\n stroke={'var(--color-base-border-onlight)'}\n strokeWidth={1}\n />\n </div>\n </FloatingFocusManager>\n );\n});\n\nPopOver.displayName = 'PopOver';\n\nexport default PopOver;\n"],"names":["PopOverVariant","React"],"mappings":";;;;;;;AAwBY,IAAA,mCAAAA,oBAAL;AACLA,kBAAA,mBAAoB,IAAA;AACpBA,kBAAA,eAAgB,IAAA;AAChBA,kBAAA,eAAgB,IAAA;AAHNA,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAuCZ,MAAM,UAAUC,eAAM,WAAuE,CAAC,OAAO,QAAQ;;AACrG,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,OAAO;AAAA,IACP;AAAA,IACA,SAAS,OAAO;AAAA,IAChB;AAAA,EAAA,IACE;AAEJ,QAAM,sBAAsB,uBAAuB,EAAE,OAAO,WAAW,IAAI,kBAAkB;AAE7F,QAAM,gBAAgB,cAAc,YAAY,kBAA+B,QAAQ;AAEjF,QAAA,WAAW,OAAO,IAAI;AAC5B,QAAM,EAAE,MAAM,gBAAgB,SAAS,eAAA,IAAmB,YAAY;AAAA,IACpE,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,MAAM,EAAE,SAAS,EAAG,CAAA,GAAG,QAAQ,MAAM,EAAE,SAAS,SAAA,CAAU,CAAC;AAAA,IAC5F,WAAW;AAAA,IACX,sBAAsB;AAAA,IACtB,UAAU;AAAA,MACR,WAAW,cAAc;AAAA,IAAA;AAAA,EAC3B,CACD;AAEK,QAAA,QAAQ,SAAS,OAAO;AACxB,QAAA,UAAU,WAAW,OAAO;AAElC,QAAM,EAAE,iBAAiB,IAAI,gBAAgB,CAAC,OAAO,OAAO,CAAC;AAE7D,QAAM,YAAY,QAAQ,GAAC,oBAAe,SAAf,mBAAqB;AAEhD,QAAM,YAAY,aAA0C,CAAC,KAAK,aAAa,GAAG,CAAC;AAEnF,SACG,oBAAA,sBAAA,EAAqB,SAAkB,OAAO,OAC7C,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,KAAK;AAAA,MACL,OAAO,EAAE,GAAG,gBAAgB,YAAY,YAAY,YAAY,UAAU,OAAe;AAAA,MACzF,WAAW,WAAW,OAAO,SAAS,SAAS;AAAA,MAC9C,GAAG,iBAAiB;AAAA,MACrB;AAAA,MACA,eAAa;AAAA,MACb,oBAAkB,YAAY;AAAA,MAC7B,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA;AAAA,QACD;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAK;AAAA,YACL,WAAW,OAAO,gBAAgB;AAAA,YAClC;AAAA,YACA,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,aAAa;AAAA,UAAA;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,CAAC;AAED,QAAQ,cAAc;"}
|
package/StatusDot.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import React__default from "react";
|
|
2
3
|
import classNames from "classnames";
|
|
3
4
|
import "./theme/grid.js";
|
|
4
5
|
import "./hooks/useBreakpoint.js";
|
|
5
|
-
import "react";
|
|
6
6
|
import { AnalyticsId, FormOnColor, IconSize } from "./constants.js";
|
|
7
7
|
import { getColor } from "./theme/currys/color.js";
|
|
8
8
|
import { L as LazyIcon } from "./LazyIcon.js";
|
|
@@ -29,6 +29,9 @@ var StatusDotVariant = /* @__PURE__ */ ((StatusDotVariant2) => {
|
|
|
29
29
|
StatusDotVariant2["hidden"] = "hidden";
|
|
30
30
|
StatusDotVariant2["login"] = "login";
|
|
31
31
|
StatusDotVariant2["attachment"] = "attachment";
|
|
32
|
+
StatusDotVariant2["active"] = "active";
|
|
33
|
+
StatusDotVariant2["pending"] = "pending";
|
|
34
|
+
StatusDotVariant2["inactive"] = "inactive";
|
|
32
35
|
return StatusDotVariant2;
|
|
33
36
|
})(StatusDotVariant || {});
|
|
34
37
|
const StatusDotIcon = ({ onColor, variant = "info" }) => {
|
|
@@ -75,23 +78,29 @@ const StatusDotIcon = ({ onColor, variant = "info" }) => {
|
|
|
75
78
|
return /* @__PURE__ */ jsx(LazyIcon, { ...iconProps, iconName: "Login" });
|
|
76
79
|
case "attachment":
|
|
77
80
|
return /* @__PURE__ */ jsx(LazyIcon, { ...iconProps, iconName: "Attachment" });
|
|
81
|
+
case "active":
|
|
82
|
+
return /* @__PURE__ */ jsx(LazyIcon, { ...iconProps, iconName: "DotActive" });
|
|
83
|
+
case "pending":
|
|
84
|
+
return /* @__PURE__ */ jsx(LazyIcon, { ...iconProps, iconName: "DotPending" });
|
|
85
|
+
case "inactive":
|
|
86
|
+
return /* @__PURE__ */ jsx(LazyIcon, { ...iconProps, iconName: "DotInactive" });
|
|
78
87
|
}
|
|
79
88
|
return null;
|
|
80
89
|
};
|
|
81
|
-
const StatusDot = (props)
|
|
90
|
+
const StatusDot = React__default.forwardRef(function StatusDotForwardedRef(props, ref) {
|
|
82
91
|
const { id, onColor = StatusDotOnColor.onwhite, variant = "info", text, className, testId } = props;
|
|
83
92
|
const statusDotClasses = classNames(styles["statusdot"], className);
|
|
84
93
|
const labelClasses = classNames(styles["statusdot__label"], {
|
|
85
94
|
[styles["statusdot__label--on-dark"]]: onColor === StatusDotOnColor.ondark
|
|
86
95
|
});
|
|
87
|
-
return /* @__PURE__ */ jsxs("span", { id, className: statusDotClasses, "data-testid": testId, "data-analyticsid": AnalyticsId.StatusDot, children: [
|
|
96
|
+
return /* @__PURE__ */ jsxs("span", { id, ref, className: statusDotClasses, "data-testid": testId, "data-analyticsid": AnalyticsId.StatusDot, children: [
|
|
88
97
|
/* @__PURE__ */ jsx("span", { className: styles["statusdot__dot"], "data-testid": testId + "-dot", children: /* @__PURE__ */ jsx(StatusDotIcon, { onColor, variant }) }),
|
|
89
98
|
/* @__PURE__ */ jsx("span", { className: labelClasses, children: text })
|
|
90
99
|
] });
|
|
91
|
-
};
|
|
100
|
+
});
|
|
92
101
|
export {
|
|
93
102
|
StatusDot as S,
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
StatusDotVariant as a,
|
|
104
|
+
StatusDotOnColor as b
|
|
96
105
|
};
|
|
97
106
|
//# sourceMappingURL=StatusDot.js.map
|
package/StatusDot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusDot.js","sources":["../src/components/StatusDot/StatusDot.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { IconSize } from '../..';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { getColor } from '../../theme/currys';\nimport { LazyIcon } from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport enum StatusDotOnColor {\n onwhite = FormOnColor.onwhite,\n ondark = FormOnColor.ondark,\n}\n\nexport enum StatusDotVariant {\n success = 'success',\n inprocess = 'inprocess',\n exception = 'exception',\n unknown = 'unknown',\n inspected = 'inspected',\n cancelled = 'cancelled',\n alert = 'alert',\n transparent = 'transparent',\n info = 'info',\n group = 'group',\n recurring = 'recurring',\n noaccess = 'noaccess',\n draft = 'draft',\n hidden = 'hidden',\n login = 'login',\n attachment = 'attachment',\n}\n\nexport interface StatusDotIconProps {\n /** Defines the color of the icon */\n onColor?: keyof typeof StatusDotOnColor;\n /** The variant defines style formatting and what icon to use */\n variant?: keyof typeof StatusDotVariant;\n}\n\nconst StatusDotIcon: React.FC<StatusDotIconProps> = ({ onColor, variant = 'info' }) => {\n const color = onColor === StatusDotOnColor.ondark ? getColor('white') : getColor('black');\n const iconProps = {\n color,\n size: IconSize.XXSmall,\n onColor,\n className: classNames({\n [styles[`statusdot__dot--${variant}`]]: typeof variant !== 'undefined',\n [styles['statusdot__dot--on-dark']]: onColor === StatusDotOnColor.ondark,\n }),\n };\n\n switch (variant) {\n case StatusDotVariant.success:\n return <LazyIcon {...iconProps} iconName={'DotSuccess'} />;\n case StatusDotVariant.inprocess:\n return <LazyIcon {...iconProps} iconName={'DotHalfDisc'} />;\n case StatusDotVariant.exception:\n return <LazyIcon {...iconProps} iconName={'DotWarningTriangle'} />;\n case StatusDotVariant.unknown:\n return <LazyIcon {...iconProps} iconName={'DotQuestionMark'} />;\n case StatusDotVariant.inspected:\n return <LazyIcon {...iconProps} iconName={'DotLookingGlass'} />;\n case StatusDotVariant.cancelled:\n return <LazyIcon {...iconProps} iconName={'DotCancelled'} />;\n case StatusDotVariant.alert:\n return <LazyIcon {...iconProps} iconName={'DotAlert'} />;\n case StatusDotVariant.transparent:\n return <LazyIcon {...iconProps} iconName={'DotTransparent'} />;\n case StatusDotVariant.info:\n return <LazyIcon {...iconProps} iconName={'DotInfo'} />;\n case StatusDotVariant.group:\n return <LazyIcon {...iconProps} iconName={'Group'} />;\n case StatusDotVariant.recurring:\n return <LazyIcon {...iconProps} iconName={'Change'} />;\n case StatusDotVariant.noaccess:\n return <LazyIcon {...iconProps} iconName={'NoAccess'} />;\n case StatusDotVariant.draft:\n return <LazyIcon {...iconProps} iconName={'Pencil'} />;\n case StatusDotVariant.hidden:\n return <LazyIcon {...iconProps} iconName={'NoEye'} />;\n case StatusDotVariant.login:\n return <LazyIcon {...iconProps} iconName={'Login'} />;\n case StatusDotVariant.attachment:\n return <LazyIcon {...iconProps} iconName={'Attachment'} />;\n }\n\n return null;\n};\n\nexport interface StatusDotProps {\n /** id that is placed on the wrapper */\n id?: string;\n /** Defines the color mode, onwhite, ondark etc. */\n onColor?: keyof typeof StatusDotOnColor;\n /** Visual variants for the statusdot */\n variant?: keyof typeof StatusDotVariant;\n /** Text placed to the right of the statusdot */\n text: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\
|
|
1
|
+
{"version":3,"file":"StatusDot.js","sources":["../src/components/StatusDot/StatusDot.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { IconSize } from '../..';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { getColor } from '../../theme/currys';\nimport { LazyIcon } from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport enum StatusDotOnColor {\n onwhite = FormOnColor.onwhite,\n ondark = FormOnColor.ondark,\n}\n\nexport enum StatusDotVariant {\n success = 'success',\n inprocess = 'inprocess',\n exception = 'exception',\n unknown = 'unknown',\n inspected = 'inspected',\n cancelled = 'cancelled',\n alert = 'alert',\n transparent = 'transparent',\n info = 'info',\n group = 'group',\n recurring = 'recurring',\n noaccess = 'noaccess',\n draft = 'draft',\n hidden = 'hidden',\n login = 'login',\n attachment = 'attachment',\n active = 'active',\n pending = 'pending',\n inactive = 'inactive',\n}\n\nexport interface StatusDotIconProps {\n /** Defines the color of the icon */\n onColor?: keyof typeof StatusDotOnColor;\n /** The variant defines style formatting and what icon to use */\n variant?: keyof typeof StatusDotVariant;\n}\n\nconst StatusDotIcon: React.FC<StatusDotIconProps> = ({ onColor, variant = 'info' }) => {\n const color = onColor === StatusDotOnColor.ondark ? getColor('white') : getColor('black');\n const iconProps = {\n color,\n size: IconSize.XXSmall,\n onColor,\n className: classNames({\n [styles[`statusdot__dot--${variant}`]]: typeof variant !== 'undefined',\n [styles['statusdot__dot--on-dark']]: onColor === StatusDotOnColor.ondark,\n }),\n };\n\n switch (variant) {\n case StatusDotVariant.success:\n return <LazyIcon {...iconProps} iconName={'DotSuccess'} />;\n case StatusDotVariant.inprocess:\n return <LazyIcon {...iconProps} iconName={'DotHalfDisc'} />;\n case StatusDotVariant.exception:\n return <LazyIcon {...iconProps} iconName={'DotWarningTriangle'} />;\n case StatusDotVariant.unknown:\n return <LazyIcon {...iconProps} iconName={'DotQuestionMark'} />;\n case StatusDotVariant.inspected:\n return <LazyIcon {...iconProps} iconName={'DotLookingGlass'} />;\n case StatusDotVariant.cancelled:\n return <LazyIcon {...iconProps} iconName={'DotCancelled'} />;\n case StatusDotVariant.alert:\n return <LazyIcon {...iconProps} iconName={'DotAlert'} />;\n case StatusDotVariant.transparent:\n return <LazyIcon {...iconProps} iconName={'DotTransparent'} />;\n case StatusDotVariant.info:\n return <LazyIcon {...iconProps} iconName={'DotInfo'} />;\n case StatusDotVariant.group:\n return <LazyIcon {...iconProps} iconName={'Group'} />;\n case StatusDotVariant.recurring:\n return <LazyIcon {...iconProps} iconName={'Change'} />;\n case StatusDotVariant.noaccess:\n return <LazyIcon {...iconProps} iconName={'NoAccess'} />;\n case StatusDotVariant.draft:\n return <LazyIcon {...iconProps} iconName={'Pencil'} />;\n case StatusDotVariant.hidden:\n return <LazyIcon {...iconProps} iconName={'NoEye'} />;\n case StatusDotVariant.login:\n return <LazyIcon {...iconProps} iconName={'Login'} />;\n case StatusDotVariant.attachment:\n return <LazyIcon {...iconProps} iconName={'Attachment'} />;\n case StatusDotVariant.active:\n return <LazyIcon {...iconProps} iconName={'DotActive'} />;\n case StatusDotVariant.pending:\n return <LazyIcon {...iconProps} iconName={'DotPending'} />;\n case StatusDotVariant.inactive:\n return <LazyIcon {...iconProps} iconName={'DotInactive'} />;\n }\n\n return null;\n};\n\nexport interface StatusDotProps {\n /** id that is placed on the wrapper */\n id?: string;\n /** Defines the color mode, onwhite, ondark etc. */\n onColor?: keyof typeof StatusDotOnColor;\n /** Visual variants for the statusdot */\n variant?: keyof typeof StatusDotVariant;\n /** Text placed to the right of the statusdot */\n text: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport type StatusDotType = React.ForwardRefExoticComponent<StatusDotProps & React.RefAttributes<HTMLElement>>;\nconst StatusDot: StatusDotType = React.forwardRef(function StatusDotForwardedRef(\n props: StatusDotProps,\n ref: React.ForwardedRef<HTMLElement>\n) {\n const { id, onColor = StatusDotOnColor.onwhite, variant = StatusDotVariant.info, text, className, testId } = props;\n\n const statusDotClasses = classNames(styles['statusdot'], className);\n const labelClasses = classNames(styles['statusdot__label'], {\n [styles['statusdot__label--on-dark']]: onColor === StatusDotOnColor.ondark,\n });\n\n return (\n <span id={id} ref={ref} className={statusDotClasses} data-testid={testId} data-analyticsid={AnalyticsId.StatusDot}>\n <span className={styles['statusdot__dot']} data-testid={testId + '-dot'}>\n <StatusDotIcon onColor={onColor} variant={variant} />\n </span>\n <span className={labelClasses}>{text}</span>\n </span>\n );\n});\n\nexport default StatusDot;\n"],"names":["StatusDotOnColor","StatusDotVariant","React"],"mappings":";;;;;;;;;AAWY,IAAA,oBAAL,CAAKA,sBAAL;AACLA,oBAAAA,kBAAA,SAAU,IAAA,YAAY,OAAtB,IAAA;AACAA,oBAAAA,kBAAA,QAAS,IAAA,YAAY,MAArB,IAAA;AAFUA,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAKA,IAAA,qCAAAC,sBAAL;AACLA,oBAAA,SAAU,IAAA;AACVA,oBAAA,WAAY,IAAA;AACZA,oBAAA,WAAY,IAAA;AACZA,oBAAA,SAAU,IAAA;AACVA,oBAAA,WAAY,IAAA;AACZA,oBAAA,WAAY,IAAA;AACZA,oBAAA,OAAQ,IAAA;AACRA,oBAAA,aAAc,IAAA;AACdA,oBAAA,MAAO,IAAA;AACPA,oBAAA,OAAQ,IAAA;AACRA,oBAAA,WAAY,IAAA;AACZA,oBAAA,UAAW,IAAA;AACXA,oBAAA,OAAQ,IAAA;AACRA,oBAAA,QAAS,IAAA;AACTA,oBAAA,OAAQ,IAAA;AACRA,oBAAA,YAAa,IAAA;AACbA,oBAAA,QAAS,IAAA;AACTA,oBAAA,SAAU,IAAA;AACVA,oBAAA,UAAW,IAAA;AAn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AAA,CAAA;AAAA,EAAA,GACvC;AAEJ,CAAC;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { S as StatusDot, a as StatusDotVariant } from "./StatusDot.js";
|
|
4
|
+
import styles from "./components/ElementHeader/StatusDotMultiComposition/styles.module.scss";
|
|
5
|
+
const StatusDotMultiComposition = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
additionalText,
|
|
8
|
+
children,
|
|
9
|
+
className = "",
|
|
10
|
+
testId,
|
|
11
|
+
stacking = "horizontal",
|
|
12
|
+
hiddenForChild = false,
|
|
13
|
+
topStatusDot,
|
|
14
|
+
bottomStatusDot
|
|
15
|
+
} = props;
|
|
16
|
+
return /* @__PURE__ */ jsxs("span", { "data-testid": testId, className: classNames(styles["statusdotmulticomposition"], className), children: [
|
|
17
|
+
topStatusDot,
|
|
18
|
+
hiddenForChild && /* @__PURE__ */ jsx(StatusDot, { variant: StatusDotVariant.hidden, text: "Skjult for barnet" }),
|
|
19
|
+
/* @__PURE__ */ jsx("span", { "data-stacking": stacking, className: styles["statusdotmulticomposition__children"], children }),
|
|
20
|
+
bottomStatusDot,
|
|
21
|
+
additionalText && /* @__PURE__ */ jsx("span", { className: styles["statusdotmulticomposition__additional-text"], children: additionalText })
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
StatusDotMultiComposition as S
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=StatusDotMultiComposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusDotMultiComposition.js","sources":["../src/components/ElementHeader/StatusDotMultiComposition/StatusDotMultiComposition.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport StatusDot, { StatusDotProps, StatusDotVariant } from '../../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type StatusDotMultiCompositionType = React.FC<StatusDotMultiCompositionProps>;\n\nexport interface StatusDotMultiCompositionProps {\n /** Additional text to the bottom statusdot */\n additionalText?: string;\n /** StatusDot that is under the others and outside the stacking */\n bottomStatusDot?: React.ReactElement<StatusDotProps>;\n /** Stacking of the statusdots */\n stacking?: 'vertical' | 'horizontal';\n /** StatusDots as children */\n children?: React.ReactNode;\n /** Adds custom classes */\n className?: string;\n /** Show a hidden for child statusdot over the other */\n hiddenForChild?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** StatusDot that is over the others and outside the stacking */\n topStatusDot?: React.ReactElement<StatusDotProps>;\n}\n\nexport const StatusDotMultiComposition: StatusDotMultiCompositionType = props => {\n const {\n additionalText,\n children,\n className = '',\n testId,\n stacking = 'horizontal',\n hiddenForChild = false,\n topStatusDot,\n bottomStatusDot,\n } = props;\n\n return (\n <span data-testid={testId} className={cn(styles['statusdotmulticomposition'], className)}>\n {topStatusDot}\n {/* @todo: legg til tekst i SOT */}\n {hiddenForChild && <StatusDot variant={StatusDotVariant.hidden} text=\"Skjult for barnet\" />}\n <span data-stacking={stacking} className={styles['statusdotmulticomposition__children']}>\n {children}\n </span>\n {bottomStatusDot}\n {additionalText && <span className={styles['statusdotmulticomposition__additional-text']}>{additionalText}</span>}\n </span>\n );\n};\n\nexport default StatusDotMultiComposition;\n"],"names":["cn"],"mappings":";;;;AA6BO,MAAM,4BAA2D,CAAS,UAAA;AACzE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EAAA,IACE;AAGF,SAAA,qBAAC,QAAK,EAAA,eAAa,QAAQ,WAAWA,WAAG,OAAO,2BAA2B,GAAG,SAAS,GACpF,UAAA;AAAA,IAAA;AAAA,IAEA,kBAAmB,oBAAA,WAAA,EAAU,SAAS,iBAAiB,QAAQ,MAAK,qBAAoB;AAAA,IACzF,oBAAC,UAAK,iBAAe,UAAU,WAAW,OAAO,qCAAqC,GACnF,UACH;AAAA,IACC;AAAA,IACA,kBAAmB,oBAAA,QAAA,EAAK,WAAW,OAAO,4CAA4C,GAAI,UAAe,eAAA,CAAA;AAAA,EAAA,GAC5G;AAEJ;"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
|
-
@
|
|
2
|
+
@import '../../scss/supernova/styles/colors.css';
|
|
3
3
|
|
|
4
4
|
$underline-width: 0.0625rem;
|
|
5
5
|
$focus-width: 0.15rem;
|
|
6
6
|
|
|
7
7
|
@mixin anchorlink-hover {
|
|
8
8
|
cursor: pointer;
|
|
9
|
-
color:
|
|
10
|
-
background-color:
|
|
11
|
-
text-decoration-color:
|
|
9
|
+
color: var(--color-action-text-onlight-hover);
|
|
10
|
+
background-color: var(--color-action-background-transparent-onlight-hover);
|
|
11
|
+
text-decoration-color: var(--color-action-border-hover);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
@mixin anchorlink-focus {
|
|
15
15
|
outline: none;
|
|
16
|
-
border: $focus-width solid
|
|
16
|
+
border: $focus-width solid var(--color-action-border-onlight-focus);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
@mixin anchorlink {
|
|
@@ -22,11 +22,11 @@ $focus-width: 0.15rem;
|
|
|
22
22
|
overflow-wrap: break-word;
|
|
23
23
|
word-break: break-word;
|
|
24
24
|
text-align: left;
|
|
25
|
-
color:
|
|
25
|
+
color: var(--color-action-text-onlight);
|
|
26
26
|
border: $focus-width solid transparent;
|
|
27
27
|
text-decoration: underline;
|
|
28
28
|
text-underline-offset: 0.16rem;
|
|
29
|
-
text-decoration-color:
|
|
29
|
+
text-decoration-color: var(--core-color-neutral-700);
|
|
30
30
|
text-decoration-thickness: $underline-width;
|
|
31
31
|
padding: 0.1rem;
|
|
32
32
|
|
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
border-bottom: 1px solid var(--color-base-border-onlight);
|
|
9
9
|
|
|
10
10
|
&__content {
|
|
11
|
-
margin-bottom: var(--core-space-l);
|
|
12
11
|
overflow: hidden;
|
|
12
|
+
padding-bottom: 1rem;
|
|
13
|
+
|
|
14
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
15
|
+
padding-bottom: 2.65rem;
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
&--collapsed {
|
|
15
19
|
max-height: 10rem;
|
|
@@ -18,9 +22,9 @@
|
|
|
18
22
|
content: '';
|
|
19
23
|
position: absolute;
|
|
20
24
|
height: var(--core-space-3xl);
|
|
21
|
-
background: linear-gradient(180deg, #
|
|
25
|
+
background: linear-gradient(180deg, #fff0 0%, #fff 60%);
|
|
22
26
|
width: 100%;
|
|
23
|
-
bottom:
|
|
27
|
+
bottom: 0;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -86,6 +86,8 @@
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
$checkbox-icon-size: 1.625rem;
|
|
89
|
+
$padding-clickable-area-top-bottom: 7px;
|
|
90
|
+
$padding-clickable-area-left: 8px;
|
|
89
91
|
|
|
90
92
|
.checkbox-errors {
|
|
91
93
|
font-size: font-settings.$font-size-sm;
|
|
@@ -95,6 +97,8 @@ $checkbox-icon-size: 1.625rem;
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
.checkbox-wrapper {
|
|
100
|
+
margin-left: -$padding-clickable-area-left;
|
|
101
|
+
|
|
98
102
|
&--large {
|
|
99
103
|
margin: spacers.getSpacer(2xs) 0;
|
|
100
104
|
}
|
|
@@ -104,6 +108,7 @@ $checkbox-icon-size: 1.625rem;
|
|
|
104
108
|
display: flex;
|
|
105
109
|
align-items: flex-start;
|
|
106
110
|
cursor: pointer;
|
|
111
|
+
padding: $padding-clickable-area-top-bottom 0 $padding-clickable-area-top-bottom $padding-clickable-area-left;
|
|
107
112
|
|
|
108
113
|
&__text {
|
|
109
114
|
color: palette.$black;
|
|
@@ -439,5 +444,6 @@ $checkbox-icon-size: 1.625rem;
|
|
|
439
444
|
}
|
|
440
445
|
|
|
441
446
|
.checkbox-sublabel-wrapper {
|
|
442
|
-
|
|
447
|
+
margin-top: -$padding-clickable-area-top-bottom;
|
|
448
|
+
padding-left: calc(2.8rem + $padding-clickable-area-left);
|
|
443
449
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
|
-
@use '../../scss/spacers' as spacers;
|
|
3
|
-
@use '../../scss/palette' as palette;
|
|
4
2
|
@use '../../scss/breakpoints' as breakpoints;
|
|
5
3
|
@import '../../scss/supernova/styles/colors.css';
|
|
6
4
|
|
|
@@ -47,11 +45,14 @@ $mobile-outer-size: 2.75rem;
|
|
|
47
45
|
height: $mobile-inner-size;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
:hover >
|
|
51
|
-
:active > & {
|
|
48
|
+
:hover > & {
|
|
52
49
|
background-color: var(--color-action-background-transparent-onlight-hover);
|
|
53
50
|
}
|
|
54
51
|
|
|
52
|
+
:active > & {
|
|
53
|
+
background-color: var(--color-action-background-transparent-onlight-active);
|
|
54
|
+
}
|
|
55
|
+
|
|
55
56
|
:focus-visible > & {
|
|
56
57
|
outline: 3px solid var(--color-action-border-onlight-focus);
|
|
57
58
|
border-radius: 0;
|
|
@@ -59,11 +60,14 @@ $mobile-outer-size: 2.75rem;
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
&--plum {
|
|
62
|
-
:hover >
|
|
63
|
-
:active > & {
|
|
63
|
+
:hover > & {
|
|
64
64
|
background-color: var(--color-help-background-transparent-onlight-hover, #6c36b31a);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
:active > & {
|
|
68
|
+
background-color: var(--color-help-background-transparent-onlight-active, #6c36b31a);
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
:focus-visible > & {
|
|
68
72
|
outline: 3px solid var(--color-action-border-onlight-focus);
|
|
69
73
|
border-radius: 0;
|