@isettingkit/business-rules 0.1.13 → 0.1.14

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