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