@ahmadmubarak98/namozaj 1.6.11 → 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
@@ -46334,26 +46334,21 @@ const FileField = ({
46334
46334
  onChange: l,
46335
46335
  error: c
46336
46336
  }) => {
46337
- const { name: p, meta: d, type: u } = t, b = useFormContext(), h = (m) => {
46338
- const y = m.target.value;
46339
- l(y);
46340
- }, g = useCallback(
46341
- (m) => {
46342
- if (!(typeof m > "u" || m === null))
46343
- return typeof m == "function" ? m(b.watch(), b) : m;
46337
+ const { name: p, meta: d, type: u } = t, b = useFormContext(), h = useCallback(
46338
+ (C) => {
46339
+ if (!(typeof C > "u" || C === null))
46340
+ return typeof C == "function" ? C(b.watch(), b) : C;
46344
46341
  },
46345
46342
  [b, b == null ? void 0 : b.watch()]
46346
- );
46347
- return useEffect(() => {
46348
- const m = g(d.min), y = g(d.max);
46349
- a && (m && typeof m == "object" && a < m.value && b.setError(p, {
46350
- type: "manual",
46351
- message: m.errorMessage || `Value should be greater than ${m.value}`
46352
- }), y && typeof y == "object" && a > y.value && b.setError(p, {
46353
- type: "manual",
46354
- message: y.errorMessage || `Value should be less than ${y.value}`
46355
- }));
46356
- }, [a]), /* @__PURE__ */ jsx(
46343
+ ), g = h(d.min), m = h(d.max), y = (C) => {
46344
+ const v = C.target.value;
46345
+ if (v.trim() === "") {
46346
+ l(null);
46347
+ return;
46348
+ }
46349
+ /^-?\d*\.?\d+$/.test(v.trim()) ? (l(parseFloat(v)), typeof g == "object" && parseFloat(v) < g.value && (b.setValue(p, g.value), b.clearErrors(p)), typeof m == "object" && parseFloat(v) > m.value && (b.setValue(p, m.value), b.clearErrors(p))) : l(null);
46350
+ };
46351
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
46357
46352
  TextField$2,
46358
46353
  {
46359
46354
  id: e,
@@ -46368,16 +46363,16 @@ const FileField = ({
46368
46363
  endAdornment: d.endAdornment
46369
46364
  },
46370
46365
  htmlInput: {
46371
- min: g(d.min),
46372
- max: g(d.max),
46366
+ // min: typeof min === "object" ? min.value : min,
46367
+ // max: typeof max === "object" ? max.value : max,
46373
46368
  step: d.step
46374
46369
  }
46375
46370
  },
46376
46371
  value: a ?? "",
46377
- onChange: h,
46372
+ onChange: y,
46378
46373
  fullWidth: !0
46379
46374
  }
46380
- );
46375
+ ) });
46381
46376
  }, SliderField = ({ id: e, config: t, value: a, onChange: l }) => {
46382
46377
  const {
46383
46378
  meta: {
@@ -85026,7 +85021,8 @@ const _ = /* @__PURE__ */ getDefaultExportFromCjs(lodashExports), MultiSelectFie
85026
85021
  error: h.fieldState.error
85027
85022
  }) }),
85028
85023
  ((w = d.helperText) == null ? void 0 : w.content) && shouldRenderHelperText(e.type) && /* @__PURE__ */ jsx(Box, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...d.helperText }) }),
85029
- h.fieldState.error && h.fieldState.error.message && /* @__PURE__ */ jsx(FormHelperText$1, { error: !0, children: h.fieldState.error.message })
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)
85030
85026
  ]
85031
85027
  }
85032
85028
  ) : null;
@@ -85242,100 +85238,109 @@ const Form = React__default.forwardRef(
85242
85238
  }
