@ahmadmubarak98/namozaj 1.6.12 → 1.6.14

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 CHANGED
@@ -296,6 +296,7 @@ export declare interface NamozajLocalizationOptions {
296
296
  localePicker?: {
297
297
  name?: string;
298
298
  label?: string;
299
+ defaultValue?: string[];
299
300
  getLocaleLabel: (locale: string) => string;
300
301
  onLocaleChange: (locale: string[], formMethods: any) => void;
301
302
  grid?: GridColumnConfig;
package/dist/namozaj.js CHANGED
@@ -85021,8 +85021,7 @@ const _ = /* @__PURE__ */ getDefaultExportFromCjs(lodashExports), MultiSelectFie
85021
85021
  error: h.fieldState.error
85022
85022
  }) }),
85023
85023
  ((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)
85024
+ h.fieldState.error && h.fieldState.error.message && /* @__PURE__ */ jsx(FormHelperText$1, { error: !0, children: h.fieldState.error.message })
85026
85025
  ]
85027
85026
  }
85028
85027
  ) : null;
@@ -85238,100 +85237,109 @@ const Form = React__default.forwardRef(
85238
85237
  }
85239
85238
  ), Namozaj = forwardRef(
85240
85239
  (e, t) => {
85241
- var d;
85240
+ var d, u, b;
85242
85241
  const [a, l] = useState(
85243
- ((d = e.localization) == null ? void 0 : d.locales) || []
85244
- ), c = (u, b) => {
85245
- var y, C, v;
85246
- const h = u.meta || {}, g = { ...u }, m = { ...h };
85247
- return g.name = getTranslatedFieldName(
85248
- u,
85249
- b,
85250
- (y = e.localization) == null ? void 0 : y.translatedFieldNameSuffix
85251
- ), m.label = getTranslatedFieldLabel(
85252
- u,
85253
- b,
85254
- (C = e.localization) == null ? void 0 : C.translatedLabel
85255
- ), m.grid = getTranslatedFieldGrid(
85256
- u,
85257
- b,
85242
+ ((u = (d = e.localization) == null ? void 0 : d.localePicker) == null ? void 0 : u.defaultValue) || []
85243
+ ), c = (h, g) => {
85244
+ var v, w, S;
85245
+ const m = h.meta || {}, y = { ...h }, C = { ...m };
85246
+ return y.name = getTranslatedFieldName(
85247
+ h,
85248
+ g,
85249
+ (v = e.localization) == null ? void 0 : v.translatedFieldNameSuffix
85250
+ ), C.label = getTranslatedFieldLabel(
85251
+ h,
85252
+ g,
85253
+ (w = e.localization) == null ? void 0 : w.translatedLabel
85254
+ ), C.grid = getTranslatedFieldGrid(
85255
+ h,
85256
+ g,
85258
85257
  a,
85259
- (v = e.localization) == null ? void 0 : v.translatedFieldGrid
85260
- ), g.meta = m, g.locale = b, g;
85258
+ (S = e.localization) == null ? void 0 : S.translatedFieldGrid
85259
+ ), y.meta = C, y.locale = g, y;
85261
85260
  }, p = useMemo(() => {
85262
- var b, h, g, m;
85263
- const u = [];
85264
- if (e.fields.forEach((y) => {
85265
- const v = (y.meta || {}).translated || !1;
85266
- if (y.type === "field-array" || y.type === "repeater") {
85267
- const w = y.meta.fields || [], S = [];
85268
- w.forEach((x) => {
85269
- if (!(x.meta || {}).translated) {
85270
- S.push(x);
85261
+ var g, m, y, C;
85262
+ const h = [];
85263
+ if (e.fields.forEach((v) => {
85264
+ const S = (v.meta || {}).translated || !1;
85265
+ if (v.type === "field-array" || v.type === "repeater") {
85266
+ const x = v.meta.fields || [], L = [];
85267
+ x.forEach((D) => {
85268
+ if (!(D.meta || {}).translated) {
85269
+ L.push(D);
85271
85270
  return;
85272
85271
  }
85273
- a == null || a.forEach((N) => {
85274
- const I = c(x, N);
85275
- S.push(I);
85272
+ a == null || a.forEach((k) => {
85273
+ const H = c(D, k);
85274
+ L.push(H);
85276
85275
  });
85277
- }), u.push({
85278
- ...y,
85276
+ }), h.push({
85277
+ ...v,
85279
85278
  meta: {
85280
- ...y.meta,
85281
- fields: S
85279
+ ...v.meta,
85280
+ fields: L
85282
85281
  }
85283
85282
  });
85284
85283
  return;
85285
85284
  }
85286
- if (!v) {
85287
- u.push(y);
85285
+ if (!S) {
85286
+ h.push(v);
85288
85287
  return;
85289
85288
  }
85290
- a == null || a.forEach((w) => {
85291
- const S = c(y, w);
85292
- u.push({
85293
- ...S
85289
+ a == null || a.forEach((x) => {
85290
+ const L = c(v, x);
85291
+ h.push({
85292
+ ...L
85294
85293
  });
85295
85294
  });
85296
- }), e.localization && a.length > 0 && ((b = e.localization) != null && b.localePicker)) {
85297
- const y = {
85298
- name: ((h = e.localization) == null ? void 0 : h.localePicker.name) || DEFAULT_LOCALE_PICKER_FIELD_NAME,
85295
+ }), e.localization && a.length > 0 && ((g = e.localization) != null && g.localePicker)) {
85296
+ const v = {
85297
+ name: ((m = e.localization) == null ? void 0 : m.localePicker.name) || DEFAULT_LOCALE_PICKER_FIELD_NAME,
85299
85298
  type: "checkbox-group",
85300
85299
  meta: {
85301
- label: ((g = e.localization) == null ? void 0 : g.localePicker.label) || "Select Input Locale",
85300
+ label: ((y = e.localization) == null ? void 0 : y.localePicker.label) || "Select Input Locale",
85302
85301
  defaultValue: a,
85303
85302
  horizontal: !0,
85304
85303
  min: 1,
85305
- options: async () => (a || []).map((C) => {
85306
- var v;
85307
- return {
85308
- label: ((v = e.localization) == null ? void 0 : v.localePicker).getLocaleLabel(
85309
- C
85310
- ) || C,
85311
- value: C
85312
- };
85313
- }),
85314
- onValueChange: (C, v) => {
85315
- var w, S, x;
85316
- l(C), (S = (w = e.localization) == null ? void 0 : w.localePicker) != null && S.onLocaleChange && ((x = e.localization) == null || x.localePicker.onLocaleChange(
85317
- C.sort((L, D) => {
85318
- var k, H;
85319
- const N = ((k = e.localization) == null ? void 0 : k.locales.indexOf(L)) || 0, I = ((H = e.localization) == null ? void 0 : H.locales.indexOf(D)) || 0;
85320
- return N - I;
85304
+ options: async () => {
85305
+ var w;
85306
+ return (((w = e.localization) == null ? void 0 : w.locales) || []).map((S) => {
85307
+ var x;
85308
+ return {
85309
+ label: ((x = e.localization) == null ? void 0 : x.localePicker).getLocaleLabel(
85310
+ S
85311
+ ) || S,
85312
+ value: S
85313
+ };
85314
+ });
85315
+ },
85316
+ onValueChange: (w, S) => {
85317
+ var x, L, D;
85318
+ l(w), (L = (x = e.localization) == null ? void 0 : x.localePicker) != null && L.onLocaleChange && ((D = e.localization) == null || D.localePicker.onLocaleChange(
85319
+ w.sort((N, I) => {
85320
+ var G, Y;
85321
+ const k = ((G = e.localization) == null ? void 0 : G.locales.indexOf(N)) || 0, H = ((Y = e.localization) == null ? void 0 : Y.locales.indexOf(I)) || 0;
85322
+ return k - H;
85321
85323
  }),
85322
- v
85324
+ S
85323
85325
  ));
85324
85326
  },
85325
- grid: ((m = e.localization) == null ? void 0 : m.localePicker.grid) || {
85327
+ grid: ((C = e.localization) == null ? void 0 : C.localePicker.grid) || {
85326
85328
  xs: 12
85327
85329
  }
85328
85330
  }
85329
85331
  };
85330
- u.unshift(y);
85332
+ h.unshift(v);
85331
85333
  }
85332
- return u;
85334
+ return h;
85333
85335
  }, [e.fields, a, e.localization]);
85334
- return /* @__PURE__ */ jsx(
85336
+ return useEffect(() => {
85337
+ var h, g, m;
85338
+ if ((h = e.localization) != null && h.localePicker) {
85339
+ const y = (m = (g = e.localization) == null ? void 0 : g.localePicker) == null ? void 0 : m.defaultValue;
85340
+ Array.isArray(y) ? l(y) : l([]);
85341
+ }
85342
+ }, [(b = e.localization) == null ? void 0 : b.localePicker]), /* @__PURE__ */ jsx(
85335
85343
  DynamicFormLocalProvider,
85336
85344
  {
85337
85345
  value: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.6.12",
4
+ "version": "1.6.14",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",