@vritti/quantum-ui 0.2.8 → 0.2.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 +7 -7
- package/dist/Alert.js +110 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Avatar.js +1 -1
- package/dist/Chart.js +1 -1
- package/dist/Checkbox.js +2 -2
- package/dist/Combination.js +3 -15
- package/dist/Combination.js.map +1 -1
- package/dist/DatePicker.js +5 -14
- package/dist/DatePicker.js.map +1 -1
- package/dist/DropdownMenu.js +5 -74
- package/dist/DropdownMenu.js.map +1 -1
- package/dist/Form.js +29 -21
- package/dist/Form.js.map +1 -1
- package/dist/SelectField.js +1351 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/Sonner.js +3 -38
- package/dist/Sonner.js.map +1 -1
- package/dist/Switch.js +2 -2
- package/dist/Toggle.js +1 -1
- package/dist/chevron-down.js +15 -0
- package/dist/chevron-down.js.map +1 -0
- package/dist/chevron-right.js +15 -0
- package/dist/chevron-right.js.map +1 -0
- package/dist/components/Alert.js +2 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/SelectField.js +2 -0
- package/dist/components/SelectField.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index11.js +69 -91
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +86 -190
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +196 -190
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +199 -0
- package/dist/index14.js.map +1 -0
- package/dist/lib/components/Alert/Alert.d.ts +10 -0
- package/dist/lib/components/Alert/Alert.d.ts.map +1 -0
- package/dist/lib/components/Alert/index.d.ts +2 -0
- package/dist/lib/components/Alert/index.d.ts.map +1 -0
- package/dist/lib/components/Form/Form.d.ts +1 -1
- package/dist/lib/components/Form/Form.d.ts.map +1 -1
- package/dist/lib/components/SelectField/SelectField.d.ts +24 -0
- package/dist/lib/components/SelectField/SelectField.d.ts.map +1 -0
- package/dist/lib/components/SelectField/index.d.ts +3 -0
- package/dist/lib/components/SelectField/index.d.ts.map +1 -0
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/utils/formHelpers.d.ts +7 -3
- package/dist/lib/utils/formHelpers.d.ts.map +1 -1
- package/dist/shadcn/shadcnAlert/alert.d.ts +11 -0
- package/dist/shadcn/shadcnAlert/alert.d.ts.map +1 -0
- package/dist/shadcn/shadcnAlert/index.d.ts +2 -0
- package/dist/shadcn/shadcnAlert/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts +1 -1
- package/dist/shadcn/shadcnButton/Button.d.ts +2 -2
- package/dist/triangle-alert.js +40 -0
- package/dist/triangle-alert.js.map +1 -0
- package/package.json +15 -6
package/dist/Form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import { c as FieldError } from './field.js';
|
|
5
4
|
import { c as cn } from './utils.js';
|
|
5
|
+
import { A as Alert } from './Alert.js';
|
|
6
6
|
import { B as Button } from './Button.js';
|
|
7
7
|
import { C as Checkbox } from './Checkbox.js';
|
|
8
8
|
import { S as Switch } from './Switch.js';
|
|
@@ -621,7 +621,7 @@ function mapApiErrorsToForm(error, form, options = {}) {
|
|
|
621
621
|
if (!error || typeof error !== "object") {
|
|
622
622
|
if (setRootError) {
|
|
623
623
|
form.setError("root", {
|
|
624
|
-
type: "
|
|
624
|
+
type: "Error",
|
|
625
625
|
message: "An error occurred"
|
|
626
626
|
});
|
|
627
627
|
}
|
|
@@ -630,28 +630,20 @@ function mapApiErrorsToForm(error, form, options = {}) {
|
|
|
630
630
|
const axiosError = error;
|
|
631
631
|
const errorData = axiosError.response?.data || error;
|
|
632
632
|
const apiError = errorData;
|
|
633
|
-
const
|
|
634
|
-
|
|
633
|
+
const errorTitle = apiError.label || apiError.title || "Error";
|
|
634
|
+
const generalMessage = apiError.detail;
|
|
635
635
|
if (apiError.errors && Array.isArray(apiError.errors)) {
|
|
636
636
|
for (const errorItem of apiError.errors) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
});
|
|
643
|
-
hasFieldErrors = true;
|
|
644
|
-
} else if (errorItem.message && setRootError) {
|
|
645
|
-
form.setError("root", {
|
|
646
|
-
type: "manual",
|
|
647
|
-
message: errorItem.message
|
|
648
|
-
});
|
|
649
|
-
}
|
|
637
|
+
const formField = fieldMapping[errorItem.field] || errorItem.field;
|
|
638
|
+
form.setError(formField, {
|
|
639
|
+
type: "manual",
|
|
640
|
+
message: errorItem.message
|
|
641
|
+
});
|
|
650
642
|
}
|
|
651
643
|
}
|
|
652
|
-
if (
|
|
644
|
+
if (generalMessage && setRootError) {
|
|
653
645
|
form.setError("root", {
|
|
654
|
-
type:
|
|
646
|
+
type: errorTitle,
|
|
655
647
|
message: generalMessage
|
|
656
648
|
});
|
|
657
649
|
}
|
|
@@ -748,9 +740,25 @@ function Form({
|
|
|
748
740
|
const handleSubmit = form.handleSubmit(wrappedOnSubmit);
|
|
749
741
|
const processedChildren = processChildren(children, form.control, isSubmitting);
|
|
750
742
|
return /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, ...props, children: [
|
|
751
|
-
showRootError && rootErrorPosition === "top" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
743
|
+
showRootError && rootErrorPosition === "top" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
744
|
+
Alert,
|
|
745
|
+
{
|
|
746
|
+
variant: "destructive",
|
|
747
|
+
title: form.formState.errors.root.type || "Error",
|
|
748
|
+
description: form.formState.errors.root.message,
|
|
749
|
+
className: cn("mb-4", rootErrorClassName)
|
|
750
|
+
}
|
|
751
|
+
),
|
|
752
752
|
processedChildren,
|
|
753
|
-
showRootError && rootErrorPosition === "bottom" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
753
|
+
showRootError && rootErrorPosition === "bottom" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
754
|
+
Alert,
|
|
755
|
+
{
|
|
756
|
+
variant: "destructive",
|
|
757
|
+
title: form.formState.errors.root.type || "Error",
|
|
758
|
+
description: form.formState.errors.root.message,
|
|
759
|
+
className: cn("mt-4", rootErrorClassName)
|
|
760
|
+
}
|
|
761
|
+
)
|
|
754
762
|
] }) });
|
|
755
763
|
}
|
|
756
764
|
Form.displayName = "Form";
|