@isettingkit/business-rules 0.1.31 → 0.1.32

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.
Files changed (2) hide show
  1. package/dist/index.es.js +231 -235
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsxs as u, Fragment as E, jsx as r } from "react/jsx-runtime";
2
2
  import { ValueDataType as k, ValueHowToSetUp as b, DecisionConditionRender as $ } from "@isettingkit/input";
3
- import { Stack as s } from "@inubekit/stack";
3
+ import { Stack as d } from "@inubekit/stack";
4
4
  import { Divider as w } from "@inubekit/divider";
5
5
  import { Button as z } from "@inubekit/button";
6
- import { useState as _, useEffect as te } from "react";
6
+ import { useState as N, useEffect as te } from "react";
7
7
  import { Text as x } from "@inubekit/text";
8
8
  import { Date as q } from "@inubekit/date";
9
9
  import { Checkbox as re } from "@inubekit/checkbox";
@@ -11,8 +11,8 @@ import { Toggle as B } from "@inubekit/toggle";
11
11
  import { inube as v } from "@inubekit/foundations";
12
12
  import g, { keyframes as ae } from "styled-components";
13
13
  import { useFormik as ne } from "formik";
14
- import { mixed as P, object as L, number as R, string as I, date as O, lazy as j } from "yup";
15
- import { DecisionViewConditionRenderer as N } from "@isettingkit/view";
14
+ import { mixed as P, object as L, number as R, string as I, date as M, lazy as H } from "yup";
15
+ import { DecisionViewConditionRenderer as _ } from "@isettingkit/view";
16
16
  import { SkeletonLine as T } from "@inubekit/skeleton";
17
17
  import { MdOutlineDelete as oe, MdClear as ie, MdAdd as de } from "react-icons/md";
18
18
  import { Icon as Q } from "@inubekit/icon";
