@ahmadmubarak98/namozaj 1.8.3 → 1.8.5

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
@@ -1,6 +1,9 @@
1
+ import { ButtonPropsSizeOverrides } from '@mui/material';
2
+ import { ButtonPropsVariantOverrides } from '@mui/material';
1
3
  import { CountryIso2 } from 'react-international-phone';
2
4
  import { default as default_2 } from 'react';
3
5
  import { FieldValues } from 'react-hook-form';
6
+ import { OverridableStringUnion } from '@mui/types';
4
7
  import { ParsedCountry } from 'react-international-phone';
5
8
  import { PickersTimezone } from '@mui/x-date-pickers';
6
9
  import { SxProps } from '@mui/material';
@@ -24,6 +27,7 @@ export declare type BaseFieldConfig = {
24
27
  translated?: boolean;
25
28
  helperText?: HelperTextConfig;
26
29
  validations?: ValidationRule[];
30
+ renderLabelRightSide?: (formMethods: RHFFormMethods) => React.ReactNode;
27
31
  grid?: GridColumnConfig;
28
32
  fullRow?: boolean;
29
33
  className?: string;
@@ -295,6 +299,7 @@ export declare type NamozajPhoneFieldCountry = CountryIso2;
295
299
  export declare interface NamozajProps {
296
300
  fields: NamozajField[];
297
301
  dirtyLock?: boolean;
302
+ unloadConfirm?: boolean;
298
303
  localization?: NamozajLocalizationOptions;
299
304
  stepper?: NamozajStepperConfig;
300
305
  emptyFormMessage?: string;
@@ -474,11 +479,15 @@ export declare type SliderFieldConfig = BaseFieldConfig & {
474
479
 
475
480
  export declare interface SubmitButtonProps {
476
481
  label?: string;
477
- size?: "default" | "xs" | "sm" | "md" | "lg" | "xl";
482
+ size?: OverridableStringUnion<'small' | 'medium' | 'large', ButtonPropsSizeOverrides>;
478
483
  className?: string;
484
+ sx?: SxProps<Theme>;
485
+ color?: BaseColors;
486
+ variant?: OverridableStringUnion<'text' | 'outlined' | 'contained', ButtonPropsVariantOverrides>;
479
487
  buttonType?: "button" | "submit" | "reset";
480
488
  disabled?: boolean;
481
489
  hidden?: boolean;
490
+ fullWidth?: boolean;
482
491
  }
483
492
 
484
493
  export declare type SwitchFieldConfig = BaseFieldConfig & {
@@ -495,6 +504,7 @@ export declare type TextFieldConfig = BaseFieldConfig & {
495
504
  size?: FieldSize;
496
505
  maxLength?: number;
497
506
  minLength?: number;
507
+ showCharCount?: boolean;
498
508
  secured?: boolean;
499
509
  multiline?: boolean;
500
510
  rows?: number;
package/dist/namozaj.js CHANGED
@@ -10674,7 +10674,7 @@ const VisibilityIcon = createSvgIcon(/* @__PURE__ */ jsx("path", {
10674
10674
  fullWidth: !0
10675
10675
  }
10676
10676
  ),
10677
- l.maxLength && l.maxLength > 0 && /* @__PURE__ */ jsxs(
10677
+ l.showCharCount && l.maxLength && l.maxLength > 0 && /* @__PURE__ */ jsxs(
10678
10678
  InputLabel$1,
10679
10679
  {
10680
10680
  variant: "standard",
@@ -51208,30 +51208,43 @@ const FileField = ({
51208
51208
  ]
51209
51209
  }
51210
51210
  ), FieldLabel = ({ field: e, htmlFor: t }) => {
51211
- const a = e.meta.tooltip, l = useMemo(() => isFieldRequired(e), [e]);
51212
- return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
51213
- /* @__PURE__ */ jsxs(
51214
- Typography$1,
51215
- {
51216
- variant: "body1",
51217
- sx: {
51218
- fontWeight: 500,
51219
- fontSize: "0.875rem",
51220
- lineHeight: 1.5,
51221
- color: "#000"
51222
- },
51223
- component: "label",
51224
- htmlFor: t,
51225
- "aria-required": l,
51226
- children: [
51227
- e.meta.label,
51228
- " ",
51229
- l && /* @__PURE__ */ jsx("span", { style: { color: "red" }, children: "*" })
51230
- ]
51231
- }
51232
- ),
51233
- (a == null ? void 0 : a.text) && /* @__PURE__ */ jsx(Tooltip, { ...a })
51234
- ] });
51211
+ const a = useFormContext(), l = e.meta.tooltip, c = useMemo(() => isFieldRequired(e), [e]);
51212
+ return /* @__PURE__ */ jsxs(
51213
+ Stack,
51214
+ {
51215
+ direction: "row",
51216
+ justifyContent: "space-between",
51217
+ alignItems: "center",
51218
+ spacing: 0.5,
51219
+ flexWrap: "wrap",
51220
+ children: [
51221
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
51222
+ /* @__PURE__ */ jsxs(
51223
+ Typography$1,
51224
+ {
51225
+ variant: "body1",
51226
+ sx: {
51227
+ fontWeight: 500,
51228
+ fontSize: "0.875rem",
51229
+ lineHeight: 1.5,
51230
+ color: "#000"
51231
+ },
51232
+ component: "label",
51233
+ htmlFor: t,
51234
+ "aria-required": c,
51235
+ children: [
51236
+ e.meta.label,
51237
+ " ",
51238
+ c && /* @__PURE__ */ jsx("span", { style: { color: "red" }, children: "*" })
51239
+ ]
51240
+ }
51241
+ ),
51242
+ (l == null ? void 0 : l.text) && /* @__PURE__ */ jsx(Tooltip, { ...l })
51243
+ ] }),
51244
+ e.meta.renderLabelRightSide ? e.meta.renderLabelRightSide(a) : null
51245
+ ]
51246
+ }
51247
+ );
51235
51248
  };
51236
51249
  var LocalEventService = class {
51237
51250
  constructor() {
@@ -87576,17 +87589,22 @@ const Form = React__default.forwardRef(
87576
87589
  },
87577
87590
  [h]
87578
87591
  ), S = () => {
87579
- var K, ce, we, Re, ve;
87592
+ var K, ce, we, Re, ve, ye, We, je, Xe, Ue, Ge;
87580
87593
  return /* @__PURE__ */ jsx(Fragment, { children: !((K = e.submitButtonProps) != null && K.hidden) && /* @__PURE__ */ jsx(
87581
87594
  Button$1,
87582
87595
  {
87583
87596
  loading: e.loading,
87584
87597
  loadingPosition: "start",
87585
- variant: "contained",
87586
- color: "primary",
87587
- type: "submit",
87588
- disabled: typeof ((ce = e.submitButtonProps) == null ? void 0 : ce.disabled) == "boolean" ? (we = e.submitButtonProps) == null ? void 0 : we.disabled : (Re = e.stepper) != null && Re.advanceOnValidation ? l : v,
87589
- children: ((ve = e.submitButtonProps) == null ? void 0 : ve.label) || "Submit"
87598
+ variant: ((ce = e.submitButtonProps) == null ? void 0 : ce.variant) || "contained",
87599
+ color: ((we = e.submitButtonProps) == null ? void 0 : we.color) || "primary",
87600
+ type: ((Re = e.submitButtonProps) == null ? void 0 : Re.buttonType) || "submit",
87601
+ size: ((ve = e.submitButtonProps) == null ? void 0 : ve.size) || "medium",
87602
+ disabled: typeof ((ye = e.submitButtonProps) == null ? void 0 : ye.disabled) == "boolean" ? (We = e.submitButtonProps) == null ? void 0 : We.disabled : (je = e.stepper) != null && je.advanceOnValidation ? l : v,
87603
+ sx: {
87604
+ ...((Xe = e.submitButtonProps) == null ? void 0 : Xe.sx) || {}
87605
+ },
87606
+ fullWidth: (Ue = e.submitButtonProps) == null ? void 0 : Ue.fullWidth,
87607
+ children: ((Ge = e.submitButtonProps) == null ? void 0 : Ge.label) || "Submit"
87590
87608
  }
87591
87609
  ) });
87592
87610
  }, x = () => /* @__PURE__ */ jsx(Fragment, {});
@@ -87623,14 +87641,14 @@ const Form = React__default.forwardRef(
87623
87641
  });
87624
87642
  }, [e.error]), useEffect(() => {
87625
87643
  const K = (ce) => {
87626
- if (h.formState.isDirty && (ce.preventDefault(), !window.confirm()))
87644
+ if (h.formState.isDirty && e.unloadConfirm && (ce.preventDefault(), !window.confirm()))
87627
87645
  return history.pushState(null, "", window.location.href), !1;
87628
87646
  };
87629
87647
  if (!e.isNested)
87630
87648
  return window.addEventListener("beforeunload", K), () => {
87631
87649
  window.removeEventListener("beforeunload", K);
87632
87650
  };
87633
- }, [h.formState.isDirty]);
87651
+ }, [h.formState.isDirty, e.unloadConfirm]);
87634
87652
  const N = (K) => /* @__PURE__ */ jsx(Grid, { container: !0, spacing: 2, children: (K || []).map((ce, we) => /* @__PURE__ */ jsx(Fragment$1, { children: ce.meta.fullRow ? /* @__PURE__ */ jsx(
87635
87653
  Grid,
87636
87654
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.8.3",
4
+ "version": "1.8.5",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",