@open-mercato/ui 0.10.1-develop.8130.1.8964ae359f → 0.10.1-develop.8143.1.bf633ea932

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.
@@ -884,12 +884,14 @@ function CrudFormImpl({
884
884
  );
885
885
  const navigateWithGuard = React.useCallback(
886
886
  async (target) => {
887
- if (!target) return;
887
+ if (!target) return false;
888
888
  const allowed = await canNavigateTo(target);
889
889
  if (allowed) {
890
890
  allowNextNavigation();
891
891
  router.push(target);
892
+ return true;
892
893
  }
894
+ return false;
893
895
  },
894
896
  [allowNextNavigation, canNavigateTo, router]
895
897
  );
@@ -2283,6 +2285,7 @@ function CrudFormImpl({
2283
2285
  if (formReadOnly) return;
2284
2286
  if (submittingRef.current) return;
2285
2287
  submittingRef.current = true;
2288
+ let redirectNavigationStarted = false;
2286
2289
  try {
2287
2290
  setFormError(null);
2288
2291
  setErrors({});
@@ -2495,7 +2498,7 @@ function CrudFormImpl({
2495
2498
  logger.error("Error in onSubmitSuccess", { err });
2496
2499
  getTelemetryRuntime()?.reportError(err, { module: "ui", code: "ui.form_submit_success_failed" });
2497
2500
  }
2498
- if (successRedirect) await navigateWithGuard(successRedirect);
2501
+ if (successRedirect) redirectNavigationStarted = await navigateWithGuard(successRedirect);
2499
2502
  } catch (err) {
2500
2503
  clearSubmitNavigationBypass();
2501
2504
  try {
@@ -2557,10 +2560,10 @@ function CrudFormImpl({
2557
2560
  }
2558
2561
  setFormError(displayMessage);
2559
2562
  } finally {
2560
- setPending(false);
2563
+ if (!redirectNavigationStarted) setPending(false);
2561
2564
  }
2562
2565
  } finally {
2563
- submittingRef.current = false;
2566
+ if (!redirectNavigationStarted) submittingRef.current = false;
2564
2567
  }
2565
2568
  };
2566
2569
  const dynamicOptionLoadersRef = React.useRef(/* @__PURE__ */ new Map());
@@ -2685,7 +2688,8 @@ function CrudFormImpl({
2685
2688
  wrapperClassName,
2686
2689
  entityIdForField: primaryEntityId ?? void 0,
2687
2690
  recordId: explicitResourceId ?? recordId,
2688
- markRequired: widgetRequiredFieldIds.has(f.id)
2691
+ markRequired: widgetRequiredFieldIds.has(f.id),
2692
+ formId
2689
2693
  },
2690
2694
  f.id
2691
2695
  );
@@ -3188,7 +3192,8 @@ function CrudFormImpl({
3188
3192
  wrapperClassName,
3189
3193
  entityIdForField: primaryEntityId ?? void 0,
3190
3194
  recordId: explicitResourceId ?? recordId,
3191
- markRequired: widgetRequiredFieldIds.has(f.id)
3195
+ markRequired: widgetRequiredFieldIds.has(f.id),
3196
+ formId
3192
3197
  },
3193
3198
  f.id
3194
3199
  );
@@ -3274,6 +3279,7 @@ function RelationSelect({
3274
3279
  ] });
3275
3280
  }
3276
3281
  function TextInput({
3282
+ id,
3277
3283
  value,
3278
3284
  onChange,
3279
3285
  placeholder,
@@ -3324,6 +3330,7 @@ function TextInput({
3324
3330
  return /* @__PURE__ */ jsx(
3325
3331
  PasswordInput,
3326
3332
  {
3333
+ id,
3327
3334
  placeholder,
3328
3335
  value: local,
3329
3336
  onChange: handleChange,
@@ -3342,6 +3349,7 @@ function TextInput({
3342
3349
  /* @__PURE__ */ jsx(
3343
3350
  Input,
3344
3351
  {
3352
+ id,
3345
3353
  type: inputType,
3346
3354
  placeholder,
3347
3355
  value: local,
@@ -3361,6 +3369,7 @@ function TextInput({
3361
3369
  ] });
3362
3370
  }
3363
3371
  function NumberInput({
3372
+ id,
3364
3373
  value,
3365
3374
  onChange,
3366
3375
  placeholder,
@@ -3428,6 +3437,7 @@ function NumberInput({
3428
3437
  /* @__PURE__ */ jsx(
3429
3438
  Input,
3430
3439
  {
3440
+ id,
3431
3441
  type: "text",
3432
3442
  inputMode: "decimal",
3433
3443
  autoComplete: "off",
@@ -3447,6 +3457,7 @@ function NumberInput({
3447
3457
  );
3448
3458
  }
3449
3459
  function TextAreaInput({
3460
+ id,
3450
3461
  value,
3451
3462
  onChange,
3452
3463
  placeholder,
@@ -3482,6 +3493,7 @@ function TextAreaInput({
3482
3493
  return /* @__PURE__ */ jsx(
3483
3494
  Textarea,
3484
3495
  {
3496
+ id,
3485
3497
  placeholder,
3486
3498
  value: local,
3487
3499
  onChange: handleChange,
@@ -3681,7 +3693,8 @@ const FieldControl = React.memo(
3681
3693
  wrapperClassName,
3682
3694
  entityIdForField,
3683
3695
  recordId,
3684
- markRequired
3696
+ markRequired,
3697
+ formId
3685
3698
  }) {
3686
3699
  const t = useT();
3687
3700
  const fieldSetValue = React.useCallback(
@@ -3718,6 +3731,9 @@ const FieldControl = React.memo(
3718
3731
  [options]
3719
3732
  );
3720
3733
  const singleSelectLabel = singleSelectValue ? options.find((option) => option.value === singleSelectValue)?.label : void 0;
3734
+ const controlId = `${formId}-field-${field.id}`;
3735
+ const labelId = `${controlId}-label`;
3736
+ const hasSingleControl = field.type === "text" || field.type === "password" || field.type === "number" || field.type === "textarea" || field.type === "combobox" || field.type === "select" && !builtin?.multiple;
3721
3737
  return /* @__PURE__ */ jsxs(
3722
3738
  "div",
3723
3739
  {
@@ -3729,13 +3745,22 @@ const FieldControl = React.memo(
3729
3745
  onBlurRequest(field.id);
3730
3746
  } : void 0,
3731
3747
  children: [
3732
- field.type !== "checkbox" && field.label.trim().length > 0 ? /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium", children: [
3733
- field.label,
3734
- field.required || markRequired ? /* @__PURE__ */ jsx("span", { className: "text-status-error-text", children: " *" }) : null
3735
- ] }) : null,
3748
+ field.type !== "checkbox" && field.label.trim().length > 0 ? /* @__PURE__ */ jsxs(
3749
+ "label",
3750
+ {
3751
+ id: labelId,
3752
+ htmlFor: hasSingleControl ? controlId : void 0,
3753
+ className: "block text-sm font-medium",
3754
+ children: [
3755
+ field.label,
3756
+ field.required || markRequired ? /* @__PURE__ */ jsx("span", { className: "text-status-error-text", children: " *" }) : null
3757
+ ]
3758
+ }
3759
+ ) : null,
3736
3760
  field.type === "text" && /* @__PURE__ */ jsx(
3737
3761
  TextInput,
3738
3762
  {
3763
+ id: controlId,
3739
3764
  value: value == null ? "" : String(value),
3740
3765
  placeholder,
3741
3766
  onChange: (next) => fieldSetValue(next),
@@ -3749,6 +3774,7 @@ const FieldControl = React.memo(
3749
3774
  field.type === "password" && /* @__PURE__ */ jsx(
3750
3775
  TextInput,
3751
3776
  {
3777
+ id: controlId,
3752
3778
  value: value == null ? "" : String(value),
3753
3779
  placeholder,
3754
3780
  onChange: (next) => fieldSetValue(next),
@@ -3762,6 +3788,7 @@ const FieldControl = React.memo(
3762
3788
  field.type === "number" && /* @__PURE__ */ jsx(
3763
3789
  NumberInput,
3764
3790
  {
3791
+ id: controlId,
3765
3792
  value: typeof value === "number" || typeof value === "string" ? value : null,
3766
3793
  placeholder,
3767
3794
  onChange: fieldSetValue,
@@ -3771,7 +3798,7 @@ const FieldControl = React.memo(
3771
3798
  readOnly
3772
3799
  }
3773
3800
  ),
3774
- field.type === "date" && /* @__PURE__ */ jsx(
3801
+ field.type === "date" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3775
3802
  DatePicker,
3776
3803
  {
3777
3804
  value: typeof value === "string" && value ? parseISO(value) : value instanceof Date ? value : null,
@@ -3785,8 +3812,8 @@ const FieldControl = React.memo(
3785
3812
  closeOnSelect: builtin?.closeOnSelect,
3786
3813
  locale: builtin?.locale
3787
3814
  }
3788
- ),
3789
- field.type === "datetime-local" && /* @__PURE__ */ jsx(
3815
+ ) }),
3816
+ field.type === "datetime-local" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3790
3817
  DateTimePicker,
3791
3818
  {
3792
3819
  value: typeof value === "string" && value ? new Date(value) : value instanceof Date ? value : null,
@@ -3800,8 +3827,8 @@ const FieldControl = React.memo(
3800
3827
  displayFormat: builtin?.displayFormat,
3801
3828
  locale: builtin?.locale
3802
3829
  }
3803
- ),
3804
- field.type === "datepicker" && /* @__PURE__ */ jsx(
3830
+ ) }),
3831
+ field.type === "datepicker" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3805
3832
  DatePicker,
3806
3833
  {
3807
3834
  value: typeof value === "string" && value ? parseISO(value) : value instanceof Date ? value : null,
@@ -3815,8 +3842,8 @@ const FieldControl = React.memo(
3815
3842
  closeOnSelect: builtin?.closeOnSelect,
3816
3843
  locale: builtin?.locale
3817
3844
  }
3818
- ),
3819
- field.type === "datetime" && /* @__PURE__ */ jsx(
3845
+ ) }),
3846
+ field.type === "datetime" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3820
3847
  DateTimePicker,
3821
3848
  {
3822
3849
  value: typeof value === "string" && value ? new Date(value) : value instanceof Date ? value : null,
@@ -3830,8 +3857,8 @@ const FieldControl = React.memo(
3830
3857
  displayFormat: builtin?.displayFormat,
3831
3858
  locale: builtin?.locale
3832
3859
  }
3833
- ),
3834
- field.type === "time" && /* @__PURE__ */ jsx(
3860
+ ) }),
3861
+ field.type === "time" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3835
3862
  TimePicker,
3836
3863
  {
3837
3864
  value: typeof value === "string" ? value : null,
@@ -3841,10 +3868,11 @@ const FieldControl = React.memo(
3841
3868
  placeholder,
3842
3869
  minuteStep: builtin?.minuteStep
3843
3870
  }
3844
- ),
3871
+ ) }),
3845
3872
  field.type === "textarea" && /* @__PURE__ */ jsx(
3846
3873
  TextAreaInput,
3847
3874
  {
3875
+ id: controlId,
3848
3876
  value: value == null ? "" : String(value),
3849
3877
  placeholder,
3850
3878
  onChange: (next) => fieldSetValue(next),
@@ -3856,10 +3884,10 @@ const FieldControl = React.memo(
3856
3884
  readOnly
3857
3885
  }
3858
3886
  ),
3859
- field.type === "richtext" && builtin?.editor === "simple" && /* @__PURE__ */ jsx(SimpleMarkdownEditor, { value: String(value ?? ""), onChange: fieldSetValue }),
3860
- field.type === "richtext" && builtin?.editor === "html" && /* @__PURE__ */ jsx(HtmlRichEditorField, { value: String(value ?? ""), onChange: fieldSetValue }),
3861
- field.type === "richtext" && (!builtin?.editor || builtin.editor !== "simple" && builtin.editor !== "html") && /* @__PURE__ */ jsx(MarkdownEditor, { value: String(value ?? ""), onChange: fieldSetValue }),
3862
- field.type === "tags" && /* @__PURE__ */ jsx(
3887
+ field.type === "richtext" && builtin?.editor === "simple" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(SimpleMarkdownEditor, { value: String(value ?? ""), onChange: fieldSetValue }) }),
3888
+ field.type === "richtext" && builtin?.editor === "html" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(HtmlRichEditorField, { value: String(value ?? ""), onChange: fieldSetValue }) }),
3889
+ field.type === "richtext" && (!builtin?.editor || builtin.editor !== "simple" && builtin.editor !== "html") && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(MarkdownEditor, { value: String(value ?? ""), onChange: fieldSetValue }) }),
3890
+ field.type === "tags" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3863
3891
  TagsInput,
3864
3892
  {
3865
3893
  value: Array.isArray(value) ? value.filter((item) => typeof item === "string") : [],
@@ -3871,10 +3899,11 @@ const FieldControl = React.memo(
3871
3899
  loadSuggestions: loadFieldSuggestions,
3872
3900
  disabled
3873
3901
  }
3874
- ),
3902
+ ) }),
3875
3903
  field.type === "combobox" && /* @__PURE__ */ jsx(
3876
3904
  ComboboxInput,
3877
3905
  {
3906
+ id: controlId,
3878
3907
  value: typeof value === "string" ? value : String(value ?? ""),
3879
3908
  onChange: (next) => fieldSetValue(next),
3880
3909
  placeholder,
@@ -3888,10 +3917,11 @@ const FieldControl = React.memo(
3888
3917
  disabled
3889
3918
  }
3890
3919
  ),
3891
- field.type === "checkbox" && /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2 cursor-pointer", children: [
3920
+ field.type === "checkbox" && /* @__PURE__ */ jsxs("label", { htmlFor: controlId, className: "inline-flex items-center gap-2 cursor-pointer", children: [
3892
3921
  /* @__PURE__ */ jsx(
3893
3922
  Checkbox,
3894
3923
  {
3924
+ id: controlId,
3895
3925
  checked: value === true,
3896
3926
  onCheckedChange: (next) => setValue(field.id, next === true),
3897
3927
  "data-crud-focus-target": "",
@@ -3914,7 +3944,7 @@ const FieldControl = React.memo(
3914
3944
  },
3915
3945
  disabled: disabled || readOnly,
3916
3946
  children: [
3917
- /* @__PURE__ */ jsx(SelectTrigger, { "data-crud-focus-target": "", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("ui.forms.select.emptyOption", "\u2014"), children: singleSelectLabel }) }),
3947
+ /* @__PURE__ */ jsx(SelectTrigger, { id: controlId, "data-crud-focus-target": "", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("ui.forms.select.emptyOption", "\u2014"), children: singleSelectLabel }) }),
3918
3948
  /* @__PURE__ */ jsxs(SelectContent, { children: [
3919
3949
  !field.required && value != null && value !== "" && /* @__PURE__ */ jsx(SelectItem, { value: SELECT_CLEAR_SENTINEL, children: t("ui.forms.select.clearOption", "\u2014 Clear \u2014") }),
3920
3950
  options.filter((opt) => opt.value !== "").map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value))
@@ -3923,7 +3953,7 @@ const FieldControl = React.memo(
3923
3953
  },
3924
3954
  `${field.id}:${singleSelectValue}:${singleSelectOptionsKey}`
3925
3955
  ),
3926
- field.type === "select" && builtin?.multiple && builtin.listbox === true && /* @__PURE__ */ jsx(
3956
+ field.type === "select" && builtin?.multiple && builtin.listbox === true && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3927
3957
  ListboxMultiSelect,
3928
3958
  {
3929
3959
  options,
@@ -3932,8 +3962,8 @@ const FieldControl = React.memo(
3932
3962
  onChange: (vals) => setValue(field.id, vals),
3933
3963
  autoFocus: autoFocusField
3934
3964
  }
3935
- ),
3936
- field.type === "select" && builtin?.multiple && builtin.listbox !== true && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", children: options.map((opt) => {
3965
+ ) }),
3966
+ field.type === "select" && builtin?.multiple && builtin.listbox !== true && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", role: "group", "aria-labelledby": labelId, children: options.map((opt) => {
3937
3967
  const arr = Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
3938
3968
  const checked = arr.includes(opt.value);
3939
3969
  return /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2 cursor-pointer", children: [
@@ -3956,7 +3986,7 @@ const FieldControl = React.memo(
3956
3986
  /* @__PURE__ */ jsx("span", { className: "text-sm", children: opt.label })
3957
3987
  ] }, opt.value);
3958
3988
  }) }),
3959
- field.type === "relation" && /* @__PURE__ */ jsx(
3989
+ field.type === "relation" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: /* @__PURE__ */ jsx(
3960
3990
  RelationSelect,
3961
3991
  {
3962
3992
  options,
@@ -3965,8 +3995,8 @@ const FieldControl = React.memo(
3965
3995
  onChange: (selected) => setValue(field.id, selected),
3966
3996
  autoFocus: autoFocusField
3967
3997
  }
3968
- ),
3969
- field.type === "custom" && /* @__PURE__ */ jsx(Fragment, { children: field.component({
3998
+ ) }),
3999
+ field.type === "custom" && /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, children: field.component({
3970
4000
  id: field.id,
3971
4001
  value,
3972
4002
  error,
@@ -3987,7 +4017,7 @@ const FieldControl = React.memo(
3987
4017
  }
3988
4018
  );
3989
4019
  },
3990
- (prev, next) => prev.field.id === next.field.id && prev.field.type === next.field.type && prev.field.label === next.field.label && prev.field.description === next.field.description && prev.field.required === next.field.required && prev.markRequired === next.markRequired && prev.value === next.value && prev.error === next.error && prev.options === next.options && prev.loadFieldOptions === next.loadFieldOptions && prev.autoFocus === next.autoFocus && prev.onSubmitRequest === next.onSubmitRequest && prev.setValue === next.setValue && prev.onBlurRequest === next.onBlurRequest && prev.wrapperClassName === next.wrapperClassName && prev.entityIdForField === next.entityIdForField && prev.recordId === next.recordId && (prev.field.type !== "custom" || prev.values === next.values && prev.field.component === next.field.component && prev.field.rendersOwnError === next.field.rendersOwnError)
4020
+ (prev, next) => prev.field.id === next.field.id && prev.field.type === next.field.type && prev.field.label === next.field.label && prev.field.description === next.field.description && prev.field.required === next.field.required && prev.markRequired === next.markRequired && prev.value === next.value && prev.error === next.error && prev.options === next.options && prev.loadFieldOptions === next.loadFieldOptions && prev.autoFocus === next.autoFocus && prev.onSubmitRequest === next.onSubmitRequest && prev.setValue === next.setValue && prev.onBlurRequest === next.onBlurRequest && prev.wrapperClassName === next.wrapperClassName && prev.entityIdForField === next.entityIdForField && prev.recordId === next.recordId && prev.formId === next.formId && (prev.field.type !== "custom" || prev.values === next.values && prev.field.component === next.field.component && prev.field.rendersOwnError === next.field.rendersOwnError)
3991
4021
  );
3992
4022
  export {
3993
4023
  CrudForm