@isettingkit/business-rules 0.1.10 → 0.1.11

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