@ahmadmubarak98/namozaj 1.8.20 → 1.10.0

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,3 +1,4 @@
1
+ import { ButtonOwnProps } from '@mui/material';
1
2
  import { ButtonPropsSizeOverrides } from '@mui/material';
2
3
  import { ButtonPropsVariantOverrides } from '@mui/material';
3
4
  import { CountryIso2 } from 'react-international-phone';
@@ -50,8 +51,42 @@ export declare type BaseFormFieldProps = {
50
51
  locale?: string | undefined;
51
52
  };
52
53
 
54
+ export declare type BaseFormRepresentationalBlockProps = {
55
+ id?: string;
56
+ name: string;
57
+ config: NamozajRepresentationalBlock;
58
+ };
59
+
53
60
  export declare type BasePlacement = "top" | "bottom" | "right" | "left";
54
61
 
62
+ export declare type BaseRepresentationalBlockConfig = {
63
+ name: string;
64
+ type: "button";
65
+ meta: {
66
+ style?: React.CSSProperties;
67
+ className?: string;
68
+ hidden?: boolean;
69
+ fullRow?: boolean;
70
+ grid?: GridColumnConfig;
71
+ };
72
+ };
73
+
74
+ export declare type ButtonConfig = BaseRepresentationalBlockConfig & {
75
+ type: "button";
76
+ meta: BaseRepresentationalBlockConfig['meta'] & {
77
+ label: string;
78
+ variant?: ButtonOwnProps['variant'];
79
+ startIcon?: React.ReactNode | string;
80
+ size?: ButtonOwnProps['size'];
81
+ color?: ButtonOwnProps['color'];
82
+ endIcon?: React.ReactNode | string;
83
+ onClick: (formMethods: RHFFormMethods) => void | Promise<void>;
84
+ disabled?: boolean;
85
+ hidden?: boolean;
86
+ fullWidth?: boolean;
87
+ };
88
+ };
89
+
55
90
  export declare type ButtonFieldConfig = BaseFieldConfig & {
56
91
  type: "button";
57
92
  meta: BaseFieldConfig["meta"] & {
@@ -158,7 +193,7 @@ export declare type FieldOptionFetchFunction = (() => Promise<FieldOption[]>) |
158
193
 
159
194
  export declare type FieldSize = 'small' | 'medium';
160
195
 
161
- export declare type FieldType = "text" | "phone" | "number" | "slider" | "select" | "multi-select" | "checkbox-group" | "radio-group" | "checkbox" | "switch" | "date" | "time" | "datetime" | "file" | "repeater" | "field-array" | "group";
196
+ export declare type FieldType = "text" | "phone" | "number" | "slider" | "select" | "multi-select" | "checkbox-group" | "radio-group" | "checkbox" | "switch" | "date" | "time" | "datetime" | "file" | "repeater" | "field-array" | "group" | "button";
162
197
 
163
198
  export declare type FieldValueType = string | number | boolean | Date | File | (string | undefined)[] | ({
164
199
  [x: string]: any;
@@ -276,6 +311,8 @@ export declare type MultiSelectFieldConfig = BaseFieldConfig & {
276
311
 
277
312
  export declare const Namozaj: default_2.ForwardRefExoticComponent<NamozajProps & default_2.RefAttributes<any>>;
278
313
 
314
+ export declare type NamozajBlock = NamozajField | NamozajRepresentationalBlock;
315
+
279
316
  export declare type NamozajField = TextFieldConfig | NumberFieldConfig | SliderFieldConfig | PhoneFieldConfig | GroupFieldConfig | SelectFieldConfig | MultiSelectFieldConfig | CheckBoxGroupFieldConfig | RadioGroupFieldConfig | SwitchFieldConfig | CheckboxFieldConfig | DateFieldConfig | FileFieldConfig | ComputedFieldConfig | SectionFieldConfig | ButtonFieldConfig | RepeaterFieldConfig | FieldArrayFieldConfig;
280
317
 
281
318
  export declare type NamozajFormMethods = RHFFormMethods & {
@@ -330,6 +367,8 @@ export declare interface NamozajProps {
330
367
  onChange?: (data: any) => void;
331
368
  }
332
369
 
370
+ export declare type NamozajRepresentationalBlock = ButtonConfig;
371
+
333
372
  export declare type NamozajStepItem = {
334
373
  label: string;
335
374
  description?: React.ReactNode;
package/dist/namozaj.js CHANGED
@@ -1248,7 +1248,9 @@ function useForm(e = {}) {
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
1250
  "group"
1251
- ], FIELDS_TO_FLATTEN = ["group"], FIELDS_EXCLUDE_LABEL = [
1251
+ ], FIELDS_TO_FLATTEN = ["group"], FIELDS_EXCLUDE_AS_VALUE = [
1252
+ "button"
1253
+ ], FIELDS_EXCLUDE_LABEL = [
1252
1254
  "checkbox",
1253
1255
  "switch",
1254
1256
  "repeater",
@@ -6048,7 +6050,7 @@ addMethod(create$6, YUP_PHONE_METHOD, function(t, a) {
6048
6050
  });
6049
6051
  });
6050
6052
  const createYupSchema = (e) => {
6051
- const l = flattenFields(e).filter(
6053
+ const l = flattenFields(e).filter((c) => !FIELDS_EXCLUDE_AS_VALUE.includes(c.type) && c.name).filter(
6052
6054
  (c) => !FIELDS_EXCLUDE_VALIDATION.includes(c.type)
6053
6055
  ).reduce((c, p) => (c[p.name] = createFieldValidator(p), c), {});
6054
6056
  return create$3().shape(l);
@@ -86051,6 +86053,8 @@ const ConfirmationDialog = ({
86051
86053
  return /* @__PURE__ */ jsx(FieldArrayField, { ...D });
86052
86054
  case "group":
86053
86055
  return /* @__PURE__ */ jsx(GroupField, { ...D });
86056
+ case "button":
86057
+ return /* @__PURE__ */ jsx(GroupField, { ...D });
86054
86058
  default:
86055
86059
  return null;
86056
86060
  }
@@ -87614,7 +87618,12 @@ const Form = React__default.forwardRef(
87614
87618
  const { selectedLocales: a } = useLocalNamozajProvider(), [l, c] = useState(!0), [p, d] = useState(0), u = useMemo(
87615
87619
  () => createYupSchema(e.fields),
87616
87620
  [e, e.fields, (V = e.localization) == null ? void 0 : V.locales, createYupSchema]
87617
- ), b = useMemo(() => e.defaultValues ? e.defaultValues : getDefaultValues(e.fields), [e.fields, e.defaultValues]), h = useForm({
87621
+ ), b = useMemo(() => {
87622
+ let Z = e.fields.filter(
87623
+ (ce) => !FIELDS_EXCLUDE_AS_VALUE.includes(ce.type)
87624
+ );
87625
+ return e.defaultValues ? e.defaultValues : getDefaultValues(Z);
87626
+ }, [e.fields, e.defaultValues]), h = useForm({
87618
87627
  resolver: o(u),
87619
87628
  defaultValues: b,
87620
87629
  mode: e.validationMode || "onChange"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.8.20",
4
+ "version": "1.10.0",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",