@isettingkit/business-rules 0.1.30 → 0.1.31

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