@ahmadmubarak98/namozaj 1.10.1 → 1.11.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
@@ -114,6 +114,16 @@ export declare type CheckBoxGroupFieldConfig = BaseFieldConfig & {
114
114
  };
115
115
  };
116
116
 
117
+ export declare type ColorFieldConfig = BaseFieldConfig & {
118
+ type: "color";
119
+ meta: BaseFieldConfig["meta"] & {
120
+ variant?: FieldVariant;
121
+ size?: FieldSize;
122
+ startAdornment?: React.ReactNode | string;
123
+ step?: number;
124
+ };
125
+ };
126
+
117
127
  export declare type ComputedFieldConfig = BaseFieldConfig & {
118
128
  type: "computed";
119
129
  meta: BaseFieldConfig["meta"] & {
@@ -195,7 +205,7 @@ export declare type FieldOptionFetchFunction = (() => Promise<FieldOption[]>) |
195
205
 
196
206
  export declare type FieldSize = 'small' | 'medium';
197
207
 
198
- 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";
208
+ 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" | "color";
199
209
 
200
210
  export declare type FieldValueType = string | number | boolean | Date | File | (string | undefined)[] | ({
201
211
  [x: string]: any;
@@ -315,7 +325,7 @@ export declare const Namozaj: default_2.ForwardRefExoticComponent<NamozajProps &
315
325
 
316
326
  export declare type NamozajBlock = NamozajField | NamozajRepresentationalBlock;
317
327
 
318
- export declare type NamozajField = TextFieldConfig | NumberFieldConfig | SliderFieldConfig | PhoneFieldConfig | GroupFieldConfig | SelectFieldConfig | MultiSelectFieldConfig | CheckBoxGroupFieldConfig | RadioGroupFieldConfig | SwitchFieldConfig | CheckboxFieldConfig | DateFieldConfig | FileFieldConfig | ComputedFieldConfig | SectionFieldConfig | ButtonFieldConfig | RepeaterFieldConfig | FieldArrayFieldConfig;
328
+ export declare type NamozajField = TextFieldConfig | ColorFieldConfig | NumberFieldConfig | SliderFieldConfig | PhoneFieldConfig | GroupFieldConfig | SelectFieldConfig | MultiSelectFieldConfig | CheckBoxGroupFieldConfig | RadioGroupFieldConfig | SwitchFieldConfig | CheckboxFieldConfig | DateFieldConfig | FileFieldConfig | ComputedFieldConfig | SectionFieldConfig | ButtonFieldConfig | RepeaterFieldConfig | FieldArrayFieldConfig;
319
329
 
320
330
  export declare type NamozajFormMethods = RHFFormMethods & {
321
331
  validateForm: () => Promise<boolean>;
package/dist/namozaj.js CHANGED
@@ -86036,6 +86036,81 @@ const ConfirmationDialog = ({
86036
86036
  children: a.label
86037
86037
  }
86038
86038
  );
86039
+ }, ColorField = ({
86040
+ id: e,
86041
+ config: t,
86042
+ value: a,
86043
+ onChange: l,
86044
+ error: c
86045
+ }) => {
86046
+ const { name: p, meta: d } = t, u = useFormContext(), b = useRef(null), h = useMemo(
86047
+ () => _.debounce((y) => {
86048
+ l(y), u.setValue(p, y);
86049
+ }, 300),
86050
+ [l, u.setValue, p]
86051
+ ), g = (y) => {
86052
+ l(y.target.value);
86053
+ }, m = (y) => {
86054
+ h(y.target.value);
86055
+ };
86056
+ return /* @__PURE__ */ jsx(
86057
+ TextField$2,
86058
+ {
86059
+ id: e,
86060
+ placeholder: d.placeholder,
86061
+ variant: d.variant || DEFAULT_FIELD_VARIANT,
86062
+ size: d.size || DEFAULT_FIELD_SIZE,
86063
+ type: "text",
86064
+ error: c,
86065
+ disabled: d.disabled,
86066
+ value: a ?? "",
86067
+ onChange: g,
86068
+ fullWidth: !0,
86069
+ slotProps: {
86070
+ htmlInput: {
86071
+ maxLength: 7
86072
+ },
86073
+ input: {
86074
+ endAdornment: /* @__PURE__ */ jsxs(InputAdornment$1, { position: "end", children: [
86075
+ /* @__PURE__ */ jsx(
86076
+ Box$1,
86077
+ {
86078
+ role: "button",
86079
+ onClick: () => {
86080
+ var y;
86081
+ return (y = b.current) == null ? void 0 : y.click();
86082
+ },
86083
+ sx: {
86084
+ width: 24,
86085
+ height: 24,
86086
+ bgcolor: a || "#ffffff",
86087
+ border: "1px solid #ccc",
86088
+ borderRadius: 1,
86089
+ cursor: "pointer"
86090
+ }
86091
+ }
86092
+ ),
86093
+ /* @__PURE__ */ jsx(
86094
+ "input",
86095
+ {
86096
+ ref: b,
86097
+ type: "color",
86098
+ value: a || "#ffffff",
86099
+ onChange: m,
86100
+ style: {
86101
+ opacity: 0,
86102
+ width: 0,
86103
+ height: 0,
86104
+ pointerEvents: "none"
86105
+ },
86106
+ title: "Pick a color"
86107
+ }
86108
+ )
86109
+ ] })
86110
+ }
86111
+ }
86112
+ }
86113
+ );
86039
86114
  }, FieldRenderer = (e) => {
86040
86115
  var C, v, T, S;
86041
86116
  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({
@@ -86079,6 +86154,8 @@ const ConfirmationDialog = ({
86079
86154
  return /* @__PURE__ */ jsx(FieldArrayField, { ...D });
86080
86155
  case "group":
86081
86156
  return /* @__PURE__ */ jsx(GroupField, { ...D });
86157
+ case "color":
86158
+ return /* @__PURE__ */ jsx(ColorField, { ...D });
86082
86159
  case "button":
86083
86160
  return /* @__PURE__ */ jsx(Button, { ...D });
86084
86161
  default:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.10.1",
4
+ "version": "1.11.0",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",