@blakesteve/roster 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/atoms/Combobox/Combobox.cjs +1 -1
- package/dist/components/atoms/Combobox/Combobox.js +63 -62
- package/dist/components/atoms/Input/Input.cjs +1 -1
- package/dist/components/atoms/Input/Input.js +49 -52
- package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.js +69 -68
- package/dist/components/atoms/Select/Select.cjs +1 -1
- package/dist/components/atoms/Select/Select.js +52 -51
- package/dist/components/atoms/Textarea/Textarea.cjs +1 -1
- package/dist/components/atoms/Textarea/Textarea.js +36 -34
- package/dist/components/molecules/CheckboxGroup/CheckboxGroup.cjs +1 -1
- package/dist/components/molecules/CheckboxGroup/CheckboxGroup.d.ts +5 -3
- package/dist/components/molecules/CheckboxGroup/CheckboxGroup.js +61 -59
- package/dist/components/molecules/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/components/molecules/RadioGroup/RadioGroup.d.ts +4 -3
- package/dist/components/molecules/RadioGroup/RadioGroup.js +48 -47
- package/dist/internal/field-invalid.cjs +1 -0
- package/dist/internal/field-invalid.d.ts +37 -0
- package/dist/internal/field-invalid.js +13 -0
- package/dist/meta.json +3 -3
- package/package.json +1 -1
|
@@ -30,13 +30,15 @@ export interface CheckboxGroupProps extends Omit<React.HTMLAttributes<HTMLFieldS
|
|
|
30
30
|
helperText?: string;
|
|
31
31
|
/**
|
|
32
32
|
* The message for an invalid selection. Implies the error state, so a caller
|
|
33
|
-
*
|
|
33
|
+
* can not color the text red and forget to say why.
|
|
34
34
|
*
|
|
35
35
|
* What it repaints depends on `variant`, and the difference is worth
|
|
36
36
|
* knowing: `panel` gets an error border, `plain` has no boundary to repaint
|
|
37
37
|
* and so the message *is* the whole error state. Narrower than `Input`'s or
|
|
38
|
-
* `Select`'s, which both ring the control itself
|
|
39
|
-
*
|
|
38
|
+
* `Select`'s, which both ring the control itself: what is invalid here is
|
|
39
|
+
* the selection. Each checkbox is still announced as invalid, though, since
|
|
40
|
+
* a checkbox is what a screen reader focuses
|
|
41
|
+
* (`src/internal/field-invalid.ts`).
|
|
40
42
|
*/
|
|
41
43
|
errorMessage?: string;
|
|
42
44
|
/**
|
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import
|
|
2
|
+
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import P from "react";
|
|
4
4
|
import { Description as _ } from "../../../node_modules/@headlessui/react/dist/components/description/description.js";
|
|
5
|
-
import { Field as
|
|
6
|
-
import { Fieldset as
|
|
7
|
-
import { Label as
|
|
8
|
-
import { Legend as
|
|
5
|
+
import { Field as S } from "../../../node_modules/@headlessui/react/dist/components/field/field.js";
|
|
6
|
+
import { Fieldset as h } from "../../../node_modules/@headlessui/react/dist/components/fieldset/fieldset.js";
|
|
7
|
+
import { Label as Z } from "../../../node_modules/@headlessui/react/dist/components/label/label.js";
|
|
8
|
+
import { Legend as g } from "../../../node_modules/@headlessui/react/dist/components/legend/legend.js";
|
|
9
9
|
import { cn as e } from "../../../lib/utils.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import { isFieldInvalid as R, withoutInvalidProps as V } from "../../../internal/field-invalid.js";
|
|
11
|
+
import { Checkbox as W } from "../../atoms/Checkbox/Checkbox.js";
|
|
12
|
+
import { Eyebrow as q } from "../../atoms/Eyebrow/Eyebrow.js";
|
|
13
|
+
import { checkboxGroupPanelVariants as J, checkboxGroupOptionsVariants as K } from "./checkbox-group-variants.js";
|
|
14
|
+
const Q = (s) => s.length > 0 && Array.isArray(s[0].options), U = {
|
|
14
15
|
sm: "rst:text-xs",
|
|
15
16
|
md: "rst:text-sm",
|
|
16
17
|
lg: "rst:text-base"
|
|
17
|
-
},
|
|
18
|
+
}, or = ({
|
|
18
19
|
options: s,
|
|
19
|
-
value:
|
|
20
|
-
onChange:
|
|
20
|
+
value: d,
|
|
21
|
+
onChange: k,
|
|
21
22
|
label: x,
|
|
22
|
-
helperText:
|
|
23
|
-
errorMessage:
|
|
23
|
+
helperText: c,
|
|
24
|
+
errorMessage: i,
|
|
24
25
|
maxHeight: b,
|
|
25
26
|
disabled: l = !1,
|
|
26
|
-
variant:
|
|
27
|
-
size:
|
|
28
|
-
columns:
|
|
29
|
-
colorScheme:
|
|
30
|
-
className:
|
|
31
|
-
optionsClassName:
|
|
32
|
-
panelClassName:
|
|
33
|
-
"aria-describedby":
|
|
34
|
-
"aria-invalid":
|
|
35
|
-
...
|
|
27
|
+
variant: N,
|
|
28
|
+
size: a = "md",
|
|
29
|
+
columns: w,
|
|
30
|
+
colorScheme: I,
|
|
31
|
+
className: E,
|
|
32
|
+
optionsClassName: G,
|
|
33
|
+
panelClassName: L,
|
|
34
|
+
"aria-describedby": j,
|
|
35
|
+
"aria-invalid": A,
|
|
36
|
+
...p
|
|
36
37
|
}) => {
|
|
37
|
-
const n = !!
|
|
38
|
-
|
|
39
|
-
f ? [...
|
|
38
|
+
const n = !!i, v = R(n, { ...p, "aria-invalid": A }), B = V(p), m = b !== void 0, u = P.useId(), C = [j, c || i ? u : void 0].filter(Boolean).join(" ") || void 0, D = (r, f) => {
|
|
39
|
+
k(
|
|
40
|
+
f ? [...d, r] : d.filter((O) => O !== r)
|
|
40
41
|
);
|
|
41
|
-
},
|
|
42
|
-
|
|
42
|
+
}, F = (r) => /* @__PURE__ */ o(
|
|
43
|
+
S,
|
|
43
44
|
{
|
|
44
45
|
disabled: l || r.disabled,
|
|
45
46
|
className: "rst:flex rst:items-start rst:gap-2",
|
|
46
47
|
children: [
|
|
47
48
|
/* @__PURE__ */ t(
|
|
48
|
-
|
|
49
|
+
W,
|
|
49
50
|
{
|
|
50
|
-
size:
|
|
51
|
-
colorScheme:
|
|
52
|
-
checked:
|
|
53
|
-
onChange: (f) =>
|
|
51
|
+
size: a ?? "md",
|
|
52
|
+
colorScheme: I,
|
|
53
|
+
checked: d.includes(r.value),
|
|
54
|
+
onChange: (f) => D(r.value, f),
|
|
55
|
+
"aria-invalid": v || void 0,
|
|
54
56
|
className: "rst:mt-0.5 rst:shrink-0"
|
|
55
57
|
}
|
|
56
58
|
),
|
|
57
|
-
/* @__PURE__ */
|
|
59
|
+
/* @__PURE__ */ o("div", { className: "rst:flex rst:min-w-0 rst:flex-col", children: [
|
|
58
60
|
/* @__PURE__ */ t(
|
|
59
|
-
|
|
61
|
+
Z,
|
|
60
62
|
{
|
|
61
63
|
className: e(
|
|
62
64
|
"rst:cursor-pointer rst:select-none rst:px-1 rst:py-0.5",
|
|
63
65
|
"rst:text-[var(--roster-control-text)]",
|
|
64
66
|
"rst:data-disabled:cursor-not-allowed rst:data-disabled:opacity-50",
|
|
65
|
-
|
|
67
|
+
U[a ?? "md"]
|
|
66
68
|
),
|
|
67
69
|
children: r.label
|
|
68
70
|
}
|
|
@@ -72,33 +74,33 @@ const W = (s) => s.length > 0 && Array.isArray(s[0].options), q = {
|
|
|
72
74
|
]
|
|
73
75
|
},
|
|
74
76
|
r.value
|
|
75
|
-
),
|
|
76
|
-
return /* @__PURE__ */
|
|
77
|
-
|
|
77
|
+
), y = (r) => /* @__PURE__ */ t("div", { className: e(K({ columns: w, size: a })), children: r.map(F) });
|
|
78
|
+
return /* @__PURE__ */ o(
|
|
79
|
+
h,
|
|
78
80
|
{
|
|
79
81
|
disabled: l,
|
|
80
82
|
className: e(
|
|
81
83
|
"rst:font-ui rst:flex rst:flex-col rst:gap-1.5 rst:min-w-0",
|
|
82
|
-
|
|
84
|
+
E
|
|
83
85
|
),
|
|
84
|
-
...
|
|
85
|
-
"aria-invalid":
|
|
86
|
-
"aria-describedby":
|
|
86
|
+
...B,
|
|
87
|
+
"aria-invalid": v || void 0,
|
|
88
|
+
"aria-describedby": C,
|
|
87
89
|
children: [
|
|
88
|
-
x && /* @__PURE__ */ t(
|
|
90
|
+
x && /* @__PURE__ */ t(g, { className: "rst:block rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)] rst:text-left rst:data-disabled:opacity-50", children: x }),
|
|
89
91
|
/* @__PURE__ */ t(
|
|
90
92
|
"div",
|
|
91
93
|
{
|
|
92
94
|
className: e(
|
|
93
|
-
|
|
95
|
+
J({ variant: N, size: a, error: n }),
|
|
94
96
|
m && "rst:overflow-y-auto rst:custom-scrollbar rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",
|
|
95
97
|
/* Deprecated name first, so the current one wins when both are set. */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
L,
|
|
99
|
+
G
|
|
98
100
|
),
|
|
99
101
|
style: m ? { maxHeight: b } : void 0,
|
|
100
102
|
tabIndex: m ? 0 : void 0,
|
|
101
|
-
children:
|
|
103
|
+
children: Q(s) ? s.map((r) => (
|
|
102
104
|
/* Nested fieldset per category, so the heading is the group's
|
|
103
105
|
accessible name rather than decoration a screen reader walks
|
|
104
106
|
straight past. Nesting is valid HTML, the inner
|
|
@@ -109,32 +111,32 @@ const W = (s) => s.length > 0 && Array.isArray(s[0].options), q = {
|
|
|
109
111
|
`as={Eyebrow}` overrides Legend's own `as="div"` — it is
|
|
110
112
|
spread after — so these render as <span>. The registration is
|
|
111
113
|
what matters and it is unchanged. */
|
|
112
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ o(h, { className: "rst:flex rst:flex-col rst:gap-2", children: [
|
|
113
115
|
/* @__PURE__ */ t(
|
|
114
|
-
|
|
116
|
+
g,
|
|
115
117
|
{
|
|
116
|
-
as:
|
|
118
|
+
as: q,
|
|
117
119
|
weight: "semibold",
|
|
118
120
|
tone: "default",
|
|
119
121
|
className: "rst:border-b rst:border-gray-200 rst:pb-1 rst:dark:border-gray-800",
|
|
120
122
|
children: r.category
|
|
121
123
|
}
|
|
122
124
|
),
|
|
123
|
-
|
|
125
|
+
y(r.options)
|
|
124
126
|
] }, r.category)
|
|
125
|
-
)) :
|
|
127
|
+
)) : y(s)
|
|
126
128
|
}
|
|
127
129
|
),
|
|
128
|
-
(
|
|
130
|
+
(c || i) && /* @__PURE__ */ t(
|
|
129
131
|
"p",
|
|
130
132
|
{
|
|
131
|
-
id:
|
|
133
|
+
id: u,
|
|
132
134
|
className: e(
|
|
133
135
|
"rst:text-xs rst:text-left",
|
|
134
136
|
n ? "rst:text-error-600 rst:dark:text-error-400 rst:font-medium" : "rst:text-gray-500 rst:dark:text-gray-400",
|
|
135
137
|
l && "rst:opacity-50"
|
|
136
138
|
),
|
|
137
|
-
children:
|
|
139
|
+
children: i || c
|
|
138
140
|
}
|
|
139
141
|
)
|
|
140
142
|
]
|
|
@@ -142,5 +144,5 @@ const W = (s) => s.length > 0 && Array.isArray(s[0].options), q = {
|
|
|
142
144
|
);
|
|
143
145
|
};
|
|
144
146
|
export {
|
|
145
|
-
|
|
147
|
+
or as CheckboxGroup
|
|
146
148
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");require("react");const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");require("react");const m=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),D=require("../../../node_modules/@headlessui/react/dist/components/field/field.cjs"),p=require("../../../node_modules/@headlessui/react/dist/components/label/label.cjs"),v=require("../../../node_modules/@headlessui/react/dist/components/radio-group/radio-group.cjs"),r=require("../../../lib/utils.cjs"),f=require("../../../internal/field-invalid.cjs"),c=require("./radio-group-variants.cjs"),E={sm:"rst:text-xs",md:"rst:text-sm",lg:"rst:text-base"},O=({options:y,value:j,onChange:b,label:n,helperText:d,errorMessage:l,disabled:e=!1,size:h="md",orientation:i="vertical",colorScheme:N,className:q,optionsClassName:g,optionClassName:G,radioClassName:w,labelClassName:z,optionLabelClassName:R,descriptionClassName:S,messageClassName:V,"aria-invalid":k,...x})=>{const u=!!l,I=f.isFieldInvalid(u,{...x,"aria-invalid":k}),L=f.withoutInvalidProps(x),a=h??"md";return t.jsxs(v.RadioGroup,{value:j,onChange:b,disabled:e,className:r.cn("rst:font-ui rst:flex rst:flex-col rst:gap-1.5 rst:min-w-0",q),...L,"aria-invalid":I||void 0,"aria-orientation":i,children:[n&&t.jsx(p.Label,{className:r.cn("rst:block rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)] rst:text-left",e&&"rst:opacity-50",z),children:n}),t.jsx("div",{className:r.cn(c.radioGroupOptionsVariants({size:a,orientation:i}),g),children:y.map(s=>t.jsxs(D.Field,{disabled:e||s.disabled,className:r.cn(c.radioOptionVariants({orientation:i,size:a}),G),children:[t.jsx(v.Radio,{value:s.value,className:({checked:o})=>r.cn(c.radioVariants({colorScheme:N,size:a,checked:o}),"rst:self-start",e||s.disabled?"rst:opacity-50 rst:cursor-not-allowed":"rst:cursor-pointer",w),children:({checked:o})=>t.jsx("span",{className:r.cn(c.radioDotVariants({size:a}),o?"rst:opacity-100":"rst:opacity-0")})}),t.jsxs("div",{className:r.cn("rst:flex rst:min-w-0 rst:flex-col",i==="vertical"&&"rst:flex-1"),children:[t.jsx(p.Label,{className:r.cn("rst:cursor-pointer rst:select-none","rst:text-[var(--roster-control-text)]","rst:data-disabled:cursor-not-allowed rst:data-disabled:opacity-50",E[a],R),children:s.label}),s.description&&t.jsx(m.Description,{className:r.cn("rst:text-xs rst:text-gray-500 rst:dark:text-gray-400 rst:data-disabled:opacity-50",S),children:s.description})]})]},s.value))}),(d||l)&&t.jsx(m.Description,{as:"p",className:r.cn("rst:text-xs rst:text-left",u?"rst:text-error-600 rst:dark:text-error-400 rst:font-medium":"rst:text-gray-500 rst:dark:text-gray-400",e&&"rst:opacity-50",V),children:l||d})]})};exports.RadioGroup=O;
|
|
@@ -45,9 +45,10 @@ export interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
45
45
|
* `aria-describedby` is one of the props Headless UI controls on a
|
|
46
46
|
* `RadioGroup`, and a controlled prop is spread last. Passing one is
|
|
47
47
|
* therefore a no-op rather than an addition. `aria-invalid` is not one of
|
|
48
|
-
* Headless UI's
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* Headless UI's: a caller's is read by the rule every Roster field follows
|
|
49
|
+
* (`src/internal/field-invalid.ts`), so any value but "false" marks the
|
|
50
|
+
* group invalid, as `"true"`, and an error message marks it invalid whatever
|
|
51
|
+
* the caller passed.
|
|
51
52
|
*/
|
|
52
53
|
errorMessage?: string;
|
|
53
54
|
/** Disables every option, and dims the label and helper text with them. */
|
|
@@ -1,55 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as c, jsx as s } from "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
|
-
import { Description as
|
|
5
|
-
import { Field as
|
|
6
|
-
import { Label as
|
|
7
|
-
import { RadioGroup as
|
|
4
|
+
import { Description as p } from "../../../node_modules/@headlessui/react/dist/components/description/description.js";
|
|
5
|
+
import { Field as S } from "../../../node_modules/@headlessui/react/dist/components/field/field.js";
|
|
6
|
+
import { Label as f } from "../../../node_modules/@headlessui/react/dist/components/label/label.js";
|
|
7
|
+
import { RadioGroup as j, Radio as D } from "../../../node_modules/@headlessui/react/dist/components/radio-group/radio-group.js";
|
|
8
8
|
import { cn as t } from "../../../lib/utils.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import { isFieldInvalid as F, withoutInvalidProps as O } from "../../../internal/field-invalid.js";
|
|
10
|
+
import { radioDotVariants as P, radioVariants as Z, radioOptionVariants as A, radioGroupOptionsVariants as B } from "./radio-group-variants.js";
|
|
11
|
+
const K = {
|
|
11
12
|
sm: "rst:text-xs",
|
|
12
13
|
md: "rst:text-sm",
|
|
13
14
|
lg: "rst:text-base"
|
|
14
|
-
},
|
|
15
|
-
options:
|
|
16
|
-
value:
|
|
17
|
-
onChange:
|
|
15
|
+
}, Y = ({
|
|
16
|
+
options: u,
|
|
17
|
+
value: v,
|
|
18
|
+
onChange: y,
|
|
18
19
|
label: d,
|
|
19
20
|
helperText: m,
|
|
20
21
|
errorMessage: o,
|
|
21
22
|
disabled: a = !1,
|
|
22
|
-
size:
|
|
23
|
+
size: h = "md",
|
|
23
24
|
orientation: i = "vertical",
|
|
24
25
|
colorScheme: N,
|
|
25
|
-
className:
|
|
26
|
-
optionsClassName:
|
|
27
|
-
optionClassName:
|
|
28
|
-
radioClassName:
|
|
26
|
+
className: b,
|
|
27
|
+
optionsClassName: g,
|
|
28
|
+
optionClassName: w,
|
|
29
|
+
radioClassName: z,
|
|
29
30
|
labelClassName: k,
|
|
30
|
-
optionLabelClassName:
|
|
31
|
-
descriptionClassName:
|
|
32
|
-
messageClassName:
|
|
33
|
-
"aria-invalid":
|
|
34
|
-
...
|
|
31
|
+
optionLabelClassName: V,
|
|
32
|
+
descriptionClassName: E,
|
|
33
|
+
messageClassName: G,
|
|
34
|
+
"aria-invalid": I,
|
|
35
|
+
...n
|
|
35
36
|
}) => {
|
|
36
|
-
const
|
|
37
|
+
const x = !!o, L = F(x, { ...n, "aria-invalid": I }), R = O(n), e = h ?? "md";
|
|
37
38
|
return /* @__PURE__ */ c(
|
|
38
|
-
|
|
39
|
+
j,
|
|
39
40
|
{
|
|
40
|
-
value:
|
|
41
|
-
onChange:
|
|
41
|
+
value: v,
|
|
42
|
+
onChange: y,
|
|
42
43
|
disabled: a,
|
|
43
44
|
className: t(
|
|
44
45
|
"rst:font-ui rst:flex rst:flex-col rst:gap-1.5 rst:min-w-0",
|
|
45
|
-
|
|
46
|
+
b
|
|
46
47
|
),
|
|
47
|
-
...
|
|
48
|
-
"aria-invalid":
|
|
48
|
+
...R,
|
|
49
|
+
"aria-invalid": L || void 0,
|
|
49
50
|
"aria-orientation": i,
|
|
50
51
|
children: [
|
|
51
52
|
d && /* @__PURE__ */ s(
|
|
52
|
-
|
|
53
|
+
f,
|
|
53
54
|
{
|
|
54
55
|
className: t(
|
|
55
56
|
"rst:block rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)] rst:text-left",
|
|
@@ -63,37 +64,37 @@ const B = {
|
|
|
63
64
|
"div",
|
|
64
65
|
{
|
|
65
66
|
className: t(
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
B({ size: e, orientation: i }),
|
|
68
|
+
g
|
|
68
69
|
),
|
|
69
|
-
children:
|
|
70
|
-
|
|
70
|
+
children: u.map((r) => /* @__PURE__ */ c(
|
|
71
|
+
S,
|
|
71
72
|
{
|
|
72
73
|
disabled: a || r.disabled,
|
|
73
74
|
className: t(
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
A({ orientation: i, size: e }),
|
|
76
|
+
w
|
|
76
77
|
),
|
|
77
78
|
children: [
|
|
78
79
|
/* @__PURE__ */ s(
|
|
79
|
-
|
|
80
|
+
D,
|
|
80
81
|
{
|
|
81
82
|
value: r.value,
|
|
82
83
|
className: ({ checked: l }) => t(
|
|
83
|
-
|
|
84
|
+
Z({ colorScheme: N, size: e, checked: l }),
|
|
84
85
|
/* `self-start`, and no nudge. The circle's height equals the
|
|
85
86
|
label's line-height at every size, so aligning their top
|
|
86
87
|
edges puts the radio on the first line whether the label
|
|
87
88
|
is one line or four. */
|
|
88
89
|
"rst:self-start",
|
|
89
90
|
a || r.disabled ? "rst:opacity-50 rst:cursor-not-allowed" : "rst:cursor-pointer",
|
|
90
|
-
|
|
91
|
+
z
|
|
91
92
|
),
|
|
92
93
|
children: ({ checked: l }) => /* @__PURE__ */ s(
|
|
93
94
|
"span",
|
|
94
95
|
{
|
|
95
96
|
className: t(
|
|
96
|
-
|
|
97
|
+
P({ size: e }),
|
|
97
98
|
l ? "rst:opacity-100" : "rst:opacity-0"
|
|
98
99
|
)
|
|
99
100
|
}
|
|
@@ -113,24 +114,24 @@ const B = {
|
|
|
113
114
|
),
|
|
114
115
|
children: [
|
|
115
116
|
/* @__PURE__ */ s(
|
|
116
|
-
|
|
117
|
+
f,
|
|
117
118
|
{
|
|
118
119
|
className: t(
|
|
119
120
|
"rst:cursor-pointer rst:select-none",
|
|
120
121
|
"rst:text-[var(--roster-control-text)]",
|
|
121
122
|
"rst:data-disabled:cursor-not-allowed rst:data-disabled:opacity-50",
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
K[e],
|
|
124
|
+
V
|
|
124
125
|
),
|
|
125
126
|
children: r.label
|
|
126
127
|
}
|
|
127
128
|
),
|
|
128
129
|
r.description && /* @__PURE__ */ s(
|
|
129
|
-
|
|
130
|
+
p,
|
|
130
131
|
{
|
|
131
132
|
className: t(
|
|
132
133
|
"rst:text-xs rst:text-gray-500 rst:dark:text-gray-400 rst:data-disabled:opacity-50",
|
|
133
|
-
|
|
134
|
+
E
|
|
134
135
|
),
|
|
135
136
|
children: r.description
|
|
136
137
|
}
|
|
@@ -145,14 +146,14 @@ const B = {
|
|
|
145
146
|
}
|
|
146
147
|
),
|
|
147
148
|
(m || o) && /* @__PURE__ */ s(
|
|
148
|
-
|
|
149
|
+
p,
|
|
149
150
|
{
|
|
150
151
|
as: "p",
|
|
151
152
|
className: t(
|
|
152
153
|
"rst:text-xs rst:text-left",
|
|
153
|
-
|
|
154
|
+
x ? "rst:text-error-600 rst:dark:text-error-400 rst:font-medium" : "rst:text-gray-500 rst:dark:text-gray-400",
|
|
154
155
|
a && "rst:opacity-50",
|
|
155
|
-
|
|
156
|
+
G
|
|
156
157
|
),
|
|
157
158
|
children: o || m
|
|
158
159
|
}
|
|
@@ -162,5 +163,5 @@ const B = {
|
|
|
162
163
|
);
|
|
163
164
|
};
|
|
164
165
|
export {
|
|
165
|
-
|
|
166
|
+
Y as RadioGroup
|
|
166
167
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,i){if(t||i.invalid)return!0;const e=i["aria-invalid"];return e!=null&&e!==!1&&e!=="false"&&e!==""}function l(t){const i={...t};return delete i["aria-invalid"],delete i.invalid,i}exports.isFieldInvalid=n;exports.withoutInvalidProps=l;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a Roster field is invalid, and where it says so. Every field component
|
|
3
|
+
* follows this one rule; a new field should too.
|
|
4
|
+
*
|
|
5
|
+
* A field is invalid when any of these hold:
|
|
6
|
+
*
|
|
7
|
+
* - it shows an error: an `errorMessage`, or the `error` flag;
|
|
8
|
+
* - the consumer passes `aria-invalid` with any value but `false`, `"false"`
|
|
9
|
+
* or `""` (ARIA reads an empty value as false). `"grammar"` and
|
|
10
|
+
* `"spelling"` count, and come out as `"true"`: a field is invalid or it
|
|
11
|
+
* isn't;
|
|
12
|
+
* - the consumer passes Headless UI's own `invalid`.
|
|
13
|
+
*
|
|
14
|
+
* An error wins: a field with one is invalid even when the consumer passes
|
|
15
|
+
* `aria-invalid="false"`.
|
|
16
|
+
*
|
|
17
|
+
* An invalid field renders `aria-invalid="true"` on the control a screen
|
|
18
|
+
* reader focuses, so it is announced as invalid along with its error text,
|
|
19
|
+
* not only drawn in red. A valid one renders no `aria-invalid` at all. The
|
|
20
|
+
* only exception is a role that can't carry the state: a radio can't, so a
|
|
21
|
+
* radio group says it on the group.
|
|
22
|
+
*
|
|
23
|
+
* Read the consumer's props here, not by spreading them: the props of most
|
|
24
|
+
* fields land on a wrapper with no role, where `aria-invalid` does nothing,
|
|
25
|
+
* and Headless UI's text controls overwrite a passed `aria-invalid` with
|
|
26
|
+
* their own.
|
|
27
|
+
*/
|
|
28
|
+
export interface InvalidProps {
|
|
29
|
+
"aria-invalid"?: unknown;
|
|
30
|
+
invalid?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare function isFieldInvalid(hasError: boolean | null | undefined, props: InvalidProps): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Splits the two invalid props off the rest, so the rest can be spread on a
|
|
35
|
+
* wrapper without them landing where they mean nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withoutInvalidProps<T extends object>(props: T): Omit<T, "aria-invalid" | "invalid">;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function t(n, i) {
|
|
2
|
+
if (n || i.invalid) return !0;
|
|
3
|
+
const e = i["aria-invalid"];
|
|
4
|
+
return e != null && e !== !1 && e !== "false" && e !== "";
|
|
5
|
+
}
|
|
6
|
+
function r(n) {
|
|
7
|
+
const i = { ...n };
|
|
8
|
+
return delete i["aria-invalid"], delete i.invalid, i;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
t as isFieldInvalid,
|
|
12
|
+
r as withoutInvalidProps
|
|
13
|
+
};
|
package/dist/meta.json
CHANGED
package/package.json
CHANGED