@pathscale/ui 1.1.61 → 1.1.63

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.
@@ -15,7 +15,7 @@
15
15
  align-items: center;
16
16
  justify-content: center;
17
17
  gap: 0.5rem;
18
- border-radius: 1.5rem;
18
+ border-radius: 0.5rem;
19
19
  border: 1px solid transparent;
20
20
  padding: 0.5rem 0.875rem;
21
21
  font-size: 0.875rem;
@@ -10,8 +10,9 @@ export type CreateFormOptions<TValues extends AnyValues = AnyValues> = {
10
10
  */
11
11
  defaultValues: TValues;
12
12
  /**
13
- * Any Standard Schema-compatible schema (Zod, Valibot, Arktype, ).
14
- * Applied as `validators.onBlur` and `validators.onSubmit` by default.
13
+ * Any Standard Schema-compatible schema (Zod, Valibot, Arktype, ...).
14
+ * Applied as `validators.onChange`, `validators.onBlur` and
15
+ * `validators.onSubmit`.
15
16
  */
16
17
  schema?: StandardSchemaV1<TValues>;
17
18
  /**
@@ -1,12 +1,87 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE__tanstack_solid_form_5af81884__ from "@tanstack/solid-form";
2
+ const createValidationLogic = (props)=>{
3
+ if (!props.validators) return props.runValidation({
4
+ validators: [],
5
+ form: props.form
6
+ });
7
+ const isAsync = props.event.async;
8
+ const onMountValidator = isAsync ? void 0 : {
9
+ fn: props.validators.onMount,
10
+ cause: "mount"
11
+ };
12
+ const onChangeValidator = {
13
+ fn: isAsync ? props.validators.onChangeAsync : props.validators.onChange,
14
+ cause: "change"
15
+ };
16
+ const onBlurValidator = {
17
+ fn: isAsync ? props.validators.onBlurAsync : props.validators.onBlur,
18
+ cause: "blur"
19
+ };
20
+ const onSubmitValidator = {
21
+ fn: isAsync ? props.validators.onSubmitAsync : props.validators.onSubmit,
22
+ cause: "submit"
23
+ };
24
+ const onServerValidator = isAsync ? void 0 : {
25
+ fn: ()=>void 0,
26
+ cause: "server"
27
+ };
28
+ switch(props.event.type){
29
+ case "mount":
30
+ return props.runValidation({
31
+ validators: [
32
+ onMountValidator
33
+ ],
34
+ form: props.form
35
+ });
36
+ case "submit":
37
+ return props.runValidation({
38
+ validators: [
39
+ onChangeValidator,
40
+ onBlurValidator,
41
+ onSubmitValidator,
42
+ onServerValidator
43
+ ],
44
+ form: props.form
45
+ });
46
+ case "server":
47
+ return props.runValidation({
48
+ validators: [],
49
+ form: props.form
50
+ });
51
+ case "blur":
52
+ return props.runValidation({
53
+ validators: [
54
+ onBlurValidator,
55
+ onServerValidator
56
+ ],
57
+ form: props.form
58
+ });
59
+ case "change":
60
+ return props.runValidation({
61
+ validators: [
62
+ onChangeValidator,
63
+ onBlurValidator,
64
+ onServerValidator
65
+ ],
66
+ form: props.form
67
+ });
68
+ default:
69
+ throw new Error(`Unknown validation event type: ${props.event.type}`);
70
+ }
71
+ };
2
72
  const createForm = (options)=>{
73
+ const hasSchema = Boolean(options.schema);
74
+ const hasAsyncValidators = Boolean(options.asyncValidators);
3
75
  const tsForm = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_solid_form_5af81884__.createForm)(()=>({
4
76
  defaultValues: options.defaultValues,
5
- validators: options.schema ? {
77
+ validators: hasSchema || hasAsyncValidators ? {
6
78
  onChange: options.schema,
7
79
  onBlur: options.schema,
8
- onSubmit: options.schema
80
+ onSubmit: options.schema,
81
+ onBlurAsync: options.asyncValidators?.onBlur,
82
+ onSubmitAsync: options.asyncValidators?.onSubmit
9
83
  } : void 0,
84
+ validationLogic: createValidationLogic,
10
85
  onSubmit: async ({ value })=>{
11
86
  await options.onSubmit?.(value);
12
87
  }