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