@page-speed/forms 0.6.7 → 0.6.9

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 CHANGED
@@ -129,6 +129,40 @@ import { Form } from "@page-speed/forms";
129
129
  />;
130
130
  ```
131
131
 
132
+ ### `FormEngine` Defaults + Wrapper Setup
133
+
134
+ `FormEngine` supports both direct props and a wrapper setup object. This is useful
135
+ for block/component libraries that want to provide local default fields and styles.
136
+
137
+ ```tsx
138
+ import * as React from "react";
139
+ import {
140
+ FormEngine,
141
+ type FormEngineSetup,
142
+ type FormFieldConfig,
143
+ type FormEngineStyleRules,
144
+ } from "@page-speed/forms/integration";
145
+
146
+ const defaultFields: FormFieldConfig[] = [
147
+ { name: "email", type: "email", label: "Email", required: true },
148
+ ];
149
+
150
+ const defaultStyleRules: FormEngineStyleRules = {
151
+ formClassName: "space-y-6",
152
+ };
153
+
154
+ const setup: FormEngineSetup = {
155
+ api: { endpoint: "/api/contact", method: "post" },
156
+ formLayoutSettings: { formLayout: "standard" },
157
+ };
158
+
159
+ <FormEngine
160
+ formEngineSetup={setup}
161
+ defaultFields={defaultFields}
162
+ defaultStyleRules={defaultStyleRules}
163
+ />;
164
+ ```
165
+
132
166
  ## Package Entry Points
133
167
 
134
168
  ### Main
@@ -288,8 +288,10 @@ function CheckboxGroup({
288
288
  const maxReached = Boolean(maxSelections && countableValue >= maxSelections);
289
289
  const containerClass = React19.useMemo(() => {
290
290
  return cn(
291
- "w-full gap-3 grid grid-cols-1 border-0 m-0 p-0 min-w-0",
291
+ "w-full grid grid-cols-1 border-0 m-0 p-0 min-w-0",
292
292
  (layout === "grid" || layout === "inline") && "md:grid-cols-2",
293
+ layout === "grid" && "gap-3",
294
+ layout === "inline" && "gap-0",
293
295
  className
294
296
  );
295
297
  }, [layout, className]);
@@ -446,14 +448,7 @@ function Radio({
446
448
  return options.some((option) => option.description);
447
449
  }, [options]);
448
450
  const groupDescriptionId = description ? `${name}-description` : void 0;
449
- return /* @__PURE__ */ React19.createElement("div", { className: cn("w-full", className), "data-invalid": error || void 0 }, (label || description) && /* @__PURE__ */ React19.createElement("div", { className: "mb-3 space-y-1" }, label && /* @__PURE__ */ React19.createElement("div", { className: "text-base font-medium leading-none" }, label), description && /* @__PURE__ */ React19.createElement(
450
- FieldDescription,
451
- {
452
- id: groupDescriptionId,
453
- className: "leading-snug"
454
- },
455
- description
456
- )), /* @__PURE__ */ React19.createElement(
451
+ return /* @__PURE__ */ React19.createElement("div", { className: cn("w-full", className), "data-invalid": error || void 0 }, (label || description) && /* @__PURE__ */ React19.createElement("div", { className: "mb-3 space-y-1" }, label && /* @__PURE__ */ React19.createElement("div", { className: "text-base font-medium leading-none" }, label), description && /* @__PURE__ */ React19.createElement(FieldDescription, { id: groupDescriptionId, className: "leading-snug" }, description)), /* @__PURE__ */ React19.createElement(
457
452
  RadioGroup,
458
453
  {
459
454
  name,
@@ -463,9 +458,8 @@ function Radio({
463
458
  disabled,
464
459
  required,
465
460
  className: cn(
466
- "gap-3",
467
- layout === "grid" && "grid grid-cols-1 md:grid-cols-2",
468
- layout === "inline" && "flex flex-wrap"
461
+ layout === "grid" && "grid grid-cols-1 md:grid-cols-2 gap-3",
462
+ layout === "inline" && "flex flex-wrap gap-0"
469
463
  ),
470
464
  "aria-invalid": error || props["aria-invalid"],
471
465
  "aria-describedby": groupDescriptionId || props["aria-describedby"],
@@ -4050,5 +4044,5 @@ function DateRangePicker({
4050
4044
  DateRangePicker.displayName = "DateRangePicker";
4051
4045
 
4052
4046
  export { Checkbox2 as Checkbox, CheckboxGroup, DatePicker, DateRangePicker, FileInput, MultiSelect, Radio, Select2 as Select, Switch2 as Switch, TextArea, TimePicker };
4053
- //# sourceMappingURL=chunk-ML6FGUYS.js.map
4054
- //# sourceMappingURL=chunk-ML6FGUYS.js.map
4047
+ //# sourceMappingURL=chunk-AI5Q4N6D.js.map
4048
+ //# sourceMappingURL=chunk-AI5Q4N6D.js.map