@rikstv/shared-components 3.3.15-alpha.2 → 3.3.15-alpha.3
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 +5 -0
- package/dist/components/alert/Alert-CX6wPqur.mjs +70 -0
- package/dist/components/core/Core-DVnHiJm2.mjs +46 -0
- package/dist/components/core/{RiksTV-D1wr-aYp.mjs → RiksTV-CxHetJcp.mjs} +1 -1
- package/dist/components/core/{Strim-1ocLRXTP.mjs → Strim-C1ajVDCm.mjs} +1 -1
- package/dist/components/dropdown/{Dropdown-c9wdxVoJ.mjs → Dropdown-CWVW7rKD.mjs} +19 -18
- package/dist/components/icons/{Icons-CgcqUFmH.mjs → Icons-knwkK_Mh.mjs} +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/list/{CheckmarkListItem-DE0v1Zhg.mjs → CheckmarkListItem-DokxieXU.mjs} +1 -1
- package/dist/components/list/{CrossmarkListItem-DFXTjZR6.mjs → CrossmarkListItem-CRelk7jn.mjs} +1 -1
- package/dist/components/panel/Panel-BaTG2zyz.mjs +63 -0
- package/dist/components/toggleButton/{ToggleButton-Dhxp8g2g.mjs → ToggleButton-CGLyQll6.mjs} +18 -17
- package/dist/components/toggleInlineButton/ToggleInlineButton-Cnet1doK.mjs +40 -0
- package/dist/components/toggleLinkButton/ToggleLinkButton-DRGFajD0.mjs +34 -0
- package/dist/components/toggleLinkButton/ToggleLinkButton.d.ts +11 -3
- package/dist/components/toggleLinkButton/toggleLinkButton.scss +17 -14
- package/dist/shared-components.mjs +161 -159
- package/dist/style.css +1 -1
- package/package.json +2 -3
- package/dist/components/alert/Alert-BvwcxnzO.mjs +0 -70
- package/dist/components/core/Core-BdJiu9y4.mjs +0 -46
- package/dist/components/panel/Panel-D2Nkdd54.mjs +0 -63
- package/dist/components/toggleInlineButton/ToggleInlineButton-9ZcLN5Lf.mjs +0 -39
- package/dist/components/toggleLinkButton/ToggleLinkButton-B01oBGAX.mjs +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# 📖 Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.15
|
|
4
|
+
|
|
5
|
+
- Refactor ToggleLinkButton to use `<button>` instead of checkbox for WCAG-compliant disclosure pattern (aria-expanded, aria-controls)
|
|
6
|
+
- Add support for controlled mode via `checked` prop (in addition to `defaultChecked`)
|
|
7
|
+
|
|
3
8
|
## 3.3.12
|
|
4
9
|
|
|
5
10
|
- Allow to set Circular Progress size in px
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsxs as d, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as B, useState as c } from "react";
|
|
3
|
+
import { H as F, B as T } from "../typography/Typography-CXNJ1SFo.mjs";
|
|
4
|
+
import "../icons/HeartToggle-Bwgo4FxH.mjs";
|
|
5
|
+
import { S as b, a as x, b as O, c as R, d as D } from "../icons/Icons-knwkK_Mh.mjs";
|
|
6
|
+
const E = "_rds-alert--icon_m8jce_67", H = "_rds-alert--content-title_m8jce_79", M = "_rds-alert--content_m8jce_79", V = "_rds-alert--dismiss_m8jce_109", q = "_dismissed_m8jce_138", z = "_dismiss-fade-out_m8jce_1", e = {
|
|
7
|
+
rdsAlertIcon: E,
|
|
8
|
+
rdsAlertContentTitle: H,
|
|
9
|
+
rdsAlertContent: M,
|
|
10
|
+
rdsAlertDismiss: V,
|
|
11
|
+
dismissed: q,
|
|
12
|
+
dismissFadeOut: z
|
|
13
|
+
}, G = {
|
|
14
|
+
warning: { title: "Advarsel", Icon: R },
|
|
15
|
+
error: { title: "Feil", Icon: O },
|
|
16
|
+
info: { title: "Informasjon", Icon: x },
|
|
17
|
+
success: { title: "Vellykket", Icon: b }
|
|
18
|
+
}, J = B(
|
|
19
|
+
({
|
|
20
|
+
className: m,
|
|
21
|
+
intent: r = "warning",
|
|
22
|
+
variant: l = "filled",
|
|
23
|
+
testId: A = "rds-alert",
|
|
24
|
+
heading: f,
|
|
25
|
+
noHeading: i = !1,
|
|
26
|
+
children: _,
|
|
27
|
+
dismissible: v = !0,
|
|
28
|
+
lightBackground: u,
|
|
29
|
+
onDismissed: t,
|
|
30
|
+
LinkToDetails: C,
|
|
31
|
+
...p
|
|
32
|
+
}, j) => {
|
|
33
|
+
const [I, n] = c(!1), [h, a] = c(!1), g = ["rds-alert", u ? "rds-light" : "", I ? e.dismissed : "", m].filter(Boolean).join(" ");
|
|
34
|
+
if (h)
|
|
35
|
+
return null;
|
|
36
|
+
const N = () => {
|
|
37
|
+
n(!1), a(!1);
|
|
38
|
+
}, { title: o, Icon: S } = G[r], y = (w) => {
|
|
39
|
+
w.animationName === e.dismissFadeOut && (a(!0), t == null || t(N));
|
|
40
|
+
}, k = v && l !== "inline";
|
|
41
|
+
return /* @__PURE__ */ d(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
role: "alert",
|
|
45
|
+
"aria-live": "polite",
|
|
46
|
+
ref: j,
|
|
47
|
+
className: g,
|
|
48
|
+
"data-testid": A,
|
|
49
|
+
"data-intent": r,
|
|
50
|
+
"data-variant": l,
|
|
51
|
+
onAnimationEnd: y,
|
|
52
|
+
...p,
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ s(S, { className: e.rdsAlertIcon }),
|
|
55
|
+
/* @__PURE__ */ d("div", { className: e.rdsAlertContent, children: [
|
|
56
|
+
!i && /* @__PURE__ */ s(F, { className: e.rdsAlertContentTitle, as: "span", children: f || o }),
|
|
57
|
+
i && /* @__PURE__ */ s("span", { className: "sr-only", children: o }),
|
|
58
|
+
/* @__PURE__ */ s(T, { as: "div", children: _ }),
|
|
59
|
+
C
|
|
60
|
+
] }),
|
|
61
|
+
k && /* @__PURE__ */ s("div", { className: e.rdsAlertDismiss, children: /* @__PURE__ */ s("button", { "aria-label": "Avvis varsel", onClick: () => n(!0), children: /* @__PURE__ */ s(D, {}) }) })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
J.displayName = "Alert";
|
|
68
|
+
export {
|
|
69
|
+
J as A
|
|
70
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
let a = !1, n = !1, u = !1;
|
|
3
|
+
const r = {
|
|
4
|
+
mousedown: c,
|
|
5
|
+
keydown: d,
|
|
6
|
+
touchstart: f
|
|
7
|
+
};
|
|
8
|
+
function s() {
|
|
9
|
+
Object.keys(r).forEach((t) => {
|
|
10
|
+
document.removeEventListener(t, r[t]);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function e(t) {
|
|
14
|
+
document.addEventListener(t, r[t]);
|
|
15
|
+
}
|
|
16
|
+
function c() {
|
|
17
|
+
if (!a && !u) {
|
|
18
|
+
a = !0, n = !1;
|
|
19
|
+
const t = document.querySelector("html");
|
|
20
|
+
t == null || t.setAttribute("data-mousenavigation", "true"), t == null || t.removeAttribute("data-touchnavigation"), s(), e("touchstart"), e("keydown");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function d(t) {
|
|
24
|
+
if (t.key === "Tab") {
|
|
25
|
+
const o = document.querySelector("html");
|
|
26
|
+
s(), o == null || o.removeAttribute("data-mousenavigation"), o == null || o.removeAttribute("data-touchnavigation"), a = !1, n = !1, e("touchstart"), e("mousedown");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function f() {
|
|
30
|
+
if (!n) {
|
|
31
|
+
a = !1, n = !0;
|
|
32
|
+
const t = document.querySelector("html");
|
|
33
|
+
t == null || t.setAttribute("data-touchnavigation", "true"), t == null || t.removeAttribute("data-mousenavigation"), s(), e("touchstart"), e("keydown"), e("mousedown");
|
|
34
|
+
}
|
|
35
|
+
u = !0, setTimeout(() => {
|
|
36
|
+
u = !1;
|
|
37
|
+
}, 150);
|
|
38
|
+
}
|
|
39
|
+
function v() {
|
|
40
|
+
typeof document < "u" && (e("touchstart"), e("mousedown"));
|
|
41
|
+
}
|
|
42
|
+
v();
|
|
43
|
+
const m = ({ brand: t, children: o }) => /* @__PURE__ */ i("div", { "data-testid": "core-entry", className: t, children: o });
|
|
44
|
+
export {
|
|
45
|
+
m as C
|
|
46
|
+
};
|
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import { jsxs as n, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
const
|
|
2
|
+
const f = ({
|
|
3
3
|
label: a,
|
|
4
4
|
id: s,
|
|
5
5
|
options: r,
|
|
6
|
-
onChange:
|
|
7
|
-
className:
|
|
8
|
-
defaultValue:
|
|
9
|
-
rightIcon:
|
|
6
|
+
onChange: t,
|
|
7
|
+
className: o = "",
|
|
8
|
+
defaultValue: h,
|
|
9
|
+
rightIcon: m,
|
|
10
10
|
leftIcon: c,
|
|
11
|
-
innerRef:
|
|
12
|
-
...
|
|
11
|
+
innerRef: v,
|
|
12
|
+
...u
|
|
13
13
|
}) => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
var i;
|
|
15
|
+
const p = `dropdown-styling ${c ? "menu-with-left-icon" : ""} ${o}`;
|
|
16
|
+
return /* @__PURE__ */ n("span", { className: p, children: [
|
|
16
17
|
/* @__PURE__ */ l("label", { htmlFor: s, children: a }),
|
|
17
18
|
/* @__PURE__ */ n("div", { className: "select-wrapper", children: [
|
|
18
19
|
/* @__PURE__ */ l(
|
|
19
20
|
"select",
|
|
20
21
|
{
|
|
21
|
-
defaultValue:
|
|
22
|
-
value: r.find((e) => e.selected)
|
|
22
|
+
defaultValue: h,
|
|
23
|
+
value: (i = r.find((e) => e.selected)) == null ? void 0 : i.value,
|
|
23
24
|
id: s,
|
|
24
|
-
ref:
|
|
25
|
+
ref: v,
|
|
25
26
|
onChange: ({ target: e }) => {
|
|
26
|
-
const d = r.find((
|
|
27
|
-
|
|
27
|
+
const d = r.find((w) => w.value === e.value) ?? r[0];
|
|
28
|
+
t(d);
|
|
28
29
|
},
|
|
29
|
-
...
|
|
30
|
+
...u,
|
|
30
31
|
children: r.map((e, d) => /* @__PURE__ */ l("option", { value: e.value, children: e.title }, `dropdown-${a}-${e.title}-${d}`))
|
|
31
32
|
}
|
|
32
33
|
),
|
|
33
34
|
/* @__PURE__ */ n("div", { children: [
|
|
34
35
|
/* @__PURE__ */ l("div", { className: "left-icon", children: c }),
|
|
35
|
-
/* @__PURE__ */ l("div", { className: "right-icon", children:
|
|
36
|
+
/* @__PURE__ */ l("div", { className: "right-icon", children: m })
|
|
36
37
|
] })
|
|
37
38
|
] })
|
|
38
39
|
] });
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
+
f.displayName = "Dropdown";
|
|
41
42
|
export {
|
|
42
|
-
|
|
43
|
+
f as D
|
|
43
44
|
};
|
|
@@ -17,7 +17,7 @@ export { PrimaryArrowButton, SecondaryArrowButton, GhostArrowButton, TertiaryArr
|
|
|
17
17
|
export { PrimaryIconButton, SecondaryIconButton, GhostIconButton, TertiaryIconButton } from './button/IconButton';
|
|
18
18
|
export { ToggleButton } from './toggleButton/ToggleButton';
|
|
19
19
|
export { ToggleInlineButton } from './toggleInlineButton/ToggleInlineButton';
|
|
20
|
-
export { ToggleLinkButton } from './toggleLinkButton/ToggleLinkButton';
|
|
20
|
+
export { ToggleLinkButton, type ToggleLinkButtonChangeEvent } from './toggleLinkButton/ToggleLinkButton';
|
|
21
21
|
export { Checkbox } from './checkbox/Checkbox';
|
|
22
22
|
export { RadioToggleInput } from './toggle/RadioToggle';
|
|
23
23
|
export { FieldSet } from './toggle/FieldSet';
|
package/dist/components/list/{CheckmarkListItem-DE0v1Zhg.mjs → CheckmarkListItem-DokxieXU.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../icons/HeartToggle-Bwgo4FxH.mjs";
|
|
4
|
-
import { e as o } from "../icons/Icons-
|
|
4
|
+
import { e as o } from "../icons/Icons-knwkK_Mh.mjs";
|
|
5
5
|
import { L as e } from "./ListItem-ClQsSisn.mjs";
|
|
6
6
|
const k = ({ children: r, ...m }) => /* @__PURE__ */ t(e, { testId: "rds-list-item--check", icon: /* @__PURE__ */ t(o, {}), ...m, children: r });
|
|
7
7
|
export {
|
package/dist/components/list/{CrossmarkListItem-DFXTjZR6.mjs → CrossmarkListItem-CRelk7jn.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../icons/HeartToggle-Bwgo4FxH.mjs";
|
|
4
|
-
import { d as o } from "../icons/Icons-
|
|
4
|
+
import { d as o } from "../icons/Icons-knwkK_Mh.mjs";
|
|
5
5
|
import { L as m } from "./ListItem-ClQsSisn.mjs";
|
|
6
6
|
const d = ({ children: r, ...s }) => /* @__PURE__ */ t(m, { testId: "rds-list-item--cross", icon: /* @__PURE__ */ t(o, {}), ...s, children: r });
|
|
7
7
|
export {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, Children as v } from "react";
|
|
3
|
+
import { S as C } from "../typography/Typography-CXNJ1SFo.mjs";
|
|
4
|
+
import "../icons/HeartToggle-Bwgo4FxH.mjs";
|
|
5
|
+
import { c as y, S as N, a as i } from "../icons/Icons-knwkK_Mh.mjs";
|
|
6
|
+
const $ = "_rds-panel_1x54j_1", P = "_content-and-buttons_1x54j_34", S = "_content_1x54j_34", b = "_title_1x54j_60", A = "_content-centered_1x54j_69", k = "_icon_1x54j_80", B = "_buttons_1x54j_87", n = {
|
|
7
|
+
rdsPanel: $,
|
|
8
|
+
contentAndButtons: P,
|
|
9
|
+
content: S,
|
|
10
|
+
title: b,
|
|
11
|
+
contentCentered: A,
|
|
12
|
+
icon: k,
|
|
13
|
+
buttons: B
|
|
14
|
+
}, I = {
|
|
15
|
+
error: {
|
|
16
|
+
title: "Feil",
|
|
17
|
+
icon: /* @__PURE__ */ e(i, {})
|
|
18
|
+
},
|
|
19
|
+
info: {
|
|
20
|
+
title: "Informasjon",
|
|
21
|
+
icon: /* @__PURE__ */ e(i, {})
|
|
22
|
+
},
|
|
23
|
+
success: {
|
|
24
|
+
title: "Vellykket",
|
|
25
|
+
icon: /* @__PURE__ */ e(N, {})
|
|
26
|
+
},
|
|
27
|
+
warning: {
|
|
28
|
+
title: "Advarsel",
|
|
29
|
+
icon: /* @__PURE__ */ e(y, {})
|
|
30
|
+
}
|
|
31
|
+
}, T = x(
|
|
32
|
+
({ className: a = "", intent: c = "info", heading: t, action: l, id: _, children: o, ...d }, m) => {
|
|
33
|
+
const { title: p, icon: f } = I[c], u = typeof t == "string" ? t : (t == null ? void 0 : t.title) ?? p, j = typeof t == "string" ? "span" : (t == null ? void 0 : t.level) ?? "span", r = v.count(o) === 0 || typeof o == "string" && o.trim() === "";
|
|
34
|
+
return /* @__PURE__ */ s(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
id: _,
|
|
38
|
+
className: `${n.rdsPanel} ${a}`,
|
|
39
|
+
"data-testid": "rds-panel",
|
|
40
|
+
"data-intent": c,
|
|
41
|
+
ref: m,
|
|
42
|
+
...d,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ s("span", { className: `${n.icon} ${r ? n.contentCentered : ""}`, children: [
|
|
45
|
+
" ",
|
|
46
|
+
f
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ s("div", { className: n.contentAndButtons, children: [
|
|
49
|
+
/* @__PURE__ */ s("div", { className: `${n.content} ${r ? n.contentCentered : ""}`, children: [
|
|
50
|
+
/* @__PURE__ */ e(j, { className: `${n.title} rds-title-4`, children: u }),
|
|
51
|
+
/* @__PURE__ */ e(C, { children: o })
|
|
52
|
+
] }),
|
|
53
|
+
l && /* @__PURE__ */ e("div", { className: n.buttons, children: l })
|
|
54
|
+
] })
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
T.displayName = "Panel";
|
|
61
|
+
export {
|
|
62
|
+
T as P
|
|
63
|
+
};
|
package/dist/components/toggleButton/{ToggleButton-Dhxp8g2g.mjs → ToggleButton-CGLyQll6.mjs}
RENAMED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsx as t, jsxs as l, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { B
|
|
4
|
-
const
|
|
5
|
-
({ children: a, className:
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useRef as T, useState as y } from "react";
|
|
3
|
+
import { B } from "../checkbox/BaseCheckbox-BGkrjof6.mjs";
|
|
4
|
+
const R = N(
|
|
5
|
+
({ children: a, className: h = "", defaultChecked: c, icons: e, iconClass: i = "", id: b, onChange: s, alwaysShowLabel: f = !1, ...m }, p) => {
|
|
6
|
+
const I = T(null), [n, g] = y(!!c), r = e && "checkedIcon" in e ? e.checkedIcon : null, d = e && "uncheckedIcon" in e ? e.uncheckedIcon : null, u = e && "toggleIcon" in e ? e.toggleIcon : null, o = p || I, k = (x) => {
|
|
7
|
+
var _;
|
|
8
|
+
typeof s == "function" && s(x), g(typeof o != "function" ? !!((_ = o.current) != null && _.checked) : !n);
|
|
8
9
|
};
|
|
9
10
|
return /* @__PURE__ */ t(
|
|
10
|
-
|
|
11
|
+
B,
|
|
11
12
|
{
|
|
12
|
-
id:
|
|
13
|
+
id: b,
|
|
13
14
|
ref: o,
|
|
14
15
|
dataTestId: "toggle-button__label",
|
|
15
|
-
containerClassName:
|
|
16
|
+
containerClassName: h + " rds-toggle-button-container",
|
|
16
17
|
inputClassName: "rds-toggle-button__input",
|
|
17
18
|
labelClassName: "rds-toggle-button",
|
|
18
|
-
onChange:
|
|
19
|
+
onChange: k,
|
|
19
20
|
defaultChecked: c,
|
|
20
|
-
...
|
|
21
|
+
...m,
|
|
21
22
|
children: /* @__PURE__ */ l("span", { className: "rds-toggle-button__content", children: [
|
|
22
|
-
e && /* @__PURE__ */ l(
|
|
23
|
-
/* @__PURE__ */ l("span", { className: `rds-toggle-button__icon ${
|
|
23
|
+
e && /* @__PURE__ */ l(C, { children: [
|
|
24
|
+
/* @__PURE__ */ l("span", { className: `rds-toggle-button__icon ${i}`, children: [
|
|
24
25
|
u && /* @__PURE__ */ t(u, { checked: n }),
|
|
25
26
|
r && n && /* @__PURE__ */ t(r, {}),
|
|
26
27
|
d && !n && /* @__PURE__ */ t(d, {})
|
|
@@ -29,7 +30,7 @@ const B = C(
|
|
|
29
30
|
"span",
|
|
30
31
|
{
|
|
31
32
|
"data-testid": "toggle-button__icon__label__text",
|
|
32
|
-
className: `label-text__icon ${
|
|
33
|
+
className: `label-text__icon ${f ? "always-show-label" : ""}`,
|
|
33
34
|
children: a
|
|
34
35
|
}
|
|
35
36
|
)
|
|
@@ -40,7 +41,7 @@ const B = C(
|
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
43
|
);
|
|
43
|
-
|
|
44
|
+
R.displayName = "ToggleButton";
|
|
44
45
|
export {
|
|
45
|
-
|
|
46
|
+
R as T
|
|
46
47
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as _, useRef as b, useState as C } from "react";
|
|
3
|
+
import { B as k } from "../checkbox/BaseCheckbox-BGkrjof6.mjs";
|
|
4
|
+
const N = _(
|
|
5
|
+
({
|
|
6
|
+
defaultChecked: a,
|
|
7
|
+
lightBackground: i,
|
|
8
|
+
children: r,
|
|
9
|
+
onChange: t,
|
|
10
|
+
id: c,
|
|
11
|
+
className: d = "",
|
|
12
|
+
inputClassName: g = "",
|
|
13
|
+
labelClassName: u = "",
|
|
14
|
+
...f
|
|
15
|
+
}, h) => {
|
|
16
|
+
const m = b(null), [n, o] = C(!!a), e = h || m;
|
|
17
|
+
return /* @__PURE__ */ s(
|
|
18
|
+
k,
|
|
19
|
+
{
|
|
20
|
+
id: c,
|
|
21
|
+
ref: e,
|
|
22
|
+
onChange: (p) => {
|
|
23
|
+
var l;
|
|
24
|
+
typeof t == "function" && t(p), o(typeof e != "function" ? !!((l = e.current) != null && l.checked) : !n);
|
|
25
|
+
},
|
|
26
|
+
checked: n,
|
|
27
|
+
dataTestId: "toggle-inline-button__label",
|
|
28
|
+
containerClassName: `rds-toggle-inline-button ${d}`,
|
|
29
|
+
inputClassName: `rds-toggle-inline-button__input ${g}`,
|
|
30
|
+
labelClassName: `${i ? "rds-light" : ""} ${u}`,
|
|
31
|
+
...f,
|
|
32
|
+
children: /* @__PURE__ */ s("span", { "data-testid": "toggle-inline-button__label__text", className: "rds-toggle-inline-button__content", children: r })
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
N.displayName = "ToggleInlineButton";
|
|
38
|
+
export {
|
|
39
|
+
N as T
|
|
40
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as o, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f, useState as h } from "react";
|
|
3
|
+
import "../icons/HeartToggle-Bwgo4FxH.mjs";
|
|
4
|
+
import { f as x, g as N } from "../icons/Icons-knwkK_Mh.mjs";
|
|
5
|
+
const S = f(
|
|
6
|
+
({ toggledContentId: s, lightBackground: a, children: r, checked: l, defaultChecked: d, onChange: t, id: c, className: g = "", ...k }, u) => {
|
|
7
|
+
const [_, m] = h(!!d), n = l !== void 0, e = n ? l : _, b = () => {
|
|
8
|
+
const i = !e;
|
|
9
|
+
n || m(i), t == null || t({ target: { checked: i } });
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ o(
|
|
12
|
+
"button",
|
|
13
|
+
{
|
|
14
|
+
ref: u,
|
|
15
|
+
type: "button",
|
|
16
|
+
id: c,
|
|
17
|
+
className: `rds-toggle-link-button ${a ? "rds-light" : ""} ${g}`.trim(),
|
|
18
|
+
"aria-expanded": e,
|
|
19
|
+
"aria-controls": s,
|
|
20
|
+
onClick: b,
|
|
21
|
+
"data-testid": "toggle-link-button__label",
|
|
22
|
+
...k,
|
|
23
|
+
children: /* @__PURE__ */ p("span", { className: "rds-toggle-link-button__label__content rds-link", "data-testid": "toggle-link-button__label__text", children: [
|
|
24
|
+
r,
|
|
25
|
+
e ? /* @__PURE__ */ o(x, { className: "rds-toggle-link-button__icon", "aria-hidden": !0 }) : /* @__PURE__ */ o(N, { className: "rds-toggle-link-button__icon", "aria-hidden": !0 })
|
|
26
|
+
] })
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
S.displayName = "ToggleLinkButton";
|
|
32
|
+
export {
|
|
33
|
+
S as T
|
|
34
|
+
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export interface ToggleLinkButtonChangeEvent {
|
|
3
|
+
target: {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
interface Props extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "children"> {
|
|
3
8
|
children: string;
|
|
4
9
|
toggledContentId: string;
|
|
5
10
|
lightBackground?: boolean;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
defaultChecked?: boolean;
|
|
13
|
+
onChange?: (e: ToggleLinkButtonChangeEvent) => void;
|
|
6
14
|
}
|
|
7
|
-
export declare const ToggleLinkButton: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<
|
|
15
|
+
export declare const ToggleLinkButton: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLButtonElement>>;
|
|
8
16
|
export {};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
.rds-toggle-link-button {
|
|
2
|
+
background: none;
|
|
3
|
+
border: none;
|
|
4
|
+
padding: 0;
|
|
5
|
+
margin: 0;
|
|
6
|
+
font: inherit;
|
|
7
|
+
color: inherit;
|
|
8
|
+
cursor: pointer;
|
|
2
9
|
display: inline-block;
|
|
3
10
|
user-select: none;
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
&:focus-visible {
|
|
13
|
+
outline: 2px solid currentColor;
|
|
14
|
+
outline-offset: 2px;
|
|
15
|
+
border-radius: 2px;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
&
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
}
|
|
18
|
+
&__label__content {
|
|
19
|
+
text-decoration: underline;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
&__icon {
|
|
@@ -22,8 +27,6 @@
|
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
.rds-light {
|
|
26
|
-
|
|
27
|
-
color: var(--rds-button-primary-fg);
|
|
28
|
-
}
|
|
30
|
+
.rds-toggle-link-button.rds-light {
|
|
31
|
+
color: var(--rds-button-primary-fg);
|
|
29
32
|
}
|