jaci-ui 0.3.0 → 0.4.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +48 -0
  3. package/dist/components/calendar/calendar.cjs +377 -0
  4. package/dist/components/calendar/calendar.cjs.map +1 -0
  5. package/dist/components/calendar/calendar.d.cts +56 -0
  6. package/dist/components/calendar/calendar.d.ts +56 -0
  7. package/dist/components/calendar/calendar.js +368 -0
  8. package/dist/components/calendar/calendar.js.map +1 -0
  9. package/dist/components/calendar/index.d.cts +2 -0
  10. package/dist/components/calendar/index.d.ts +2 -0
  11. package/dist/components/combobox/combobox.cjs +13 -1
  12. package/dist/components/combobox/combobox.cjs.map +1 -1
  13. package/dist/components/combobox/combobox.d.cts +7 -2
  14. package/dist/components/combobox/combobox.d.ts +7 -2
  15. package/dist/components/combobox/combobox.js +13 -2
  16. package/dist/components/combobox/combobox.js.map +1 -1
  17. package/dist/components/combobox/index.d.cts +2 -2
  18. package/dist/components/combobox/index.d.ts +2 -2
  19. package/dist/components/controls/input.cjs +26 -5
  20. package/dist/components/controls/input.cjs.map +1 -1
  21. package/dist/components/controls/input.d.cts +5 -2
  22. package/dist/components/controls/input.d.ts +5 -2
  23. package/dist/components/controls/input.js +28 -7
  24. package/dist/components/controls/input.js.map +1 -1
  25. package/dist/components/controls/textarea.cjs +26 -5
  26. package/dist/components/controls/textarea.cjs.map +1 -1
  27. package/dist/components/controls/textarea.d.cts +5 -2
  28. package/dist/components/controls/textarea.d.ts +5 -2
  29. package/dist/components/controls/textarea.js +28 -7
  30. package/dist/components/controls/textarea.js.map +1 -1
  31. package/dist/components/date-picker/date-picker.cjs +9 -9
  32. package/dist/components/date-picker/date-picker.cjs.map +1 -1
  33. package/dist/components/date-picker/date-picker.d.cts +3 -1
  34. package/dist/components/date-picker/date-picker.d.ts +3 -1
  35. package/dist/components/date-picker/date-picker.js +9 -9
  36. package/dist/components/date-picker/date-picker.js.map +1 -1
  37. package/dist/components/date-range-picker/date-range-picker.cjs +589 -0
  38. package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -0
  39. package/dist/components/date-range-picker/date-range-picker.d.cts +134 -0
  40. package/dist/components/date-range-picker/date-range-picker.d.ts +134 -0
  41. package/dist/components/date-range-picker/date-range-picker.js +568 -0
  42. package/dist/components/date-range-picker/date-range-picker.js.map +1 -0
  43. package/dist/components/date-range-picker/index.d.cts +2 -0
  44. package/dist/components/date-range-picker/index.d.ts +2 -0
  45. package/dist/components/field/field.cjs +106 -11
  46. package/dist/components/field/field.cjs.map +1 -1
  47. package/dist/components/field/field.d.cts +22 -4
  48. package/dist/components/field/field.d.ts +22 -4
  49. package/dist/components/field/field.js +107 -13
  50. package/dist/components/field/field.js.map +1 -1
  51. package/dist/components/field/index.d.cts +2 -2
  52. package/dist/components/field/index.d.ts +2 -2
  53. package/dist/components/pin-input/index.d.cts +2 -0
  54. package/dist/components/pin-input/index.d.ts +2 -0
  55. package/dist/components/pin-input/pin-input.cjs +266 -0
  56. package/dist/components/pin-input/pin-input.cjs.map +1 -0
  57. package/dist/components/pin-input/pin-input.d.cts +46 -0
  58. package/dist/components/pin-input/pin-input.d.ts +46 -0
  59. package/dist/components/pin-input/pin-input.js +258 -0
  60. package/dist/components/pin-input/pin-input.js.map +1 -0
  61. package/dist/components/select/index.d.cts +2 -2
  62. package/dist/components/select/index.d.ts +2 -2
  63. package/dist/components/select/select.cjs +80 -3
  64. package/dist/components/select/select.cjs.map +1 -1
  65. package/dist/components/select/select.d.cts +18 -3
  66. package/dist/components/select/select.d.ts +18 -3
  67. package/dist/components/select/select.js +78 -5
  68. package/dist/components/select/select.js.map +1 -1
  69. package/dist/components/tags-input/tags-input.cjs +83 -5
  70. package/dist/components/tags-input/tags-input.cjs.map +1 -1
  71. package/dist/components/tags-input/tags-input.d.cts +3 -0
  72. package/dist/components/tags-input/tags-input.d.ts +3 -0
  73. package/dist/components/tags-input/tags-input.js +83 -5
  74. package/dist/components/tags-input/tags-input.js.map +1 -1
  75. package/dist/components/upload/index.d.cts +2 -2
  76. package/dist/components/upload/index.d.ts +2 -2
  77. package/dist/components/upload/upload.cjs +90 -10
  78. package/dist/components/upload/upload.cjs.map +1 -1
  79. package/dist/components/upload/upload.d.cts +25 -2
  80. package/dist/components/upload/upload.d.ts +25 -2
  81. package/dist/components/upload/upload.js +89 -11
  82. package/dist/components/upload/upload.js.map +1 -1
  83. package/dist/index.cjs +52 -1
  84. package/dist/index.d.cts +11 -5
  85. package/dist/index.d.ts +11 -5
  86. package/dist/index.js +9 -6
  87. package/dist/styled-system/recipes/calendar.cjs +43 -0
  88. package/dist/styled-system/recipes/calendar.cjs.map +1 -0
  89. package/dist/styled-system/recipes/calendar.js +43 -0
  90. package/dist/styled-system/recipes/calendar.js.map +1 -0
  91. package/dist/styled-system/recipes/combobox.cjs +1 -0
  92. package/dist/styled-system/recipes/combobox.cjs.map +1 -1
  93. package/dist/styled-system/recipes/combobox.js +1 -0
  94. package/dist/styled-system/recipes/combobox.js.map +1 -1
  95. package/dist/styled-system/recipes/date-range-picker.cjs +52 -0
  96. package/dist/styled-system/recipes/date-range-picker.cjs.map +1 -0
  97. package/dist/styled-system/recipes/date-range-picker.js +52 -0
  98. package/dist/styled-system/recipes/date-range-picker.js.map +1 -0
  99. package/dist/styled-system/recipes/pin-input.cjs +39 -0
  100. package/dist/styled-system/recipes/pin-input.cjs.map +1 -0
  101. package/dist/styled-system/recipes/pin-input.js +39 -0
  102. package/dist/styled-system/recipes/pin-input.js.map +1 -0
  103. package/dist/styled-system/recipes/select.cjs +5 -1
  104. package/dist/styled-system/recipes/select.cjs.map +1 -1
  105. package/dist/styled-system/recipes/select.js +5 -1
  106. package/dist/styled-system/recipes/select.js.map +1 -1
  107. package/dist/styled-system/recipes/upload.cjs +2 -0
  108. package/dist/styled-system/recipes/upload.cjs.map +1 -1
  109. package/dist/styled-system/recipes/upload.js +2 -0
  110. package/dist/styled-system/recipes/upload.js.map +1 -1
  111. package/dist/styles.css +745 -81
  112. package/package.json +3 -2
