@isettingkit/business-rules 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +55 -50
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as i, jsxs as p, Fragment as
|
|
1
|
+
import { jsx as i, jsxs as p, Fragment as N } from "react/jsx-runtime";
|
|
2
2
|
import { MdOutlineDelete as ge, MdClear as ne, MdAdd as ae, MdOutlineFilterAltOff as me, MdOutlineFilterAlt as be } from "react-icons/md";
|
|
3
|
-
import { inube as v, Stack as u, Divider as D, Icon as z, Text as x, SkeletonLine as F, useMediaQuery as
|
|
3
|
+
import { inube as v, Stack as u, Divider as D, Icon as z, Text as x, SkeletonLine as F, useMediaQuery as I, Blanket as ie, Button as E, Grid as oe, Box as Te, Tag as fe, Checkpicker as ye, Toggle as re, Checkbox as xe, Date as Q } from "@inubekit/inubekit";
|
|
4
4
|
import f, { keyframes as ve } from "styled-components";
|
|
5
|
-
import { ValueDataType as k, ValueHowToSetUp as L, DecisionConditionRender as
|
|
5
|
+
import { ValueDataType as k, ValueHowToSetUp as L, DecisionConditionRender as Z } from "@isettingkit/input";
|
|
6
6
|
import { DecisionViewConditionRenderer as _ } from "@isettingkit/view";
|
|
7
7
|
import { createPortal as le } from "react-dom";
|
|
8
8
|
import { useFormik as we } from "formik";
|
|
9
|
-
import { string as H, mixed as se, object as O, number as q, lazy as
|
|
9
|
+
import { string as H, mixed as se, object as O, number as q, lazy as Y, date as K } from "yup";
|
|
10
10
|
import { useState as V, useEffect as Ce } from "react";
|
|
11
11
|
import Se from "axios";
|
|
12
12
|
import { franc as De } from "franc-min";
|
|
13
|
-
const
|
|
13
|
+
const Ne = f.div`
|
|
14
14
|
border-radius: 8px;
|
|
15
15
|
border: 1px solid ${v.palette.neutral.N30};
|
|
16
16
|
box-sizing: border-box;
|
|
@@ -43,9 +43,9 @@ f.div`
|
|
|
43
43
|
`;
|
|
44
44
|
const P = (e) => {
|
|
45
45
|
const { children: t, controls: n = !0, handleDelete: a, id: o } = e;
|
|
46
|
-
return /* @__PURE__ */ i(
|
|
46
|
+
return /* @__PURE__ */ i(Ne, { children: /* @__PURE__ */ p(u, { direction: "column", gap: "16px", padding: "12px 16px", children: [
|
|
47
47
|
t,
|
|
48
|
-
n && /* @__PURE__ */ p(
|
|
48
|
+
n && /* @__PURE__ */ p(N, { children: [
|
|
49
49
|
/* @__PURE__ */ i(D, {}),
|
|
50
50
|
/* @__PURE__ */ i(u, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ i(
|
|
51
51
|
z,
|
|
@@ -88,20 +88,20 @@ const P = (e) => {
|
|
|
88
88
|
background-color: #ebecf0;
|
|
89
89
|
border-radius: 8px;
|
|
90
90
|
}
|
|
91
|
-
`,
|
|
91
|
+
`, Ee = (e) => e.value, ke = (e) => e.value, Ae = (e) => e.value, Fe = (e) => ({
|
|
92
92
|
from: e.from ?? "",
|
|
93
93
|
to: e.to ?? ""
|
|
94
|
-
}), $e = (e) => e.value,
|
|
94
|
+
}), $e = (e) => e.value, Re = (e) => e.value, Ie = (e) => e.value;
|
|
95
95
|
var y = /* @__PURE__ */ ((e) => (e.EQUAL = "EqualTo", e.GREATER_THAN = "GreaterThan", e.LESS_THAN = "LessThan", e.LIST_OF_VALUES = "ListOfValues", e.LIST_OF_VALUES_MULTI = "ListOfValuesMulti", e.RANGE = "Range", e))(y || {});
|
|
96
96
|
const Me = {
|
|
97
97
|
[y.LIST_OF_VALUES]: ke,
|
|
98
98
|
[y.LIST_OF_VALUES_MULTI]: Ae,
|
|
99
99
|
[y.RANGE]: Fe,
|
|
100
100
|
[y.GREATER_THAN]: $e,
|
|
101
|
-
[y.LESS_THAN]:
|
|
102
|
-
[y.EQUAL]:
|
|
103
|
-
},
|
|
104
|
-
const t = e == null ? void 0 : e.value, n = typeof t == "object" && t !== null && !Array.isArray(t), a = Me[e == null ? void 0 : e.howToSetTheDecision] ||
|
|
101
|
+
[y.LESS_THAN]: Re,
|
|
102
|
+
[y.EQUAL]: Ie
|
|
103
|
+
}, R = (e) => {
|
|
104
|
+
const t = e == null ? void 0 : e.value, n = typeof t == "object" && t !== null && !Array.isArray(t), a = Me[e == null ? void 0 : e.howToSetTheDecision] || Ee;
|
|
105
105
|
return n && a(t) || t || void 0;
|
|
106
106
|
}, Le = (e) => {
|
|
107
107
|
const {
|
|
@@ -120,7 +120,7 @@ const Me = {
|
|
|
120
120
|
_,
|
|
121
121
|
{
|
|
122
122
|
element: o,
|
|
123
|
-
valueData:
|
|
123
|
+
valueData: R(
|
|
124
124
|
o
|
|
125
125
|
),
|
|
126
126
|
type: "decision"
|
|
@@ -150,12 +150,12 @@ const Me = {
|
|
|
150
150
|
_,
|
|
151
151
|
{
|
|
152
152
|
element: { ...s, value: s.value },
|
|
153
|
-
valueData:
|
|
153
|
+
valueData: R(
|
|
154
154
|
s
|
|
155
155
|
)
|
|
156
156
|
}
|
|
157
157
|
) }) }, s.conditionName)),
|
|
158
|
-
g && /* @__PURE__ */ p(
|
|
158
|
+
g && /* @__PURE__ */ p(N, { children: [
|
|
159
159
|
/* @__PURE__ */ i(D, { dashed: !0 }),
|
|
160
160
|
a && /* @__PURE__ */ i(
|
|
161
161
|
_,
|
|
@@ -211,7 +211,7 @@ const Me = {
|
|
|
211
211
|
howToSetTheDecision: L.RANGE,
|
|
212
212
|
decisionDataType: k.DATE
|
|
213
213
|
},
|
|
214
|
-
valueData:
|
|
214
|
+
valueData: R({
|
|
215
215
|
labelName: a == null ? void 0 : a.terms,
|
|
216
216
|
value: {
|
|
217
217
|
from: String(t.effectiveFrom),
|
|
@@ -227,7 +227,7 @@ const Me = {
|
|
|
227
227
|
howToSetTheDecision: L.EQUAL,
|
|
228
228
|
decisionDataType: k.DATE
|
|
229
229
|
},
|
|
230
|
-
valueData:
|
|
230
|
+
valueData: R({
|
|
231
231
|
labelName: a == null ? void 0 : a.terms,
|
|
232
232
|
value: String(t.effectiveFrom),
|
|
233
233
|
howToSetTheDecision: L.EQUAL,
|
|
@@ -236,7 +236,7 @@ const Me = {
|
|
|
236
236
|
} : null, g = t ? {
|
|
237
237
|
labelName: t.labelName || "",
|
|
238
238
|
decisionDataType: t.decisionDataType || "alphabetical",
|
|
239
|
-
value:
|
|
239
|
+
value: R(t),
|
|
240
240
|
howToSetTheDecision: t.howToSetTheDecision || "EqualTo"
|
|
241
241
|
} : null, d = ((b = t == null ? void 0 : t.conditionsThatEstablishesTheDecision) == null ? void 0 : b.filter(
|
|
242
242
|
(T) => !T.hidden
|
|
@@ -297,7 +297,7 @@ const Me = {
|
|
|
297
297
|
throw new Error(
|
|
298
298
|
"The portal node is not defined. This can occur when the specific node used to render the portal has not been defined correctly."
|
|
299
299
|
);
|
|
300
|
-
const c =
|
|
300
|
+
const c = I("(max-width: 400px)");
|
|
301
301
|
return le(
|
|
302
302
|
/* @__PURE__ */ i(Oe, { smallScreen: c, children: /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ i(Ve, { children: /* @__PURE__ */ p(u, { direction: "column", gap: "24px", children: [
|
|
303
303
|
/* @__PURE__ */ i(u, { direction: "column", gap: "24px", children: /* @__PURE__ */ p(u, { alignItems: "center", justifyContent: "space-between", children: [
|
|
@@ -504,7 +504,7 @@ const Ge = {
|
|
|
504
504
|
handleSubmitForm: b,
|
|
505
505
|
handleDelete: T,
|
|
506
506
|
terms: m = !0
|
|
507
|
-
} = e, w =
|
|
507
|
+
} = e, w = I("(max-width: 681px)"), C = I("(max-width: 400px)"), { renderedCards: A, shouldRenderAddCard: U } = Qe({
|
|
508
508
|
controls: t,
|
|
509
509
|
customTitleContentAddCard: n,
|
|
510
510
|
decisions: o,
|
|
@@ -513,7 +513,7 @@ const Ge = {
|
|
|
513
513
|
handleDelete: T,
|
|
514
514
|
textValues: r
|
|
515
515
|
}), M = (o == null ? void 0 : o.length) === 0 && !h;
|
|
516
|
-
return /* @__PURE__ */ p(
|
|
516
|
+
return /* @__PURE__ */ p(N, { children: [
|
|
517
517
|
/* @__PURE__ */ i(je, { children: /* @__PURE__ */ i(qe, { children: /* @__PURE__ */ i(u, { direction: "column", gap: "16px", padding: "6px", children: M ? /* @__PURE__ */ p(
|
|
518
518
|
u,
|
|
519
519
|
{
|
|
@@ -524,7 +524,7 @@ const Ge = {
|
|
|
524
524
|
justifyContent: "center",
|
|
525
525
|
alignItems: "center",
|
|
526
526
|
children: [
|
|
527
|
-
/* @__PURE__ */ i(x, { as: "span", type: "label", size: "large", appearance: "gray", children: a || /* @__PURE__ */ p(
|
|
527
|
+
/* @__PURE__ */ i(x, { as: "span", type: "label", size: "large", appearance: "gray", children: a || /* @__PURE__ */ p(N, { children: [
|
|
528
528
|
"Aún NO tienes definidas tasas de interés efectivas . Presiona",
|
|
529
529
|
/* @__PURE__ */ p(
|
|
530
530
|
x,
|
|
@@ -544,7 +544,7 @@ const Ge = {
|
|
|
544
544
|
"para empezar."
|
|
545
545
|
] }) }),
|
|
546
546
|
/* @__PURE__ */ i(
|
|
547
|
-
|
|
547
|
+
E,
|
|
548
548
|
{
|
|
549
549
|
iconBefore: /* @__PURE__ */ i(ae, {}),
|
|
550
550
|
onClick: () => s ? s() : null,
|
|
@@ -602,7 +602,7 @@ const Ge = {
|
|
|
602
602
|
}
|
|
603
603
|
)
|
|
604
604
|
] });
|
|
605
|
-
},
|
|
605
|
+
}, Ze = f.div`
|
|
606
606
|
display: flex;
|
|
607
607
|
justify-content: ${({ justifyContent: e }) => e};
|
|
608
608
|
align-items: ${({ alignItems: e }) => e};
|
|
@@ -625,7 +625,7 @@ const Ge = {
|
|
|
625
625
|
border-radius: ${({ borderRadius: e }) => e};
|
|
626
626
|
box-sizing: ${({ boxSizing: e }) => e};
|
|
627
627
|
overflow-y: ${({ scroll: e }) => e ? "scroll" : "none"};
|
|
628
|
-
`,
|
|
628
|
+
`, Ye = (e) => {
|
|
629
629
|
const {
|
|
630
630
|
children: t,
|
|
631
631
|
wrap: n,
|
|
@@ -645,7 +645,7 @@ const Ge = {
|
|
|
645
645
|
scroll: C = !1
|
|
646
646
|
} = e;
|
|
647
647
|
return /* @__PURE__ */ i(
|
|
648
|
-
|
|
648
|
+
Ze,
|
|
649
649
|
{
|
|
650
650
|
direction: a,
|
|
651
651
|
justifyContent: o,
|
|
@@ -669,7 +669,7 @@ const Ge = {
|
|
|
669
669
|
const { appliedFilters: t, onClear: n, onClick: a, titleClearFilter: o, titleFilter: r } = e, c = !t || t.length === 0;
|
|
670
670
|
return /* @__PURE__ */ i(Te, { borderRadius: "8px", children: /* @__PURE__ */ p(oe, { gap: "12px", templateColumns: "1fr auto auto", children: [
|
|
671
671
|
/* @__PURE__ */ i(
|
|
672
|
-
|
|
672
|
+
Ye,
|
|
673
673
|
{
|
|
674
674
|
background: !0,
|
|
675
675
|
borderRadius: "8px",
|
|
@@ -691,7 +691,7 @@ const Ge = {
|
|
|
691
691
|
}
|
|
692
692
|
),
|
|
693
693
|
/* @__PURE__ */ i(
|
|
694
|
-
|
|
694
|
+
E,
|
|
695
695
|
{
|
|
696
696
|
cursorHover: !0,
|
|
697
697
|
disabled: c,
|
|
@@ -702,7 +702,7 @@ const Ge = {
|
|
|
702
702
|
}
|
|
703
703
|
),
|
|
704
704
|
/* @__PURE__ */ i(
|
|
705
|
-
|
|
705
|
+
E,
|
|
706
706
|
{
|
|
707
707
|
cursorHover: !0,
|
|
708
708
|
iconBefore: /* @__PURE__ */ i(be, {}),
|
|
@@ -725,7 +725,7 @@ const Ge = {
|
|
|
725
725
|
padding: 24px;
|
|
726
726
|
gap: 24px;
|
|
727
727
|
box-sizing: border-box;
|
|
728
|
-
`,
|
|
728
|
+
`, Rt = (e) => {
|
|
729
729
|
const {
|
|
730
730
|
actionButtonLabel: t,
|
|
731
731
|
cancelButtonLabel: n,
|
|
@@ -735,7 +735,7 @@ const Ge = {
|
|
|
735
735
|
onCloseModal: c,
|
|
736
736
|
portalId: g,
|
|
737
737
|
title: d
|
|
738
|
-
} = e, h =
|
|
738
|
+
} = e, h = I("(max-width: 768px)"), s = document.getElementById(g);
|
|
739
739
|
if (!s)
|
|
740
740
|
throw new Error(
|
|
741
741
|
"The portal node is not defined. This can occur when the specific node used to render the portal has not been defined correctly."
|
|
@@ -763,7 +763,7 @@ const Ge = {
|
|
|
763
763
|
a,
|
|
764
764
|
/* @__PURE__ */ p(u, { gap: "20px", justifyContent: "flex-end", children: [
|
|
765
765
|
/* @__PURE__ */ i(
|
|
766
|
-
|
|
766
|
+
E,
|
|
767
767
|
{
|
|
768
768
|
appearance: "gray",
|
|
769
769
|
onClick: c,
|
|
@@ -773,7 +773,7 @@ const Ge = {
|
|
|
773
773
|
}
|
|
774
774
|
),
|
|
775
775
|
/* @__PURE__ */ i(
|
|
776
|
-
|
|
776
|
+
E,
|
|
777
777
|
{
|
|
778
778
|
appearance: "primary",
|
|
779
779
|
loading: o,
|
|
@@ -787,7 +787,7 @@ const Ge = {
|
|
|
787
787
|
] }) }),
|
|
788
788
|
s
|
|
789
789
|
);
|
|
790
|
-
},
|
|
790
|
+
}, It = (e) => {
|
|
791
791
|
const { fields: t, onChange: n } = e;
|
|
792
792
|
return /* @__PURE__ */ i(u, { direction: "column", gap: "16px", children: t.map((a) => /* @__PURE__ */ p(u, { gap: "6px", alignItems: "center", children: [
|
|
793
793
|
/* @__PURE__ */ i(u, { padding: "22px 0 0 0", children: /* @__PURE__ */ i(z, { appearance: "primary", icon: a.icon }) }),
|
|
@@ -920,13 +920,13 @@ function nt({
|
|
|
920
920
|
let o;
|
|
921
921
|
const r = {
|
|
922
922
|
ruleName: H().required("Name is required"),
|
|
923
|
-
value:
|
|
923
|
+
value: Y(() => X(
|
|
924
924
|
o.values.howToSetTheDecision
|
|
925
925
|
)(
|
|
926
926
|
o.values.value,
|
|
927
927
|
o.values.decisionDataType
|
|
928
928
|
).schema),
|
|
929
|
-
conditionsThatEstablishesTheDecision:
|
|
929
|
+
conditionsThatEstablishesTheDecision: Y((d, { parent: h }) => {
|
|
930
930
|
var b;
|
|
931
931
|
if ((h == null ? void 0 : h.toggleNone) && Object.keys(h.conditionsThatEstablishesTheDecision || {}).length > 0) return O().shape({});
|
|
932
932
|
const l = (b = e.conditionsThatEstablishesTheDecision) == null ? void 0 : b.reduce(
|
|
@@ -1049,7 +1049,7 @@ const at = f.div`
|
|
|
1049
1049
|
};
|
|
1050
1050
|
return Ce(() => {
|
|
1051
1051
|
h(t);
|
|
1052
|
-
}, [t]), /* @__PURE__ */ p(
|
|
1052
|
+
}, [t]), /* @__PURE__ */ p(N, { children: [
|
|
1053
1053
|
/* @__PURE__ */ i(u, { children: /* @__PURE__ */ i(
|
|
1054
1054
|
re,
|
|
1055
1055
|
{
|
|
@@ -1062,7 +1062,7 @@ const at = f.div`
|
|
|
1062
1062
|
children: /* @__PURE__ */ i(x, { size: "medium", type: "label", weight: "bold", children: r })
|
|
1063
1063
|
}
|
|
1064
1064
|
) }),
|
|
1065
|
-
d && /* @__PURE__ */ i(
|
|
1065
|
+
d && /* @__PURE__ */ i(N, { children: n })
|
|
1066
1066
|
] });
|
|
1067
1067
|
}, rt = (e) => {
|
|
1068
1068
|
const {
|
|
@@ -1085,8 +1085,8 @@ const at = f.div`
|
|
|
1085
1085
|
A(S.target.value), t(S);
|
|
1086
1086
|
}, ue = (S) => {
|
|
1087
1087
|
M(S.target.value), n(S);
|
|
1088
|
-
}, pe =
|
|
1089
|
-
return /* @__PURE__ */ p(
|
|
1088
|
+
}, pe = I("(max-width: 400px)");
|
|
1089
|
+
return /* @__PURE__ */ p(N, { children: [
|
|
1090
1090
|
/* @__PURE__ */ p(u, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
|
|
1091
1091
|
/* @__PURE__ */ i(
|
|
1092
1092
|
x,
|
|
@@ -1169,7 +1169,7 @@ const at = f.div`
|
|
|
1169
1169
|
termEndStatus: s
|
|
1170
1170
|
} = e;
|
|
1171
1171
|
return /* @__PURE__ */ i("form", { onSubmit: t.handleSubmit, children: /* @__PURE__ */ p(u, { direction: "column", gap: "24px", children: [
|
|
1172
|
-
|
|
1172
|
+
Z({
|
|
1173
1173
|
condition: r,
|
|
1174
1174
|
formik: t,
|
|
1175
1175
|
isDecision: !0
|
|
@@ -1215,14 +1215,14 @@ const at = f.div`
|
|
|
1215
1215
|
l.conditionName,
|
|
1216
1216
|
l.howToSetTheCondition === y.LIST_OF_VALUES_MULTI
|
|
1217
1217
|
)(b.target.checked),
|
|
1218
|
-
children:
|
|
1218
|
+
children: Z({ condition: l, formik: t })
|
|
1219
1219
|
},
|
|
1220
1220
|
l.conditionName
|
|
1221
1221
|
)) })
|
|
1222
1222
|
]
|
|
1223
1223
|
}
|
|
1224
1224
|
) }) }),
|
|
1225
|
-
n.terms && /* @__PURE__ */ p(
|
|
1225
|
+
n.terms && /* @__PURE__ */ p(N, { children: [
|
|
1226
1226
|
/* @__PURE__ */ i(D, { dashed: !0 }),
|
|
1227
1227
|
/* @__PURE__ */ i(
|
|
1228
1228
|
rt,
|
|
@@ -1247,8 +1247,8 @@ const at = f.div`
|
|
|
1247
1247
|
/* @__PURE__ */ i(D, {}),
|
|
1248
1248
|
d && /* @__PURE__ */ i(x, { type: "label", size: "medium", appearance: "danger", children: String(t.errors.conditionsThatEstablishesTheDecision) }),
|
|
1249
1249
|
/* @__PURE__ */ p(u, { direction: "row", justifyContent: "end", gap: "16px", children: [
|
|
1250
|
-
/* @__PURE__ */ i(
|
|
1251
|
-
/* @__PURE__ */ i(
|
|
1250
|
+
/* @__PURE__ */ i(E, { appearance: "gray", onClick: a, children: n.cancel }),
|
|
1251
|
+
/* @__PURE__ */ i(E, { type: "submit", children: n.confirm })
|
|
1252
1252
|
] })
|
|
1253
1253
|
] }) });
|
|
1254
1254
|
}, st = (e) => {
|
|
@@ -1340,7 +1340,13 @@ const at = f.div`
|
|
|
1340
1340
|
const o = $.keys().next().value;
|
|
1341
1341
|
o !== void 0 && $.delete(o);
|
|
1342
1342
|
}
|
|
1343
|
-
}, ht = (e) =>
|
|
1343
|
+
}, ht = (e) => {
|
|
1344
|
+
const t = e.trim();
|
|
1345
|
+
if (t.length < 3) return !1;
|
|
1346
|
+
if (/^(Mr|Mrs|Ms|Dr|Sr|Sra)\.?\s+[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+(?:\s[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+)?$/.test(t)) return !0;
|
|
1347
|
+
const a = /^[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+(?:\s[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+){1,2}$/;
|
|
1348
|
+
return t === t.toUpperCase() ? !1 : a.test(t);
|
|
1349
|
+
}, ee = /* @__PURE__ */ new Map(), ut = 1e3, pt = (e) => {
|
|
1344
1350
|
const t = Date.now(), n = ee.get(e) || 0;
|
|
1345
1351
|
return t - n < ut ? !0 : (ee.set(e, t), !1);
|
|
1346
1352
|
}, gt = (e) => {
|
|
@@ -1361,7 +1367,6 @@ const at = f.div`
|
|
|
1361
1367
|
if (pt(n))
|
|
1362
1368
|
return console.warn(`[Throttle] Skipped translation for: "${e}"`), e;
|
|
1363
1369
|
const o = gt(e);
|
|
1364
|
-
console.log(`[Detected] ${e} => ${o}`);
|
|
1365
1370
|
try {
|
|
1366
1371
|
const { data: c } = await Se.get(mt, {
|
|
1367
1372
|
params: {
|
|
@@ -1400,8 +1405,8 @@ export {
|
|
|
1400
1405
|
de as BusinessRuleView,
|
|
1401
1406
|
Ft as BusinessRules,
|
|
1402
1407
|
$t as Filter,
|
|
1403
|
-
|
|
1404
|
-
|
|
1408
|
+
Rt as FilterModal,
|
|
1409
|
+
It as FormFilter,
|
|
1405
1410
|
ze as ModalRules,
|
|
1406
1411
|
st as RulesForm,
|
|
1407
1412
|
Mt as revertSortedDataSampleSwitchPlaces,
|