@helsenorge/designsystem-react 7.7.0 → 7.8.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 +47 -3
- package/components/AnchorLink/styles.module.scss +6 -5
- package/components/Button/Button.d.ts +3 -0
- package/components/Button/Button.js +68 -66
- package/components/Button/Button.js.map +1 -1
- package/components/Button/styles.module.scss +6 -0
- package/components/Button/styles.module.scss.d.ts +1 -0
- package/components/Expander/styles.module.scss +1 -0
- package/components/ExpanderHierarchy/ExpanderHierarchy.stories.d.ts +13 -12
- package/components/List/List.stories.d.ts +19 -2
- package/components/Tabs/Tab.d.ts +17 -0
- package/components/Tabs/Tab.js +6 -0
- package/components/Tabs/Tab.js.map +1 -0
- package/components/Tabs/TabList/TabList.d.ts +11 -0
- package/components/Tabs/TabList/TabList.js +51 -0
- package/components/Tabs/TabList/TabList.js.map +1 -0
- package/components/Tabs/TabList/index.d.ts +3 -0
- package/components/Tabs/TabList/index.js +5 -0
- package/components/Tabs/TabList/index.js.map +1 -0
- package/components/Tabs/TabList/styles.module.scss +109 -0
- package/components/Tabs/TabList/styles.module.scss.d.ts +18 -0
- package/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
- package/components/Tabs/TabPanel/TabPanel.js +13 -0
- package/components/Tabs/TabPanel/TabPanel.js.map +1 -0
- package/components/Tabs/TabPanel/index.d.ts +3 -0
- package/components/Tabs/TabPanel/index.js +5 -0
- package/components/Tabs/TabPanel/index.js.map +1 -0
- package/components/Tabs/TabPanel/styles.module.scss +37 -0
- package/components/Tabs/TabPanel/styles.module.scss.d.ts +15 -0
- package/components/Tabs/Tabs.d.ts +22 -0
- package/components/Tabs/Tabs.js +19 -0
- package/components/Tabs/Tabs.js.map +1 -0
- package/components/Tabs/Tabs.stories.d.ts +50 -0
- package/components/Tabs/index.d.ts +3 -0
- package/components/Tabs/index.js +5 -0
- package/components/Tabs/index.js.map +1 -0
- package/components/Tabs/styles.module.scss +3 -0
- package/components/Tabs/styles.module.scss.d.ts +9 -0
- package/components/Tile/Tile.stories.d.ts +26 -2
- package/constants.d.ts +5 -1
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/docs/index.js +7 -7
- package/docs/index.js.map +1 -1
- package/hooks/useRovingFocus.d.ts +1 -0
- package/hooks/useRovingFocus.js +27 -0
- package/hooks/useRovingFocus.js.map +1 -0
- package/hooks/useRovingFocus.stories.d.ts +17 -0
- package/package.json +1 -1
- package/scss/typography.module.scss +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
## [7.8.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.7.0&targetVersion=GTv7.8.0) (2024-06-04)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **anchorlink:** sett underline med text decoration istedenfor border
|
|
6
|
+
([d3a8a53](https://github.com/helsenorge/designsystem/commit/d3a8a532094fec1187770beb570336edad0f47d0)), closes
|
|
7
|
+
[#324794](https://github.com/helsenorge/designsystem/issues/324794)
|
|
8
|
+
- **button:** ny prop textposition ([fb5fdba](https://github.com/helsenorge/designsystem/commit/fb5fdba4cd5390fdb8e9dd2a4c21c4180b282e50)),
|
|
9
|
+
closes [#325052](https://github.com/helsenorge/designsystem/issues/325052)
|
|
10
|
+
- **tabs:** ny komponent ([50eae16](https://github.com/helsenorge/designsystem/commit/50eae16394ccf26eff226563940fb18f5f84728b)), closes
|
|
11
|
+
[#297427](https://github.com/helsenorge/designsystem/issues/297427)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **button:** ikke hover effekt på ikon ved disabled
|
|
16
|
+
([ea79c60](https://github.com/helsenorge/designsystem/commit/ea79c605adcf77d6bfa4cb6ad9ab8ba88fba9166)), closes
|
|
17
|
+
[#325454](https://github.com/helsenorge/designsystem/issues/325454)
|
|
18
|
+
- **datepicker:** datevalue valideres riktig før den settes
|
|
19
|
+
([ec5422e](https://github.com/helsenorge/designsystem/commit/ec5422e1e744af6b4315e16edc5dfa2c066df54a)), closes
|
|
20
|
+
[#325330](https://github.com/helsenorge/designsystem/issues/325330)
|
|
21
|
+
- **expander:** cursor pointer på expander large
|
|
22
|
+
([2239314](https://github.com/helsenorge/designsystem/commit/2239314c0c582680f9bba0e19562433f534a202b)), closes
|
|
23
|
+
[#325072](https://github.com/helsenorge/designsystem/issues/325072)
|
|
24
|
+
|
|
25
|
+
## [7.7.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.6.0&targetVersion=GTv7.7.0) (2024-05-28)
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
- ny type notification Badge og tillates flere badges i ListHeader
|
|
30
|
+
([0768e0a](https://github.com/helsenorge/designsystem/commit/0768e0ae1d137f17ecfa92aa2b708ca52862e6b2)), closes
|
|
31
|
+
[#325119](https://github.com/helsenorge/designsystem/issues/325119)
|
|
32
|
+
- **expander:** bruk token på bakgrunn for liten expander
|
|
33
|
+
([73d8531](https://github.com/helsenorge/designsystem/commit/73d8531a52ed5a6387af8fa84045a0afd620eb38)), closes
|
|
34
|
+
[#324989](https://github.com/helsenorge/designsystem/issues/324989)
|
|
35
|
+
- **notificationpanel:** bruk Expander-komponent i NotificationPanel
|
|
36
|
+
([e8d4e8d](https://github.com/helsenorge/designsystem/commit/e8d4e8d776333f243cddba8f15742dd6f271bb3d)), closes
|
|
37
|
+
[#324989](https://github.com/helsenorge/designsystem/issues/324989)
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
- **expander:** manglende import av supernova stylesheet
|
|
42
|
+
([077ec2d](https://github.com/helsenorge/designsystem/commit/077ec2d1f59ce80076deeae5bc7911f7a9a2e431)), closes
|
|
43
|
+
[#324989](https://github.com/helsenorge/designsystem/issues/324989)
|
|
44
|
+
|
|
1
45
|
## [7.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.5.0&targetVersion=GTv7.6.0) (2024-05-15)
|
|
2
46
|
|
|
3
47
|
### Features
|
|
@@ -1448,12 +1492,12 @@ Dette er fordi vi skal kunne dynamisk importere alt som ligger i Icons, så da b
|
|
|
1448
1492
|
|
|
1449
1493
|
### Bug Fixes
|
|
1450
1494
|
|
|
1451
|
-
- panel har avstand fra tittel til badge
|
|
1452
|
-
([09034c4](https://github.com/helsenorge/designsystem/commit/09034c4844408c7cfe8f65d7a1a0d82a7828c2ef)), closes
|
|
1453
|
-
[#282359](https://github.com/helsenorge/designsystem/issues/282359)
|
|
1454
1495
|
- økt kontrast på understreking av lenker
|
|
1455
1496
|
([50b7fa4](https://github.com/helsenorge/designsystem/commit/50b7fa47fb44cb7d75fb877bd53e2309b35e1e21)), closes
|
|
1456
1497
|
[#229049](https://github.com/helsenorge/designsystem/issues/229049)
|
|
1498
|
+
- panel har avstand fra tittel til badge
|
|
1499
|
+
([09034c4](https://github.com/helsenorge/designsystem/commit/09034c4844408c7cfe8f65d7a1a0d82a7828c2ef)), closes
|
|
1500
|
+
[#282359](https://github.com/helsenorge/designsystem/issues/282359)
|
|
1457
1501
|
|
|
1458
1502
|
## [1.2.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv1.2.1&targetVersion=GTv1.2.2) (2022-08-31)
|
|
1459
1503
|
|
|
@@ -10,7 +10,7 @@ $focus-width: 0.15rem;
|
|
|
10
10
|
cursor: pointer;
|
|
11
11
|
color: $blueberry700;
|
|
12
12
|
background-color: $blueberry60010;
|
|
13
|
-
|
|
13
|
+
text-decoration-color: $blueberry600;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
@mixin anchorlink-focus {
|
|
@@ -24,12 +24,13 @@ $focus-width: 0.15rem;
|
|
|
24
24
|
overflow-wrap: break-word;
|
|
25
25
|
word-break: break-word;
|
|
26
26
|
text-align: left;
|
|
27
|
-
text-decoration: none;
|
|
28
27
|
color: $blueberry600;
|
|
29
28
|
border: $focus-width solid transparent;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
text-decoration: underline;
|
|
30
|
+
text-underline-offset: 0.16rem;
|
|
31
|
+
text-decoration-color: $blueberry400;
|
|
32
|
+
text-decoration-thickness: $underline-width;
|
|
33
|
+
padding: 0.1rem;
|
|
33
34
|
|
|
34
35
|
&:hover {
|
|
35
36
|
@include anchorlink-hover;
|
|
@@ -6,6 +6,7 @@ export type ButtonSize = 'medium' | 'large';
|
|
|
6
6
|
export type ButtonMode = 'onlight' | 'ondark';
|
|
7
7
|
export type ButtonTags = 'button' | 'a';
|
|
8
8
|
export type ButtonArrows = 'icon' | 'accessibility-character';
|
|
9
|
+
export type ButtonTextPosition = 'left' | 'centered-mobile';
|
|
9
10
|
export interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {
|
|
10
11
|
/** Sets the aria-label of the button, use when the button only includes an icon */
|
|
11
12
|
ariaLabel?: string;
|
|
@@ -41,6 +42,8 @@ export interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttri
|
|
|
41
42
|
tabIndex?: number;
|
|
42
43
|
/** Sets the data-testid attribute. */
|
|
43
44
|
testId?: string;
|
|
45
|
+
/** Sets the position of the text in the button - only applies when button is fluid */
|
|
46
|
+
textPosition?: ButtonTextPosition;
|
|
44
47
|
/** Button type. Default: button */
|
|
45
48
|
type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
46
49
|
}
|
|
@@ -1,116 +1,118 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { AnalyticsId as $, IconSize as
|
|
5
|
-
import { useBreakpoint as
|
|
1
|
+
import e, { useRef as it, useEffect as ct } from "react";
|
|
2
|
+
import p from "classnames";
|
|
3
|
+
import { Icon as ut } from "../Icon/Icon.js";
|
|
4
|
+
import { AnalyticsId as $, IconSize as N } from "../../constants.js";
|
|
5
|
+
import { useBreakpoint as mt } from "../../hooks/useBreakpoint.js";
|
|
6
6
|
import { useHover as D } from "../../hooks/useHover.js";
|
|
7
|
-
import { useIcons as
|
|
8
|
-
import { getColor as
|
|
9
|
-
import { breakpoints as
|
|
10
|
-
import { isTest as
|
|
11
|
-
import
|
|
7
|
+
import { useIcons as bt } from "../../hooks/useIcons.js";
|
|
8
|
+
import { getColor as c } from "../../theme/currys/color.js";
|
|
9
|
+
import { breakpoints as dt } from "../../theme/grid.js";
|
|
10
|
+
import { isTest as pt, isProd as ft } from "../../utils/environment.js";
|
|
11
|
+
import ht from "../Icons/ArrowRight.js";
|
|
12
12
|
import t from "../Button/styles.module.scss";
|
|
13
|
-
const
|
|
14
|
-
if (n &&
|
|
13
|
+
const _t = (o, r, n, f, s, _) => _ && n ? !s || o ? c("neutral", r ? 500 : 700) : c("white") : n ? !s || o ? c("neutral", 500) : `${c("white")}b3` : o && !s || !o && s ? "white" : f === "normal" ? c("blueberry", 600) : c("cherry", 500), B = (o, r) => r && o ? N.Small : o ? N.Medium : N.XSmall, gt = (o, r, n) => {
|
|
14
|
+
if (n && o && (r === void 0 || r === ""))
|
|
15
15
|
throw new Error("Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav");
|
|
16
|
-
},
|
|
16
|
+
}, wt = e.forwardRef(function(r, n) {
|
|
17
17
|
const {
|
|
18
|
-
ariaLabel:
|
|
19
|
-
id:
|
|
20
|
-
children:
|
|
18
|
+
ariaLabel: f,
|
|
19
|
+
id: s,
|
|
20
|
+
children: _,
|
|
21
21
|
wrapperClassName: O,
|
|
22
22
|
className: X,
|
|
23
|
-
arrow:
|
|
24
|
-
concept:
|
|
25
|
-
disabled:
|
|
26
|
-
ellipsis:
|
|
27
|
-
fluid:
|
|
28
|
-
htmlMarkup:
|
|
23
|
+
arrow: g,
|
|
24
|
+
concept: R = "normal",
|
|
25
|
+
disabled: u = !1,
|
|
26
|
+
ellipsis: x = !1,
|
|
27
|
+
fluid: w = !1,
|
|
28
|
+
htmlMarkup: I = "button",
|
|
29
29
|
mode: j = "onlight",
|
|
30
|
-
onBlur:
|
|
31
|
-
onClick:
|
|
30
|
+
onBlur: A,
|
|
31
|
+
onClick: E,
|
|
32
32
|
size: q = "medium",
|
|
33
|
-
variant:
|
|
33
|
+
variant: y = "fill",
|
|
34
34
|
href: G,
|
|
35
35
|
tabIndex: S,
|
|
36
36
|
testId: z,
|
|
37
37
|
target: U,
|
|
38
38
|
type: J = "button",
|
|
39
|
+
textPosition: K = "left",
|
|
39
40
|
...F
|
|
40
|
-
} = r, [
|
|
41
|
+
} = r, [m, b, H] = bt(e.Children.toArray(_)), { hoverRef: P, isHovered: Q } = I === "button" ? D(n) : D(n), Y = it(null), a = !!(m || b) && !H, L = m && (b || g) && !a, C = j === "ondark", h = mt() < dt.md, M = R === "destructive" && !u, Z = y === "outline", l = y === "borderless", T = _t(y === "fill", l, u, R, C, h), v = g === "icon" && !l, d = q === "large" && !M && !l, tt = g === "accessibility-character" && !w && !m && !b && !v && l, et = { ...F }, V = p(
|
|
41
42
|
t["button-wrapper"],
|
|
42
|
-
{ [t["button-wrapper--fluid"]]:
|
|
43
|
+
{ [t["button-wrapper--fluid"]]: w || x },
|
|
43
44
|
O
|
|
44
|
-
), ot =
|
|
45
|
+
), ot = p(
|
|
45
46
|
t.button,
|
|
46
47
|
{
|
|
47
|
-
[t["button--destructive"]]:
|
|
48
|
-
[t["button--normal"]]: !
|
|
49
|
-
[t["button--large"]]:
|
|
50
|
-
[t["button--outline"]]:
|
|
48
|
+
[t["button--destructive"]]: M,
|
|
49
|
+
[t["button--normal"]]: !d,
|
|
50
|
+
[t["button--large"]]: d,
|
|
51
|
+
[t["button--outline"]]: Z,
|
|
51
52
|
[t["button--borderless"]]: l,
|
|
52
|
-
[t["button--left-icon"]]:
|
|
53
|
-
[t["button--right-icon"]]:
|
|
54
|
-
[t["button--both-icons"]]:
|
|
55
|
-
[t["button--only-icon"]]:
|
|
56
|
-
[t["button--arrow"]]:
|
|
57
|
-
[t["button--on-dark"]]:
|
|
53
|
+
[t["button--left-icon"]]: m && !a,
|
|
54
|
+
[t["button--right-icon"]]: b && !a,
|
|
55
|
+
[t["button--both-icons"]]: L,
|
|
56
|
+
[t["button--only-icon"]]: a,
|
|
57
|
+
[t["button--arrow"]]: v,
|
|
58
|
+
[t["button--on-dark"]]: C
|
|
58
59
|
},
|
|
59
60
|
X
|
|
60
|
-
),
|
|
61
|
-
[t["button__text--ellipsis"]]:
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
), rt = p(t.button__text, {
|
|
62
|
+
[t["button__text--ellipsis"]]: x,
|
|
63
|
+
[t["button__text--centered-mobile"]]: w && K === "centered-mobile"
|
|
64
|
+
}), nt = p(t.diagonal, {
|
|
65
|
+
[t["diagonal--on-dark"]]: C
|
|
64
66
|
});
|
|
65
67
|
ct(() => {
|
|
66
|
-
gt(
|
|
68
|
+
gt(a, f, !pt() && !ft());
|
|
67
69
|
}, []);
|
|
68
|
-
const k = (
|
|
70
|
+
const k = (i, at, lt) => i ? e.cloneElement(i, {
|
|
69
71
|
size: at,
|
|
70
|
-
color:
|
|
71
|
-
isHovered:
|
|
72
|
-
className:
|
|
73
|
-
}) : null,
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
) : k(
|
|
78
|
-
return /* @__PURE__ */
|
|
72
|
+
color: i != null && i.props.color ? i.props.color : T,
|
|
73
|
+
isHovered: !u && Q,
|
|
74
|
+
className: lt
|
|
75
|
+
}) : null, st = () => /* @__PURE__ */ e.createElement("span", { className: rt, ref: Y }, u && l && /* @__PURE__ */ e.createElement("span", { className: nt }, /* @__PURE__ */ e.createElement("span", { className: t.diagonal__line })), /* @__PURE__ */ e.createElement("span", null, a ? f : H)), W = () => /* @__PURE__ */ e.createElement("span", { className: ot }, k(m, B(d, h), a ? void 0 : t["button__left-icon"]), st(), v ? k(
|
|
76
|
+
/* @__PURE__ */ e.createElement(ut, { svgIcon: ht }),
|
|
77
|
+
B(d, h),
|
|
78
|
+
p(t.button__arrow, { [t["button__arrow--both-icons"]]: L })
|
|
79
|
+
) : k(b, B(d, h), t["button__right-icon"]), tt && /* @__PURE__ */ e.createElement("span", { style: { color: T }, className: t["button__right-unicode-arrow"], "aria-hidden": !0 }, " →"));
|
|
80
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, I === "button" && /* @__PURE__ */ e.createElement(
|
|
79
81
|
"button",
|
|
80
82
|
{
|
|
81
|
-
id:
|
|
82
|
-
onBlur:
|
|
83
|
-
onClick:
|
|
84
|
-
disabled:
|
|
83
|
+
id: s,
|
|
84
|
+
onBlur: A,
|
|
85
|
+
onClick: E,
|
|
86
|
+
disabled: u,
|
|
85
87
|
"data-testid": z,
|
|
86
88
|
"data-analyticsid": $.Button,
|
|
87
89
|
className: V,
|
|
88
|
-
ref:
|
|
90
|
+
ref: P,
|
|
89
91
|
tabIndex: S,
|
|
90
92
|
type: J,
|
|
91
|
-
...
|
|
93
|
+
...et
|
|
92
94
|
},
|
|
93
95
|
W()
|
|
94
|
-
),
|
|
96
|
+
), I === "a" && /* @__PURE__ */ e.createElement(
|
|
95
97
|
"a",
|
|
96
98
|
{
|
|
97
|
-
id:
|
|
98
|
-
onBlur:
|
|
99
|
-
onClick:
|
|
99
|
+
id: s,
|
|
100
|
+
onBlur: A,
|
|
101
|
+
onClick: E,
|
|
100
102
|
"data-testid": z,
|
|
101
103
|
"data-analyticsid": $.Button,
|
|
102
104
|
className: V,
|
|
103
105
|
href: G,
|
|
104
106
|
target: U,
|
|
105
107
|
rel: U === "_blank" ? "noopener noreferrer" : r.rel,
|
|
106
|
-
ref:
|
|
108
|
+
ref: P,
|
|
107
109
|
tabIndex: S,
|
|
108
110
|
...F
|
|
109
111
|
},
|
|
110
112
|
W()
|
|
111
113
|
));
|
|
112
|
-
}),
|
|
114
|
+
}), Ut = wt;
|
|
113
115
|
export {
|
|
114
|
-
|
|
116
|
+
Ut as default
|
|
115
117
|
};
|
|
116
118
|
//# sourceMappingURL=Button.js.map
|
|
@@ -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']} 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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,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';\nexport type ButtonTextPosition = 'left' | 'centered-mobile';\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 /** Sets the position of the text in the button - only applies when button is fluid */\n textPosition?: ButtonTextPosition;\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 textPosition = 'left',\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 [buttonStyles['button__text--centered-mobile']]: fluid && textPosition === 'centered-mobile',\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: !disabled && 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","textPosition","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":";;;;;;;;;;;;AAiEA,MAAMA,KAAe,CACnBC,GACAC,GACAC,GACAC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SAASC,GAAY,CAAA;AAAA,IAC3BnE,EAAiBC,GAAOH,CAAM;AAAA,IAC9BsD,EAAWC,EAAa,eAAkB,EAAE,CAACA,EAAa,2BAA2B,CAAC,GAAGb,GAAW;AAAA,EACtG,IACAoB,EAAW5B,GAAWhC,EAAiBC,GAAOH,CAAM,GAAGuD,EAAa,oBAAoB,CAAC,GAC5FJ,MACCzC,gBAAAA,EAAA,cAAC,UAAK,OAAO,EAAE,OAAOuC,EAAA,GAAa,WAAWM,EAAa,6BAA6B,GAAG,eAAW,MACnG,KACH,CAEJ;AAIA,SAAA7C,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,oBAAkB0C,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,KAAKhB;AAAA,MACL,UAAAV;AAAA,MACA,MAAAG;AAAA,MACC,GAAGsB;AAAA,IAAA;AAAA,IAEHe,EAA2B;AAAA,EAAA,GAG/B/C,MAAe,OACdV,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,QAAAS;AAAA,MACA,SAAAC;AAAA,MACA,eAAaK;AAAA,MACb,oBAAkB0C,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,MAAA3B;AAAA,MACA,QAAAG;AAAA,MACA,KAAKA,MAAW,WAAW,wBAAwBlB,EAAM;AAAA,MACzD,KAAK0B;AAAA,MACL,UAAAV;AAAA,MACC,GAAGK;AAAA,IAAA;AAAA,IAEHmC,EAA2B;AAAA,EAAA,CAGlC;AAEJ,CAAC,GAEDI,KAAe9D;"}
|
|
@@ -330,6 +330,12 @@ $with-icons: // icon-class, size-class, padding-left, padding-right, padding-lef
|
|
|
330
330
|
overflow: hidden;
|
|
331
331
|
text-overflow: ellipsis;
|
|
332
332
|
}
|
|
333
|
+
|
|
334
|
+
&--centered-mobile {
|
|
335
|
+
@media (max-width: map.get($grid-max-breakpoints, xs)) {
|
|
336
|
+
width: 100%;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
333
339
|
}
|
|
334
340
|
|
|
335
341
|
&__right-unicode-arrow {
|
|
@@ -8,6 +8,7 @@ export type Styles = {
|
|
|
8
8
|
'button__right-icon': string;
|
|
9
9
|
'button__right-unicode-arrow': string;
|
|
10
10
|
button__text: string;
|
|
11
|
+
'button__text--centered-mobile': string;
|
|
11
12
|
'button__text--ellipsis': string;
|
|
12
13
|
'button--arrow': string;
|
|
13
14
|
'button--arrow--both-icons': string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StoryObj } from '@storybook/react';
|
|
3
3
|
import ExpanderHierarchy from './ExpanderHierarchy';
|
|
4
|
-
type ExpanderHierarchyWithAndCustomArgs = React.ComponentProps<typeof ExpanderHierarchy> & {
|
|
5
|
-
title: string;
|
|
6
|
-
expanded: boolean;
|
|
7
|
-
};
|
|
8
4
|
declare const meta: {
|
|
9
5
|
title: string;
|
|
10
6
|
component: import("./ExpanderHierarchy").ExpanderHierarchyCompound;
|
|
@@ -17,27 +13,32 @@ declare const meta: {
|
|
|
17
13
|
};
|
|
18
14
|
};
|
|
19
15
|
args: {
|
|
20
|
-
title: string;
|
|
21
16
|
htmlMarkup: "h2";
|
|
22
|
-
expanded: false;
|
|
23
17
|
print: false;
|
|
24
18
|
};
|
|
25
19
|
argTypes: {
|
|
26
|
-
title: {
|
|
27
|
-
control: string;
|
|
28
|
-
};
|
|
29
20
|
htmlMarkup: {
|
|
30
21
|
control: string;
|
|
31
22
|
options: string[];
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
print: {
|
|
26
|
+
control: string;
|
|
27
|
+
description: string;
|
|
32
28
|
};
|
|
33
|
-
|
|
29
|
+
children: {
|
|
34
30
|
control: string;
|
|
35
31
|
};
|
|
36
|
-
|
|
32
|
+
level: {
|
|
33
|
+
control: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
testId: {
|
|
37
37
|
control: string;
|
|
38
|
+
description: string;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
export default meta;
|
|
42
|
-
type Story = StoryObj<
|
|
43
|
+
type Story = StoryObj<typeof ExpanderHierarchy>;
|
|
43
44
|
export declare const Default: Story;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StoryObj } from '@storybook/react';
|
|
3
|
+
import List from './List';
|
|
3
4
|
declare const meta: {
|
|
4
5
|
title: string;
|
|
5
6
|
component: import("./List").ListCompound;
|
|
@@ -12,22 +13,38 @@ declare const meta: {
|
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
args: {
|
|
15
|
-
children: string;
|
|
16
16
|
variant: "bullet";
|
|
17
17
|
margin: false;
|
|
18
|
+
className: string;
|
|
19
|
+
testId: string;
|
|
18
20
|
};
|
|
19
21
|
argTypes: {
|
|
20
22
|
variant: {
|
|
21
23
|
control: string;
|
|
22
24
|
options: string[];
|
|
25
|
+
description: string;
|
|
26
|
+
defaultValue: string;
|
|
23
27
|
};
|
|
24
28
|
margin: {
|
|
25
29
|
control: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
children: {
|
|
33
|
+
control: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
className: {
|
|
37
|
+
control: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
testId: {
|
|
41
|
+
control: string;
|
|
42
|
+
description: string;
|
|
26
43
|
};
|
|
27
44
|
};
|
|
28
45
|
};
|
|
29
46
|
export default meta;
|
|
30
|
-
type Story = StoryObj<typeof
|
|
47
|
+
type Story = StoryObj<typeof List>;
|
|
31
48
|
export declare const Default: Story;
|
|
32
49
|
export declare const Bullet: Story;
|
|
33
50
|
export declare const Dashed: Story;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SvgIcon } from '../Icon';
|
|
3
|
+
import { IconName } from '../Icons/IconNames';
|
|
4
|
+
export interface TabProps {
|
|
5
|
+
/** Sets the tab panel content */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Optional icon on the tab */
|
|
8
|
+
icon?: SvgIcon | IconName;
|
|
9
|
+
/** Called when tab is selected */
|
|
10
|
+
onTabClick?: (index: number) => void;
|
|
11
|
+
/** Sets the data-testid attribute. */
|
|
12
|
+
testId?: string;
|
|
13
|
+
/** Title on the tab */
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Tab: React.FC<TabProps>;
|
|
17
|
+
export default Tab;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.js","sources":["../../../src/components/Tabs/Tab.tsx"],"sourcesContent":["import React from 'react';\n\nimport { SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\n\nexport interface TabProps {\n /** Sets the tab panel content */\n children?: React.ReactNode;\n /** Optional icon on the tab */\n icon?: SvgIcon | IconName;\n /** Called when tab is selected */\n onTabClick?: (index: number) => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Title on the tab */\n title?: string;\n}\n\nconst Tab: React.FC<TabProps> = props => {\n return <>{props.children ?? null}</>;\n};\n\nexport default Tab;\n"],"names":["Tab","props","React","Tab$1"],"mappings":";AAkBA,MAAMA,IAA0B,CAASC,MAChCC,gBAAAA,EAAA,cAAAA,EAAA,UAAA,MAAGD,EAAM,YAAY,IAAK,GAGnCE,IAAeH;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabsColors, TabsType } from '../Tabs';
|
|
3
|
+
interface TabListProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
onTabListClick: (index: number) => void;
|
|
6
|
+
selectedTab: number;
|
|
7
|
+
color?: TabsColors;
|
|
8
|
+
type?: TabsType;
|
|
9
|
+
}
|
|
10
|
+
declare const TabList: React.FC<TabListProps>;
|
|
11
|
+
export default TabList;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import t, { useRef as p } from "react";
|
|
2
|
+
import u from "classnames";
|
|
3
|
+
import { useRovingFocus as N } from "../../../hooks/useRovingFocus.js";
|
|
4
|
+
import { palette as s } from "../../../theme/palette.js";
|
|
5
|
+
import { isComponent as $ } from "../../../utils/component.js";
|
|
6
|
+
import { uuid as L } from "../../../utils/uuid.js";
|
|
7
|
+
import { Icon as S } from "../../Icon/Icon.js";
|
|
8
|
+
import { IconSize as _ } from "../../../constants.js";
|
|
9
|
+
import g from "../../LazyIcon/LazyIcon.js";
|
|
10
|
+
import v from "../Tab.js";
|
|
11
|
+
import e from "../../Tabs/TabList/styles.module.scss";
|
|
12
|
+
const X = (d) => {
|
|
13
|
+
const { selectedTab: C, onTabListClick: i, children: n, color: k = "white", type: y = "normal" } = d, c = p(null), l = p(t.Children.map(n, () => t.createRef()));
|
|
14
|
+
N(i, l, c, !0);
|
|
15
|
+
const R = u(e["tab-list"], e[`tab-list--${y}`]), E = L();
|
|
16
|
+
return /* @__PURE__ */ t.createElement("ul", { className: R, ref: c, role: "tablist", "aria-orientation": "horizontal" }, t.Children.map(n, (m, o) => {
|
|
17
|
+
if ($(m, v)) {
|
|
18
|
+
const r = o === C, { title: b, onTabClick: f, icon: a, testId: T } = m.props, h = () => {
|
|
19
|
+
f && f(o), i(o);
|
|
20
|
+
}, z = u(e["tab-list__tab"], e[`tab-list__tab--${k}`], {
|
|
21
|
+
[e["tab-list__tab--selected"]]: r,
|
|
22
|
+
[e["tab-list__tab--first"]]: o == 0
|
|
23
|
+
}), I = l.current && l.current[o];
|
|
24
|
+
return /* @__PURE__ */ t.createElement("li", { role: "presentation" }, /* @__PURE__ */ t.createElement(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
role: "tab",
|
|
28
|
+
"aria-selected": r,
|
|
29
|
+
onClick: h,
|
|
30
|
+
className: z,
|
|
31
|
+
key: `${b}-${E}`,
|
|
32
|
+
"data-testid": T,
|
|
33
|
+
ref: I
|
|
34
|
+
},
|
|
35
|
+
/* @__PURE__ */ t.createElement("span", { className: e["tab-list__tab__title-and-icon"] }, a && (typeof a == "string" ? /* @__PURE__ */ t.createElement(
|
|
36
|
+
g,
|
|
37
|
+
{
|
|
38
|
+
iconName: a,
|
|
39
|
+
size: _.XSmall,
|
|
40
|
+
color: r ? s.black : s.blueberry500
|
|
41
|
+
}
|
|
42
|
+
) : /* @__PURE__ */ t.createElement(S, { svgIcon: a, size: _.XSmall, color: r ? s.black : s.blueberry500 })), b)
|
|
43
|
+
));
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}));
|
|
47
|
+
}, M = X;
|
|
48
|
+
export {
|
|
49
|
+
M as default
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=TabList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabList.js","sources":["../../../../src/components/Tabs/TabList/TabList.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { useRovingFocus } from '../../../hooks/useRovingFocus';\nimport { palette } from '../../../theme/palette';\nimport { isComponent } from '../../../utils/component';\nimport uuid from '../../../utils/uuid';\nimport Icon, { IconSize } from '../../Icon';\nimport { IconName } from '../../Icons/IconNames';\nimport LazyIcon from '../../LazyIcon';\nimport Tab from '../Tab';\nimport { TabsColors, TabsType } from '../Tabs';\n\nimport styles from './styles.module.scss';\ninterface TabListProps {\n children: React.ReactNode;\n onTabListClick: (index: number) => void;\n selectedTab: number;\n color?: TabsColors;\n type?: TabsType;\n}\n\nconst TabList: React.FC<TabListProps> = props => {\n const { selectedTab, onTabListClick, children, color = 'white', type = 'normal' } = props;\n\n const listRef = useRef<HTMLUListElement>(null);\n\n const tabRefs = useRef(React.Children.map(children, () => React.createRef<HTMLButtonElement>()));\n useRovingFocus(onTabListClick, tabRefs, listRef, true);\n\n const tablistClasses = classNames(styles['tab-list'], styles[`tab-list--${type}`]);\n\n const id = uuid();\n\n return (\n <ul className={tablistClasses} ref={listRef} role=\"tablist\" aria-orientation=\"horizontal\">\n {React.Children.map(children, (child, index) => {\n if (isComponent(child, Tab)) {\n const isSelected = index === selectedTab;\n const { title, onTabClick, icon, testId } = child.props;\n const handleClick = (): void => {\n onTabClick && onTabClick(index);\n onTabListClick(index);\n };\n const tabButtonClasses = classNames(styles['tab-list__tab'], styles[`tab-list__tab--${color}`], {\n [styles['tab-list__tab--selected']]: isSelected,\n [styles['tab-list__tab--first']]: index == 0,\n });\n\n const currentRef = tabRefs.current && tabRefs.current[index];\n\n return (\n <li role=\"presentation\">\n <button\n role=\"tab\"\n aria-selected={isSelected}\n onClick={handleClick}\n className={tabButtonClasses}\n key={`${title}-${id}`}\n data-testid={testId}\n ref={currentRef as React.RefObject<HTMLButtonElement>}\n >\n <span className={styles['tab-list__tab__title-and-icon']}>\n {icon &&\n (typeof icon === 'string' ? (\n <LazyIcon\n iconName={icon as IconName}\n size={IconSize.XSmall}\n color={isSelected ? palette[`black`] : palette['blueberry500']}\n />\n ) : (\n <Icon svgIcon={icon} size={IconSize.XSmall} color={isSelected ? palette[`black`] : palette['blueberry500']} />\n ))}\n {title}\n </span>\n </button>\n </li>\n );\n }\n return null;\n })}\n </ul>\n );\n};\n\nexport default TabList;\n"],"names":["TabList","props","selectedTab","onTabListClick","children","color","type","listRef","useRef","tabRefs","React","useRovingFocus","tablistClasses","classNames","styles","id","uuid","child","index","isComponent","Tab","isSelected","title","onTabClick","icon","testId","handleClick","tabButtonClasses","currentRef","LazyIcon","IconSize","palette","Icon","TabList$1"],"mappings":";;;;;;;;;;;AAuBA,MAAMA,IAAkC,CAASC,MAAA;AACzC,QAAA,EAAE,aAAAC,GAAa,gBAAAC,GAAgB,UAAAC,GAAU,OAAAC,IAAQ,SAA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