@tedi-design-system/react 19.2.0-rc.6 → 19.2.0-rc.8
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/bundle-stats.html +1 -1
- package/component.manifest.json +8 -8
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/map-components/map-layer/map-layer.cjs.js +1 -1
- package/src/community/components/map-components/map-layer/map-layer.es.js +1 -1
- package/src/tedi/components/content/label/label.cjs.js +1 -1
- package/src/tedi/components/content/label/label.d.ts +22 -0
- package/src/tedi/components/content/label/label.es.js +30 -28
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.d.ts +20 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.es.js +5 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.d.ts +72 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.es.js +124 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.es.js +13 -0
- package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.d.ts +8 -2
- package/src/tedi/components/form/checkbox/checkbox.es.js +146 -108
- package/src/tedi/components/form/checkbox/checkbox.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.module.scss.es.js +11 -3
- package/src/tedi/components/form/checkbox/index.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/index.d.ts +11 -0
- package/src/tedi/components/form/checkbox/index.es.js +7 -0
- package/src/tedi/components/form/choice-group/choice-group.cjs.js +1 -1
- package/src/tedi/components/form/choice-group/choice-group.d.ts +11 -0
- package/src/tedi/components/form/choice-group/choice-group.es.js +80 -69
- package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
- package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +15 -15
- package/src/tedi/components/form/choice-input.types.d.ts +46 -8
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +5 -0
- package/src/tedi/components/form/date-field/date-field.es.js +187 -184
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +5 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +103 -101
- package/src/tedi/components/form/form-label/form-label.cjs.js +1 -1
- package/src/tedi/components/form/form-label/form-label.d.ts +9 -0
- package/src/tedi/components/form/form-label/form-label.es.js +15 -14
- package/src/tedi/components/form/multi-value-field/multi-value-field.cjs.js +1 -1
- package/src/tedi/components/form/multi-value-field/multi-value-field.d.ts +7 -0
- package/src/tedi/components/form/multi-value-field/multi-value-field.es.js +41 -40
- package/src/tedi/components/form/number-field/number-field.cjs.js +1 -1
- package/src/tedi/components/form/number-field/number-field.es.js +54 -43
- package/src/tedi/components/form/radio/index.cjs.js +1 -0
- package/src/tedi/components/form/radio/index.d.ts +11 -0
- package/src/tedi/components/form/radio/index.es.js +7 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.d.ts +21 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.es.js +5 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.d.ts +56 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.es.js +78 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.es.js +13 -0
- package/src/tedi/components/form/radio/radio.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.d.ts +7 -2
- package/src/tedi/components/form/radio/radio.es.js +117 -77
- package/src/tedi/components/form/radio/radio.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.module.scss.es.js +11 -3
- package/src/tedi/components/form/select/select.cjs.js +1 -1
- package/src/tedi/components/form/select/select.es.js +79 -77
- package/src/tedi/components/form/slider/slider.cjs.js +1 -1
- package/src/tedi/components/form/slider/slider.d.ts +7 -0
- package/src/tedi/components/form/slider/slider.es.js +48 -47
- package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
- package/src/tedi/components/form/textfield/textfield.es.js +72 -61
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +5 -0
- package/src/tedi/components/form/time-field/time-field.es.js +87 -85
- package/src/tedi/components/form/toggle/toggle.cjs.js +1 -1
- package/src/tedi/components/form/toggle/toggle.d.ts +7 -0
- package/src/tedi/components/form/toggle/toggle.es.js +26 -24
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.d.ts +12 -0
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +57 -27
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +17 -0
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +65 -51
- package/src/tedi/index.d.ts +2 -2
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +25 -11
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +298 -294
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import { jsxs as m, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import g from "../../../../../external/classnames/index.es.js";
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { ClosingButton as
|
|
6
|
-
import { Separator as
|
|
7
|
-
import { Tag as
|
|
8
|
-
import { FormLabel as
|
|
3
|
+
import { forwardRef as ie, useState as C, useRef as R, useImperativeHandle as re, useCallback as ne, useEffect as P, useLayoutEffect as se } from "react";
|
|
4
|
+
import { Icon as T } from "../../base/icon/icon.es.js";
|
|
5
|
+
import { ClosingButton as ae } from "../../buttons/closing-button/closing-button.es.js";
|
|
6
|
+
import { Separator as oe } from "../../misc/separator/separator.es.js";
|
|
7
|
+
import { Tag as F } from "../../tags/tag/tag.es.js";
|
|
8
|
+
import { FormLabel as ce } from "../form-label/form-label.es.js";
|
|
9
9
|
import i from "./multi-value-field.module.scss.es.js";
|
|
10
|
-
import { useLabels as
|
|
11
|
-
const y = 4,
|
|
10
|
+
import { useLabels as ue } from "../../../providers/label-provider/use-labels.es.js";
|
|
11
|
+
const y = 4, de = 44, fe = ie((j, q) => {
|
|
12
12
|
const {
|
|
13
13
|
id: G,
|
|
14
14
|
label: V,
|
|
15
|
+
labelProps: X,
|
|
15
16
|
name: W,
|
|
16
17
|
values: E,
|
|
17
18
|
onChange: _,
|
|
18
19
|
tagColor: I = "primary",
|
|
19
|
-
tagsDirection:
|
|
20
|
-
className:
|
|
20
|
+
tagsDirection: $ = "stack",
|
|
21
|
+
className: D,
|
|
21
22
|
icon: o,
|
|
22
23
|
onIconClick: k,
|
|
23
24
|
iconButtonProps: h,
|
|
24
|
-
isClearable:
|
|
25
|
-
showClearOnInteraction:
|
|
25
|
+
isClearable: H = !0,
|
|
26
|
+
showClearOnInteraction: J,
|
|
26
27
|
required: M,
|
|
27
28
|
disabled: b
|
|
28
|
-
} = j, { getLabel: S } =
|
|
29
|
-
|
|
30
|
-
const n = E ??
|
|
31
|
-
|
|
29
|
+
} = j, { getLabel: S } = ue(), [U, B] = C(E ?? []), x = R(null), z = R(null);
|
|
30
|
+
re(q, () => ({ input: z.current, wrapper: x.current }), []);
|
|
31
|
+
const n = E ?? U, r = $ === "row", [d, K] = C(null), Q = ne((e) => K(e), []), N = R(0), [u, p] = C(null);
|
|
32
|
+
P(() => {
|
|
32
33
|
r && p(null);
|
|
33
|
-
}, [n.length, r]),
|
|
34
|
+
}, [n.length, r]), P(() => {
|
|
34
35
|
if (!r || !d || typeof ResizeObserver > "u") return;
|
|
35
36
|
const e = new ResizeObserver((t) => {
|
|
36
37
|
var c;
|
|
@@ -38,7 +39,7 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
38
39
|
l > 0 && l !== N.current && p(null);
|
|
39
40
|
});
|
|
40
41
|
return e.observe(d), () => e.disconnect();
|
|
41
|
-
}, [r, d]),
|
|
42
|
+
}, [r, d]), se(() => {
|
|
42
43
|
if (!r || u !== null) return;
|
|
43
44
|
const e = d;
|
|
44
45
|
if (!e) return;
|
|
@@ -55,8 +56,8 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
55
56
|
}
|
|
56
57
|
let A = 0, f = 0;
|
|
57
58
|
for (let s = 0; s < l.length; s++) {
|
|
58
|
-
const
|
|
59
|
-
if (L +
|
|
59
|
+
const te = l[s].offsetWidth, le = s < l.length - 1 ? de + y : 0, L = A + te + (f > 0 ? y : 0);
|
|
60
|
+
if (L + le <= t)
|
|
60
61
|
A = L, f++;
|
|
61
62
|
else
|
|
62
63
|
break;
|
|
@@ -64,13 +65,13 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
64
65
|
f === 0 && (f = 1), N.current = t, p(f);
|
|
65
66
|
}, [r, u, n, d]);
|
|
66
67
|
const O = (e) => {
|
|
67
|
-
|
|
68
|
-
},
|
|
68
|
+
B(e), _ == null || _(e);
|
|
69
|
+
}, Y = (e) => {
|
|
69
70
|
const t = n.filter((l, c) => c !== e);
|
|
70
71
|
O(t);
|
|
71
|
-
}, v = !b &&
|
|
72
|
+
}, v = !b && H && n.length > 0, Z = () => {
|
|
72
73
|
O([]);
|
|
73
|
-
}, w = r && u !== null ? Math.max(0, n.length - u) : 0,
|
|
74
|
+
}, w = r && u !== null ? Math.max(0, n.length - u) : 0, ee = () => {
|
|
74
75
|
if (!o) return null;
|
|
75
76
|
const e = typeof o == "string" ? { name: o } : o;
|
|
76
77
|
return k ? /* @__PURE__ */ a(
|
|
@@ -80,18 +81,18 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
80
81
|
className: g(i["tedi-multi-value-field__icon-wrapper"], h == null ? void 0 : h.className),
|
|
81
82
|
onClick: k,
|
|
82
83
|
type: "button",
|
|
83
|
-
children: /* @__PURE__ */ a(
|
|
84
|
+
children: /* @__PURE__ */ a(T, { ...e, size: 18 })
|
|
84
85
|
}
|
|
85
|
-
) : /* @__PURE__ */ a("div", { className: i["tedi-multi-value-field__icon-wrapper"], children: /* @__PURE__ */ a(
|
|
86
|
+
) : /* @__PURE__ */ a("div", { className: i["tedi-multi-value-field__icon-wrapper"], children: /* @__PURE__ */ a(T, { ...e, size: 18 }) });
|
|
86
87
|
};
|
|
87
88
|
return /* @__PURE__ */ m(
|
|
88
89
|
"div",
|
|
89
90
|
{
|
|
90
|
-
className: g(i["tedi-multi-value-field"],
|
|
91
|
-
[i["tedi-multi-value-field--clear-on-interaction"]]: v &&
|
|
91
|
+
className: g(i["tedi-multi-value-field"], D, {
|
|
92
|
+
[i["tedi-multi-value-field--clear-on-interaction"]]: v && J
|
|
92
93
|
}),
|
|
93
94
|
children: [
|
|
94
|
-
V && /* @__PURE__ */ a(
|
|
95
|
+
V && /* @__PURE__ */ a(ce, { id: G, label: V, required: M, labelProps: X }),
|
|
95
96
|
/* @__PURE__ */ m(
|
|
96
97
|
"div",
|
|
97
98
|
{
|
|
@@ -103,23 +104,23 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
103
104
|
n.length > 0 && /* @__PURE__ */ m(
|
|
104
105
|
"div",
|
|
105
106
|
{
|
|
106
|
-
ref:
|
|
107
|
+
ref: Q,
|
|
107
108
|
className: g(i["tedi-multi-value-field__tags"], {
|
|
108
109
|
[i["tedi-multi-value-field__tags--row"]]: r
|
|
109
110
|
}),
|
|
110
111
|
children: [
|
|
111
112
|
n.map((e, t) => r && u !== null && t >= u ? null : /* @__PURE__ */ a(
|
|
112
|
-
|
|
113
|
+
F,
|
|
113
114
|
{
|
|
114
115
|
color: I,
|
|
115
116
|
"data-tedi-tag-index": t,
|
|
116
|
-
onClose: b ? void 0 : () =>
|
|
117
|
+
onClose: b ? void 0 : () => Y(t),
|
|
117
118
|
children: e
|
|
118
119
|
},
|
|
119
120
|
`${e}-${t}`
|
|
120
121
|
)),
|
|
121
122
|
w > 0 && /* @__PURE__ */ m(
|
|
122
|
-
|
|
123
|
+
F,
|
|
123
124
|
{
|
|
124
125
|
color: I,
|
|
125
126
|
className: i["tedi-multi-value-field__overflow-tag"],
|
|
@@ -135,16 +136,16 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
135
136
|
),
|
|
136
137
|
(v || o) && /* @__PURE__ */ m("div", { className: i["tedi-multi-value-field__right-area"], children: [
|
|
137
138
|
v && /* @__PURE__ */ a(
|
|
138
|
-
|
|
139
|
+
ae,
|
|
139
140
|
{
|
|
140
|
-
onClick:
|
|
141
|
+
onClick: Z,
|
|
141
142
|
title: S("clear"),
|
|
142
143
|
className: i["tedi-multi-value-field__clear-button"],
|
|
143
144
|
iconSize: 18
|
|
144
145
|
}
|
|
145
146
|
),
|
|
146
|
-
v && o && /* @__PURE__ */ a(
|
|
147
|
-
o &&
|
|
147
|
+
v && o && /* @__PURE__ */ a(oe, { color: "primary", axis: "vertical", height: 1.5, spacing: 0.25 }),
|
|
148
|
+
o && ee()
|
|
148
149
|
] })
|
|
149
150
|
]
|
|
150
151
|
}
|
|
@@ -164,8 +165,8 @@ const y = 4, ue = 44, de = le((j, q) => {
|
|
|
164
165
|
}
|
|
165
166
|
);
|
|
166
167
|
});
|
|
167
|
-
|
|
168
|
+
fe.displayName = "MultiValueField";
|
|
168
169
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
fe as MultiValueField,
|
|
171
|
+
fe as default
|
|
171
172
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),T=require("../../../../../external/classnames/index.cjs.js"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),T=require("../../../../../external/classnames/index.cjs.js"),r=require("react"),fe=require("../../base/typography/text/text.cjs.js"),me=require("../../buttons/button/button.cjs.js"),be=require("../feedback-text/feedback-text.cjs.js"),pe=require("../form-label/form-label.cjs.js"),i=require("./number-field.module.scss.cjs.js"),ve=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),xe=require("../../../providers/label-provider/use-labels.cjs.js"),U=g=>{const{getCurrentBreakpointProps:G}=ve.useBreakpointProps(g.defaultServerBreakpoint),{getLabel:h,locale:J}=xe.useLabels(),K=J==="en"?".":",",{id:Q,label:k,hideLabel:X,labelProps:Y,required:w,className:P,size:q,inputMode:Z,decimalPlaces:x,decimalSeparator:j=K,min:d,max:o,step:M=1,defaultValue:C,value:c,onChange:a,suffix:S,fullWidth:ee=!1,disabled:N=!1,invalid:R=!1,helper:u,input:_}=G(g),te=r.useId(),E=Q??te,ne=Z??(x&&x>0||j===","?"decimal":"numeric"),m=r.useCallback(e=>e===void 0?"":j===","?String(e).replace(".",","):String(e),[j]),y=r.useRef(null),B=r.useRef(!1),[re,L]=r.useState(""),[ie,V]=r.useState(C),[ue,I]=r.useState(()=>m(c??C)),F=c!==void 0,n=F?c:ie,b=r.useRef(),p=r.useRef(),O=r.useRef(n);r.useEffect(()=>{!B.current&&typeof c<"u"&&I(m(c))},[c,m]);const $=u?`${E}-helper`:void 0,z=r.useCallback(e=>{if(e===void 0)return R||(u==null?void 0:u.type)==="error";const t=d!==void 0&&e<d,l=o!==void 0&&e>o;return R||t||l||(u==null?void 0:u.type)==="error"},[R,u,o,d]),A=e=>Math.min(o??1/0,Math.max(d??-1/0,e)),D=r.useCallback(e=>{e&&(L(""),b.current&&clearTimeout(b.current),p.current&&clearTimeout(p.current),b.current=setTimeout(()=>{L(e),p.current=setTimeout(()=>L(""),5e3)},100))},[]);r.useEffect(()=>()=>{b.current&&clearTimeout(b.current),p.current&&clearTimeout(p.current)},[]),r.useEffect(()=>{O.current!==n&&(!B.current&&n!==void 0&&D(h("numberField.quantityUpdated",n)),O.current=n)},[n,D,h]);const W=e=>x!==void 0?parseFloat(e.toFixed(x)):e,ae=e=>{let t=n??0;e==="increment"&&(t=t+M),e==="decrement"&&(t=t-M),t=A(t),t=W(t),a==null||a(t),F||V(t),I(m(t))},se=({currentTarget:{value:e}})=>{if(I(e),e===""){n!==void 0&&(a==null||a(void 0),F||V(void 0));return}const t=e.replace(",",".");if(!/^-?(\d+(\.\d*)?|\.\d+)$/.test(t))return;const l=parseFloat(t);if(Number.isNaN(l))return;const f=A(l),v=W(f);v!==n&&(a==null||a(v),F||V(v))},le=()=>{B.current=!0},de=()=>{B.current=!1,I(m(n))},H=e=>{const t=n!==void 0&&(e==="increment"?o!==void 0&&n>=o:d!==void 0&&n<=d),l=T.default(i.default["tedi-number-field__button"],i.default[`tedi-number-field__button--${e}`],{[i.default["tedi-number-field__button--disabled"]]:t||N}),f=typeof k=="string"?k:void 0,v=h(`numberField.${e}`,M,f);return s.jsx(me.Button,{"aria-label":v,onClick:()=>ae(e),disabled:t||N,visualType:"secondary",className:l,icon:{name:e==="increment"?"add":"remove"},size:q==="small"?"small":void 0,children:e==="increment"?"+":"-"})},oe=()=>{const e=T.default(i.default["tedi-number-field__input-wrapper"],{[i.default["tedi-number-field__input-wrapper--with-suffix"]]:S,[i.default["tedi-number-field__input-wrapper--full-width"]]:ee}),t=T.default(i.default["tedi-number-field__input"],_==null?void 0:_.className),l=()=>{var f;return(f=y==null?void 0:y.current)==null?void 0:f.focus()};return s.jsxs("div",{className:e,onClick:l,children:[s.jsx("input",{ref:y,id:E,role:"spinbutton","aria-valuemin":d,"aria-valuemax":o,"aria-valuenow":n,"aria-describedby":$,"aria-invalid":z(n)?"true":"false",type:"text",inputMode:ne,value:ue,required:w,disabled:N,onChange:se,onFocus:le,onBlur:de,className:t,..._}),S&&s.jsx(fe.Text,{element:"span",modifiers:"small",color:"tertiary",className:i.default["tedi-number-field__suffix"],children:S})]})},ce=T.default(i.default["tedi-number-field"],{[i.default["tedi-number-field--invalid"]]:z(n)},{[i.default["tedi-number-field--disabled"]]:N},{[i.default["tedi-number-field--small"]]:q==="small"},P);return s.jsxs("div",{"data-name":"number-field",className:P,children:[s.jsx(pe.FormLabel,{id:E,label:k,required:w,hideLabel:X,size:q,labelProps:Y}),s.jsxs("div",{className:ce,children:[H("decrement"),oe(),H("increment")]}),u&&s.jsx(be.FeedbackText,{className:i.default["tedi-number-field__feedback"],...u,id:$}),s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:re})]})};U.displayName="NumberField";exports.NumberField=U;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as P, jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import F from "../../../../../external/classnames/index.es.js";
|
|
3
|
-
import { useId as
|
|
4
|
-
import { Text as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { FeedbackText as
|
|
7
|
-
import { FormLabel as
|
|
3
|
+
import { useId as be, useCallback as $, useRef as v, useState as z, useEffect as C } from "react";
|
|
4
|
+
import { Text as ve } from "../../base/typography/text/text.es.js";
|
|
5
|
+
import { Button as Ne } from "../../buttons/button/button.es.js";
|
|
6
|
+
import { FeedbackText as _e } from "../feedback-text/feedback-text.es.js";
|
|
7
|
+
import { FormLabel as ye } from "../form-label/form-label.es.js";
|
|
8
8
|
import n from "./number-field.module.scss.es.js";
|
|
9
|
-
import { useBreakpointProps as
|
|
10
|
-
import { useLabels as
|
|
11
|
-
const
|
|
12
|
-
const { getCurrentBreakpointProps: Q } =
|
|
9
|
+
import { useBreakpointProps as Be } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
10
|
+
import { useLabels as Ie } from "../../../providers/label-provider/use-labels.es.js";
|
|
11
|
+
const he = (j) => {
|
|
12
|
+
const { getCurrentBreakpointProps: Q } = Be(j.defaultServerBreakpoint), { getLabel: T, locale: X } = Ie(), Y = X === "en" ? "." : ",", {
|
|
13
13
|
id: Z,
|
|
14
14
|
label: M,
|
|
15
15
|
hideLabel: ee,
|
|
16
|
+
labelProps: te,
|
|
16
17
|
required: q,
|
|
17
18
|
className: A,
|
|
18
19
|
size: k,
|
|
19
|
-
inputMode:
|
|
20
|
+
inputMode: re,
|
|
20
21
|
decimalPlaces: N,
|
|
21
22
|
decimalSeparator: S = Y,
|
|
22
23
|
min: a,
|
|
@@ -26,19 +27,19 @@ const Ie = (j) => {
|
|
|
26
27
|
value: u,
|
|
27
28
|
onChange: o,
|
|
28
29
|
suffix: w,
|
|
29
|
-
fullWidth:
|
|
30
|
+
fullWidth: ne = !1,
|
|
30
31
|
disabled: _ = !1,
|
|
31
32
|
invalid: E = !1,
|
|
32
33
|
helper: i,
|
|
33
34
|
input: y
|
|
34
|
-
} = Q(j),
|
|
35
|
+
} = Q(j), ie = be(), L = Z ?? ie, oe = re ?? (N && N > 0 || S === "," ? "decimal" : "numeric"), m = $(
|
|
35
36
|
(e) => e === void 0 ? "" : S === "," ? String(e).replace(".", ",") : String(e),
|
|
36
37
|
[S]
|
|
37
|
-
), B = v(null), I = v(!1), [
|
|
38
|
-
|
|
38
|
+
), B = v(null), I = v(!1), [ae, g] = z(""), [le, O] = z(D), [se, h] = z(() => m(u ?? D)), x = u !== void 0, r = x ? u : le, f = v(), p = v(), R = v(r);
|
|
39
|
+
C(() => {
|
|
39
40
|
!I.current && typeof u < "u" && h(m(u));
|
|
40
41
|
}, [u, m]);
|
|
41
|
-
const W = i ? `${L}-helper` : void 0, H =
|
|
42
|
+
const W = i ? `${L}-helper` : void 0, H = $(
|
|
42
43
|
(e) => {
|
|
43
44
|
if (e === void 0)
|
|
44
45
|
return E || (i == null ? void 0 : i.type) === "error";
|
|
@@ -46,20 +47,20 @@ const Ie = (j) => {
|
|
|
46
47
|
return E || t || s || (i == null ? void 0 : i.type) === "error";
|
|
47
48
|
},
|
|
48
49
|
[E, i, l, a]
|
|
49
|
-
), U = (e) => Math.min(l ?? 1 / 0, Math.max(a ?? -1 / 0, e)), G =
|
|
50
|
+
), U = (e) => Math.min(l ?? 1 / 0, Math.max(a ?? -1 / 0, e)), G = $((e) => {
|
|
50
51
|
e && (g(""), f.current && clearTimeout(f.current), p.current && clearTimeout(p.current), f.current = setTimeout(() => {
|
|
51
52
|
g(e), p.current = setTimeout(() => g(""), 5e3);
|
|
52
53
|
}, 100));
|
|
53
54
|
}, []);
|
|
54
|
-
|
|
55
|
+
C(() => () => {
|
|
55
56
|
f.current && clearTimeout(f.current), p.current && clearTimeout(p.current);
|
|
56
|
-
}, []),
|
|
57
|
+
}, []), C(() => {
|
|
57
58
|
R.current !== r && (!I.current && r !== void 0 && G(T("numberField.quantityUpdated", r)), R.current = r);
|
|
58
59
|
}, [r, G, T]);
|
|
59
|
-
const J = (e) => N !== void 0 ? parseFloat(e.toFixed(N)) : e,
|
|
60
|
+
const J = (e) => N !== void 0 ? parseFloat(e.toFixed(N)) : e, ue = (e) => {
|
|
60
61
|
let t = r ?? 0;
|
|
61
62
|
e === "increment" && (t = t + V), e === "decrement" && (t = t - V), t = U(t), t = J(t), o == null || o(t), x || O(t), h(m(t));
|
|
62
|
-
},
|
|
63
|
+
}, de = ({ currentTarget: { value: e } }) => {
|
|
63
64
|
if (h(e), e === "") {
|
|
64
65
|
r !== void 0 && (o == null || o(void 0), x || O(void 0));
|
|
65
66
|
return;
|
|
@@ -71,19 +72,19 @@ const Ie = (j) => {
|
|
|
71
72
|
if (Number.isNaN(s)) return;
|
|
72
73
|
const d = U(s), b = J(d);
|
|
73
74
|
b !== r && (o == null || o(b), x || O(b));
|
|
74
|
-
}, de = () => {
|
|
75
|
-
I.current = !0;
|
|
76
75
|
}, ce = () => {
|
|
76
|
+
I.current = !0;
|
|
77
|
+
}, me = () => {
|
|
77
78
|
I.current = !1, h(m(r));
|
|
78
79
|
}, K = (e) => {
|
|
79
80
|
const t = r !== void 0 && (e === "increment" ? l !== void 0 && r >= l : a !== void 0 && r <= a), s = F(n["tedi-number-field__button"], n[`tedi-number-field__button--${e}`], {
|
|
80
81
|
[n["tedi-number-field__button--disabled"]]: t || _
|
|
81
82
|
}), d = typeof M == "string" ? M : void 0, b = T(`numberField.${e}`, V, d);
|
|
82
83
|
return /* @__PURE__ */ c(
|
|
83
|
-
|
|
84
|
+
Ne,
|
|
84
85
|
{
|
|
85
86
|
"aria-label": b,
|
|
86
|
-
onClick: () =>
|
|
87
|
+
onClick: () => ue(e),
|
|
87
88
|
disabled: t || _,
|
|
88
89
|
visualType: "secondary",
|
|
89
90
|
className: s,
|
|
@@ -92,12 +93,12 @@ const Ie = (j) => {
|
|
|
92
93
|
children: e === "increment" ? "+" : "-"
|
|
93
94
|
}
|
|
94
95
|
);
|
|
95
|
-
},
|
|
96
|
+
}, fe = () => {
|
|
96
97
|
const e = F(n["tedi-number-field__input-wrapper"], {
|
|
97
98
|
[n["tedi-number-field__input-wrapper--with-suffix"]]: w,
|
|
98
|
-
[n["tedi-number-field__input-wrapper--full-width"]]:
|
|
99
|
+
[n["tedi-number-field__input-wrapper--full-width"]]: ne
|
|
99
100
|
}), t = F(n["tedi-number-field__input"], y == null ? void 0 : y.className);
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ P("div", { className: e, onClick: () => {
|
|
101
102
|
var d;
|
|
102
103
|
return (d = B == null ? void 0 : B.current) == null ? void 0 : d.focus();
|
|
103
104
|
}, children: [
|
|
@@ -113,38 +114,48 @@ const Ie = (j) => {
|
|
|
113
114
|
"aria-describedby": W,
|
|
114
115
|
"aria-invalid": H(r) ? "true" : "false",
|
|
115
116
|
type: "text",
|
|
116
|
-
inputMode:
|
|
117
|
-
value:
|
|
117
|
+
inputMode: oe,
|
|
118
|
+
value: se,
|
|
118
119
|
required: q,
|
|
119
120
|
disabled: _,
|
|
120
|
-
onChange:
|
|
121
|
-
onFocus:
|
|
122
|
-
onBlur:
|
|
121
|
+
onChange: de,
|
|
122
|
+
onFocus: ce,
|
|
123
|
+
onBlur: me,
|
|
123
124
|
className: t,
|
|
124
125
|
...y
|
|
125
126
|
}
|
|
126
127
|
),
|
|
127
|
-
w && /* @__PURE__ */ c(
|
|
128
|
+
w && /* @__PURE__ */ c(ve, { element: "span", modifiers: "small", color: "tertiary", className: n["tedi-number-field__suffix"], children: w })
|
|
128
129
|
] });
|
|
129
|
-
},
|
|
130
|
+
}, pe = F(
|
|
130
131
|
n["tedi-number-field"],
|
|
131
132
|
{ [n["tedi-number-field--invalid"]]: H(r) },
|
|
132
133
|
{ [n["tedi-number-field--disabled"]]: _ },
|
|
133
134
|
{ [n["tedi-number-field--small"]]: k === "small" },
|
|
134
135
|
A
|
|
135
136
|
);
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */ c(
|
|
138
|
-
|
|
137
|
+
return /* @__PURE__ */ P("div", { "data-name": "number-field", className: A, children: [
|
|
138
|
+
/* @__PURE__ */ c(
|
|
139
|
+
ye,
|
|
140
|
+
{
|
|
141
|
+
id: L,
|
|
142
|
+
label: M,
|
|
143
|
+
required: q,
|
|
144
|
+
hideLabel: ee,
|
|
145
|
+
size: k,
|
|
146
|
+
labelProps: te
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ P("div", { className: pe, children: [
|
|
139
150
|
K("decrement"),
|
|
140
|
-
|
|
151
|
+
fe(),
|
|
141
152
|
K("increment")
|
|
142
153
|
] }),
|
|
143
|
-
i && /* @__PURE__ */ c(
|
|
144
|
-
/* @__PURE__ */ c("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children:
|
|
154
|
+
i && /* @__PURE__ */ c(_e, { className: n["tedi-number-field__feedback"], ...i, id: W }),
|
|
155
|
+
/* @__PURE__ */ c("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: ae })
|
|
145
156
|
] });
|
|
146
157
|
};
|
|
147
|
-
|
|
158
|
+
he.displayName = "NumberField";
|
|
148
159
|
export {
|
|
149
|
-
|
|
160
|
+
he as NumberField
|
|
150
161
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./radio.cjs.js"),o=require("./radio-group/radio-group.cjs.js"),i=Object.assign(r.Radio,{Group:o.RadioGroup});exports.RadioGroup=o.RadioGroup;exports.Radio=i;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RadioProps } from './radio';
|
|
2
|
+
import { default as RadioGroup } from './radio-group/radio-group';
|
|
3
|
+
declare const Radio: {
|
|
4
|
+
(props: RadioProps): JSX.Element;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
Group: typeof RadioGroup;
|
|
7
|
+
};
|
|
8
|
+
export { Radio, RadioGroup };
|
|
9
|
+
export type { RadioProps } from './radio';
|
|
10
|
+
export type { RadioGroupProps } from './radio-group/radio-group';
|
|
11
|
+
export default Radio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=t.createContext(null);exports.RadioGroupContext=e;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChoiceInputCardVariant, ChoiceInputVariant } from '../../choice-input.types';
|
|
3
|
+
export interface RadioGroupContextValue {
|
|
4
|
+
/** Shared `name` for all radios in the group. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Currently selected value (`null` when nothing is selected). */
|
|
7
|
+
value: string | null;
|
|
8
|
+
/** Called by a `Radio` when it is selected. */
|
|
9
|
+
onValueChange: (value: string) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
invalid?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
size?: 'default' | 'large';
|
|
14
|
+
variant?: ChoiceInputVariant;
|
|
15
|
+
cardVariant?: ChoiceInputCardVariant;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Provided by `Radio.Group`. When present, a `Radio` reads its selection,
|
|
19
|
+
* `name`, and shared visual props from here instead of managing its own state.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RadioGroupContext: React.Context<RadioGroupContextValue | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),V=require("../../../../../../external/classnames/index.cjs.js"),r=require("react"),z=require("../../feedback-text/feedback-text.cjs.js"),e=require("./radio-group.module.scss.cjs.js"),F=require("./radio-group-context.cjs.js"),L=require("../../../../helpers/hooks/use-breakpoint-props.cjs.js"),c=p=>{const{getCurrentBreakpointProps:k}=L.useBreakpointProps(p.defaultServerBreakpoint),{id:I,name:C,label:l,hideLabel:G=!1,helper:d,className:R,value:g,defaultValue:P=null,onChange:t,disabled:u,invalid:s,required:i,size:m,variant:o="default",cardVariant:f="primary",direction:v=o==="card"?"row":"column",layout:b="separated",children:B}=k(p),S=r.useId(),h=I??S,M=r.useId(),x=C??M,n=g!==void 0,[T,$]=r.useState(P),q=n?g??null:T,_=d?d.id??`${h}-helper`:void 0,j=`${h}-legend`,y=r.useCallback(N=>{n||$(N),t==null||t(N)},[n,t]),w=r.useMemo(()=>({name:x,value:q,onValueChange:y,disabled:u,invalid:s,required:i,size:m,variant:o,cardVariant:f}),[x,q,y,u,s,i,m,o,f]);return a.jsxs("fieldset",{className:V.default(e.default["tedi-radio-group"],e.default[`tedi-radio-group--${v}`],{[e.default["tedi-radio-group--card"]]:o==="card"},{[e.default["tedi-radio-group--segmented"]]:b==="segmented"},R),role:"radiogroup","aria-labelledby":l?j:void 0,disabled:u,"aria-invalid":s||void 0,"aria-required":i||void 0,"aria-describedby":_,children:[l&&a.jsxs("legend",{id:j,className:V.default(e.default["tedi-radio-group__legend"],{"sr-only":G}),children:[l,i&&a.jsx("span",{"aria-hidden":"true",className:e.default["tedi-radio-group__required"],children:"*"})]}),a.jsx(F.RadioGroupContext.Provider,{value:w,children:a.jsx("div",{className:e.default["tedi-radio-group__items"],"data-layout":b,"data-direction":v,children:B})}),d&&a.jsx(z.FeedbackText,{id:_,...d})]})};c.displayName="Radio.Group";exports.RadioGroup=c;exports.default=c;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BreakpointSupport } from '../../../../helpers';
|
|
3
|
+
import { ChoiceInputCardVariant, ChoiceInputVariant } from '../../choice-input.types';
|
|
4
|
+
import { FeedbackTextProps } from '../../feedback-text/feedback-text';
|
|
5
|
+
interface RadioGroupBreakpointProps {
|
|
6
|
+
/** Group id. When omitted a stable id is generated. */
|
|
7
|
+
id?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Shared `name` for the radios. When omitted a stable name is generated so the
|
|
10
|
+
* group still behaves as a single native radio group.
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Group label, rendered as the fieldset legend. */
|
|
14
|
+
label: React.ReactNode;
|
|
15
|
+
/** Visually hide the legend while keeping it available to screen readers. */
|
|
16
|
+
hideLabel?: boolean;
|
|
17
|
+
/** Helper / feedback text rendered below the group. */
|
|
18
|
+
helper?: FeedbackTextProps;
|
|
19
|
+
/** Additional class name(s) applied to the fieldset. */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Controlled selected value. Pair with `onChange`. */
|
|
22
|
+
value?: string | null;
|
|
23
|
+
/** Uncontrolled initial selected value. */
|
|
24
|
+
defaultValue?: string | null;
|
|
25
|
+
/** Fires with the newly selected value. */
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
/** Disables the whole group and every radio within it. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Marks the group as invalid, forwarding the error state to each radio. */
|
|
30
|
+
invalid?: boolean;
|
|
31
|
+
/** Marks the group as required, adding a required indicator to the legend. */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
/** Size forwarded to every radio. @default 'default' */
|
|
34
|
+
size?: 'default' | 'large';
|
|
35
|
+
/** Visual variant forwarded to every radio. @default 'default' */
|
|
36
|
+
variant?: ChoiceInputVariant;
|
|
37
|
+
/** Card colour variant forwarded to every radio (only applies to `variant="card"`). @default 'primary' */
|
|
38
|
+
cardVariant?: ChoiceInputCardVariant;
|
|
39
|
+
/** Layout direction of the radios. Defaults to `row` for cards, `column` otherwise. */
|
|
40
|
+
direction?: 'row' | 'column';
|
|
41
|
+
/**
|
|
42
|
+
* Card layout. `separated` = individual cards with a gap; `segmented` = joined
|
|
43
|
+
* cards with shared borders and only the group's outer corners rounded (a
|
|
44
|
+
* button-group style). Only applies to `variant="card"`.
|
|
45
|
+
* @default separated
|
|
46
|
+
*/
|
|
47
|
+
layout?: 'separated' | 'segmented';
|
|
48
|
+
/** The `Radio` items that make up the group. */
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
export type RadioGroupProps = BreakpointSupport<RadioGroupBreakpointProps>;
|
|
52
|
+
export declare const RadioGroup: {
|
|
53
|
+
(props: RadioGroupProps): JSX.Element;
|
|
54
|
+
displayName: string;
|
|
55
|
+
};
|
|
56
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsxs as k, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import x from "../../../../../../external/classnames/index.es.js";
|
|
3
|
+
import a from "react";
|
|
4
|
+
import { FeedbackText as L } from "../../feedback-text/feedback-text.es.js";
|
|
5
|
+
import e from "./radio-group.module.scss.es.js";
|
|
6
|
+
import { RadioGroupContext as M } from "./radio-group-context.es.js";
|
|
7
|
+
import { useBreakpointProps as T } from "../../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
8
|
+
const A = (c) => {
|
|
9
|
+
const { getCurrentBreakpointProps: C } = T(c.defaultServerBreakpoint), {
|
|
10
|
+
id: R,
|
|
11
|
+
name: q,
|
|
12
|
+
label: l,
|
|
13
|
+
hideLabel: B = !1,
|
|
14
|
+
helper: r,
|
|
15
|
+
className: G,
|
|
16
|
+
value: m,
|
|
17
|
+
defaultValue: P = null,
|
|
18
|
+
onChange: d,
|
|
19
|
+
disabled: s,
|
|
20
|
+
invalid: n,
|
|
21
|
+
required: o,
|
|
22
|
+
size: p,
|
|
23
|
+
variant: i = "default",
|
|
24
|
+
cardVariant: g = "primary",
|
|
25
|
+
direction: v = i === "card" ? "row" : "column",
|
|
26
|
+
layout: f = "separated",
|
|
27
|
+
children: $
|
|
28
|
+
} = C(c), j = a.useId(), h = R ?? j, S = a.useId(), b = q ?? S, u = m !== void 0, [w, z] = a.useState(P), N = u ? m ?? null : w, y = r ? r.id ?? `${h}-helper` : void 0, V = `${h}-legend`, _ = a.useCallback(
|
|
29
|
+
(I) => {
|
|
30
|
+
u || z(I), d == null || d(I);
|
|
31
|
+
},
|
|
32
|
+
[u, d]
|
|
33
|
+
), F = a.useMemo(
|
|
34
|
+
() => ({
|
|
35
|
+
name: b,
|
|
36
|
+
value: N,
|
|
37
|
+
onValueChange: _,
|
|
38
|
+
disabled: s,
|
|
39
|
+
invalid: n,
|
|
40
|
+
required: o,
|
|
41
|
+
size: p,
|
|
42
|
+
variant: i,
|
|
43
|
+
cardVariant: g
|
|
44
|
+
}),
|
|
45
|
+
[b, N, _, s, n, o, p, i, g]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ k(
|
|
48
|
+
"fieldset",
|
|
49
|
+
{
|
|
50
|
+
className: x(
|
|
51
|
+
e["tedi-radio-group"],
|
|
52
|
+
e[`tedi-radio-group--${v}`],
|
|
53
|
+
{ [e["tedi-radio-group--card"]]: i === "card" },
|
|
54
|
+
{ [e["tedi-radio-group--segmented"]]: f === "segmented" },
|
|
55
|
+
G
|
|
56
|
+
),
|
|
57
|
+
role: "radiogroup",
|
|
58
|
+
"aria-labelledby": l ? V : void 0,
|
|
59
|
+
disabled: s,
|
|
60
|
+
"aria-invalid": n || void 0,
|
|
61
|
+
"aria-required": o || void 0,
|
|
62
|
+
"aria-describedby": y,
|
|
63
|
+
children: [
|
|
64
|
+
l && /* @__PURE__ */ k("legend", { id: V, className: x(e["tedi-radio-group__legend"], { "sr-only": B }), children: [
|
|
65
|
+
l,
|
|
66
|
+
o && /* @__PURE__ */ t("span", { "aria-hidden": "true", className: e["tedi-radio-group__required"], children: "*" })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ t(M.Provider, { value: F, children: /* @__PURE__ */ t("div", { className: e["tedi-radio-group__items"], "data-layout": f, "data-direction": v, children: $ }) }),
|
|
69
|
+
r && /* @__PURE__ */ t(L, { id: y, ...r })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
A.displayName = "Radio.Group";
|
|
75
|
+
export {
|
|
76
|
+
A as RadioGroup,
|
|
77
|
+
A as default
|
|
78
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d={"tedi-radio-group":"tedi-radio-group-9afc9d2d","tedi-radio-group__legend":"tedi-radio-group__legend-b05d4880","tedi-radio-group__required":"tedi-radio-group__required-d42646cf","tedi-radio-group__items":"tedi-radio-group__items-aa5bd239","tedi-radio-group--column":"tedi-radio-group--column-45aad530","tedi-radio-group--row":"tedi-radio-group--row-c3eb1dfe","tedi-radio-group--card":"tedi-radio-group--card-5828dd1c","tedi-radio-group--segmented":"tedi-radio-group--segmented-2b67e0c6"};exports.default=d;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const d = {
|
|
2
|
+
"tedi-radio-group": "tedi-radio-group-9afc9d2d",
|
|
3
|
+
"tedi-radio-group__legend": "tedi-radio-group__legend-b05d4880",
|
|
4
|
+
"tedi-radio-group__required": "tedi-radio-group__required-d42646cf",
|
|
5
|
+
"tedi-radio-group__items": "tedi-radio-group__items-aa5bd239",
|
|
6
|
+
"tedi-radio-group--column": "tedi-radio-group--column-45aad530",
|
|
7
|
+
"tedi-radio-group--row": "tedi-radio-group--row-c3eb1dfe",
|
|
8
|
+
"tedi-radio-group--card": "tedi-radio-group--card-5828dd1c",
|
|
9
|
+
"tedi-radio-group--segmented": "tedi-radio-group--segmented-2b67e0c6"
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
d as default
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),r=require("../../../../../external/classnames/index.cjs.js"),s=require("react"),ee=require("../../base/icon/icon.cjs.js"),R=require("../feedback-text/feedback-text.cjs.js"),ae=require("../form-label/form-label.cjs.js"),a=require("./radio.module.scss.cjs.js"),de=require("./radio-group/radio-group-context.cjs.js"),ie=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),te=require("../../layout/grid/row.cjs.js"),z=require("../../layout/grid/col.cjs.js"),N=j=>{const e=s.useContext(de.RadioGroupContext),{getCurrentBreakpointProps:$}=ie.useBreakpointProps(j.defaultServerBreakpoint),{id:L,label:c,value:o,className:q,onChange:l,hideLabel:v,helper:t,checked:u,defaultChecked:V,hover:M,name:S,tooltip:k,description:b,icon:h,labelProps:T,size:E,variant:F,cardVariant:G,disabled:D,invalid:H,required:y,...C}=$(j),p=E??(e==null?void 0:e.size)??"default",P=F??(e==null?void 0:e.variant)??"default",O=G??(e==null?void 0:e.cardVariant)??"primary",f=D??(e==null?void 0:e.disabled)??!1,U=H??(e==null?void 0:e.invalid),A=y??(e==null?void 0:e.required);P==="card"&&k&&console.warn('Radio: `tooltip` is not supported with `variant="card"` and will be ignored. Use `description`.');const J=s.useId(),n=L??J,K=S??(e==null?void 0:e.name),[w,Q]=s.useState(V||!1),_=e!==null,W=s.useMemo(()=>_?(e==null?void 0:e.value)===o:l&&typeof u<"u"?u:w,[_,e,o,l,u,w]),X=i=>{_?e==null||e.onValueChange(o):typeof u>"u"&&Q(i==null?void 0:i.target.checked),l==null||l(o,i==null?void 0:i.target.checked)},m=t?t.id??`${n}-helper`:void 0,Y=m,B=d.jsx("input",{id:n,value:o,name:K,type:"radio",disabled:f,checked:W,required:A,onChange:X,className:a.default["tedi-radio__input"],"aria-describedby":Y}),x=d.jsx("span",{"aria-hidden":"true",className:r.default(a.default["tedi-radio__indicator"],{[a.default["tedi-radio__indicator--hover"]]:M},{[a.default[`tedi-radio__indicator--size-${p}`]]:p},{[a.default["tedi-radio__indicator--invalid"]]:U}),"data-testid":"radio-indicator"});if(P==="card"){const i=`${n}-label`,I=b?`${n}-description`:void 0,g=[I,m].filter(Boolean).join(" ")||void 0;return d.jsxs("label",{"data-name":"radio",className:r.default(a.default["tedi-radio"],a.default["tedi-radio--card"],a.default[`tedi-radio--card-${O}`],{[a.default["tedi-radio--card-with-icon"]]:!!h},{[a.default["tedi-radio--disabled"]]:f},q),...C,children:[d.jsxs("span",{className:a.default["tedi-radio__card-control"],children:[s.cloneElement(B,{"aria-labelledby":c?i:void 0,"aria-describedby":g}),x,h&&d.jsx(ee.Icon,{name:h,size:p==="default"?18:24,className:a.default["tedi-radio__card-icon"]}),d.jsx("span",{id:i,className:r.default(a.default["tedi-radio__card-label"],{"sr-only":v}),children:c})]}),b&&d.jsx("span",{id:I,className:a.default["tedi-radio__card-description"],children:b}),t&&d.jsx(R.FeedbackText,{id:m,...t,className:r.default(a.default["tedi-radio__helper"],t.className)})]})}const Z=r.default(a.default["tedi-radio__label"],{[a.default["tedi-radio--disabled"]]:f});return d.jsxs("div",{className:r.default(a.default["tedi-radio"],{[a.default["tedi-radio--disabled"]]:f}),"data-name":"radio",...C,children:[d.jsxs(te.Row,{gutter:0,children:[d.jsx(z.Col,{width:"auto",children:d.jsxs("div",{className:a.default["tedi-radio__outer-indicator-wrapper"],children:[B,s.cloneElement(x,{className:r.default(x.props.className,q)})]})}),c&&d.jsx(z.Col,{children:d.jsx(ae.FormLabel,{className:Z,id:n,"data-testid":"radio-label",hideLabel:v,label:c,tooltip:k,required:y,labelProps:T})})]}),t&&d.jsx(R.FeedbackText,{id:m,...t,className:r.default(a.default["tedi-radio__helper"],t.className)})]})};N.displayName="Radio";exports.Radio=N;exports.default=N;
|