@isettingkit/business-rules 0.1.13 → 0.1.15
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 +1 -47
- package/dist/index.es.js +283 -256
- package/package.json +4 -5
package/dist/index.es.d.ts
CHANGED
|
@@ -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:
|
|
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,34 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as h, jsx as n, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import { useFormik as Q } from "formik";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Divider as
|
|
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
|
|
6
|
+
import { Text as y } from "@inubekit/text";
|
|
7
7
|
import { Toggle as $ } from "@inubekit/toggle";
|
|
8
|
-
import { ValueHowToSetUp as f,
|
|
9
|
-
import { Textarea as
|
|
10
|
-
import { Date as
|
|
11
|
-
import { Checkbox as
|
|
12
|
-
import { Button as
|
|
13
|
-
import { object as B, string as
|
|
14
|
-
import { DecisionViewConditionRenderer as
|
|
15
|
-
import { MdOutlineRemoveRedEye as
|
|
16
|
-
import { Icon as
|
|
17
|
-
import { inube as
|
|
8
|
+
import { ValueHowToSetUp as f, ValueDataType as j, parsePercentageString as Z, DecisionConditionRenderer as L } from "@isettingkit/input";
|
|
9
|
+
import { Textarea as J } from "@inubekit/textarea";
|
|
10
|
+
import { Date as M } from "@inubekit/date";
|
|
11
|
+
import { Checkbox as K } from "@inubekit/checkbox";
|
|
12
|
+
import { Button as z } from "@inubekit/button";
|
|
13
|
+
import { object as B, string as H, number as F, mixed as I } from "yup";
|
|
14
|
+
import { DecisionViewConditionRenderer as A } from "@isettingkit/view";
|
|
15
|
+
import { MdOutlineRemoveRedEye as W, MdOutlineDelete as X } from "react-icons/md";
|
|
16
|
+
import { Icon as N } from "@inubekit/icon";
|
|
17
|
+
import { inube as Y } from "@inubekit/foundations";
|
|
18
18
|
import G from "styled-components";
|
|
19
|
-
const
|
|
19
|
+
const ee = (t) => {
|
|
20
20
|
const {
|
|
21
21
|
label: e,
|
|
22
|
-
labelText:
|
|
22
|
+
labelText: a,
|
|
23
23
|
onHandleChange: i,
|
|
24
24
|
placeholder: l,
|
|
25
|
-
required:
|
|
26
|
-
value:
|
|
27
|
-
} =
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
/* @__PURE__ */ n(
|
|
25
|
+
required: c,
|
|
26
|
+
value: m = ""
|
|
27
|
+
} = t, [d, 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
|
-
|
|
31
|
+
J,
|
|
32
32
|
{
|
|
33
33
|
id: "reasonChange",
|
|
34
34
|
label: e,
|
|
@@ -36,58 +36,58 @@ const X = (a) => {
|
|
|
36
36
|
b(p.target.value), i(p);
|
|
37
37
|
},
|
|
38
38
|
placeholder: l,
|
|
39
|
-
required:
|
|
40
|
-
value:
|
|
39
|
+
required: c,
|
|
40
|
+
value: d,
|
|
41
41
|
maxLength: 120,
|
|
42
42
|
fullwidth: !0
|
|
43
43
|
}
|
|
44
44
|
) })
|
|
45
45
|
] });
|
|
46
|
-
},
|
|
46
|
+
}, ne = (t) => {
|
|
47
47
|
const {
|
|
48
48
|
checked: e,
|
|
49
|
-
children:
|
|
49
|
+
children: a,
|
|
50
50
|
handleToggleChange: i,
|
|
51
51
|
id: l,
|
|
52
|
-
labelToggle:
|
|
53
|
-
name:
|
|
54
|
-
valueToggle:
|
|
55
|
-
} =
|
|
52
|
+
labelToggle: c,
|
|
53
|
+
name: m,
|
|
54
|
+
valueToggle: d = ""
|
|
55
|
+
} = t, [b, C] = x(e), p = (v) => {
|
|
56
56
|
C(v.target.checked), i(v);
|
|
57
57
|
};
|
|
58
|
-
return
|
|
58
|
+
return P(() => {
|
|
59
59
|
C(e);
|
|
60
|
-
}, [e]), /* @__PURE__ */
|
|
60
|
+
}, [e]), /* @__PURE__ */ h(R, { 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:
|
|
67
|
+
name: m,
|
|
68
68
|
onChange: p,
|
|
69
69
|
size: "small",
|
|
70
|
-
value:
|
|
71
|
-
children: /* @__PURE__ */ n(
|
|
70
|
+
value: d,
|
|
71
|
+
children: /* @__PURE__ */ n(y, { size: "medium", type: "label", weight: "bold", children: c })
|
|
72
72
|
}
|
|
73
73
|
) }),
|
|
74
|
-
b && /* @__PURE__ */ n(
|
|
74
|
+
b && /* @__PURE__ */ n(R, { children: a })
|
|
75
75
|
] });
|
|
76
|
-
},
|
|
76
|
+
}, te = (t) => {
|
|
77
77
|
const {
|
|
78
78
|
onHandleStartChange: e,
|
|
79
|
-
onHandleEndChange:
|
|
79
|
+
onHandleEndChange: a,
|
|
80
80
|
labelStart: i,
|
|
81
81
|
labelEnd: l,
|
|
82
|
-
checkedClosed:
|
|
83
|
-
required:
|
|
84
|
-
valueStart:
|
|
82
|
+
checkedClosed: c = !1,
|
|
83
|
+
required: m = !1,
|
|
84
|
+
valueStart: d = "",
|
|
85
85
|
valueEnd: b = ""
|
|
86
|
-
} =
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
86
|
+
} = t, [C, p] = x(c), [v, E] = x(d), [S, T] = x(b);
|
|
87
|
+
return /* @__PURE__ */ h(R, { children: [
|
|
88
|
+
/* @__PURE__ */ h(o, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
|
|
89
89
|
/* @__PURE__ */ n(o, { children: /* @__PURE__ */ n(
|
|
90
|
-
|
|
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
|
-
|
|
108
|
+
K,
|
|
109
109
|
{
|
|
110
110
|
label: "Cerrada",
|
|
111
|
-
onChange: ({ target:
|
|
112
|
-
p(
|
|
111
|
+
onChange: ({ target: s }) => {
|
|
112
|
+
p(s.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__ */
|
|
121
|
+
/* @__PURE__ */ h(o, { justifyContent: "space-between", gap: "24px", children: [
|
|
122
122
|
/* @__PURE__ */ n(o, { width: "189px", children: /* @__PURE__ */ n(
|
|
123
|
-
|
|
123
|
+
M,
|
|
124
124
|
{
|
|
125
125
|
id: "dateStart",
|
|
126
126
|
label: i,
|
|
127
|
-
onChange: (
|
|
128
|
-
|
|
127
|
+
onChange: (s) => {
|
|
128
|
+
E(s.target.value), e(s);
|
|
129
129
|
},
|
|
130
130
|
value: v,
|
|
131
|
-
required:
|
|
131
|
+
required: m,
|
|
132
132
|
size: "compact"
|
|
133
133
|
}
|
|
134
134
|
) }),
|
|
135
135
|
C && /* @__PURE__ */ n(o, { width: "189px", children: /* @__PURE__ */ n(
|
|
136
|
-
|
|
136
|
+
M,
|
|
137
137
|
{
|
|
138
138
|
id: "dateEnd",
|
|
139
139
|
label: l,
|
|
140
|
-
onChange: (
|
|
141
|
-
|
|
140
|
+
onChange: (s) => {
|
|
141
|
+
T(s.target.value), a(s);
|
|
142
142
|
},
|
|
143
|
-
value:
|
|
144
|
-
required:
|
|
143
|
+
value: S,
|
|
144
|
+
required: m,
|
|
145
145
|
size: "compact"
|
|
146
146
|
}
|
|
147
147
|
) })
|
|
148
148
|
] })
|
|
149
149
|
] });
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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: I().test(
|
|
157
|
+
"isArrayOrString",
|
|
158
|
+
"Must be an array of strings/numbers or a single string",
|
|
159
|
+
(l) => Array.isArray(l) ? l.every(
|
|
160
|
+
(c) => typeof c == "string" || typeof c == "number"
|
|
161
|
+
) : typeof l == "string"
|
|
162
|
+
),
|
|
163
|
+
value: e
|
|
164
|
+
};
|
|
165
|
+
case f.LIST_OF_VALUES_MULTI:
|
|
166
|
+
return {
|
|
167
|
+
schema: I().test(
|
|
168
|
+
"isArrayOrString",
|
|
169
|
+
"Must be an array of strings/numbers or a single string",
|
|
170
|
+
(l) => Array.isArray(l) ? l.every(
|
|
171
|
+
(c) => typeof c == "string" || typeof c == "number"
|
|
172
|
+
) : typeof l == "string"
|
|
173
|
+
),
|
|
174
|
+
value: e
|
|
175
|
+
};
|
|
176
|
+
case f.RANGE:
|
|
177
|
+
return {
|
|
178
|
+
schema: B({
|
|
179
|
+
from: F().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: F().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 === j.PERCENTAGE ? {
|
|
191
|
+
schema: F().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: H().required("Required"),
|
|
195
|
+
value: e
|
|
196
|
+
};
|
|
197
|
+
default:
|
|
198
|
+
return {
|
|
199
|
+
schema: H(),
|
|
200
|
+
value: void 0
|
|
201
|
+
};
|
|
202
|
+
}
|
|
190
203
|
}
|
|
191
|
-
},
|
|
192
|
-
const e = {},
|
|
193
|
-
if (
|
|
194
|
-
const i =
|
|
195
|
-
i && (e[
|
|
204
|
+
}, ae = (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
|
|
198
|
-
const l =
|
|
199
|
-
l && (e[i.name] = l.schema,
|
|
200
|
-
}), { validationSchema: B().shape(e), initialValues:
|
|
201
|
-
},
|
|
202
|
-
if (typeof
|
|
203
|
-
return
|
|
204
|
-
if (typeof
|
|
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
|
-
|
|
207
|
-
|
|
219
|
+
from: t.from || "",
|
|
220
|
+
to: t.to || ""
|
|
208
221
|
};
|
|
209
|
-
for (const e in
|
|
210
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
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
|
-
},
|
|
216
|
-
var
|
|
228
|
+
}, re = (t) => {
|
|
229
|
+
var D;
|
|
217
230
|
const {
|
|
218
231
|
decision: e,
|
|
219
|
-
formik:
|
|
232
|
+
formik: a,
|
|
220
233
|
onChangeCondition: i,
|
|
221
234
|
onChangeDecision: l,
|
|
222
|
-
onStartChange:
|
|
223
|
-
onEndChange:
|
|
224
|
-
textValues:
|
|
235
|
+
onStartChange: c,
|
|
236
|
+
onEndChange: m,
|
|
237
|
+
textValues: d,
|
|
225
238
|
onCancel: b,
|
|
226
239
|
onSubmit: C
|
|
227
|
-
} =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
} = t, [p, v] = x(!1), [E, S] = x(!0), T = {
|
|
241
|
+
name: e.name,
|
|
242
|
+
dataType: e.dataType,
|
|
243
|
+
value: e.dataType === "percentage" ? Z(e.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 k = (r) => {
|
|
232
251
|
v(r.target.checked);
|
|
233
252
|
}, w = (r) => {
|
|
234
|
-
r.target.value ?
|
|
235
|
-
}, S = (r) => {
|
|
236
|
-
const h = R(t.errors[r] || {});
|
|
237
|
-
return typeof h == "string" ? h ? "invalid" : "pending" : h;
|
|
253
|
+
r.target.value ? S(!1) : S(!0);
|
|
238
254
|
}, u = (r) => {
|
|
239
|
-
const
|
|
240
|
-
return
|
|
255
|
+
const g = U(a.errors[r] || {});
|
|
256
|
+
return typeof g == "string" ? g ? "invalid" : "pending" : g;
|
|
257
|
+
}, s = (r) => {
|
|
258
|
+
const g = U(a.errors[r] || {});
|
|
259
|
+
return g;
|
|
241
260
|
};
|
|
242
|
-
return /* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
/* @__PURE__ */ n(
|
|
245
|
-
e
|
|
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: d.criteria }),
|
|
264
|
+
e && /* @__PURE__ */ n(
|
|
246
265
|
L,
|
|
247
266
|
{
|
|
248
|
-
element:
|
|
267
|
+
element: T,
|
|
249
268
|
onDecision: l,
|
|
250
|
-
valueData:
|
|
251
|
-
message:
|
|
252
|
-
status:
|
|
269
|
+
valueData: a.values[e.name],
|
|
270
|
+
message: a.errors[e.name],
|
|
271
|
+
status: u(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(
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
/* @__PURE__ */ n(
|
|
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: d.factsThatConditionIt }),
|
|
266
285
|
/* @__PURE__ */ n(
|
|
267
286
|
$,
|
|
268
287
|
{
|
|
269
288
|
id: "toogleNone",
|
|
270
|
-
onChange:
|
|
289
|
+
onChange: k,
|
|
271
290
|
checked: p,
|
|
272
291
|
size: "small",
|
|
273
|
-
children: /* @__PURE__ */ n(
|
|
292
|
+
children: /* @__PURE__ */ n(y, { size: "medium", type: "label", weight: "bold", children: d.none })
|
|
274
293
|
}
|
|
275
294
|
)
|
|
276
295
|
] }),
|
|
277
296
|
e.conditions && e.conditions.map((r) => /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
|
|
278
|
-
|
|
297
|
+
ne,
|
|
279
298
|
{
|
|
280
299
|
checked: !p,
|
|
281
|
-
handleToggleChange: (
|
|
282
|
-
|
|
300
|
+
handleToggleChange: (g) => {
|
|
301
|
+
g.target.checked || i(
|
|
283
302
|
{
|
|
284
303
|
value: "",
|
|
285
|
-
|
|
286
|
-
|
|
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:
|
|
301
|
-
message:
|
|
302
|
-
status:
|
|
319
|
+
valueData: a.values[r.name],
|
|
320
|
+
message: s(r.name),
|
|
321
|
+
status: u(r.name),
|
|
303
322
|
textValues: {
|
|
304
323
|
selectOptions: "Select an option",
|
|
305
324
|
selectOption: "Option selected",
|
|
306
|
-
rangeMin: (
|
|
307
|
-
rangeMax: (
|
|
325
|
+
rangeMin: (g) => `Minimum ${g}`,
|
|
326
|
+
rangeMax: (g) => `Maximum ${g}`
|
|
308
327
|
}
|
|
309
328
|
}
|
|
310
329
|
)
|
|
311
330
|
}
|
|
312
331
|
) }, r.name))
|
|
313
332
|
] }),
|
|
314
|
-
/* @__PURE__ */ n(
|
|
333
|
+
/* @__PURE__ */ n(V, { dashed: !0 }),
|
|
315
334
|
/* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
|
|
316
|
-
|
|
335
|
+
ee,
|
|
317
336
|
{
|
|
318
|
-
label:
|
|
319
|
-
labelText:
|
|
337
|
+
label: d.reasonForChange,
|
|
338
|
+
labelText: d.change,
|
|
320
339
|
onHandleChange: w,
|
|
321
|
-
placeholder:
|
|
340
|
+
placeholder: d.changePlaceholder,
|
|
322
341
|
required: !0
|
|
323
342
|
}
|
|
324
343
|
) }),
|
|
325
|
-
/* @__PURE__ */ n(
|
|
326
|
-
/* @__PURE__ */ n(o, { direction: "column", children: e
|
|
327
|
-
|
|
344
|
+
/* @__PURE__ */ n(V, { dashed: !0 }),
|
|
345
|
+
/* @__PURE__ */ n(o, { direction: "column", children: e && /* @__PURE__ */ n(
|
|
346
|
+
te,
|
|
328
347
|
{
|
|
329
|
-
onHandleStartChange: (r) =>
|
|
330
|
-
onHandleEndChange: (r) =>
|
|
331
|
-
labelStart:
|
|
332
|
-
labelEnd:
|
|
333
|
-
checkedClosed: !!e.
|
|
334
|
-
valueStart: e.
|
|
335
|
-
|
|
336
|
-
),
|
|
337
|
-
valueEnd: ((c = e.decision.endDate) == null ? void 0 : c.toLocaleDateString("en-CA")) || ""
|
|
348
|
+
onHandleStartChange: (r) => c(r.target.value),
|
|
349
|
+
onHandleEndChange: (r) => m(r.target.value),
|
|
350
|
+
labelStart: d.termStart,
|
|
351
|
+
labelEnd: d.termEnd,
|
|
352
|
+
checkedClosed: !!e.endDate,
|
|
353
|
+
valueStart: e.startDate.toLocaleDateString("en-CA"),
|
|
354
|
+
valueEnd: ((D = e.endDate) == null ? void 0 : D.toLocaleDateString("en-CA")) || ""
|
|
338
355
|
}
|
|
339
356
|
) }),
|
|
340
|
-
/* @__PURE__ */ n(
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
/* @__PURE__ */ n(
|
|
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: d.cancel }),
|
|
343
360
|
/* @__PURE__ */ n(
|
|
344
|
-
|
|
361
|
+
z,
|
|
345
362
|
{
|
|
346
363
|
onClick: C,
|
|
347
|
-
disabled:
|
|
364
|
+
disabled: E || !a.isValid,
|
|
348
365
|
type: "submit",
|
|
349
|
-
children:
|
|
366
|
+
children: d.confirm
|
|
350
367
|
}
|
|
351
368
|
)
|
|
352
369
|
] })
|
|
353
370
|
] });
|
|
354
|
-
},
|
|
355
|
-
const { id: e, decision:
|
|
356
|
-
|
|
357
|
-
}, C = (u,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
371
|
+
}, ke = (t) => {
|
|
372
|
+
const { id: e, decision: a, onCancel: i, onSubmitEvent: l, textValues: c } = t, [m, d] = x(a), b = (u, s) => {
|
|
373
|
+
k.setFieldValue(u, s), k.validateField(u);
|
|
374
|
+
}, C = (u, s) => {
|
|
375
|
+
const D = u instanceof Date ? u.toISOString() : u;
|
|
376
|
+
d((r) => {
|
|
377
|
+
if (!r.conditions)
|
|
378
|
+
return r;
|
|
379
|
+
const g = r.conditions.map((O) => O.name === s ? { ...O, value: D } : O);
|
|
380
|
+
return {
|
|
381
|
+
...r,
|
|
382
|
+
conditions: g
|
|
383
|
+
};
|
|
384
|
+
}), b(s, D);
|
|
363
385
|
}, p = (u) => {
|
|
364
|
-
|
|
365
|
-
(
|
|
386
|
+
d(
|
|
387
|
+
(s) => w(s, "value", u)
|
|
366
388
|
);
|
|
367
389
|
}, v = (u) => {
|
|
368
|
-
|
|
369
|
-
(
|
|
390
|
+
d(
|
|
391
|
+
(s) => w(s, "endDate", new Date(u))
|
|
370
392
|
);
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
(
|
|
393
|
+
}, E = (u) => {
|
|
394
|
+
d(
|
|
395
|
+
(s) => w(s, "startDate", new Date(u))
|
|
374
396
|
);
|
|
375
|
-
}, { validationSchema:
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
initialValues:
|
|
379
|
-
validationSchema:
|
|
397
|
+
}, { validationSchema: S, initialValues: T } = ae(m);
|
|
398
|
+
S.validate(T, { abortEarly: !1 }).then(() => console.log("Validation passed")).catch((u) => console.log("Validation failed:", u.errors));
|
|
399
|
+
const k = Q({
|
|
400
|
+
initialValues: T,
|
|
401
|
+
validationSchema: S,
|
|
380
402
|
validateOnChange: !0,
|
|
381
403
|
validateOnBlur: !0,
|
|
382
404
|
onSubmit: () => {
|
|
383
|
-
l(
|
|
405
|
+
l(m);
|
|
384
406
|
}
|
|
385
|
-
}),
|
|
407
|
+
}), w = (u, s, D) => ({
|
|
386
408
|
...u,
|
|
387
|
-
|
|
409
|
+
...u.decision,
|
|
410
|
+
[s]: D
|
|
388
411
|
});
|
|
389
412
|
return /* @__PURE__ */ n(
|
|
390
|
-
|
|
413
|
+
re,
|
|
391
414
|
{
|
|
392
415
|
id: e,
|
|
393
|
-
formik:
|
|
394
|
-
decision:
|
|
416
|
+
formik: k,
|
|
417
|
+
decision: m,
|
|
395
418
|
onCancel: i,
|
|
396
|
-
onSubmit: () => l(
|
|
419
|
+
onSubmit: () => l(m),
|
|
397
420
|
onChangeCondition: C,
|
|
398
421
|
onChangeDecision: p,
|
|
399
|
-
onStartChange:
|
|
422
|
+
onStartChange: E,
|
|
400
423
|
onEndChange: v,
|
|
401
|
-
textValues:
|
|
424
|
+
textValues: c
|
|
402
425
|
}
|
|
403
426
|
);
|
|
404
|
-
},
|
|
405
|
-
if (!
|
|
427
|
+
}, q = (t) => {
|
|
428
|
+
if (!t)
|
|
406
429
|
return;
|
|
407
|
-
const e =
|
|
430
|
+
const e = t.value;
|
|
408
431
|
if (!e)
|
|
409
432
|
return;
|
|
410
433
|
if (((i) => typeof i == "object" && i !== null)(e))
|
|
411
|
-
switch (
|
|
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
|
-
},
|
|
426
|
-
const { decision: e, textValues:
|
|
448
|
+
}, we = (t) => {
|
|
449
|
+
const { decision: e, textValues: a } = t, i = (c) => c && Object.keys(c).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__ */
|
|
433
|
-
/* @__PURE__ */
|
|
434
|
-
/* @__PURE__ */ n(
|
|
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
|
-
|
|
459
|
+
A,
|
|
437
460
|
{
|
|
438
461
|
element: l,
|
|
439
|
-
valueData:
|
|
462
|
+
valueData: q(l)
|
|
440
463
|
}
|
|
441
464
|
) }, e.name) })
|
|
442
465
|
] }),
|
|
443
|
-
/* @__PURE__ */
|
|
444
|
-
/* @__PURE__ */ n(
|
|
445
|
-
e.conditions && e.conditions.map(
|
|
446
|
-
|
|
447
|
-
|
|
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((c) => {
|
|
469
|
+
const m = c.value;
|
|
470
|
+
return (typeof m == "object" && i(m) || m) && /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
|
|
471
|
+
A,
|
|
448
472
|
{
|
|
449
|
-
element:
|
|
450
|
-
|
|
473
|
+
element: {
|
|
474
|
+
...c,
|
|
475
|
+
value: m
|
|
476
|
+
},
|
|
477
|
+
valueData: q(c)
|
|
451
478
|
}
|
|
452
|
-
) },
|
|
453
|
-
)
|
|
479
|
+
) }, c.name);
|
|
480
|
+
})
|
|
454
481
|
] }),
|
|
455
|
-
/* @__PURE__ */
|
|
456
|
-
/* @__PURE__ */ n(
|
|
457
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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:
|
|
492
|
+
dataType: j.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
|
-
|
|
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:
|
|
507
|
+
dataType: j.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
|
-
},
|
|
516
|
+
}, oe = G.div`
|
|
490
517
|
border-radius: 8px;
|
|
491
|
-
border: 1px solid ${
|
|
518
|
+
border: 1px solid ${Y.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
|
-
`,
|
|
525
|
+
`, ie = 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
|
-
`,
|
|
517
|
-
const { children: e, handleDelete:
|
|
518
|
-
return /* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */ n(o, { height: "282px", gap: "24px", direction: "column", children: /* @__PURE__ */ n(
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */ n(
|
|
522
|
-
/* @__PURE__ */
|
|
543
|
+
`, Ee = (t) => {
|
|
544
|
+
const { children: e, handleDelete: a, handleView: i, id: l } = t;
|
|
545
|
+
return /* @__PURE__ */ h(oe, { children: [
|
|
546
|
+
/* @__PURE__ */ n(o, { height: "282px", gap: "24px", direction: "column", children: /* @__PURE__ */ n(ie, { 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
|
-
|
|
551
|
+
N,
|
|
525
552
|
{
|
|
526
553
|
appearance: "dark",
|
|
527
554
|
size: "24px",
|
|
528
555
|
cursorHover: !0,
|
|
529
|
-
icon: /* @__PURE__ */ n(
|
|
556
|
+
icon: /* @__PURE__ */ n(W, {}),
|
|
530
557
|
onClick: () => {
|
|
531
558
|
i(l);
|
|
532
559
|
}
|
|
533
560
|
}
|
|
534
561
|
),
|
|
535
562
|
/* @__PURE__ */ n(
|
|
536
|
-
|
|
563
|
+
N,
|
|
537
564
|
{
|
|
538
565
|
cursorHover: !0,
|
|
539
566
|
appearance: "dark",
|
|
540
567
|
size: "24px",
|
|
541
|
-
icon: /* @__PURE__ */ n(
|
|
568
|
+
icon: /* @__PURE__ */ n(X, {}),
|
|
542
569
|
onClick: () => {
|
|
543
|
-
|
|
570
|
+
a(l);
|
|
544
571
|
}
|
|
545
572
|
}
|
|
546
573
|
)
|
|
@@ -549,7 +576,7 @@ const X = (a) => {
|
|
|
549
576
|
] });
|
|
550
577
|
};
|
|
551
578
|
export {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
579
|
+
Ee as BusinessRuleCard,
|
|
580
|
+
we as BusinessRuleView,
|
|
581
|
+
ke 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
|
+
"version": "0.1.15",
|
|
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.
|
|
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"
|