@ahmadmubarak98/namozaj 1.9.0 → 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
@@ -51,11 +51,30 @@ export declare type BaseFormFieldProps = {
51
51
  locale?: string | undefined;
52
52
  };
53
53
 
54
+ export declare type BaseFormRepresentationalBlockProps = {
55
+ id?: string;
56
+ name: string;
57
+ config: NamozajRepresentationalBlock;
58
+ };
59
+
54
60
  export declare type BasePlacement = "top" | "bottom" | "right" | "left";
55
61
 
56
- export declare type ButtonConfig = BaseFieldConfig & {
57
- type: "text";
58
- meta: Omit<BaseFieldConfig["meta"], 'defaultValue, placeholder, translated, validations, renderLabelRightSide, dependencies, onValueChange, compute'> & {
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;
59
78
  variant?: ButtonOwnProps['variant'];
60
79
  startIcon?: React.ReactNode | string;
61
80
  size?: ButtonOwnProps['size'];
@@ -292,7 +311,9 @@ export declare type MultiSelectFieldConfig = BaseFieldConfig & {
292
311
 
293
312
  export declare const Namozaj: default_2.ForwardRefExoticComponent<NamozajProps & default_2.RefAttributes<any>>;
294
313
 
295
- export declare type NamozajField = ButtonConfig | TextFieldConfig | NumberFieldConfig | SliderFieldConfig | PhoneFieldConfig | GroupFieldConfig | SelectFieldConfig | MultiSelectFieldConfig | CheckBoxGroupFieldConfig | RadioGroupFieldConfig | SwitchFieldConfig | CheckboxFieldConfig | DateFieldConfig | FileFieldConfig | ComputedFieldConfig | SectionFieldConfig | ButtonFieldConfig | RepeaterFieldConfig | FieldArrayFieldConfig;
314
+ export declare type NamozajBlock = NamozajField | NamozajRepresentationalBlock;
315
+
316
+ export declare type NamozajField = TextFieldConfig | NumberFieldConfig | SliderFieldConfig | PhoneFieldConfig | GroupFieldConfig | SelectFieldConfig | MultiSelectFieldConfig | CheckBoxGroupFieldConfig | RadioGroupFieldConfig | SwitchFieldConfig | CheckboxFieldConfig | DateFieldConfig | FileFieldConfig | ComputedFieldConfig | SectionFieldConfig | ButtonFieldConfig | RepeaterFieldConfig | FieldArrayFieldConfig;
296
317
 
297
318
  export declare type NamozajFormMethods = RHFFormMethods & {
298
319
  validateForm: () => Promise<boolean>;
@@ -346,6 +367,8 @@ export declare interface NamozajProps {
346
367
  onChange?: (data: any) => void;
347
368
  }
348
369
 
370
+ export declare type NamozajRepresentationalBlock = ButtonConfig;
371
+
349
372
  export declare type NamozajStepItem = {
350
373
  label: string;
351
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);
@@ -87616,7 +87618,12 @@ const Form = React__default.forwardRef(
87616
87618
  const { selectedLocales: a } = useLocalNamozajProvider(), [l, c] = useState(!0), [p, d] = useState(0), u = useMemo(
87617
87619
  () => createYupSchema(e.fields),
87618
87620
  [e, e.fields, (V = e.localization) == null ? void 0 : V.locales, createYupSchema]
87619
- ), 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({
87620
87627
  resolver: o(u),
87621
87628
  defaultValues: b,
87622
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.9.0",
4
+ "version": "1.10.0",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",