@@ -0,0 +1,2 @@
1
+ import { DateRange, DateRangePicker, DateRangePickerCalendar, DateRangePickerCalendarProps, DateRangePickerClear, DateRangePickerClearProps, DateRangePickerClose, DateRangePickerCloseProps, DateRangePickerControl, DateRangePickerControlProps, DateRangePickerDay, DateRangePickerDayProps, DateRangePickerEndInput, DateRangePickerHeader, DateRangePickerHeaderProps, DateRangePickerInputProps, DateRangePickerLabel, DateRangePickerLabelProps, DateRangePickerMonthSelect, DateRangePickerMonthSelectProps, DateRangePickerNavigationProps, DateRangePickerNext, DateRangePickerPopup, DateRangePickerPopupProps, DateRangePickerPortal, DateRangePickerPortalProps, DateRangePickerPositioner, DateRangePickerPositionerProps, DateRangePickerPreview, DateRangePickerPreviewProps, DateRangePickerPrevious, DateRangePickerRoot, DateRangePickerRootProps, DateRangePickerStartInput, DateRangePickerTrigger, DateRangePickerTriggerProps, DateRangePickerValue, DateRangePickerValueProps, DateRangePickerYearRange, DateRangePickerYearSelect, DateRangePickerYearSelectProps } from "./date-range-picker.js";
2
+ export { type DateRange, DateRangePicker, DateRangePickerCalendar, type DateRangePickerCalendarProps, DateRangePickerClear, type DateRangePickerClearProps, DateRangePickerClose, type DateRangePickerCloseProps, DateRangePickerControl, type DateRangePickerControlProps, DateRangePickerDay, type DateRangePickerDayProps, DateRangePickerEndInput, DateRangePickerHeader, type DateRangePickerHeaderProps, type DateRangePickerInputProps, DateRangePickerLabel, type DateRangePickerLabelProps, DateRangePickerMonthSelect, type DateRangePickerMonthSelectProps, type DateRangePickerNavigationProps, DateRangePickerNext, DateRangePickerPopup, type DateRangePickerPopupProps, DateRangePickerPortal, type DateRangePickerPortalProps, DateRangePickerPositioner, type DateRangePickerPositionerProps, DateRangePickerPreview, type DateRangePickerPreviewProps, DateRangePickerPrevious, DateRangePickerRoot, type DateRangePickerRootProps, DateRangePickerStartInput, DateRangePickerTrigger, type DateRangePickerTriggerProps, DateRangePickerValue, type DateRangePickerValueProps, type DateRangePickerYearRange, DateRangePickerYearSelect, type DateRangePickerYearSelectProps };
@@ -7,10 +7,18 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let _base_ui_react_field = require("@base-ui/react/field");
8
8
  //#region src/components/field/field.tsx
