@ahmadmubarak98/namozaj 1.6.16 → 1.6.18
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 -2
- package/dist/namozaj.js +34 -33
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -99,7 +99,6 @@ export declare type DynamicFormField = TextFieldConfig | NumberFieldConfig | Sli
|
|
|
99
99
|
export declare interface DynamicFormProps {
|
|
100
100
|
fields: DynamicFormField[];
|
|
101
101
|
dirtyLock?: boolean;
|
|
102
|
-
validLock?: boolean;
|
|
103
102
|
localization?: NamozajLocalizationOptions;
|
|
104
103
|
emptyFormMessage?: string;
|
|
105
104
|
defaultValues?: Record<string, FieldValueType>;
|
|
@@ -292,13 +291,13 @@ export declare const Namozaj: default_2.ForwardRefExoticComponent<DynamicFormPro
|
|
|
292
291
|
|
|
293
292
|
export declare interface NamozajLocalizationOptions {
|
|
294
293
|
locales: string[];
|
|
294
|
+
defaultSelectedLocales?: string[];
|
|
295
295
|
translatedLabel?: (label: string, locale: string) => string;
|
|
296
296
|
translatedFieldNameSuffix?: (locale: string) => string;
|
|
297
297
|
translatedFieldGrid?: (field: DynamicFormField, locale: string, selectedLocales: string[]) => GridColumnConfig;
|
|
298
298
|
localePicker?: {
|
|
299
299
|
name?: string;
|
|
300
300
|
label?: string;
|
|
301
|
-
defaultValue?: string[];
|
|
302
301
|
getLocaleLabel: (locale: string) => string;
|
|
303
302
|
onLocaleChange: (locale: string[], formMethods: any) => void;
|
|
304
303
|
grid?: GridColumnConfig;
|
package/dist/namozaj.js
CHANGED
|
@@ -85132,10 +85132,11 @@ const Form = React__default.forwardRef(
|
|
|
85132
85132
|
p.current = new Set(e.fields.map((H) => H.name));
|
|
85133
85133
|
}, [e.fields]);
|
|
85134
85134
|
const u = (H) => {
|
|
85135
|
-
var
|
|
85136
|
-
|
|
85135
|
+
var Y;
|
|
85136
|
+
let G = { ...H };
|
|
85137
|
+
delete G[DEFAULT_LOCALE_PICKER_FIELD_NAME], (Y = e.onSubmit) == null || Y.call(e, H), e.dirtyLock && c.reset(G);
|
|
85137
85138
|
}, b = async () => (await c.trigger()).valueOf(), h = () => {
|
|
85138
|
-
var H, G, Y;
|
|
85139
|
+
var H, G, Y, V;
|
|
85139
85140
|
return /* @__PURE__ */ jsx(Fragment, { children: !((H = e.submitButtonProps) != null && H.hidden) && /* @__PURE__ */ jsx(
|
|
85140
85141
|
Button$1,
|
|
85141
85142
|
{
|
|
@@ -85144,8 +85145,8 @@ const Form = React__default.forwardRef(
|
|
|
85144
85145
|
variant: "contained",
|
|
85145
85146
|
color: "primary",
|
|
85146
85147
|
type: "submit",
|
|
85147
|
-
disabled: (G = e.submitButtonProps)
|
|
85148
|
-
children: ((
|
|
85148
|
+
disabled: typeof ((G = e.submitButtonProps) == null ? void 0 : G.disabled) == "boolean" ? (Y = e.submitButtonProps) == null ? void 0 : Y.disabled : e.dirtyLock ? Object.keys(c.formState.dirtyFields).length === 0 : !1,
|
|
85149
|
+
children: ((V = e.submitButtonProps) == null ? void 0 : V.label) || "Submit"
|
|
85149
85150
|
}
|
|
85150
85151
|
) });
|
|
85151
85152
|
}, g = () => /* @__PURE__ */ jsx(Fragment, {});
|
|
@@ -85255,29 +85256,29 @@ const Form = React__default.forwardRef(
|
|
|
85255
85256
|
}
|
|
85256
85257
|
), Namozaj = forwardRef(
|
|
85257
85258
|
(e, t) => {
|
|
85258
|
-
var d, u
|
|
85259
|
+
var d, u;
|
|
85259
85260
|
const [a, l] = useState(
|
|
85260
|
-
((
|
|
85261
|
-
), c = (
|
|
85262
|
-
var v, w
|
|
85263
|
-
const
|
|
85264
|
-
return
|
|
85261
|
+
((d = e.localization) == null ? void 0 : d.defaultSelectedLocales) || []
|
|
85262
|
+
), c = (b, h) => {
|
|
85263
|
+
var C, v, w;
|
|
85264
|
+
const g = b.meta || {}, m = { ...b }, y = { ...g };
|
|
85265
|
+
return m.name = getTranslatedFieldName(
|
|
85266
|
+
b,
|
|
85265
85267
|
h,
|
|
85266
|
-
|
|
85267
|
-
|
|
85268
|
-
|
|
85268
|
+
(C = e.localization) == null ? void 0 : C.translatedFieldNameSuffix
|
|
85269
|
+
), y.label = getTranslatedFieldLabel(
|
|
85270
|
+
b,
|
|
85269
85271
|
h,
|
|
85270
|
-
|
|
85271
|
-
|
|
85272
|
-
|
|
85272
|
+
(v = e.localization) == null ? void 0 : v.translatedLabel
|
|
85273
|
+
), y.grid = getTranslatedFieldGrid(
|
|
85274
|
+
b,
|
|
85273
85275
|
h,
|
|
85274
|
-
g,
|
|
85275
85276
|
a,
|
|
85276
|
-
(
|
|
85277
|
-
),
|
|
85277
|
+
(w = e.localization) == null ? void 0 : w.translatedFieldGrid
|
|
85278
|
+
), m.meta = y, m.locale = h, m;
|
|
85278
85279
|
}, p = useMemo(() => {
|
|
85279
|
-
var g, m, y, C;
|
|
85280
|
-
const
|
|
85280
|
+
var h, g, m, y, C;
|
|
85281
|
+
const b = [];
|
|
85281
85282
|
if (e.fields.forEach((v) => {
|
|
85282
85283
|
const S = (v.meta || {}).translated || !1;
|
|
85283
85284
|
if (v.type === "field-array" || v.type === "repeater") {
|
|
@@ -85291,7 +85292,7 @@ const Form = React__default.forwardRef(
|
|
|
85291
85292
|
const H = c(D, k);
|
|
85292
85293
|
L.push(H);
|
|
85293
85294
|
});
|
|
85294
|
-
}),
|
|
85295
|
+
}), b.push({
|
|
85295
85296
|
...v,
|
|
85296
85297
|
meta: {
|
|
85297
85298
|
...v.meta,
|
|
@@ -85301,16 +85302,16 @@ const Form = React__default.forwardRef(
|
|
|
85301
85302
|
return;
|
|
85302
85303
|
}
|
|
85303
85304
|
if (!S) {
|
|
85304
|
-
|
|
85305
|
+
b.push(v);
|
|
85305
85306
|
return;
|
|
85306
85307
|
}
|
|
85307
85308
|
a == null || a.forEach((x) => {
|
|
85308
85309
|
const L = c(v, x);
|
|
85309
|
-
|
|
85310
|
+
b.push({
|
|
85310
85311
|
...L
|
|
85311
85312
|
});
|
|
85312
85313
|
});
|
|
85313
|
-
}), e.localization &&
|
|
85314
|
+
}), e.localization && ((h = e.localization) == null ? void 0 : h.locales.length) > 0 && ((g = e.localization) != null && g.localePicker)) {
|
|
85314
85315
|
const v = {
|
|
85315
85316
|
name: ((m = e.localization) == null ? void 0 : m.localePicker.name) || DEFAULT_LOCALE_PICKER_FIELD_NAME,
|
|
85316
85317
|
type: "checkbox-group",
|
|
@@ -85347,17 +85348,17 @@ const Form = React__default.forwardRef(
|
|
|
85347
85348
|
}
|
|
85348
85349
|
}
|
|
85349
85350
|
};
|
|
85350
|
-
|
|
85351
|
+
b.unshift(v);
|
|
85351
85352
|
}
|
|
85352
|
-
return
|
|
85353
|
+
return b;
|
|
85353
85354
|
}, [e.fields, a, e.localization]);
|
|
85354
85355
|
return useEffect(() => {
|
|
85355
|
-
var h, g
|
|
85356
|
-
if ((h = e.localization) != null && h.
|
|
85357
|
-
const
|
|
85358
|
-
Array.isArray(
|
|
85356
|
+
var b, h, g;
|
|
85357
|
+
if ((h = (b = e.localization) == null ? void 0 : b.defaultSelectedLocales) != null && h.length) {
|
|
85358
|
+
const m = (g = e.localization) == null ? void 0 : g.defaultSelectedLocales;
|
|
85359
|
+
Array.isArray(m) ? l(m) : l([]);
|
|
85359
85360
|
}
|
|
85360
|
-
}, [(
|
|
85361
|
+
}, [JSON.stringify((u = e.localization) == null ? void 0 : u.defaultSelectedLocales)]), /* @__PURE__ */ jsx(
|
|
85361
85362
|
DynamicFormLocalProvider,
|
|
85362
85363
|
{
|
|
85363
85364
|
value: {
|