@ahmadmubarak98/namozaj 1.6.65 → 1.6.67

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
@@ -67,6 +67,7 @@ export declare type CheckBoxGroupFieldConfig = BaseFieldConfig & {
67
67
  max?: number;
68
68
  horizontal?: boolean;
69
69
  options: FieldOption[] | FieldOptionFetchFunction;
70
+ eliminatedOptionValues?: EliminatedOptionValues;
70
71
  };
71
72
  };
72
73
 
@@ -97,6 +98,8 @@ export declare type DateMinMaxValue = {
97
98
  errorMessage?: string;
98
99
  } | null);
99
100
 
101
+ export declare type EliminatedOptionValues = string[] | number[] | ((formMethods: NamozajFormMethods) => string[] | number[]);
102
+
100
103
  export declare type FieldArrayFieldConfig = BaseFieldConfig & {
101
104
  type: "field-array";
102
105
  meta: BaseFieldConfig["meta"] & {
@@ -253,6 +256,7 @@ export declare type MultiSelectFieldConfig = BaseFieldConfig & {
253
256
  min?: number;
254
257
  max?: number;
255
258
  options: FieldOption[] | FieldOptionFetchFunction;
259
+ eliminatedOptionValues?: EliminatedOptionValues;
256
260
  searchable?: boolean;
257
261
  creatable?: boolean;
258
262
  clearable?: boolean;
@@ -383,6 +387,7 @@ export declare type RadioGroupFieldConfig = BaseFieldConfig & {
383
387
  meta: BaseFieldConfig["meta"] & {
384
388
  horizontal?: boolean;
385
389
  options: FieldOption[] | FieldOptionFetchFunction;
390
+ eliminatedOptionValues?: EliminatedOptionValues;
386
391
  };
387
392
  };
388
393
 
@@ -429,6 +434,7 @@ export declare type SelectFieldConfig = BaseFieldConfig & {
429
434
  min?: number;
430
435
  max?: number;
431
436
  options: FieldOption[] | FieldOptionFetchFunction;
437
+ eliminatedOptionValues?: EliminatedOptionValues;
432
438
  searchable?: boolean;
433
439
  creatable?: boolean;
434
440
  clearable?: boolean;
package/dist/namozaj.js CHANGED
@@ -6231,7 +6231,7 @@ function handleComparison(e, t, a) {
6231
6231
  }
6232
6232
  const getDefaultValue = (e) => {
6233
6233
  var t, a, l, c, p;
6234
- return e.type === "date" ? e.meta.defaultValue ? new Date(e.meta.defaultValue) : null : e.type === "checkbox" || e.type === "switch" ? e.meta.defaultValue === !0 : e.type === "checkbox-group" ? e.meta.defaultValue ?? [] : e.type === "multi-select" ? e.meta.defaultValue ?? [] : e.type === "time" || e.type === "datetime" ? e.meta.defaultValue ? new Date(e.meta.defaultValue) : /* @__PURE__ */ new Date() : e.type === "number" ? ((t = e.meta) == null ? void 0 : t.defaultValue) ?? null : e.type === "repeater" || e.type === "field-array" ? ((a = e.meta) == null ? void 0 : a.defaultValue) ?? [] : e.type === "file" ? e.meta.multiple ? ((l = e.meta) == null ? void 0 : l.defaultValue) ?? [] : ((c = e.meta) == null ? void 0 : c.defaultValue) ?? null : ((p = e.meta) == null ? void 0 : p.defaultValue) ?? "";
6234
+ return e.type === "date" ? e.meta.defaultValue ? new Date(e.meta.defaultValue) : null : e.type === "checkbox" || e.type === "switch" ? e.meta.defaultValue === !0 : e.type === "checkbox-group" ? e.meta.defaultValue ?? [] : e.type === "multi-select" ? e.meta.defaultValue ?? [] : e.type === "time" || e.type === "datetime" ? e.meta.defaultValue ? new Date(e.meta.defaultValue) : null : e.type === "number" ? ((t = e.meta) == null ? void 0 : t.defaultValue) ?? null : e.type === "repeater" || e.type === "field-array" ? ((a = e.meta) == null ? void 0 : a.defaultValue) ?? [] : e.type === "file" ? e.meta.multiple ? ((l = e.meta) == null ? void 0 : l.defaultValue) ?? [] : ((c = e.meta) == null ? void 0 : c.defaultValue) ?? null : ((p = e.meta) == null ? void 0 : p.defaultValue) ?? "";
6235
6235
  }, getDefaultValues = (e) => e.reduce((t, a) => (t[a.name] = getDefaultValue(a), t), {}), shouldRenderLabel = (e) => !FIELDS_EXCLUDE_LABEL.includes(e), shouldRenderHelperText = (e) => !FIELDS_EXCLUDE_HELPER_TEXT.includes(e), evaluateVisibilityRules = (visibilityRules, values) => {
6236
6236
  if (!visibilityRules) return !0;
6237
6237
  let isVisible = !0;
@@ -85794,14 +85794,28 @@ const ConfirmationDialog = ({
85794
85794
  return null;
85795
85795
  }
85796
85796
  }, y = () => {
85797
- var S, x, L, N, D;
85798
- "options" in e.meta && ((S = e.meta) != null && S.options) && (typeof ((x = e.meta) == null ? void 0 : x.options) == "function" ? Promise.resolve((L = e.meta) == null ? void 0 : L.options()).then(
85799
- (k) => {
85800
- a(e.name, k);
85801
- }
85802
- ) : Array.isArray((N = e.meta) == null ? void 0 : N.options) ? a(e.name, (D = e.meta) == null ? void 0 : D.options) : console.warn(
85803
- `Field ${e.name} has options but it's not a function or an array.`
85804
- ));
85797
+ var S, x, L, N, D, k, V, H;
85798
+ if ("options" in e.meta && ((S = e.meta) != null && S.options)) {
85799
+ let G = [];
85800
+ if ("eliminatedOptionValues" in e.meta && (G = (typeof ((x = e.meta) == null ? void 0 : x.eliminatedOptionValues) == "function" ? (L = e.meta) == null ? void 0 : L.eliminatedOptionValues(g) : (N = e.meta) == null ? void 0 : N.eliminatedOptionValues) ?? []), typeof ((D = e.meta) == null ? void 0 : D.options) == "function")
85801
+ Promise.resolve((k = e.meta) == null ? void 0 : k.options()).then(
85802
+ (te) => {
85803
+ let I = te;
85804
+ I = I.filter(
85805
+ (U) => !G.includes(U.value)
85806
+ ), a(e.name, I);
85807
+ }
85808
+ );
85809
+ else if (Array.isArray((V = e.meta) == null ? void 0 : V.options)) {
85810
+ let te = (H = e.meta) == null ? void 0 : H.options;
85811
+ te = te.filter(
85812
+ (I) => !G.includes(I.value)
85813
+ ), a(e.name, te);
85814
+ } else
85815
+ console.warn(
85816
+ `Field ${e.name} has options but it's not a function or an array.`
85817
+ );
85818
+ }
85805
85819
  };
85806
85820
  return useEffect(() => {
85807
85821
  var S;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ahmadmubarak98/namozaj",
3
3
  "private": false,
4
- "version": "1.6.65",
4
+ "version": "1.6.67",
5
5
  "type": "module",
6
6
  "main": "dist/namozaj.js",
7
7
  "types": "dist/main.d.ts",