9
9
  const FieldContext = (0, react.createContext)({
10
+ controlId: void 0,
11
+ descriptionId: void 0,
12
+ dirty: false,
13
+ errorId: void 0,
10
14
  errors: [],
11
15
  insideField: false,
12
16
  invalid: false,
13
- name: void 0
17
+ labelId: void 0,
18
+ name: void 0,
19
+ pending: false,
20
+ touched: false,
21
+ valid: null
14
22
  });
15
23
  function normalizeErrors(errors) {
16
24
  if (errors === void 0 || errors === null || errors === false) return [];
@@ -20,51 +28,127 @@ function renderErrors(errors) {
20
28
  if (errors.length <= 1) return errors[0];
21
29
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: errors.map((error, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: error }, typeof error === "string" ? error : index)) });
22
30
  }
23
- const Field = (0, react.forwardRef)(function Field({ actionsRef, children, className, dirty, disabled = false, errors: directErrors, invalid: invalidProp = false, name, touched, validate, validationDebounceTime, validationMode, ...props }, ref) {
31
+ const FieldRoot = (0, react.forwardRef)(function Field({ actionsRef, children, className, dirty, disabled = false, errors: directErrors, invalid: invalidProp = false, name, pending: pendingProp = false, touched, validate, validationDebounceTime, validationMode, ...props }, ref) {
32
+ const generatedId = (0, react.useId)();
33
+ const controlId = `${generatedId}-control`;
34
+ const labelId = `${generatedId}-label`;
35
+ const descriptionId = `${generatedId}-description`;
36
+ const errorId = `${generatedId}-error`;
37
+ const [pendingValidation, setPendingValidation] = (0, react.useState)(false);
38
+ const [validationErrors, setValidationErrors] = (0, react.useState)([]);
39
+ const [validationValid, setValidationValid] = (0, react.useState)(null);
40
+ const validationSequence = (0, react.useRef)(0);
24
41
  const { errors: formErrors } = (0, react.useContext)(require_form.JaciFormContext);
25
42
  const formError = name ? formErrors[name] : void 0;
26
- const errors = directErrors === void 0 ? normalizeErrors(formError) : normalizeErrors(directErrors);
43
+ const externalErrors = directErrors === void 0 ? normalizeErrors(formError) : normalizeErrors(directErrors);
44
+ const errors = directErrors !== void 0 || formError !== void 0 ? externalErrors : validationErrors;
27
45
  const invalid = invalidProp || errors.length > 0;
46
+ const pending = pendingProp || pendingValidation;
47
+ const wrappedValidate = (0, react.useCallback)((value, formValues) => {
48
+ const sequence = ++validationSequence.current;
49
+ if (!validate) return null;
50
+ const result = validate(value, formValues);
51
+ if (!result || typeof result !== "object" || !("then" in result)) {
52
+ const resultErrors = normalizeErrors(result);
53
+ setValidationErrors(resultErrors);
54
+ setValidationValid(resultErrors.length === 0);
55
+ setPendingValidation(false);
56
+ return result;
57
+ }
58
+ setValidationErrors([]);
59
+ setValidationValid(null);
60
+ setPendingValidation(true);
61
+ return Promise.resolve(result).then((validationResult) => {
62
+ if (sequence !== validationSequence.current) return null;
63
+ const resultErrors = normalizeErrors(validationResult);
64
+ setValidationErrors(resultErrors);
65
+ setValidationValid(resultErrors.length === 0);
66
+ return validationResult;
67
+ }).finally(() => {
68
+ if (sequence === validationSequence.current) setPendingValidation(false);
69
+ });
70
+ }, [validate]);
28
71
  const styles = require_field.field({ invalid });
29
72
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldContext.Provider, {
30
73
  value: {
74
+ controlId,
75
+ descriptionId,
76
+ dirty: dirty ?? false,
77
+ errorId,
31
78
  errors,
32
79
  insideField: true,
33
80
  invalid,
34
- name
81
+ labelId,
82
+ name,
83
+ pending,
84
+ touched: touched ?? false,
85
+ valid: invalid ? false : validationValid
35
86
  },
36
87
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_field.Field.Root, {
37
88
  ...props,
38
89
  ref,
39
90
  actionsRef,
40
91
  className: require_cx.cx(styles.root, className),
92
+ "aria-busy": pending || void 0,
93
+ "data-dirty": dirty || void 0,
41
94
  "data-invalid": invalid || void 0,
42
95
  "data-jaci-component": "field",
96
+ "data-pending": pending || void 0,
43
97
  "data-slot": "field",
98
+ "data-touched": touched || void 0,
44
99
  disabled,
45
100
  dirty,
46
101
  invalid,
47
102
  name,
48
103
  touched,
49
- validate,
104
+ ...validate ? { validate: wrappedValidate } : {},
50
105
  validationDebounceTime,
51
106
  validationMode,
52
107
  children
53
108
  })
54
109
  });
55
110
  });
