@ahmadmubarak98/namozaj 1.6.10 → 1.6.12

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
@@ -311,12 +311,20 @@ export declare type NumberFieldConfig = BaseFieldConfig & {
311
311
  size?: FieldSize;
312
312
  startAdornment?: React.ReactNode | string;
313
313
  endAdornment?: React.ReactNode | string;
314
- min?: number;
315
- max?: number;
314
+ min?: NumberMinMaxValue;
315
+ max?: NumberMinMaxValue;
316
316
  step?: number;
317
317
  };
318
318
  };
319
319
 
320
+ export declare type NumberMinMaxValue = number | {
321
+ value: number | null;
322
+ errorMessage?: string;
323
+ } | ((data: any, formMethods: UseFormReturn<FieldValues, any, FieldValues>) => {
324
+ value: number | null;
325
+ errorMessage?: string;
326
+ } | null);
327
+
320
328
  export declare type Operand = "OR" | "AND";
321
329
 
322
330
  export declare type Operator = "=" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not-in" | "contains" | "not-contains" | "match" | "not-match" | "between" | "starts-with" | "not-starts-with";
package/dist/namozaj.js CHANGED
@@ -46327,37 +46327,52 @@ const FileField = ({
46327
46327
  d === "default" && Qe(),
46328
46328
  te && /* @__PURE__ */ jsx(Typography$1, { color: "error", mt: 1, children: te })
46329
46329
  ] });
46330
- }, NumberField = ({ id: e, config: t, value: a, onChange: l, error: c }) => {
46331
- const { meta: p, type: d } = t, u = (b) => {
46332
- const h = b.target.value;
46333
- l(h);
46330
+ }, NumberField = ({
46331
+ id: e,
46332
+ config: t,
46333
+ value: a,
46334
+ onChange: l,
46335
+ error: c
46336
+ }) => {
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;
46341
+ },
46342
+ [b, b == null ? void 0 : b.watch()]
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);
46334
46350
  };
46335
- return /* @__PURE__ */ jsx(
46351
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
46336
46352
  TextField$2,
46337
46353
  {
46338
46354
  id: e,
46339
- placeholder: p.placeholder,
46340
- variant: p.variant || DEFAULT_FIELD_VARIANT,
46341
- size: p.size || DEFAULT_FIELD_SIZE,
46355
+ placeholder: d.placeholder,
46356
+ variant: d.variant || DEFAULT_FIELD_VARIANT,
46357
+ size: d.size || DEFAULT_FIELD_SIZE,
46342
46358
  type: "number",
46343
46359
  error: c,
46344
46360
  slotProps: {
46345
46361
  input: {
46346
- startAdornment: p.startAdornment,
46347
- endAdornment: p.endAdornment
46362
+ startAdornment: d.startAdornment,
46363
+ endAdornment: d.endAdornment
46364
+ },
46365
+ htmlInput: {
46366
+ // min: typeof min === "object" ? min.value : min,
46367
+ // max: typeof max === "object" ? max.value : max,
46368
+ step: d.step
46348
46369
  }
46349
46370
  },
46350
- inputProps: {
46351
- min: p.min,
46352
- max: p.max,
46353
- step: p.step
46354
- },
46355
- InputProps: {},
46356
46371
  value: a ?? "",
46357
- onChange: u,
46372
+ onChange: y,
46358
46373
  fullWidth: !0
46359
46374
  }
46360
- );
46375
+ ) });
46361
46376
  }, SliderField = ({ id: e, config: t, value: a, onChange: l }) => {
46362
46377
  const {
46363
46378
  meta: {
@@ -85006,7 +85021,8 @@ const _ = /* @__PURE__ */ getDefaultExportFromCjs(lodashExports), MultiSelectFie
85006
85021
  error: h.fieldState.error
85007
85022
  }) }),
85008
85023
  ((w = d.helperText) == null ? void 0 : w.content) && shouldRenderHelperText(e.type) && /* @__PURE__ */ jsx(Box, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...d.helperText }) }),
85009
- 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)
85010
85026
  ]
85011
85027
  }
85012
85028
  ) : null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.6.10",
4
+ "version": "1.6.12",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",