@isettingkit/business-rules 0.1.12 → 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.
- package/dist/index.es.d.ts +1 -45
- package/dist/index.es.js +299 -272
- package/package.json +5 -6
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,37 +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
|
-
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
|
-
|
|
50
20
|
export declare interface IRulesForm {
|
|
51
21
|
id: string;
|
|
52
22
|
decision: IRuleDecision;
|
|
@@ -74,20 +44,6 @@ declare interface IRulesFormTextValues {
|
|
|
74
44
|
termStart: string;
|
|
75
45
|
}
|
|
76
46
|
|
|
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
|
-
|
|
91
47
|
export declare const RulesForm: (prop: IRulesForm) => JSX_2.Element;
|
|
92
48
|
|
|
93
49
|
export { }
|
package/dist/index.es.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { jsxs as
|
|
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
|
|
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 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
|
|
19
|
+
const Y = (t) => {
|
|
20
20
|
const {
|
|
21
21
|
label: e,
|
|
22
22
|
labelText: a,
|
|
23
23
|
onHandleChange: i,
|
|
24
|
-
placeholder:
|
|
25
|
-
required:
|
|
26
|
-
value:
|
|
27
|
-
} = t, [
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
/* @__PURE__ */ n(
|
|
24
|
+
placeholder: l,
|
|
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
|
-
|
|
31
|
+
Z,
|
|
32
32
|
{
|
|
33
33
|
id: "reasonChange",
|
|
34
34
|
label: e,
|
|
35
|
-
onChange: (
|
|
36
|
-
b(
|
|
35
|
+
onChange: (g) => {
|
|
36
|
+
b(g.target.value), i(g);
|
|
37
37
|
},
|
|
38
|
-
placeholder:
|
|
39
|
-
required:
|
|
40
|
-
value:
|
|
38
|
+
placeholder: l,
|
|
39
|
+
required: s,
|
|
40
|
+
value: u,
|
|
41
41
|
maxLength: 120,
|
|
42
42
|
fullwidth: !0
|
|
43
43
|
}
|
|
44
44
|
) })
|
|
45
45
|
] });
|
|
46
|
-
},
|
|
46
|
+
}, ee = (t) => {
|
|
47
47
|
const {
|
|
48
48
|
checked: e,
|
|
49
49
|
children: a,
|
|
50
50
|
handleToggleChange: i,
|
|
51
|
-
id:
|
|
52
|
-
labelToggle:
|
|
53
|
-
name:
|
|
54
|
-
valueToggle:
|
|
55
|
-
} = t, [b, C] =
|
|
51
|
+
id: l,
|
|
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
|
|
58
|
+
return P(() => {
|
|
59
59
|
C(e);
|
|
60
|
-
}, [e]), /* @__PURE__ */
|
|
60
|
+
}, [e]), /* @__PURE__ */ h(F, { children: [
|
|
61
61
|
/* @__PURE__ */ n(o, { children: /* @__PURE__ */ n(
|
|
62
62
|
$,
|
|
63
63
|
{
|
|
64
64
|
checked: b,
|
|
65
|
-
id:
|
|
65
|
+
id: l,
|
|
66
66
|
margin: "10px",
|
|
67
|
-
name:
|
|
68
|
-
onChange:
|
|
67
|
+
name: m,
|
|
68
|
+
onChange: g,
|
|
69
69
|
size: "small",
|
|
70
|
-
value:
|
|
71
|
-
children: /* @__PURE__ */ n(
|
|
70
|
+
value: u,
|
|
71
|
+
children: /* @__PURE__ */ n(y, { size: "medium", type: "label", weight: "bold", children: s })
|
|
72
72
|
}
|
|
73
73
|
) }),
|
|
74
|
-
b && /* @__PURE__ */ n(
|
|
74
|
+
b && /* @__PURE__ */ n(F, { children: a })
|
|
75
75
|
] });
|
|
76
|
-
},
|
|
76
|
+
}, ne = (t) => {
|
|
77
77
|
const {
|
|
78
78
|
onHandleStartChange: e,
|
|
79
79
|
onHandleEndChange: a,
|
|
80
80
|
labelStart: i,
|
|
81
|
-
labelEnd:
|
|
82
|
-
checkedClosed:
|
|
83
|
-
required:
|
|
84
|
-
valueStart:
|
|
81
|
+
labelEnd: l,
|
|
82
|
+
checkedClosed: s = !1,
|
|
83
|
+
required: m = !1,
|
|
84
|
+
valueStart: u = "",
|
|
85
85
|
valueEnd: b = ""
|
|
86
|
-
} = t, [C,
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
90
|
+
y,
|
|
91
91
|
{
|
|
92
92
|
appearance: "gray",
|
|
93
93
|
margin: "10px 0",
|
|
@@ -105,11 +105,11 @@ const X = (t) => {
|
|
|
105
105
|
wrap: "wrap",
|
|
106
106
|
gap: "4px",
|
|
107
107
|
children: /* @__PURE__ */ n(
|
|
108
|
-
|
|
108
|
+
J,
|
|
109
109
|
{
|
|
110
110
|
label: "Cerrada",
|
|
111
|
-
onChange: ({ target:
|
|
112
|
-
|
|
111
|
+
onChange: ({ target: d }) => {
|
|
112
|
+
g(d.checked);
|
|
113
113
|
},
|
|
114
114
|
checked: C,
|
|
115
115
|
value: ""
|
|
@@ -118,138 +118,157 @@ const X = (t) => {
|
|
|
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: (d) => {
|
|
128
|
+
E(d.target.value), e(d);
|
|
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
|
-
label:
|
|
140
|
-
onChange: (
|
|
141
|
-
|
|
139
|
+
label: l,
|
|
140
|
+
onChange: (d) => {
|
|
141
|
+
T(d.target.value), a(d);
|
|
142
142
|
},
|
|
143
|
-
value:
|
|
144
|
-
required:
|
|
143
|
+
value: D,
|
|
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: 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
|
-
},
|
|
204
|
+
}, te = (t) => {
|
|
192
205
|
const e = {}, a = {};
|
|
193
|
-
if (t
|
|
194
|
-
const i =
|
|
195
|
-
i && (e[t.
|
|
206
|
+
if (t) {
|
|
207
|
+
const i = _(t);
|
|
208
|
+
i && (e[t.name] = i.schema, a[t.name] = i.value);
|
|
196
209
|
}
|
|
197
210
|
return t.conditions && t.conditions.forEach((i) => {
|
|
198
|
-
const
|
|
199
|
-
|
|
211
|
+
const l = _(i);
|
|
212
|
+
l && (e[i.name] = l.schema, a[i.name] = l.value);
|
|
200
213
|
}), { validationSchema: B().shape(e), initialValues: a };
|
|
201
|
-
},
|
|
214
|
+
}, U = (t) => {
|
|
202
215
|
if (typeof t == "string")
|
|
203
216
|
return t;
|
|
204
|
-
if (typeof t == "object" && ("
|
|
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
222
|
for (const e in t)
|
|
210
223
|
if (Object.prototype.hasOwnProperty.call(t, e)) {
|
|
211
|
-
const a =
|
|
224
|
+
const a = U(t[e]);
|
|
212
225
|
if (a) return a;
|
|
213
226
|
}
|
|
214
227
|
return "";
|
|
215
|
-
},
|
|
216
|
-
var
|
|
228
|
+
}, ae = (t) => {
|
|
229
|
+
var S;
|
|
217
230
|
const {
|
|
218
231
|
decision: e,
|
|
219
232
|
formik: a,
|
|
220
233
|
onChangeCondition: i,
|
|
221
|
-
onChangeDecision:
|
|
222
|
-
onStartChange:
|
|
223
|
-
onEndChange:
|
|
224
|
-
textValues:
|
|
234
|
+
onChangeDecision: l,
|
|
235
|
+
onStartChange: s,
|
|
236
|
+
onEndChange: m,
|
|
237
|
+
textValues: u,
|
|
225
238
|
onCancel: b,
|
|
226
239
|
onSubmit: C
|
|
227
|
-
} = t, [
|
|
228
|
-
|
|
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(() => {
|
|
229
248
|
console.log("Updated formik.errors in RulesFormUI:", a.errors);
|
|
230
249
|
}, [a.errors]);
|
|
231
|
-
const
|
|
250
|
+
const w = (r) => {
|
|
232
251
|
v(r.target.checked);
|
|
233
|
-
},
|
|
234
|
-
r.target.value ?
|
|
235
|
-
},
|
|
236
|
-
const
|
|
237
|
-
return typeof
|
|
238
|
-
},
|
|
239
|
-
const
|
|
240
|
-
return
|
|
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__ */
|
|
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: u.criteria }),
|
|
264
|
+
e && /* @__PURE__ */ n(
|
|
246
265
|
L,
|
|
247
266
|
{
|
|
248
|
-
element:
|
|
249
|
-
onDecision:
|
|
250
|
-
valueData: a.values[e.
|
|
251
|
-
message: a.errors[e.
|
|
252
|
-
status:
|
|
267
|
+
element: T,
|
|
268
|
+
onDecision: l,
|
|
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 = (t) => {
|
|
|
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: u.factsThatConditionIt }),
|
|
266
285
|
/* @__PURE__ */ n(
|
|
267
286
|
$,
|
|
268
287
|
{
|
|
269
288
|
id: "toogleNone",
|
|
270
|
-
onChange:
|
|
271
|
-
checked:
|
|
289
|
+
onChange: w,
|
|
290
|
+
checked: g,
|
|
272
291
|
size: "small",
|
|
273
|
-
children: /* @__PURE__ */ n(
|
|
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
|
-
|
|
297
|
+
ee,
|
|
279
298
|
{
|
|
280
|
-
checked: !
|
|
281
|
-
handleToggleChange: (
|
|
282
|
-
|
|
299
|
+
checked: !g,
|
|
300
|
+
handleToggleChange: (p) => {
|
|
301
|
+
p.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
|
|
@@ -298,110 +317,114 @@ const X = (t) => {
|
|
|
298
317
|
element: r,
|
|
299
318
|
onDecision: i,
|
|
300
319
|
valueData: a.values[r.name],
|
|
301
|
-
message:
|
|
302
|
-
status:
|
|
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: (
|
|
307
|
-
rangeMax: (
|
|
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(
|
|
333
|
+
/* @__PURE__ */ n(V, { dashed: !0 }),
|
|
315
334
|
/* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
|
|
316
|
-
|
|
335
|
+
Y,
|
|
317
336
|
{
|
|
318
|
-
label:
|
|
319
|
-
labelText:
|
|
320
|
-
onHandleChange:
|
|
321
|
-
placeholder:
|
|
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(
|
|
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
|
+
ne,
|
|
328
347
|
{
|
|
329
|
-
onHandleStartChange: (r) =>
|
|
330
|
-
onHandleEndChange: (r) =>
|
|
331
|
-
labelStart:
|
|
332
|
-
labelEnd:
|
|
333
|
-
checkedClosed: !!e.
|
|
334
|
-
valueStart: e.
|
|
335
|
-
|
|
336
|
-
),
|
|
337
|
-
valueEnd: ((s = e.decision.endDate) == null ? void 0 : s.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(
|
|
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: u.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: u.confirm
|
|
350
367
|
}
|
|
351
368
|
)
|
|
352
369
|
] })
|
|
353
370
|
] });
|
|
354
|
-
},
|
|
355
|
-
const { id: e, decision: a, onCancel: i, onSubmitEvent:
|
|
356
|
-
w.setFieldValue(
|
|
357
|
-
}, C = (
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
},
|
|
372
|
-
|
|
373
|
-
(
|
|
393
|
+
}, E = (c) => {
|
|
394
|
+
u(
|
|
395
|
+
(d) => k(d, "startDate", new Date(c))
|
|
374
396
|
);
|
|
375
|
-
}, { validationSchema:
|
|
376
|
-
|
|
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:
|
|
379
|
-
validationSchema:
|
|
400
|
+
initialValues: T,
|
|
401
|
+
validationSchema: D,
|
|
380
402
|
validateOnChange: !0,
|
|
381
403
|
validateOnBlur: !0,
|
|
382
404
|
onSubmit: () => {
|
|
383
|
-
|
|
405
|
+
l(m);
|
|
384
406
|
}
|
|
385
|
-
}),
|
|
386
|
-
...
|
|
387
|
-
|
|
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:
|
|
417
|
+
decision: m,
|
|
395
418
|
onCancel: i,
|
|
396
|
-
onSubmit: () =>
|
|
419
|
+
onSubmit: () => l(m),
|
|
397
420
|
onChangeCondition: C,
|
|
398
|
-
onChangeDecision:
|
|
399
|
-
onStartChange:
|
|
421
|
+
onChangeDecision: g,
|
|
422
|
+
onStartChange: E,
|
|
400
423
|
onEndChange: v,
|
|
401
|
-
textValues:
|
|
424
|
+
textValues: s
|
|
402
425
|
}
|
|
403
426
|
);
|
|
404
|
-
},
|
|
427
|
+
}, q = (t) => {
|
|
405
428
|
if (!t)
|
|
406
429
|
return;
|
|
407
430
|
const e = t.value;
|
|
@@ -422,80 +445,84 @@ const X = (t) => {
|
|
|
422
445
|
return e.value;
|
|
423
446
|
}
|
|
424
447
|
return e;
|
|
425
|
-
},
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
448
|
+
}, we = (t) => {
|
|
449
|
+
const { decision: e, textValues: a } = t, i = (s) => s && Object.keys(s).length > 0, l = {
|
|
450
|
+
name: e.name,
|
|
451
|
+
dataType: e.dataType,
|
|
452
|
+
value: e.value,
|
|
453
|
+
valueUse: e.valueUse
|
|
454
|
+
};
|
|
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 }),
|
|
458
|
+
/* @__PURE__ */ n(o, { justifyContent: "space-between", children: e && /* @__PURE__ */ n(o, { direction: "column", children: /* @__PURE__ */ n(
|
|
459
|
+
A,
|
|
433
460
|
{
|
|
434
|
-
element:
|
|
435
|
-
valueData:
|
|
461
|
+
element: l,
|
|
462
|
+
valueData: q(l)
|
|
436
463
|
}
|
|
437
|
-
) }, e.
|
|
464
|
+
) }, e.name) })
|
|
438
465
|
] }),
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */ n(
|
|
441
|
-
e.conditions && e.conditions.map(
|
|
442
|
-
|
|
443
|
-
|
|
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,
|
|
444
472
|
{
|
|
445
|
-
element:
|
|
446
|
-
|
|
473
|
+
element: {
|
|
474
|
+
...s,
|
|
475
|
+
value: m
|
|
476
|
+
},
|
|
477
|
+
valueData: q(s)
|
|
447
478
|
}
|
|
448
|
-
) },
|
|
449
|
-
)
|
|
479
|
+
) }, s.name);
|
|
480
|
+
})
|
|
450
481
|
] }),
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */ n(
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
(
|
|
455
|
-
|
|
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: [
|
|
485
|
+
(e == null ? void 0 : e.startDate) && /* @__PURE__ */ n(
|
|
486
|
+
A,
|
|
456
487
|
{
|
|
457
488
|
element: {
|
|
458
489
|
name: "Fecha de inicio",
|
|
459
|
-
description: a.termStart,
|
|
460
490
|
value: String(e.startDate),
|
|
461
491
|
valueUse: f.EQUAL,
|
|
462
|
-
dataType:
|
|
492
|
+
dataType: R.DATE
|
|
463
493
|
},
|
|
464
|
-
valueData: new Date(
|
|
465
|
-
|
|
466
|
-
)
|
|
494
|
+
valueData: new Date(e.startDate).toLocaleDateString(
|
|
495
|
+
"en-CA"
|
|
496
|
+
)
|
|
467
497
|
},
|
|
468
498
|
"startDate"
|
|
469
499
|
),
|
|
470
|
-
(
|
|
471
|
-
|
|
500
|
+
(e == null ? void 0 : e.endDate) && /* @__PURE__ */ n(
|
|
501
|
+
A,
|
|
472
502
|
{
|
|
473
503
|
element: {
|
|
474
504
|
name: "Fecha de final",
|
|
475
|
-
description: a.termEnd,
|
|
476
505
|
value: String(e.endDate),
|
|
477
506
|
valueUse: f.EQUAL,
|
|
478
|
-
dataType:
|
|
507
|
+
dataType: R.DATE
|
|
479
508
|
},
|
|
480
|
-
valueData: new Date(e.
|
|
481
|
-
"en-CA"
|
|
482
|
-
)
|
|
509
|
+
valueData: new Date(e.endDate).toLocaleDateString("en-CA")
|
|
483
510
|
},
|
|
484
511
|
"endDate"
|
|
485
512
|
)
|
|
486
513
|
] })
|
|
487
514
|
] })
|
|
488
515
|
] });
|
|
489
|
-
},
|
|
516
|
+
}, re = G.div`
|
|
490
517
|
border-radius: 8px;
|
|
491
|
-
border: 1px solid ${
|
|
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
|
-
`,
|
|
525
|
+
`, oe = G.div`
|
|
499
526
|
width: 100%;
|
|
500
527
|
height: 100%;
|
|
501
528
|
overflow-y: auto;
|
|
@@ -513,34 +540,34 @@ const X = (t) => {
|
|
|
513
540
|
background-color: #ebecf0;
|
|
514
541
|
border-radius: 8px;
|
|
515
542
|
}
|
|
516
|
-
`,
|
|
517
|
-
const { children: e, handleDelete: a, handleView: i, id:
|
|
518
|
-
return /* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */ n(o, { height: "282px", gap: "24px", direction: "column", children: /* @__PURE__ */ n(
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */ n(
|
|
522
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
551
|
+
N,
|
|
525
552
|
{
|
|
526
553
|
appearance: "dark",
|
|
527
554
|
size: "24px",
|
|
528
555
|
cursorHover: !0,
|
|
529
|
-
icon: /* @__PURE__ */ n(
|
|
556
|
+
icon: /* @__PURE__ */ n(K, {}),
|
|
530
557
|
onClick: () => {
|
|
531
|
-
i(
|
|
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(W, {}),
|
|
542
569
|
onClick: () => {
|
|
543
|
-
a(
|
|
570
|
+
a(l);
|
|
544
571
|
}
|
|
545
572
|
}
|
|
546
573
|
)
|
|
@@ -549,7 +576,7 @@ const X = (t) => {
|
|
|
549
576
|
] });
|
|
550
577
|
};
|
|
551
578
|
export {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
+
"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.
|
|
52
|
-
"@isettingkit/view": "^0.1.
|
|
51
|
+
"@isettingkit/input": "^0.1.23",
|
|
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"
|