@igne-agency/react-web-ui 0.2.1 → 0.3.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/README.md +39 -0
- package/dist/components/checkbox-field/tsf-checkbox-field.js +1 -1
- package/dist/components/checkbox-group-field/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox-group-field/checkbox-group.js +1 -1
- package/dist/components/checkbox-group-field/tsf-checkbox-group-field.js +1 -1
- package/dist/components/combobox-field/tsf-combobox-field.js +2 -2
- package/dist/components/date-field/tsf-date-field.js +1 -1
- package/dist/components/date-range-field/tsf-date-range-field.js +1 -1
- package/dist/components/field/field-group-context.d.ts +21 -0
- package/dist/components/field/field-group-context.js +38 -0
- package/dist/components/field/field.css +27 -8
- package/dist/components/field/field.d.ts +6 -3
- package/dist/components/field/field.js +88 -45
- package/dist/components/field/field.module.js +12 -10
- package/dist/components/fieldset/field-group.d.ts +31 -0
- package/dist/components/fieldset/field-group.js +102 -0
- package/dist/components/fieldset/fieldset-root.d.ts +60 -0
- package/dist/components/fieldset/fieldset-root.js +285 -0
- package/dist/components/fieldset/fieldset.css +22 -0
- package/dist/components/fieldset/fieldset.d.ts +37 -0
- package/dist/components/fieldset/fieldset.js +127 -0
- package/dist/components/fieldset/fieldset.module.js +8 -0
- package/dist/components/fieldset/index.d.ts +4 -0
- package/dist/components/fieldset/index.js +4 -0
- package/dist/components/fieldset/tsf-field-group.d.ts +21 -0
- package/dist/components/fieldset/tsf-field-group.js +58 -0
- package/dist/components/file-field/tsf-file-field.js +1 -1
- package/dist/components/number-field/tsf-number-field.js +1 -1
- package/dist/components/otp-field/tsf-otp-field.js +1 -1
- package/dist/components/password-field/tsf-password-field.js +1 -1
- package/dist/components/photo-field/tsf-photo-field.js +1 -1
- package/dist/components/radio-group-field/radio-group.d.ts +1 -1
- package/dist/components/radio-group-field/radio-group.js +1 -1
- package/dist/components/radio-group-field/tsf-radio-group-field.js +1 -1
- package/dist/components/segmented-control-field/segmented-control.d.ts +1 -1
- package/dist/components/segmented-control-field/segmented-control.js +1 -1
- package/dist/components/segmented-control-field/tsf-segmented-control-field.js +1 -1
- package/dist/components/select-field/tsf-select-field.js +1 -1
- package/dist/components/switch-field/tsf-switch-field.js +1 -1
- package/dist/components/text-field/connect-text-preset.js +1 -1
- package/dist/components/text-field/text-field.css +28 -27
- package/dist/components/text-field/text-field.module.js +9 -9
- package/dist/components/text-field/tsf-text-field.js +1 -1
- package/dist/components/textarea-field/tsf-textarea-field.js +1 -1
- package/dist/components/time-field/tsf-time-field.js +1 -1
- package/dist/components/toggle-group-field/toggle-group.d.ts +1 -1
- package/dist/components/toggle-group-field/toggle-group.js +1 -1
- package/dist/components/toggle-group-field/tsf-toggle-group-field.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -2
- package/dist/lib/forms/create-app-form.d.ts +18 -9
- package/dist/lib/forms/create-app-form.js +17 -8
- package/dist/lib/forms/index.d.ts +1 -0
- package/dist/lib/forms/index.js +2 -1
- package/dist/lib/forms/use-connected-field.d.ts +10 -7
- package/dist/lib/forms/use-connected-field.js +54 -28
- package/package.json +5 -1
- package/dist/components/field/fieldset.d.ts +0 -22
- package/dist/components/field/fieldset.js +0 -130
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { normalizeFieldErrors } from "../../lib/forms/errors.js";
|
|
2
|
+
import { Fieldset } from "./fieldset.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/fieldset/field-group.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Related fields side by side under one legend, with one error for all of
|
|
9
|
+
* them: the lines of its `members`, each tied to its field's control, then its
|
|
10
|
+
* own `errors`. Every field's label, control, description and error line up
|
|
11
|
+
* with its neighbours'. The `--field-group-columns` knob sets the columns.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <FieldGroup legend="Address" optionalLabel="optional" members={members}>
|
|
15
|
+
* <TextField label="Postal code" … />
|
|
16
|
+
* <TextField label="House number" … />
|
|
17
|
+
* </FieldGroup>
|
|
18
|
+
*/
|
|
19
|
+
var FieldGroup = (t0) => {
|
|
20
|
+
const $ = c(27);
|
|
21
|
+
const { legend, description, errors, requiredness, optionalLabel, members, formatError, className, children } = t0;
|
|
22
|
+
const id = useId();
|
|
23
|
+
const descriptionId = `${id}description`;
|
|
24
|
+
const errorId = `${id}error`;
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[0] !== description || $[1] !== descriptionId || $[2] !== errorId || $[3] !== errors) {
|
|
27
|
+
t1 = [description === void 0 ? "" : descriptionId, normalizeFieldErrors(errors).length === 0 ? "" : errorId].filter(_temp).join(" ") || void 0;
|
|
28
|
+
$[0] = description;
|
|
29
|
+
$[1] = descriptionId;
|
|
30
|
+
$[2] = errorId;
|
|
31
|
+
$[3] = errors;
|
|
32
|
+
$[4] = t1;
|
|
33
|
+
} else t1 = $[4];
|
|
34
|
+
const describedBy = t1;
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[5] !== legend || $[6] !== optionalLabel || $[7] !== requiredness) {
|
|
37
|
+
t2 = /* @__PURE__ */ jsx(Fieldset.Legend, {
|
|
38
|
+
requiredness,
|
|
39
|
+
optionalLabel,
|
|
40
|
+
children: legend
|
|
41
|
+
});
|
|
42
|
+
$[5] = legend;
|
|
43
|
+
$[6] = optionalLabel;
|
|
44
|
+
$[7] = requiredness;
|
|
45
|
+
$[8] = t2;
|
|
46
|
+
} else t2 = $[8];
|
|
47
|
+
let t3;
|
|
48
|
+
if ($[9] !== description || $[10] !== descriptionId) {
|
|
49
|
+
t3 = /* @__PURE__ */ jsx(Fieldset.Description, {
|
|
50
|
+
id: descriptionId,
|
|
51
|
+
children: description
|
|
52
|
+
});
|
|
53
|
+
$[9] = description;
|
|
54
|
+
$[10] = descriptionId;
|
|
55
|
+
$[11] = t3;
|
|
56
|
+
} else t3 = $[11];
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[12] !== children) {
|
|
59
|
+
t4 = /* @__PURE__ */ jsx(Fieldset.Fields, { children });
|
|
60
|
+
$[12] = children;
|
|
61
|
+
$[13] = t4;
|
|
62
|
+
} else t4 = $[13];
|
|
63
|
+
let t5;
|
|
64
|
+
if ($[14] !== errorId) {
|
|
65
|
+
t5 = /* @__PURE__ */ jsx(Fieldset.Error, { id: errorId });
|
|
66
|
+
$[14] = errorId;
|
|
67
|
+
$[15] = t5;
|
|
68
|
+
} else t5 = $[15];
|
|
69
|
+
let t6;
|
|
70
|
+
if ($[16] !== className || $[17] !== describedBy || $[18] !== errors || $[19] !== formatError || $[20] !== members || $[21] !== requiredness || $[22] !== t2 || $[23] !== t3 || $[24] !== t4 || $[25] !== t5) {
|
|
71
|
+
t6 = /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
72
|
+
errors,
|
|
73
|
+
requiredness,
|
|
74
|
+
members,
|
|
75
|
+
formatError,
|
|
76
|
+
"aria-describedby": describedBy,
|
|
77
|
+
className,
|
|
78
|
+
children: [
|
|
79
|
+
t2,
|
|
80
|
+
t3,
|
|
81
|
+
t4,
|
|
82
|
+
t5
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
$[16] = className;
|
|
86
|
+
$[17] = describedBy;
|
|
87
|
+
$[18] = errors;
|
|
88
|
+
$[19] = formatError;
|
|
89
|
+
$[20] = members;
|
|
90
|
+
$[21] = requiredness;
|
|
91
|
+
$[22] = t2;
|
|
92
|
+
$[23] = t3;
|
|
93
|
+
$[24] = t4;
|
|
94
|
+
$[25] = t5;
|
|
95
|
+
$[26] = t6;
|
|
96
|
+
} else t6 = $[26];
|
|
97
|
+
return t6;
|
|
98
|
+
};
|
|
99
|
+
function _temp(part) {
|
|
100
|
+
return part !== "";
|
|
101
|
+
}
|
|
102
|
+
export { FieldGroup };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type FieldLabelProps, type FieldProps, type FieldRootProps } from "../field/field.tsx";
|
|
3
|
+
/** A field whose errors a fieldset collects, by the name of the TanStack Form field it renders in. */
|
|
4
|
+
export type FieldsetMember = Readonly<{
|
|
5
|
+
name: string;
|
|
6
|
+
/** Errors in any shape `normalizeFieldErrors` accepts. */
|
|
7
|
+
errors: unknown;
|
|
8
|
+
}>;
|
|
9
|
+
/** The field a collected line belongs to, as `formatError` receives it. */
|
|
10
|
+
export type FieldsetMemberField = Readonly<{
|
|
11
|
+
name: string;
|
|
12
|
+
/** The field's label, once the field has told the group. */
|
|
13
|
+
label: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
/** Turns one of a member's messages into the line the group shows for it. */
|
|
16
|
+
export type FieldsetErrorFormat = (field: FieldsetMemberField, message: string) => ReactNode;
|
|
17
|
+
/** One line of a fieldset's error. */
|
|
18
|
+
export type FieldsetLine = Readonly<{
|
|
19
|
+
id: string;
|
|
20
|
+
/** The member the line belongs to, or `undefined` for a line about the group. */
|
|
21
|
+
name: string | undefined;
|
|
22
|
+
content: ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
/** What a fieldset's root hands its parts. */
|
|
25
|
+
export type FieldsetContextValue = Readonly<{
|
|
26
|
+
/** The members' lines in member order, then the group's own. */
|
|
27
|
+
lines: readonly FieldsetLine[];
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* The lines of the surrounding fieldset's error.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const { lines } = useFieldsetContext();
|
|
34
|
+
*/
|
|
35
|
+
export declare const useFieldsetContext: () => FieldsetContextValue;
|
|
36
|
+
/** What the root of a fieldset takes, for a group of choices or a group of fields. */
|
|
37
|
+
export type FieldsetRootProps = FieldRootProps & Pick<FieldProps, "errors" | "requiredness" | "dirty" | "touched" | "pending"> & Readonly<{
|
|
38
|
+
/** A choice is made. */
|
|
39
|
+
filled?: boolean;
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
/** The fields whose errors the group shows in its own error instead of under each field. */
|
|
42
|
+
members?: readonly FieldsetMember[];
|
|
43
|
+
/** Turns a member's message into its line. Left out, the line is the message. */
|
|
44
|
+
formatError?: FieldsetErrorFormat;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* A field rendered as a fieldset, named by its legend: a group of choices, or a
|
|
48
|
+
* group of fields that shows the errors of its `members` in one place.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* <FieldsetRoot filled={kind !== null}>…</FieldsetRoot>
|
|
52
|
+
*/
|
|
53
|
+
export declare const FieldsetRoot: ({ errors, requiredness, dirty, touched, pending, filled, readOnly, disabled, members, formatError, children, ...props }: FieldsetRootProps) => ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* The legend that names a {@link FieldsetRoot}.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* <FieldsetLegend optionalLabel="optional">Kind</FieldsetLegend>
|
|
59
|
+
*/
|
|
60
|
+
export declare const FieldsetLegend: (props: FieldLabelProps) => ReactNode;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { normalizeFieldErrors } from "../../lib/forms/errors.js";
|
|
2
|
+
import { useRequiredContext } from "../../lib/use-required-context.js";
|
|
3
|
+
import { Field } from "../field/field.js";
|
|
4
|
+
import { FieldGroupContext } from "../field/field-group-context.js";
|
|
5
|
+
import { fieldStateAttributes } from "../field/field-state.js";
|
|
6
|
+
import { useFieldState } from "../field/use-field-state.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { createContext, useContext, useId, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fieldset } from "@base-ui/react/fieldset";
|
|
11
|
+
// src/components/fieldset/fieldset-root.tsx
|
|
12
|
+
var FieldsetContext = createContext(null);
|
|
13
|
+
/**
|
|
14
|
+
* The lines of the surrounding fieldset's error.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const { lines } = useFieldsetContext();
|
|
18
|
+
*/
|
|
19
|
+
var useFieldsetContext = () => {
|
|
20
|
+
return useRequiredContext(FieldsetContext, "Fieldset parts must be rendered within <Fieldset.Root>.");
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A copy of `record` without `key`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* withoutKey({ street: "Street", city: "City" }, "city"); // { street: "Street" }
|
|
27
|
+
*/
|
|
28
|
+
var withoutKey = (record, key) => Object.fromEntries(Object.entries(record).filter(([name]) => name !== key));
|
|
29
|
+
/**
|
|
30
|
+
* A field rendered as a fieldset, named by its legend: a group of choices, or a
|
|
31
|
+
* group of fields that shows the errors of its `members` in one place.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* <FieldsetRoot filled={kind !== null}>…</FieldsetRoot>
|
|
35
|
+
*/
|
|
36
|
+
var FieldsetRoot = (t0) => {
|
|
37
|
+
const $ = c(64);
|
|
38
|
+
let children;
|
|
39
|
+
let dirty;
|
|
40
|
+
let disabled;
|
|
41
|
+
let errors;
|
|
42
|
+
let filled;
|
|
43
|
+
let formatError;
|
|
44
|
+
let members;
|
|
45
|
+
let pending;
|
|
46
|
+
let props;
|
|
47
|
+
let readOnly;
|
|
48
|
+
let requiredness;
|
|
49
|
+
let touched;
|
|
50
|
+
if ($[0] !== t0) {
|
|
51
|
+
({errors, requiredness, dirty, touched, pending, filled, readOnly, disabled, members, formatError, children, ...props} = t0);
|
|
52
|
+
$[0] = t0;
|
|
53
|
+
$[1] = children;
|
|
54
|
+
$[2] = dirty;
|
|
55
|
+
$[3] = disabled;
|
|
56
|
+
$[4] = errors;
|
|
57
|
+
$[5] = filled;
|
|
58
|
+
$[6] = formatError;
|
|
59
|
+
$[7] = members;
|
|
60
|
+
$[8] = pending;
|
|
61
|
+
$[9] = props;
|
|
62
|
+
$[10] = readOnly;
|
|
63
|
+
$[11] = requiredness;
|
|
64
|
+
$[12] = touched;
|
|
65
|
+
} else {
|
|
66
|
+
children = $[1];
|
|
67
|
+
dirty = $[2];
|
|
68
|
+
disabled = $[3];
|
|
69
|
+
errors = $[4];
|
|
70
|
+
filled = $[5];
|
|
71
|
+
formatError = $[6];
|
|
72
|
+
members = $[7];
|
|
73
|
+
pending = $[8];
|
|
74
|
+
props = $[9];
|
|
75
|
+
readOnly = $[10];
|
|
76
|
+
requiredness = $[11];
|
|
77
|
+
touched = $[12];
|
|
78
|
+
}
|
|
79
|
+
const id = useId();
|
|
80
|
+
const parentGroup = useContext(FieldGroupContext);
|
|
81
|
+
let t1;
|
|
82
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
83
|
+
t1 = {};
|
|
84
|
+
$[13] = t1;
|
|
85
|
+
} else t1 = $[13];
|
|
86
|
+
const [labels, setLabels] = useState(t1);
|
|
87
|
+
let t2;
|
|
88
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
89
|
+
t2 = (name, label) => {
|
|
90
|
+
setLabels((current) => ({
|
|
91
|
+
...current,
|
|
92
|
+
[name]: label
|
|
93
|
+
}));
|
|
94
|
+
return () => {
|
|
95
|
+
setLabels((current_0) => withoutKey(current_0, name));
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
$[14] = t2;
|
|
99
|
+
} else t2 = $[14];
|
|
100
|
+
const registerLabel = t2;
|
|
101
|
+
let t3;
|
|
102
|
+
if ($[15] !== members) {
|
|
103
|
+
t3 = members ?? [];
|
|
104
|
+
$[15] = members;
|
|
105
|
+
$[16] = t3;
|
|
106
|
+
} else t3 = $[16];
|
|
107
|
+
let group;
|
|
108
|
+
let lines;
|
|
109
|
+
let t4;
|
|
110
|
+
let t5;
|
|
111
|
+
if ($[17] !== errors || $[18] !== formatError || $[19] !== id || $[20] !== labels || $[21] !== members || $[22] !== parentGroup || $[23] !== t3) {
|
|
112
|
+
let t6;
|
|
113
|
+
if ($[28] !== formatError || $[29] !== id || $[30] !== labels) {
|
|
114
|
+
t6 = (member, memberIndex) => normalizeFieldErrors(member.errors).map((message, lineIndex) => ({
|
|
115
|
+
id: `${id}member${memberIndex}line${lineIndex}`,
|
|
116
|
+
name: member.name,
|
|
117
|
+
content: formatError === void 0 ? message : formatError({
|
|
118
|
+
name: member.name,
|
|
119
|
+
label: labels[member.name]
|
|
120
|
+
}, message)
|
|
121
|
+
}));
|
|
122
|
+
$[28] = formatError;
|
|
123
|
+
$[29] = id;
|
|
124
|
+
$[30] = labels;
|
|
125
|
+
$[31] = t6;
|
|
126
|
+
} else t6 = $[31];
|
|
127
|
+
const memberLines = t3.flatMap(t6);
|
|
128
|
+
const groupMessages = normalizeFieldErrors(errors);
|
|
129
|
+
let t7;
|
|
130
|
+
if ($[32] !== id) {
|
|
131
|
+
t7 = (message_0, lineIndex_0) => ({
|
|
132
|
+
id: `${id}line${lineIndex_0}`,
|
|
133
|
+
name: void 0,
|
|
134
|
+
content: message_0
|
|
135
|
+
});
|
|
136
|
+
$[32] = id;
|
|
137
|
+
$[33] = t7;
|
|
138
|
+
} else t7 = $[33];
|
|
139
|
+
lines = [...memberLines, ...groupMessages.map(t7)];
|
|
140
|
+
group = members === void 0 ? parentGroup : {
|
|
141
|
+
lineIds: (name_0) => members.some((member_0) => member_0.name === name_0) ? memberLines.filter((line) => line.name === name_0).map(_temp) : void 0,
|
|
142
|
+
registerLabel
|
|
143
|
+
};
|
|
144
|
+
t5 = useFieldState;
|
|
145
|
+
let t8;
|
|
146
|
+
if ($[34] !== members) {
|
|
147
|
+
t8 = members ?? [];
|
|
148
|
+
$[34] = members;
|
|
149
|
+
$[35] = t8;
|
|
150
|
+
} else t8 = $[35];
|
|
151
|
+
t4 = [...groupMessages, ...t8.flatMap(_temp2)];
|
|
152
|
+
$[17] = errors;
|
|
153
|
+
$[18] = formatError;
|
|
154
|
+
$[19] = id;
|
|
155
|
+
$[20] = labels;
|
|
156
|
+
$[21] = members;
|
|
157
|
+
$[22] = parentGroup;
|
|
158
|
+
$[23] = t3;
|
|
159
|
+
$[24] = group;
|
|
160
|
+
$[25] = lines;
|
|
161
|
+
$[26] = t4;
|
|
162
|
+
$[27] = t5;
|
|
163
|
+
} else {
|
|
164
|
+
group = $[24];
|
|
165
|
+
lines = $[25];
|
|
166
|
+
t4 = $[26];
|
|
167
|
+
t5 = $[27];
|
|
168
|
+
}
|
|
169
|
+
let t6;
|
|
170
|
+
if ($[36] !== dirty || $[37] !== disabled || $[38] !== filled || $[39] !== pending || $[40] !== readOnly || $[41] !== requiredness || $[42] !== t4 || $[43] !== touched) {
|
|
171
|
+
t6 = {
|
|
172
|
+
errors: t4,
|
|
173
|
+
requiredness,
|
|
174
|
+
dirty,
|
|
175
|
+
touched,
|
|
176
|
+
pending,
|
|
177
|
+
disabled,
|
|
178
|
+
readOnly,
|
|
179
|
+
filled
|
|
180
|
+
};
|
|
181
|
+
$[36] = dirty;
|
|
182
|
+
$[37] = disabled;
|
|
183
|
+
$[38] = filled;
|
|
184
|
+
$[39] = pending;
|
|
185
|
+
$[40] = readOnly;
|
|
186
|
+
$[41] = requiredness;
|
|
187
|
+
$[42] = t4;
|
|
188
|
+
$[43] = touched;
|
|
189
|
+
$[44] = t6;
|
|
190
|
+
} else t6 = $[44];
|
|
191
|
+
const field = t5(t6);
|
|
192
|
+
let t7;
|
|
193
|
+
if ($[45] !== lines) {
|
|
194
|
+
t7 = { lines };
|
|
195
|
+
$[45] = lines;
|
|
196
|
+
$[46] = t7;
|
|
197
|
+
} else t7 = $[46];
|
|
198
|
+
let t8;
|
|
199
|
+
if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
|
|
200
|
+
t8 = /* @__PURE__ */ jsx(Fieldset.Root, {});
|
|
201
|
+
$[47] = t8;
|
|
202
|
+
} else t8 = $[47];
|
|
203
|
+
const t9 = field.disabled;
|
|
204
|
+
const t10 = field.invalid;
|
|
205
|
+
let t11;
|
|
206
|
+
if ($[48] !== field.state) {
|
|
207
|
+
t11 = fieldStateAttributes(field.state);
|
|
208
|
+
$[48] = field.state;
|
|
209
|
+
$[49] = t11;
|
|
210
|
+
} else t11 = $[49];
|
|
211
|
+
let t12;
|
|
212
|
+
if ($[50] !== children || $[51] !== dirty || $[52] !== field.disabled || $[53] !== field.invalid || $[54] !== props || $[55] !== t11 || $[56] !== touched) {
|
|
213
|
+
t12 = /* @__PURE__ */ jsx(Field.Root, {
|
|
214
|
+
render: t8,
|
|
215
|
+
disabled: t9,
|
|
216
|
+
invalid: t10,
|
|
217
|
+
dirty,
|
|
218
|
+
touched,
|
|
219
|
+
...t11,
|
|
220
|
+
...props,
|
|
221
|
+
children
|
|
222
|
+
});
|
|
223
|
+
$[50] = children;
|
|
224
|
+
$[51] = dirty;
|
|
225
|
+
$[52] = field.disabled;
|
|
226
|
+
$[53] = field.invalid;
|
|
227
|
+
$[54] = props;
|
|
228
|
+
$[55] = t11;
|
|
229
|
+
$[56] = touched;
|
|
230
|
+
$[57] = t12;
|
|
231
|
+
} else t12 = $[57];
|
|
232
|
+
let t13;
|
|
233
|
+
if ($[58] !== group || $[59] !== t12) {
|
|
234
|
+
t13 = /* @__PURE__ */ jsx(FieldGroupContext, {
|
|
235
|
+
value: group,
|
|
236
|
+
children: t12
|
|
237
|
+
});
|
|
238
|
+
$[58] = group;
|
|
239
|
+
$[59] = t12;
|
|
240
|
+
$[60] = t13;
|
|
241
|
+
} else t13 = $[60];
|
|
242
|
+
let t14;
|
|
243
|
+
if ($[61] !== t13 || $[62] !== t7) {
|
|
244
|
+
t14 = /* @__PURE__ */ jsx(FieldsetContext, {
|
|
245
|
+
value: t7,
|
|
246
|
+
children: t13
|
|
247
|
+
});
|
|
248
|
+
$[61] = t13;
|
|
249
|
+
$[62] = t7;
|
|
250
|
+
$[63] = t14;
|
|
251
|
+
} else t14 = $[63];
|
|
252
|
+
return t14;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* The legend that names a {@link FieldsetRoot}.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* <FieldsetLegend optionalLabel="optional">Kind</FieldsetLegend>
|
|
259
|
+
*/
|
|
260
|
+
var FieldsetLegend = (props) => {
|
|
261
|
+
const $ = c(3);
|
|
262
|
+
let t0;
|
|
263
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
264
|
+
t0 = /* @__PURE__ */ jsx(Fieldset.Legend, {});
|
|
265
|
+
$[0] = t0;
|
|
266
|
+
} else t0 = $[0];
|
|
267
|
+
let t1;
|
|
268
|
+
if ($[1] !== props) {
|
|
269
|
+
t1 = /* @__PURE__ */ jsx(Field.Label, {
|
|
270
|
+
nativeLabel: false,
|
|
271
|
+
render: t0,
|
|
272
|
+
...props
|
|
273
|
+
});
|
|
274
|
+
$[1] = props;
|
|
275
|
+
$[2] = t1;
|
|
276
|
+
} else t1 = $[2];
|
|
277
|
+
return t1;
|
|
278
|
+
};
|
|
279
|
+
function _temp(line_0) {
|
|
280
|
+
return line_0.id;
|
|
281
|
+
}
|
|
282
|
+
function _temp2(member_1) {
|
|
283
|
+
return normalizeFieldErrors(member_1.errors);
|
|
284
|
+
}
|
|
285
|
+
export { FieldsetLegend, FieldsetRoot, useFieldsetContext };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@layer kit.reset, kit.base, kit.components;
|
|
2
|
+
@layer kit.components {
|
|
3
|
+
._description_xocet_3 {
|
|
4
|
+
color: var(--fieldset-description-fg, var(--sys-color-text-muted));
|
|
5
|
+
font: var(--fieldset-description-font, var(--sys-font-body-medium));
|
|
6
|
+
}
|
|
7
|
+
._fields_xocet_7 {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-auto-flow: column;
|
|
10
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
11
|
+
grid-template-rows: [label] auto [control] auto [extra] auto [description] auto [error] auto;
|
|
12
|
+
grid-template-columns: var(--field-group-columns, none);
|
|
13
|
+
column-gap: var(--field-group-gap, var(--sys-unit-8));
|
|
14
|
+
}
|
|
15
|
+
._fields_xocet_7 > [data-field-group-member] {
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-row: 1/-1;
|
|
18
|
+
grid-template-rows: subgrid;
|
|
19
|
+
grid-template-columns: minmax(0, 1fr);
|
|
20
|
+
row-gap: 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { FieldsetLegend, FieldsetRoot } from "./fieldset-root.tsx";
|
|
3
|
+
export type FieldsetDescriptionProps = ComponentProps<"p">;
|
|
4
|
+
declare const FieldsetDescription: ({ children, className, ...props }: FieldsetDescriptionProps) => ReactNode;
|
|
5
|
+
export type FieldsetFieldsProps = ComponentProps<"div">;
|
|
6
|
+
declare const FieldsetFields: ({ className, ...props }: FieldsetFieldsProps) => ReactNode;
|
|
7
|
+
export type FieldsetErrorProps = Readonly<{
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
}>;
|
|
11
|
+
declare const FieldsetError: ({ id, className, }: FieldsetErrorProps) => ReactNode;
|
|
12
|
+
/** The parts of a fieldset. */
|
|
13
|
+
export type FieldsetParts = Readonly<{
|
|
14
|
+
Root: typeof FieldsetRoot;
|
|
15
|
+
Legend: typeof FieldsetLegend;
|
|
16
|
+
Description: typeof FieldsetDescription;
|
|
17
|
+
Fields: typeof FieldsetFields;
|
|
18
|
+
Error: typeof FieldsetError;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* A group of related fields named by one legend, with one error for all of
|
|
22
|
+
* them. `Fields` lays the fields side by side on one grid, so every field's
|
|
23
|
+
* label, control, description and error share a row with its neighbours'.
|
|
24
|
+
* `Error` is the group's only live region: it shows the lines of the `members`
|
|
25
|
+
* the root collects, each tied to its field's control, then the group's own
|
|
26
|
+
* `errors`. For the ordinary case, use `FieldGroup`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <Fieldset.Root members={members} aria-describedby={descriptionId}>
|
|
30
|
+
* <Fieldset.Legend optionalLabel="optional">Address</Fieldset.Legend>
|
|
31
|
+
* <Fieldset.Description id={descriptionId}>We send the invoice here.</Fieldset.Description>
|
|
32
|
+
* <Fieldset.Fields>…</Fieldset.Fields>
|
|
33
|
+
* <Fieldset.Error />
|
|
34
|
+
* </Fieldset.Root>
|
|
35
|
+
*/
|
|
36
|
+
export declare const Fieldset: FieldsetParts;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ErrorText } from "../error-text/error-text.js";
|
|
2
|
+
import { FieldRowContext } from "../field/field-group-context.js";
|
|
3
|
+
import { FieldsetLegend, FieldsetRoot, useFieldsetContext } from "./fieldset-root.js";
|
|
4
|
+
import fieldset_module_default from "./fieldset.module.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
// src/components/fieldset/fieldset.tsx
|
|
9
|
+
var FieldsetDescription = (t0) => {
|
|
10
|
+
const $ = c(8);
|
|
11
|
+
let children;
|
|
12
|
+
let className;
|
|
13
|
+
let props;
|
|
14
|
+
if ($[0] !== t0) {
|
|
15
|
+
({children, className, ...props} = t0);
|
|
16
|
+
$[0] = t0;
|
|
17
|
+
$[1] = children;
|
|
18
|
+
$[2] = className;
|
|
19
|
+
$[3] = props;
|
|
20
|
+
} else {
|
|
21
|
+
children = $[1];
|
|
22
|
+
className = $[2];
|
|
23
|
+
props = $[3];
|
|
24
|
+
}
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[4] !== children || $[5] !== className || $[6] !== props) {
|
|
27
|
+
t1 = children === void 0 || children === null || children === false || children === "" ? null : /* @__PURE__ */ jsx("p", {
|
|
28
|
+
className: clsx(fieldset_module_default.description, className),
|
|
29
|
+
...props,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
$[4] = children;
|
|
33
|
+
$[5] = className;
|
|
34
|
+
$[6] = props;
|
|
35
|
+
$[7] = t1;
|
|
36
|
+
} else t1 = $[7];
|
|
37
|
+
return t1;
|
|
38
|
+
};
|
|
39
|
+
var FieldsetFields = (t0) => {
|
|
40
|
+
const $ = c(8);
|
|
41
|
+
let className;
|
|
42
|
+
let props;
|
|
43
|
+
if ($[0] !== t0) {
|
|
44
|
+
({className, ...props} = t0);
|
|
45
|
+
$[0] = t0;
|
|
46
|
+
$[1] = className;
|
|
47
|
+
$[2] = props;
|
|
48
|
+
} else {
|
|
49
|
+
className = $[1];
|
|
50
|
+
props = $[2];
|
|
51
|
+
}
|
|
52
|
+
let t1;
|
|
53
|
+
if ($[3] !== className) {
|
|
54
|
+
t1 = clsx(fieldset_module_default.fields, className);
|
|
55
|
+
$[3] = className;
|
|
56
|
+
$[4] = t1;
|
|
57
|
+
} else t1 = $[4];
|
|
58
|
+
let t2;
|
|
59
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
60
|
+
t2 = /* @__PURE__ */ jsx(FieldRowContext, {
|
|
61
|
+
value: true,
|
|
62
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: t1,
|
|
64
|
+
...props
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
$[5] = props;
|
|
68
|
+
$[6] = t1;
|
|
69
|
+
$[7] = t2;
|
|
70
|
+
} else t2 = $[7];
|
|
71
|
+
return t2;
|
|
72
|
+
};
|
|
73
|
+
var FieldsetError = (t0) => {
|
|
74
|
+
const $ = c(6);
|
|
75
|
+
const { id, className } = t0;
|
|
76
|
+
const { lines } = useFieldsetContext();
|
|
77
|
+
let t1;
|
|
78
|
+
if ($[0] !== lines) {
|
|
79
|
+
t1 = lines.map(_temp);
|
|
80
|
+
$[0] = lines;
|
|
81
|
+
$[1] = t1;
|
|
82
|
+
} else t1 = $[1];
|
|
83
|
+
let t2;
|
|
84
|
+
if ($[2] !== className || $[3] !== id || $[4] !== t1) {
|
|
85
|
+
t2 = /* @__PURE__ */ jsx(ErrorText, {
|
|
86
|
+
role: "alert",
|
|
87
|
+
id,
|
|
88
|
+
className,
|
|
89
|
+
children: t1
|
|
90
|
+
});
|
|
91
|
+
$[2] = className;
|
|
92
|
+
$[3] = id;
|
|
93
|
+
$[4] = t1;
|
|
94
|
+
$[5] = t2;
|
|
95
|
+
} else t2 = $[5];
|
|
96
|
+
return t2;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* A group of related fields named by one legend, with one error for all of
|
|
100
|
+
* them. `Fields` lays the fields side by side on one grid, so every field's
|
|
101
|
+
* label, control, description and error share a row with its neighbours'.
|
|
102
|
+
* `Error` is the group's only live region: it shows the lines of the `members`
|
|
103
|
+
* the root collects, each tied to its field's control, then the group's own
|
|
104
|
+
* `errors`. For the ordinary case, use `FieldGroup`.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* <Fieldset.Root members={members} aria-describedby={descriptionId}>
|
|
108
|
+
* <Fieldset.Legend optionalLabel="optional">Address</Fieldset.Legend>
|
|
109
|
+
* <Fieldset.Description id={descriptionId}>We send the invoice here.</Fieldset.Description>
|
|
110
|
+
* <Fieldset.Fields>…</Fieldset.Fields>
|
|
111
|
+
* <Fieldset.Error />
|
|
112
|
+
* </Fieldset.Root>
|
|
113
|
+
*/
|
|
114
|
+
var Fieldset = {
|
|
115
|
+
Root: FieldsetRoot,
|
|
116
|
+
Legend: FieldsetLegend,
|
|
117
|
+
Description: FieldsetDescription,
|
|
118
|
+
Fields: FieldsetFields,
|
|
119
|
+
Error: FieldsetError
|
|
120
|
+
};
|
|
121
|
+
function _temp(line) {
|
|
122
|
+
return /* @__PURE__ */ jsx("span", {
|
|
123
|
+
id: line.id,
|
|
124
|
+
children: line.content
|
|
125
|
+
}, line.id);
|
|
126
|
+
}
|
|
127
|
+
export { Fieldset };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './fieldset.css';// src/components/fieldset/fieldset.module.scss
|
|
2
|
+
var description = "_description_xocet_3";
|
|
3
|
+
var fields = "_fields_xocet_7";
|
|
4
|
+
var fieldset_module_default = {
|
|
5
|
+
description,
|
|
6
|
+
fields
|
|
7
|
+
};
|
|
8
|
+
export { fieldset_module_default as default, description, fields };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type FieldGroupProps } from "./field-group.tsx";
|
|
3
|
+
export type TSFFieldGroupProps = Omit<FieldGroupProps, "members"> & Readonly<{
|
|
4
|
+
/** The fields whose errors the group shows, by name, in the order it shows them. A field it does not name keeps its own error. */
|
|
5
|
+
names: readonly string[];
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* `FieldGroup` bound to the TanStack Form it renders in: it shows the errors
|
|
9
|
+
* of the fields it `names`. Registered as `form.FieldGroup`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <form.FieldGroup legend="Address" optionalLabel="optional" names={["postalCode", "houseNumber"]}>
|
|
13
|
+
* <form.AppField name="postalCode">
|
|
14
|
+
* {field => <field.TextField label="Postal code" optionalLabel="optional" />}
|
|
15
|
+
* </form.AppField>
|
|
16
|
+
* <form.AppField name="houseNumber">
|
|
17
|
+
* {field => <field.TextField label="House number" optionalLabel="optional" />}
|
|
18
|
+
* </form.AppField>
|
|
19
|
+
* </form.FieldGroup>
|
|
20
|
+
*/
|
|
21
|
+
export declare const TSFFieldGroup: ({ names, ...props }: TSFFieldGroupProps) => ReactNode;
|