@helsenorge/designsystem-react 7.1.0 → 7.2.1
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 +31 -3
- package/components/AnchorLink/AnchorLink.stories.d.ts +1 -0
- package/components/Avatar/Avatar.stories.d.ts +2 -0
- package/components/Badge/Badge.stories.d.ts +2 -0
- package/components/Button/Button.js +21 -21
- package/components/Button/Button.js.map +1 -1
- package/components/Checkbox/Checkbox.stories.d.ts +1 -0
- package/components/Close/Close.stories.d.ts +1 -0
- package/components/DictionaryTrigger/DictionaryTrigger.stories.d.ts +1 -0
- package/components/Dropdown/Dropdown.js +17 -17
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.stories.d.ts +1 -0
- package/components/Duolist/Duolist.stories.d.ts +1 -0
- package/components/Duolist/styles.module.scss +19 -19
- package/components/EmptyState/EmptyState.stories.d.ts +1 -0
- package/components/Expander/Expander.stories.d.ts +1 -0
- package/components/Expander/styles.module.scss +13 -13
- package/components/ExpanderHierarchy/ExpanderHierarchy.stories.d.ts +1 -0
- package/components/ExpanderList/ExpanderList.stories.d.ts +2 -0
- package/components/FormGroup/FormGroup.stories.d.ts +1 -0
- package/components/FormLayout/FormLayout.stories.d.ts +1 -0
- package/components/GridExample/GridExample.js +2 -5
- package/components/GridExample/GridExample.js.map +1 -1
- package/components/HelpBubble/HelpBubble.stories.d.ts +1 -0
- package/components/HelpPanel/HelpPanel.stories.d.ts +1 -0
- package/components/HelpQuestion/HelpQuestion.stories.d.ts +1 -0
- package/components/HighlightBox/HighlightBox.stories.d.ts +1 -0
- package/components/HorizontalScroll/styles.module.scss +2 -0
- package/components/Icon/Icon.stories.d.ts +1 -0
- package/components/Illustration/Illustration.stories.d.ts +1 -0
- package/components/Illustration/Illustrations.stories.d.ts +1 -0
- package/components/Input/Input.stories.d.ts +1 -0
- package/components/Label/Label.stories.d.ts +1 -0
- package/components/LazyIcon/LazyIcon.stories.d.ts +1 -0
- package/components/LazyIllustration/LazyIllustration.stories.d.ts +1 -0
- package/components/LinkList/LinkList.stories.d.ts +2 -0
- package/components/List/styles.module.scss +6 -0
- package/components/Loader/Loader.stories.d.ts +1 -0
- package/components/Logo/Logo.stories.d.ts +1 -0
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +1 -0
- package/components/Panel/Panel.stories.d.ts +1 -0
- package/components/PanelList/PanelList.stories.d.ts +1 -0
- package/components/PopMenu/PopMenu.stories.d.ts +1 -0
- package/components/PopMenu/styles.module.scss +7 -8
- package/components/PopOver/styles.module.scss +4 -4
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.stories.d.ts +1 -0
- package/components/Select/Select.stories.d.ts +1 -0
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -0
- package/components/SharingStatus/SharingStatus.stories.d.ts +1 -0
- package/components/Slider/Slider.stories.d.ts +1 -0
- package/components/Spacer/Spacer.stories.d.ts +1 -0
- package/components/StatusDot/StatusDot.stories.d.ts +1 -0
- package/components/Step/Step.stories.d.ts +1 -0
- package/components/StepButtons/StepButtons.stories.d.ts +1 -0
- package/components/Stepper/Stepper.stories.d.ts +1 -0
- package/components/Table/Table.stories.d.ts +1 -0
- package/components/Tag/Tag.stories.d.ts +1 -0
- package/components/TagList/TagList.stories.d.ts +1 -0
- package/components/Textarea/Textarea.stories.d.ts +1 -0
- package/components/Tile/Tile.stories.d.ts +2 -0
- package/components/Title/Title.stories.d.ts +1 -0
- package/components/Tooltip/Tooltip.stories.d.ts +1 -0
- package/components/Trigger/Trigger.stories.d.ts +1 -0
- package/components/Validation/Validation.stories.d.ts +2 -1
- package/docs/index.d.ts +1 -0
- package/docs/index.js +9 -4
- package/docs/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [7.2.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.1.0&targetVersion=GTv7.2.0) (2024-04-19)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- knappen i dropdown skal ikke være fluid
|
|
6
|
+
([a3abe2b](https://github.com/helsenorge/designsystem/commit/a3abe2bf5a57e62302b5e4f1a1f1b609452effd0)), closes
|
|
7
|
+
[#323389](https://github.com/helsenorge/designsystem/issues/323389)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- bruk supernova-sjekk som funker i ff
|
|
12
|
+
([afae2a9](https://github.com/helsenorge/designsystem/commit/afae2a90d9e453be054016b5922aa378500f91cc))
|
|
13
|
+
- oppdater sjekk for om vi er i superNova
|
|
14
|
+
([b20a776](https://github.com/helsenorge/designsystem/commit/b20a776f293953d78ccab6e40d687bab67676a28))
|
|
15
|
+
- oppdater sjekk for om vi er i superNova
|
|
16
|
+
([167d572](https://github.com/helsenorge/designsystem/commit/167d572261a91fd60a8c432d4d990356a610115f))
|
|
17
|
+
|
|
18
|
+
## [7.1.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.0.0&targetVersion=GTv7.1.0) (2024-04-17)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- badge innstramming av tilgjengelige farger
|
|
23
|
+
([193ec66](https://github.com/helsenorge/designsystem/commit/193ec6633394354505a60147668800269b51feae)), closes
|
|
24
|
+
[#308135](https://github.com/helsenorge/designsystem/issues/308135)
|
|
25
|
+
- ny default breddehåndtering for Dropdown
|
|
26
|
+
([6078613](https://github.com/helsenorge/designsystem/commit/6078613bf8bae571eb582f9778b8c4a494d3339d)), closes
|
|
27
|
+
[#323389](https://github.com/helsenorge/designsystem/issues/323389)
|
|
28
|
+
|
|
1
29
|
## [7.0.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv6.6.2&targetVersion=GTv7.0.0) (2024-04-08)
|
|
2
30
|
|
|
3
31
|
## 7.0.0-beta.7 (2024-04-05)
|
|
@@ -1349,12 +1377,12 @@ Dette er fordi vi skal kunne dynamisk importere alt som ligger i Icons, så da b
|
|
|
1349
1377
|
|
|
1350
1378
|
### Bug Fixes
|
|
1351
1379
|
|
|
1352
|
-
- panel har avstand fra tittel til badge
|
|
1353
|
-
([09034c4](https://github.com/helsenorge/designsystem/commit/09034c4844408c7cfe8f65d7a1a0d82a7828c2ef)), closes
|
|
1354
|
-
[#282359](https://github.com/helsenorge/designsystem/issues/282359)
|
|
1355
1380
|
- økt kontrast på understreking av lenker
|
|
1356
1381
|
([50b7fa4](https://github.com/helsenorge/designsystem/commit/50b7fa47fb44cb7d75fb877bd53e2309b35e1e21)), closes
|
|
1357
1382
|
[#229049](https://github.com/helsenorge/designsystem/issues/229049)
|
|
1383
|
+
- panel har avstand fra tittel til badge
|
|
1384
|
+
([09034c4](https://github.com/helsenorge/designsystem/commit/09034c4844408c7cfe8f65d7a1a0d82a7828c2ef)), closes
|
|
1385
|
+
[#282359](https://github.com/helsenorge/designsystem/issues/282359)
|
|
1358
1386
|
|
|
1359
1387
|
## [1.2.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv1.2.1&targetVersion=GTv1.2.2) (2022-08-31)
|
|
1360
1388
|
|
|
@@ -5,6 +5,7 @@ declare const meta: {
|
|
|
5
5
|
component: React.ForwardRefExoticComponent<import("./AnchorLink").AnchorLinkProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
6
6
|
parameters: {
|
|
7
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
8
9
|
description: {
|
|
9
10
|
component: string;
|
|
10
11
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
import { AvatarSize } from './Avatar';
|
|
3
4
|
declare const meta: {
|
|
@@ -5,6 +6,7 @@ declare const meta: {
|
|
|
5
6
|
component: import("./Avatar").AvatarType;
|
|
6
7
|
parameters: {
|
|
7
8
|
docs: {
|
|
9
|
+
page: () => React.JSX.Element;
|
|
8
10
|
description: {
|
|
9
11
|
component: string;
|
|
10
12
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./Badge").BadgeType;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import o, { useRef as lt, useEffect as ct } from "react";
|
|
2
|
-
import
|
|
2
|
+
import d from "classnames";
|
|
3
3
|
import { Icon as it } from "../Icon/Icon.js";
|
|
4
4
|
import { AnalyticsId as $, IconSize as v } from "../../constants.js";
|
|
5
5
|
import { useBreakpoint as ut } from "../../hooks/useBreakpoint.js";
|
|
@@ -7,16 +7,16 @@ import { useHover as D } from "../../hooks/useHover.js";
|
|
|
7
7
|
import { useIcons as mt } from "../../hooks/useIcons.js";
|
|
8
8
|
import { getColor as i } from "../../theme/currys/color.js";
|
|
9
9
|
import { breakpoints as bt } from "../../theme/grid.js";
|
|
10
|
-
import { isTest as
|
|
10
|
+
import { isTest as dt, isProd as pt } from "../../utils/environment.js";
|
|
11
11
|
import ft from "../Icons/ArrowRight.js";
|
|
12
12
|
import t from "../Button/styles.module.scss";
|
|
13
|
-
const ht = (e, r, n,
|
|
13
|
+
const ht = (e, r, n, p, a, g) => g && n ? !a || e ? i("neutral", r ? 500 : 700) : i("white") : n ? !a || e ? i("neutral", 500) : `${i("white")}b3` : e && !a || !e && a ? "white" : p === "normal" ? i("blueberry", 600) : i("cherry", 500), N = (e, r) => r && e ? v.Small : e ? v.Medium : v.XSmall, gt = (e, r, n) => {
|
|
14
14
|
if (n && e && (r === void 0 || r === ""))
|
|
15
15
|
throw new Error("Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav");
|
|
16
16
|
}, _t = o.forwardRef(function(r, n) {
|
|
17
17
|
const {
|
|
18
|
-
ariaLabel:
|
|
19
|
-
id:
|
|
18
|
+
ariaLabel: p,
|
|
19
|
+
id: a,
|
|
20
20
|
children: g,
|
|
21
21
|
wrapperClassName: O,
|
|
22
22
|
className: X,
|
|
@@ -37,11 +37,11 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
37
37
|
target: U,
|
|
38
38
|
type: J = "button",
|
|
39
39
|
...F
|
|
40
|
-
} = r, [u, m, H] = mt(o.Children.toArray(g)), { hoverRef: L, isHovered: K } = w === "button" ? D(n) : D(n), Q = lt(null),
|
|
40
|
+
} = r, [u, m, H] = mt(o.Children.toArray(g)), { hoverRef: L, isHovered: K } = w === "button" ? D(n) : D(n), Q = lt(null), s = !!(u || m) && !H, M = u && (m || _) && !s, y = j === "ondark", h = ut() < bt.md, P = B === "destructive" && !f, Y = I === "outline", l = I === "borderless", T = ht(I === "fill", l, f, B, y, h), C = _ === "icon" && !l, b = q === "large" && !P && !l, Z = _ === "accessibility-character" && !A && !u && !m && !C && l, tt = { ...F }, V = d(
|
|
41
41
|
t["button-wrapper"],
|
|
42
42
|
{ [t["button-wrapper--fluid"]]: A || R },
|
|
43
43
|
O
|
|
44
|
-
), ot =
|
|
44
|
+
), ot = d(
|
|
45
45
|
t.button,
|
|
46
46
|
{
|
|
47
47
|
[t["button--destructive"]]: P,
|
|
@@ -49,36 +49,36 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
49
49
|
[t["button--large"]]: b,
|
|
50
50
|
[t["button--outline"]]: Y,
|
|
51
51
|
[t["button--borderless"]]: l,
|
|
52
|
-
[t["button--left-icon"]]: u && !
|
|
53
|
-
[t["button--right-icon"]]: m && !
|
|
52
|
+
[t["button--left-icon"]]: u && !s,
|
|
53
|
+
[t["button--right-icon"]]: m && !s,
|
|
54
54
|
[t["button--both-icons"]]: M,
|
|
55
|
-
[t["button--only-icon"]]:
|
|
55
|
+
[t["button--only-icon"]]: s,
|
|
56
56
|
[t["button--arrow"]]: C,
|
|
57
57
|
[t["button--on-dark"]]: y
|
|
58
58
|
},
|
|
59
59
|
X
|
|
60
|
-
), et =
|
|
60
|
+
), et = d(t.button__text, {
|
|
61
61
|
[t["button__text--ellipsis"]]: R
|
|
62
|
-
}), rt =
|
|
62
|
+
}), rt = d(t.diagonal, {
|
|
63
63
|
[t["diagonal--on-dark"]]: y
|
|
64
64
|
});
|
|
65
65
|
ct(() => {
|
|
66
|
-
gt(
|
|
66
|
+
gt(s, p, !dt() && !pt());
|
|
67
67
|
}, []);
|
|
68
|
-
const k = (c,
|
|
69
|
-
size:
|
|
68
|
+
const k = (c, at, st) => c ? o.cloneElement(c, {
|
|
69
|
+
size: at,
|
|
70
70
|
color: c != null && c.props.color ? c.props.color : T,
|
|
71
71
|
isHovered: K,
|
|
72
|
-
className:
|
|
73
|
-
}) : null, nt = () => /* @__PURE__ */ o.createElement("span", { className: et, ref: Q }, f && l && /* @__PURE__ */ o.createElement("span", { className: rt }, /* @__PURE__ */ o.createElement("span", { className: t.diagonal__line })), /* @__PURE__ */ o.createElement("span", null,
|
|
72
|
+
className: st
|
|
73
|
+
}) : null, nt = () => /* @__PURE__ */ o.createElement("span", { className: et, ref: Q }, f && l && /* @__PURE__ */ o.createElement("span", { className: rt }, /* @__PURE__ */ o.createElement("span", { className: t.diagonal__line })), /* @__PURE__ */ o.createElement("span", null, s ? p : H)), W = () => /* @__PURE__ */ o.createElement("span", { className: ot }, k(u, N(b, h), s ? void 0 : t["button__left-icon"]), nt(), C ? k(
|
|
74
74
|
/* @__PURE__ */ o.createElement(it, { svgIcon: ft }),
|
|
75
75
|
N(b, h),
|
|
76
|
-
|
|
77
|
-
) : k(m, N(b, h), t["button__right-icon"]), Z && /* @__PURE__ */ o.createElement("span", { style: { color: T }, className: t["button__right-unicode-arrow"] }, " →"));
|
|
76
|
+
d(t.button__arrow, { [t["button__arrow--both-icons"]]: M })
|
|
77
|
+
) : k(m, N(b, h), t["button__right-icon"]), Z && /* @__PURE__ */ o.createElement("span", { style: { color: T }, className: t["button__right-unicode-arrow"], "aria-hidden": !0 }, " →"));
|
|
78
78
|
return /* @__PURE__ */ o.createElement(o.Fragment, null, w === "button" && /* @__PURE__ */ o.createElement(
|
|
79
79
|
"button",
|
|
80
80
|
{
|
|
81
|
-
id:
|
|
81
|
+
id: a,
|
|
82
82
|
onBlur: E,
|
|
83
83
|
onClick: x,
|
|
84
84
|
disabled: f,
|
|
@@ -94,7 +94,7 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
94
94
|
), w === "a" && /* @__PURE__ */ o.createElement(
|
|
95
95
|
"a",
|
|
96
96
|
{
|
|
97
|
-
id:
|
|
97
|
+
id: a,
|
|
98
98
|
onBlur: E,
|
|
99
99
|
onClick: x,
|
|
100
100
|
"data-testid": z,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color ? iconElement.props.color : iconColor,\n isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, mobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']}>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onBlur","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","hasUURightArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","renderButtonContent","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":";;;;;;;;;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AAA,IAC9BqD,EAAWC,EAAa,eAAkB,EAAE,CAACA,EAAa,2BAA2B,CAAC,GAAGb,GAAW;AAAA,EACtG,IACAoB,EAAW5B,GAAW/B,EAAiBC,GAAOH,CAAM,GAAGsD,EAAa,oBAAoB,CAAC,GAC5FJ,qCACE,QAAK,EAAA,OAAO,EAAE,OAAOF,EAAU,GAAG,WAAWM,EAAa,6BAA6B,KACrF,KACH,CAEJ;AAIA,SAAA5C,gBAAAA,EAAA,cAAAA,EAAA,UAAA,MACGU,MAAe,YACdV,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,QAAAS;AAAA,MACA,SAAAC;AAAA,MACA,UAAA1B;AAAA,MACA,eAAa+B;AAAA,MACb,oBAAkByC,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,KAAKhB;AAAA,MACL,UAAAT;AAAA,MACA,MAAAG;AAAA,MACC,GAAGqB;AAAA,IAAA;AAAA,IAEHe,EAA2B;AAAA,EAAA,GAG/B9C,MAAe,OACdV,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,QAAAS;AAAA,MACA,SAAAC;AAAA,MACA,eAAaK;AAAA,MACb,oBAAkByC,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,MAAA1B;AAAA,MACA,QAAAG;AAAA,MACA,KAAKA,MAAW,WAAW,wBAAwBlB,EAAM;AAAA,MACzD,KAAKyB;AAAA,MACL,UAAAT;AAAA,MACC,GAAGI;AAAA,IAAA;AAAA,IAEHmC,EAA2B;AAAA,EAAA,CAGlC;AAEJ,CAAC,GAEDI,KAAe7D;"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color ? iconElement.props.color : iconColor,\n isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, mobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']} aria-hidden>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onBlur","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","hasUURightArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","renderButtonContent","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":";;;;;;;;;;;;AA8DA,MAAMA,KAAe,CACnBC,GACAC,GACAC,GACAC,GACAC,GACAC,MAEIA,KAAUH,IACL,CAACE,KAAUJ,IAAOM,EAAS,WAAYL,IAAmB,MAAN,GAAS,IAAIK,EAAS,OAAO,IAEtFJ,IACK,CAACE,KAAUJ,IAAOM,EAAS,WAAW,GAAG,IAAI,GAAGA,EAAS,OAAO,CAAC,OAErEN,KAAQ,CAACI,KAAY,CAACJ,KAAQI,IAC1B,UAGFD,MAAY,WAAWG,EAAS,aAAa,GAAG,IAAIA,EAAS,UAAU,GAAG,GAE7EC,IAAmB,CAACC,GAAgBH,MACpCA,KAAUG,IAAcC,EAAS,QACjCD,IAAcC,EAAS,SACpBA,EAAS,QAGZC,KAAoB,CAACC,GAAmBC,GAA+BC,MAA0B;AACrG,MAAIA,KAAUF,MAAaC,MAAc,UAAaA,MAAc;AAC5D,UAAA,IAAI,MAAM,yEAAyE;AAE7F,GAEME,KAASC,EAAM,WAAW,SAC9BC,GACAC,GACA;AACM,QAAA;AAAA,IACJ,WAAAL;AAAA,IACA,IAAAM;AAAA,IACA,UAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAnB,IAAU;AAAA,IACV,UAAAD,IAAW;AAAA,IACX,UAAAqB,IAAW;AAAA,IACX,OAAAC,IAAQ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;AAAA,MACX,MAAA1B;AAAA,MACA,QAAAG;AAAA,MACA,KAAKA,MAAW,WAAW,wBAAwBlB,EAAM;AAAA,MACzD,KAAKyB;AAAA,MACL,UAAAT;AAAA,MACC,GAAGI;AAAA,IAAA;AAAA,IAEHmC,EAA2B;AAAA,EAAA,CAGlC;AAEJ,CAAC,GAEDI,KAAe7D;"}
|
|
@@ -23,16 +23,16 @@ const re = (d) => {
|
|
|
23
23
|
onToggle: O,
|
|
24
24
|
open: $ = !1,
|
|
25
25
|
children: _,
|
|
26
|
-
mode:
|
|
26
|
+
mode: i = "onwhite",
|
|
27
27
|
transparent: S = !1,
|
|
28
28
|
fluid: y = !1,
|
|
29
29
|
testId: z,
|
|
30
|
-
disabled:
|
|
30
|
+
disabled: c,
|
|
31
31
|
zIndex: D = G.PopOver
|
|
32
|
-
} = d, p = f(null), b = f(null), { hoverRef: w, isHovered: L } = Z(), { value: l, toggleValue: h } = j(!
|
|
32
|
+
} = d, p = f(null), b = f(null), { hoverRef: w, isHovered: L } = Z(), { value: l, toggleValue: h } = j(!c && $, O), a = f(r.Children.map(_, () => r.createRef())), [m, P] = X(), E = g(), I = g(), x = g(), v = () => {
|
|
33
33
|
var e;
|
|
34
34
|
h(), (e = b.current) == null || e.focus();
|
|
35
|
-
},
|
|
35
|
+
}, u = () => {
|
|
36
36
|
var e;
|
|
37
37
|
h(), (e = w.current) == null || e.focus();
|
|
38
38
|
};
|
|
@@ -42,7 +42,7 @@ const re = (d) => {
|
|
|
42
42
|
return;
|
|
43
43
|
if (l) {
|
|
44
44
|
if (e.key === n.Escape && l) {
|
|
45
|
-
|
|
45
|
+
u();
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
} else {
|
|
@@ -59,19 +59,19 @@ const re = (d) => {
|
|
|
59
59
|
n.Enter,
|
|
60
60
|
n.Escape,
|
|
61
61
|
n.Home
|
|
62
|
-
]), F(p, () => l &&
|
|
62
|
+
]), F(p, () => l && u());
|
|
63
63
|
const T = k(
|
|
64
64
|
o.dropdown__toggle,
|
|
65
|
-
!
|
|
66
|
-
[o["dropdown__toggle--on-white"]]:
|
|
67
|
-
[o["dropdown__toggle--on-grey"]]:
|
|
68
|
-
[o["dropdown__toggle--on-blueberry"]]:
|
|
69
|
-
[o["dropdown__toggle--on-cherry"]]:
|
|
65
|
+
!c && {
|
|
66
|
+
[o["dropdown__toggle--on-white"]]: i === "onwhite",
|
|
67
|
+
[o["dropdown__toggle--on-grey"]]: i === "ongrey",
|
|
68
|
+
[o["dropdown__toggle--on-blueberry"]]: i === "onblueberry",
|
|
69
|
+
[o["dropdown__toggle--on-cherry"]]: i === "oncherry",
|
|
70
70
|
[o["dropdown__toggle--transparent"]]: S,
|
|
71
71
|
[o["dropdown__toggle--fluid"]]: y,
|
|
72
72
|
[o["dropdown__toggle--open"]]: l
|
|
73
73
|
}
|
|
74
|
-
), U = k(o.dropdown__content, l && o["dropdown__content--open"]), B = r.Children.map(_, (e, t) => /* @__PURE__ */ r.createElement("li", { className: o.dropdown__input, role: "option", id: `${x}-${t}`, "aria-selected": t ===
|
|
74
|
+
), U = k(o.dropdown__content, l && o["dropdown__content--open"]), B = r.Children.map(_, (e, t) => /* @__PURE__ */ r.createElement("li", { className: o.dropdown__input, role: "option", id: `${x}-${t}`, "aria-selected": t === m }, r.isValidElement(e) && a.current && a.current[t] ? r.cloneElement(e, { ref: W([e.props.ref, a.current[t]]) }) : e));
|
|
75
75
|
return /* @__PURE__ */ r.createElement("div", { className: o.dropdown, ref: p }, /* @__PURE__ */ r.createElement("span", { id: E, className: o.dropdown__label }, R), /* @__PURE__ */ r.createElement(
|
|
76
76
|
"button",
|
|
77
77
|
{
|
|
@@ -81,7 +81,7 @@ const re = (d) => {
|
|
|
81
81
|
ref: w,
|
|
82
82
|
"data-testid": z,
|
|
83
83
|
"data-analyticsid": J.Dropdown,
|
|
84
|
-
disabled:
|
|
84
|
+
disabled: c,
|
|
85
85
|
"aria-labelledby": I,
|
|
86
86
|
"aria-haspopup": "listbox",
|
|
87
87
|
"aria-expanded": l
|
|
@@ -90,10 +90,10 @@ const re = (d) => {
|
|
|
90
90
|
/* @__PURE__ */ r.createElement(
|
|
91
91
|
M,
|
|
92
92
|
{
|
|
93
|
-
color:
|
|
93
|
+
color: c ? C.palette.neutral700 : C.palette.blueberry600,
|
|
94
94
|
svgIcon: ee,
|
|
95
95
|
className: o.dropdown__icon,
|
|
96
|
-
isHovered: !
|
|
96
|
+
isHovered: !c && L,
|
|
97
97
|
size: Q.XSmall
|
|
98
98
|
}
|
|
99
99
|
)
|
|
@@ -104,11 +104,11 @@ const re = (d) => {
|
|
|
104
104
|
role: "listbox",
|
|
105
105
|
"aria-labelledby": E,
|
|
106
106
|
tabIndex: -1,
|
|
107
|
-
"aria-activedescendant": typeof
|
|
107
|
+
"aria-activedescendant": typeof m < "u" ? `${x}-${m}` : void 0,
|
|
108
108
|
ref: b
|
|
109
109
|
},
|
|
110
110
|
B
|
|
111
|
-
), !K && /* @__PURE__ */ r.createElement("div", { className: o.dropdown__close }, /* @__PURE__ */ r.createElement(Y, { onClick:
|
|
111
|
+
), !K && /* @__PURE__ */ r.createElement("div", { className: o.dropdown__close }, /* @__PURE__ */ r.createElement(Y, { onClick: u, "aria-expanded": l }, H))));
|
|
112
112
|
}, we = re;
|
|
113
113
|
export {
|
|
114
114
|
oe as DropdownMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n ZIndex,\n theme,\n useHover,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n useUuid,\n} from '../..';\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 DropdownMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n\nexport interface DropdownProps {\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 /** Close button text */\n closeText?: string;\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 mode?: keyof typeof DropdownMode;\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}\n\nconst Dropdown: React.FC<DropdownProps> = props => {\n const {\n label,\n placeholder,\n closeText = 'Lukk',\n noCloseButton = false,\n onToggle,\n open = false,\n children,\n mode = DropdownMode.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { hoverRef: buttonRef, isHovered } = useHover<HTMLButtonElement>();\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const [currentIndex, setCurrentIndex] = useState<number>();\n const labelId = useUuid();\n const toggleLabelId = useUuid();\n const optionIdPrefix = useUuid();\n\n const handleOpen = (): void => {\n toggleIsOpen();\n optionsRef.current?.focus();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n event.preventDefault();\n\n if (!inputRefList.current) {\n return;\n }\n\n if (!isOpen) {\n handleOpen();\n return;\n } else if (event.key === KeyboardEventKey.Escape && isOpen) {\n handleClose();\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 if (nextIndex !== -1) {\n inputRefList.current[nextIndex].current?.focus();\n setCurrentIndex(nextIndex);\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 ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: mode === DropdownMode.onwhite,\n [styles['dropdown__toggle--on-grey']]: mode === DropdownMode.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: mode === DropdownMode.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: mode === DropdownMode.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 <li className={styles.dropdown__input} role=\"option\" id={`${optionIdPrefix}-${index}`} aria-selected={index === currentIndex}>\n {React.isValidElement(child) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(child as React.ReactElement, { ref: mergeRefs([child.props.ref, inputRefList.current[index]]) })\n : child}\n </li>\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 => !isOpen && handleOpen()}\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=\"listbox\"\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 className={contentClasses} style={{ width: fluid ? '100%' : `auto`, zIndex: zIndex }}>\n <ul\n className={styles.dropdown__options}\n role=\"listbox\"\n aria-labelledby={labelId}\n tabIndex={-1}\n aria-activedescendant={typeof currentIndex !== 'undefined' ? `${optionIdPrefix}-${currentIndex}` : undefined}\n ref={optionsRef}\n >\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose} fluid aria-expanded={isOpen}>\n {closeText}\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"names":["DropdownMode","Dropdown","props","label","placeholder","closeText","noCloseButton","onToggle","open","children","mode","transparent","fluid","testId","disabled","zIndex","ZIndex","dropdownRef","useRef","optionsRef","buttonRef","isHovered","useHover","isOpen","toggleIsOpen","useToggle","inputRefList","React","currentIndex","setCurrentIndex","useState","labelId","useUuid","toggleLabelId","optionIdPrefix","handleOpen","_a","handleClose","useKeyboardEvent","event","KeyboardEventKey","index","x","nextIndex","useOutsideEvent","toggleClasses","classNames","styles","contentClasses","renderChildren","child","mergeRefs","AnalyticsId","Icon","theme","PlusSmall","IconSize","Button","Dropdown$1"],"mappings":";;;;;;;;;;;;;;;AAuBY,IAAAA,uBAAAA,OACVA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pC,IAAQ,SAAS,QAAQ,QAAAG,EACvE,EAAA,GAAAY,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWoB,EAAO;AAAA,MAClB,MAAK;AAAA,MACL,mBAAiBhB;AAAA,MACjB,UAAU;AAAA,MACV,yBAAuB,OAAOH,IAAiB,MAAc,GAAGM,CAAc,IAAIN,CAAY,KAAK;AAAA,MACnG,KAAKT;AAAA,IAAA;AAAA,IAEJ8B;AAAA,EAAA,GAEF,CAAC3C,qCACC,OAAI,EAAA,WAAWyC,EAAO,gBACrB,GAAApB,gBAAAA,EAAA,cAAC8B,KAAO,SAASpB,GAAa,OAAK,IAAC,iBAAed,KAChDlB,CACH,CACF,CAEJ,CACF;AAEJ,GAEAqD,KAAezD;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport {\n AnalyticsId,\n IconSize,\n KeyboardEventKey,\n ZIndex,\n theme,\n useHover,\n useKeyboardEvent,\n useOutsideEvent,\n useToggle,\n useUuid,\n} from '../..';\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 DropdownMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n oncherry = 'oncherry',\n}\n\nexport interface DropdownProps {\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 /** Close button text */\n closeText?: string;\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 mode?: keyof typeof DropdownMode;\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}\n\nconst Dropdown: React.FC<DropdownProps> = props => {\n const {\n label,\n placeholder,\n closeText = 'Lukk',\n noCloseButton = false,\n onToggle,\n open = false,\n children,\n mode = DropdownMode.onwhite,\n transparent = false,\n fluid = false,\n testId,\n disabled,\n zIndex = ZIndex.PopOver,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLUListElement>(null);\n const { hoverRef: buttonRef, isHovered } = useHover<HTMLButtonElement>();\n const { value: isOpen, toggleValue: toggleIsOpen } = useToggle(!disabled && open, onToggle);\n const inputRefList = useRef(React.Children.map(children, () => React.createRef<HTMLElement>()));\n const [currentIndex, setCurrentIndex] = useState<number>();\n const labelId = useUuid();\n const toggleLabelId = useUuid();\n const optionIdPrefix = useUuid();\n\n const handleOpen = (): void => {\n toggleIsOpen();\n optionsRef.current?.focus();\n };\n\n const handleClose = (): void => {\n toggleIsOpen();\n buttonRef.current?.focus();\n };\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n event.preventDefault();\n\n if (!inputRefList.current) {\n return;\n }\n\n if (!isOpen) {\n handleOpen();\n return;\n } else if (event.key === KeyboardEventKey.Escape && isOpen) {\n handleClose();\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 if (nextIndex !== -1) {\n inputRefList.current[nextIndex].current?.focus();\n setCurrentIndex(nextIndex);\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 ]);\n\n useOutsideEvent(dropdownRef, () => isOpen && handleClose());\n\n const toggleClasses = classNames(\n styles.dropdown__toggle,\n !disabled && {\n [styles['dropdown__toggle--on-white']]: mode === DropdownMode.onwhite,\n [styles['dropdown__toggle--on-grey']]: mode === DropdownMode.ongrey,\n [styles['dropdown__toggle--on-blueberry']]: mode === DropdownMode.onblueberry,\n [styles['dropdown__toggle--on-cherry']]: mode === DropdownMode.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 <li className={styles.dropdown__input} role=\"option\" id={`${optionIdPrefix}-${index}`} aria-selected={index === currentIndex}>\n {React.isValidElement(child) && inputRefList.current && inputRefList.current[index]\n ? React.cloneElement(child as React.ReactElement, { ref: mergeRefs([child.props.ref, inputRefList.current[index]]) })\n : child}\n </li>\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 => !isOpen && handleOpen()}\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=\"listbox\"\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 className={contentClasses} style={{ width: fluid ? '100%' : `auto`, zIndex: zIndex }}>\n <ul\n className={styles.dropdown__options}\n role=\"listbox\"\n aria-labelledby={labelId}\n tabIndex={-1}\n aria-activedescendant={typeof currentIndex !== 'undefined' ? `${optionIdPrefix}-${currentIndex}` : undefined}\n ref={optionsRef}\n >\n {renderChildren}\n </ul>\n {!noCloseButton && (\n <div className={styles.dropdown__close}>\n <Button onClick={handleClose} aria-expanded={isOpen}>\n {closeText}\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"names":["DropdownMode","Dropdown","props","label","placeholder","closeText","noCloseButton","onToggle","open","children","mode","transparent","fluid","testId","disabled","zIndex","ZIndex","dropdownRef","useRef","optionsRef","buttonRef","isHovered","useHover","isOpen","toggleIsOpen","useToggle","inputRefList","React","currentIndex","setCurrentIndex","useState","labelId","useUuid","toggleLabelId","optionIdPrefix","handleOpen","_a","handleClose","useKeyboardEvent","event","KeyboardEventKey","index","x","nextIndex","useOutsideEvent","toggleClasses","classNames","styles","contentClasses","renderChildren","child","mergeRefs","AnalyticsId","Icon","theme","PlusSmall","IconSize","Button","Dropdown$1"],"mappings":";;;;;;;;;;;;;;;AAuBY,IAAAA,uBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,cAAc,eACdA,EAAA,WAAW,YAJDA,IAAAA,MAAA,CAAA,CAAA;AAoCZ,MAAMC,KAAoC,CAASC,MAAA;AAC3C,QAAA;AAAA,IACJ,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,eAAAC,IAAgB;AAAA,IAChB,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,aAAAC,IAAc;AAAA,IACd,OAAAC,IAAQ;AAAA,IACR,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gBAAAA,EAAA,cAAA8B,GAAA,EAAO,SAASpB,GAAa,iBAAed,KAC1ClB,CACH,CACF,CAEJ,CACF;AAEJ,GAEAqD,KAAezD;"}
|
|
@@ -25,25 +25,6 @@
|
|
|
25
25
|
font-size: $font-size-md;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
&__dt,
|
|
29
|
-
&__dd {
|
|
30
|
-
line-height: $lineheight-size-md;
|
|
31
|
-
padding-bottom: getSpacer(2xs);
|
|
32
|
-
|
|
33
|
-
&:last-of-type {
|
|
34
|
-
padding-bottom: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&--bold {
|
|
38
|
-
font-weight: 600;
|
|
39
|
-
line-height: $lineheight-size-sm;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&--non-formatted {
|
|
43
|
-
display: inline;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
28
|
&__dt {
|
|
48
29
|
padding-right: getSpacer(l);
|
|
49
30
|
|
|
@@ -64,6 +45,25 @@
|
|
|
64
45
|
margin-inline-start: 0;
|
|
65
46
|
}
|
|
66
47
|
|
|
48
|
+
&__dt,
|
|
49
|
+
&__dd {
|
|
50
|
+
line-height: $lineheight-size-md;
|
|
51
|
+
padding-bottom: getSpacer(2xs);
|
|
52
|
+
|
|
53
|
+
&:last-of-type {
|
|
54
|
+
padding-bottom: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--bold {
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
line-height: $lineheight-size-sm;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&--non-formatted {
|
|
63
|
+
display: inline;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
67
|
&--line &__dt,
|
|
68
68
|
&--line &__dd {
|
|
69
69
|
padding-top: getSpacer(2xs);
|
|
@@ -34,6 +34,19 @@
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
&__button,
|
|
38
|
+
&__trigger {
|
|
39
|
+
&--sticky {
|
|
40
|
+
position: fixed;
|
|
41
|
+
top: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&--absolute {
|
|
45
|
+
position: absolute;
|
|
46
|
+
bottom: 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
&__button {
|
|
38
51
|
position: relative;
|
|
39
52
|
padding-right: getSpacer(s);
|
|
@@ -134,19 +147,6 @@
|
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
|
|
137
|
-
&__button,
|
|
138
|
-
&__trigger {
|
|
139
|
-
&--sticky {
|
|
140
|
-
position: fixed;
|
|
141
|
-
top: 0;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
&--absolute {
|
|
145
|
-
position: absolute;
|
|
146
|
-
bottom: 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
150
|
&__content {
|
|
151
151
|
$content: &;
|
|
152
152
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./ExpanderList").ExpanderListCompound;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import { isSupernova as r } from "../../docs/index.js";
|
|
3
|
-
const m = ({ gridLayout:
|
|
4
|
-
const n = r() || t === "padding";
|
|
5
|
-
return /* @__PURE__ */ e.createElement(e.Fragment, null, n && /* @__PURE__ */ e.createElement("div", { style: { padding: "0.5rem" } }, a), t === "helsenorge" && /* @__PURE__ */ e.createElement("div", { className: "container py-5" }, /* @__PURE__ */ e.createElement("div", { className: "row" }, /* @__PURE__ */ e.createElement("div", { className: "col" }, a))), t === "none" && a);
|
|
6
|
-
}, c = m;
|
|
3
|
+
const m = ({ gridLayout: a = r(), children: t }) => r() || a === "padding" ? /* @__PURE__ */ e.createElement("div", { style: { padding: "0.5rem" } }, t) : a === "helsenorge" ? /* @__PURE__ */ e.createElement("div", { className: "container py-5" }, /* @__PURE__ */ e.createElement("div", { className: "row" }, /* @__PURE__ */ e.createElement("div", { className: "col" }, t))) : /* @__PURE__ */ e.createElement(e.Fragment, null, t), s = m;
|
|
7
4
|
export {
|
|
8
5
|
m as GridExample,
|
|
9
|
-
|
|
6
|
+
s as default
|
|
10
7
|
};
|
|
11
8
|
//# sourceMappingURL=GridExample.js.map
|