@tedi-design-system/react 18.1.0-rc.23 → 18.1.0-rc.25
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/index.css +1 -1
- package/package.json +1 -1
- package/src/tedi/components/content/label/label.cjs.js +1 -1
- package/src/tedi/components/content/label/label.d.ts +4 -3
- package/src/tedi/components/content/label/label.es.js +24 -27
- package/src/tedi/components/content/label/label.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/label/label.module.scss.es.js +2 -1
- package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.es.js +64 -58
- package/src/tedi/components/form/choice-group/choice-group.cjs.js +1 -1
- package/src/tedi/components/form/choice-group/choice-group.es.js +98 -85
- 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 +13 -14
- package/src/tedi/components/form/choice-input.types.d.ts +3 -2
- package/src/tedi/components/form/form-label/form-label.d.ts +1 -1
- package/src/tedi/components/form/radio/radio.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.es.js +24 -23
- package/src/tedi/components/overlays/tooltip/index.d.ts +1 -0
- package/src/tedi/components/overlays/tooltip/info-tooltip.cjs.js +1 -0
- package/src/tedi/components/overlays/tooltip/info-tooltip.d.ts +52 -0
- package/src/tedi/components/overlays/tooltip/info-tooltip.es.js +24 -0
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +156 -154
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),q=require("../../../../../external/classnames/index.cjs.js"),h=require("react"),j=require("../../overlays/tooltip/info-tooltip.cjs.js"),e=require("./label.module.scss.cjs.js"),x=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),i=h.forwardRef((a,n)=>{const{getCurrentBreakpointProps:o}=x.useBreakpointProps(a.defaultServerBreakpoint),{as:d="label",children:u,className:c,isBold:b,isSmall:t,required:f,tooltip:r,...p}=o(a),m=q.default(e.default["tedi-label"],b&&e.default["tedi-label--bold"],t&&e.default["tedi-label--small"],c),s=l.jsxs(d,{ref:n,className:m,...p,children:[u,f&&l.jsx("span",{className:e.default["tedi-label__required"],"aria-hidden":"true",children:"*"})]});return r?l.jsxs("span",{className:e.default["tedi-label__wrapper"],children:[s,l.jsx("span",{className:e.default["tedi-label__info"],children:l.jsx(j.InfoTooltip,{isSmall:t,children:r})})]}):s});i.displayName="Label";exports.Label=i;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementType, LabelHTMLAttributes } from 'react';
|
|
1
|
+
import { ElementType, LabelHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { BreakpointSupport } from '../../../helpers';
|
|
3
3
|
type LabelBreakpointProps = {
|
|
4
4
|
/**
|
|
@@ -27,10 +27,11 @@ export interface LabelProps extends BreakpointSupport<LabelBreakpointProps>, Lab
|
|
|
27
27
|
*/
|
|
28
28
|
required?: boolean;
|
|
29
29
|
/**
|
|
30
|
-
* Tooltip content to display when hovering over the info button.
|
|
30
|
+
* Tooltip content to display when hovering over the info button. Accepts rich
|
|
31
|
+
* content (e.g. bold text, links), not just a plain string.
|
|
31
32
|
* If provided, an info button with a tooltip will be rendered.
|
|
32
33
|
*/
|
|
33
|
-
tooltip?:
|
|
34
|
+
tooltip?: ReactNode;
|
|
34
35
|
}
|
|
35
36
|
export declare const Label: import('react').ForwardRefExoticComponent<LabelProps & import('react').RefAttributes<HTMLLabelElement | HTMLSpanElement>>;
|
|
36
37
|
export {};
|
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
import { jsxs as i, jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import h from "../../../../../external/classnames/index.es.js";
|
|
3
3
|
import { forwardRef as N } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const k = N((o, s) => {
|
|
10
|
-
const { getCurrentBreakpointProps: n } = L(o.defaultServerBreakpoint), {
|
|
4
|
+
import { InfoTooltip as _ } from "../../overlays/tooltip/info-tooltip.es.js";
|
|
5
|
+
import e from "./label.module.scss.es.js";
|
|
6
|
+
import { useBreakpointProps as B } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
7
|
+
const k = N((r, o) => {
|
|
8
|
+
const { getCurrentBreakpointProps: n } = B(r.defaultServerBreakpoint), {
|
|
11
9
|
as: m = "label",
|
|
12
10
|
children: d,
|
|
13
|
-
className:
|
|
14
|
-
isBold:
|
|
15
|
-
isSmall:
|
|
16
|
-
required:
|
|
17
|
-
tooltip:
|
|
18
|
-
...
|
|
19
|
-
} = n(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
return /* @__PURE__ */ i(m, { ref: s, className: h, ...b, children: [
|
|
11
|
+
className: p,
|
|
12
|
+
isBold: c,
|
|
13
|
+
isSmall: a,
|
|
14
|
+
required: b,
|
|
15
|
+
tooltip: s,
|
|
16
|
+
...f
|
|
17
|
+
} = n(r), u = h(
|
|
18
|
+
e["tedi-label"],
|
|
19
|
+
c && e["tedi-label--bold"],
|
|
20
|
+
a && e["tedi-label--small"],
|
|
21
|
+
p
|
|
22
|
+
), t = /* @__PURE__ */ i(m, { ref: o, className: u, ...f, children: [
|
|
26
23
|
d,
|
|
27
|
-
|
|
28
|
-
a && /* @__PURE__ */ e("span", { "aria-hidden": "true", className: r["tedi-label__info"], children: /* @__PURE__ */ i(l, { children: [
|
|
29
|
-
/* @__PURE__ */ e(l.Trigger, { children: /* @__PURE__ */ e(g, { isSmall: t, "aria-label": u("infoButton.moreInformation") }) }),
|
|
30
|
-
/* @__PURE__ */ e(l.Content, { children: a })
|
|
31
|
-
] }) })
|
|
24
|
+
b && /* @__PURE__ */ l("span", { className: e["tedi-label__required"], "aria-hidden": "true", children: "*" })
|
|
32
25
|
] });
|
|
26
|
+
return s ? /* @__PURE__ */ i("span", { className: e["tedi-label__wrapper"], children: [
|
|
27
|
+
t,
|
|
28
|
+
/* @__PURE__ */ l("span", { className: e["tedi-label__info"], children: /* @__PURE__ */ l(_, { isSmall: a, children: s }) })
|
|
29
|
+
] }) : t;
|
|
33
30
|
});
|
|
34
31
|
k.displayName = "Label";
|
|
35
32
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-label":"tedi-label-473ab627","tedi-label--small":"tedi-label--small-20e328dc","tedi-label--bold":"tedi-label--bold-9d758835","tedi-label__required":"tedi-label__required-414e3f9d","tedi-label__info":"tedi-label__info-c9df19b4"};exports.default=e;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-label":"tedi-label-473ab627","tedi-label--small":"tedi-label--small-20e328dc","tedi-label--bold":"tedi-label--bold-9d758835","tedi-label__required":"tedi-label__required-414e3f9d","tedi-label__info":"tedi-label__info-c9df19b4","tedi-label__wrapper":"tedi-label__wrapper-db98e7da"};exports.default=e;
|
|
@@ -3,7 +3,8 @@ const e = {
|
|
|
3
3
|
"tedi-label--small": "tedi-label--small-20e328dc",
|
|
4
4
|
"tedi-label--bold": "tedi-label--bold-9d758835",
|
|
5
5
|
"tedi-label__required": "tedi-label__required-414e3f9d",
|
|
6
|
-
"tedi-label__info": "tedi-label__info-c9df19b4"
|
|
6
|
+
"tedi-label__info": "tedi-label__info-c9df19b4",
|
|
7
|
+
"tedi-label__wrapper": "tedi-label__wrapper-db98e7da"
|
|
7
8
|
};
|
|
8
9
|
export {
|
|
9
10
|
e as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),d=require("../../../../../external/classnames/index.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),d=require("../../../../../external/classnames/index.cjs.js"),r=require("react"),j=require("../../base/icon/icon.cjs.js"),B=require("../feedback-text/feedback-text.cjs.js"),E=require("../form-label/form-label.cjs.js"),e=require("./checkbox.module.scss.cjs.js"),F=require("../../layout/grid/row.cjs.js"),q=require("../../layout/grid/col.cjs.js"),C=N=>{const{id:a,label:h,value:b,className:R,disabled:n=!1,onChange:l,hideLabel:g=!1,helper:i,checked:u,defaultChecked:v,indeterminate:o,hover:y,name:I,tooltip:k,invalid:x,size:s="default",required:_,...w}=N,[z,L]=r.useState(v||!1),m=r.useRef(null),f=r.useRef(null),M=l&&typeof u<"u"?u:z;r.useEffect(()=>{f.current&&(f.current.indeterminate=!!o)},[o]);const S=t=>{typeof u>"u"&&L(t==null?void 0:t.target.checked),l==null||l(b,t==null?void 0:t.target.checked)},p=i?i.id??`${a}-helper`:void 0,T=k?`${a}-tooltip`:void 0,$=d.default(e.default["tedi-checkbox__label"],{[e.default["tedi-checkbox--disabled"]]:n});return c.jsxs("div",{className:d.default(e.default["tedi-checkbox"],{[e.default["tedi-checkbox--disabled"]]:n}),"data-name":"check",...w,children:[c.jsxs(F.Row,{gutter:0,children:[c.jsx(q.Col,{width:"auto",children:c.jsxs("div",{className:e.default["tedi-checkbox__outer-indicator-wrapper"],children:[c.jsx("input",{ref:f,id:a,value:b,name:I,type:"checkbox",disabled:n,checked:o?!1:M,onChange:S,className:e.default["tedi-checkbox__input"],"aria-describedby":[p,T].filter(Boolean).join(" "),required:_,"aria-invalid":x||void 0}),c.jsxs("div",{"aria-hidden":"true",onClick:()=>{var t;return(t=m.current)==null?void 0:t.click()},className:d.default(e.default["tedi-checkbox__indicator"],{[e.default["tedi-checkbox__indicator--hover"]]:y,[e.default["tedi-checkbox__indicator--indeterminate"]]:o,[e.default[`tedi-checkbox__indicator--size-${s}`]]:s,[e.default["tedi-checkbox__indicator--invalid"]]:x},R),"data-testid":"checkbox-indicator",children:[c.jsx(j.Icon,{size:s==="default"?16:18,name:"remove",className:d.default(e.default["tedi-checkbox__icon"],e.default["tedi-checkbox__icon--indeterminate"])}),c.jsx(j.Icon,{size:s==="default"?16:18,name:"check",className:d.default(e.default["tedi-checkbox__icon"],e.default["tedi-checkbox__icon--check"])})]})]})}),h&&c.jsx(q.Col,{children:c.jsx(E.FormLabel,{ref:m,className:$,id:a,"data-testid":"checkbox-label",hideLabel:g,label:h,tooltip:k,required:_})})]}),i&&c.jsx(B.FeedbackText,{id:p,...i,className:d.default(e.default["tedi-checkbox__helper"],i.className)})]})};exports.Checkbox=C;exports.default=C;
|
|
@@ -1,57 +1,63 @@
|
|
|
1
1
|
import { jsxs as s, jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { FeedbackText as
|
|
6
|
-
import { FormLabel as
|
|
2
|
+
import t from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import n from "react";
|
|
4
|
+
import { Icon as C } from "../../base/icon/icon.es.js";
|
|
5
|
+
import { FeedbackText as H } from "../feedback-text/feedback-text.es.js";
|
|
6
|
+
import { FormLabel as M } from "../form-label/form-label.es.js";
|
|
7
7
|
import e from "./checkbox.module.scss.es.js";
|
|
8
|
-
import { Row as
|
|
9
|
-
import { Col as
|
|
10
|
-
const
|
|
8
|
+
import { Row as S } from "../../layout/grid/row.es.js";
|
|
9
|
+
import { Col as R } from "../../layout/grid/col.es.js";
|
|
10
|
+
const U = (y) => {
|
|
11
11
|
const {
|
|
12
|
-
id:
|
|
13
|
-
label:
|
|
14
|
-
value:
|
|
15
|
-
className:
|
|
16
|
-
disabled:
|
|
17
|
-
onChange:
|
|
18
|
-
hideLabel:
|
|
19
|
-
helper:
|
|
20
|
-
checked:
|
|
21
|
-
defaultChecked:
|
|
22
|
-
indeterminate:
|
|
23
|
-
hover:
|
|
12
|
+
id: o,
|
|
13
|
+
label: k,
|
|
14
|
+
value: b,
|
|
15
|
+
className: g,
|
|
16
|
+
disabled: h = !1,
|
|
17
|
+
onChange: a,
|
|
18
|
+
hideLabel: v = !1,
|
|
19
|
+
helper: d,
|
|
20
|
+
checked: m,
|
|
21
|
+
defaultChecked: z,
|
|
22
|
+
indeterminate: r,
|
|
23
|
+
hover: I,
|
|
24
24
|
name: j,
|
|
25
25
|
tooltip: _,
|
|
26
|
-
invalid:
|
|
26
|
+
invalid: u,
|
|
27
27
|
size: l = "default",
|
|
28
|
-
required:
|
|
29
|
-
|
|
30
|
-
} =
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
required: p,
|
|
29
|
+
...w
|
|
30
|
+
} = y, [L, $] = n.useState(z || !1), x = n.useRef(null), f = n.useRef(null), B = a && typeof m < "u" ? m : L;
|
|
31
|
+
n.useEffect(() => {
|
|
32
|
+
f.current && (f.current.indeterminate = !!r);
|
|
33
|
+
}, [r]);
|
|
34
|
+
const E = (c) => {
|
|
35
|
+
typeof m > "u" && $(c == null ? void 0 : c.target.checked), a == null || a(b, c == null ? void 0 : c.target.checked);
|
|
36
|
+
}, N = d ? d.id ?? `${o}-helper` : void 0, F = _ ? `${o}-tooltip` : void 0, q = t(e["tedi-checkbox__label"], { [e["tedi-checkbox--disabled"]]: h });
|
|
33
37
|
return /* @__PURE__ */ s(
|
|
34
38
|
"div",
|
|
35
39
|
{
|
|
36
|
-
className:
|
|
40
|
+
className: t(e["tedi-checkbox"], { [e["tedi-checkbox--disabled"]]: h }),
|
|
37
41
|
"data-name": "check",
|
|
38
|
-
|
|
42
|
+
...w,
|
|
39
43
|
children: [
|
|
40
|
-
/* @__PURE__ */ s(
|
|
41
|
-
/* @__PURE__ */ i(
|
|
44
|
+
/* @__PURE__ */ s(S, { gutter: 0, children: [
|
|
45
|
+
/* @__PURE__ */ i(R, { width: "auto", children: /* @__PURE__ */ s("div", { className: e["tedi-checkbox__outer-indicator-wrapper"], children: [
|
|
42
46
|
/* @__PURE__ */ i(
|
|
43
47
|
"input",
|
|
44
48
|
{
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
ref: f,
|
|
50
|
+
id: o,
|
|
51
|
+
value: b,
|
|
47
52
|
name: j,
|
|
48
53
|
type: "checkbox",
|
|
49
|
-
disabled:
|
|
50
|
-
checked:
|
|
51
|
-
|
|
52
|
-
onChange: B,
|
|
54
|
+
disabled: h,
|
|
55
|
+
checked: r ? !1 : B,
|
|
56
|
+
onChange: E,
|
|
53
57
|
className: e["tedi-checkbox__input"],
|
|
54
|
-
"aria-describedby": [
|
|
58
|
+
"aria-describedby": [N, F].filter(Boolean).join(" "),
|
|
59
|
+
required: p,
|
|
60
|
+
"aria-invalid": u || void 0
|
|
55
61
|
}
|
|
56
62
|
),
|
|
57
63
|
/* @__PURE__ */ s(
|
|
@@ -60,60 +66,60 @@ const Q = (g) => {
|
|
|
60
66
|
"aria-hidden": "true",
|
|
61
67
|
onClick: () => {
|
|
62
68
|
var c;
|
|
63
|
-
return (c =
|
|
69
|
+
return (c = x.current) == null ? void 0 : c.click();
|
|
64
70
|
},
|
|
65
|
-
className:
|
|
71
|
+
className: t(
|
|
66
72
|
e["tedi-checkbox__indicator"],
|
|
67
73
|
{
|
|
68
|
-
[e["tedi-checkbox__indicator--hover"]]:
|
|
69
|
-
[e["tedi-checkbox__indicator--indeterminate"]]:
|
|
74
|
+
[e["tedi-checkbox__indicator--hover"]]: I,
|
|
75
|
+
[e["tedi-checkbox__indicator--indeterminate"]]: r,
|
|
70
76
|
[e[`tedi-checkbox__indicator--size-${l}`]]: l,
|
|
71
|
-
[e["tedi-checkbox__indicator--invalid"]]:
|
|
77
|
+
[e["tedi-checkbox__indicator--invalid"]]: u
|
|
72
78
|
},
|
|
73
|
-
|
|
79
|
+
g
|
|
74
80
|
),
|
|
75
81
|
"data-testid": "checkbox-indicator",
|
|
76
82
|
children: [
|
|
77
83
|
/* @__PURE__ */ i(
|
|
78
|
-
|
|
84
|
+
C,
|
|
79
85
|
{
|
|
80
86
|
size: l === "default" ? 16 : 18,
|
|
81
87
|
name: "remove",
|
|
82
|
-
className:
|
|
88
|
+
className: t(e["tedi-checkbox__icon"], e["tedi-checkbox__icon--indeterminate"])
|
|
83
89
|
}
|
|
84
90
|
),
|
|
85
91
|
/* @__PURE__ */ i(
|
|
86
|
-
|
|
92
|
+
C,
|
|
87
93
|
{
|
|
88
94
|
size: l === "default" ? 16 : 18,
|
|
89
95
|
name: "check",
|
|
90
|
-
className:
|
|
96
|
+
className: t(e["tedi-checkbox__icon"], e["tedi-checkbox__icon--check"])
|
|
91
97
|
}
|
|
92
98
|
)
|
|
93
99
|
]
|
|
94
100
|
}
|
|
95
101
|
)
|
|
96
102
|
] }) }),
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
k && /* @__PURE__ */ i(R, { children: /* @__PURE__ */ i(
|
|
104
|
+
M,
|
|
99
105
|
{
|
|
100
|
-
ref:
|
|
101
|
-
className:
|
|
102
|
-
id:
|
|
106
|
+
ref: x,
|
|
107
|
+
className: q,
|
|
108
|
+
id: o,
|
|
103
109
|
"data-testid": "checkbox-label",
|
|
104
|
-
hideLabel:
|
|
105
|
-
label:
|
|
110
|
+
hideLabel: v,
|
|
111
|
+
label: k,
|
|
106
112
|
tooltip: _,
|
|
107
|
-
required:
|
|
113
|
+
required: p
|
|
108
114
|
}
|
|
109
115
|
) })
|
|
110
116
|
] }),
|
|
111
|
-
|
|
117
|
+
d && /* @__PURE__ */ i(H, { id: N, ...d, className: t(e["tedi-checkbox__helper"], d.className) })
|
|
112
118
|
]
|
|
113
119
|
}
|
|
114
120
|
);
|
|
115
121
|
};
|
|
116
122
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
U as Checkbox,
|
|
124
|
+
U as default
|
|
119
125
|
};
|
|
@@ -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 n=require("react/jsx-runtime"),F=require("../../../../../external/classnames/index.cjs.js"),f=require("react"),Z=require("../feedback-text/feedback-text.cjs.js"),ee=require("../form-label/form-label.cjs.js"),te=require("../checkbox/checkbox.cjs.js"),j=require("./choice-group.module.scss.cjs.js"),re=require("./choice-group-context.cjs.js"),R=require("./components/choice-group-item/choice-group-item.cjs.js"),oe=require("../../../providers/label-provider/use-labels.cjs.js"),B=require("../../../helpers/hooks/use-breakpoint.cjs.js"),ne=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),N=require("../../layout/grid/row.cjs.js"),ie=require("../../layout/grid/col.cjs.js"),I=h=>{const{getLabel:m}=oe.useLabels(),S=B.default(h.defaultServerBreakpoint),{getCurrentBreakpointProps:T}=ne.useBreakpointProps(h.defaultServerBreakpoint),{id:c,className:H,label:p,required:G,helper:a,items:o,variant:k="default",direction:v=k==="default"||B.isBreakpointBelow(S,"md")?"column":"row",rowProps:b,name:w,inputType:i="radio",value:L,defaultValue:M,onChange:d,hideLabel:P,indeterminateCheck:s,indeterminateCheckProps:x={},color:E,layout:y="separated",showIndicator:$,...O}=T(h),{...W}=x,X=(x==null?void 0:x.indented)??!0,C=(a==null?void 0:a.id)??`${c}-helper`,A=s&&i==="checkbox",[Y,_]=f.useState(()=>{if(M)return M;if(i==="radio"){const e=o.find(l=>l.defaultChecked);return e?e.value:null}return i==="checkbox"?o.filter(e=>e.defaultChecked).map(e=>e.value):null}),q=(e=h.value)=>!!d&&typeof e<"u",r=q(L)?L:Y,g=f.useMemo(()=>(r==null?void 0:r.length)===0,[r==null?void 0:r.length]),u=f.useMemo(()=>{var e;return(r==null?void 0:r.length)===((e=o==null?void 0:o.filter(l=>!l.disabled))==null?void 0:e.length)},[r==null?void 0:r.length,o]),z=f.useMemo(()=>!g&&!u,[u,g]),D=f.useMemo(()=>{const e=u?"all":g?"none":"some";return typeof s=="string"?s:typeof s=="function"?s(e):s?m(e==="all"?"table.filter.remove-all":"table.filter.select-all"):""},[m,s,u,g]),J={name:w,inputType:i,onChange:(e,l)=>{let t=r;i==="checkbox"&&t?t=l?Array.isArray(t)?[...t,e]:[e]:Array.isArray(t)?t.filter(V=>V!==e):t:t=e,q()||_(Array.isArray(t)?[...t]:t),d==null||d(t)},currentValue:r},K=F.default(j.default["tedi-choice-group"],H),Q=F.default(j.default["tedi-choice-group__inner"],b==null?void 0:b.className,{[j.default["tedi-choice-group__inner--indented"]]:A&&X}),U=()=>{var l;const e=u?[]:(l=o==null?void 0:o.filter(t=>!t.disabled))==null?void 0:l.map(t=>t.value);q()||_([...e]),d==null||d(e)};return n.jsx(re.ChoiceGroupContext.Provider,{value:J,children:n.jsxs("fieldset",{...O,className:K,id:c,name:w,"aria-describedby":a&&i!=="radio"?C:void 0,children:[p&&typeof p=="string"?n.jsx(ee.FormLabel,{id:c,label:p,required:G,hideLabel:P,renderWithoutLabel:!0}):n.jsx("label",{htmlFor:c,children:p}),n.jsx(N.Row,{children:n.jsx(ie.Col,{children:o!=null&&o.length?n.jsxs(n.Fragment,{children:[A&&n.jsx(te.Checkbox,{id:`${c}-indeterminate`,value:"indeterminate",name:"indeterminate",...W,label:D,indeterminate:z,checked:u,onChange:U}),n.jsx(N.Row,{direction:v,gutterX:y==="segmented"?0:2,gutterY:y==="segmented"?0:1,gap:k==="default"&&(B.isBreakpointBelow(S,"md")||v==="row")?1:0,...b,className:Q,role:i==="radio"?"radiogroup":void 0,"aria-labelledby":i==="radio"?c:void 0,"aria-describedby":i==="radio"&&a?C:void 0,"aria-required":i==="radio"&&G?!0:void 0,"aria-invalid":i==="radio"&&(a==null?void 0:a.type)==="error"?!0:void 0,children:o.map(e=>n.jsx(R.ChoiceGroupItem,{...e,color:E,variant:k,type:i,layout:y,showIndicator:$,direction:v},e.id))})]}):n.jsx("p",{children:m("table.filter.no-options")})})}),a&&n.jsx(Z.FeedbackText,{...a,id:C})]})})};I.Item=R.ChoiceGroupItem;exports.ChoiceGroup=I;exports.default=I;
|
|
@@ -1,118 +1,131 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as a, jsxs as F, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import G from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import y, { useState as ee } from "react";
|
|
4
4
|
import { FeedbackText as te } from "../feedback-text/feedback-text.es.js";
|
|
5
5
|
import { FormLabel as re } from "../form-label/form-label.es.js";
|
|
6
6
|
import { Checkbox as oe } from "../checkbox/checkbox.es.js";
|
|
7
|
-
import
|
|
8
|
-
import { ChoiceGroupContext as
|
|
9
|
-
import { ChoiceGroupItem as
|
|
10
|
-
import { useLabels as
|
|
11
|
-
import ae, { isBreakpointBelow as
|
|
7
|
+
import B from "./choice-group.module.scss.es.js";
|
|
8
|
+
import { ChoiceGroupContext as ie } from "./choice-group-context.es.js";
|
|
9
|
+
import { ChoiceGroupItem as q } from "./components/choice-group-item/choice-group-item.es.js";
|
|
10
|
+
import { useLabels as ne } from "../../../providers/label-provider/use-labels.es.js";
|
|
11
|
+
import ae, { isBreakpointBelow as H } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
12
12
|
import { useBreakpointProps as le } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
13
|
-
import { Row as
|
|
13
|
+
import { Row as j } from "../../layout/grid/row.es.js";
|
|
14
14
|
import { Col as de } from "../../layout/grid/col.es.js";
|
|
15
|
-
const se = (
|
|
16
|
-
const { getLabel:
|
|
17
|
-
id:
|
|
15
|
+
const se = (u) => {
|
|
16
|
+
const { getLabel: f } = ne(), S = ae(u.defaultServerBreakpoint), { getCurrentBreakpointProps: E } = le(u.defaultServerBreakpoint), {
|
|
17
|
+
id: c,
|
|
18
18
|
className: R,
|
|
19
19
|
label: p,
|
|
20
|
-
required:
|
|
21
|
-
helper:
|
|
20
|
+
required: A,
|
|
21
|
+
helper: n,
|
|
22
22
|
items: o,
|
|
23
|
-
variant:
|
|
24
|
-
direction:
|
|
23
|
+
variant: k = "default",
|
|
24
|
+
direction: v = k === "default" || H(S, "md") ? "column" : "row",
|
|
25
25
|
rowProps: h,
|
|
26
|
-
name:
|
|
26
|
+
name: L,
|
|
27
27
|
inputType: i = "radio",
|
|
28
|
-
value:
|
|
29
|
-
defaultValue:
|
|
30
|
-
onChange:
|
|
31
|
-
hideLabel:
|
|
32
|
-
indeterminateCheck:
|
|
28
|
+
value: M,
|
|
29
|
+
defaultValue: N,
|
|
30
|
+
onChange: d,
|
|
31
|
+
hideLabel: T,
|
|
32
|
+
indeterminateCheck: s,
|
|
33
33
|
indeterminateCheckProps: b = {},
|
|
34
|
-
color:
|
|
35
|
-
layout:
|
|
34
|
+
color: $,
|
|
35
|
+
layout: C = "separated",
|
|
36
36
|
showIndicator: P,
|
|
37
37
|
...W
|
|
38
|
-
} = E(
|
|
39
|
-
if (
|
|
38
|
+
} = E(u), { ...X } = b, Y = (b == null ? void 0 : b.indented) ?? !0, x = (n == null ? void 0 : n.id) ?? `${c}-helper`, _ = s && i === "checkbox", [z, w] = ee(() => {
|
|
39
|
+
if (N) return N;
|
|
40
40
|
if (i === "radio") {
|
|
41
|
-
const e = o.find((
|
|
41
|
+
const e = o.find((l) => l.defaultChecked);
|
|
42
42
|
return e ? e.value : null;
|
|
43
43
|
}
|
|
44
44
|
return i === "checkbox" ? o.filter((e) => e.defaultChecked).map((e) => e.value) : null;
|
|
45
|
-
}),
|
|
45
|
+
}), I = (e = u.value) => !!d && typeof e < "u", r = I(M) ? M : z, g = y.useMemo(() => (r == null ? void 0 : r.length) === 0, [r == null ? void 0 : r.length]), m = y.useMemo(
|
|
46
46
|
() => {
|
|
47
47
|
var e;
|
|
48
|
-
return (r == null ? void 0 : r.length) === ((e = o == null ? void 0 : o.filter((
|
|
48
|
+
return (r == null ? void 0 : r.length) === ((e = o == null ? void 0 : o.filter((l) => !l.disabled)) == null ? void 0 : e.length);
|
|
49
49
|
},
|
|
50
50
|
[r == null ? void 0 : r.length, o]
|
|
51
|
-
), D =
|
|
52
|
-
const e =
|
|
53
|
-
return typeof
|
|
54
|
-
}, [
|
|
55
|
-
name:
|
|
51
|
+
), D = y.useMemo(() => !g && !m, [m, g]), J = y.useMemo(() => {
|
|
52
|
+
const e = m ? "all" : g ? "none" : "some";
|
|
53
|
+
return typeof s == "string" ? s : typeof s == "function" ? s(e) : s ? f(e === "all" ? "table.filter.remove-all" : "table.filter.select-all") : "";
|
|
54
|
+
}, [f, s, m, g]), K = {
|
|
55
|
+
name: L,
|
|
56
56
|
inputType: i,
|
|
57
|
-
onChange: (e,
|
|
57
|
+
onChange: (e, l) => {
|
|
58
58
|
let t = r;
|
|
59
|
-
i === "checkbox" && t ? t =
|
|
59
|
+
i === "checkbox" && t ? t = l ? Array.isArray(t) ? [...t, e] : [e] : Array.isArray(t) ? t.filter((V) => V !== e) : t : t = e, I() || w(Array.isArray(t) ? [...t] : t), d == null || d(t);
|
|
60
60
|
},
|
|
61
61
|
currentValue: r
|
|
62
|
-
}, O =
|
|
63
|
-
[
|
|
62
|
+
}, O = G(B["tedi-choice-group"], R), Q = G(B["tedi-choice-group__inner"], h == null ? void 0 : h.className, {
|
|
63
|
+
[B["tedi-choice-group__inner--indented"]]: _ && Y
|
|
64
64
|
}), U = () => {
|
|
65
|
-
var
|
|
66
|
-
const e =
|
|
67
|
-
|
|
65
|
+
var l;
|
|
66
|
+
const e = m ? [] : (l = o == null ? void 0 : o.filter((t) => !t.disabled)) == null ? void 0 : l.map((t) => t.value);
|
|
67
|
+
I() || w([...e]), d == null || d(e);
|
|
68
68
|
};
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
role: i === "radio" ? "radiogroup" : void 0,
|
|
95
|
-
"aria-labelledby": i === "radio" ? s : void 0,
|
|
96
|
-
children: o.map((e) => /* @__PURE__ */ n(
|
|
69
|
+
return /* @__PURE__ */ a(ie.Provider, { value: K, children: /* @__PURE__ */ F(
|
|
70
|
+
"fieldset",
|
|
71
|
+
{
|
|
72
|
+
...W,
|
|
73
|
+
className: O,
|
|
74
|
+
id: c,
|
|
75
|
+
name: L,
|
|
76
|
+
"aria-describedby": n && i !== "radio" ? x : void 0,
|
|
77
|
+
children: [
|
|
78
|
+
p && typeof p == "string" ? /* @__PURE__ */ a(re, { id: c, label: p, required: A, hideLabel: T, renderWithoutLabel: !0 }) : /* @__PURE__ */ a("label", { htmlFor: c, children: p }),
|
|
79
|
+
/* @__PURE__ */ a(j, { children: /* @__PURE__ */ a(de, { children: o != null && o.length ? /* @__PURE__ */ F(Z, { children: [
|
|
80
|
+
_ && /* @__PURE__ */ a(
|
|
81
|
+
oe,
|
|
82
|
+
{
|
|
83
|
+
id: `${c}-indeterminate`,
|
|
84
|
+
value: "indeterminate",
|
|
85
|
+
name: "indeterminate",
|
|
86
|
+
...X,
|
|
87
|
+
label: J,
|
|
88
|
+
indeterminate: D,
|
|
89
|
+
checked: m,
|
|
90
|
+
onChange: U
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ a(
|
|
97
94
|
j,
|
|
98
95
|
{
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
96
|
+
direction: v,
|
|
97
|
+
gutterX: C === "segmented" ? 0 : 2,
|
|
98
|
+
gutterY: C === "segmented" ? 0 : 1,
|
|
99
|
+
gap: k === "default" && (H(S, "md") || v === "row") ? 1 : 0,
|
|
100
|
+
...h,
|
|
101
|
+
className: Q,
|
|
102
|
+
role: i === "radio" ? "radiogroup" : void 0,
|
|
103
|
+
"aria-labelledby": i === "radio" ? c : void 0,
|
|
104
|
+
"aria-describedby": i === "radio" && n ? x : void 0,
|
|
105
|
+
"aria-required": i === "radio" && A ? !0 : void 0,
|
|
106
|
+
"aria-invalid": i === "radio" && (n == null ? void 0 : n.type) === "error" ? !0 : void 0,
|
|
107
|
+
children: o.map((e) => /* @__PURE__ */ a(
|
|
108
|
+
q,
|
|
109
|
+
{
|
|
110
|
+
...e,
|
|
111
|
+
color: $,
|
|
112
|
+
variant: k,
|
|
113
|
+
type: i,
|
|
114
|
+
layout: C,
|
|
115
|
+
showIndicator: P,
|
|
116
|
+
direction: v
|
|
117
|
+
},
|
|
118
|
+
e.id
|
|
119
|
+
))
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }) : /* @__PURE__ */ a("p", { children: f("table.filter.no-options") }) }) }),
|
|
123
|
+
n && /* @__PURE__ */ a(te, { ...n, id: x })
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
) });
|
|
114
127
|
};
|
|
115
|
-
se.Item =
|
|
128
|
+
se.Item = q;
|
|
116
129
|
export {
|
|
117
130
|
se as ChoiceGroup,
|
|
118
131
|
se as default
|
package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),h=require("../../../../../../../external/classnames/index.cjs.js"),S=require("react"),A=require("../../../checkbox/checkbox.cjs.js"),H=require("../../../feedback-text/feedback-text.cjs.js"),L=require("../../../radio/radio.cjs.js"),O=require("../../choice-group-context.cjs.js"),e=require("./choice-group-item.module.scss.cjs.js"),V=require("../../../../../helpers/hooks/use-breakpoint-props.cjs.js"),z=require("../../../../layout/grid/col.cjs.js"),_=n=>{const{getCurrentBreakpointProps:q}=V.useBreakpointProps(n.defaultServerBreakpoint),{id:a,label:C,value:d,className:N,direction:m,disabled:r,colProps:I=m==="column"?{width:12}:{width:"auto"},onChange:p,hideLabel:B,helper:u,tooltip:$,type:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),h=require("../../../../../../../external/classnames/index.cjs.js"),S=require("react"),A=require("../../../checkbox/checkbox.cjs.js"),H=require("../../../feedback-text/feedback-text.cjs.js"),L=require("../../../radio/radio.cjs.js"),O=require("../../choice-group-context.cjs.js"),e=require("./choice-group-item.module.scss.cjs.js"),V=require("../../../../../helpers/hooks/use-breakpoint-props.cjs.js"),z=require("../../../../layout/grid/col.cjs.js"),_=n=>{const{getCurrentBreakpointProps:q}=V.useBreakpointProps(n.defaultServerBreakpoint),{id:a,label:C,value:d,className:N,direction:m,disabled:r,colProps:I=m==="column"?{width:12}:{width:"auto"},onChange:p,hideLabel:B,helper:u,tooltip:$,type:i="radio",variant:s="default",color:G="primary",layout:P,showIndicator:x,justifyContent:b="start"}=q(n),{currentValue:l,name:v,onChange:f,inputType:M}=S.useContext(O.ChoiceGroupContext),o=Array.isArray(l)?l.includes(d):d===l,R=l===void 0?n.defaultChecked:o,y=(c,k)=>{f==null||f(c,k),p==null||p(c,k)},T=h.default(e.default[`tedi-choice-group-item--${P==="separated"?"separated":"segmented"}`],m&&e.default[`tedi-choice-group-item--${m}`]),w=h.default(e.default["tedi-choice-group-item"],e.default[`tedi-choice-group-item--${s}`],e.default[`tedi-choice-group-item--${s}-${G}`],x&&e.default["tedi-choice-group-item--indicator"],i&&e.default[`tedi-choice-group-item--${i}`],{[e.default["tedi-choice-group-item--disabled"]]:r},{[e.default["tedi-choice-group-item--checked"]]:o},{[`justify-content-${b}`]:b}),E=i==="radio"?L.Radio:A.Checkbox,F=c=>{var j;r||s!=="card"||c.target.closest("input, label")||(j=document.getElementById(a))==null||j.click()},g=i==="radio";return t.jsx(z.Col,{...I,className:T,children:t.jsx("div",{className:w,tabIndex:g||r?-1:0,onClick:F,role:g?void 0:i,"aria-checked":g?void 0:o,children:s==="default"||x?t.jsx(E,{id:a,label:C,value:d,name:v,className:h.default(e.default["tedi-choice-group-item__indicator"],N),disabled:r,checked:o,defaultChecked:R,onChange:y,hideLabel:B,helper:u?{...u,className:h.default(e.default["tedi-choice-group-item__feedback-text"],u.className)}:void 0,tooltip:$,"data-testid":"choice-group-item-indicator"}):t.jsxs(t.Fragment,{children:[t.jsx("input",{id:a,value:d,name:v,type:M,disabled:r,checked:o,defaultChecked:l===void 0?n.defaultChecked:void 0,onChange:c=>{y(d,c.target.checked)},className:"visually-hidden",role:i==="radio"?"radio":void 0,"aria-checked":o,tabIndex:-1}),t.jsxs("label",{htmlFor:a,className:e.default["tedi-choice-group-item__label"],children:[C,u&&t.jsx(H.FeedbackText,{...u,id:a,className:e.default["tedi-choice-group-item__feedback-text"]})]})]})})})};exports.ChoiceGroupItem=_;exports.default=_;
|