@vritti/quantum-ui 0.2.8 → 0.2.10
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 +115 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Avatar.js +6 -6
- package/dist/Badge.js +2 -28
- package/dist/Badge.js.map +1 -1
- package/dist/Badge2.js +30 -0
- package/dist/Badge2.js.map +1 -0
- package/dist/Button.js +1 -1
- package/dist/Button2.js +35 -16
- package/dist/Button2.js.map +1 -1
- package/dist/Card.js +1 -1
- package/dist/Chart.js +2 -2
- package/dist/Checkbox.js +2 -289
- package/dist/Checkbox.js.map +1 -1
- package/dist/Checkbox2.js +292 -0
- package/dist/Checkbox2.js.map +1 -0
- package/dist/Combination.js +6 -18
- package/dist/Combination.js.map +1 -1
- package/dist/DatePicker.js +4 -335
- package/dist/DatePicker.js.map +1 -1
- package/dist/DropdownMenu.js +8 -7
- package/dist/DropdownMenu.js.map +1 -1
- package/dist/Form.js +52 -27
- package/dist/Form.js.map +1 -1
- package/dist/Label.js +2 -2
- package/dist/OTPField.js +1 -1
- package/dist/PasswordField.js +1 -1
- package/dist/PhoneField.js +6 -6
- package/dist/PhoneField.js.map +1 -1
- package/dist/Progress.js +3 -3
- package/dist/Skeleton.js +1 -1
- package/dist/Sonner.js +7 -39
- package/dist/Sonner.js.map +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Switch.js +5 -5
- package/dist/TextArea.js +1 -1
- package/dist/TextField.js +4 -3
- package/dist/TextField.js.map +1 -1
- package/dist/ThemeContext.js +2 -8
- package/dist/ThemeContext.js.map +1 -1
- package/dist/Toggle.js +3 -3
- package/dist/Typography.js +1 -1
- package/dist/assets/quantum-ui.css +31 -31
- package/dist/chevron-left.js +15 -0
- package/dist/chevron-left.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/Badge.js +2 -1
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/DataTable.js +2 -0
- package/dist/components/DataTable.js.map +1 -0
- package/dist/components/Select.js +1379 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/field.js +2 -2
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/index10.js +10 -99
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +35 -95
- 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/index2.js +65 -58
- package/dist/index2.js.map +1 -1
- package/dist/index3.js +60 -8
- package/dist/index3.js.map +1 -1
- package/dist/index4.js +80 -106
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +42 -37
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +9 -4
- package/dist/index6.js.map +1 -1
- package/dist/index7.js +125 -10
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +37 -42
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +4 -37
- package/dist/index9.js.map +1 -1
- package/dist/lib/components/Alert/Alert.d.ts +11 -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/DataTable/DataTable.d.ts +15 -0
- package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTableColumnHeader.d.ts +12 -0
- package/dist/lib/components/DataTable/components/DataTableColumnHeader.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTableEmpty.d.ts +13 -0
- package/dist/lib/components/DataTable/components/DataTableEmpty.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTablePagination.d.ts +13 -0
- package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTableToolbar.d.ts +15 -0
- package/dist/lib/components/DataTable/components/DataTableToolbar.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTableViewOptions.d.ts +11 -0
- package/dist/lib/components/DataTable/components/DataTableViewOptions.d.ts.map +1 -0
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +3 -0
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -0
- package/dist/lib/components/DataTable/index.d.ts +10 -0
- package/dist/lib/components/DataTable/index.d.ts.map +1 -0
- package/dist/lib/components/DataTable/types.d.ts +67 -0
- package/dist/lib/components/DataTable/types.d.ts.map +1 -0
- package/dist/lib/components/DataTable/utils.d.ts +3 -0
- package/dist/lib/components/DataTable/utils.d.ts.map +1 -0
- package/dist/lib/components/Form/Form.d.ts +3 -2
- package/dist/lib/components/Form/Form.d.ts.map +1 -1
- package/dist/lib/components/PhoneField/PhoneField.d.ts +1 -0
- package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/lib/components/Select/Select.d.ts +23 -0
- package/dist/lib/components/Select/Select.d.ts.map +1 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +25 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts +21 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +25 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts +21 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -0
- package/dist/lib/components/Select/hooks/useMultiSelect.d.ts +32 -0
- package/dist/lib/components/Select/hooks/useMultiSelect.d.ts.map +1 -0
- package/dist/lib/components/Select/hooks/useSelect.d.ts +23 -0
- package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -0
- package/dist/lib/components/Select/hooks/useSingleSelect.d.ts +30 -0
- package/dist/lib/components/Select/hooks/useSingleSelect.d.ts.map +1 -0
- package/dist/lib/components/Select/index.d.ts +38 -0
- package/dist/lib/components/Select/index.d.ts.map +1 -0
- package/dist/lib/components/Select/types.d.ts +31 -0
- package/dist/lib/components/Select/types.d.ts.map +1 -0
- package/dist/lib/components/TextField/TextField.d.ts.map +1 -1
- package/dist/lib/components/index.d.ts +3 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/context/ThemeContext.d.ts +1 -1
- package/dist/lib/context/ThemeContext.d.ts.map +1 -1
- package/dist/lib/context/index.d.ts +1 -1
- package/dist/lib/context/index.d.ts.map +1 -1
- package/dist/lib/hooks/index.d.ts +2 -1
- package/dist/lib/hooks/index.d.ts.map +1 -1
- package/dist/lib/hooks/useSSE.d.ts +21 -0
- package/dist/lib/hooks/useSSE.d.ts.map +1 -0
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/utils/axios.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/popover.js +329 -0
- package/dist/popover.js.map +1 -0
- package/dist/separator2.js +2 -2
- 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/shadcn/shadcnButton/Button.d.ts.map +1 -1
- package/dist/shadcn/shadcnInputOTP/InputOTP.d.ts +2 -2
- package/dist/shadcn/shadcnMultiSelect/index.d.ts +3 -0
- package/dist/shadcn/shadcnMultiSelect/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts +61 -0
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts.map +1 -0
- package/dist/shadcn/shadcnSingleSelect/index.d.ts +3 -0
- package/dist/shadcn/shadcnSingleSelect/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnSingleSelect/single-select.d.ts +60 -0
- package/dist/shadcn/shadcnSingleSelect/single-select.d.ts.map +1 -0
- package/dist/shadcn/shadcnSonner/sonner.d.ts +1 -1
- package/dist/shadcn/shadcnSonner/sonner.d.ts.map +1 -1
- package/dist/triangle-alert.js +40 -0
- package/dist/triangle-alert.js.map +1 -0
- package/dist/useSSE.js +82 -0
- package/dist/useSSE.js.map +1 -0
- package/dist/useTheme.js.map +1 -1
- package/dist/utils/axios.js +4167 -2
- package/dist/utils/axios.js.map +1 -1
- package/dist/utils.js +3748 -2970
- package/dist/utils.js.map +1 -1
- package/dist/utils2.js +3042 -0
- package/dist/utils2.js.map +1 -0
- package/dist/x.js +18 -0
- package/dist/x.js.map +1 -0
- package/package.json +22 -7
- package/dist/axios.js +0 -4228
- package/dist/axios.js.map +0 -1
package/dist/Form.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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
|
|
5
|
-
import {
|
|
4
|
+
import { c as cn } from './utils2.js';
|
|
5
|
+
import { axios } from './utils/axios.js';
|
|
6
|
+
import { A as Alert } from './Alert.js';
|
|
6
7
|
import { B as Button } from './Button.js';
|
|
7
8
|
import { C as Checkbox } from './Checkbox.js';
|
|
9
|
+
import { P as PhoneField } from './PhoneField.js';
|
|
8
10
|
import { S as Switch } from './Switch.js';
|
|
9
11
|
|
|
10
12
|
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
@@ -621,7 +623,7 @@ function mapApiErrorsToForm(error, form, options = {}) {
|
|
|
621
623
|
if (!error || typeof error !== "object") {
|
|
622
624
|
if (setRootError) {
|
|
623
625
|
form.setError("root", {
|
|
624
|
-
type: "
|
|
626
|
+
type: "Error",
|
|
625
627
|
message: "An error occurred"
|
|
626
628
|
});
|
|
627
629
|
}
|
|
@@ -630,34 +632,26 @@ function mapApiErrorsToForm(error, form, options = {}) {
|
|
|
630
632
|
const axiosError = error;
|
|
631
633
|
const errorData = axiosError.response?.data || error;
|
|
632
634
|
const apiError = errorData;
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
+
const errorTitle = apiError.label || apiError.title || "Error";
|
|
636
|
+
const generalMessage = apiError.detail;
|
|
635
637
|
if (apiError.errors && Array.isArray(apiError.errors)) {
|
|
636
638
|
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
|
-
}
|
|
639
|
+
const formField = fieldMapping[errorItem.field] || errorItem.field;
|
|
640
|
+
form.setError(formField, {
|
|
641
|
+
type: "manual",
|
|
642
|
+
message: errorItem.message
|
|
643
|
+
});
|
|
650
644
|
}
|
|
651
645
|
}
|
|
652
|
-
if (
|
|
646
|
+
if (generalMessage && setRootError) {
|
|
653
647
|
form.setError("root", {
|
|
654
|
-
type:
|
|
648
|
+
type: errorTitle,
|
|
655
649
|
message: generalMessage
|
|
656
650
|
});
|
|
657
651
|
}
|
|
658
652
|
}
|
|
659
653
|
|
|
660
|
-
function processChildren(children, control, isSubmitting) {
|
|
654
|
+
function processChildren(children, control, isSubmitting, setValue) {
|
|
661
655
|
return React.Children.map(children, (child) => {
|
|
662
656
|
if (!React.isValidElement(child)) {
|
|
663
657
|
return child;
|
|
@@ -674,11 +668,17 @@ function processChildren(children, control, isSubmitting) {
|
|
|
674
668
|
render: ({ field, fieldState }) => {
|
|
675
669
|
const isCheckbox = child.type === Checkbox;
|
|
676
670
|
const isSwitch = child.type === Switch;
|
|
671
|
+
const isPhone = child.type === PhoneField;
|
|
677
672
|
const fieldProps = isCheckbox || isSwitch ? {
|
|
678
673
|
checked: field.value,
|
|
679
674
|
onCheckedChange: field.onChange,
|
|
680
675
|
onBlur: field.onBlur,
|
|
681
676
|
ref: field.ref
|
|
677
|
+
} : isPhone ? {
|
|
678
|
+
...field,
|
|
679
|
+
onCountryChange: (country) => {
|
|
680
|
+
setValue(`${name}Country`, country);
|
|
681
|
+
}
|
|
682
682
|
} : field;
|
|
683
683
|
return React.cloneElement(child, {
|
|
684
684
|
...childProps,
|
|
@@ -702,12 +702,12 @@ function processChildren(children, control, isSubmitting) {
|
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
if (isFragment) {
|
|
705
|
-
return processChildren(childProps.children, control, isSubmitting);
|
|
705
|
+
return processChildren(childProps.children, control, isSubmitting, setValue);
|
|
706
706
|
}
|
|
707
707
|
if (childProps.children != null) {
|
|
708
708
|
return React.cloneElement(child, {
|
|
709
709
|
...childProps,
|
|
710
|
-
children: processChildren(childProps.children, control, isSubmitting)
|
|
710
|
+
children: processChildren(childProps.children, control, isSubmitting, setValue)
|
|
711
711
|
});
|
|
712
712
|
}
|
|
713
713
|
return child;
|
|
@@ -717,9 +717,10 @@ function Form({
|
|
|
717
717
|
form,
|
|
718
718
|
onSubmit,
|
|
719
719
|
children,
|
|
720
|
-
showRootError =
|
|
720
|
+
showRootError = false,
|
|
721
721
|
rootErrorPosition = "bottom",
|
|
722
722
|
rootErrorClassName,
|
|
723
|
+
rootErrorAction,
|
|
723
724
|
fieldMapping,
|
|
724
725
|
mutation,
|
|
725
726
|
transformSubmit,
|
|
@@ -728,6 +729,10 @@ function Form({
|
|
|
728
729
|
const isSubmitting = form.formState.isSubmitting || (mutation?.isPending ?? false);
|
|
729
730
|
const wrappedOnSubmit = React.useCallback(
|
|
730
731
|
async (data) => {
|
|
732
|
+
const interceptorId = axios.interceptors.request.use((config) => ({
|
|
733
|
+
...config,
|
|
734
|
+
showErrorToast: false
|
|
735
|
+
}));
|
|
731
736
|
try {
|
|
732
737
|
if (mutation) {
|
|
733
738
|
const variables = transformSubmit ? transformSubmit(data) : data;
|
|
@@ -741,16 +746,36 @@ function Form({
|
|
|
741
746
|
setRootError: showRootError
|
|
742
747
|
});
|
|
743
748
|
console.error("[Form Submission Error]", error);
|
|
749
|
+
} finally {
|
|
750
|
+
axios.interceptors.request.eject(interceptorId);
|
|
744
751
|
}
|
|
745
752
|
},
|
|
746
753
|
[onSubmit, mutation, transformSubmit, fieldMapping, form, showRootError]
|
|
747
754
|
);
|
|
748
755
|
const handleSubmit = form.handleSubmit(wrappedOnSubmit);
|
|
749
|
-
const processedChildren = processChildren(children, form.control, isSubmitting);
|
|
756
|
+
const processedChildren = processChildren(children, form.control, isSubmitting, form.setValue);
|
|
750
757
|
return /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, ...props, children: [
|
|
751
|
-
showRootError && rootErrorPosition === "top" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
758
|
+
showRootError && rootErrorPosition === "top" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
759
|
+
Alert,
|
|
760
|
+
{
|
|
761
|
+
variant: "destructive",
|
|
762
|
+
title: form.formState.errors.root.type || "Error",
|
|
763
|
+
description: form.formState.errors.root.message,
|
|
764
|
+
action: rootErrorAction,
|
|
765
|
+
className: cn("mb-4", rootErrorClassName)
|
|
766
|
+
}
|
|
767
|
+
),
|
|
752
768
|
processedChildren,
|
|
753
|
-
showRootError && rootErrorPosition === "bottom" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
769
|
+
showRootError && rootErrorPosition === "bottom" && form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
770
|
+
Alert,
|
|
771
|
+
{
|
|
772
|
+
variant: "destructive",
|
|
773
|
+
title: form.formState.errors.root.type || "Error",
|
|
774
|
+
description: form.formState.errors.root.message,
|
|
775
|
+
action: rootErrorAction,
|
|
776
|
+
className: cn("mt-4", rootErrorClassName)
|
|
777
|
+
}
|
|
778
|
+
)
|
|
754
779
|
] }) });
|
|
755
780
|
}
|
|
756
781
|
Form.displayName = "Form";
|