@gridui/form 3.0.2 → 4.1.0
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 +6 -61
- package/dist/field/field.d.ts +3 -3
- package/dist/field-counter/field-counter.d.ts +14 -0
- package/dist/field-grid/field-grid.d.ts +3 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.js +88 -40
- package/dist/index.js.map +4 -4
- package/dist/shared/field-sizing.d.ts +4 -0
- package/dist/styles.css +23 -23
- package/dist/use-field/use-field.d.ts +30 -0
- package/docs/catalog.json +37 -3
- package/docs/guides/action-form.md +11 -0
- package/docs/guides/fields.md +35 -0
- package/docs/guides/form-state.md +23 -0
- package/docs/guides/search-form.md +14 -0
- package/docs/reference/README.md +11 -0
- package/docs/reference/action-form.md +71 -0
- package/docs/reference/field-counter.md +65 -0
- package/docs/reference/field-grid.md +61 -0
- package/docs/reference/field-note.md +63 -0
- package/docs/reference/field.md +69 -0
- package/docs/reference/fieldset.md +57 -0
- package/docs/reference/list-field-control.md +43 -0
- package/docs/reference/search-form.md +57 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -9,75 +9,20 @@ See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/
|
|
|
9
9
|
|
|
10
10
|
## Form controls
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Inputs preserve native form constraints, refs, labels, descriptions and invalid
|
|
14
|
-
state; controls use 2.75rem standard or 2.25rem small sizing. Select accepts explicit
|
|
15
|
-
options with managed keyboard navigation, focus, and native form integration. `Field`, `Fieldset`, and
|
|
16
|
-
`FieldNote` own field grouping and error presentation. Input Label owns label/icon alignment.
|
|
17
|
-
Fieldset keeps native disabled propagation and legend semantics.
|
|
18
|
-
|
|
19
|
-
`FilePicker` owns the bordered surface, drag state, native input, and optional
|
|
20
|
-
selection button. Callers supply `inputId`, `accept`, labels, hint, icon,
|
|
21
|
-
`disabled`, and `onFile`; `drop` enables drag-and-drop. Omitting `action` retains
|
|
22
|
-
the visible native input. `onFile` may return a promise. FilePicker owns its native input ref and clears
|
|
23
|
-
selection after that callback settles, including errors and cancelled
|
|
24
|
-
replacement. `onFileError(error)` receives synchronous reader exceptions and promise
|
|
25
|
-
rejections after input cleanup. Without a handler, failures are logged to the
|
|
26
|
-
console instead of becoming unhandled promise rejections. This permits repeated selection of the same file without DOM
|
|
27
|
-
access in business controllers. Parsing and exported bytes remain application-owned. Optional
|
|
28
|
-
`confirmSelection` requests native confirmation before replacing a pending file.
|
|
29
|
-
Invalid borders use the danger color token; keyboard focus remains owned by the theme.
|
|
30
|
-
|
|
12
|
+
Read [Fields and native controls](docs/guides/fields.md).
|
|
31
13
|
|
|
32
14
|
## Form arrangements
|
|
33
15
|
|
|
34
|
-
|
|
35
|
-
FieldGrid supplies full-width field spans, two columns above 24rem, and one
|
|
36
|
-
column at or below 24rem. SearchForm aligns fields and submit actions.
|
|
37
|
-
Use `<Field grow>` or `<FieldGrid grow>` for a flexible search region; other
|
|
38
|
-
children retain their own sizing. Layout containers do not style arbitrary divs,
|
|
39
|
-
labels, or icons. Use Input's `<Label icon={...}>` for label/icon alignment.
|
|
40
|
-
Migration: add `grow` to former implicitly stretched SearchForm children and
|
|
41
|
-
use Label instead of relying on FieldGrid to restyle native labels.
|
|
42
|
-
Both forward native props and refs. The corresponding Core families own labels, constraints, invalid
|
|
43
|
-
state, field notes, and native fieldset semantics; applications own values,
|
|
44
|
-
validation, and submission actions. These local form arrangements do not own
|
|
45
|
-
page frames or shared region seams.
|
|
46
|
-
|
|
16
|
+
Read [Form arrangements and search](docs/guides/search-form.md).
|
|
47
17
|
|
|
48
18
|
## Declarative action boundaries
|
|
49
19
|
|
|
50
|
-
[
|
|
51
|
-
owns pending state and scheduling for caller-owned actions. `ActionForm` from
|
|
52
|
-
`@gridui/form` prevents native form navigation and invokes its declared
|
|
53
|
-
`onAction` unless disabled. Native form
|
|
54
|
-
validation still runs before submission. `onActionError(error)` receives synchronous
|
|
55
|
-
exceptions and promise rejections; without a handler, failures are logged to the
|
|
56
|
-
console. Applications own visible feedback. `Input.onValueChange` exposes text
|
|
57
|
-
values directly; native onChange props remain available for browser-level
|
|
58
|
-
consumers.
|
|
59
|
-
|
|
20
|
+
Read [Action forms and asynchronous submission](docs/guides/action-form.md).
|
|
60
21
|
|
|
61
22
|
## Native form collaborators
|
|
62
23
|
|
|
63
|
-
|
|
64
|
-
the element's current form owner, including forms mounted later, replacement
|
|
65
|
-
forms, and controls moved between forms. Native controls supply their own form
|
|
66
|
-
association; composite roots use the optional form ID or their closest form.
|
|
67
|
-
The callback runs after native reset and cancellation handlers. Pending callbacks
|
|
68
|
-
are discarded on unmount or reassociation. Value ownership remains with each
|
|
69
|
-
control: selection families can request controlled resets, while ordinary
|
|
70
|
-
controlled inputs leave reset policy to their caller.
|
|
24
|
+
Read [Native form state and reset](docs/guides/form-state.md).
|
|
71
25
|
|
|
72
|
-
|
|
73
|
-
input/select mirror and invokes the visible-control focus callback only when that
|
|
74
|
-
mirror is the form's first participating invalid control. Applications still own
|
|
75
|
-
validation messages and invalid appearance.
|
|
26
|
+
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
|
76
27
|
|
|
77
|
-
`
|
|
78
|
-
TagInput. It forwards `ref`, `name`, `form`, `required`, and `disabled`, accepts
|
|
79
|
-
`value` and caller-owned option children, and routes native changes through
|
|
80
|
-
`onValueChange` and invalid focus through `onInvalidFocus`. Pair it with
|
|
81
|
-
`useListField` for controlled/local values and cancellable reset synchronization.
|
|
82
|
-
Option membership, unavailable values, tag parsing, and visible focus targets
|
|
83
|
-
remain caller-owned. Single-value SelectionForm remains Select-owned.
|
|
28
|
+
Use `useField` for native label/help/error associations and `FieldCounter` for localized native-length feedback. See [fields](docs/guides/fields.md#associations-and-counters).
|
package/dist/field/field.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @namespace Field
|
|
5
5
|
* @description Field
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { type FieldSizingOptions } from "../shared/field-sizing";
|
|
8
|
+
import type { FC } from "react";
|
|
9
|
+
export type FieldProps = FieldSizingOptions & {
|
|
10
10
|
readonly span?: "auto" | "full";
|
|
11
11
|
};
|
|
12
12
|
export declare const Field: FC<FieldProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Form
|
|
4
|
+
* @namespace FieldCounter
|
|
5
|
+
* @description Field Counter
|
|
6
|
+
*/
|
|
7
|
+
import { type FieldNoteProps } from "../field-note/field-note";
|
|
8
|
+
import type { FC, ReactNode } from "react";
|
|
9
|
+
export type FieldCounterProps = Omit<FieldNoteProps, "children" | "invalid"> & {
|
|
10
|
+
readonly value: string;
|
|
11
|
+
readonly maxLength?: number;
|
|
12
|
+
readonly formatCount: (count: number, maxLength: number | undefined) => ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare const FieldCounter: FC<FieldCounterProps>;
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* @namespace FieldGrid
|
|
5
5
|
* @description Field Grid
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
7
|
+
import { type FieldSizingOptions } from "../shared/field-sizing";
|
|
8
|
+
import type { FC } from "react";
|
|
9
|
+
export type FieldGridProps = FieldSizingOptions;
|
|
11
10
|
export declare const FieldGrid: FC<FieldGridProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { runFormAction } from "./action-form/run-action";
|
|
|
10
10
|
export type { FieldProps } from "./field/field";
|
|
11
11
|
export { Field } from "./field/field";
|
|
12
12
|
export { fieldClass } from "./field/style";
|
|
13
|
+
export type { FieldCounterProps } from "./field-counter/field-counter";
|
|
14
|
+
export { FieldCounter } from "./field-counter/field-counter";
|
|
13
15
|
export type { FieldGridProps } from "./field-grid/field-grid";
|
|
14
16
|
export { FieldGrid } from "./field-grid/field-grid";
|
|
15
17
|
export type { FieldNoteProps } from "./field-note/field-note";
|
|
@@ -24,3 +26,5 @@ export { focusInvalidControl } from "./shared/focus-invalid-control";
|
|
|
24
26
|
export { useFormReset } from "./shared/use-form-reset";
|
|
25
27
|
export type { ListFieldProps } from "./shared/use-list-field";
|
|
26
28
|
export { useListField } from "./shared/use-list-field";
|
|
29
|
+
export type { UseFieldOptions } from "./use-field/use-field";
|
|
30
|
+
export { useField } from "./use-field/use-field";
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var ActionForm = (props) => {
|
|
|
38
38
|
import { cva } from "class-variance-authority";
|
|
39
39
|
var fieldSizingStyles = cva("", {
|
|
40
40
|
variants: {
|
|
41
|
-
grow: { true: "gridui-u-flex-1 gridui-u-basis-48" }
|
|
41
|
+
grow: { true: "gridui-u-form--flex-1 gridui-u-form--basis-48" }
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -47,7 +47,7 @@ import { cn } from "@gridui/style-utils";
|
|
|
47
47
|
import { cva as cva2 } from "class-variance-authority";
|
|
48
48
|
var fieldStyles = cva2(cn(
|
|
49
49
|
"gridui-field",
|
|
50
|
-
"gridui-u-grid gridui-u-min-w-0 gridui-u-gap-gridui-8"
|
|
50
|
+
"gridui-u-form--grid gridui-u-form--min-w-0 gridui-u-form--gap-gridui-8"
|
|
51
51
|
));
|
|
52
52
|
var fieldClass = (className) => {
|
|
53
53
|
return cn(fieldStyles(), className);
|
|
@@ -68,54 +68,71 @@ var Field = (props) => {
|
|
|
68
68
|
);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
// src/field-
|
|
71
|
+
// src/field-note/style.ts
|
|
72
72
|
import { cn as cn3 } from "@gridui/style-utils";
|
|
73
73
|
import { cva as cva3 } from "class-variance-authority";
|
|
74
|
-
var
|
|
75
|
-
"gridui-field-
|
|
76
|
-
"gridui-u-
|
|
77
|
-
"gridui-u
|
|
78
|
-
"gridui-u-[@media(max-width:24rem)]:grid-cols-[1fr]"
|
|
74
|
+
var fieldNoteStyles = cva3(cn3(
|
|
75
|
+
"gridui-field-note",
|
|
76
|
+
"gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere",
|
|
77
|
+
"gridui-u-form--data-[invalid='true']:text-danger-foreground"
|
|
79
78
|
));
|
|
80
79
|
|
|
81
|
-
// src/field-
|
|
80
|
+
// src/field-note/field-note.tsx
|
|
82
81
|
import { cn as cn4 } from "@gridui/style-utils";
|
|
83
82
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
84
|
-
var
|
|
85
|
-
const {
|
|
83
|
+
var FieldNote = (props) => {
|
|
84
|
+
const {
|
|
85
|
+
invalid = false,
|
|
86
|
+
className,
|
|
87
|
+
...restProps
|
|
88
|
+
} = props;
|
|
86
89
|
return /* @__PURE__ */ jsx3(
|
|
87
|
-
"
|
|
90
|
+
"span",
|
|
88
91
|
{
|
|
89
92
|
...restProps,
|
|
90
|
-
className: cn4(
|
|
93
|
+
className: cn4(fieldNoteStyles(), className),
|
|
94
|
+
"data-invalid": invalid
|
|
91
95
|
}
|
|
92
96
|
);
|
|
93
97
|
};
|
|
94
98
|
|
|
95
|
-
// src/field-
|
|
99
|
+
// src/field-counter/field-counter.tsx
|
|
100
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
101
|
+
var FieldCounter = (props) => {
|
|
102
|
+
const { value, maxLength, formatCount, ...restProps } = props;
|
|
103
|
+
if (maxLength !== void 0 && (!Number.isSafeInteger(maxLength) || maxLength < 0)) {
|
|
104
|
+
throw new RangeError("FieldCounter maxLength must be a nonnegative integer.");
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ jsx4(
|
|
107
|
+
FieldNote,
|
|
108
|
+
{
|
|
109
|
+
...restProps,
|
|
110
|
+
invalid: maxLength !== void 0 && value.length > maxLength,
|
|
111
|
+
children: formatCount(value.length, maxLength)
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/field-grid/style.ts
|
|
96
117
|
import { cn as cn5 } from "@gridui/style-utils";
|
|
97
118
|
import { cva as cva4 } from "class-variance-authority";
|
|
98
|
-
var
|
|
99
|
-
"gridui-field-
|
|
100
|
-
"gridui-u-
|
|
101
|
-
"gridui-u-data-[
|
|
119
|
+
var fieldGridStyles = cva4(cn5(
|
|
120
|
+
"gridui-field-grid",
|
|
121
|
+
"gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16",
|
|
122
|
+
"gridui-u-form--*:data-[span='full']:col-span-full",
|
|
123
|
+
"gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]"
|
|
102
124
|
));
|
|
103
125
|
|
|
104
|
-
// src/field-
|
|
126
|
+
// src/field-grid/field-grid.tsx
|
|
105
127
|
import { cn as cn6 } from "@gridui/style-utils";
|
|
106
|
-
import { jsx as
|
|
107
|
-
var
|
|
108
|
-
const {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...restProps
|
|
112
|
-
} = props;
|
|
113
|
-
return /* @__PURE__ */ jsx4(
|
|
114
|
-
"span",
|
|
128
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
129
|
+
var FieldGrid = (props) => {
|
|
130
|
+
const { grow = false, className, ...restProps } = props;
|
|
131
|
+
return /* @__PURE__ */ jsx5(
|
|
132
|
+
"div",
|
|
115
133
|
{
|
|
116
134
|
...restProps,
|
|
117
|
-
className: cn6(
|
|
118
|
-
"data-invalid": invalid
|
|
135
|
+
className: cn6(fieldGridStyles(), fieldSizingStyles({ grow }), className)
|
|
119
136
|
}
|
|
120
137
|
);
|
|
121
138
|
};
|
|
@@ -125,16 +142,16 @@ import { cn as cn7 } from "@gridui/style-utils";
|
|
|
125
142
|
import { cva as cva5 } from "class-variance-authority";
|
|
126
143
|
var fieldsetStyles = cva5(cn7(
|
|
127
144
|
"gridui-fieldset",
|
|
128
|
-
"gridui-u-min-w-0 gridui-u-m-0 gridui-u-p-0 gridui-u-border-0",
|
|
129
|
-
"gridui-u-[&>legend]:mb-gridui-24 gridui-u-[&>legend]:p-0"
|
|
145
|
+
"gridui-u-form--min-w-0 gridui-u-form--m-0 gridui-u-form--p-0 gridui-u-form--border-0",
|
|
146
|
+
"gridui-u-form--[&>legend]:mb-gridui-24 gridui-u-form--[&>legend]:p-0"
|
|
130
147
|
));
|
|
131
148
|
|
|
132
149
|
// src/fieldset/fieldset.tsx
|
|
133
150
|
import { cn as cn8 } from "@gridui/style-utils";
|
|
134
|
-
import { jsx as
|
|
151
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
135
152
|
var Fieldset = (props) => {
|
|
136
153
|
const { className, ...restProps } = props;
|
|
137
|
-
return /* @__PURE__ */
|
|
154
|
+
return /* @__PURE__ */ jsx6(
|
|
138
155
|
"fieldset",
|
|
139
156
|
{
|
|
140
157
|
...restProps,
|
|
@@ -157,15 +174,15 @@ var focusInvalidControl = (event, focus) => {
|
|
|
157
174
|
};
|
|
158
175
|
|
|
159
176
|
// src/list-field-control/list-field-control.tsx
|
|
160
|
-
import { jsx as
|
|
177
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
161
178
|
var ListFieldControl = (props) => {
|
|
162
179
|
const { onValueChange, onInvalidFocus, ...restProps } = props;
|
|
163
|
-
return /* @__PURE__ */
|
|
180
|
+
return /* @__PURE__ */ jsx7(
|
|
164
181
|
"select",
|
|
165
182
|
{
|
|
166
183
|
...restProps,
|
|
167
184
|
multiple: true,
|
|
168
|
-
className: "gridui-u-sr-only",
|
|
185
|
+
className: "gridui-u-form--sr-only",
|
|
169
186
|
"aria-hidden": "true",
|
|
170
187
|
tabIndex: -1,
|
|
171
188
|
onChange: (event) => {
|
|
@@ -185,15 +202,15 @@ import { cn as cn9 } from "@gridui/style-utils";
|
|
|
185
202
|
import { cva as cva6 } from "class-variance-authority";
|
|
186
203
|
var searchFormStyles = cva6(cn9(
|
|
187
204
|
"gridui-search-form",
|
|
188
|
-
"gridui-u-flex gridui-u-flex-wrap gridui-u-items-end gridui-u-gap-gridui-16"
|
|
205
|
+
"gridui-u-form--flex gridui-u-form--flex-wrap gridui-u-form--items-end gridui-u-form--gap-gridui-16"
|
|
189
206
|
));
|
|
190
207
|
|
|
191
208
|
// src/search-form/search-form.tsx
|
|
192
209
|
import { cn as cn10 } from "@gridui/style-utils";
|
|
193
|
-
import { jsx as
|
|
210
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
194
211
|
var SearchForm = (props) => {
|
|
195
212
|
const { className, ...restProps } = props;
|
|
196
|
-
return /* @__PURE__ */
|
|
213
|
+
return /* @__PURE__ */ jsx8(
|
|
197
214
|
"form",
|
|
198
215
|
{
|
|
199
216
|
...restProps,
|
|
@@ -314,9 +331,39 @@ var useListField = (props, onReset) => {
|
|
|
314
331
|
available
|
|
315
332
|
};
|
|
316
333
|
};
|
|
334
|
+
|
|
335
|
+
// src/use-field/use-field.ts
|
|
336
|
+
import { useId } from "react";
|
|
337
|
+
var useField = (options = {}) => {
|
|
338
|
+
const generatedId = useId();
|
|
339
|
+
const { id = generatedId, invalid = false, description = false, error = false } = options;
|
|
340
|
+
const descriptionId = `${id}-description`;
|
|
341
|
+
const errorId = `${id}-error`;
|
|
342
|
+
const describedBy = [
|
|
343
|
+
.../* @__PURE__ */ new Set([
|
|
344
|
+
...options["aria-describedby"]?.split(/\s+/).filter(Boolean) ?? [],
|
|
345
|
+
...description ? [descriptionId] : [],
|
|
346
|
+
...invalid && error ? [errorId] : []
|
|
347
|
+
])
|
|
348
|
+
].join(" ") || void 0;
|
|
349
|
+
return {
|
|
350
|
+
controlProps: {
|
|
351
|
+
id,
|
|
352
|
+
"aria-invalid": invalid,
|
|
353
|
+
"aria-describedby": describedBy
|
|
354
|
+
},
|
|
355
|
+
labelProps: { htmlFor: id },
|
|
356
|
+
descriptionProps: { id: descriptionId },
|
|
357
|
+
errorProps: {
|
|
358
|
+
id: errorId,
|
|
359
|
+
invalid
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
};
|
|
317
363
|
export {
|
|
318
364
|
ActionForm,
|
|
319
365
|
Field,
|
|
366
|
+
FieldCounter,
|
|
320
367
|
FieldGrid,
|
|
321
368
|
FieldNote,
|
|
322
369
|
Fieldset,
|
|
@@ -325,6 +372,7 @@ export {
|
|
|
325
372
|
fieldClass,
|
|
326
373
|
focusInvalidControl,
|
|
327
374
|
runFormAction,
|
|
375
|
+
useField,
|
|
328
376
|
useFormReset,
|
|
329
377
|
useListField
|
|
330
378
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/action-form/run-action.ts", "../src/action-form/action-form.tsx", "../src/shared/field-sizing.ts", "../src/field/style.ts", "../src/field/field.tsx", "../src/field-
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Run Action\n */\n\nexport const runFormAction = async (\n action: () => void | Promise<void>,\n onError?: (error: unknown) => void,\n): Promise<void> => {\n try {\n await action();\n } catch (error) {\n if (onError) {\n onError(error);\n } else {\n console.error(error);\n }\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Action Form\n */\n\nimport { runFormAction } from \"./run-action\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ActionFormProps = Omit<ComponentPropsWithRef<\"form\">, \"onSubmit\"> & {\n readonly onAction: () => void | Promise<void>;\n readonly onActionError?: (error: unknown) => void;\n readonly disabled?: boolean;\n};\n\nexport const ActionForm: FC<ActionFormProps> = (props: ActionFormProps) => {\n const {\n onAction,\n onActionError,\n disabled = false,\n ...restProps\n } = props;\n return (<form\n {...restProps}\n onSubmit={(event) => {\n event.preventDefault();\n if (!disabled) {\n void runFormAction(onAction, onActionError);\n }\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Field Sizing\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldSizingStyles = cva(\"\", {\n variants: {\n grow: { true: \"gridui-u-flex-1 gridui-u-basis-48\" },\n },\n});\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldStyles = cva(cn(\n \"gridui-field\",\n \"gridui-u-grid gridui-u-min-w-0 gridui-u-gap-gridui-8\",\n));\n\nexport const fieldClass = (className?: string): string => {\n return cn(fieldStyles(), className);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Field\n */\n\nimport { fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldClass } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldProps = ComponentPropsWithRef<\"div\"> & {\n readonly grow?: boolean;\n readonly span?: \"auto\" | \"full\";\n};\n\nexport const Field: FC<FieldProps> = (props: FieldProps) => {\n const { span = \"auto\", grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldClass(), fieldSizingStyles({ grow }), className)}\n data-span={span}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldGridStyles = cva(cn(\n \"gridui-field-grid\",\n \"gridui-u-grid gridui-u-grid-cols-2 gridui-u-gap-gridui-16\",\n \"gridui-u-*:data-[span='full']:col-span-full\",\n \"gridui-u-[@media(max-width:24rem)]:grid-cols-[1fr]\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Field Grid\n */\n\nimport { fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldGridStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldGridProps = ComponentPropsWithRef<\"div\"> & {\n readonly grow?: boolean;\n};\n\nexport const FieldGrid: FC<FieldGridProps> = (props: FieldGridProps) => {\n const { grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldGridStyles(), fieldSizingStyles({ grow }), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldNoteStyles = cva(cn(\n \"gridui-field-note\",\n \"gridui-u-text-muted gridui-u-type-supporting gridui-u-wrap-anywhere\",\n \"gridui-u-data-[invalid='true']:text-danger-foreground\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Field Note\n */\n\nimport { fieldNoteStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldNoteProps = ComponentPropsWithRef<\"span\"> & {\n readonly invalid?: boolean;\n};\n\nexport const FieldNote: FC<FieldNoteProps> = (props: FieldNoteProps) => {\n const {\n invalid = false,\n className,\n ...restProps\n } = props;\n return (<span\n {...restProps}\n className={cn(fieldNoteStyles(), className)}\n data-invalid={invalid}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldsetStyles = cva(cn(\n \"gridui-fieldset\",\n \"gridui-u-min-w-0 gridui-u-m-0 gridui-u-p-0 gridui-u-border-0\",\n \"gridui-u-[&>legend]:mb-gridui-24 gridui-u-[&>legend]:p-0\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Fieldset\n */\n\nimport { fieldsetStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldsetProps = ComponentPropsWithRef<\"fieldset\">;\n\nexport const Fieldset: FC<FieldsetProps> = (props: FieldsetProps) => {\n const { className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(fieldsetStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Focus Invalid Control\n */\n\nimport type { SyntheticEvent } from \"react\";\n\nexport const focusInvalidControl = (\n event: SyntheticEvent<HTMLInputElement | HTMLSelectElement>,\n focus: () => void,\n): void => {\n event.preventDefault();\n const control = event.currentTarget;\n const owner = control.form;\n const firstInvalid = owner && Array.from(owner.elements).find(element => {\n return \"willValidate\" in element && element.willValidate && element.matches(\":invalid\");\n });\n if (!owner || firstInvalid === control) {\n focus();\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ListFieldControl\n * @description List Field Control\n */\n\nimport { focusInvalidControl } from \"../shared/focus-invalid-control\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ListFieldControlProps = Pick<ComponentPropsWithRef<\"select\">, \"name\" | \"form\" | \"disabled\" | \"required\" | \"ref\" | \"children\"> & {\n readonly value: readonly string[];\n readonly onValueChange?: (value: string[]) => void;\n readonly onInvalidFocus: () => void;\n};\n\nexport const ListFieldControl: FC<ListFieldControlProps> = (props: ListFieldControlProps) => {\n const { onValueChange, onInvalidFocus, ...restProps } = props;\n return (<select\n {...restProps}\n multiple\n className=\"gridui-u-sr-only\"\n aria-hidden=\"true\"\n tabIndex={-1}\n onChange={event => {\n onValueChange?.(Array.from(event.currentTarget.selectedOptions, option => {\n return option.value;\n }));\n }}\n onInvalid={event => {\n focusInvalidControl(event, onInvalidFocus);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const searchFormStyles = cva(cn(\n \"gridui-search-form\",\n \"gridui-u-flex gridui-u-flex-wrap gridui-u-items-end gridui-u-gap-gridui-16\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Search Form\n */\n\nimport { searchFormStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type SearchFormProps = ComponentPropsWithRef<\"form\">;\n\nexport const SearchForm: FC<SearchFormProps> = (props: SearchFormProps) => {\n const { className, ...restProps } = props;\n return (<form\n {...restProps}\n className={cn(searchFormStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use Form Reset\n */\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\ntype ResetElement = HTMLElement & {\n readonly form?: HTMLFormElement | null;\n};\n\nconst formOwner = (element: ResetElement, form?: string): Element | null => {\n if (element.form !== undefined) {\n return element.form;\n }\n return form === undefined ? element.closest(\"form\") : element.ownerDocument.getElementById(form);\n};\n\nexport const useFormReset = (element: RefObject<ResetElement | null>, onReset: () => void, form?: string): void => {\n const latest = useRef(onReset);\n useLayoutEffect(() => {\n latest.current = onReset;\n });\n useEffect(() => {\n const document = element.current?.ownerDocument;\n if (!document) {\n return;\n }\n const pending = new Set<ReturnType<typeof setTimeout>>();\n const reset = (event: Event): void => {\n const control = element.current;\n if (!control || event.target !== formOwner(control, form)) {\n return;\n }\n // Native reset runs after dispatch; React bubbling handlers can cancel it.\n const timer = setTimeout(() => {\n pending.delete(timer);\n const current = element.current;\n if (!event.defaultPrevented && current && event.target === formOwner(current, form)) {\n latest.current();\n }\n }, 0);\n pending.add(timer);\n };\n document.addEventListener(\"reset\", reset, true);\n return () => {\n document.removeEventListener(\"reset\", reset, true);\n pending.forEach(timer => {\n clearTimeout(timer);\n });\n };\n }, [\n element,\n form,\n ]);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use List Field\n */\n\nimport { useFormReset } from \"./use-form-reset\";\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nexport type ListFieldProps = {\n readonly value?: readonly string[] | undefined;\n readonly defaultValue?: readonly string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly disabled?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly form?: string | undefined;\n};\n\nexport const useListField = (props: ListFieldProps, onReset: () => void) => {\n const { value, defaultValue = [], onValueChange, disabled, readOnly, form } = props;\n const [\n local,\n setLocal,\n ] = useState(() => {\n return [...new Set(defaultValue)];\n });\n const selected = [...new Set(value ?? local)];\n const initial = useRef(selected);\n const native = useRef<HTMLSelectElement>(null);\n const control = useRef<HTMLElement>(null);\n const available = () => {\n return !disabled && !readOnly && !control.current?.matches(\":disabled\");\n };\n const update = (next: readonly string[]) => {\n const unique = [...new Set(next)];\n if (selected.length === unique.length && selected.every((entry, index) => {\n return entry === unique[index];\n })) {\n return;\n }\n if (value === undefined) {\n setLocal(unique);\n }\n onValueChange?.(unique);\n };\n const latest = useRef({\n update,\n onReset,\n selected,\n });\n useLayoutEffect(() => {\n latest.current = {\n update,\n onReset,\n selected,\n };\n });\n useFormReset(native, () => {\n flushSync(() => {\n latest.current.update(initial.current);\n latest.current.onReset();\n });\n if (native.current) {\n for (const option of native.current.options) {\n option.selected = latest.current.selected.includes(option.value);\n }\n }\n }, form);\n const change = (next: readonly string[]) => {\n if (available()) {\n update(next);\n }\n };\n return {\n selected,\n native,\n control,\n change,\n available,\n };\n};\n"],
|
|
5
|
-
"mappings": ";AAOO,IAAM,gBAAgB,OACzB,QACA,YACgB;AAChB,MAAI;AACA,UAAM,OAAO;AAAA,EACjB,SAAS,OAAO;AACZ,QAAI,SAAS;AACT,cAAQ,KAAK;AAAA,IACjB,OAAO;AACH,cAAQ,MAAM,KAAK;AAAA,IACvB;AAAA,EACJ;AACJ;;;ACGY;AAPL,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,GAAG;AAAA,EACP,IAAI;AACJ,SAAQ;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ,UAAU,CAAC,UAAU;AACjB,cAAM,eAAe;AACrB,YAAI,CAAC,UAAU;AACX,eAAK,cAAc,UAAU,aAAa;AAAA,QAC9C;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;;;ACzBA,SAAS,WAAW;
|
|
6
|
-
"names": ["cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "useLayoutEffect", "useRef"]
|
|
3
|
+
"sources": ["../src/action-form/run-action.ts", "../src/action-form/action-form.tsx", "../src/shared/field-sizing.ts", "../src/field/style.ts", "../src/field/field.tsx", "../src/field-note/style.ts", "../src/field-note/field-note.tsx", "../src/field-counter/field-counter.tsx", "../src/field-grid/style.ts", "../src/field-grid/field-grid.tsx", "../src/fieldset/style.ts", "../src/fieldset/fieldset.tsx", "../src/shared/focus-invalid-control.ts", "../src/list-field-control/list-field-control.tsx", "../src/search-form/style.ts", "../src/search-form/search-form.tsx", "../src/shared/use-form-reset.ts", "../src/shared/use-list-field.ts", "../src/use-field/use-field.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Run Action\n */\n\nexport const runFormAction = async (\n action: () => void | Promise<void>,\n onError?: (error: unknown) => void,\n): Promise<void> => {\n try {\n await action();\n } catch (error) {\n if (onError) {\n onError(error);\n } else {\n console.error(error);\n }\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Action Form\n */\n\nimport { runFormAction } from \"./run-action\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ActionFormProps = Omit<ComponentPropsWithRef<\"form\">, \"onSubmit\"> & {\n readonly onAction: () => void | Promise<void>;\n readonly onActionError?: (error: unknown) => void;\n readonly disabled?: boolean;\n};\n\nexport const ActionForm: FC<ActionFormProps> = (props: ActionFormProps) => {\n const {\n onAction,\n onActionError,\n disabled = false,\n ...restProps\n } = props;\n return (<form\n {...restProps}\n onSubmit={(event) => {\n event.preventDefault();\n if (!disabled) {\n void runFormAction(onAction, onActionError);\n }\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Field Sizing\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nexport type FieldSizingOptions = ComponentPropsWithRef<\"div\"> & {\n readonly grow?: boolean;\n};\n\nexport const fieldSizingStyles = cva(\"\", {\n variants: {\n grow: { true: \"gridui-u-form--flex-1 gridui-u-form--basis-48\" },\n },\n});\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldStyles = cva(cn(\n \"gridui-field\",\n \"gridui-u-form--grid gridui-u-form--min-w-0 gridui-u-form--gap-gridui-8\",\n));\n\nexport const fieldClass = (className?: string): string => {\n return cn(fieldStyles(), className);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Field\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldClass } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldProps = FieldSizingOptions & {\n readonly span?: \"auto\" | \"full\";\n};\n\nexport const Field: FC<FieldProps> = (props: FieldProps) => {\n const { span = \"auto\", grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldClass(), fieldSizingStyles({ grow }), className)}\n data-span={span}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldNoteStyles = cva(cn(\n \"gridui-field-note\",\n \"gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere\",\n \"gridui-u-form--data-[invalid='true']:text-danger-foreground\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Field Note\n */\n\nimport { fieldNoteStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldNoteProps = ComponentPropsWithRef<\"span\"> & {\n readonly invalid?: boolean;\n};\n\nexport const FieldNote: FC<FieldNoteProps> = (props: FieldNoteProps) => {\n const {\n invalid = false,\n className,\n ...restProps\n } = props;\n return (<span\n {...restProps}\n className={cn(fieldNoteStyles(), className)}\n data-invalid={invalid}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldCounter\n * @description Field Counter\n */\n\nimport { FieldNote, type FieldNoteProps } from \"../field-note/field-note\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type FieldCounterProps = Omit<FieldNoteProps, \"children\" | \"invalid\"> & {\n readonly value: string;\n readonly maxLength?: number;\n readonly formatCount: (count: number, maxLength: number | undefined) => ReactNode;\n};\nexport const FieldCounter: FC<FieldCounterProps> = (props: FieldCounterProps) => {\n const { value, maxLength, formatCount, ...restProps } = props;\n if (maxLength !== undefined && (!Number.isSafeInteger(maxLength) || maxLength < 0)) {\n throw new RangeError(\"FieldCounter maxLength must be a nonnegative integer.\");\n }\n return (<FieldNote\n {...restProps}\n invalid={maxLength !== undefined && value.length > maxLength}\n >\n {formatCount(value.length, maxLength)}\n </FieldNote>);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldGridStyles = cva(cn(\n \"gridui-field-grid\",\n \"gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16\",\n \"gridui-u-form--*:data-[span='full']:col-span-full\",\n \"gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Field Grid\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldGridStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldGridProps = FieldSizingOptions;\n\nexport const FieldGrid: FC<FieldGridProps> = (props: FieldGridProps) => {\n const { grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldGridStyles(), fieldSizingStyles({ grow }), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldsetStyles = cva(cn(\n \"gridui-fieldset\",\n \"gridui-u-form--min-w-0 gridui-u-form--m-0 gridui-u-form--p-0 gridui-u-form--border-0\",\n \"gridui-u-form--[&>legend]:mb-gridui-24 gridui-u-form--[&>legend]:p-0\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Fieldset\n */\n\nimport { fieldsetStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldsetProps = ComponentPropsWithRef<\"fieldset\">;\n\nexport const Fieldset: FC<FieldsetProps> = (props: FieldsetProps) => {\n const { className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(fieldsetStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Focus Invalid Control\n */\n\nimport type { SyntheticEvent } from \"react\";\n\nexport const focusInvalidControl = (\n event: SyntheticEvent<HTMLInputElement | HTMLSelectElement>,\n focus: () => void,\n): void => {\n event.preventDefault();\n const control = event.currentTarget;\n const owner = control.form;\n const firstInvalid = owner && Array.from(owner.elements).find(element => {\n return \"willValidate\" in element && element.willValidate && element.matches(\":invalid\");\n });\n if (!owner || firstInvalid === control) {\n focus();\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ListFieldControl\n * @description List Field Control\n */\n\nimport { focusInvalidControl } from \"../shared/focus-invalid-control\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ListFieldControlProps = Pick<ComponentPropsWithRef<\"select\">, \"name\" | \"form\" | \"disabled\" | \"required\" | \"ref\" | \"children\"> & {\n readonly value: readonly string[];\n readonly onValueChange?: (value: string[]) => void;\n readonly onInvalidFocus: () => void;\n};\n\nexport const ListFieldControl: FC<ListFieldControlProps> = (props: ListFieldControlProps) => {\n const { onValueChange, onInvalidFocus, ...restProps } = props;\n return (<select\n {...restProps}\n multiple\n className=\"gridui-u-form--sr-only\"\n aria-hidden=\"true\"\n tabIndex={-1}\n onChange={event => {\n onValueChange?.(Array.from(event.currentTarget.selectedOptions, option => {\n return option.value;\n }));\n }}\n onInvalid={event => {\n focusInvalidControl(event, onInvalidFocus);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const searchFormStyles = cva(cn(\n \"gridui-search-form\",\n \"gridui-u-form--flex gridui-u-form--flex-wrap gridui-u-form--items-end gridui-u-form--gap-gridui-16\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Search Form\n */\n\nimport { searchFormStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type SearchFormProps = ComponentPropsWithRef<\"form\">;\n\nexport const SearchForm: FC<SearchFormProps> = (props: SearchFormProps) => {\n const { className, ...restProps } = props;\n return (<form\n {...restProps}\n className={cn(searchFormStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use Form Reset\n */\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\ntype ResetElement = HTMLElement & {\n readonly form?: HTMLFormElement | null;\n};\n\nconst formOwner = (element: ResetElement, form?: string): Element | null => {\n if (element.form !== undefined) {\n return element.form;\n }\n return form === undefined ? element.closest(\"form\") : element.ownerDocument.getElementById(form);\n};\n\nexport const useFormReset = (element: RefObject<ResetElement | null>, onReset: () => void, form?: string): void => {\n const latest = useRef(onReset);\n useLayoutEffect(() => {\n latest.current = onReset;\n });\n useEffect(() => {\n const document = element.current?.ownerDocument;\n if (!document) {\n return;\n }\n const pending = new Set<ReturnType<typeof setTimeout>>();\n const reset = (event: Event): void => {\n const control = element.current;\n if (!control || event.target !== formOwner(control, form)) {\n return;\n }\n // Native reset runs after dispatch; React bubbling handlers can cancel it.\n const timer = setTimeout(() => {\n pending.delete(timer);\n const current = element.current;\n if (!event.defaultPrevented && current && event.target === formOwner(current, form)) {\n latest.current();\n }\n }, 0);\n pending.add(timer);\n };\n document.addEventListener(\"reset\", reset, true);\n return () => {\n document.removeEventListener(\"reset\", reset, true);\n pending.forEach(timer => {\n clearTimeout(timer);\n });\n };\n }, [\n element,\n form,\n ]);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use List Field\n */\n\nimport { useFormReset } from \"./use-form-reset\";\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nexport type ListFieldProps = {\n readonly value?: readonly string[] | undefined;\n readonly defaultValue?: readonly string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly disabled?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly form?: string | undefined;\n};\n\nexport const useListField = (props: ListFieldProps, onReset: () => void) => {\n const { value, defaultValue = [], onValueChange, disabled, readOnly, form } = props;\n const [\n local,\n setLocal,\n ] = useState(() => {\n return [...new Set(defaultValue)];\n });\n const selected = [...new Set(value ?? local)];\n const initial = useRef(selected);\n const native = useRef<HTMLSelectElement>(null);\n const control = useRef<HTMLElement>(null);\n const available = () => {\n return !disabled && !readOnly && !control.current?.matches(\":disabled\");\n };\n const update = (next: readonly string[]) => {\n const unique = [...new Set(next)];\n if (selected.length === unique.length && selected.every((entry, index) => {\n return entry === unique[index];\n })) {\n return;\n }\n if (value === undefined) {\n setLocal(unique);\n }\n onValueChange?.(unique);\n };\n const latest = useRef({\n update,\n onReset,\n selected,\n });\n useLayoutEffect(() => {\n latest.current = {\n update,\n onReset,\n selected,\n };\n });\n useFormReset(native, () => {\n flushSync(() => {\n latest.current.update(initial.current);\n latest.current.onReset();\n });\n if (native.current) {\n for (const option of native.current.options) {\n option.selected = latest.current.selected.includes(option.value);\n }\n }\n }, form);\n const change = (next: readonly string[]) => {\n if (available()) {\n update(next);\n }\n };\n return {\n selected,\n native,\n control,\n change,\n available,\n };\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace UseField\n * @description Use Field\n */\n\nimport { useId } from \"react\";\n\nexport type UseFieldOptions = {\n readonly id?: string | undefined;\n readonly invalid?: boolean | undefined;\n readonly description?: boolean | undefined;\n readonly error?: boolean | undefined;\n readonly \"aria-describedby\"?: string | undefined;\n};\nexport const useField = (options: UseFieldOptions = {}) => {\n const generatedId = useId();\n const { id = generatedId, invalid = false, description = false, error = false } = options;\n const descriptionId = `${id}-description`;\n const errorId = `${id}-error`;\n const describedBy = [\n ...new Set([\n ...(options[\"aria-describedby\"]?.split(/\\s+/).filter(Boolean) ?? []),\n ...(description ? [descriptionId] : []),\n ...(invalid && error ? [errorId] : []),\n ]),\n ].join(\" \") || undefined;\n return {\n controlProps: {\n id,\n \"aria-invalid\": invalid,\n \"aria-describedby\": describedBy,\n },\n labelProps: { htmlFor: id },\n descriptionProps: { id: descriptionId },\n errorProps: {\n id: errorId,\n invalid,\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,gBAAgB,OACzB,QACA,YACgB;AAChB,MAAI;AACA,UAAM,OAAO;AAAA,EACjB,SAAS,OAAO;AACZ,QAAI,SAAS;AACT,cAAQ,KAAK;AAAA,IACjB,OAAO;AACH,cAAQ,MAAM,KAAK;AAA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,MACnE;AAAA,IACJ;AAAA,EACJ,GAAG,IAAI;AACP,QAAM,SAAS,CAAC,SAA4B;AACxC,QAAI,UAAU,GAAG;AACb,aAAO,IAAI;AAAA,IACf;AAAA,EACJ;AACA,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;;;AC3EA,SAAS,aAAa;AASf,IAAM,WAAW,CAAC,UAA2B,CAAC,MAAM;AACvD,QAAM,cAAc,MAAM;AAC1B,QAAM,EAAE,KAAK,aAAa,UAAU,OAAO,cAAc,OAAO,QAAQ,MAAM,IAAI;AAClF,QAAM,gBAAgB,GAAG,EAAE;AAC3B,QAAM,UAAU,GAAG,EAAE;AACrB,QAAM,cAAc;AAAA,IAChB,GAAG,oBAAI,IAAI;AAAA,MACP,GAAI,QAAQ,kBAAkB,GAAG,MAAM,KAAK,EAAE,OAAO,OAAO,KAAK,CAAC;AAAA,MAClE,GAAI,cAAc,CAAC,aAAa,IAAI,CAAC;AAAA,MACrC,GAAI,WAAW,QAAQ,CAAC,OAAO,IAAI,CAAC;AAAA,IACxC,CAAC;AAAA,EACL,EAAE,KAAK,GAAG,KAAK;AACf,SAAO;AAAA,IACH,cAAc;AAAA,MACV;AAAA,MACA,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACxB;AAAA,IACA,YAAY,EAAE,SAAS,GAAG;AAAA,IAC1B,kBAAkB,EAAE,IAAI,cAAc;AAAA,IACtC,YAAY;AAAA,MACR,IAAI;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "useLayoutEffect", "useRef"]
|
|
7
7
|
}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* @namespace Shared
|
|
5
5
|
* @description Field Sizing
|
|
6
6
|
*/
|
|
7
|
+
import type { ComponentPropsWithRef } from "react";
|
|
8
|
+
export type FieldSizingOptions = ComponentPropsWithRef<"div"> & {
|
|
9
|
+
readonly grow?: boolean;
|
|
10
|
+
};
|
|
7
11
|
export declare const fieldSizingStyles: (props?: ({
|
|
8
12
|
grow?: boolean | null | undefined;
|
|
9
13
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
package/dist/styles.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! tailwindcss v4.3.
|
|
1
|
+
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer properties;
|
|
3
3
|
@layer theme, base, components, utilities;
|
|
4
4
|
@layer theme {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
@layer utilities {
|
|
10
|
-
.gridui-u-sr-only {
|
|
10
|
+
.gridui-u-form--sr-only {
|
|
11
11
|
position: absolute;
|
|
12
12
|
width: 1px;
|
|
13
13
|
height: 1px;
|
|
@@ -18,70 +18,70 @@
|
|
|
18
18
|
white-space: nowrap;
|
|
19
19
|
border-width: 0;
|
|
20
20
|
}
|
|
21
|
-
.gridui-u-m-0 {
|
|
21
|
+
.gridui-u-form--m-0 {
|
|
22
22
|
margin: 0px;
|
|
23
23
|
}
|
|
24
|
-
.gridui-u-flex {
|
|
24
|
+
.gridui-u-form--flex {
|
|
25
25
|
display: flex;
|
|
26
26
|
}
|
|
27
|
-
.gridui-u-grid {
|
|
27
|
+
.gridui-u-form--grid {
|
|
28
28
|
display: grid;
|
|
29
29
|
}
|
|
30
|
-
.gridui-u-min-w-0 {
|
|
30
|
+
.gridui-u-form--min-w-0 {
|
|
31
31
|
min-width: 0px;
|
|
32
32
|
}
|
|
33
|
-
.gridui-u-flex-1 {
|
|
33
|
+
.gridui-u-form--flex-1 {
|
|
34
34
|
flex: 1;
|
|
35
35
|
}
|
|
36
|
-
.gridui-u-basis-48 {
|
|
36
|
+
.gridui-u-form--basis-48 {
|
|
37
37
|
flex-basis: calc(var(--spacing) * 48);
|
|
38
38
|
}
|
|
39
|
-
.gridui-u-grid-cols-2 {
|
|
39
|
+
.gridui-u-form--grid-cols-2 {
|
|
40
40
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
41
41
|
}
|
|
42
|
-
.gridui-u-flex-wrap {
|
|
42
|
+
.gridui-u-form--flex-wrap {
|
|
43
43
|
flex-wrap: wrap;
|
|
44
44
|
}
|
|
45
|
-
.gridui-u-items-end {
|
|
45
|
+
.gridui-u-form--items-end {
|
|
46
46
|
align-items: flex-end;
|
|
47
47
|
}
|
|
48
|
-
.gridui-u-gap-gridui-8 {
|
|
48
|
+
.gridui-u-form--gap-gridui-8 {
|
|
49
49
|
gap: var(--gridui-space-8);
|
|
50
50
|
}
|
|
51
|
-
.gridui-u-gap-gridui-16 {
|
|
51
|
+
.gridui-u-form--gap-gridui-16 {
|
|
52
52
|
gap: var(--gridui-space-16);
|
|
53
53
|
}
|
|
54
|
-
.gridui-u-border-0 {
|
|
54
|
+
.gridui-u-form--border-0 {
|
|
55
55
|
border-style: var(--tw-border-style);
|
|
56
56
|
border-width: 0px;
|
|
57
57
|
}
|
|
58
|
-
.gridui-u-p-0 {
|
|
58
|
+
.gridui-u-form--p-0 {
|
|
59
59
|
padding: 0px;
|
|
60
60
|
}
|
|
61
|
-
.gridui-u-type-supporting {
|
|
61
|
+
.gridui-u-form--type-supporting {
|
|
62
62
|
font: var(--gridui-type-supporting);
|
|
63
63
|
letter-spacing: normal;
|
|
64
64
|
}
|
|
65
|
-
.gridui-u-wrap-anywhere {
|
|
65
|
+
.gridui-u-form--wrap-anywhere {
|
|
66
66
|
overflow-wrap: anywhere;
|
|
67
67
|
}
|
|
68
|
-
.gridui-u-text-muted {
|
|
68
|
+
.gridui-u-form--text-muted {
|
|
69
69
|
color: var(--gridui-muted);
|
|
70
70
|
}
|
|
71
|
-
.gridui-u-data-\[invalid\=\'true\'\]\:text-danger-foreground[data-invalid='true'] {
|
|
71
|
+
.gridui-u-form--data-\[invalid\=\'true\'\]\:text-danger-foreground[data-invalid='true'] {
|
|
72
72
|
color: var(--gridui-danger-foreground);
|
|
73
73
|
}
|
|
74
|
-
:is(.gridui-u
|
|
74
|
+
:is(.gridui-u-form--\*\:data-\[span\=\'full\'\]\:col-span-full > *)[data-span='full'] {
|
|
75
75
|
grid-column: 1 / -1;
|
|
76
76
|
}
|
|
77
|
-
.gridui-u
|
|
77
|
+
.gridui-u-form--\[\&\>legend\]\:mb-gridui-24 > legend {
|
|
78
78
|
margin-bottom: var(--gridui-space-24);
|
|
79
79
|
}
|
|
80
|
-
.gridui-u
|
|
80
|
+
.gridui-u-form--\[\&\>legend\]\:p-0 > legend {
|
|
81
81
|
padding: 0px;
|
|
82
82
|
}
|
|
83
83
|
@media (max-width:24rem) {
|
|
84
|
-
.gridui-u
|
|
84
|
+
.gridui-u-form--\[\@media\(max-width\:24rem\)\]\:grid-cols-\[1fr\] {
|
|
85
85
|
grid-template-columns: 1fr;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Form
|
|
4
|
+
* @namespace UseField
|
|
5
|
+
* @description Use Field
|
|
6
|
+
*/
|
|
7
|
+
export type UseFieldOptions = {
|
|
8
|
+
readonly id?: string | undefined;
|
|
9
|
+
readonly invalid?: boolean | undefined;
|
|
10
|
+
readonly description?: boolean | undefined;
|
|
11
|
+
readonly error?: boolean | undefined;
|
|
12
|
+
readonly "aria-describedby"?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare const useField: (options?: UseFieldOptions) => {
|
|
15
|
+
controlProps: {
|
|
16
|
+
id: string;
|
|
17
|
+
"aria-invalid": boolean;
|
|
18
|
+
"aria-describedby": string | undefined;
|
|
19
|
+
};
|
|
20
|
+
labelProps: {
|
|
21
|
+
htmlFor: string;
|
|
22
|
+
};
|
|
23
|
+
descriptionProps: {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
errorProps: {
|
|
27
|
+
id: string;
|
|
28
|
+
invalid: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|