111
+ const FieldControl = (0, react.forwardRef)(function FieldControl({ "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, className, id, ...props }, ref) {
112
+ const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } = (0, react.useContext)(FieldContext);
113
+ const describedBy = [
114
+ ariaDescribedBy,
115
+ descriptionId,
116
+ invalid ? errorId : void 0
117
+ ].filter(Boolean).join(" ") || void 0;
118
+ const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(" ") || void 0;
119
+ const controlProps = {
120
+ ...props,
121
+ "aria-busy": pending || void 0,
122
+ "aria-describedby": describedBy,
123
+ "aria-errormessage": ariaErrorMessage ?? (invalid ? errorId : void 0),
124
+ "aria-invalid": ariaInvalid ?? (invalid || void 0),
125
+ "aria-labelledby": labelledBy,
126
+ className,
127
+ "data-pending": pending || void 0,
128
+ id: id ?? controlId
129
+ };
130
+ if (!insideField) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_field.Field.Control, {
131
+ ...controlProps,
132
+ ref
133
+ });
134
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_field.Field.Control, {
135
+ ...controlProps,
136
+ ref
137
+ });
138
+ });
56
139
  const FieldLabel = (0, react.forwardRef)(function FieldLabel({ children, className, htmlFor, ...props }, ref) {
57
- const { insideField, invalid } = (0, react.useContext)(FieldContext);
140
+ const { controlId, insideField, invalid, labelId } = (0, react.useContext)(FieldContext);
58
141
  const labelProps = {
59
142
  ...props,
60
143
  className: require_cx.cx(require_field.field({ invalid }).label, className),
61
144
  "data-slot": "field-label",
62
- htmlFor
145
+ htmlFor: htmlFor ?? controlId,
146
+ id: props.id ?? labelId
63
147
  };
64
148
  if (!insideField) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
65
149
  ...labelProps,
66
150
  ref,
67
- htmlFor,
151
+ htmlFor: htmlFor ?? controlId,
68
152
  children
69
153
  });
70
154
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_field.Field.Label, {
@@ -74,11 +158,12 @@ const FieldLabel = (0, react.forwardRef)(function FieldLabel({ children, classNa
74
158
  });
75
159
  });
