@ahmadmubarak98/namozaj 1.6.13 → 1.6.15
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/main.d.ts +1 -0
- package/dist/namozaj.js +29 -12
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export declare type DynamicFormField = TextFieldConfig | NumberFieldConfig | Sli
|
|
|
98
98
|
|
|
99
99
|
export declare interface DynamicFormProps {
|
|
100
100
|
fields: DynamicFormField[];
|
|
101
|
+
dirtyLock?: boolean;
|
|
101
102
|
localization?: NamozajLocalizationOptions;
|
|
102
103
|
emptyFormMessage?: string;
|
|
103
104
|
defaultValues?: Record<string, FieldValueType>;
|
package/dist/namozaj.js
CHANGED
|
@@ -80823,7 +80823,9 @@ const ConfirmationDialog = ({
|
|
|
80823
80823
|
try {
|
|
80824
80824
|
L(!0), u.onBeforeAdd && typeof u.onBeforeAdd == "function" && await u.onBeforeAdd(Ve, h);
|
|
80825
80825
|
const Ne = [...l, Ve];
|
|
80826
|
-
c(Ne), h.setValue(a, Ne
|
|
80826
|
+
c(Ne), h.setValue(a, Ne, {
|
|
80827
|
+
shouldDirty: !0
|
|
80828
|
+
}), Ke();
|
|
80827
80829
|
} catch {
|
|
80828
80830
|
} finally {
|
|
80829
80831
|
L(!1);
|
|
@@ -80836,7 +80838,9 @@ const ConfirmationDialog = ({
|
|
|
80836
80838
|
try {
|
|
80837
80839
|
L(!0), u.onBeforeEdit && typeof u.onBeforeEdit == "function" && await u.onBeforeEdit(Ve, h);
|
|
80838
80840
|
const je = [...l];
|
|
80839
|
-
je[Ne] = Ve, c(je), h.setValue(a, je
|
|
80841
|
+
je[Ne] = Ve, c(je), h.setValue(a, je, {
|
|
80842
|
+
shouldDirty: !0
|
|
80843
|
+
}), S(null), Ke();
|
|
80840
80844
|
} catch {
|
|
80841
80845
|
} finally {
|
|
80842
80846
|
L(!1);
|
|
@@ -80851,7 +80855,9 @@ const ConfirmationDialog = ({
|
|
|
80851
80855
|
const Ne = l[Ve];
|
|
80852
80856
|
u.onBeforeRemove && typeof u.onBeforeRemove == "function" && await u.onBeforeRemove(Ne, h);
|
|
80853
80857
|
const je = [...l];
|
|
80854
|
-
je.splice(Ve, 1), c(je), h.setValue(a, je
|
|
80858
|
+
je.splice(Ve, 1), c(je), h.setValue(a, je, {
|
|
80859
|
+
shouldDirty: !0
|
|
80860
|
+
}), S(null), Qe();
|
|
80855
80861
|
} catch {
|
|
80856
80862
|
} finally {
|
|
80857
80863
|
L(!1);
|
|
@@ -81018,7 +81024,9 @@ const ConfirmationDialog = ({
|
|
|
81018
81024
|
[l, a, u]
|
|
81019
81025
|
), Z = useCallback(
|
|
81020
81026
|
(be, ve) => {
|
|
81021
|
-
u.setValue(`${a}[${be}]`, ve
|
|
81027
|
+
u.setValue(`${a}[${be}]`, ve, {
|
|
81028
|
+
shouldDirty: !0
|
|
81029
|
+
});
|
|
81022
81030
|
},
|
|
81023
81031
|
[l]
|
|
81024
81032
|
), te = (be) => {
|
|
@@ -81027,9 +81035,16 @@ const ConfirmationDialog = ({
|
|
|
81027
81035
|
m(!1), C(null);
|
|
81028
81036
|
};
|
|
81029
81037
|
return useEffect(() => {
|
|
81030
|
-
l && Array.isArray(l) && l.length > 0
|
|
81031
|
-
|
|
81032
|
-
|
|
81038
|
+
if (l && Array.isArray(l) && l.length > 0)
|
|
81039
|
+
u.resetField(a, {
|
|
81040
|
+
defaultValue: l
|
|
81041
|
+
});
|
|
81042
|
+
else if (I && l.length < I) {
|
|
81043
|
+
const be = Array.from({ length: I }, (ve, Re) => d.fields.reduce((we, ye) => (we[ye.name] = u.watch()[`${a}[${Re}].${ye.name}`] || getDefaultValue(ye), we), {}));
|
|
81044
|
+
u.resetField(a, {
|
|
81045
|
+
defaultValue: be
|
|
81046
|
+
});
|
|
81047
|
+
}
|
|
81033
81048
|
}, []), /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Fieldset, { id: e, legend: /* @__PURE__ */ jsx(FieldLabel, { field: t }), children: [
|
|
81034
81049
|
h.fields.length === 0 && /* @__PURE__ */ jsxs(
|
|
81035
81050
|
Box,
|
|
@@ -85021,8 +85036,7 @@ const _ = /* @__PURE__ */ getDefaultExportFromCjs(lodashExports), MultiSelectFie
|
|
|
85021
85036
|
error: h.fieldState.error
|
|
85022
85037
|
}) }),
|
|
85023
85038
|
((w = d.helperText) == null ? void 0 : w.content) && shouldRenderHelperText(e.type) && /* @__PURE__ */ jsx(Box, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...d.helperText }) }),
|
|
85024
|
-
h.fieldState.error && h.fieldState.error.message && /* @__PURE__ */ jsx(FormHelperText$1, { error: !0, children: h.fieldState.error.message })
|
|
85025
|
-
JSON.stringify(h.fieldState.error)
|
|
85039
|
+
h.fieldState.error && h.fieldState.error.message && /* @__PURE__ */ jsx(FormHelperText$1, { error: !0, children: h.fieldState.error.message })
|
|
85026
85040
|
]
|
|
85027
85041
|
}
|
|
85028
85042
|
) : null;
|
|
@@ -85109,7 +85123,9 @@ const Form = React__default.forwardRef(
|
|
|
85109
85123
|
const j = e.defaultValues ?? getDefaultValues(e.fields);
|
|
85110
85124
|
V.forEach((Z) => {
|
|
85111
85125
|
const te = j[Z];
|
|
85112
|
-
c.
|
|
85126
|
+
c.resetField(Z, {
|
|
85127
|
+
defaultValue: te
|
|
85128
|
+
});
|
|
85113
85129
|
}), p.current = H;
|
|
85114
85130
|
} else
|
|
85115
85131
|
d.current = !0;
|
|
@@ -85119,7 +85135,7 @@ const Form = React__default.forwardRef(
|
|
|
85119
85135
|
var G;
|
|
85120
85136
|
({ ...H }, (G = e.onSubmit) == null || G.call(e, H));
|
|
85121
85137
|
}, b = async () => (await c.trigger()).valueOf(), h = () => {
|
|
85122
|
-
var H, G;
|
|
85138
|
+
var H, G, Y;
|
|
85123
85139
|
return /* @__PURE__ */ jsx(Fragment, { children: !((H = e.submitButtonProps) != null && H.hidden) && /* @__PURE__ */ jsx(
|
|
85124
85140
|
Button$1,
|
|
85125
85141
|
{
|
|
@@ -85128,7 +85144,8 @@ const Form = React__default.forwardRef(
|
|
|
85128
85144
|
variant: "contained",
|
|
85129
85145
|
color: "primary",
|
|
85130
85146
|
type: "submit",
|
|
85131
|
-
|
|
85147
|
+
disabled: (G = e.submitButtonProps) != null && G.disabled || e.dirtyLock ? Object.keys(c.formState.dirtyFields).length === 0 : !1,
|
|
85148
|
+
children: ((Y = e.submitButtonProps) == null ? void 0 : Y.label) || "Submit"
|
|
85132
85149
|
}
|
|
85133
85150
|
) });
|
|
85134
85151
|
}, g = () => /* @__PURE__ */ jsx(Fragment, {});
|