@ahmadmubarak98/namozaj 1.6.12 → 1.6.13

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