@isettingkit/business-rules 1.0.6 → 1.0.8

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 +69 -70
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { jsx as i, jsxs as p, Fragment as E } 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 R, Blanket as ie, Button as N, Grid as oe, Box as Te, Tag as fe, Checkpicker as ye, Toggle as re, Checkbox as xe, Date as Q } from "@inubekit/inubekit";
3
+ import { inube as v, Stack as u, Divider as D, Icon as U, Text as x, SkeletonLine as F, useMediaQuery as R, Blanket as ie, Button as N, 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
5
  import { ValueDataType as k, ValueHowToSetUp as L, DecisionConditionRender as Y } from "@isettingkit/input";
6
- import { DecisionViewConditionRenderer as _ } from "@isettingkit/view";
6
+ import { DecisionViewConditionRenderer as z } 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 Z, date as K } from "yup";
9
+ import { string as H, mixed as se, object as O, number as q, lazy as K, date as W } 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";
@@ -48,7 +48,7 @@ const P = (e) => {
48
48
  n && /* @__PURE__ */ p(E, { children: [
49
49
  /* @__PURE__ */ i(D, {}),
50
50
  /* @__PURE__ */ i(u, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ i(
51
- z,
51
+ U,
52
52
  {
53
53
  cursorHover: !0,
54
54
  appearance: "danger",
@@ -61,7 +61,7 @@ const P = (e) => {
61
61
  ) })
62
62
  ] })
63
63
  ] }) });
64
- }, W = f.div`
64
+ }, J = f.div`
65
65
  & > div {
66
66
  border-radius: 8px;
67
67
  border: 1px solid
@@ -70,7 +70,7 @@ const P = (e) => {
70
70
  return ((n = (t = e == null ? void 0 : e.palette) == null ? void 0 : t.neutral) == null ? void 0 : n.N30) || v.palette.neutral.N30;
71
71
  }};
72
72
  }
73
- `, J = f.div`
73
+ `, X = f.div`
74
74
  width: 100%;
75
75
  height: 100%;
76
76
  overflow-y: auto;
@@ -117,7 +117,7 @@ const Me = {
117
117
  } = e;
