@connect-soft/form-generator 1.0.0-alpha → 1.1.0-alpha2

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/index.m.js CHANGED
@@ -3442,86 +3442,89 @@ function getItemKey(item, index) {
3442
3442
  }
3443
3443
  return item.name;
3444
3444
  }
3445
- function FormGenerator(t0) {
3445
+ function hasSchema(props) {
3446
+ return props.schema !== undefined;
3447
+ }
3448
+ function FormGenerator(props) {
3446
3449
  const $ = c(20);
3447
3450
  const {
3448
3451
  fields,
3449
- onSubmit,
3450
3452
  defaultValues,
3451
- schema: userSchema,
3452
3453
  className,
3453
- submitText: t1,
3454
+ submitText: t0,
3454
3455
  disabled,
3455
- mode: t2
3456
- } = t0;
3457
- const submitText = t1 === undefined ? "Submit" : t1;
3458
- const mode = t2 === undefined ? "onChange" : t2;
3459
- let t3;
3456
+ mode: t1
3457
+ } = props;
3458
+ const submitText = t0 === undefined ? "Submit" : t0;
3459
+ const mode = t1 === undefined ? "onChange" : t1;
3460
+ const userSchema = hasSchema(props) ? props.schema : undefined;
3461
+ const onSubmit = props.onSubmit;
3462
+ let t2;
3460
3463
  bb0: {
3461
3464
  if (userSchema) {
3462
- t3 = userSchema;
3465
+ t2 = userSchema;
3463
3466
  break bb0;
3464
3467
  }
3465
- let t4;
3468
+ let t3;
3466
3469
  if ($[0] !== fields) {
3467
- t4 = buildSchema(fields);
3470
+ t3 = buildSchema(fields);
3468
3471
  $[0] = fields;
3469
- $[1] = t4;
3472
+ $[1] = t3;
3470
3473
  } else {
3471
- t4 = $[1];
3474
+ t3 = $[1];
3472
3475
  }
3473
- t3 = t4;
3476
+ t2 = t3;
3474
3477
  }
3475
- const schema = t3;
3476
- let t4;
3478
+ const schema = t2;
3479
+ let t3;
3477
3480
  if ($[2] !== defaultValues || $[3] !== fields) {
3478
3481
  const builtDefaults = buildDefaultValues(fields);
3479
- t4 = defaultValues ? deepMerge(builtDefaults, defaultValues) : builtDefaults;
3482
+ t3 = defaultValues ? deepMerge(builtDefaults, defaultValues) : builtDefaults;
3480
3483
  $[2] = defaultValues;
3481
3484
  $[3] = fields;
3482
- $[4] = t4;
3485
+ $[4] = t3;
3483
3486
  } else {
3484
- t4 = $[4];
3487
+ t3 = $[4];
3485
3488
  }
3486
- const mergedDefaultValues = t4;
3487
- let t5;
3489
+ const mergedDefaultValues = t3;
3490
+ let t4;
3488
3491
  if ($[5] !== schema) {
3489
- t5 = a(schema);
3492
+ t4 = a(schema);
3490
3493
  $[5] = schema;
3491
- $[6] = t5;
3494
+ $[6] = t4;
3492
3495
  } else {
3493
- t5 = $[6];
3496
+ t4 = $[6];
3494
3497
  }
3495
- let t6;
3496
- if ($[7] !== mergedDefaultValues || $[8] !== mode || $[9] !== t5) {
3497
- t6 = {
3498
- resolver: t5,
3498
+ let t5;
3499
+ if ($[7] !== mergedDefaultValues || $[8] !== mode || $[9] !== t4) {
3500
+ t5 = {
3501
+ resolver: t4,
3499
3502
  defaultValues: mergedDefaultValues,
3500
3503
  mode
3501
3504
  };
3502
3505
  $[7] = mergedDefaultValues;
3503
3506
  $[8] = mode;
3504
- $[9] = t5;
3505
- $[10] = t6;
3507
+ $[9] = t4;
3508
+ $[10] = t5;
3506
3509
  } else {
3507
- t6 = $[10];
3510
+ t5 = $[10];
3508
3511
  }
3509
- const form = useForm(t6);
3510
- let t7;
3512
+ const form = useForm(t5);
3513
+ let t6;
3511
3514
  if ($[11] !== className || $[12] !== disabled || $[13] !== fields || $[14] !== form || $[15] !== onSubmit || $[16] !== submitText) {
3512
- let t8;
3515
+ let t7;
3513
3516
  if ($[18] !== onSubmit) {
3514
- t8 = async data => {
3517
+ t7 = async data => {
3515
3518
  await onSubmit(data);
3516
3519
  };
3517
3520
  $[18] = onSubmit;
3518
- $[19] = t8;
3521
+ $[19] = t7;
3519
3522
  } else {
3520
- t8 = $[19];
3523
+ t7 = $[19];
3521
3524
  }
3522
- const handleSubmit = form.handleSubmit(t8);
3525
+ const handleSubmit = form.handleSubmit(t7);
3523
3526
  const SubmitButton = getFormComponent("SubmitButton");
3524
- t7 = jsx(FormProvider, {
3527
+ t6 = jsx(FormProvider, {
3525
3528
  ...form,
3526
3529
  children: jsxs("form", {
3527
3530
  onSubmit: handleSubmit,
@@ -3539,11 +3542,11 @@ function FormGenerator(t0) {
3539
3542
  $[14] = form;
3540
3543
  $[15] = onSubmit;
3541
3544
  $[16] = submitText;
3542
- $[17] = t7;
3545
+ $[17] = t6;
3543
3546
  } else {
3544
- t7 = $[17];
3547
+ t6 = $[17];
3545
3548
  }
3546
- return t7;
3549
+ return t6;
3547
3550
  }
3548
3551
  function _temp(item, index) {
3549
3552
  return jsx(FormItemRenderer, {