85243
85239
  ), Namozaj = forwardRef(
85244
85240
  (e, t) => {
85245
- var d;
85241
+ var d, u, b;
85246
85242
  const [a, l] = useState(
85247
- ((d = e.localization) == null ? void 0 : d.locales) || []
85248
- ), c = (u, b) => {
85249
- var y, C, v;
85250
- const h = u.meta || {}, g = { ...u }, m = { ...h };
85251
- return g.name = getTranslatedFieldName(
85252
- u,
85253
- b,
85254
- (y = e.localization) == null ? void 0 : y.translatedFieldNameSuffix
85255
- ), m.label = getTranslatedFieldLabel(
85256
- u,
85257
- b,
85258
- (C = e.localization) == null ? void 0 : C.translatedLabel
85259
- ), m.grid = getTranslatedFieldGrid(
85260
- u,
85261
- 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,
85262
85258
  a,
85263
- (v = e.localization) == null ? void 0 : v.translatedFieldGrid
85264
- ), g.meta = m, g.locale = b, g;
85259
+ (S = e.localization) == null ? void 0 : S.translatedFieldGrid
85260
+ ), y.meta = C, y.locale = g, y;
85265
85261
  }, p = useMemo(() => {
85266
- var b, h, g, m;
85267
- const u = [];
85268
- if (e.fields.forEach((y) => {
85269
- const v = (y.meta || {}).translated || !1;
85270
- if (y.type === "field-array" || y.type === "repeater") {
85271
- const w = y.meta.fields || [], S = [];
85272
- w.forEach((x) => {
85273
- if (!(x.meta || {}).translated) {
85274
- 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);
85275
85271
  return;
85276
85272
  }
85277
- a == null || a.forEach((N) => {
85278
- const I = c(x, N);
85279
- S.push(I);
85273
+ a == null || a.forEach((k) => {
85274
+ const H = c(D, k);
85275
+ L.push(H);
85280
85276
  });
85281
- }), u.push({
85282
- ...y,
85277
+ }), h.push({
85278
+ ...v,
85283
85279
  meta: {
85284
- ...y.meta,
85285
- fields: S
85280
+ ...v.meta,
85281
+ fields: L
85286
85282
  }
85287
85283
  });
85288
85284
  return;
85289
85285
  }
85290
- if (!v) {
85291
- u.push(y);
85286
+ if (!S) {
85287
+ h.push(v);
85292
85288
  return;
85293
85289
  }
85294
- a == null || a.forEach((w) => {
85295
- const S = c(y, w);
85296
- u.push({
85297
- ...S
85290
+ a == null || a.forEach((x) => {
85291
+ const L = c(v, x);
85292
+ h.push({
85293
+ ...L
85298
85294
  });
85299
85295
  });
85300
- }), e.localization && a.length > 0 && ((b = e.localization) != null && b.localePicker)) {
85301
- const y = {
85302
- 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,
85303
85299
  type: "checkbox-group",
85304
85300
  meta: {
85305
- 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",
85306
85302
  defaultValue: a,
85307
85303
  horizontal: !0,
85308
85304
  min: 1,
85309
- options: async () => (a || []).map((C) => {
85310
- var v;
85311
- return {
85312
- label: ((v = e.localization) == null ? void 0 : v.localePicker).getLocaleLabel(
85313
- C
85314
- ) || C,
85315
- value: C
85316
- };
85317
- }),
85318
- onValueChange: (C, v) => {
85319
- var w, S, x;
85320
- l(C), (S = (w = e.localization) == null ? void 0 : w.localePicker) != null && S.onLocaleChange && ((x = e.localization) == null || x.localePicker.onLocaleChange(
85321
- C.sort((L, D) => {
85322
- var k, H;
85323
- 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;
85324
- 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;
85325
85324
  }),
85326
- v
85325
+ S
85327
85326
  ));
85328
85327
  },
85329
- grid: ((m = e.localization) == null ? void 0 : m.localePicker.grid) || {
85328
+ grid: ((C = e.localization) == null ? void 0 : C.localePicker.grid) || {
85330
85329
  xs: 12
85331
85330
  }
85332
85331
  }
85333
85332
  };
85334
- u.unshift(y);
85333
+ h.unshift(v);
85335
85334
  }
85336
- return u;
85335
+ return h;
85337
85336
  }, [e.fields, a, e.localization]);
85338
- 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(
85339
85344
  DynamicFormLocalProvider,
85340
85345
  {
85341
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.11",
4
+ "version": "1.6.13",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",