@page-speed/forms 0.3.5 → 0.3.7

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/dist/core.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-WxAFrgDW.cjs';
2
- export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-WxAFrgDW.cjs';
1
+ import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-BBif0kuP.cjs';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.cjs';
3
3
  import * as React from 'react';
4
4
 
5
5
  /**
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-WxAFrgDW.js';
2
- export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-WxAFrgDW.js';
1
+ import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-BBif0kuP.js';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.js';
3
3
  import * as React from 'react';
4
4
 
5
5
  /**
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Field, Form, FormContext, useField, useForm } from './core.cjs';
2
- export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-WxAFrgDW.cjs';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.cjs';
3
3
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Field, Form, FormContext, useField, useForm } from './core.js';
2
- export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-WxAFrgDW.js';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.js';
3
3
  import 'react';
package/dist/inputs.cjs CHANGED
@@ -34,6 +34,7 @@ function TextInput({
34
34
  error = false,
35
35
  className = "",
36
36
  type = "text",
37
+ id = "text",
37
38
  ...props
38
39
  }) {
39
40
  const handleChange = (e) => {
@@ -49,6 +50,7 @@ function TextInput({
49
50
  "input",
50
51
  {
51
52
  type,
53
+ id,
52
54
  name,
53
55
  value: value ?? "",
54
56
  onChange: handleChange,
@@ -126,9 +128,11 @@ function Checkbox({
126
128
  className = "",
127
129
  indeterminate = false,
128
130
  label,
131
+ description,
129
132
  ...props
130
133
  }) {
131
134
  const inputRef = React7__namespace.useRef(null);
135
+ const checkboxId = props.id || `checkbox-${name}`;
132
136
  React7__namespace.useEffect(() => {
133
137
  if (inputRef.current) {
134
138
  inputRef.current.indeterminate = indeterminate;
@@ -142,27 +146,37 @@ function Checkbox({
142
146
  };
143
147
  const baseClassName = "checkbox";
144
148
  const errorClassName = error ? "checkbox--error" : "";
145
- const combinedClassName = `${baseClassName} ${errorClassName} ${className}`.trim();
149
+ const checkedClassName = value ? "checkbox--checked" : "";
150
+ const disabledClassName = disabled ? "checkbox--disabled" : "";
151
+ const combinedClassName = `${baseClassName} ${errorClassName} ${checkedClassName} ${disabledClassName} ${className}`.trim();
146
152
  const checkbox = /* @__PURE__ */ React7__namespace.createElement(
147
153
  "input",
148
154
  {
149
155
  ref: inputRef,
150
156
  type: "checkbox",
157
+ id: checkboxId,
151
158
  name,
152
159
  checked: value,
153
160
  onChange: handleChange,
154
161
  onBlur: handleBlur,
155
162
  disabled,
156
163
  required,
157
- className: combinedClassName,
164
+ className: "checkbox-input",
158
165
  "aria-invalid": error || props["aria-invalid"],
159
- "aria-describedby": props["aria-describedby"],
166
+ "aria-describedby": description ? `${checkboxId}-description` : props["aria-describedby"],
160
167
  "aria-required": required || props["aria-required"],
161
168
  ...props
162
169
  }
163
170
  );
164
171
  if (label) {
165
- return /* @__PURE__ */ React7__namespace.createElement("label", { className: "checkbox-label" }, checkbox, /* @__PURE__ */ React7__namespace.createElement("span", { className: "checkbox-label-text" }, label));
172
+ return /* @__PURE__ */ React7__namespace.createElement("label", { className: `checkbox-field ${combinedClassName}`, htmlFor: checkboxId }, /* @__PURE__ */ React7__namespace.createElement("div", { className: "checkbox-field-content" }, checkbox, /* @__PURE__ */ React7__namespace.createElement("div", { className: "checkbox-field-text" }, /* @__PURE__ */ React7__namespace.createElement("span", { className: "checkbox-label" }, label), description && /* @__PURE__ */ React7__namespace.createElement(
173
+ "span",
174
+ {
175
+ className: "checkbox-description",
176
+ id: `${checkboxId}-description`
177
+ },
178
+ description
179
+ ))));
166
180
  }
167
181
  return checkbox;
168
182
  }
@@ -358,10 +372,19 @@ function Radio({
358
372
  "label",
359
373
  {
360
374
  key: option.value,
361
- className: `radio-option ${isDisabled ? "radio-option--disabled" : ""}`,
362
- htmlFor: radioId
375
+ className: `radio-option ${isChecked ? "radio-option--checked" : ""} ${isDisabled ? "radio-option--disabled" : ""}`,
376
+ htmlFor: radioId,
377
+ onKeyDown: (e) => handleKeyDown(e, index),
378
+ tabIndex: 0
363
379
  },
364
- /* @__PURE__ */ React7__namespace.createElement(
380
+ /* @__PURE__ */ React7__namespace.createElement("div", { className: "radio-option-content" }, /* @__PURE__ */ React7__namespace.createElement("div", { className: "radio-option-text" }, /* @__PURE__ */ React7__namespace.createElement("span", { className: "radio-label" }, option.label), option.description && /* @__PURE__ */ React7__namespace.createElement(
381
+ "span",
382
+ {
383
+ className: "radio-description",
384
+ id: `${radioId}-description`
385
+ },
386
+ option.description
387
+ )), /* @__PURE__ */ React7__namespace.createElement(
365
388
  "input",
366
389
  {
367
390
  type: "radio",
@@ -371,20 +394,11 @@ function Radio({
371
394
  checked: isChecked,
372
395
  onChange: (e) => handleChange(e.target.value),
373
396
  onBlur: handleBlur,
374
- onKeyDown: (e) => handleKeyDown(e, index),
375
397
  disabled: isDisabled,
376
398
  required,
377
399
  className: "radio-input",
378
400
  "aria-describedby": option.description ? `${radioId}-description` : props["aria-describedby"]
379
401
  }
380
- ),
381
- /* @__PURE__ */ React7__namespace.createElement("div", { className: "radio-content" }, /* @__PURE__ */ React7__namespace.createElement("span", { className: "radio-label" }, option.label), option.description && /* @__PURE__ */ React7__namespace.createElement(
382
- "span",
383
- {
384
- className: "radio-description",
385
- id: `${radioId}-description`
386
- },
387
- option.description
388
402
  ))
389
403
  );
390
404
  }))