118
118
  return r ? /* @__PURE__ */ p(u, { direction: "column", gap: "12px", children: [
119
119
  /* @__PURE__ */ i(u, { direction: "column", alignItems: "center", children: /* @__PURE__ */ i(
120
- _,
120
+ z,
121
121
  {
122
122
  element: o,
123
123
  valueData: I(
@@ -127,7 +127,7 @@ const Me = {
127
127
  }
128
128
  ) }, n.ruleName),
129
129
  /* @__PURE__ */ i(D, { dashed: !0 }),
130
- /* @__PURE__ */ i(J, { children: /* @__PURE__ */ p(
130
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ p(
131
131
  u,
132
132
  {
133
133
  direction: "column",
@@ -146,8 +146,8 @@ const Me = {
146
146
  children: d.factsThatConditionIt
147
147
  }
148
148
  ),
149
- h.map((s) => /* @__PURE__ */ i(W, { children: /* @__PURE__ */ i(u, { direction: "column", padding: "8px", children: /* @__PURE__ */ i(
150
- _,
149
+ h.map((s) => /* @__PURE__ */ i(J, { children: /* @__PURE__ */ i(u, { direction: "column", padding: "8px", children: /* @__PURE__ */ i(
150
+ z,
151
151
  {
152
152
  element: { ...s, value: s.value },
153
153
  valueData: I(
@@ -158,7 +158,7 @@ const Me = {
158
158
  g && /* @__PURE__ */ p(E, { children: [
159
159
  /* @__PURE__ */ i(D, { dashed: !0 }),
160
160
  a && /* @__PURE__ */ i(
161
- _,
161
+ z,
162
162
  {
163
163
  element: a.element,
164
164
  valueData: a.valueData,
@@ -179,14 +179,14 @@ const Me = {
179
179
  /* @__PURE__ */ i(D, { dashed: !0 }),
180
180
  /* @__PURE__ */ i(F, { animated: !0, width: "150px" })
181
181
  ] }),
182
- /* @__PURE__ */ i(J, { children: /* @__PURE__ */ i(
182
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(
183
183
  u,
184
184
  {
185
185
  direction: "column",
186
186
  gap: "12px",
187
187
  justifyContent: "space-between",
188
188
  height: "203px",
189
- children: c.map((s, l) => /* @__PURE__ */ i(W, { children: /* @__PURE__ */ p(
189
+ children: c.map((s, l) => /* @__PURE__ */ i(J, { children: /* @__PURE__ */ p(
190
190
  u,
191
191
  {
192
192
  direction: "column",
@@ -291,7 +291,7 @@ const Me = {
291
291
  background-color: #ebecf0;
292
292
  border-radius: 8px;
293
293
  }
294
- `, ze = (e) => {
294
+ `, Ue = (e) => {
295
295
  const { children: t, portalId: n, onCloseModal: a, title: o } = e, r = document.getElementById(n);
296
296
  if (!r)
297
297
  throw new Error(
@@ -308,7 +308,7 @@ const Me = {
308
308
  ] }) }) }) }),
309
309
  r
310
310
  );
311
- }, Ue = ve`
311
+ }, _e = ve`
312
312
  from {
313
313
  opacity: 0;
314
314
  transform: translateY(20px);
@@ -342,7 +342,7 @@ f.div`
342
342
  }};
343
343
  }
344
344
  `;
345
- const _e = f.div`
345
+ const ze = f.div`
346
346
  & > div {
347
347
  background-color: ${({ theme: e }) => {
348
348
  var t, n;
@@ -358,7 +358,7 @@ const _e = f.div`
358
358
  width: 100%;
359
359
  height: 100%;
360
360
  & > div {
361
- animation: ${Ue} 600ms ease-out;
361
+ animation: ${_e} 600ms ease-out;
362
362
  }
363
363
  `, je = f.div`
364
364
  & > div > div {
@@ -427,7 +427,7 @@ function Pe(e) {
427
427
  return /* @__PURE__ */ i(ce, { children: o ? null : /* @__PURE__ */ p(u, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
428
428
  /* @__PURE__ */ i(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: "Nueva decisión" }),
429
429
  /* @__PURE__ */ i(
430
- _e,
430
+ ze,
431
431
  {
432
432
  onClick: () => a ? a() : null,
433
433
  children: /* @__PURE__ */ i(
@@ -439,7 +439,7 @@ function Pe(e) {
439
439
  handleView: () => a ? a() : null,
440
440
  controls: !1,
441
441
  children: /* @__PURE__ */ p(u, { direction: "column", gap: "12px", alignItems: "center", children: [
442
- /* @__PURE__ */ i(z, { appearance: "gray", icon: /* @__PURE__ */ i(ae, {}), size: "35px" }),
442
+ /* @__PURE__ */ i(U, { appearance: "gray", icon: /* @__PURE__ */ i(ae, {}), size: "35px" }),
443
443
  /* @__PURE__ */ i(x, { appearance: "gray", type: "body", size: "large", children: r })
444
444
  ] })
445
445
  }
@@ -488,7 +488,7 @@ const Ge = {
488
488
  })
489
489
  ), h = ((a == null ? void 0 : a.length) === 0 || a.length < Math.floor(window.innerWidth / 300)) && !o && t;
490
490
  return { renderedCards: d, shouldRenderAddCard: h };
491
- }, Ft = (e) => {
491
+ }, At = (e) => {
492
492
  const {
493
493
  controls: t = !0,
494
494
  customTitleContentAddCard: n,
@@ -504,7 +504,7 @@ const Ge = {
504
504
  handleSubmitForm: b,
505
505
  handleDelete: T,
506
506
  terms: m = !0
507
- } = e, w = R("(max-width: 681px)"), C = R("(max-width: 400px)"), { renderedCards: A, shouldRenderAddCard: U } = Qe({
507
+ } = e, w = R("(max-width: 681px)"), C = R("(max-width: 400px)"), { renderedCards: A, shouldRenderAddCard: _ } = Qe({
508
508
  controls: t,
509
509
  customTitleContentAddCard: n,
510
510
  decisions: o,
@@ -567,7 +567,7 @@ const Ge = {
567
567
  height: w ? "auto" : "484px",
568
568
  children: [
569
569
  A,
570
- U && B({
570
+ _ && B({
571
571
  type: "add",
572
572
  index: o == null ? void 0 : o.length,
573
573
  controls: t,
@@ -584,7 +584,7 @@ const Ge = {
584
584
  }
585
585
  ) }) }) }),
586
586
  g && /* @__PURE__ */ i(
587
- ze,
587
+ Ue,
588
588
  {
589
589
  portalId: "modal-portal",
590
590
  onCloseModal: l,
@@ -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
- `, Ze = (e) => {
628
+ `, Ke = (e) => {
629
629
  const {
630
630
  children: t,
631
631
  wrap: n,
@@ -665,11 +665,11 @@ const Ge = {
665
665
  children: t
666
666
  }
667
667
  );
668
- }, $t = (e) => {
668
+ }, Ft = (e) => {
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
- Ze,
672
+ Ke,
673
673
  {
674
674
  background: !0,
675
675
  borderRadius: "8px",
@@ -712,7 +712,7 @@ const Ge = {
712
712
  }
713
713
  )
714
714
  ] }) });
715
- }, Ke = f.div`
715
+ }, We = f.div`
716
716
  display: flex;
717
717
  flex-direction: column;
718
718
  background-color: ${({ theme: e }) => {
@@ -725,7 +725,7 @@ const Ge = {
725
725
  padding: 24px;
726
726
  gap: 24px;
727
727
  box-sizing: border-box;
728
- `, It = (e) => {
728
+ `, $t = (e) => {
729
729
  const {
730
730
  actionButtonLabel: t,
731
731
  cancelButtonLabel: n,
@@ -741,14 +741,14 @@ const Ge = {
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."
742
742
  );
743
743
  return le(
744
- /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ p(Ke, { $smallScreen: h, children: [
744
+ /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ p(We, { $smallScreen: h, children: [
745
745
  /* @__PURE__ */ p(u, { direction: "column", gap: "16px", children: [
746
746
  /* @__PURE__ */ p(u, { alignContent: "center", justifyContent: "space-between", children: [
747
747
  /* @__PURE__ */ i(x, { appearance: "dark", size: "small", type: "headline", children: d }),
748
748
  /* @__PURE__ */ p(u, { alignItems: "center", children: [
749
749
  /* @__PURE__ */ i(x, { children: "Cerrar" }),
750
750
  /* @__PURE__ */ i(
751
- z,
751
+ U,
752
752
  {
753
753
  appearance: "dark",
754
754
  icon: /* @__PURE__ */ i(ne, {}),
@@ -787,10 +787,10 @@ const Ge = {
787
787
  ] }) }),
788
788
  s
789
789
  );
790
- }, Rt = (e) => {
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
- /* @__PURE__ */ i(u, { padding: "22px 0 0 0", children: /* @__PURE__ */ i(z, { appearance: "primary", icon: a.icon }) }),
793
+ /* @__PURE__ */ i(u, { padding: "22px 0 0 0", children: /* @__PURE__ */ i(U, { appearance: "primary", icon: a.icon }) }),
794
794
  /* @__PURE__ */ i(
795
795
  ye,
796
796
  {
@@ -809,7 +809,7 @@ const Ge = {
809
809
  a.name
810
810
  )
811
811
  ] }, a.name)) });
812
- }, Mt = (e) => {
812
+ }, Rt = (e) => {
813
813
  console.log(e);
814
814
  const { dataDecision: t, originalDecision: n } = e, a = {
815
815
  conditionName: t.ruleName || "",
@@ -826,7 +826,7 @@ const Ge = {
826
826
  (o) => o.hidden ? { ...a } : o
827
827
  )
828
828
  };
829
- }, Lt = (e) => {
829
+ }, Mt = (e) => {
830
830
  const { decisions: t } = e;
831
831
  return t == null ? void 0 : t.map((n) => {
832
832
  var o;
@@ -845,14 +845,14 @@ const Ge = {
845
845
  )
846
846
  } : n;
847
847
  });
848
- }, We = (e) => ({
848
+ }, Je = (e) => ({
849
849
  schema: H().required("Required").test(
850
850
  "non-empty",
851
851
  "Value cannot be empty",
852
852
  (t) => t != null && t.trim() !== ""
853
853
  ),
854
854
  value: e
855
- }), Je = (e) => ({
855
+ }), Xe = (e) => ({
856
856
  schema: se().test(
857
857
  "isArrayOrString",
858
858
  "Must be an array of strings/numbers or a single string",
@@ -861,7 +861,7 @@ const Ge = {
861
861
  ) : typeof t == "string"
862
862
  ),
863
863
  value: e
864
- }), Xe = (e) => ({
864
+ }), Ze = (e) => ({
865
865
  schema: se().test(
866
866
  "isArrayOrString",
867
867
  "Must be an array of strings/numbers or a single string",
@@ -893,13 +893,13 @@ const Ge = {
893
893
  schema: H().required("Required"),
894
894
  value: e
895
895
  }, tt = {
896
- [y.LIST_OF_VALUES]: Je,
897
- [y.LIST_OF_VALUES_MULTI]: Xe,
896
+ [y.LIST_OF_VALUES]: Xe,
897
+ [y.LIST_OF_VALUES_MULTI]: Ze,
898
898
  [y.RANGE]: et,
899
899
  [y.GREATER_THAN]: j,
900
900
  [y.LESS_THAN]: j,
901
901
  [y.EQUAL]: j
902
- }, X = (e) => tt[e] || We;
902
+ }, Z = (e) => tt[e] || Je;
903
903
  function nt({
904
904
  decision: e,
905
905
  onSubmitEvent: t,
@@ -920,19 +920,19 @@ function nt({
920
920
  let o;
921
921
  const r = {
922
922
  ruleName: H().required("Name is required"),
923
- value: Z(() => X(
923
+ value: K(() => Z(
924
924
  o.values.howToSetTheDecision
925
925
  )(
926
926
  o.values.value,
927
927
  o.values.decisionDataType
928
928
  ).schema),
929
- conditionsThatEstablishesTheDecision: Z((d, { parent: h }) => {
929
+ conditionsThatEstablishesTheDecision: K((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(
933
933
  (T, m) => {
934
934
  if (o.values.conditionsThatEstablishesTheDecision[m.conditionName] !== void 0) {
935
- const C = X(
935
+ const C = Z(
936
936
  m.howToSetTheCondition
937
937
  );
938
938
  T[m.conditionName] = C(
@@ -953,9 +953,9 @@ function nt({
953
953
  );
954
954
  })
955
955
  };
956
- n.terms && (r.effectiveFrom = K().required(
956
+ n.terms && (r.effectiveFrom = W().required(
957
957
  "effective From date is required"
958
- ), r.validUntil = K().when(
958
+ ), r.validUntil = W().when(
959
959
  "checkClosed",
960
960
  (d, h, { parent: s }) => (s == null ? void 0 : s.checkClosed) ? h.required("valid Until date is required").test(
961
961
  "is-after-startDate",
@@ -1079,7 +1079,7 @@ const at = f.div`
1079
1079
  messageEnd: l = "",
1080
1080
  statusStart: b = "pending",
1081
1081
  statusEnd: T = "pending"
1082
- } = e, [m, w] = V(c), [C, A] = V(d), [U, M] = V(h), G = ({ target: S }) => {
1082
+ } = e, [m, w] = V(c), [C, A] = V(d), [_, M] = V(h), G = ({ target: S }) => {
1083
1083
  w(S.checked), a && a(S.checked);
1084
1084
  }, he = (S) => {
1085
1085
  A(S.target.value), t(S);
@@ -1144,7 +1144,7 @@ const at = f.div`
1144
1144
  id: "dateEnd",
1145
1145
  label: r,
1146
1146
  onChange: ue,
1147
- value: U,
1147
+ value: _,
1148
1148
  required: g,
1149
1149
  size: "compact",
1150
1150
  status: T,
@@ -1299,7 +1299,7 @@ const at = f.div`
1299
1299
  termEndStatus: l
1300
1300
  }
1301
1301
  );
1302
- }, Ot = (e) => {
1302
+ }, Lt = (e) => {
1303
1303
  var o;
1304
1304
  const { decisionTemplate: t } = e, n = { ...t }, a = (o = n.conditionsThatEstablishesTheDecision) == null ? void 0 : o.find(
1305
1305
  (r) => r.switchPlaces
@@ -1315,7 +1315,7 @@ const at = f.div`
1315
1315
  (r) => r.conditionName === a.conditionName ? { ...r, hidden: !0 } : r
1316
1316
  )
1317
1317
  } : n;
1318
- }, Vt = (e) => {
1318
+ }, Ot = (e) => {
1319
1319
  const { decisions: t } = e;
1320
1320
  return t == null ? void 0 : t.map((n) => {
1321
1321
  var o;
@@ -1340,10 +1340,10 @@ const at = f.div`
1340
1340
  const o = $.keys().next().value;
1341
1341
  o !== void 0 && $.delete(o);
1342
1342
  }
1343
- }, ht = (e) => /^[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+(?:\s[A-ZÁÉÍÓÚÑ][a-záéíóúñ]+)*$/.test(e.trim()), ee = /* @__PURE__ */ new Map(), ut = 1e3, pt = (e) => {
1343
+ }, ee = /* @__PURE__ */ new Map(), ht = 1e3, ut = (e) => {
1344
1344
  const t = Date.now(), n = ee.get(e) || 0;
1345
- return t - n < ut ? !0 : (ee.set(e, t), !1);
1346
- }, gt = (e) => {
1345
+ return t - n < ht ? !0 : (ee.set(e, t), !1);
1346
+ }, pt = (e) => {
1347
1347
  const t = De(e);
1348
1348
  return {
1349
1349
  spa: "es",
@@ -1353,16 +1353,15 @@ const at = f.div`
1353
1353
  ita: "it",
1354
1354
  por: "pt"
1355
1355
  }[t] || "en";
1356
- }, mt = "https://api.mymemory.translated.net/get", bt = async (e, t) => {
1356
+ }, gt = "https://api.mymemory.translated.net/get", mt = async (e, t) => {
1357
1357
  var r;
1358
- if (ht(e)) return e;
1359
1358
  const n = `${t}:${e}`, a = dt(e, t);
1360
1359
  if (a) return a;
1361
- if (pt(n))
1360
+ if (ut(n))
1362
1361
  return console.warn(`[Throttle] Skipped translation for: "${e}"`), e;
1363
- const o = gt(e);
1362
+ const o = pt(e);
1364
1363
  try {
1365
- const { data: c } = await Se.get(mt, {
1364
+ const { data: c } = await Se.get(gt, {
1366
1365
  params: {
1367
1366
  q: e,
1368
1367
  langpair: `${o}|${t}`
@@ -1372,11 +1371,11 @@ const at = f.div`
1372
1371
  } catch (c) {
1373
1372
  return console.warn(`[Translation] Failed for: "${e}"`, c), e;
1374
1373
  }
1375
- }, Tt = (e) => typeof e == "string" && e.trim().length > 0, te = async (e, t) => {
1374
+ }, bt = (e) => typeof e == "string" && e.trim().length > 0, te = async (e, t) => {
1376
1375
  const n = await Promise.all(
1377
1376
  Object.entries(e).map(async ([a, o]) => {
1378
- if (Tt(o)) {
1379
- const r = await bt(o, t);
1377
+ if (bt(o)) {
1378
+ const r = await mt(o, t);
1380
1379
  return [a, r];
1381
1380
  } else if (Array.isArray(o)) {
1382
1381
  const r = await Promise.all(
@@ -1397,16 +1396,16 @@ const at = f.div`
1397
1396
  export {
1398
1397
  P as BusinessRuleCard,
1399
1398
  de as BusinessRuleView,
1400
- Ft as BusinessRules,
1401
- $t as Filter,
1402
- It as FilterModal,
1403
- Rt as FormFilter,
1404
- ze as ModalRules,
1399
+ At as BusinessRules,
1400
+ Ft as Filter,
1401
+ $t as FilterModal,
1402
+ It as FormFilter,
1403
+ Ue as ModalRules,
1405
1404
  st as RulesForm,
1406
- Mt as revertSortedDataSampleSwitchPlaces,
1407
- Lt as revertSortedDataSwitchPlaces,
1408
- Ot as sortDisplayDataSampleSwitchPlaces,
1409
- Vt as sortDisplayDataSwitchPlaces,
1405
+ Rt as revertSortedDataSampleSwitchPlaces,
1406
+ Mt as revertSortedDataSwitchPlaces,
1407
+ Lt as sortDisplayDataSampleSwitchPlaces,
1408
+ Ot as sortDisplayDataSwitchPlaces,
1410
1409
  te as translateObject,
1411
- bt as translateText
1410
+ mt as translateText
1412
1411
  };
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "description": "",
12
12
  "private": false,
13
- "version": "1.0.6",
13
+ "version": "1.0.8",
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": {