76
160
  const FieldDescription = (0, react.forwardRef)(function FieldDescription({ className, ...props }, ref) {
77
- const { insideField, invalid } = (0, react.useContext)(FieldContext);
161
+ const { descriptionId, insideField, invalid } = (0, react.useContext)(FieldContext);
78
162
  const descriptionProps = {
79
163
  ...props,
80
164
  className: require_cx.cx(require_field.field({ invalid }).description, className),
81
- "data-slot": "field-description"
165
+ "data-slot": "field-description",
166
+ id: props.id ?? descriptionId
82
167
  };
83
168
  if (!insideField) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
84
169
  ...descriptionProps,
@@ -90,7 +175,7 @@ const FieldDescription = (0, react.forwardRef)(function FieldDescription({ class
90
175
  });
91
176
  });
92
177
  const FieldError = (0, react.forwardRef)(function FieldError({ children, className, match, ...props }, ref) {
93
- const { errors, insideField, invalid } = (0, react.useContext)(FieldContext);
178
+ const { errorId, errors, insideField, invalid } = (0, react.useContext)(FieldContext);
94
179
  const content = children ?? renderErrors(errors);
95
180
  if (!insideField) {
96
181
  if (content === void 0 || content === null || content === false) return null;
@@ -99,6 +184,7 @@ const FieldError = (0, react.forwardRef)(function FieldError({ children, classNa
99
184
  ref,
100
185
  className: require_cx.cx(require_field.field({ invalid }).error, className),
101
186
  "data-slot": "field-error",
187
+ id: props.id ?? errorId,
102
188
  role: "alert",
103
189
  children: content
104
190
  });
@@ -108,6 +194,7 @@ const FieldError = (0, react.forwardRef)(function FieldError({ children, classNa
108
194
  ref,
109
195
  className: require_cx.cx(require_field.field({ invalid }).error, className),
110
196
  "data-slot": "field-error",
197
+ id: props.id ?? errorId,
111
198
  match: match ?? (invalid ? true : void 0),
112
199
  render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {}),
113
200
  role: "alert",
@@ -117,8 +204,16 @@ const FieldError = (0, react.forwardRef)(function FieldError({ children, classNa
117
204
  function useFieldState() {
118
205
  return (0, react.useContext)(FieldContext);
119
206
  }
207
+ const Field = Object.assign(FieldRoot, {
208
+ Root: FieldRoot,
209
+ Control: FieldControl,
210
+ Label: FieldLabel,
211
+ Description: FieldDescription,
212
+ Error: FieldError
213
+ });
120
214
  //#endregion
121
215
  exports.Field = Field;
216
+ exports.FieldControl = FieldControl;
122
217
  exports.FieldDescription = FieldDescription;
123
218
  exports.FieldError = FieldError;
124
219
  exports.FieldLabel = FieldLabel;
@@ -1 +1 @@
1
- {"version":3,"file":"field.cjs","names":["JaciFormContext","field","BaseField","cx"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useContext } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n name: string | undefined;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n errors: [],\n insideField: false,\n invalid: false,\n name: undefined,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor: string;\n}\n\nexport const Field = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const errors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const invalid = invalidProp || errors.length > 0;\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider value={{ errors, insideField: true, invalid, name }}>\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-slot=\"field\"\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n validate={validate}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { insideField, invalid } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,gBAAA,GAAA,MAAA,cAAA,CAAgD;CACpD,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,MAAM,KAAA;AACR,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UAAqD,MAAU,GAAtD,OAAO,UAAU,WAAW,QAAQ,KAAkB,CAChE,EACC,CAAA;AAER;AA6BA,MAAa,SAAA,GAAA,MAAA,WAAA,CAA+C,SAAS,MACnE,EACE,YACA,UACA,WACA,OACA,WAAW,OACX,QAAQ,cACR,SAAS,cAAc,OACvB,MACA,SACA,UACA,wBACA,gBACA,GAAG,SAEL,KACA;CACA,MAAM,EAAE,QAAQ,gBAAA,GAAA,MAAA,WAAA,CAA0BA,aAAAA,eAAe;CACzD,MAAM,YAAY,OAAO,WAAW,QAAQ,KAAA;CAC5C,MAAM,SACJ,iBAAiB,KAAA,IAAY,gBAAgB,SAAS,IAAI,gBAAgB,YAAY;CACxF,MAAM,UAAU,eAAe,OAAO,SAAS;CAC/C,MAAM,SAASC,cAAAA,MAAM,EAAE,QAAQ,CAAC;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAa,UAAd;EAAuB,OAAO;GAAE;GAAQ,aAAa;GAAM;GAAS;EAAK;YACvE,iBAAA,GAAA,kBAAA,IAAA,CAACC,q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,GAAA,MAAA,WAAA,CAA+D,SAAS,WACnF,EAAE,UAAU,WAAW,OAAO,GAAG,SACjC,KACA;CACA,MAAM,EAAE,QAAQ,aAAa,aAAA,GAAA,MAAA,WAAA,CAAuB,YAAY;CAChE,MAAM,UAAU,YAAY,aAAa,MAAM;CAE/C,IAAI,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GACE,GAAI;GACC;GACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,MAAK;aAEJ;EACA,CAAA;CAEP;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,QAAA,GAAA,MAAA,WAAA,CAAkB,YAAY;AAChC"}
1
+ {"version":3,"file":"field.cjs","names":["JaciFormContext","field","BaseField","cx"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: F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BAAAA,MAAU,aAAX;EAAuB,GAAI;EAAuB;CAAM,CAAA;AACjE,CACF;AAOA,MAAa,cAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,WACnF,EAAE,UAAU,WAAW,OAAO,GAAG,SACjC,KACA;CACA,MAAM,EAAE,SAAS,QAAQ,aAAa,aAAA,GAAA,MAAA,WAAA,CAAuB,YAAY;CACzE,MAAM,UAAU,YAAY,aAAa,MAAM;CAE/C,IAAI,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GACE,GAAI;GACC;GACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,IAAI,MAAM,MAAM;GAChB,MAAK;aAEJ;EACA,CAAA;CAEP;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,QAAA,GAAA,MAAA,WAAA,CAAkB,YAAY;AAChC;AAEA,MAAa,QAAQ,OAAO,OAAO,WAAW;CAC5C,MAAM;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
@@ -1,12 +1,20 @@
1
1
  import { ComponentPropsWithoutRef, ReactNode } from "react";
2
- import { FieldRoot } from "@base-ui/react/field";
2
+ import { Field, FieldRoot } from "@base-ui/react/field";
3
3
  //#region src/components/field/field.d.ts
4
4
  type FieldValidationMode = "onSubmit" | "onBlur" | "onChange";
5
5
  interface FieldContextValue {
6
+ controlId: string | undefined;
7
+ descriptionId: string | undefined;
8
+ dirty: boolean;
9
+ errorId: string | undefined;
6
10
  errors: ReactNode[];
7
11
  insideField: boolean;
8
12
  invalid: boolean;
13
+ labelId: string | undefined;
9
14
  name: string | undefined;
15
+ pending: boolean;
16
+ touched: boolean;
17
+ valid: boolean | null;
10
18
  }
11
19
  interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
12
20
  /** Marks the field invalid when an external validator owns its state. */
@@ -26,14 +34,17 @@ interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
26
34
  /** Controlled dirty/touched state for integrations with external form state. */
27
35
  dirty?: boolean;
28
36
  touched?: boolean;
37
+ /** Marks the field as awaiting asynchronous validation. */
38
+ pending?: boolean;
29
39
  /** Imperative field validation actions. */
30
40
  actionsRef?: FieldRoot.Props["actionsRef"];
31
41
  children?: ReactNode;
32
42
  }
33
43
  interface FieldLabelProps extends ComponentPropsWithoutRef<"label"> {
34
- htmlFor: string;
44
+ htmlFor?: string;
35
45
  }
36
- declare const Field$1: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
46
+ interface FieldControlProps extends ComponentPropsWithoutRef<typeof Field.Control> {}
47
+ declare const FieldControl: import("react").ForwardRefExoticComponent<FieldControlProps & import("react").RefAttributes<HTMLElement>>;
37
48
  declare const FieldLabel: import("react").ForwardRefExoticComponent<FieldLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
38
49
  declare const FieldDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
39
50
  interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"> {
@@ -42,6 +53,13 @@ interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"
42
53
  }
43
54
  declare const FieldError: import("react").ForwardRefExoticComponent<FieldErrorProps & import("react").RefAttributes<HTMLParagraphElement>>;
44
55
  declare function useFieldState(): FieldContextValue;
56
+ declare const Field$1: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>> & {
57
+ Root: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
58
+ Control: import("react").ForwardRefExoticComponent<FieldControlProps & import("react").RefAttributes<HTMLElement>>;
59
+ Label: import("react").ForwardRefExoticComponent<FieldLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
60
+ Description: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
61
+ Error: import("react").ForwardRefExoticComponent<FieldErrorProps & import("react").RefAttributes<HTMLParagraphElement>>;
62
+ };
45
63
  //#endregion
46
- export { Field$1 as Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState };
64
+ export { Field$1 as Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState };
47
65
  //# sourceMappingURL=field.d.cts.map
@@ -1,12 +1,20 @@
1
1
  import { ComponentPropsWithoutRef, ReactNode } from "react";
2
- import { FieldRoot } from "@base-ui/react/field";
2
+ import { Field, FieldRoot } from "@base-ui/react/field";
3
3
  //#region src/components/field/field.d.ts
4
4
  type FieldValidationMode = "onSubmit" | "onBlur" | "onChange";
5
5
  interface FieldContextValue {
6
+ controlId: string | undefined;
7
+ descriptionId: string | undefined;
8
+ dirty: boolean;
9
+ errorId: string | undefined;
6
10
  errors: ReactNode[];
7
11
  insideField: boolean;
8
12
  invalid: boolean;
13
+ labelId: string | undefined;
9
14
  name: string | undefined;
15
+ pending: boolean;
16
+ touched: boolean;
17
+ valid: boolean | null;
10
18
  }
11
19
  interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
12
20
  /** Marks the field invalid when an external validator owns its state. */
@@ -26,14 +34,17 @@ interface FieldProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
26
34
  /** Controlled dirty/touched state for integrations with external form state. */
27
35
  dirty?: boolean;
28
36
  touched?: boolean;
37
+ /** Marks the field as awaiting asynchronous validation. */
38
+ pending?: boolean;
29
39
  /** Imperative field validation actions. */
30
40
  actionsRef?: FieldRoot.Props["actionsRef"];
31
41
  children?: ReactNode;
32
42
  }
33
43
  interface FieldLabelProps extends ComponentPropsWithoutRef<"label"> {
34
- htmlFor: string;
44
+ htmlFor?: string;
35
45
  }
36
- declare const Field$1: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
46
+ interface FieldControlProps extends ComponentPropsWithoutRef<typeof Field.Control> {}
47
+ declare const FieldControl: import("react").ForwardRefExoticComponent<FieldControlProps & import("react").RefAttributes<HTMLElement>>;
37
48
  declare const FieldLabel: import("react").ForwardRefExoticComponent<FieldLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
38
49
  declare const FieldDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
39
50
  interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"> {
@@ -42,6 +53,13 @@ interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"
42
53
  }
43
54
  declare const FieldError: import("react").ForwardRefExoticComponent<FieldErrorProps & import("react").RefAttributes<HTMLParagraphElement>>;
44
55
  declare function useFieldState(): FieldContextValue;
56
+ declare const Field$1: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>> & {
57
+ Root: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
58
+ Control: import("react").ForwardRefExoticComponent<FieldControlProps & import("react").RefAttributes<HTMLElement>>;
59
+ Label: import("react").ForwardRefExoticComponent<FieldLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
60
+ Description: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
61
+ Error: import("react").ForwardRefExoticComponent<FieldErrorProps & import("react").RefAttributes<HTMLParagraphElement>>;
62
+ };
45
63
  //#endregion
46
- export { Field$1 as Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState };
64
+ export { Field$1 as Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState };
47
65
  //# sourceMappingURL=field.d.ts.map
@@ -2,15 +2,23 @@
2
2
  import { cx } from "../../styled-system/css/cx.js";
3
3
  import { field } from "../../styled-system/recipes/field.js";
4
4
  import { JaciFormContext } from "../form/form.js";
5
- import { createContext, forwardRef, useContext } from "react";
5
+ import { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { Field } from "@base-ui/react/field";
8
8
  //#region src/components/field/field.tsx
9
9
  const FieldContext = createContext({
10
+ controlId: void 0,
11
+ descriptionId: void 0,
12
+ dirty: false,
13
+ errorId: void 0,
10
14
  errors: [],
11
15
  insideField: false,
12
16
  invalid: false,
13
- name: void 0
17
+ labelId: void 0,
18
+ name: void 0,
19
+ pending: false,
20
+ touched: false,
21
+ valid: null
14
22
  });
15
23
  function normalizeErrors(errors) {
16
24
  if (errors === void 0 || errors === null || errors === false) return [];
@@ -20,51 +28,127 @@ function renderErrors(errors) {
20
28
  if (errors.length <= 1) return errors[0];
21
29
  return /* @__PURE__ */ jsx("ul", { children: errors.map((error, index) => /* @__PURE__ */ jsx("li", { children: error }, typeof error === "string" ? error : index)) });
22
30
  }
23
- const Field$1 = forwardRef(function Field$2({ actionsRef, children, className, dirty, disabled = false, errors: directErrors, invalid: invalidProp = false, name, touched, validate, validationDebounceTime, validationMode, ...props }, ref) {
31
+ const FieldRoot$1 = forwardRef(function Field$2({ actionsRef, children, className, dirty, disabled = false, errors: directErrors, invalid: invalidProp = false, name, pending: pendingProp = false, touched, validate, validationDebounceTime, validationMode, ...props }, ref) {
32
+ const generatedId = useId();
33
+ const controlId = `${generatedId}-control`;
34
+ const labelId = `${generatedId}-label`;
35
+ const descriptionId = `${generatedId}-description`;
36
+ const errorId = `${generatedId}-error`;
37
+ const [pendingValidation, setPendingValidation] = useState(false);
38
+ const [validationErrors, setValidationErrors] = useState([]);
39
+ const [validationValid, setValidationValid] = useState(null);
40
+ const validationSequence = useRef(0);
24
41
  const { errors: formErrors } = useContext(JaciFormContext);
25
42
  const formError = name ? formErrors[name] : void 0;
26
- const errors = directErrors === void 0 ? normalizeErrors(formError) : normalizeErrors(directErrors);
43
+ const externalErrors = directErrors === void 0 ? normalizeErrors(formError) : normalizeErrors(directErrors);
44
+ const errors = directErrors !== void 0 || formError !== void 0 ? externalErrors : validationErrors;
27
45
  const invalid = invalidProp || errors.length > 0;
46
+ const pending = pendingProp || pendingValidation;
47
+ const wrappedValidate = useCallback((value, formValues) => {
48
+ const sequence = ++validationSequence.current;
49
+ if (!validate) return null;
50
+ const result = validate(value, formValues);
51
+ if (!result || typeof result !== "object" || !("then" in result)) {
52
+ const resultErrors = normalizeErrors(result);
53
+ setValidationErrors(resultErrors);
54
+ setValidationValid(resultErrors.length === 0);
55
+ setPendingValidation(false);
56
+ return result;
57
+ }
58
+ setValidationErrors([]);
59
+ setValidationValid(null);
60
+ setPendingValidation(true);
61
+ return Promise.resolve(result).then((validationResult) => {
62
+ if (sequence !== validationSequence.current) return null;
63
+ const resultErrors = normalizeErrors(validationResult);
64
+ setValidationErrors(resultErrors);
65
+ setValidationValid(resultErrors.length === 0);
66
+ return validationResult;
67
+ }).finally(() => {
68
+ if (sequence === validationSequence.current) setPendingValidation(false);
69
+ });
70
+ }, [validate]);
28
71
  const styles = field({ invalid });
29
72
  return /* @__PURE__ */ jsx(FieldContext.Provider, {
30
73
  value: {
74
+ controlId,
75
+ descriptionId,
76
+ dirty: dirty ?? false,
77
+ errorId,
31
78
  errors,
32
79
  insideField: true,
33
80
  invalid,
34
- name
81
+ labelId,
82
+ name,
83
+ pending,
84
+ touched: touched ?? false,
85
+ valid: invalid ? false : validationValid
35
86
  },
36
87
  children: /* @__PURE__ */ jsx(Field.Root, {
37
88
  ...props,
38
89
  ref,
39
90
  actionsRef,
40
91
  className: cx(styles.root, className),
92
+ "aria-busy": pending || void 0,
93
+ "data-dirty": dirty || void 0,
41
94
  "data-invalid": invalid || void 0,
42
95
  "data-jaci-component": "field",
96
+ "data-pending": pending || void 0,
43
97
  "data-slot": "field",
98
+ "data-touched": touched || void 0,
44
99
  disabled,
45
100
  dirty,
46
101
  invalid,
47
102
  name,
48
103
  touched,
49
- validate,
104
+ ...validate ? { validate: wrappedValidate } : {},
50
105
  validationDebounceTime,
51
106
  validationMode,
52
107
  children
53
108
  })
54
109
  });
55
110
  });
111
+ const FieldControl = forwardRef(function FieldControl({ "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, className, id, ...props }, ref) {
112
+ const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } = useContext(FieldContext);
113
+ const describedBy = [
114
+ ariaDescribedBy,
115
+ descriptionId,
116
+ invalid ? errorId : void 0
117
+ ].filter(Boolean).join(" ") || void 0;
118
+ const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(" ") || void 0;
119
+ const controlProps = {
120
+ ...props,
121
+ "aria-busy": pending || void 0,
122
+ "aria-describedby": describedBy,
123
+ "aria-errormessage": ariaErrorMessage ?? (invalid ? errorId : void 0),
124
+ "aria-invalid": ariaInvalid ?? (invalid || void 0),
125
+ "aria-labelledby": labelledBy,
126
+ className,
127
+ "data-pending": pending || void 0,
128
+ id: id ?? controlId
129
+ };
130
+ if (!insideField) return /* @__PURE__ */ jsx(Field.Control, {
131
+ ...controlProps,
132
+ ref
133
+ });
134
+ return /* @__PURE__ */ jsx(Field.Control, {
135
+ ...controlProps,
136
+ ref
137
+ });
138
+ });
56
139
  const FieldLabel = forwardRef(function FieldLabel({ children, className, htmlFor, ...props }, ref) {
57
- const { insideField, invalid } = useContext(FieldContext);
140
+ const { controlId, insideField, invalid, labelId } = useContext(FieldContext);
58
141
  const labelProps = {
59
142
  ...props,
60
143
  className: cx(field({ invalid }).label, className),
61
144
  "data-slot": "field-label",
62
- htmlFor
145
+ htmlFor: htmlFor ?? controlId,
146
+ id: props.id ?? labelId
63
147
  };
64
148
  if (!insideField) return /* @__PURE__ */ jsx("label", {
65
149
  ...labelProps,
66
150
  ref,
67
- htmlFor,
151
+ htmlFor: htmlFor ?? controlId,
68
152
  children
69
153
  });
70
154
  return /* @__PURE__ */ jsx(Field.Label, {
@@ -74,11 +158,12 @@ const FieldLabel = forwardRef(function FieldLabel({ children, className, htmlFor
74
158
  });
75
159
  });
76
160
  const FieldDescription = forwardRef(function FieldDescription({ className, ...props }, ref) {
77
- const { insideField, invalid } = useContext(FieldContext);
161
+ const { descriptionId, insideField, invalid } = useContext(FieldContext);
78
162
  const descriptionProps = {
79
163
  ...props,
80
164
  className: cx(field({ invalid }).description, className),
81
- "data-slot": "field-description"
165
+ "data-slot": "field-description",
166
+ id: props.id ?? descriptionId
82
167
  };
83
168
  if (!insideField) return /* @__PURE__ */ jsx("p", {
84
169
  ...descriptionProps,
@@ -90,7 +175,7 @@ const FieldDescription = forwardRef(function FieldDescription({ className, ...pr
90
175
  });
91
176
  });
92
177
  const FieldError = forwardRef(function FieldError({ children, className, match, ...props }, ref) {
93
- const { errors, insideField, invalid } = useContext(FieldContext);
178
+ const { errorId, errors, insideField, invalid } = useContext(FieldContext);
94
179
  const content = children ?? renderErrors(errors);
95
180
  if (!insideField) {
96
181
  if (content === void 0 || content === null || content === false) return null;
@@ -99,6 +184,7 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
99
184
  ref,
100
185
  className: cx(field({ invalid }).error, className),
101
186
  "data-slot": "field-error",
187
+ id: props.id ?? errorId,
102
188
  role: "alert",
103
189
  children: content
104
190
  });
@@ -108,6 +194,7 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
108
194
  ref,
109
195
  className: cx(field({ invalid }).error, className),
110
196
  "data-slot": "field-error",
197
+ id: props.id ?? errorId,
111
198
  match: match ?? (invalid ? true : void 0),
112
199
  render: /* @__PURE__ */ jsx("p", {}),
113
200
  role: "alert",
@@ -117,7 +204,14 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
117
204
  function useFieldState() {
118
205
  return useContext(FieldContext);
119
206
  }
207
+ const Field$1 = Object.assign(FieldRoot$1, {
208
+ Root: FieldRoot$1,
209
+ Control: FieldControl,
210
+ Label: FieldLabel,
211
+ Description: FieldDescription,
212
+ Error: FieldError
213
+ });
120
214
  //#endregion
121
- export { Field$1 as Field, FieldDescription, FieldError, FieldLabel, useFieldState };
215
+ export { Field$1 as Field, FieldControl, FieldDescription, FieldError, FieldLabel, useFieldState };
122
216
 
123
217
  //# sourceMappingURL=field.js.map