@@ -23,22 +23,22 @@ import { useMediaQuery as ue } from "@inubekit/hooks";
23
23
  const he = (e) => {
24
24
  const {
25
25
  onHandleStartChange: t,
26
- onHandleEndChange: a,
27
- onCheckClosedChange: n,
28
- labelStart: c,
29
- labelEnd: o,
30
- checkedClosed: l = !1,
31
- required: i = !1,
26
+ onHandleEndChange: n,
27
+ onCheckClosedChange: o,
28
+ labelStart: l,
29
+ labelEnd: a,
30
+ checkedClosed: s = !1,
31
+ required: c = !1,
32
32
  valueStart: h = "",
33
- valueEnd: d = "",
33
+ valueEnd: i = "",
34
34
  messageStart: m = "",
35
35
  messageEnd: p = "",
36
36
  statusStart: f = "pending",
37
37
  statusEnd: S = "pending"
38
- } = e, [A, J] = _(l), [K, X] = _(h), [Z, ee] = _(d);
38
+ } = e, [A, J] = N(s), [K, X] = N(h), [Z, ee] = N(i);
39
39
  return /* @__PURE__ */ u(E, { children: [
40
- /* @__PURE__ */ u(s, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
41
- /* @__PURE__ */ r(s, { children: /* @__PURE__ */ r(
40
+ /* @__PURE__ */ u(d, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
41
+ /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
42
42
  x,
43
43
  {
44
44
  appearance: "gray",
@@ -50,7 +50,7 @@ const he = (e) => {
50
50
  }
51
51
  ) }),
52
52
  /* @__PURE__ */ r(
53
- s,
53
+ d,
54
54
  {
55
55
  alignContent: "center",
56
56
  justifyContent: "center",
@@ -61,7 +61,7 @@ const he = (e) => {
61
61
  {
62
62
  label: "Cerrada",
63
63
  onChange: ({ target: y }) => {
64
- J(y.checked), n && n(y.checked);
64
+ J(y.checked), o && o(y.checked);
65
65
  },
66
66
  checked: A,
67
67
  value: ""
@@ -70,32 +70,32 @@ const he = (e) => {
70
70
  }
71
71
  )
72
72
  ] }),
73
- /* @__PURE__ */ u(s, { justifyContent: "space-between", gap: "24px", children: [
74
- /* @__PURE__ */ r(s, { width: "189px", children: /* @__PURE__ */ r(
73
+ /* @__PURE__ */ u(d, { justifyContent: "space-between", gap: "24px", children: [
74
+ /* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
75
75
  q,
76
76
  {
77
77
  id: "dateStart",
78
- label: c,
78
+ label: l,
79
79
  onChange: (y) => {
80
80
  X(y.target.value), t(y);
81
81
  },
82
82
  value: K,
83
- required: i,
83
+ required: c,
84
84
  size: "compact",
85
85
  status: f,
86
86
  message: m
87
87
  }
88
88
  ) }),
89
- A && /* @__PURE__ */ r(s, { width: "189px", children: /* @__PURE__ */ r(
89
+ A && /* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
90
90
  q,
91
91
  {
92
92
  id: "dateEnd",
93
- label: o,
93
+ label: a,
94
94
  onChange: (y) => {
95
- ee(y.target.value), a(y);
95
+ ee(y.target.value), n(y);
96
96
  },
97
97
  value: Z,
98
- required: i,
98
+ required: c,
99
99
  size: "compact",
100
100
  status: S,
101
101
  message: p
@@ -128,38 +128,38 @@ const he = (e) => {
128
128
  `, me = (e) => {
129
129
  const {
130
130
  checked: t,
131
- children: a,
132
- handleToggleChange: n,
133
- id: c,
134
- labelToggle: o,
135
- name: l,
136
- valueToggle: i = ""
137
- } = e, [h, d] = _(t), m = (p) => {
138
- d(p.target.checked), n(p);
131
+ children: n,
132
+ handleToggleChange: o,
133
+ id: l,
134
+ labelToggle: a,
135
+ name: s,
136
+ valueToggle: c = ""
137
+ } = e, [h, i] = N(t), m = (p) => {
138
+ i(p.target.checked), o(p);
139
139
  };
140
140
  return te(() => {
141
- d(t);
141
+ i(t);
142
142
  }, [t]), /* @__PURE__ */ u(E, { children: [
143
- /* @__PURE__ */ r(s, { children: /* @__PURE__ */ r(
143
+ /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
144
144
  B,
145
145
  {
146
146
  checked: h,
147
- id: c,
148
- name: l,
147
+ id: l,
148
+ name: s,
149
149
  onChange: m,
150
150
  size: "small",
151
- value: i,
152
- children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: o })
151
+ value: c,
152
+ children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: a })
153
153
  }
154
154
  ) }),
155
- h && /* @__PURE__ */ r(E, { children: a })
155
+ h && /* @__PURE__ */ r(E, { children: n })
156
156
  ] });
157
157
  }, be = (e) => ({
158
158
  schema: P().test(
159
159
  "isArrayOrString",
160
160
  "Must be an array of strings/numbers or a single string",
161
161
  (t) => Array.isArray(t) ? t.every(
162
- (a) => typeof a == "string" || typeof a == "number"
162
+ (n) => typeof n == "string" || typeof n == "number"
163
163
  ) : typeof t == "string"
164
164
  ),
165
165
  value: e
@@ -168,25 +168,25 @@ const he = (e) => {
168
168
  "isArrayOrString",
169
169
  "Must be an array of strings/numbers or a single string",
170
170
  (t) => Array.isArray(t) ? t.every(
171
- (a) => typeof a == "string" || typeof a == "number"
171
+ (n) => typeof n == "string" || typeof n == "number"
172
172
  ) : typeof t == "string"
173
173
  ),
174
174
  value: e
175
175
  }), xe = (e) => {
176
- const t = (e == null ? void 0 : e.from) ?? 0, a = (e == null ? void 0 : e.to) ?? 0;
176
+ const t = (e == null ? void 0 : e.from) ?? 0, n = (e == null ? void 0 : e.to) ?? 0;
177
177
  return {
178
178
  schema: L({
179
- from: R().required("Range From is required").max(a, "'Range From' cannot be greater than 'Range To'").min(0, "'Range From' cannot be less than 0"),
179
+ from: R().required("Range From is required").max(n, "'Range From' cannot be greater than 'Range To'").min(0, "'Range From' cannot be less than 0"),
180
180
  to: R().min(0, "To value must be greater than or equal to 0").required("To value is required").test(
181
181
  "is-greater",
182
182
  "To value must be greater than From value",
183
- function(n) {
184
- const { from: c } = this.parent;
185
- return n > c;
183
+ function(o) {
184
+ const { from: l } = this.parent;
185
+ return o > l;
186
186
  }
187
187
  )
188
188
  }),
189
- value: { from: t, to: a }
189
+ value: { from: t, to: n }
190
190
  };
191
191
  }, V = (e, t) => t === k.PERCENTAGE ? {
192
192
  schema: R().required("Percentage is required").min(0, "Percentage cannot be less than 0").max(100, "Percentage cannot be greater than 100"),
@@ -208,9 +208,9 @@ const he = (e) => {
208
208
  [b.GREATER_THAN]: V,
209
209
  [b.LESS_THAN]: V,
210
210
  [b.EQUAL]: V
211
- }, M = (e) => ve[e] || ye;
211
+ }, O = (e) => ve[e] || ye;
212
212
  function Ce({ decision: e, onSubmitEvent: t }) {
213
- const a = {
213
+ const n = {
214
214
  name: e.name || "",
215
215
  dataType: e.dataType || k.ALPHABETICAL,
216
216
  valueUse: e.valueUse || "",
@@ -220,25 +220,25 @@ function Ce({ decision: e, onSubmitEvent: t }) {
220
220
  toggleNone: !0,
221
221
  conditions: {},
222
222
  checkClosed: !1
223
- }, n = L({
223
+ }, o = L({
224
224
  name: I().required("Name is required"),
225
- startDate: O().required("Start date is required"),
226
- endDate: O().when("checkClosed", (l, i, { parent: h }) => (h == null ? void 0 : h.checkClosed) ? i.required("End date is required").test(
225
+ startDate: M().required("Start date is required"),
226
+ endDate: M().when("checkClosed", (s, c, { parent: h }) => (h == null ? void 0 : h.checkClosed) ? c.required("End date is required").test(
227
227
  "is-after-startDate",
228
228
  "End date must be greater than or equal to Start date",
229
229
  function(m) {
230
230
  const p = this.parent.startDate;
231
231
  return !p || !m ? !0 : new Date(m) >= new Date(p);
232
232
  }
233
- ) : i.notRequired()),
234
- value: j(() => M(c.values.valueUse)(c.values.value, c.values.dataType).schema),
235
- conditions: j((l, { parent: i }) => {
236
- var d, m;
237
- return (i == null ? void 0 : i.toggleNone) && ((d = i == null ? void 0 : i.conditions) == null ? void 0 : d.length) > 0 ? L().shape({}) : L(
233
+ ) : c.notRequired()),
234
+ value: H(() => O(l.values.valueUse)(l.values.value, l.values.dataType).schema),
235
+ conditions: H((s, { parent: c }) => {
236
+ var i, m;
237
+ return (c == null ? void 0 : c.toggleNone) && ((i = c == null ? void 0 : c.conditions) == null ? void 0 : i.length) > 0 ? L().shape({}) : L(
238
238
  (m = e.conditions) == null ? void 0 : m.reduce(
239
239
  (p, f) => {
240
- if (c.values.conditions[f.name] !== void 0) {
241
- const S = M(f.valueUse);
240
+ if (l.values.conditions[f.name] !== void 0) {
241
+ const S = O(f.valueUse);
242
242
  p[f.name] = S(
243
243
  f.value,
244
244
  f.dataType
@@ -250,60 +250,60 @@ function Ce({ decision: e, onSubmitEvent: t }) {
250
250
  )
251
251
  );
252
252
  })
253
- }), c = ne({
254
- initialValues: a,
255
- validationSchema: n,
253
+ }), l = ne({
254
+ initialValues: n,
255
+ validationSchema: o,
256
256
  validateOnBlur: !0,
257
- onSubmit: (l) => {
257
+ onSubmit: (s) => {
258
258
  var h;
259
- const i = {
259
+ const c = {
260
260
  ...e,
261
- name: l.name,
262
- dataType: l.dataType,
263
- valueUse: l.valueUse,
264
- value: l.value,
265
- startDate: l.startDate,
266
- endDate: l.endDate,
267
- conditions: (h = e.conditions) == null ? void 0 : h.map((d) => ({
268
- ...d,
269
- value: l.conditions[d.name]
261
+ name: s.name,
262
+ dataType: s.dataType,
263
+ valueUse: s.valueUse,
264
+ value: s.value,
265
+ startDate: s.startDate,
266
+ endDate: s.endDate,
267
+ conditions: (h = e.conditions) == null ? void 0 : h.map((i) => ({
268
+ ...i,
269
+ value: s.conditions[i.name]
270
270
  }))
271
271
  };
272
- t(i);
272
+ t(c);
273
273
  }
274
274
  });
275
- return { formik: c, handleToggleNoneChange: (l) => {
276
- var i;
277
- c.setFieldValue("toggleNone", l), (i = e.conditions) == null || i.forEach((h) => {
278
- if (l)
279
- c.setFieldValue(`conditions.${h.name}`, void 0);
275
+ return { formik: l, handleToggleNoneChange: (s) => {
276
+ var c;
277
+ l.setFieldValue("toggleNone", s), (c = e.conditions) == null || c.forEach((h) => {
278
+ if (s)
279
+ l.setFieldValue(`conditions.${h.name}`, void 0);
280
280
  else {
281
- const d = h.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
282
- c.setFieldValue(`conditions.${h.name}`, d);
281
+ const i = h.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
282
+ l.setFieldValue(`conditions.${h.name}`, i);
283
283
  }
284
284
  });
285
285
  } };
286
286
  }
287
287
  const we = (e) => {
288
288
  var h;
289
- const { decision: t, onSubmitEvent: a, textValues: n, onCancel: c } = e, { formik: o, handleToggleNoneChange: l } = Ce({
289
+ const { decision: t, onSubmitEvent: n, textValues: o, onCancel: l } = e, { formik: a, handleToggleNoneChange: s } = Ce({
290
290
  decision: t,
291
- onSubmitEvent: a
292
- }), i = {
291
+ onSubmitEvent: n
292
+ }), c = {
293
293
  name: t.name,
294
294
  valueUse: t.valueUse,
295
295
  dataType: t.dataType,
296
296
  possibleValue: t.possibleValue
297
297
  };
298
- return /* @__PURE__ */ r("form", { onSubmit: o.handleSubmit, children: /* @__PURE__ */ u(s, { direction: "column", gap: "24px", children: [
298
+ return /* @__PURE__ */ r("form", { onSubmit: a.handleSubmit, children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
299
299
  $({
300
- condition: i,
301
- formik: o,
300
+ condition: c,
301
+ formik: a,
302
302
  isDecision: !0
303
303
  }),
304
304
  /* @__PURE__ */ r(w, { dashed: !0 }),
305
305
  /* @__PURE__ */ r(pe, { children: /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ u(
306
- s,
306
+ d,
307
307
  {
308
308
  direction: "column",
309
309
  padding: "6px 12px",
@@ -311,54 +311,54 @@ const we = (e) => {
311
311
  height: "272px",
312
312
  children: [
313
313
  /* @__PURE__ */ u(
314
- s,
314
+ d,
315
315
  {
316
316
  justifyContent: "space-between",
317
317
  alignItems: "center",
318
318
  gap: "64px",
319
319
  children: [
320
- /* @__PURE__ */ r(x, { type: "title", size: "small", weight: "bold", appearance: "gray", children: n.factsThatConditionIt }),
320
+ /* @__PURE__ */ r(x, { type: "title", size: "small", weight: "bold", appearance: "gray", children: o.factsThatConditionIt }),
321
321
  /* @__PURE__ */ r(
322
322
  B,
323
323
  {
324
324
  id: "toggleNone",
325
- onChange: () => l(!o.values.toggleNone),
326
- checked: o.values.toggleNone,
325
+ onChange: () => s(!a.values.toggleNone),
326
+ checked: a.values.toggleNone,
327
327
  size: "small",
328
- children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: n.none })
328
+ children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: o.none })
329
329
  }
330
330
  )
331
331
  ]
332
332
  }
333
333
  ),
334
- /* @__PURE__ */ r(s, { direction: "column", gap: "20px", children: (h = t.conditions) == null ? void 0 : h.map((d) => /* @__PURE__ */ r(
334
+ /* @__PURE__ */ r(d, { direction: "column", gap: "20px", children: (h = t.conditions) == null ? void 0 : h.map((i) => /* @__PURE__ */ r(
335
335
  me,
336
336
  {
337
- id: `toggle-${d.name}`,
338
- name: `toggle.${d.name}`,
339
- labelToggle: d.name,
340
- checked: !o.values.toggleNone && o.values.conditions[d.name] !== void 0,
337
+ id: `toggle-${i.name}`,
338
+ name: `toggle.${i.name}`,
339
+ labelToggle: i.name,
340
+ checked: !a.values.toggleNone && a.values.conditions[i.name] !== void 0,
341
341
  handleToggleChange: (m) => {
342
342
  if (!m.target.checked)
343
- o.setFieldValue(
344
- `conditions.${d.name}`,
343
+ a.setFieldValue(
344
+ `conditions.${i.name}`,
345
345
  void 0
346
- ), o.setFieldTouched(
347
- `conditions.${d.name}`,
346
+ ), a.setFieldTouched(
347
+ `conditions.${i.name}`,
348
348
  !1,
349
349
  !1
350
350
  );
351
351
  else {
352
- const f = d.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
353
- o.setFieldValue(
354
- `conditions.${d.name}`,
352
+ const f = i.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
353
+ a.setFieldValue(
354
+ `conditions.${i.name}`,
355
355
  f
356
356
  );
357
357
  }
358
358
  },
359
- children: $({ condition: d, formik: o })
359
+ children: $({ condition: i, formik: a })
360
360
  },
361
- d.name
361
+ i.name
362
362
  )) })
363
363
  ]
364
364
  }
@@ -367,29 +367,29 @@ const we = (e) => {
367
367
  /* @__PURE__ */ r(
368
368
  he,
369
369
  {
370
- labelStart: n.termStart,
371
- labelEnd: n.termEnd,
372
- valueStart: o.values.startDate,
373
- valueEnd: o.values.endDate,
374
- messageStart: o.errors.startDate,
375
- messageEnd: o.errors.endDate,
376
- statusStart: o.touched.startDate ? o.errors.startDate ? "invalid" : "valid" : void 0,
377
- statusEnd: o.touched.endDate ? o.errors.endDate ? "invalid" : "valid" : void 0,
378
- onHandleStartChange: (d) => o.setFieldValue("startDate", d.target.value),
379
- onHandleEndChange: (d) => o.setFieldValue("endDate", d.target.value),
380
- onCheckClosedChange: (d) => {
381
- o.setFieldValue("checkClosed", d), d && o.setFieldValue("endDate", "");
370
+ labelStart: o.termStart,
371
+ labelEnd: o.termEnd,
372
+ valueStart: a.values.startDate,
373
+ valueEnd: a.values.endDate,
374
+ messageStart: a.errors.startDate,
375
+ messageEnd: a.errors.endDate,
376
+ statusStart: a.touched.startDate ? a.errors.startDate ? "invalid" : "valid" : void 0,
377
+ statusEnd: a.touched.endDate ? a.errors.endDate ? "invalid" : "valid" : void 0,
378
+ onHandleStartChange: (i) => a.setFieldValue("startDate", i.target.value),
379
+ onHandleEndChange: (i) => a.setFieldValue("endDate", i.target.value),
380
+ onCheckClosedChange: (i) => {
381
+ a.setFieldValue("checkClosed", i), i && a.setFieldValue("endDate", "");
382
382
  },
383
- checkedClosed: o.values.checkClosed
383
+ checkedClosed: a.values.checkClosed
384
384
  }
385
385
  ),
386
386
  /* @__PURE__ */ r(w, {}),
387
- /* @__PURE__ */ u(s, { direction: "row", justifyContent: "end", gap: "16px", children: [
388
- /* @__PURE__ */ r(z, { appearance: "gray", onClick: c, children: n.cancel }),
389
- /* @__PURE__ */ r(z, { type: "submit", children: n.confirm })
387
+ /* @__PURE__ */ u(d, { direction: "row", justifyContent: "end", gap: "16px", children: [
388
+ /* @__PURE__ */ r(z, { appearance: "gray", onClick: l, children: o.cancel }),
389
+ /* @__PURE__ */ r(z, { type: "submit", children: o.confirm })
390
390
  ] })
391
391
  ] }) });
392
- }, H = g.div`
392
+ }, j = g.div`
393
393
  & > div {
394
394
  border-radius: 8px;
395
395
  border: 1px solid ${v.palette.neutral.N30};
@@ -417,7 +417,7 @@ const we = (e) => {
417
417
  to: e.to ?? ""
418
418
  }), De = (e) => e.value, Ee = (e) => e.value, Ae = (e) => e.value;
419
419
  var C = /* @__PURE__ */ ((e) => (e.EQUAL = "equal", e.GREATER_THAN = "greater_than", e.LESS_THAN = "less_than", e.LIST_OF_VALUES = "list_of_values", e.LIST_OF_VALUES_MULTI = "list_of_values_multi", e.RANGE = "range", e))(C || {});
420
- const Ne = (e) => e.value, _e = {
420
+ const _e = (e) => e.value, Ne = {
421
421
  [C.LIST_OF_VALUES]: ke,
422
422
  [C.LIST_OF_VALUES_MULTI]: Se,
423
423
  [C.RANGE]: Te,
@@ -426,28 +426,28 @@ const Ne = (e) => e.value, _e = {
426
426
  [C.EQUAL]: Ae
427
427
  };
428
428
  function D(e) {
429
- const t = e == null ? void 0 : e.value, a = typeof t == "object" && t !== null && !Array.isArray(t), n = _e[e == null ? void 0 : e.valueUse] || Ne;
430
- return a && n(t) || t || void 0;
429
+ const t = e == null ? void 0 : e.value, n = typeof t == "object" && t !== null && !Array.isArray(t), o = Ne[e == null ? void 0 : e.valueUse] || _e;
430
+ return n && o(t) || t || void 0;
431
431
  }
432
432
  const Y = (e) => {
433
- const { decision: t, loading: a = !1, textValues: n } = e, c = (l) => l && Object.keys(l).length > 0, o = {
433
+ const { decision: t, loading: n = !1, textValues: o } = e, l = {
434
434
  name: (t == null ? void 0 : t.name) || "",
435
435
  dataType: (t == null ? void 0 : t.dataType) || "alphabetical",
436
436
  value: D(t),
437
437
  valueUse: (t == null ? void 0 : t.valueUse) || "equal"
438
438
  };
439
- return !a && t && n ? /* @__PURE__ */ u(s, { direction: "column", gap: "12px", children: [
440
- t && /* @__PURE__ */ r(s, { direction: "column", alignItems: "center", children: /* @__PURE__ */ r(
441
- N,
439
+ return !n && t && o ? /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
440
+ t && /* @__PURE__ */ r(d, { direction: "column", alignItems: "center", children: /* @__PURE__ */ r(
441
+ _,
442
442
  {
443
- element: o,
444
- valueData: D(o),
443
+ element: l,
444
+ valueData: D(l),
445
445
  type: "decision"
446
446
  }
447
447
  ) }, t.name),
448
448
  /* @__PURE__ */ r(w, { dashed: !0 }),
449
449
  /* @__PURE__ */ r(G, { children: /* @__PURE__ */ u(
450
- s,
450
+ d,
451
451
  {
452
452
  direction: "column",
453
453
  gap: "12px",
@@ -462,36 +462,32 @@ const Y = (e) => {
462
462
  appearance: "dark",
463
463
  weight: "bold",
464
464
  textAlign: "center",
465
- children: n.factsThatConditionIt
465
+ children: o.factsThatConditionIt
466
466
  }
467
467
  ),
468
- t.conditions && t.conditions.map((l) => {
469
- if (l.hidden) return null;
470
- const i = l.value;
471
- return (typeof i == "object" && c(i) || i !== void 0 && typeof i == "string" && i.length > 0) && /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(s, { direction: "column", padding: "8px", children: /* @__PURE__ */ r(
472
- N,
473
- {
474
- element: {
475
- ...l,
476
- value: i
477
- },
478
- valueData: D(l)
479
- }
480
- ) }) }, l.name);
481
- }),
468
+ t.conditions && t.conditions.map((a) => a.hidden ? null : (console.log("condition: ", a), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(d, { direction: "column", padding: "8px", children: /* @__PURE__ */ r(
469
+ _,
470
+ {
471
+ element: {
472
+ ...a,
473
+ value: a.value
474
+ },
475
+ valueData: D(a)
476
+ }
477
+ ) }) }, a.name))),
482
478
  /* @__PURE__ */ r(w, { dashed: !0 }),
483
- /* @__PURE__ */ u(s, { direction: "column", gap: "12px", children: [
479
+ /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
484
480
  (t == null ? void 0 : t.startDate) && (t == null ? void 0 : t.endDate) && /* @__PURE__ */ r(
485
- N,
481
+ _,
486
482
  {
487
483
  element: {
488
- name: n.terms,
484
+ name: o.terms,
489
485
  value: String(t.startDate),
490
486
  valueUse: b.RANGE,
491
487
  dataType: k.DATE
492
488
  },
493
489
  valueData: D({
494
- name: n.terms,
490
+ name: o.terms,
495
491
  value: {
496
492
  from: String(t.startDate),
497
493
  to: String(t.endDate)
@@ -501,49 +497,49 @@ const Y = (e) => {
501
497
  }),
502
498
  type: "decision"
503
499
  },
504
- n.terms
500
+ o.terms
505
501
  ),
506
502
  (t == null ? void 0 : t.startDate) && !(t != null && t.endDate) && /* @__PURE__ */ r(
507
- N,
503
+ _,
508
504
  {
509
505
  element: {
510
- name: n.terms,
506
+ name: o.terms,
511
507
  value: String(t.startDate),
512
508
  valueUse: b.EQUAL,
513
509
  dataType: k.DATE
514
510
  },
515
511
  valueData: D({
516
- name: n.terms,
512
+ name: o.terms,
517
513
  value: String(t.startDate),
518
514
  valueUse: b.EQUAL,
519
515
  dataType: k.DATE
520
516
  }),
521
517
  type: "decision"
522
518
  },
523
- n.terms
519
+ o.terms
524
520
  )
525
521
  ] })
526
522
  ]
527
523
  }
528
524
  ) })
529
- ] }) : /* @__PURE__ */ u(s, { direction: "column", gap: "12px", children: [
530
- /* @__PURE__ */ u(s, { direction: "column", alignItems: "center", gap: "4px", children: [
525
+ ] }) : /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
526
+ /* @__PURE__ */ u(d, { direction: "column", alignItems: "center", gap: "4px", children: [
531
527
  /* @__PURE__ */ r(T, { animated: !0, width: "180px" }),
532
528
  /* @__PURE__ */ r(T, { animated: !0, width: "85px" })
533
529
  ] }, "loading"),
534
- /* @__PURE__ */ u(s, { direction: "column", gap: "12px", alignItems: "center", children: [
530
+ /* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
535
531
  /* @__PURE__ */ r(w, { dashed: !0 }),
536
532
  /* @__PURE__ */ r(T, { animated: !0, width: "150px" })
537
533
  ] }),
538
534
  /* @__PURE__ */ r(G, { children: /* @__PURE__ */ r(
539
- s,
535
+ d,
540
536
  {
541
537
  direction: "column",
542
538
  gap: "12px",
543
539
  justifyContent: "space-between",
544
540
  height: "203px",
545
- children: Array.from({ length: 5 }).map((l, i) => /* @__PURE__ */ r(H, { children: /* @__PURE__ */ u(
546
- s,
541
+ children: Array.from({ length: 5 }).map((a, s) => /* @__PURE__ */ r(j, { children: /* @__PURE__ */ u(
542
+ d,
547
543
  {
548
544
  direction: "column",
549
545
  gap: "12px",
@@ -554,7 +550,7 @@ const Y = (e) => {
554
550
  /* @__PURE__ */ r(T, { animated: !0, width: "85px" })
555
551
  ]
556
552
  }
557
- ) }, `condition-${i}`))
553
+ ) }, `condition-${s}`))
558
554
  }
559
555
  ) })
560
556
  ] });
@@ -590,12 +586,12 @@ g.div`
590
586
  }
591
587
  `;
592
588
  const F = (e) => {
593
- const { children: t, controls: a = !0, handleDelete: n, id: c } = e;
594
- return /* @__PURE__ */ r(Le, { children: /* @__PURE__ */ u(s, { direction: "column", gap: "16px", padding: "12px 16px", children: [
589
+ const { children: t, controls: n = !0, handleDelete: o, id: l } = e;
590
+ return /* @__PURE__ */ r(Le, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "12px 16px", children: [
595
591
  t,
596
- a && /* @__PURE__ */ u(E, { children: [
592
+ n && /* @__PURE__ */ u(E, { children: [
597
593
  /* @__PURE__ */ r(w, {}),
598
- /* @__PURE__ */ r(s, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ r(
594
+ /* @__PURE__ */ r(d, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ r(
599
595
  Q,
600
596
  {
601
597
  cursorHover: !0,
@@ -603,7 +599,7 @@ const F = (e) => {
603
599
  size: "24px",
604
600
  icon: /* @__PURE__ */ r(oe, {}),
605
601
  onClick: () => {
606
- n(c);
602
+ o(l);
607
603
  }
608
604
  }
609
605
  ) })
@@ -616,8 +612,8 @@ const F = (e) => {
616
612
  }
617
613
  `, Re = g.div`
618
614
  background-color: ${({ theme: e }) => {
619
- var t, a;
620
- return ((a = (t = e == null ? void 0 : e.palette) == null ? void 0 : t.neutral) == null ? void 0 : a.N0) || v.palette.neutral.N0;
615
+ var t, n;
616
+ return ((n = (t = e == null ? void 0 : e.palette) == null ? void 0 : t.neutral) == null ? void 0 : n.N0) || v.palette.neutral.N0;
621
617
  }};
622
618
  max-width: 450px;
623
619
  max-height: 90vh;
@@ -646,20 +642,20 @@ const F = (e) => {
646
642
  border-radius: 8px;
647
643
  }
648
644
  `, Ue = (e) => {
649
- const { children: t, portalId: a, onCloseModal: n, title: c } = e, o = document.getElementById(a);
650
- if (!o)
645
+ const { children: t, portalId: n, onCloseModal: o, title: l } = e, a = document.getElementById(n);
646
+ if (!a)
651
647
  throw new Error(
652
648
  "The portal node is not defined. This can occur when the specific node used to render the portal has not been defined correctly."
653
649
  );
654
650
  return le(
655
- /* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(Re, { children: /* @__PURE__ */ u(s, { direction: "column", gap: "24px", children: [
656
- /* @__PURE__ */ r(s, { direction: "column", gap: "24px", children: /* @__PURE__ */ u(s, { alignItems: "center", justifyContent: "space-between", children: [
657
- /* @__PURE__ */ r(x, { type: "title", size: "large", appearance: "dark", weight: "bold", children: c }),
658
- /* @__PURE__ */ r(ie, { size: "24px", cursor: "pointer", onClick: n })
651
+ /* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(Re, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
652
+ /* @__PURE__ */ r(d, { direction: "column", gap: "24px", children: /* @__PURE__ */ u(d, { alignItems: "center", justifyContent: "space-between", children: [
653
+ /* @__PURE__ */ r(x, { type: "title", size: "large", appearance: "dark", weight: "bold", children: l }),
654
+ /* @__PURE__ */ r(ie, { size: "24px", cursor: "pointer", onClick: o })
659
655
  ] }) }),
660
656
  t
661
657
  ] }) }) }) }),
662
- o
658
+ a
663
659
  );
664
660
  }, Ie = ae`
665
661
  from {
@@ -749,32 +745,32 @@ function qe({
749
745
  `loading-card-${e}`
750
746
  );
751
747
  }
752
- function Oe({
748
+ function Me({
753
749
  decision: e,
754
750
  controls: t,
755
- handleOpenModal: a,
756
- handleDelete: n,
757
- textValues: c
751
+ handleOpenModal: n,
752
+ handleDelete: o,
753
+ textValues: l
758
754
  }) {
759
- return e ? /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(s, { direction: "column", gap: "4px", width: "100%", padding: "0 0 12px 0", children: [
755
+ return e ? /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", padding: "0 0 12px 0", children: [
760
756
  /* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: e.id }),
761
757
  /* @__PURE__ */ r(
762
758
  F,
763
759
  {
764
760
  id: e.id,
765
- handleDelete: () => n(e.id),
766
- handleView: () => a(e),
761
+ handleDelete: () => o(e.id),
762
+ handleView: () => n(e),
767
763
  controls: t,
768
- children: /* @__PURE__ */ r(Y, { decision: e, textValues: c })
764
+ children: /* @__PURE__ */ r(Y, { decision: e, textValues: l })
769
765
  }
770
766
  )
771
767
  ] }) }, e.id) : null;
772
768
  }
773
- function je({
769
+ function He({
774
770
  index: e,
775
771
  handleOpenModal: t
776
772
  }) {
777
- return /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(s, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
773
+ return /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
778
774
  /* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: "Nueva decisión" }),
779
775
  /* @__PURE__ */ r(ze, { onClick: () => t(), children: /* @__PURE__ */ r(
780
776
  F,
@@ -784,7 +780,7 @@ function je({
784
780
  },
785
781
  handleView: () => t(),
786
782
  controls: !1,
787
- children: /* @__PURE__ */ u(s, { direction: "column", gap: "12px", alignItems: "center", children: [
783
+ children: /* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
788
784
  /* @__PURE__ */ r(Q, { appearance: "gray", icon: /* @__PURE__ */ r(de, {}), size: "35px" }),
789
785
  /* @__PURE__ */ r(x, { appearance: "gray", type: "body", size: "large", children: "Agregar decisión" })
790
786
  ] })
@@ -792,70 +788,70 @@ function je({
792
788
  ) })
793
789
  ] }) }, `add-decision-${e}`);
794
790
  }
795
- const Me = {
791
+ const Oe = {
796
792
  loading: qe,
797
- decision: Oe,
798
- add: je
793
+ decision: Me,
794
+ add: He
799
795
  };
800
796
  function U(e) {
801
- const { type: t } = e, a = Me[t];
802
- return a ? a(e) : null;
797
+ const { type: t } = e, n = Oe[t];
798
+ return n ? n(e) : null;
803
799
  }
804
- function He({
800
+ function je({
805
801
  controls: e,
806
802
  decisions: t,
807
- loading: a,
808
- handleOpenModal: n,
809
- handleDelete: c,
810
- textValues: o
803
+ loading: n,
804
+ handleOpenModal: o,
805
+ handleDelete: l,
806
+ textValues: a
811
807
  }) {
812
- const l = a ? Array.from({ length: 3 }).map(
813
- (h, d) => U({
808
+ const s = n ? Array.from({ length: 3 }).map(
809
+ (h, i) => U({
814
810
  type: "loading",
815
- index: d,
811
+ index: i,
816
812
  controls: e,
817
- loading: a,
818
- handleOpenModal: n,
819
- handleDelete: c,
820
- textValues: o
813
+ loading: n,
814
+ handleOpenModal: o,
815
+ handleDelete: l,
816
+ textValues: a
821
817
  })
822
818
  ) : t.map(
823
819
  (h) => U({
824
820
  type: "decision",
825
821
  decision: h,
826
822
  controls: e,
827
- loading: a,
828
- handleOpenModal: n,
829
- handleDelete: c,
830
- textValues: o
823
+ loading: n,
824
+ handleOpenModal: o,
825
+ handleDelete: l,
826
+ textValues: a
831
827
  })
832
- ), i = (t.length === 0 || t.length < Math.floor(window.innerWidth / 300)) && !a && e;
833
- return { renderedCards: l, shouldRenderAddCard: i };
828
+ ), c = (t.length === 0 || t.length < Math.floor(window.innerWidth / 300)) && !n && e;
829
+ return { renderedCards: s, shouldRenderAddCard: c };
834
830
  }
835
831
  const mt = (e) => {
836
832
  const {
837
833
  controls: t = !0,
838
- decisions: a,
839
- textValues: n,
840
- decisionTemplate: c,
841
- isModalOpen: o,
842
- selectedDecision: l,
843
- loading: i,
834
+ decisions: n,
835
+ textValues: o,
836
+ decisionTemplate: l,
837
+ isModalOpen: a,
838
+ selectedDecision: s,
839
+ loading: c,
844
840
  handleOpenModal: h,
845
- handleCloseModal: d,
841
+ handleCloseModal: i,
846
842
  handleSubmitForm: m,
847
843
  handleDelete: p
848
- } = e, f = ue("(max-width: 681px)"), { renderedCards: S, shouldRenderAddCard: A } = He({
844
+ } = e, f = ue("(max-width: 681px)"), { renderedCards: S, shouldRenderAddCard: A } = je({
849
845
  controls: t,
850
- decisions: a,
851
- loading: i,
846
+ decisions: n,
847
+ loading: c,
852
848
  handleOpenModal: h,
853
849
  handleDelete: p,
854
- textValues: n
850
+ textValues: o
855
851
  });
856
852
  return /* @__PURE__ */ u(E, { children: [
857
- /* @__PURE__ */ r($e, { children: /* @__PURE__ */ r(Fe, { children: /* @__PURE__ */ u(s, { direction: "column", gap: "16px", padding: "6px", children: [
858
- a.length === 0 && !i && /* @__PURE__ */ u(x, { as: "span", type: "label", size: "large", appearance: "gray", children: [
853
+ /* @__PURE__ */ r($e, { children: /* @__PURE__ */ r(Fe, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "6px", children: [
854
+ n.length === 0 && !c && /* @__PURE__ */ u(x, { as: "span", type: "label", size: "large", appearance: "gray", children: [
859
855
  "Aún no tienes definidas tasas de interés efectivas. Presiona",
860
856
  /* @__PURE__ */ r(
861
857
  x,
@@ -886,30 +882,30 @@ const mt = (e) => {
886
882
  S,
887
883
  A && U({
888
884
  type: "add",
889
- index: a.length,
885
+ index: n.length,
890
886
  controls: t,
891
- loading: i,
887
+ loading: c,
892
888
  handleOpenModal: h,
893
889
  handleDelete: p,
894
- textValues: n
890
+ textValues: o
895
891
  })
896
892
  ]
897
893
  }
898
894
  )
899
895
  ] }) }) }),
900
- o && /* @__PURE__ */ r(
896
+ a && /* @__PURE__ */ r(
901
897
  Ue,
902
898
  {
903
899
  portalId: "modal-portal",
904
- onCloseModal: d,
905
- title: l ? "Editar Decisión" : "Nueva decisión",
900
+ onCloseModal: i,
901
+ title: s ? "Editar Decisión" : "Nueva decisión",
906
902
  children: /* @__PURE__ */ r(
907
903
  we,
908
904
  {
909
- decision: l || c,
905
+ decision: s || l,
910
906
  onSubmitEvent: m,
911
- textValues: n,
912
- onCancel: () => d()
907
+ textValues: o,
908
+ onCancel: () => i()
913
909
  }
914
910
  )
915
911
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "description": "",
12
12
  "private": false,
13
- "version": "0.1.31",
13
+ "version": "0.1.32",
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": {