@ahmadmubarak98/namozaj 1.6.10 → 1.6.11

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,34 +46327,54 @@ 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);
46334
- };
46335
- return /* @__PURE__ */ jsx(
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 = (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;
46344
+ },
46345
+ [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(
46336
46357
  TextField$2,
46337
46358
  {
46338
46359
  id: e,
46339
- placeholder: p.placeholder,
46340
- variant: p.variant || DEFAULT_FIELD_VARIANT,
46341
- size: p.size || DEFAULT_FIELD_SIZE,
46360
+ placeholder: d.placeholder,
46361
+ variant: d.variant || DEFAULT_FIELD_VARIANT,
46362
+ size: d.size || DEFAULT_FIELD_SIZE,
46342
46363
  type: "number",
46343
46364
  error: c,
46344
46365
  slotProps: {
46345
46366
  input: {
46346
- startAdornment: p.startAdornment,
46347
- endAdornment: p.endAdornment
46367
+ startAdornment: d.startAdornment,
46368
+ endAdornment: d.endAdornment
46369
+ },
46370
+ htmlInput: {
46371
+ min: g(d.min),
46372
+ max: g(d.max),
46373
+ step: d.step
46348
46374
  }
46349
46375
  },
46350
- inputProps: {
46351
- min: p.min,
46352
- max: p.max,
46353
- step: p.step
46354
- },
46355
- InputProps: {},
46356
46376
  value: a ?? "",
46357
- onChange: u,
46377
+ onChange: h,
46358
46378
  fullWidth: !0
46359
46379
  }
46360
46380
  );
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.11",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",