@isettingkit/business-rules 0.1.11 → 0.1.12

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.
@@ -1,5 +1,8 @@
1
+ import { IInputStatus } from '@isettingkit/input';
1
2
  import { IRuleDecision } from '@isettingkit/input';
2
3
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
+ import { ValueDataType } from '@isettingkit/input';
5
+ import { ValueHowToSetUp } from '@isettingkit/input';
3
6
 
4
7
  export declare const BusinessRuleCard: (props: IBusinessRuleCard) => JSX_2.Element;
5
8
 
@@ -13,10 +16,37 @@ export declare interface IBusinessRuleCard {
13
16
  }
14
17
 
15
18
  export declare interface IBusinessRuleView {
16
- decision: IRuleDecision;
19
+ decision: IRuleDecision_2;
17
20
  textValues: IRulesFormTextValues;
18
21
  }
19
22
 
23
+ declare interface ICondition {
24
+ description: string;
25
+ valueUse: (typeof ValueHowToSetUp)[keyof typeof ValueHowToSetUp];
26
+ name: string;
27
+ value?: string | string[] | number | IValue | undefined;
28
+ dataType: (typeof ValueDataType)[keyof typeof ValueDataType];
29
+ }
30
+
31
+ declare interface IDecision {
32
+ description: string;
33
+ endDate?: Date;
34
+ valueUse: (typeof ValueHowToSetUp)[keyof typeof ValueHowToSetUp];
35
+ name: string;
36
+ value?: string | string[] | number | IValue | undefined;
37
+ startDate?: Date;
38
+ dataType: (typeof ValueDataType)[keyof typeof ValueDataType];
39
+ }
40
+
41
+ declare interface IRuleDecision_2 {
42
+ id?: string;
43
+ conditions?: ICondition[];
44
+ decision?: IDecision;
45
+ decisions?: IDecision[];
46
+ startDate?: Date;
47
+ endDate?: Date;
48
+ }
49
+
20
50
  export declare interface IRulesForm {
21
51
  id: string;
22
52
  decision: IRuleDecision;
@@ -44,6 +74,20 @@ declare interface IRulesFormTextValues {
44
74
  termStart: string;
45
75
  }
46
76
 
77
+ declare interface IValue {
78
+ list?: string[];
79
+ listSelected?: string[];
80
+ labelFrom?: string;
81
+ labelTo?: string;
82
+ from?: number | string | Date;
83
+ to?: number | string | Date;
84
+ value?: string | number;
85
+ messageFrom?: string;
86
+ messageTo?: string;
87
+ statusFrom?: IInputStatus;
88
+ statusTo?: IInputStatus;
89
+ }
90
+
47
91
  export declare const RulesForm: (prop: IRulesForm) => JSX_2.Element;
48
92
 
49
93
  export { }
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import { jsxs as u, jsx as n, Fragment as A } from "react/jsx-runtime";
1
+ import { jsxs as m, jsx as n, Fragment as j } from "react/jsx-runtime";
2
2
  import { useFormik as Q } from "formik";
3
- import { useState as v, useEffect as q } from "react";
3
+ import { useState as y, useEffect as q } from "react";
4
4
  import { Divider as E } from "@inubekit/divider";
5
- import { Stack as i } from "@inubekit/stack";
5
+ import { Stack as o } from "@inubekit/stack";
6
6
  import { Text as x } from "@inubekit/text";
7
7
  import { Toggle as $ } from "@inubekit/toggle";
8
- import { ValueHowToSetUp as C, DecisionConditionRenderer as j, ValueDataType as U } from "@isettingkit/input";
8
+ import { ValueHowToSetUp as f, DecisionConditionRenderer as L, ValueDataType as U } from "@isettingkit/input";
9
9
  import { Textarea as P } from "@inubekit/textarea";
10
10
  import { Date as z } from "@inubekit/date";
11
11
  import { Checkbox as Z } from "@inubekit/checkbox";
@@ -20,24 +20,24 @@ const X = (t) => {
20
20
  const {
21
21
  label: e,
22
22
  labelText: a,
23
- onHandleChange: o,
24
- placeholder: l,
25
- required: m,
26
- value: g = ""
27
- } = t, [s, b] = v(g);
28
- return /* @__PURE__ */ u(i, { direction: "column", margin: "10px 4px", children: [
23
+ onHandleChange: i,
24
+ placeholder: c,
25
+ required: g,
26
+ value: l = ""
27
+ } = t, [d, b] = y(l);
28
+ return /* @__PURE__ */ m(o, { direction: "column", margin: "10px 4px", children: [
29
29
  /* @__PURE__ */ n(x, { size: "large", appearance: "gray", weight: "bold", margin: "10px 0", children: a }),
30
- /* @__PURE__ */ n(i, { margin: "10px 0", children: /* @__PURE__ */ n(
30
+ /* @__PURE__ */ n(o, { margin: "10px 0", children: /* @__PURE__ */ n(
31
31
  P,
32
32
  {
33
33
  id: "reasonChange",
34
34
  label: e,
35
35
  onChange: (p) => {
36
- b(p.target.value), o(p);
36
+ b(p.target.value), i(p);
37
37
  },
38
- placeholder: l,
39
- required: m,
40
- value: s,
38
+ placeholder: c,
39
+ required: g,
40
+ value: d,
41
41
  maxLength: 120,
42
42
  fullwidth: !0
43
43
  }
@@ -47,46 +47,46 @@ const X = (t) => {
47
47
  const {
48
48
  checked: e,
49
49
  children: a,
50
- handleToggleChange: o,
51
- id: l,
52
- labelToggle: m,
53
- name: g,
54
- valueToggle: s = ""
55
- } = t, [b, f] = v(e), p = (S) => {
56
- f(S.target.checked), o(S);
50
+ handleToggleChange: i,
51
+ id: c,
52
+ labelToggle: g,
53
+ name: l,
54
+ valueToggle: d = ""
55
+ } = t, [b, C] = y(e), p = (v) => {
56
+ C(v.target.checked), i(v);
57
57
  };
58
58
  return q(() => {
59
- f(e);
60
- }, [e]), /* @__PURE__ */ u(A, { children: [
61
- /* @__PURE__ */ n(i, { children: /* @__PURE__ */ n(
59
+ C(e);
60
+ }, [e]), /* @__PURE__ */ m(j, { children: [
61
+ /* @__PURE__ */ n(o, { children: /* @__PURE__ */ n(
62
62
  $,
63
63
  {
64
64
  checked: b,
65
- id: l,
65
+ id: c,
66
66
  margin: "10px",
67
- name: g,
67
+ name: l,
68
68
  onChange: p,
69
69
  size: "small",
70
- value: s,
71
- children: /* @__PURE__ */ n(x, { size: "medium", type: "label", weight: "bold", children: m })
70
+ value: d,
71
+ children: /* @__PURE__ */ n(x, { size: "medium", type: "label", weight: "bold", children: g })
72
72
  }
73
73
  ) }),
74
- b && /* @__PURE__ */ n(A, { children: a })
74
+ b && /* @__PURE__ */ n(j, { children: a })
75
75
  ] });
76
76
  }, ee = (t) => {
77
77
  const {
78
78
  onHandleStartChange: e,
79
79
  onHandleEndChange: a,
80
- labelStart: o,
81
- labelEnd: l,
82
- checkedClosed: m = !1,
83
- required: g = !1,
84
- valueStart: s = "",
80
+ labelStart: i,
81
+ labelEnd: c,
82
+ checkedClosed: g = !1,
83
+ required: l = !1,
84
+ valueStart: d = "",
85
85
  valueEnd: b = ""
86
- } = t, [f, p] = v(m), [S, k] = v(s), [T, w] = v(b);
87
- return /* @__PURE__ */ u(A, { children: [
88
- /* @__PURE__ */ u(i, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
89
- /* @__PURE__ */ n(i, { children: /* @__PURE__ */ n(
86
+ } = t, [C, p] = y(g), [v, k] = y(d), [T, D] = y(b);
87
+ return /* @__PURE__ */ m(j, { children: [
88
+ /* @__PURE__ */ m(o, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
89
+ /* @__PURE__ */ n(o, { children: /* @__PURE__ */ n(
90
90
  x,
91
91
  {
92
92
  appearance: "gray",
@@ -98,7 +98,7 @@ const X = (t) => {
98
98
  }
99
99
  ) }),
100
100
  /* @__PURE__ */ n(
101
- i,
101
+ o,
102
102
  {
103
103
  alignContent: "center",
104
104
  justifyContent: "center",
@@ -108,76 +108,76 @@ const X = (t) => {
108
108
  Z,
109
109
  {
110
110
  label: "Cerrada",
111
- onChange: ({ target: c }) => {
112
- p(c.checked);
111
+ onChange: ({ target: s }) => {
112
+ p(s.checked);
113
113
  },
114
- checked: f,
114
+ checked: C,
115
115
  value: ""
116
116
  }
117
117
  )
118
118
  }
119
119
  )
120
120
  ] }),
121
- /* @__PURE__ */ u(i, { justifyContent: "space-between", gap: "24px", children: [
122
- /* @__PURE__ */ n(i, { width: "189px", children: /* @__PURE__ */ n(
121
+ /* @__PURE__ */ m(o, { justifyContent: "space-between", gap: "24px", children: [
122
+ /* @__PURE__ */ n(o, { width: "189px", children: /* @__PURE__ */ n(
123
123
  z,
124
124
  {
125
125
  id: "dateStart",
126
- label: o,
127
- onChange: (c) => {
128
- k(c.target.value), e(c);
126
+ label: i,
127
+ onChange: (s) => {
128
+ k(s.target.value), e(s);
129
129
  },
130
- value: S,
131
- required: g,
130
+ value: v,
131
+ required: l,
132
132
  size: "compact"
133
133
  }
134
134
  ) }),
135
- f && /* @__PURE__ */ n(i, { width: "189px", children: /* @__PURE__ */ n(
135
+ C && /* @__PURE__ */ n(o, { width: "189px", children: /* @__PURE__ */ n(
136
136
  z,
137
137
  {
138
138
  id: "dateEnd",
139
- label: l,
140
- onChange: (c) => {
141
- w(c.target.value), a(c);
139
+ label: c,
140
+ onChange: (s) => {
141
+ D(s.target.value), a(s);
142
142
  },
143
143
  value: T,
144
- required: g,
144
+ required: l,
145
145
  size: "compact"
146
146
  }
147
147
  ) })
148
148
  ] })
149
149
  ] });
150
- }, _ = (t) => {
151
- var l;
152
- const e = t.possibleValue, a = typeof (e == null ? void 0 : e.rangeFrom) == "number" ? e.rangeFrom : 0, o = typeof (e == null ? void 0 : e.rangeTo) == "number" ? e.rangeTo : 1 / 0;
150
+ }, N = (t) => {
151
+ var c;
152
+ const e = t.possibleValue, a = typeof (e == null ? void 0 : e.rangeFrom) == "number" ? e.rangeFrom : 0, i = typeof (e == null ? void 0 : e.rangeTo) == "number" ? e.rangeTo : 1 / 0;
153
153
  switch (t.howToSetUp) {
154
- case C.LIST_OF_VALUES:
154
+ case f.LIST_OF_VALUES:
155
155
  return {
156
156
  schema: F(),
157
- value: (l = e.listSelected) == null ? void 0 : l[0]
157
+ value: (c = e.listSelected) == null ? void 0 : c[0]
158
158
  };
159
- case C.LIST_OF_VALUES_MULTI:
159
+ case f.LIST_OF_VALUES_MULTI:
160
160
  return {
161
161
  schema: F(),
162
162
  value: ""
163
163
  };
164
- case C.RANGE:
164
+ case f.RANGE:
165
165
  return {
166
166
  schema: B({
167
167
  rangeFrom: H().required("Range From is required").max(
168
- o,
168
+ i,
169
169
  "'Range From' cannot be greater than 'Range To'"
170
170
  ).min(0, "'Range From' cannot be less than 0"),
171
171
  rangeTo: H().required("Range To is required").min(a, "'Range To' cannot be less than 'Range From'").min(0, "'Range To' cannot be less than 0")
172
172
  }),
173
173
  value: {
174
174
  rangeFrom: a,
175
- rangeTo: o
175
+ rangeTo: i
176
176
  }
177
177
  };
178
- case C.GREATER_THAN:
179
- case C.LESS_THAN:
180
- case C.EQUAL:
178
+ case f.GREATER_THAN:
179
+ case f.LESS_THAN:
180
+ case f.EQUAL:
181
181
  return {
182
182
  schema: F().required("Required"),
183
183
  value: e.value
@@ -191,14 +191,14 @@ const X = (t) => {
191
191
  }, ne = (t) => {
192
192
  const e = {}, a = {};
193
193
  if (t.decision) {
194
- const o = _(t.decision);
195
- o && (e[t.decision.name] = o.schema, a[t.decision.name] = o.value);
194
+ const i = N(t.decision);
195
+ i && (e[t.decision.name] = i.schema, a[t.decision.name] = i.value);
196
196
  }
197
- return t.conditions && t.conditions.forEach((o) => {
198
- const l = _(o);
199
- l && (e[o.name] = l.schema, a[o.name] = l.value);
197
+ return t.conditions && t.conditions.forEach((i) => {
198
+ const c = N(i);
199
+ c && (e[i.name] = c.schema, a[i.name] = c.value);
200
200
  }), { validationSchema: B().shape(e), initialValues: a };
201
- }, L = (t) => {
201
+ }, R = (t) => {
202
202
  if (typeof t == "string")
203
203
  return t;
204
204
  if (typeof t == "object" && ("rangeFrom" in t || "rangeTo" in t))
@@ -208,48 +208,48 @@ const X = (t) => {
208
208
  };
209
209
  for (const e in t)
210
210
  if (Object.prototype.hasOwnProperty.call(t, e)) {
211
- const a = L(t[e]);
211
+ const a = R(t[e]);
212
212
  if (a) return a;
213
213
  }
214
214
  return "";
215
215
  }, te = (t) => {
216
- var c;
216
+ var s;
217
217
  const {
218
218
  decision: e,
219
219
  formik: a,
220
- onChangeCondition: o,
221
- onChangeDecision: l,
222
- onStartChange: m,
223
- onEndChange: g,
224
- textValues: s,
220
+ onChangeCondition: i,
221
+ onChangeDecision: c,
222
+ onStartChange: g,
223
+ onEndChange: l,
224
+ textValues: d,
225
225
  onCancel: b,
226
- onSubmit: f
227
- } = t, [p, S] = v(!1), [k, T] = v(!0);
226
+ onSubmit: C
227
+ } = t, [p, v] = y(!1), [k, T] = y(!0);
228
228
  q(() => {
229
229
  console.log("Updated formik.errors in RulesFormUI:", a.errors);
230
230
  }, [a.errors]);
231
- const w = (r) => {
232
- S(r.target.checked);
233
- }, y = (r) => {
231
+ const D = (r) => {
232
+ v(r.target.checked);
233
+ }, w = (r) => {
234
234
  r.target.value ? T(!1) : T(!0);
235
- }, D = (r) => {
236
- const h = L(a.errors[r] || {});
235
+ }, S = (r) => {
236
+ const h = R(a.errors[r] || {});
237
237
  return typeof h == "string" ? h ? "invalid" : "pending" : h;
238
- }, d = (r) => {
239
- const h = L(a.errors[r] || {});
238
+ }, u = (r) => {
239
+ const h = R(a.errors[r] || {});
240
240
  return h;
241
241
  };
242
- return /* @__PURE__ */ u(i, { direction: "column", gap: "24px", children: [
243
- /* @__PURE__ */ u(i, { direction: "column", gap: "16", children: [
244
- /* @__PURE__ */ n(x, { weight: "bold", size: "medium", children: s.criteria }),
242
+ return /* @__PURE__ */ m(o, { direction: "column", gap: "24px", children: [
243
+ /* @__PURE__ */ m(o, { direction: "column", gap: "16", children: [
244
+ /* @__PURE__ */ n(x, { weight: "bold", size: "medium", children: d.criteria }),
245
245
  e.decision && /* @__PURE__ */ n(
246
- j,
246
+ L,
247
247
  {
248
248
  element: e.decision,
249
- onDecision: l,
249
+ onDecision: c,
250
250
  valueData: a.values[e.decision.name],
251
251
  message: a.errors[e.decision.name],
252
- status: D(e.decision.name),
252
+ status: S(e.decision.name),
253
253
  textValues: {
254
254
  selectOptions: "Select an option",
255
255
  selectOption: "Option selected",
@@ -260,26 +260,26 @@ const X = (t) => {
260
260
  )
261
261
  ] }),
262
262
  /* @__PURE__ */ n(E, { dashed: !0 }),
263
- /* @__PURE__ */ u(i, { direction: "column", children: [
264
- /* @__PURE__ */ u(i, { direction: "row", gap: "16px", justifyContent: "space-between", children: [
265
- /* @__PURE__ */ n(x, { children: s.factsThatConditionIt }),
263
+ /* @__PURE__ */ m(o, { direction: "column", children: [
264
+ /* @__PURE__ */ m(o, { direction: "row", gap: "16px", justifyContent: "space-between", children: [
265
+ /* @__PURE__ */ n(x, { children: d.factsThatConditionIt }),
266
266
  /* @__PURE__ */ n(
267
267
  $,
268
268
  {
269
269
  id: "toogleNone",
270
- onChange: w,
270
+ onChange: D,
271
271
  checked: p,
272
272
  size: "small",
273
- children: /* @__PURE__ */ n(x, { size: "medium", type: "label", weight: "bold", children: s.none })
273
+ children: /* @__PURE__ */ n(x, { size: "medium", type: "label", weight: "bold", children: d.none })
274
274
  }
275
275
  )
276
276
  ] }),
277
- e.conditions && e.conditions.map((r) => /* @__PURE__ */ n(i, { direction: "column", children: /* @__PURE__ */ n(
277
+ e.conditions && e.conditions.map((r) => /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
278
278
  Y,
279
279
  {
280
280
  checked: !p,
281
281
  handleToggleChange: (h) => {
282
- h.target.checked || o(
282
+ h.target.checked || i(
283
283
  {
284
284
  value: "",
285
285
  rangeTo: 0,
@@ -293,13 +293,13 @@ const X = (t) => {
293
293
  labelToggle: r.name.split(/(?=[A-Z])/).join(" "),
294
294
  name: r.name.replace(" ", ""),
295
295
  children: /* @__PURE__ */ n(
296
- j,
296
+ L,
297
297
  {
298
298
  element: r,
299
- onDecision: o,
299
+ onDecision: i,
300
300
  valueData: a.values[r.name],
301
- message: d(r.name),
302
- status: D(r.name),
301
+ message: u(r.name),
302
+ status: S(r.name),
303
303
  textValues: {
304
304
  selectOptions: "Select an option",
305
305
  selectOption: "Option selected",
@@ -312,152 +312,154 @@ const X = (t) => {
312
312
  ) }, r.name))
313
313
  ] }),
314
314
  /* @__PURE__ */ n(E, { dashed: !0 }),
315
- /* @__PURE__ */ n(i, { direction: "column", children: /* @__PURE__ */ n(
315
+ /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
316
316
  X,
317
317
  {
318
- label: s.reasonForChange,
319
- labelText: s.change,
320
- onHandleChange: y,
321
- placeholder: s.changePlaceholder,
318
+ label: d.reasonForChange,
319
+ labelText: d.change,
320
+ onHandleChange: w,
321
+ placeholder: d.changePlaceholder,
322
322
  required: !0
323
323
  }
324
324
  ) }),
325
325
  /* @__PURE__ */ n(E, { dashed: !0 }),
326
- /* @__PURE__ */ n(i, { direction: "column", children: e.decision && /* @__PURE__ */ n(
326
+ /* @__PURE__ */ n(o, { direction: "column", children: e.decision && /* @__PURE__ */ n(
327
327
  ee,
328
328
  {
329
- onHandleStartChange: (r) => m(r.target.value),
330
- onHandleEndChange: (r) => g(r.target.value),
331
- labelStart: s.termStart,
332
- labelEnd: s.termEnd,
329
+ onHandleStartChange: (r) => g(r.target.value),
330
+ onHandleEndChange: (r) => l(r.target.value),
331
+ labelStart: d.termStart,
332
+ labelEnd: d.termEnd,
333
333
  checkedClosed: !!e.decision.endDate,
334
334
  valueStart: e.decision.startDate.toLocaleDateString(
335
335
  "en-CA"
336
336
  ),
337
- valueEnd: ((c = e.decision.endDate) == null ? void 0 : c.toLocaleDateString("en-CA")) || ""
337
+ valueEnd: ((s = e.decision.endDate) == null ? void 0 : s.toLocaleDateString("en-CA")) || ""
338
338
  }
339
339
  ) }),
340
340
  /* @__PURE__ */ n(E, { dashed: !0 }),
341
- /* @__PURE__ */ u(i, { direction: "row", justifyContent: "end", gap: "16px", children: [
342
- /* @__PURE__ */ n(M, { appearance: "gray", onClick: b, children: s.cancel }),
341
+ /* @__PURE__ */ m(o, { direction: "row", justifyContent: "end", gap: "16px", children: [
342
+ /* @__PURE__ */ n(M, { appearance: "gray", onClick: b, children: d.cancel }),
343
343
  /* @__PURE__ */ n(
344
344
  M,
345
345
  {
346
- onClick: f,
346
+ onClick: C,
347
347
  disabled: k || !a.isValid,
348
348
  type: "submit",
349
- children: s.confirm
349
+ children: d.confirm
350
350
  }
351
351
  )
352
352
  ] })
353
353
  ] });
354
- }, De = (t) => {
355
- const { id: e, decision: a, onCancel: o, onSubmitEvent: l, textValues: m } = t, [g, s] = v(a), b = (d, c) => {
356
- y.setFieldValue(d, c), y.validateField(d);
357
- }, f = (d, c) => {
358
- s((r) => {
359
- var O;
360
- const h = (O = r == null ? void 0 : r.conditions) == null ? void 0 : O.map((R) => R.name === c ? { ...R, value: d } : R);
361
- return b(c, d), { ...r, conditions: h };
354
+ }, Se = (t) => {
355
+ const { id: e, decision: a, onCancel: i, onSubmitEvent: c, textValues: g } = t, [l, d] = y(a), b = (u, s) => {
356
+ w.setFieldValue(u, s), w.validateField(u);
357
+ }, C = (u, s) => {
358
+ d((r) => {
359
+ var A;
360
+ const h = (A = r == null ? void 0 : r.conditions) == null ? void 0 : A.map((O) => O.name === s ? { ...O, value: u } : O);
361
+ return b(s, u), { ...r, conditions: h };
362
362
  });
363
- }, p = (d) => {
364
- s(
365
- (c) => D(c, "value", d)
363
+ }, p = (u) => {
364
+ d(
365
+ (s) => S(s, "value", u)
366
366
  );
367
- }, S = (d) => {
368
- s(
369
- (c) => D(c, "endDate", new Date(d))
367
+ }, v = (u) => {
368
+ d(
369
+ (s) => S(s, "endDate", new Date(u))
370
370
  );
371
- }, k = (d) => {
372
- s(
373
- (c) => D(c, "startDate", new Date(d))
371
+ }, k = (u) => {
372
+ d(
373
+ (s) => S(s, "startDate", new Date(u))
374
374
  );
375
- }, { validationSchema: T, initialValues: w } = ne(g);
376
- T.validate(w, { abortEarly: !1 }).then(() => console.log("Validation passed")).catch((d) => console.log("Validation failed:", d.errors));
377
- const y = Q({
378
- initialValues: w,
375
+ }, { validationSchema: T, initialValues: D } = ne(l);
376
+ T.validate(D, { abortEarly: !1 }).then(() => console.log("Validation passed")).catch((u) => console.log("Validation failed:", u.errors));
377
+ const w = Q({
378
+ initialValues: D,
379
379
  validationSchema: T,
380
380
  validateOnChange: !0,
381
381
  validateOnBlur: !0,
382
382
  onSubmit: () => {
383
- l(g);
383
+ c(l);
384
384
  }
385
- }), D = (d, c, r) => ({
386
- ...d,
387
- decision: { ...d.decision, [c]: r }
385
+ }), S = (u, s, r) => ({
386
+ ...u,
387
+ decision: { ...u.decision, [s]: r }
388
388
  });
389
389
  return /* @__PURE__ */ n(
390
390
  te,
391
391
  {
392
392
  id: e,
393
- formik: y,
394
- decision: g,
395
- onCancel: o,
396
- onSubmit: () => l(g),
397
- onChangeCondition: f,
393
+ formik: w,
394
+ decision: l,
395
+ onCancel: i,
396
+ onSubmit: () => c(l),
397
+ onChangeCondition: C,
398
398
  onChangeDecision: p,
399
399
  onStartChange: k,
400
- onEndChange: S,
401
- textValues: m
400
+ onEndChange: v,
401
+ textValues: g
402
402
  }
403
403
  );
404
- }, N = (t) => {
404
+ }, _ = (t) => {
405
405
  if (!t)
406
406
  return;
407
- const e = t.value || t.possibleValue;
407
+ const e = t.value;
408
408
  if (!e)
409
409
  return;
410
- if (((o) => typeof o == "object" && o !== null)(e))
411
- switch (t.howToSetUp) {
412
- case C.LIST_OF_VALUES_MULTI:
413
- return e.listSelected;
414
- case C.LIST_OF_VALUES:
415
- return e.listSelected ?? e.list;
416
- case C.RANGE:
410
+ if (((i) => typeof i == "object" && i !== null)(e))
411
+ switch (t.valueUse) {
412
+ case f.LIST_OF_VALUES_MULTI:
413
+ return e;
414
+ case f.LIST_OF_VALUES:
415
+ return e;
416
+ case f.RANGE:
417
417
  return {
418
- rangeFrom: e.rangeFrom,
419
- rangeTo: e.rangeTo
418
+ from: e.from,
419
+ to: e.to
420
420
  };
421
421
  default:
422
422
  return e.value;
423
423
  }
424
424
  return e;
425
- }, we = (t) => {
426
- var o, l;
427
- const { decision: e, textValues: a } = t;
428
- return /* @__PURE__ */ u(i, { direction: "column", gap: "24px", children: [
429
- /* @__PURE__ */ u(i, { direction: "column", gap: "16px", children: [
425
+ }, De = (t) => {
426
+ var c, g;
427
+ const { decision: e, textValues: a } = t, i = (l) => l && Object.keys(l).length > 0;
428
+ return /* @__PURE__ */ m(o, { direction: "column", gap: "24px", children: [
429
+ /* @__PURE__ */ m(o, { direction: "column", gap: "16px", children: [
430
430
  /* @__PURE__ */ n(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: a.criteria }),
431
- /* @__PURE__ */ n(i, { justifyContent: "space-between", children: e.decision && /* @__PURE__ */ n(i, { direction: "column", children: /* @__PURE__ */ n(
431
+ /* @__PURE__ */ n(o, { justifyContent: "space-between", children: e.decision && /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
432
432
  V,
433
433
  {
434
434
  element: e.decision,
435
- valueData: N(e.decision)
435
+ valueData: _(e.decision)
436
436
  }
437
437
  ) }, e.decision.name) })
438
438
  ] }),
439
- /* @__PURE__ */ u(i, { direction: "column", gap: "16px", justifyContent: "space-between", children: [
439
+ /* @__PURE__ */ m(o, { direction: "column", gap: "16px", justifyContent: "space-between", children: [
440
440
  /* @__PURE__ */ n(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: a.factsThatConditionIt }),
441
- e.conditions && e.conditions.map((m) => /* @__PURE__ */ n(i, { direction: "column", children: /* @__PURE__ */ n(
442
- V,
443
- {
444
- element: m,
445
- valueData: N(m)
446
- }
447
- ) }, m.name))
441
+ e.conditions && e.conditions.map(
442
+ (l) => (console.log("condition: ", l), (typeof l.value == "object" && i(l.value) || l.value) && /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
443
+ V,
444
+ {
445
+ element: l,
446
+ valueData: _(l)
447
+ }
448
+ ) }, l.name))
449
+ )
448
450
  ] }),
449
- /* @__PURE__ */ u(i, { direction: "column", gap: "12px", children: [
451
+ /* @__PURE__ */ m(o, { direction: "column", gap: "12px", children: [
450
452
  /* @__PURE__ */ n(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: a.terms }),
451
- /* @__PURE__ */ u(i, { justifyContent: "space-between", children: [
452
- ((o = e == null ? void 0 : e.decision) == null ? void 0 : o.startDate) && /* @__PURE__ */ n(
453
+ /* @__PURE__ */ m(o, { justifyContent: "space-between", children: [
454
+ ((c = e == null ? void 0 : e.decision) == null ? void 0 : c.startDate) && /* @__PURE__ */ n(
453
455
  V,
454
456
  {
455
457
  element: {
456
- name: "startDate",
458
+ name: "Fecha de inicio",
457
459
  description: a.termStart,
458
460
  value: String(e.startDate),
459
- howToSetUp: C.EQUAL,
460
- typeData: U.DATE
461
+ valueUse: f.EQUAL,
462
+ dataType: U.DATE
461
463
  },
462
464
  valueData: new Date(
463
465
  e.decision.startDate
@@ -465,15 +467,15 @@ const X = (t) => {
465
467
  },
466
468
  "startDate"
467
469
  ),
468
- ((l = e == null ? void 0 : e.decision) == null ? void 0 : l.endDate) && /* @__PURE__ */ n(
470
+ ((g = e == null ? void 0 : e.decision) == null ? void 0 : g.endDate) && /* @__PURE__ */ n(
469
471
  V,
470
472
  {
471
473
  element: {
472
- name: "endDate",
474
+ name: "Fecha de final",
473
475
  description: a.termEnd,
474
476
  value: String(e.endDate),
475
- howToSetUp: C.EQUAL,
476
- typeData: U.DATE
477
+ valueUse: f.EQUAL,
478
+ dataType: U.DATE
477
479
  },
478
480
  valueData: new Date(e.decision.endDate).toLocaleDateString(
479
481
  "en-CA"
@@ -511,13 +513,13 @@ const X = (t) => {
511
513
  background-color: #ebecf0;
512
514
  border-radius: 8px;
513
515
  }
514
- `, ye = (t) => {
515
- const { children: e, handleDelete: a, handleView: o, id: l } = t;
516
- return /* @__PURE__ */ u(ae, { children: [
517
- /* @__PURE__ */ n(i, { height: "282px", gap: "24px", direction: "column", children: /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(i, { direction: "column", margin: "10px", children: e }) }) }),
518
- /* @__PURE__ */ u(i, { gap: "16px", direction: "column", margin: "2px 12px", children: [
516
+ `, we = (t) => {
517
+ const { children: e, handleDelete: a, handleView: i, id: c } = t;
518
+ return /* @__PURE__ */ m(ae, { children: [
519
+ /* @__PURE__ */ n(o, { height: "282px", gap: "24px", direction: "column", children: /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(o, { direction: "column", margin: "10px", children: e }) }) }),
520
+ /* @__PURE__ */ m(o, { gap: "16px", direction: "column", margin: "2px 12px", children: [
519
521
  /* @__PURE__ */ n(E, {}),
520
- /* @__PURE__ */ u(i, { gap: "16px", justifyContent: "end", children: [
522
+ /* @__PURE__ */ m(o, { gap: "16px", justifyContent: "end", children: [
521
523
  /* @__PURE__ */ n(
522
524
  I,
523
525
  {
@@ -526,7 +528,7 @@ const X = (t) => {
526
528
  cursorHover: !0,
527
529
  icon: /* @__PURE__ */ n(J, {}),
528
530
  onClick: () => {
529
- o(l);
531
+ i(c);
530
532
  }
531
533
  }
532
534
  ),
@@ -538,7 +540,7 @@ const X = (t) => {
538
540
  size: "24px",
539
541
  icon: /* @__PURE__ */ n(K, {}),
540
542
  onClick: () => {
541
- a(l);
543
+ a(c);
542
544
  }
543
545
  }
544
546
  )
@@ -547,7 +549,7 @@ const X = (t) => {
547
549
  ] });
548
550
  };
549
551
  export {
550
- ye as BusinessRuleCard,
551
- we as BusinessRuleView,
552
- De as RulesForm
552
+ we as BusinessRuleCard,
553
+ De as BusinessRuleView,
554
+ Se as RulesForm
553
555
  };
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "description": "",
12
12
  "private": false,
13
- "version": "0.1.11",
13
+ "version": "0.1.12",
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": {
@@ -49,7 +49,7 @@
49
49
  "@inubekit/textarea": "^2.45.0",
50
50
  "@inubekit/toggle": "^3.8.2",
51
51
  "@isettingkit/input": "^0.1.21",
52
- "@isettingkit/view": "^0.1.9"
52
+ "@isettingkit/view": "^0.1.12"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "react": "^18.2.0",