@ahmadmubarak98/namozaj 1.10.0 → 1.10.1

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
@@ -47,7 +47,7 @@ export declare type BaseFormFieldProps = {
47
47
  value: any;
48
48
  onChange: ((value: any) => void);
49
49
  error?: boolean;
50
- config: NamozajField;
50
+ config: NamozajBlock;
51
51
  locale?: string | undefined;
52
52
  };
53
53
 
@@ -68,6 +68,8 @@ export declare type BaseRepresentationalBlockConfig = {
68
68
  hidden?: boolean;
69
69
  fullRow?: boolean;
70
70
  grid?: GridColumnConfig;
71
+ visibilityRules?: VisibilityRule[];
72
+ step?: number | string;
71
73
  };
72
74
  };
73
75
 
@@ -338,7 +340,7 @@ export declare interface NamozajLocalizationOptions {
338
340
  export declare type NamozajPhoneFieldCountry = CountryIso2;
339
341
 
340
342
  export declare interface NamozajProps {
341
- fields: NamozajField[];
343
+ fields: (NamozajBlock)[];
342
344
  dirtyLock?: boolean;
343
345
  unloadConfirm?: boolean;
344
346
  localization?: NamozajLocalizationOptions;
package/dist/namozaj.js CHANGED
@@ -4,7 +4,7 @@ var K1 = (e, t, a) => ob(e, typeof t != "symbol" ? t + "" : t, a);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { useState, useEffect, useMemo, createContext, useContext, createElement, useCallback, isValidElement, cloneElement, Children, useRef, forwardRef, useImperativeHandle, useReducer, Fragment as Fragment$1, Component as Component$1, memo, useLayoutEffect } from "react";
7
- import { Stack, Box as Box$1, TextField as TextField$2, IconButton as IconButton$1, InputLabel as InputLabel$1, Autocomplete, Select as Select$1, Checkbox, MenuItem as MenuItem$1, InputAdornment as InputAdornment$1, Tooltip as Tooltip$1, FormControlLabel, FormGroup, FormControl as FormControl$1, RadioGroup, Radio, Switch, Typography as Typography$1, Avatar, CircularProgress as CircularProgress$1, Button as Button$1, Slider, Portal as Portal$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, FormHelperText as FormHelperText$1, Grid } from "@mui/material";
7
+ import { Stack, Box as Box$1, TextField as TextField$2, IconButton as IconButton$1, InputLabel as InputLabel$1, Autocomplete, Select as Select$1, Checkbox, MenuItem as MenuItem$1, InputAdornment as InputAdornment$1, Tooltip as Tooltip$1, FormControlLabel, FormGroup, FormControl as FormControl$1, RadioGroup, Radio, Switch, Typography as Typography$1, Avatar, CircularProgress as CircularProgress$1, Button as Button$2, Slider, Portal as Portal$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, FormHelperText as FormHelperText$1, Grid } from "@mui/material";
8
8
  import emStyled from "@emotion/styled";
9
9
  import { Global, ThemeContext, keyframes, css } from "@emotion/react";
10
10
  const defaultContextValue = {
@@ -1247,22 +1247,25 @@ function useForm(e = {}) {
1247
1247
  }, [e.shouldUnregister, p]), t.current.formState = getProxyFormState(l, p), t.current;
1248
1248
  }
1249
1249
  const DEFAULT_LOCALE_PICKER_FIELD_NAME = "localePicker_Field", DEFAULT_GRID_SIZE = 12, DEFAULT_FIELD_VARIANT = "outlined", DEFAULT_FIELD_SIZE = "medium", DEFAULT_TEXT_AREA_ROWS = 4, FIELDS_EXCLUDE_VALIDATION = [
1250
- "group"
1250
+ "group",
1251
+ "button"
1251
1252
  ], FIELDS_TO_FLATTEN = ["group"], FIELDS_EXCLUDE_AS_VALUE = [
1252
1253
  "button"
1253
- ], FIELDS_EXCLUDE_LABEL = [
1254
+ ], REPRSENTATIONAL_BLOCKS = ["button"], FIELDS_EXCLUDE_LABEL = [
1254
1255
  "checkbox",
1255
1256
  "switch",
1256
1257
  "repeater",
1257
1258
  "field-array",
1258
- "group"
1259
+ "group",
1260
+ "button"
1259
1261
  ], FIELDS_EXCLUDE_HELPER_TEXT = [
1260
1262
  "repeater",
1261
1263
  "field-array",
1262
1264
  "group"
1263
1265
  ], FIELDS_EXCLUDE_REPEATER_GRID_HEADER = [
1264
1266
  "repeater",
1265
- "group"
1267
+ "group",
1268
+ "button"
1266
1269
  ], EXTENSION_MIME_TYPE_MAP = {
1267
1270
  123: "application/vnd.lotus-1-2-3",
1268
1271
  "1km": "application/vnd.1000minds.decision-model+xml",
@@ -24684,7 +24687,7 @@ const useUtilityClasses$14 = (e) => {
24684
24687
  display: "inline-block",
24685
24688
  width: "1em",
24686
24689
  height: "1em"
24687
- }), Button = /* @__PURE__ */ React.forwardRef(function e(t, a) {
24690
+ }), Button$1 = /* @__PURE__ */ React.forwardRef(function e(t, a) {
24688
24691
  const l = React.useContext(ButtonGroupContext), c = React.useContext(ButtonGroupButtonContext), p = resolveProps(l, t), d = useDefaultProps({
24689
24692
  props: p,
24690
24693
  name: "MuiButton"
@@ -24769,7 +24772,7 @@ const useUtilityClasses$14 = (e) => {
24769
24772
  children: [re, N !== "end" && We, u, N === "end" && We, Z]
24770
24773
  });
24771
24774
  });
24772
- process.env.NODE_ENV !== "production" && (Button.propTypes = {
24775
+ process.env.NODE_ENV !== "production" && (Button$1.propTypes = {
24773
24776
  // ┌────────────────────────────── Warning ──────────────────────────────┐
24774
24777
  // │ These PropTypes are generated from the TypeScript type definitions. │
24775
24778
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
@@ -24982,22 +24985,22 @@ function PickersActionBar(e) {
24982
24985
  const b = p == null ? void 0 : p.map((h) => {
24983
24986
  switch (h) {
24984
24987
  case "clear":
24985
- return /* @__PURE__ */ jsx(Button, {
24988
+ return /* @__PURE__ */ jsx(Button$1, {
24986
24989
  onClick: a,
24987
24990
  children: u.clearButtonLabel
24988
24991
  }, h);
24989
24992
  case "cancel":
24990
- return /* @__PURE__ */ jsx(Button, {
24993
+ return /* @__PURE__ */ jsx(Button$1, {
24991
24994
  onClick: l,
24992
24995
  children: u.cancelButtonLabel
24993
24996
  }, h);
24994
24997
  case "accept":
24995
- return /* @__PURE__ */ jsx(Button, {
24998
+ return /* @__PURE__ */ jsx(Button$1, {
24996
24999
  onClick: t,
24997
25000
  children: u.okButtonLabel
24998
25001
  }, h);
24999
25002
  case "today":
25000
- return /* @__PURE__ */ jsx(Button, {
25003
+ return /* @__PURE__ */ jsx(Button$1, {
25001
25004
  onClick: c,
25002
25005
  children: u.todayButtonLabel
25003
25006
  }, h);
@@ -40311,7 +40314,7 @@ const pickersToolbarTextClasses = generateUtilityClasses("MuiPickersToolbarText"
40311
40314
  return composeClasses({
40312
40315
  root: ["root"]
40313
40316
  }, getPickersToolbarUtilityClass, t);
40314
- }, PickersToolbarButtonRoot = styled(Button, {
40317
+ }, PickersToolbarButtonRoot = styled(Button$1, {
40315
40318
  name: "MuiPickersToolbarButton",
40316
40319
  slot: "Root",
40317
40320
  overridesResolver: (e, t) => t.root
@@ -50946,7 +50949,7 @@ const FileField = ({
50946
50949
  Ne ? Ne.focus() : alert("Please allow popups for this website");
50947
50950
  }, a0 = () => /* @__PURE__ */ jsxs(Box$1, { display: "flex", flexDirection: "column", gap: 2, children: [
50948
50951
  /* @__PURE__ */ jsxs(
50949
- Button$1,
50952
+ Button$2,
50950
50953
  {
50951
50954
  loading: oe,
50952
50955
  loadingIndicator: C,
@@ -51084,7 +51087,7 @@ const FileField = ({
51084
51087
  }
51085
51088
  )
51086
51089
  ] }),
51087
- /* @__PURE__ */ jsxs(Button$1, { variant: "outlined", component: "label", fullWidth: !0, children: [
51090
+ /* @__PURE__ */ jsxs(Button$2, { variant: "outlined", component: "label", fullWidth: !0, children: [
51088
51091
  x,
51089
51092
  /* @__PURE__ */ jsx(
51090
51093
  "input",
@@ -51147,6 +51150,7 @@ const FileField = ({
51147
51150
  size: d.size || DEFAULT_FIELD_SIZE,
51148
51151
  type: "number",
51149
51152
  error: c,
51153
+ disabled: d.disabled,
51150
51154
  slotProps: {
51151
51155
  input: {
51152
51156
  startAdornment: d.startAdornment,
@@ -51261,8 +51265,8 @@ const FileField = ({
51261
51265
  ...a == null ? void 0 : a.dialogActions
51262
51266
  },
51263
51267
  children: [
51264
- /* @__PURE__ */ jsx(Button$1, { disabled: b, type: "button", onClick: C, children: c || "Cancel" }),
51265
- /* @__PURE__ */ jsx(Button$1, { loading: b, type: "button", onClick: v, children: p || d || e })
51268
+ /* @__PURE__ */ jsx(Button$2, { disabled: b, type: "button", onClick: C, children: c || "Cancel" }),
51269
+ /* @__PURE__ */ jsx(Button$2, { loading: b, type: "button", onClick: v, children: p || d || e })
51266
51270
  ]
51267
51271
  }
51268
51272
  )
@@ -85345,7 +85349,7 @@ const RowActions = ({
85345
85349
  onRemoveClick: d
85346
85350
  }) => /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: 1, children: [
85347
85351
  l && /* @__PURE__ */ jsx(
85348
- Button$1,
85352
+ Button$2,
85349
85353
  {
85350
85354
  onClick: () => p && p(e),
85351
85355
  variant: "outlined",
@@ -85355,7 +85359,7 @@ const RowActions = ({
85355
85359
  }
85356
85360
  ),
85357
85361
  c && /* @__PURE__ */ jsx(
85358
- Button$1,
85362
+ Button$2,
85359
85363
  {
85360
85364
  onClick: () => d && d(e),
85361
85365
  variant: "outlined",
@@ -85443,7 +85447,7 @@ const RowActions = ({
85443
85447
  addBtn: a,
85444
85448
  onAddClick: l
85445
85449
  }) => /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 2, justifyContent: "end", children: e.length > 0 && t && /* @__PURE__ */ jsx(
85446
- Button$1,
85450
+ Button$2,
85447
85451
  {
85448
85452
  type: "button",
85449
85453
  variant: "contained",
@@ -85599,10 +85603,10 @@ const ConfirmationDialog = ({
85599
85603
  /* @__PURE__ */ jsx(DialogTitle, { children: t }),
85600
85604
  /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogContentText, { children: a }) }),
85601
85605
  /* @__PURE__ */ jsxs(DialogActions, { children: [
85602
- /* @__PURE__ */ jsx(Button, { disabled: p, onClick: () => {
85606
+ /* @__PURE__ */ jsx(Button$1, { disabled: p, onClick: () => {
85603
85607
  u && typeof u == "function" && u();
85604
85608
  }, children: l || "Cancel" }),
85605
- /* @__PURE__ */ jsx(Button, { loading: p, onClick: () => {
85609
+ /* @__PURE__ */ jsx(Button$1, { loading: p, onClick: () => {
85606
85610
  d && typeof d == "function" && d();
85607
85611
  }, autoFocus: !0, children: c || "Confirm" })
85608
85612
  ] })
@@ -85744,7 +85748,7 @@ const ConfirmationDialog = ({
85744
85748
  children: [
85745
85749
  /* @__PURE__ */ jsx(Typography$1, { variant: "body1", children: t.meta.emptyMessage }),
85746
85750
  /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 1, mt: 1, children: Y && /* @__PURE__ */ jsx(
85747
- Button$1,
85751
+ Button$2,
85748
85752
  {
85749
85753
  variant: "outlined",
85750
85754
  size: "small",
@@ -85888,7 +85892,7 @@ const ConfirmationDialog = ({
85888
85892
  },
85889
85893
  children: [
85890
85894
  /* @__PURE__ */ jsx(Typography$1, { variant: "body1", children: t.meta.emptyMessage }),
85891
- /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 1, mt: 1, children: K && /* @__PURE__ */ jsx(Button$1, { variant: "outlined", size: "small", onClick: j, children: N }) })
85895
+ /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 1, mt: 1, children: K && /* @__PURE__ */ jsx(Button$2, { variant: "outlined", size: "small", onClick: j, children: N }) })
85892
85896
  ]
85893
85897
  }
85894
85898
  ),
@@ -85913,7 +85917,7 @@ const ConfirmationDialog = ({
85913
85917
  }
85914
85918
  ),
85915
85919
  k && !((we = d.unRemovableIndexes) != null && we.includes(ye)) && /* @__PURE__ */ jsx(
85916
- Button$1,
85920
+ Button$2,
85917
85921
  {
85918
85922
  variant: "outlined",
85919
85923
  color: "error",
@@ -85982,7 +85986,7 @@ const ConfirmationDialog = ({
85982
85986
  ] }, ve._id);
85983
85987
  }),
85984
85988
  /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 2, justifyContent: "end", children: h.fields.length > 0 && K && /* @__PURE__ */ jsx(
85985
- Button$1,
85989
+ Button$2,
85986
85990
  {
85987
85991
  type: "button",
85988
85992
  variant: "contained",
@@ -86010,6 +86014,28 @@ const ConfirmationDialog = ({
86010
86014
  )) }),
86011
86015
  ((p = a.helperText) == null ? void 0 : p.content) && /* @__PURE__ */ jsx(Box$1, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...a.helperText }) })
86012
86016
  ] }) });
86017
+ }, Button = (e) => {
86018
+ const { config: t } = e, { meta: a } = t, l = useFormContext(), c = useCallback(() => {
86019
+ var p;
86020
+ (p = a.onClick) == null || p.call(a, l);
86021
+ }, [a, l]);
86022
+ return /* @__PURE__ */ jsx(
86023
+ Button$2,
86024
+ {
86025
+ variant: a.variant || "contained",
86026
+ size: a.size || "medium",
86027
+ color: a.color || "primary",
86028
+ onClick: c,
86029
+ disabled: a.disabled,
86030
+ hidden: a.hidden,
86031
+ startIcon: a.startIcon,
86032
+ endIcon: a.endIcon,
86033
+ fullWidth: a.fullWidth,
86034
+ style: a.style,
86035
+ className: a.className,
86036
+ children: a.label
86037
+ }
86038
+ );
86013
86039
  }, FieldRenderer = (e) => {
86014
86040
  var C, v, T, S;
86015
86041
  const { fieldsOptions: t, setFieldOptions: a } = useLocalNamozajProvider(), l = useRef(`${e.name}`), [c, p] = useState(!0), d = e.meta || {}, u = e.locale, b = d.grid || {}, h = useController({
@@ -86054,7 +86080,7 @@ const ConfirmationDialog = ({
86054
86080
  case "group":
86055
86081
  return /* @__PURE__ */ jsx(GroupField, { ...D });
86056
86082
  case "button":
86057
- return /* @__PURE__ */ jsx(GroupField, { ...D });
86083
+ return /* @__PURE__ */ jsx(Button, { ...D });
86058
86084
  default:
86059
86085
  return null;
86060
86086
  }
@@ -86081,7 +86107,7 @@ const ConfirmationDialog = ({
86081
86107
  p(V && !H);
86082
86108
  }
86083
86109
  }, [(v = e.meta) == null ? void 0 : v.visibilityRules, (T = e.meta) == null ? void 0 : T.hidden, g == null ? void 0 : g.watch()]), useEffect(() => {
86084
- c || h.field.onChange(getDefaultValue(e));
86110
+ !c && !REPRSENTATIONAL_BLOCKS.includes(e.type) && h.field.onChange(getDefaultValue(e));
86085
86111
  }, [c]), useEffect(() => {
86086
86112
  l.current = `${e.name}-${generateFieldId()}`;
86087
86113
  }, []), c ? /* @__PURE__ */ jsxs(
@@ -86113,13 +86139,13 @@ const ConfirmationDialog = ({
86113
86139
  },
86114
86140
  onChange: (x) => {
86115
86141
  var L;
86116
- h.field.onChange(x), (L = d.onValueChange) == null || L.call(d, x, g);
86142
+ REPRSENTATIONAL_BLOCKS.includes(e.type) || (h.field.onChange(x), "onValueChange" in d && typeof d.onValueChange == "function" && ((L = d.onValueChange) == null || L.call(d, x, g)));
86117
86143
  },
86118
86144
  locale: u,
86119
86145
  value: h.field.value,
86120
86146
  error: h.fieldState.error
86121
86147
  }) }),
86122
- ((S = d.helperText) == null ? void 0 : S.content) && shouldRenderHelperText(e.type) && /* @__PURE__ */ jsx(Box$1, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...d.helperText }) }),
86148
+ "helperText" in d && ((S = d.helperText) == null ? void 0 : S.content) && shouldRenderHelperText(e.type) && /* @__PURE__ */ jsx(Box$1, { mt: 0.25, children: /* @__PURE__ */ jsx(HelperText, { ...d.helperText }) }),
86123
86149
  h.fieldState.error && h.fieldState.error.message && /* @__PURE__ */ jsx(FormHelperText$1, { error: !0, children: h.fieldState.error.message })
86124
86150
  ]
86125
86151
  }
@@ -87554,7 +87580,7 @@ function NamozajStepper({
87554
87580
  },
87555
87581
  children: [
87556
87582
  /* @__PURE__ */ jsx(
87557
- Button,
87583
+ Button$1,
87558
87584
  {
87559
87585
  onClick: S,
87560
87586
  disabled: N === 0 || D.disableBack,
@@ -87563,7 +87589,7 @@ function NamozajStepper({
87563
87589
  }
87564
87590
  ),
87565
87591
  N < a.length - 1 && /* @__PURE__ */ jsx(
87566
- Button,
87592
+ Button$1,
87567
87593
  {
87568
87594
  variant: "contained",
87569
87595
  onClick: T,
@@ -87586,7 +87612,7 @@ function NamozajStepper({
87586
87612
  sx: { mt: 2, display: "flex", justifyContent: "center", gap: 2 },
87587
87613
  children: [
87588
87614
  /* @__PURE__ */ jsx(
87589
- Button,
87615
+ Button$1,
87590
87616
  {
87591
87617
  onClick: S,
87592
87618
  disabled: e === 0 || L.disableBack,
@@ -87595,7 +87621,7 @@ function NamozajStepper({
87595
87621
  }
87596
87622
  ),
87597
87623
  e < a.length - 1 && /* @__PURE__ */ jsx(
87598
- Button,
87624
+ Button$1,
87599
87625
  {
87600
87626
  variant: "contained",
87601
87627
  onClick: T,
@@ -87616,7 +87642,11 @@ const Form = React__default.forwardRef(
87616
87642
  (e, t) => {
87617
87643
  var V, H, G, K, k, j, oe, Y, re;
87618
87644
  const { selectedLocales: a } = useLocalNamozajProvider(), [l, c] = useState(!0), [p, d] = useState(0), u = useMemo(
87619
- () => createYupSchema(e.fields),
87645
+ () => createYupSchema(
87646
+ e.fields.filter(
87647
+ (Z) => !REPRSENTATIONAL_BLOCKS.includes(Z.type)
87648
+ )
87649
+ ),
87620
87650
  [e, e.fields, (V = e.localization) == null ? void 0 : V.locales, createYupSchema]
87621
87651
  ), b = useMemo(() => {
87622
87652
  let Z = e.fields.filter(
@@ -87640,7 +87670,11 @@ const Form = React__default.forwardRef(
87640
87670
  We.forEach((ye) => {
87641
87671
  h.unregister(ye);
87642
87672
  });
87643
- const ve = e.defaultValues ?? getDefaultValues(e.fields);
87673
+ const ve = e.defaultValues ?? getDefaultValues(
87674
+ e.fields.filter(
87675
+ (ye) => !REPRSENTATIONAL_BLOCKS.includes(ye.type)
87676
+ )
87677
+ );
87644
87678
  Re.forEach((ye) => {
87645
87679
  const we = ve[ye];
87646
87680
  h.resetField(ye, {
@@ -87696,7 +87730,7 @@ const Form = React__default.forwardRef(
87696
87730
  ), S = () => {
87697
87731
  var Z, ce, We, Re, ve, ye, we, Ke, je, Xe, Ge;
87698
87732
  return /* @__PURE__ */ jsx(Fragment, { children: !((Z = e.submitButtonProps) != null && Z.hidden) && /* @__PURE__ */ jsx(
87699
- Button$1,
87733
+ Button$2,
87700
87734
  {
87701
87735
  loading: e.loading,
87702
87736
  loadingPosition: "start",
@@ -87793,7 +87827,7 @@ const Form = React__default.forwardRef(
87793
87827
  return useEffect(() => {
87794
87828
  var Z;
87795
87829
  if ((Z = e.stepper) != null && Z.advanceOnValidation) {
87796
- const We = e.fields.filter((Re) => !Re.meta.hidden).filter((Re) => {
87830
+ const We = e.fields.filter((Re) => !REPRSENTATIONAL_BLOCKS.includes(Re.type)).filter((Re) => !Re.meta.hidden).filter((Re) => {
87797
87831
  var ve;
87798
87832
  return Re.meta.visibilityRules && ((ve = Re.meta.visibilityRules) == null ? void 0 : ve.length) > 0 ? evaluateVisibilityRules(
87799
87833
  Re.meta.visibilityRules,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.10.0",
4
+ "version": "1.10.1",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",