@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 +34 -0
- package/dist/{chunk-ML6FGUYS.js → chunk-AI5Q4N6D.js} +8 -14
- package/dist/chunk-AI5Q4N6D.js.map +1 -0
- package/dist/{chunk-UQ6JPOBF.cjs → chunk-I4EKHIVF.cjs} +8 -14
- package/dist/chunk-I4EKHIVF.cjs.map +1 -0
- package/dist/inputs.cjs +12 -12
- package/dist/inputs.js +1 -1
- package/dist/integration.cjs +61 -38
- package/dist/integration.cjs.map +1 -1
- package/dist/integration.d.cts +23 -8
- package/dist/integration.d.ts +23 -8
- package/dist/integration.js +51 -28
- package/dist/integration.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ML6FGUYS.js.map +0 -1
- package/dist/chunk-UQ6JPOBF.cjs.map +0 -1
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
|
|
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 === "
|
|
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-
|
|
4054
|
-
//# sourceMappingURL=chunk-
|
|
4047
|
+
//# sourceMappingURL=chunk-AI5Q4N6D.js.map
|
|
4048
|
+
//# sourceMappingURL=chunk-AI5Q4N6D.js.map
|