@helsenorge/designsystem-react 12.8.0 → 13.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/AnchorLink.js +4 -4
- package/AnchorLink.js.map +1 -1
- package/Button.js +4 -4
- package/Button.js.map +1 -1
- package/CHANGELOG.md +22 -57
- package/Checkbox.js +4 -5
- package/Checkbox.js.map +1 -1
- package/Close.js +3 -3
- package/Close.js.map +1 -1
- package/Drawer.js +6 -261
- package/Drawer.js.map +1 -1
- package/Expander.js +2 -2
- package/Expander.js.map +1 -1
- package/FormFieldTag.js +1 -2
- package/FormFieldTag.js.map +1 -1
- package/FormGroup.js +16 -16
- package/FormGroup.js.map +1 -1
- package/HelpDetails.js +1 -1
- package/HelpTriggerIcon.js +5 -3
- package/HelpTriggerIcon.js.map +1 -1
- package/HelpTriggerStandalone.js +3 -3
- package/HelpTriggerStandalone.js.map +1 -1
- package/Icon.js +2 -3
- package/Icon.js.map +1 -1
- package/Illustration.js +2 -3
- package/Illustration.js.map +1 -1
- package/InfoTeaser.js +2 -3
- package/InfoTeaser.js.map +1 -1
- package/Input.js +9 -10
- package/Input.js.map +1 -1
- package/Label.js +3 -3
- package/Label.js.map +1 -1
- package/LinkList.js +4 -5
- package/LinkList.js.map +1 -1
- package/ListEditMode.js +3 -3
- package/ListEditMode.js.map +1 -1
- package/RadioButton.js +4 -5
- package/RadioButton.js.map +1 -1
- package/Select.js +8 -10
- package/Select.js.map +1 -1
- package/Slider.js +8 -8
- package/Slider.js.map +1 -1
- package/TabList.js +2 -2
- package/TabList.js.map +1 -1
- package/Textarea.js +2 -3
- package/Textarea.js.map +1 -1
- package/__mocks__/usePseudoClasses.js +1 -1
- package/__mocks__/usePseudoClasses.js.map +1 -1
- package/components/ArticleTeaser/styles.module.scss +5 -3
- package/components/Chip/index.js +3 -3
- package/components/Chip/index.js.map +1 -1
- package/components/Drawer/styles.module.scss +26 -45
- package/components/Drawer/styles.module.scss.d.ts +0 -5
- package/components/Dropdown/Dropdown.d.ts +21 -19
- package/components/Dropdown/Dropdown.test.d.ts +0 -1
- package/components/Dropdown/index.js +78 -142
- package/components/Dropdown/index.js.map +1 -1
- package/components/Dropdown/styles.module.scss +136 -90
- package/components/Dropdown/styles.module.scss.d.ts +9 -8
- package/components/ExpanderHierarchy/index.js +3 -3
- package/components/ExpanderHierarchy/index.js.map +1 -1
- package/components/ExpanderList/index.js +4 -5
- package/components/ExpanderList/index.js.map +1 -1
- package/components/FormFieldTag/FormFieldTag.d.ts +0 -2
- package/components/FormGroup/FormGroup.d.ts +2 -1
- package/components/HelpExpanderStandalone/index.js +3 -3
- package/components/HelpExpanderStandalone/index.js.map +1 -1
- package/components/HelpTooltip/index.js +2 -3
- package/components/HelpTooltip/index.js.map +1 -1
- package/components/HelpTriggerInline/index.js +3 -3
- package/components/HelpTriggerInline/index.js.map +1 -1
- package/components/Icons/EmoticonAnnoyed.js +11 -8
- package/components/Icons/EmoticonAnnoyed.js.map +1 -1
- package/components/Icons/EmoticonDelighted.js +4 -8
- package/components/Icons/EmoticonDelighted.js.map +1 -1
- package/components/Icons/EmoticonDisappointed.js +4 -8
- package/components/Icons/EmoticonDisappointed.js.map +1 -1
- package/components/Icons/EmoticonHappy.js +4 -8
- package/components/Icons/EmoticonHappy.js.map +1 -1
- package/components/Icons/EmoticonMeh.js +4 -8
- package/components/Icons/EmoticonMeh.js.map +1 -1
- package/components/Icons/PatientAndPerson.js +2 -2
- package/components/Icons/PatientAndPerson.js.map +1 -1
- package/components/Icons/PersonAndPatient.js +2 -2
- package/components/Icons/PersonAndPatient.js.map +1 -1
- package/components/Input/styles.module.scss +21 -22
- package/components/Input/styles.module.scss.d.ts +1 -1
- package/components/Label/Label.d.ts +2 -1
- package/components/LinkList/styles.module.scss +61 -47
- package/components/LinkList/styles.module.scss.d.ts +0 -1
- package/components/ListEditMode/styles.module.scss +0 -1
- package/components/Logo/index.js +6 -6
- package/components/Logo/index.js.map +1 -1
- package/components/NotificationPanel/index.js +6 -9
- package/components/NotificationPanel/index.js.map +1 -1
- package/components/NotificationPanel/styles.module.scss +5 -10
- package/components/PopMenu/index.js +2 -2
- package/components/PopMenu/index.js.map +1 -1
- package/components/PromoPanel/index.js +3 -3
- package/components/PromoPanel/index.js.map +1 -1
- package/components/Select/styles.module.scss +2 -2
- package/components/ServiceMessage/index.js +7 -8
- package/components/ServiceMessage/index.js.map +1 -1
- package/components/StickyNote/index.js +6 -8
- package/components/StickyNote/index.js.map +1 -1
- package/components/Textarea/styles.module.scss.d.ts +0 -1
- package/components/Tile/index.js +3 -3
- package/components/Tile/index.js.map +1 -1
- package/components/Toggle/index.js +14 -12
- package/components/Toggle/index.js.map +1 -1
- package/components/Validation/index.js +2 -3
- package/components/Validation/index.js.map +1 -1
- package/constants.d.ts +0 -1
- package/constants.js +0 -1
- package/constants.js.map +1 -1
- package/designsystem-react.css +1 -11
- package/floating-ui.react.js +38 -18
- package/floating-ui.react.js.map +1 -1
- package/hooks/useIdWithFallback.d.ts +6 -0
- package/hooks/useIdWithFallback.js +9 -0
- package/hooks/useIdWithFallback.js.map +1 -0
- package/index.d.ts +0 -2
- package/index.js +0 -4
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/scss/_input.scss +0 -29
- package/scss/supernova/styles/colors.css +1 -11
- package/scss/supernova/styles/typography.css +51 -52
- package/AsChildSlot.js +0 -74
- package/AsChildSlot.js.map +0 -1
- package/HN.Designsystem.Dropdown.nb-NO.js +0 -13
- package/HN.Designsystem.Dropdown.nb-NO.js.map +0 -1
- package/PanelOld.js +0 -325
- package/PanelOld.js.map +0 -1
- package/SingleSelectItem.js +0 -96
- package/SingleSelectItem.js.map +0 -1
- package/__mocks__/useHover.d.ts +0 -1
- package/__mocks__/useHover.js +0 -6
- package/__mocks__/useHover.js.map +0 -1
- package/clamp.js +0 -11
- package/clamp.js.map +0 -1
- package/components/AsChildSlot/AsChildSlot.d.ts +0 -23
- package/components/AsChildSlot/AsChildSlot.test.d.ts +0 -1
- package/components/AsChildSlot/index.d.ts +0 -3
- package/components/AsChildSlot/index.js +0 -6
- package/components/AsChildSlot/index.js.map +0 -1
- package/components/AsChildSlot/styles.module.scss +0 -13
- package/components/AsChildSlot/styles.module.scss.d.ts +0 -9
- package/components/Dropdown/SingleSelect/SingleSelect.d.ts +0 -18
- package/components/Dropdown/SingleSelect/SingleSelect.test.d.ts +0 -1
- package/components/Dropdown/SingleSelect/SingleSelectItem.d.ts +0 -21
- package/components/Dropdown/SingleSelect/index.d.ts +0 -3
- package/components/Dropdown/SingleSelect/index.js +0 -6
- package/components/Dropdown/SingleSelect/index.js.map +0 -1
- package/components/Dropdown/SingleSelect/styles.module.scss +0 -54
- package/components/Dropdown/SingleSelect/styles.module.scss.d.ts +0 -14
- package/components/DropdownOld/DropdownOld.d.ts +0 -42
- package/components/DropdownOld/index.d.ts +0 -3
- package/components/DropdownOld/index.js +0 -194
- package/components/DropdownOld/index.js.map +0 -1
- package/components/DropdownOld/resourceHelper.d.ts +0 -3
- package/components/DropdownOld/styles.module.scss +0 -230
- package/components/DropdownOld/styles.module.scss.d.ts +0 -25
- package/components/PanelListOld/PanelListOld.d.ts +0 -12
- package/components/PanelListOld/PanelListOld.test.d.ts +0 -1
- package/components/PanelListOld/index.d.ts +0 -3
- package/components/PanelListOld/index.js +0 -20
- package/components/PanelListOld/index.js.map +0 -1
- package/components/PanelListOld/styles.module.scss +0 -14
- package/components/PanelListOld/styles.module.scss.d.ts +0 -9
- package/components/PanelOld/PanelOld.d.ts +0 -89
- package/components/PanelOld/PanelOld.test.d.ts +0 -1
- package/components/PanelOld/index.d.ts +0 -3
- package/components/PanelOld/index.js +0 -9
- package/components/PanelOld/index.js.map +0 -1
- package/components/PanelOld/styles.module.scss +0 -433
- package/components/PanelOld/styles.module.scss.d.ts +0 -61
- package/hooks/useHover.d.ts +0 -10
- package/hooks/useHover.js +0 -9
- package/hooks/useHover.js.map +0 -1
- package/hooks/useUuid.d.ts +0 -6
- package/hooks/useUuid.js +0 -10
- package/hooks/useUuid.js.map +0 -1
- package/use-animate.js +0 -3946
- package/use-animate.js.map +0 -1
- /package/{components/DropdownOld/DropdownOld.test.d.ts → resources/index.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
@use 'sass:meta';
|
|
3
|
-
@use 'sass:string';
|
|
4
|
-
@import '../../../scss/supernova/styles/colors.css';
|
|
5
|
-
@import '../../../scss/supernova/styles/spacers.css';
|
|
6
|
-
|
|
7
|
-
.single-select-item {
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
|
|
10
|
-
:focus-visible {
|
|
11
|
-
outline: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&__content {
|
|
15
|
-
all: unset;
|
|
16
|
-
width: 100%;
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: baseline;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
padding: var(--core-space-2xs) 0 var(--core-space-2xs) var(--core-space-s);
|
|
22
|
-
line-height: 1.75rem;
|
|
23
|
-
|
|
24
|
-
&--disabled {
|
|
25
|
-
cursor: default;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__dot {
|
|
30
|
-
appearance: none;
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
display: flex;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
align-items: center;
|
|
35
|
-
margin: 0 0.667rem 0 0;
|
|
36
|
-
background-color: transparent;
|
|
37
|
-
min-width: 0.67rem;
|
|
38
|
-
min-height: 0.67rem;
|
|
39
|
-
border-radius: 10rem;
|
|
40
|
-
outline: none;
|
|
41
|
-
|
|
42
|
-
&:checked {
|
|
43
|
-
background-color: var(--core-color-black);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&--checked {
|
|
47
|
-
background-color: var(--core-color-black);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&--disabled {
|
|
51
|
-
cursor: default;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Styles = {
|
|
2
|
-
'single-select-item': string;
|
|
3
|
-
'single-select-item__content': string;
|
|
4
|
-
'single-select-item__content--disabled': string;
|
|
5
|
-
'single-select-item__dot': string;
|
|
6
|
-
'single-select-item__dot--checked': string;
|
|
7
|
-
'single-select-item__dot--disabled': string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ClassNames = keyof Styles;
|
|
11
|
-
|
|
12
|
-
declare const styles: Styles;
|
|
13
|
-
|
|
14
|
-
export default styles;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { HNDesignsystemDropdown } from '../../resources/Resources';
|
|
3
|
-
export declare enum DropdownOldOnColor {
|
|
4
|
-
onwhite = "onwhite",
|
|
5
|
-
ongrey = "ongrey",
|
|
6
|
-
onblueberry = "onblueberry",
|
|
7
|
-
oncherry = "oncherry"
|
|
8
|
-
}
|
|
9
|
-
export interface DropdownOldProps {
|
|
10
|
-
/** Label for dropdown. Visible for screen readers */
|
|
11
|
-
label: string;
|
|
12
|
-
/** Text on the trigger button that opens the dropdown */
|
|
13
|
-
placeholder: string;
|
|
14
|
-
/** Sets the dropdown content */
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
/** @deprecated Close button text */
|
|
17
|
-
closeText?: string;
|
|
18
|
-
/** Minimum width for the dropdown in pixels. Does not affect trigger button */
|
|
19
|
-
dropdownMinWidth?: number;
|
|
20
|
-
/** No close button */
|
|
21
|
-
noCloseButton?: boolean;
|
|
22
|
-
/** Called when dropdown is open/closed */
|
|
23
|
-
onToggle?: (isOpen: boolean) => void;
|
|
24
|
-
/** Whether the dropdown is open or not */
|
|
25
|
-
open?: boolean;
|
|
26
|
-
/** Changes the visuals of the dropdown */
|
|
27
|
-
onColor?: keyof typeof DropdownOldOnColor;
|
|
28
|
-
/** Makes the background of the trigger transparent */
|
|
29
|
-
transparent?: boolean;
|
|
30
|
-
/** Makes the width of the full component adjust to its parent */
|
|
31
|
-
fluid?: boolean;
|
|
32
|
-
/** Makes the dropdown disabled */
|
|
33
|
-
disabled?: boolean;
|
|
34
|
-
/** Sets the data-testid attribute on the dropdown button */
|
|
35
|
-
testId?: string;
|
|
36
|
-
/** Overrides the default z-index of the DropDownContent */
|
|
37
|
-
zIndex?: number;
|
|
38
|
-
/** Resources for component */
|
|
39
|
-
resources?: Partial<HNDesignsystemDropdown>;
|
|
40
|
-
}
|
|
41
|
-
declare const DropdownOld: React.FC<DropdownOldProps>;
|
|
42
|
-
export default DropdownOld;
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React__default, { useRef, useId, useEffect } from "react";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { theme } from "../../theme/index.js";
|
|
5
|
-
import "../../hooks/useBreakpoint.js";
|
|
6
|
-
import { useHover } from "../../hooks/useHover.js";
|
|
7
|
-
import { useToggle } from "../../hooks/useToggle.js";
|
|
8
|
-
import { useKeyboardEvent } from "../../hooks/useKeyboardEvent.js";
|
|
9
|
-
import { useOutsideEvent } from "../../hooks/useOutsideEvent.js";
|
|
10
|
-
import { LanguageLocales, ZIndex, KeyboardEventKey, AnalyticsId, IconSize } from "../../constants.js";
|
|
11
|
-
import { n as nbNO, e as enGB } from "../../HN.Designsystem.Dropdown.nb-NO.js";
|
|
12
|
-
import { useLanguage } from "../../utils/language.js";
|
|
13
|
-
import { mergeRefs } from "../../utils/refs.js";
|
|
14
|
-
import { B as Button } from "../../Button.js";
|
|
15
|
-
import { I as Icon } from "../../Icon.js";
|
|
16
|
-
import PlusSmall from "../Icons/PlusSmall.js";
|
|
17
|
-
import styles from "./styles.module.scss";
|
|
18
|
-
const getResources = (language) => {
|
|
19
|
-
switch (language) {
|
|
20
|
-
case LanguageLocales.ENGLISH:
|
|
21
|
-
return enGB;
|
|
22
|
-
case LanguageLocales.NORWEGIAN:
|
|
23
|
-
default:
|
|
24
|
-
return nbNO;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var DropdownOldOnColor = /* @__PURE__ */ ((DropdownOldOnColor2) => {
|
|
28
|
-
DropdownOldOnColor2["onwhite"] = "onwhite";
|
|
29
|
-
DropdownOldOnColor2["ongrey"] = "ongrey";
|
|
30
|
-
DropdownOldOnColor2["onblueberry"] = "onblueberry";
|
|
31
|
-
DropdownOldOnColor2["oncherry"] = "oncherry";
|
|
32
|
-
return DropdownOldOnColor2;
|
|
33
|
-
})(DropdownOldOnColor || {});
|
|
34
|
-
const DropdownOld = (props) => {
|
|
35
|
-
const {
|
|
36
|
-
label,
|
|
37
|
-
placeholder,
|
|
38
|
-
noCloseButton = false,
|
|
39
|
-
onToggle,
|
|
40
|
-
dropdownMinWidth,
|
|
41
|
-
open = false,
|
|
42
|
-
children,
|
|
43
|
-
onColor = "onwhite",
|
|
44
|
-
transparent = false,
|
|
45
|
-
fluid = false,
|
|
46
|
-
testId,
|
|
47
|
-
disabled,
|
|
48
|
-
zIndex = ZIndex.PopOver,
|
|
49
|
-
resources
|
|
50
|
-
} = props;
|
|
51
|
-
const dropdownRef = useRef(null);
|
|
52
|
-
const optionsRef = useRef(null);
|
|
53
|
-
const { hoverRef: buttonRef, isHovered } = useHover();
|
|
54
|
-
const openedByKeyboard = useRef(false);
|
|
55
|
-
const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);
|
|
56
|
-
const inputRefList = useRef(React__default.Children.map(children, () => React__default.createRef()));
|
|
57
|
-
const labelId = useId();
|
|
58
|
-
const toggleLabelId = useId();
|
|
59
|
-
const optionIdPrefix = useId();
|
|
60
|
-
const contentId = useId();
|
|
61
|
-
const { language } = useLanguage(LanguageLocales.NORWEGIAN);
|
|
62
|
-
const defaultResources = getResources(language);
|
|
63
|
-
const mergedResources = {
|
|
64
|
-
...defaultResources,
|
|
65
|
-
...resources,
|
|
66
|
-
closeText: props.closeText ?? (resources == null ? void 0 : resources.closeText) ?? defaultResources.closeText
|
|
67
|
-
};
|
|
68
|
-
const handleOpen = (isKeyboard) => {
|
|
69
|
-
openedByKeyboard.current = isKeyboard;
|
|
70
|
-
toggleIsOpen();
|
|
71
|
-
};
|
|
72
|
-
const handleClose = () => {
|
|
73
|
-
var _a;
|
|
74
|
-
toggleIsOpen();
|
|
75
|
-
(_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
76
|
-
};
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
if (isOpen && openedByKeyboard.current) {
|
|
80
|
-
const firstEnabled = (_a = inputRefList.current) == null ? void 0 : _a.find((r) => r.current && !r.current.hasAttribute("disabled"));
|
|
81
|
-
(_b = firstEnabled == null ? void 0 : firstEnabled.current) == null ? void 0 : _b.focus();
|
|
82
|
-
openedByKeyboard.current = false;
|
|
83
|
-
}
|
|
84
|
-
}, [isOpen]);
|
|
85
|
-
const handleKeyboardNavigation = (event) => {
|
|
86
|
-
var _a;
|
|
87
|
-
if (!inputRefList.current) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (event.key === KeyboardEventKey.Escape) {
|
|
91
|
-
if (isOpen) handleClose();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!isOpen) {
|
|
95
|
-
handleOpen(true);
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const index = inputRefList.current.findIndex((x) => x.current === event.target);
|
|
100
|
-
let nextIndex = index;
|
|
101
|
-
if (event.key === KeyboardEventKey.Home) {
|
|
102
|
-
nextIndex = 0;
|
|
103
|
-
} else if (event.key === KeyboardEventKey.End) {
|
|
104
|
-
nextIndex = inputRefList.current.length - 1;
|
|
105
|
-
} else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {
|
|
106
|
-
nextIndex = index + 1;
|
|
107
|
-
} else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {
|
|
108
|
-
nextIndex = index - 1;
|
|
109
|
-
} else if (event.key === KeyboardEventKey.Enter && index !== -1) {
|
|
110
|
-
nextIndex = index;
|
|
111
|
-
}
|
|
112
|
-
if (nextIndex !== -1 && event.key !== KeyboardEventKey.Space) {
|
|
113
|
-
event.preventDefault();
|
|
114
|
-
(_a = inputRefList.current[nextIndex].current) == null ? void 0 : _a.focus();
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [
|
|
118
|
-
KeyboardEventKey.ArrowDown,
|
|
119
|
-
KeyboardEventKey.ArrowUp,
|
|
120
|
-
KeyboardEventKey.End,
|
|
121
|
-
KeyboardEventKey.Enter,
|
|
122
|
-
KeyboardEventKey.Escape,
|
|
123
|
-
KeyboardEventKey.Home,
|
|
124
|
-
KeyboardEventKey.Space
|
|
125
|
-
]);
|
|
126
|
-
useOutsideEvent(dropdownRef, () => isOpen && handleClose());
|
|
127
|
-
const toggleClasses = classNames(
|
|
128
|
-
styles.dropdown__toggle,
|
|
129
|
-
!disabled && {
|
|
130
|
-
[styles["dropdown__toggle--on-white"]]: onColor === "onwhite",
|
|
131
|
-
[styles["dropdown__toggle--on-grey"]]: onColor === "ongrey",
|
|
132
|
-
[styles["dropdown__toggle--on-blueberry"]]: onColor === "onblueberry",
|
|
133
|
-
[styles["dropdown__toggle--on-cherry"]]: onColor === "oncherry",
|
|
134
|
-
[styles["dropdown__toggle--transparent"]]: transparent,
|
|
135
|
-
[styles["dropdown__toggle--fluid"]]: fluid,
|
|
136
|
-
[styles["dropdown__toggle--open"]]: isOpen
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
const contentClasses = classNames(styles.dropdown__content, isOpen && styles["dropdown__content--open"]);
|
|
140
|
-
const renderChildren = React__default.Children.map(children, (child, index) => {
|
|
141
|
-
return /* @__PURE__ */ jsx("li", { className: styles.dropdown__input, id: `${optionIdPrefix}-${index}`, children: React__default.isValidElement(child) && inputRefList.current && inputRefList.current[index] ? React__default.cloneElement(child, {
|
|
142
|
-
ref: mergeRefs([child.props.ref, inputRefList.current[index]])
|
|
143
|
-
}) : child });
|
|
144
|
-
});
|
|
145
|
-
return /* @__PURE__ */ jsxs("div", { className: styles.dropdown, ref: dropdownRef, children: [
|
|
146
|
-
/* @__PURE__ */ jsx("span", { id: labelId, className: styles.dropdown__label, children: label }),
|
|
147
|
-
/* @__PURE__ */ jsxs(
|
|
148
|
-
"button",
|
|
149
|
-
{
|
|
150
|
-
type: "button",
|
|
151
|
-
onClick: () => handleOpen(false),
|
|
152
|
-
className: toggleClasses,
|
|
153
|
-
ref: buttonRef,
|
|
154
|
-
"data-testid": testId,
|
|
155
|
-
"data-analyticsid": AnalyticsId.Dropdown,
|
|
156
|
-
disabled,
|
|
157
|
-
"aria-labelledby": toggleLabelId,
|
|
158
|
-
"aria-haspopup": true,
|
|
159
|
-
"aria-controls": contentId,
|
|
160
|
-
"aria-expanded": isOpen,
|
|
161
|
-
children: [
|
|
162
|
-
/* @__PURE__ */ jsx("span", { id: toggleLabelId, className: styles.dropdown__toggle__label, children: placeholder }),
|
|
163
|
-
/* @__PURE__ */ jsx(
|
|
164
|
-
Icon,
|
|
165
|
-
{
|
|
166
|
-
color: disabled ? theme.palette.neutral700 : theme.palette.blueberry600,
|
|
167
|
-
svgIcon: PlusSmall,
|
|
168
|
-
className: styles.dropdown__icon,
|
|
169
|
-
isHovered: !disabled && isHovered,
|
|
170
|
-
size: IconSize.XSmall
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
/* @__PURE__ */ jsxs(
|
|
177
|
-
"div",
|
|
178
|
-
{
|
|
179
|
-
id: contentId,
|
|
180
|
-
className: contentClasses,
|
|
181
|
-
style: { width: fluid ? "100%" : `auto`, minWidth: dropdownMinWidth ?? "auto", zIndex },
|
|
182
|
-
children: [
|
|
183
|
-
/* @__PURE__ */ jsx("ul", { className: styles.dropdown__options, role: "group", "aria-labelledby": labelId, tabIndex: -1, ref: optionsRef, children: renderChildren }),
|
|
184
|
-
!noCloseButton && /* @__PURE__ */ jsx("div", { className: styles.dropdown__close, children: /* @__PURE__ */ jsx(Button, { onClick: handleClose, children: mergedResources.closeText }) })
|
|
185
|
-
]
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
|
-
] });
|
|
189
|
-
};
|
|
190
|
-
export {
|
|
191
|
-
DropdownOldOnColor,
|
|
192
|
-
DropdownOld as default
|
|
193
|
-
};
|
|
194
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/DropdownOld/resourceHelper.ts","../../../src/components/DropdownOld/DropdownOld.tsx"],"sourcesContent":["import { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Dropdown.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Dropdown.nb-NO.json';\nimport { HNDesignsystemDropdown } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemDropdown => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React, { useEffect, useRef, useId } from 'react';\n\nimport classNames from 'classnames';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n LanguageLocales,\n ZIndex,\n theme,\n useHover,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n} from '../..';\nimport { getResources } from './resourceHelper';\nimport { HNDesignsystemDropdown } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport { mergeRefs } from '../../utils/refs';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport PlusSmall from '../Icons/PlusSmall';\n\nimport styles from './styles.module.scss';\n\nexport enum DropdownOldOnColor {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n\nexport interface DropdownOldProps {\n /** Label for dropdown. Visible for screen readers */\n label: string;\n /** Text on the trigger button that opens the dropdown */\n placeholder: string;\n /** Sets the dropdown content */\n children: React.ReactNode;\n /** @deprecated Close button text */\n closeText?: string;\n /** Minimum width for the dropdown in pixels. Does not affect trigger button */\n dropdownMinWidth?: number;\n /** No close button */\n noCloseButton?: boolean;\n /** Called when dropdown is open/closed */\n onToggle?: (isOpen: boolean) => void;\n /** Whether the dropdown is open or not */\n open?: boolean;\n /** Changes the visuals of the dropdown */\n onColor?: keyof typeof DropdownOldOnColor;\n /** Makes the background of the trigger transparent */\n transparent?: boolean;\n /** Makes the width of the full component adjust to its parent */\n fluid?: boolean;\n /** Makes the dropdown disabled */\n disabled?: boolean;\n /** Sets the data-testid attribute on the dropdown button */\n testId?: string;\n /** Overrides the default z-index of the DropDownContent */\n zIndex?: number;\n /** Resources for component */\n resources?: Partial<HNDesignsystemDropdown>;\n}\n\nconst DropdownOld: React.FC<DropdownOldProps> = props => {\n const {\n label,\n placeholder,\n noCloseButton = false,\n onToggle,\n dropdownMinWidth,\n open = false,\n children,\n onColor = DropdownOldOnColor.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n resources,\n } = props;\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { hoverRef: buttonRef, isHovered } = useHover<HTMLButtonElement>();\n const openedByKeyboard = useRef<boolean>(false);\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const labelId = useId();\n const toggleLabelId = useId();\n const optionIdPrefix = useId();\n const contentId = useId();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemDropdown = {\n ...defaultResources,\n ...resources,\n closeText: props.closeText ?? resources?.closeText ?? defaultResources.closeText,\n };\n\n const handleOpen = (isKeyboard: boolean): void => {\n openedByKeyboard.current = isKeyboard;\n toggleIsOpen();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n useEffect(() => {\n if (isOpen && openedByKeyboard.current) {\n const firstEnabled = inputRefList.current?.find(r => r.current && !r.current.hasAttribute('disabled'));\n firstEnabled?.current?.focus();\n openedByKeyboard.current = false;\n }\n }, [isOpen]);\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (!inputRefList.current) {\n return;\n }\n\n if (event.key === KeyboardEventKey.Escape) {\n if (isOpen) handleClose();\n return;\n }\n\n if (!isOpen) {\n handleOpen(true);\n event.preventDefault();\n return;\n }\n\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (event.key === KeyboardEventKey.ArrowDown && index < inputRefList.current.length - 1) {\n nextIndex = index + 1;\n } else if (event.key === KeyboardEventKey.ArrowUp && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter && index !== -1) {\n nextIndex = index;\n }\n\n if (nextIndex !== -1 && event.key !== KeyboardEventKey.Space) {\n event.preventDefault();\n\n inputRefList.current[nextIndex].current?.focus();\n }\n };\n\n useKeyboardEvent(dropdownRef, handleKeyboardNavigation, [\n KeyboardEventKey.ArrowDown,\n KeyboardEventKey.ArrowUp,\n KeyboardEventKey.End,\n KeyboardEventKey.Enter,\n KeyboardEventKey.Escape,\n KeyboardEventKey.Home,\n KeyboardEventKey.Space,\n ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: onColor === DropdownOldOnColor.onwhite,\n [styles['dropdown__toggle--on-grey']]: onColor === DropdownOldOnColor.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: onColor === DropdownOldOnColor.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: onColor === DropdownOldOnColor.oncherry,\n [styles['dropdown__toggle--transparent']]: transparent,\n [styles['dropdown__toggle--fluid']]: fluid,\n [styles['dropdown__toggle--open']]: isOpen,\n }\n );\n\n const contentClasses = classNames(styles.dropdown__content, isOpen && styles['dropdown__content--open']);\n\n const renderChildren = React.Children.map(children, (child, index) => {\n return (\n <li className={styles.dropdown__input} id={`${optionIdPrefix}-${index}`}>\n {React.isValidElement(child) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(child as React.ReactElement, {\n ref: mergeRefs([child.props.ref, inputRefList.current[index]]),\n })\n : child}\n </li>\n );\n });\n\n return (\n <div className={styles.dropdown} ref={dropdownRef}>\n <span id={labelId} className={styles.dropdown__label}>\n {label}\n </span>\n <button\n type=\"button\"\n onClick={(): false | void => handleOpen(false)}\n className={toggleClasses}\n ref={buttonRef}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Dropdown}\n disabled={disabled}\n aria-labelledby={toggleLabelId}\n aria-haspopup={true}\n aria-controls={contentId}\n aria-expanded={isOpen}\n >\n <span id={toggleLabelId} className={styles.dropdown__toggle__label}>\n {placeholder}\n </span>\n <Icon\n color={disabled ? theme.palette.neutral700 : theme.palette.blueberry600}\n svgIcon={PlusSmall}\n className={styles.dropdown__icon}\n isHovered={!disabled && isHovered}\n size={IconSize.XSmall}\n />\n </button>\n <div\n id={contentId}\n className={contentClasses}\n style={{ width: fluid ? '100%' : `auto`, minWidth: dropdownMinWidth ?? 'auto', zIndex: zIndex }}\n >\n <ul className={styles.dropdown__options} role=\"group\" aria-labelledby={labelId} tabIndex={-1} ref={optionsRef}>\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose}>{mergedResources.closeText}</Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default DropdownOld;\n"],"names":["DropdownOldOnColor","React"],"mappings":";;;;;;;;;;;;;;;;;AAKO,MAAM,eAAe,CAAC,aAAsD;AACjF,UAAQ,UAAA;AAAA,IACN,KAAK,gBAAgB;AACnB,aAAO;AAAA,IACT,KAAK,gBAAgB;AAAA,IACrB;AACE,aAAO;AAAA,EAAA;AAEb;ACaO,IAAK,uCAAAA,wBAAL;AACLA,sBAAA,SAAA,IAAU;AACVA,sBAAA,QAAA,IAAS;AACTA,sBAAA,aAAA,IAAc;AACdA,sBAAA,UAAA,IAAW;AAJD,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AAwCZ,MAAM,cAA0C,CAAA,UAAS;AACvD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,UAAU;AAAA,IACV,cAAc;AAAA,IACd,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,SAAS,OAAO;AAAA,IAChB;AAAA,EAAA,IACE;AAEJ,QAAM,cAAc,OAAuB,IAAI;AAC/C,QAAM,aAAa,OAAyB,IAAI;AAChD,QAAM,EAAE,UAAU,WAAW,UAAA,IAAc,SAAA;AAC3C,QAAM,mBAAmB,OAAgB,KAAK;AAC9C,QAAM,EAAE,OAAO,QAAQ,aAAa,iBAAiB,UAAU,CAAC,YAAY,MAAM,QAAQ;AAC1F,QAAM,eAAe,OAAOC,eAAM,SAAS,IAAI,UAAU,MAAMA,eAAM,UAAA,CAAwB,CAAC;AAC9F,QAAM,UAAU,MAAA;AAChB,QAAM,gBAAgB,MAAA;AACtB,QAAM,iBAAiB,MAAA;AACvB,QAAM,YAAY,MAAA;AAClB,QAAM,EAAE,SAAA,IAAa,YAA6B,gBAAgB,SAAS;AAC3E,QAAM,mBAAmB,aAAa,QAAQ;AAE9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
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
@use '../../scss/spacers' as spacers;
|
|
3
|
-
@use '../../scss/palette' as palette;
|
|
4
|
-
@use '../../scss/font-settings' as font-settings;
|
|
5
|
-
@use '../../scss/screen-reader' as *;
|
|
6
|
-
@use '../../scss/breakpoints' as breakpoints;
|
|
7
|
-
|
|
8
|
-
.dropdown {
|
|
9
|
-
position: relative;
|
|
10
|
-
width: fit-content;
|
|
11
|
-
|
|
12
|
-
&__label {
|
|
13
|
-
@include sr-only;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__toggle {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: space-between;
|
|
19
|
-
align-items: center;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
border-radius: 0;
|
|
22
|
-
border-width: 2px;
|
|
23
|
-
border-style: solid;
|
|
24
|
-
padding: 0 spacers.getSpacer(3xs) 0 spacers.getSpacer(s);
|
|
25
|
-
font-family: inherit;
|
|
26
|
-
font-size: font-settings.$font-size-sm;
|
|
27
|
-
line-height: 1.3rem; // Custom fordi teksten skal henge bedre sammen om den går over to linjer
|
|
28
|
-
|
|
29
|
-
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
30
|
-
padding: spacers.getSpacer(3xs) spacers.getSpacer(3xs) spacers.getSpacer(3xs) spacers.getSpacer(s);
|
|
31
|
-
font-size: font-settings.$font-size-md;
|
|
32
|
-
line-height: 1.5rem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&:focus {
|
|
36
|
-
outline: none;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:disabled {
|
|
40
|
-
cursor: initial;
|
|
41
|
-
color: palette.$neutral700;
|
|
42
|
-
background-color: transparent;
|
|
43
|
-
border-color: palette.$neutral600;
|
|
44
|
-
border-style: dashed;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
&--on-white,
|
|
48
|
-
&--on-grey {
|
|
49
|
-
border-color: palette.$neutral700;
|
|
50
|
-
background-color: palette.$white;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
background-color: palette.$neutral50;
|
|
54
|
-
box-shadow: 0 0 0 1px palette.$neutral700;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&:focus {
|
|
58
|
-
border-color: palette.$black;
|
|
59
|
-
box-shadow: 0 0 0 1px palette.$black;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&--on-blueberry {
|
|
64
|
-
border-color: palette.$blueberry500;
|
|
65
|
-
background-color: palette.$white;
|
|
66
|
-
|
|
67
|
-
&:hover {
|
|
68
|
-
background-color: palette.$blueberry50;
|
|
69
|
-
box-shadow: 0 0 0 1px palette.$blueberry500;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&:focus {
|
|
73
|
-
border-color: palette.$black;
|
|
74
|
-
box-shadow: 0 0 0 1px palette.$black;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&--on-cherry {
|
|
79
|
-
border-color: palette.$cherry500;
|
|
80
|
-
background-color: palette.$white;
|
|
81
|
-
|
|
82
|
-
&:hover {
|
|
83
|
-
background-color: palette.$cherry50;
|
|
84
|
-
box-shadow: 0 0 0 1px palette.$cherry500;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&:focus {
|
|
88
|
-
border-color: palette.$black;
|
|
89
|
-
box-shadow: 0 0 0 1px palette.$black;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
&--open#{&}--on-white,
|
|
94
|
-
&--open#{&}--on-grey {
|
|
95
|
-
background-color: palette.$neutral50;
|
|
96
|
-
|
|
97
|
-
&:hover {
|
|
98
|
-
background-color: palette.$white;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&--open#{&}--on-blueberry {
|
|
103
|
-
background-color: palette.$blueberry50;
|
|
104
|
-
|
|
105
|
-
&:hover {
|
|
106
|
-
background-color: palette.$white;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&--open#{&}--on-cherry {
|
|
111
|
-
background-color: palette.$cherry50;
|
|
112
|
-
|
|
113
|
-
&:hover {
|
|
114
|
-
background-color: palette.$white;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
&--transparent {
|
|
119
|
-
background-color: transparent;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
&--transparent#{&}--on-grey {
|
|
123
|
-
&:hover {
|
|
124
|
-
background-color: palette.$neutral100;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&--transparent#{&}--on-blueberry {
|
|
129
|
-
&:hover {
|
|
130
|
-
background-color: palette.$blueberry100;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&--transparent#{&}--on-cherry {
|
|
135
|
-
&:hover {
|
|
136
|
-
background-color: palette.$cherry100;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&--transparent#{&}--open#{&}--on-grey {
|
|
141
|
-
background-color: palette.$neutral100;
|
|
142
|
-
|
|
143
|
-
&:hover {
|
|
144
|
-
background-color: transparent;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
&--transparent#{&}--open#{&}--on-blueberry {
|
|
149
|
-
background-color: palette.$blueberry100;
|
|
150
|
-
|
|
151
|
-
&:hover {
|
|
152
|
-
background-color: transparent;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
&--transparent#{&}--open#{&}--on-cherry {
|
|
157
|
-
background-color: palette.$cherry100;
|
|
158
|
-
|
|
159
|
-
&:hover {
|
|
160
|
-
background-color: transparent;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
&--fluid {
|
|
165
|
-
width: 100%;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
&__label {
|
|
169
|
-
padding: spacers.getSpacer(3xs) 0;
|
|
170
|
-
|
|
171
|
-
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
172
|
-
padding: spacers.getSpacer(2xs) 0;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
&__icon {
|
|
178
|
-
margin-left: spacers.getSpacer(2xs);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
&__content {
|
|
182
|
-
display: none;
|
|
183
|
-
position: absolute;
|
|
184
|
-
background-color: palette.$white;
|
|
185
|
-
margin-top: spacers.getSpacer(2xs);
|
|
186
|
-
box-shadow: 0 0 0 2px palette.$blueberry500;
|
|
187
|
-
z-index: 1;
|
|
188
|
-
|
|
189
|
-
&--open {
|
|
190
|
-
display: block;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
&__options {
|
|
195
|
-
overflow: hidden auto;
|
|
196
|
-
max-height: 384px;
|
|
197
|
-
list-style: none;
|
|
198
|
-
padding: 0;
|
|
199
|
-
margin: 0;
|
|
200
|
-
|
|
201
|
-
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
202
|
-
max-height: 464px;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
&__close {
|
|
207
|
-
padding: spacers.getSpacer(s);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
&__input {
|
|
211
|
-
border-bottom: 1px solid palette.$neutral300;
|
|
212
|
-
padding: 0 spacers.getSpacer(s);
|
|
213
|
-
|
|
214
|
-
&[role='menuitemradio'] {
|
|
215
|
-
padding: 0 spacers.getSpacer(s);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
&[role='menuitemcheckbox'] {
|
|
219
|
-
padding: 1px spacers.getSpacer(s) spacers.getSpacer(2xs) spacers.getSpacer(s);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
223
|
-
padding: spacers.getSpacer(s);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
&:last-child {
|
|
227
|
-
border-bottom: none;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type Styles = {
|
|
2
|
-
dropdown: string;
|
|
3
|
-
dropdown__close: string;
|
|
4
|
-
dropdown__content: string;
|
|
5
|
-
'dropdown__content--open': string;
|
|
6
|
-
dropdown__icon: string;
|
|
7
|
-
dropdown__input: string;
|
|
8
|
-
dropdown__label: string;
|
|
9
|
-
dropdown__options: string;
|
|
10
|
-
dropdown__toggle: string;
|
|
11
|
-
dropdown__toggle__label: string;
|
|
12
|
-
'dropdown__toggle--fluid': string;
|
|
13
|
-
'dropdown__toggle--on-blueberry': string;
|
|
14
|
-
'dropdown__toggle--on-cherry': string;
|
|
15
|
-
'dropdown__toggle--on-grey': string;
|
|
16
|
-
'dropdown__toggle--on-white': string;
|
|
17
|
-
'dropdown__toggle--open': string;
|
|
18
|
-
'dropdown__toggle--transparent': string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ClassNames = keyof Styles;
|
|
22
|
-
|
|
23
|
-
declare const styles: Styles;
|
|
24
|
-
|
|
25
|
-
export default styles;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { PanelOldVariant } from '../PanelOld';
|
|
3
|
-
export interface PanelListOldProps {
|
|
4
|
-
/** Panels to render inside the PanelList */
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
/** Changes the visual representation of the panel. Default: fill */
|
|
7
|
-
variant?: keyof typeof PanelOldVariant;
|
|
8
|
-
/** Sets the data-testid attribute. */
|
|
9
|
-
testId?: string;
|
|
10
|
-
}
|
|
11
|
-
declare const PanelListOld: React.ForwardRefExoticComponent<PanelListOldProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
-
export default PanelListOld;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default from "react";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { AnalyticsId } from "../../constants.js";
|
|
5
|
-
import { b as PanelOldVariant, P as PanelOld } from "../../PanelOld.js";
|
|
6
|
-
import styles from "./styles.module.scss";
|
|
7
|
-
const isPanelComponent = (element) => React__default.isValidElement(element) && element.type === PanelOld;
|
|
8
|
-
const PanelListOld = React__default.forwardRef(function BadgeForwardedRef(props, ref) {
|
|
9
|
-
const { testId, children, variant = PanelOldVariant.fill } = props;
|
|
10
|
-
const renderPanel = (panel, firstChild) => React__default.cloneElement(panel, {
|
|
11
|
-
variant,
|
|
12
|
-
noTopBorder: variant === PanelOldVariant.line && !firstChild,
|
|
13
|
-
className: classNames(panel.props.className, variant !== PanelOldVariant.line && styles["panel-list__panel"])
|
|
14
|
-
});
|
|
15
|
-
return /* @__PURE__ */ jsx("div", { ref, "data-testid": testId, "data-analyticsid": AnalyticsId.PanelList, children: React__default.Children.map(children, (child, index) => isPanelComponent(child) ? renderPanel(child, index === 0) : child) });
|
|
16
|
-
});
|
|
17
|
-
export {
|
|
18
|
-
PanelListOld as default
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/PanelListOld/PanelListOld.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport PanelOld, { PanelOldProps, PanelOldVariant } from '../PanelOld';\n\nimport styles from './styles.module.scss';\n\nexport interface PanelListOldProps {\n /** Panels to render inside the PanelList */\n children?: React.ReactNode;\n /** Changes the visual representation of the panel. Default: fill */\n variant?: keyof typeof PanelOldVariant;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst isPanelComponent = (element: unknown | null | undefined): element is React.ReactElement<PanelOldProps> =>\n React.isValidElement<PanelOldProps>(element) && (element as React.ReactElement).type === PanelOld;\n\nconst PanelListOld = React.forwardRef(function BadgeForwardedRef(props: PanelListOldProps, ref: React.ForwardedRef<HTMLDivElement>) {\n const { testId, children, variant = PanelOldVariant.fill } = props;\n\n const renderPanel = (panel: React.ReactElement<PanelOldProps>, firstChild: boolean): React.ReactElement =>\n React.cloneElement(panel, {\n variant: variant,\n noTopBorder: variant === PanelOldVariant.line && !firstChild,\n className: classNames(panel.props.className, variant !== PanelOldVariant.line && styles['panel-list__panel']),\n });\n\n return (\n <div ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.PanelList}>\n {React.Children.map(children, (child, index) => (isPanelComponent(child) ? renderPanel(child, index === 0) : child))}\n </div>\n );\n});\n\nexport default PanelListOld;\n"],"names":["React"],"mappings":";;;;;;AAkBA,MAAM,mBAAmB,CAAC,YACxBA,eAAM,eAA8B,OAAO,KAAM,QAA+B,SAAS;AAE3F,MAAM,eAAeA,eAAM,WAAW,SAAS,kBAAkB,OAA0B,KAAyC;AAClI,QAAM,EAAE,QAAQ,UAAU,UAAU,gBAAgB,SAAS;AAE7D,QAAM,cAAc,CAAC,OAA0C,eAC7DA,eAAM,aAAa,OAAO;AAAA,IACxB;AAAA,IACA,aAAa,YAAY,gBAAgB,QAAQ,CAAC;AAAA,IAClD,WAAW,WAAW,MAAM,MAAM,WAAW,YAAY,gBAAgB,QAAQ,OAAO,mBAAmB,CAAC;AAAA,EAAA,CAC7G;AAEH,SACE,oBAAC,OAAA,EAAI,KAAU,eAAa,QAAQ,oBAAkB,YAAY,WAC/D,UAAAA,eAAM,SAAS,IAAI,UAAU,CAAC,OAAO,UAAW,iBAAiB,KAAK,IAAI,YAAY,OAAO,UAAU,CAAC,IAAI,KAAM,EAAA,CACrH;AAEJ,CAAC;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
@use '../../scss/spacers' as spacers;
|
|
3
|
-
@use '../../scss/palette' as palette;
|
|
4
|
-
@use '../../scss/breakpoints' as breakpoints;
|
|
5
|
-
|
|
6
|
-
.panel-list {
|
|
7
|
-
&__panel:not(:last-child) {
|
|
8
|
-
margin-bottom: spacers.getSpacer(2xs);
|
|
9
|
-
|
|
10
|
-
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
11
|
-
margin-bottom: spacers.getSpacer(s);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|