sodas-validation-ui 0.1.0
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/README.md +16 -0
- package/dist/sodas-validation-ui.css +1 -0
- package/dist/sodas-validation-ui.js +518 -0
- package/dist/sodas-validation-ui.umd.cjs +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# React + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.validation-rules-editor{font-family:system-ui,-apple-system,sans-serif;font-size:14px;color:#333}.validation-rules-editor--empty{padding:1rem;color:#c00}.validation-rules-editor__toolbar{display:flex;align-items:center;gap:.5rem;margin-bottom:1rem}.validation-rules-editor__add-label{font-weight:600}.validation-rules-editor__add-select{padding:.35rem .5rem;border:1px solid #ccc;border-radius:4px;min-width:180px}.validation-rules-editor__append-btn{padding:.35rem .75rem;font-size:14px;border:1px solid #ccc;border-radius:4px;background:#fff;cursor:pointer}.validation-rules-editor__append-btn:hover:not(:disabled){background:#f0f0f0}.validation-rules-editor__append-btn:disabled{opacity:.6;cursor:not-allowed}.validation-rules-editor__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:1rem}.validation-rules-editor__rule{margin:0}.validation-rules-editor__rule-card{border:1px solid #ddd;border-radius:8px;padding:1rem;background:#fafafa}.validation-rules-editor__rule-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.validation-rules-editor__rule-type{font-weight:600;color:#555}.validation-rules-editor__rule-remove{padding:.25rem .5rem;font-size:12px;border:1px solid #ccc;border-radius:4px;background:#fff;cursor:pointer}.validation-rules-editor__rule-remove:hover{background:#f0f0f0}.validation-rules-editor__fields,.validation-rules-editor__type-fields{display:flex;flex-wrap:wrap;gap:.75rem 1.5rem}.validation-rules-editor__field{display:flex;flex-direction:column;gap:.2rem;min-width:120px}.validation-rules-editor__field--checkbox{flex-direction:row;align-items:center;min-width:auto}.validation-rules-editor__field-label{font-size:12px;color:#666}.validation-rules-editor__field-input{padding:.35rem .5rem;border:1px solid #ccc;border-radius:4px;font-size:14px}.validation-rules-editor__field--checkbox .validation-rules-editor__field-input{width:auto;margin-right:.35rem}.validation-rules-editor__empty{margin:.5rem 0 0;color:#666;font-size:13px}.template-editor{font-family:system-ui,-apple-system,sans-serif;font-size:14px;color:#333}.template-editor--empty{padding:1rem;color:#c00}.template-editor__meta{display:flex;flex-direction:column;gap:1rem;margin-bottom:1.5rem}.template-editor__field{display:flex;flex-direction:column;gap:.35rem}.template-editor__field-label{font-size:12px;font-weight:600;color:#555}.template-editor__field-input{padding:.5rem .6rem;border:1px solid #ccc;border-radius:4px;font-size:14px}.template-editor__field-input--textarea{min-height:4rem;resize:vertical}.template-editor__rules{border-top:1px solid #e0e0e0;padding-top:1.5rem}.template-editor__rules-title{margin:0 0 1rem;font-size:1rem;font-weight:600;color:#333}.quality-requirement-editor{font-family:system-ui,-apple-system,sans-serif;font-size:14px;color:#333}.quality-requirement-editor--empty{padding:1rem;color:#c00}.quality-requirement-editor__meta{margin-bottom:1.5rem}.quality-requirement-editor__field{display:flex;flex-direction:column;gap:.35rem}.quality-requirement-editor__field-label{font-size:12px;font-weight:600;color:#555}.quality-requirement-editor__field-input{padding:.5rem .6rem;border:1px solid #ccc;border-radius:4px;font-size:14px}.quality-requirement-editor__nodes{border-top:1px solid #e0e0e0;padding-top:1.5rem}.quality-requirement-editor__nodes-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.quality-requirement-editor__nodes-title{margin:0;font-size:1rem;font-weight:600;color:#333}.quality-requirement-editor__add-node-btn{padding:.35rem .75rem;font-size:14px;border:1px solid #ccc;border-radius:4px;background:#fff;cursor:pointer}.quality-requirement-editor__add-node-btn:hover{background:#f0f0f0}.quality-requirement-editor__empty-nodes{margin:0 0 1rem;color:#666;font-size:13px}.quality-requirement-editor__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:1.25rem}.quality-requirement-editor__node{margin:0}.quality-requirement-editor__node-card{border:1px solid #ddd;border-radius:8px;padding:1rem;background:#fafafa}.quality-requirement-editor__node-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.quality-requirement-editor__node-index{font-weight:600;color:#555}.quality-requirement-editor__node-remove{padding:.25rem .5rem;font-size:12px;border:1px solid #ccc;border-radius:4px;background:#fff;cursor:pointer}.quality-requirement-editor__node-remove:hover{background:#f0f0f0}.quality-requirement-editor__node-fields{display:flex;flex-wrap:wrap;gap:1rem 1.5rem;margin-bottom:1rem}.quality-requirement-editor__node-fields .quality-requirement-editor__field{min-width:160px}.quality-requirement-editor__node-rules{border-top:1px solid #e8e8e8;padding-top:1rem}.quality-requirement-editor__node-rules-title{margin:0 0 .75rem;font-size:13px;font-weight:600;color:#555}
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { jsx as a, jsxs as i, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useCallback as T, useRef as C } from "react";
|
|
3
|
+
import { VALIDATION_TYPE as s, COMPARISION_OPERATOR as g, CUSTOM_CONDITION_TYPE as q, OUTLIER_METHOD as A, EXPECTED_TYPE as E, DATETIME_FORMAT_TYPE as O, createRule as R } from "sodas-sdk";
|
|
4
|
+
function I() {
|
|
5
|
+
const [, e] = b(0);
|
|
6
|
+
return T(() => e((n) => n + 1), []);
|
|
7
|
+
}
|
|
8
|
+
const S = {
|
|
9
|
+
[s.DATA_TYPE]: "Data Type",
|
|
10
|
+
[s.RANGE]: "Range",
|
|
11
|
+
[s.PATTERN]: "Pattern",
|
|
12
|
+
[s.UNIQUENESS]: "Uniqueness",
|
|
13
|
+
[s.CUSTOM]: "Custom",
|
|
14
|
+
[s.COMPLETENESS]: "Completeness",
|
|
15
|
+
[s.LENGTH]: "Length",
|
|
16
|
+
[s.ALLOWED_VALUES]: "Allowed Values",
|
|
17
|
+
[s.OUTLIER]: "Outlier",
|
|
18
|
+
[s.STATISTICAL]: "Statistical"
|
|
19
|
+
}, f = Object.entries(g).map(([e, n]) => ({ value: n, label: e })), L = Object.entries(q).map(([e, n]) => ({ value: n, label: e })), k = Object.entries(A).map(([e, n]) => ({ value: n, label: e })), P = Object.entries(E).map(([e, n]) => ({ value: n, label: e })), U = Object.entries(O).map(([e, n]) => ({ value: n, label: e }));
|
|
20
|
+
function M({ validationRules: e }) {
|
|
21
|
+
const n = I(), [c, l] = b(""), t = (u) => {
|
|
22
|
+
if (!Array.isArray(e)) return;
|
|
23
|
+
const m = R(u);
|
|
24
|
+
e.push(m), n();
|
|
25
|
+
}, r = () => {
|
|
26
|
+
c && t(c);
|
|
27
|
+
}, o = (u) => {
|
|
28
|
+
Array.isArray(e) && (e.splice(u, 1), n());
|
|
29
|
+
}, p = (u, m, h) => {
|
|
30
|
+
m === "column" ? u.setColumn(h) : m === "name" && u.setName(h), n();
|
|
31
|
+
};
|
|
32
|
+
return Array.isArray(e) ? /* @__PURE__ */ i("div", { className: "validation-rules-editor", children: [
|
|
33
|
+
/* @__PURE__ */ i("div", { className: "validation-rules-editor__toolbar", children: [
|
|
34
|
+
/* @__PURE__ */ a("label", { className: "validation-rules-editor__add-label", children: "Add rule:" }),
|
|
35
|
+
/* @__PURE__ */ i(
|
|
36
|
+
"select",
|
|
37
|
+
{
|
|
38
|
+
className: "validation-rules-editor__add-select",
|
|
39
|
+
value: c,
|
|
40
|
+
onChange: (u) => l(u.target.value),
|
|
41
|
+
"aria-label": "Validation rule type",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ a("option", { value: "", children: "-- Select type --" }),
|
|
44
|
+
Object.entries(S).map(([u, m]) => /* @__PURE__ */ a("option", { value: u, children: m }, u))
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ a(
|
|
49
|
+
"button",
|
|
50
|
+
{
|
|
51
|
+
type: "button",
|
|
52
|
+
className: "validation-rules-editor__append-btn",
|
|
53
|
+
onClick: r,
|
|
54
|
+
disabled: !c,
|
|
55
|
+
"aria-label": "Append rule",
|
|
56
|
+
children: "Append"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ a("ul", { className: "validation-rules-editor__list", children: e.map((u, m) => /* @__PURE__ */ a("li", { className: "validation-rules-editor__rule", children: /* @__PURE__ */ a(
|
|
61
|
+
D,
|
|
62
|
+
{
|
|
63
|
+
rule: u,
|
|
64
|
+
index: m,
|
|
65
|
+
onRemove: () => o(m),
|
|
66
|
+
onCommonChange: p,
|
|
67
|
+
forceUpdate: n
|
|
68
|
+
}
|
|
69
|
+
) }, m)) }),
|
|
70
|
+
e.length === 0 && /* @__PURE__ */ a("p", { className: "validation-rules-editor__empty", children: "No rules. Select a type and click Append to add one." })
|
|
71
|
+
] }) : /* @__PURE__ */ a("div", { className: "validation-rules-editor validation-rules-editor--empty", children: "validationRules must be an array" });
|
|
72
|
+
}
|
|
73
|
+
function D({ rule: e, index: n, onRemove: c, onCommonChange: l, forceUpdate: t }) {
|
|
74
|
+
const r = e.getType;
|
|
75
|
+
return /* @__PURE__ */ i("div", { className: "validation-rules-editor__rule-card", children: [
|
|
76
|
+
/* @__PURE__ */ i("div", { className: "validation-rules-editor__rule-header", children: [
|
|
77
|
+
/* @__PURE__ */ a("span", { className: "validation-rules-editor__rule-type", children: S[r] ?? r }),
|
|
78
|
+
/* @__PURE__ */ a(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
className: "validation-rules-editor__rule-remove",
|
|
83
|
+
onClick: c,
|
|
84
|
+
"aria-label": `Remove rule ${n + 1}`,
|
|
85
|
+
children: "Remove"
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ i("div", { className: "validation-rules-editor__fields", children: [
|
|
90
|
+
/* @__PURE__ */ a(d, { label: "Column", value: e.getColumn, onChange: (o) => l(e, "column", o) }),
|
|
91
|
+
/* @__PURE__ */ a(d, { label: "Name", value: e.getName, onChange: (o) => l(e, "name", o) })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ a("div", { className: "validation-rules-editor__type-fields", children: /* @__PURE__ */ a(x, { rule: e, type: r, forceUpdate: t }) })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function d({ label: e, value: n = "", type: c = "text", onChange: l, options: t, checkbox: r }) {
|
|
97
|
+
return t ? /* @__PURE__ */ i("label", { className: "validation-rules-editor__field", children: [
|
|
98
|
+
/* @__PURE__ */ a("span", { className: "validation-rules-editor__field-label", children: e }),
|
|
99
|
+
/* @__PURE__ */ a(
|
|
100
|
+
"select",
|
|
101
|
+
{
|
|
102
|
+
className: "validation-rules-editor__field-input",
|
|
103
|
+
value: n,
|
|
104
|
+
onChange: (o) => l(o.target.value),
|
|
105
|
+
"aria-label": e,
|
|
106
|
+
children: t.map((o) => /* @__PURE__ */ a("option", { value: o.value, children: o.label }, o.value))
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] }) : c === "checkbox" || r ? /* @__PURE__ */ i("label", { className: "validation-rules-editor__field validation-rules-editor__field--checkbox", children: [
|
|
110
|
+
/* @__PURE__ */ a(
|
|
111
|
+
"input",
|
|
112
|
+
{
|
|
113
|
+
type: "checkbox",
|
|
114
|
+
className: "validation-rules-editor__field-input",
|
|
115
|
+
checked: !!n,
|
|
116
|
+
onChange: (o) => l(o.target.checked),
|
|
117
|
+
"aria-label": e
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ a("span", { className: "validation-rules-editor__field-label", children: e })
|
|
121
|
+
] }) : /* @__PURE__ */ i("label", { className: "validation-rules-editor__field", children: [
|
|
122
|
+
/* @__PURE__ */ a("span", { className: "validation-rules-editor__field-label", children: e }),
|
|
123
|
+
/* @__PURE__ */ a(
|
|
124
|
+
"input",
|
|
125
|
+
{
|
|
126
|
+
type: c,
|
|
127
|
+
className: "validation-rules-editor__field-input",
|
|
128
|
+
value: n,
|
|
129
|
+
onChange: (o) => l(o.target.value),
|
|
130
|
+
"aria-label": e
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
function x({ rule: e, type: n, forceUpdate: c }) {
|
|
136
|
+
const l = (t, r) => {
|
|
137
|
+
typeof t == "function" && t.call(e, r), c();
|
|
138
|
+
};
|
|
139
|
+
switch (n) {
|
|
140
|
+
case s.UNIQUENESS:
|
|
141
|
+
return /* @__PURE__ */ a(
|
|
142
|
+
d,
|
|
143
|
+
{
|
|
144
|
+
label: "Unique",
|
|
145
|
+
type: "checkbox",
|
|
146
|
+
value: e.getUnique,
|
|
147
|
+
onChange: (t) => l(e.setUnique, !!t),
|
|
148
|
+
checkbox: !0
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
case s.PATTERN:
|
|
152
|
+
return /* @__PURE__ */ a(
|
|
153
|
+
d,
|
|
154
|
+
{
|
|
155
|
+
label: "Pattern",
|
|
156
|
+
value: e.getPattern ?? "",
|
|
157
|
+
onChange: (t) => l(e.setPattern, t)
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
case s.RANGE:
|
|
161
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
162
|
+
/* @__PURE__ */ a(
|
|
163
|
+
d,
|
|
164
|
+
{
|
|
165
|
+
label: "Min value",
|
|
166
|
+
type: "number",
|
|
167
|
+
value: String(e.getMinValue ?? 0),
|
|
168
|
+
onChange: (t) => l(e.setMinValue, Number(t) || 0)
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ a(
|
|
172
|
+
d,
|
|
173
|
+
{
|
|
174
|
+
label: "Max value",
|
|
175
|
+
type: "number",
|
|
176
|
+
value: String(e.getMaxValue ?? 0),
|
|
177
|
+
onChange: (t) => l(e.setMaxValue, Number(t) || 0)
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] });
|
|
181
|
+
case s.LENGTH:
|
|
182
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
183
|
+
/* @__PURE__ */ a(
|
|
184
|
+
d,
|
|
185
|
+
{
|
|
186
|
+
label: "Min length",
|
|
187
|
+
type: "number",
|
|
188
|
+
value: String(e.getMinLength ?? 0),
|
|
189
|
+
onChange: (t) => l(e.setMinLength, Number(t) || 0)
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ a(
|
|
193
|
+
d,
|
|
194
|
+
{
|
|
195
|
+
label: "Max length",
|
|
196
|
+
type: "number",
|
|
197
|
+
value: String(e.getMaxLength ?? 0),
|
|
198
|
+
onChange: (t) => l(e.setMaxLength, Number(t) || 0)
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
case s.ALLOWED_VALUES: {
|
|
203
|
+
const t = e.getAllowedValues ?? [], r = Array.isArray(t) ? t.join(", ") : "";
|
|
204
|
+
return /* @__PURE__ */ a(
|
|
205
|
+
d,
|
|
206
|
+
{
|
|
207
|
+
label: "Allowed values (comma-separated)",
|
|
208
|
+
value: r,
|
|
209
|
+
onChange: (o) => l(e.setAllowedValues, o.split(",").map((p) => p.trim()).filter(Boolean))
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
case s.COMPLETENESS:
|
|
214
|
+
return /* @__PURE__ */ a(
|
|
215
|
+
d,
|
|
216
|
+
{
|
|
217
|
+
label: "Min completeness",
|
|
218
|
+
type: "number",
|
|
219
|
+
value: String(e.getMinCompleteness ?? 0),
|
|
220
|
+
onChange: (t) => l(e.setMinCompleteness, Number(t) || 0)
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
case s.DATA_TYPE:
|
|
224
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
225
|
+
/* @__PURE__ */ a(
|
|
226
|
+
d,
|
|
227
|
+
{
|
|
228
|
+
label: "Expected type",
|
|
229
|
+
value: e.getExpectedType ?? E.STRING,
|
|
230
|
+
options: P,
|
|
231
|
+
onChange: (t) => l(e.setExpectedType, t)
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ a(
|
|
235
|
+
d,
|
|
236
|
+
{
|
|
237
|
+
label: "Datetime format",
|
|
238
|
+
value: e.getDatetimeFormat ?? O.YYYY_MM_DD_HH_MM_SS,
|
|
239
|
+
options: U,
|
|
240
|
+
onChange: (t) => l(e.setDatetimeFormat, t)
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
] });
|
|
244
|
+
case s.OUTLIER:
|
|
245
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
246
|
+
/* @__PURE__ */ a(
|
|
247
|
+
d,
|
|
248
|
+
{
|
|
249
|
+
label: "Method",
|
|
250
|
+
value: e.getMethod ?? A.Z_SCORE,
|
|
251
|
+
options: k,
|
|
252
|
+
onChange: (t) => l(e.setMethod, t)
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ a(
|
|
256
|
+
d,
|
|
257
|
+
{
|
|
258
|
+
label: "Threshold",
|
|
259
|
+
type: "number",
|
|
260
|
+
value: String(e.getThreshold ?? 0),
|
|
261
|
+
onChange: (t) => l(e.setThreshold, Number(t) || 0)
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
] });
|
|
265
|
+
case s.STATISTICAL:
|
|
266
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
267
|
+
/* @__PURE__ */ a(
|
|
268
|
+
d,
|
|
269
|
+
{
|
|
270
|
+
label: "Check",
|
|
271
|
+
value: e.getCheck ?? "",
|
|
272
|
+
onChange: (t) => l(e.setCheck, t)
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
/* @__PURE__ */ a(
|
|
276
|
+
d,
|
|
277
|
+
{
|
|
278
|
+
label: "Threshold",
|
|
279
|
+
type: "number",
|
|
280
|
+
value: String(e.getThreshold ?? 0),
|
|
281
|
+
onChange: (t) => l(e.setThreshold, Number(t) || 0)
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
/* @__PURE__ */ a(
|
|
285
|
+
d,
|
|
286
|
+
{
|
|
287
|
+
label: "Comparison",
|
|
288
|
+
value: e.getComparision ?? g.EQUAL,
|
|
289
|
+
options: f,
|
|
290
|
+
onChange: (t) => l(e.setComparision, t)
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
] });
|
|
294
|
+
case s.CUSTOM: {
|
|
295
|
+
const t = e.getCondition ?? {};
|
|
296
|
+
return /* @__PURE__ */ i(N, { children: [
|
|
297
|
+
/* @__PURE__ */ a(
|
|
298
|
+
d,
|
|
299
|
+
{
|
|
300
|
+
label: "Condition type",
|
|
301
|
+
value: t.type ?? q.ALL,
|
|
302
|
+
options: L,
|
|
303
|
+
onChange: (r) => l(e.setCondition, {
|
|
304
|
+
...t,
|
|
305
|
+
type: r
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
/* @__PURE__ */ a(
|
|
310
|
+
d,
|
|
311
|
+
{
|
|
312
|
+
label: "Threshold (threholder)",
|
|
313
|
+
type: "number",
|
|
314
|
+
value: String(t.threholder ?? 0),
|
|
315
|
+
onChange: (r) => l(e.setCondition, {
|
|
316
|
+
...t,
|
|
317
|
+
threholder: Number(r) || 0
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
/* @__PURE__ */ a(
|
|
322
|
+
d,
|
|
323
|
+
{
|
|
324
|
+
label: "Comparison",
|
|
325
|
+
value: t.comparision ?? g.EQUAL,
|
|
326
|
+
options: f,
|
|
327
|
+
onChange: (r) => l(e.setCondition, {
|
|
328
|
+
...t,
|
|
329
|
+
comparision: r
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] });
|
|
334
|
+
}
|
|
335
|
+
default:
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function V() {
|
|
340
|
+
const [, e] = b(0);
|
|
341
|
+
return T(() => e((n) => n + 1), []);
|
|
342
|
+
}
|
|
343
|
+
function w({ template: e }) {
|
|
344
|
+
const n = V(), c = C(e);
|
|
345
|
+
if (c.current = e, e == null || typeof e != "object")
|
|
346
|
+
return /* @__PURE__ */ a("div", { className: "template-editor template-editor--empty", children: "template must be an object" });
|
|
347
|
+
const l = c.current;
|
|
348
|
+
Array.isArray(l.validationRules) || (l.validationRules = []);
|
|
349
|
+
const t = (m) => {
|
|
350
|
+
l.name = m.target.value, n();
|
|
351
|
+
}, r = (m) => {
|
|
352
|
+
l.description = m.target.value, n();
|
|
353
|
+
}, o = l.name ?? "", p = l.description ?? "", u = l.validationRules;
|
|
354
|
+
return /* @__PURE__ */ i("div", { className: "template-editor", children: [
|
|
355
|
+
/* @__PURE__ */ i("div", { className: "template-editor__meta", children: [
|
|
356
|
+
/* @__PURE__ */ i("label", { className: "template-editor__field", children: [
|
|
357
|
+
/* @__PURE__ */ a("span", { className: "template-editor__field-label", children: "Name" }),
|
|
358
|
+
/* @__PURE__ */ a(
|
|
359
|
+
"input",
|
|
360
|
+
{
|
|
361
|
+
type: "text",
|
|
362
|
+
className: "template-editor__field-input",
|
|
363
|
+
value: o,
|
|
364
|
+
onChange: t,
|
|
365
|
+
placeholder: "Template name",
|
|
366
|
+
"aria-label": "Template name"
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ i("label", { className: "template-editor__field", children: [
|
|
371
|
+
/* @__PURE__ */ a("span", { className: "template-editor__field-label", children: "Description" }),
|
|
372
|
+
/* @__PURE__ */ a(
|
|
373
|
+
"textarea",
|
|
374
|
+
{
|
|
375
|
+
className: "template-editor__field-input template-editor__field-input--textarea",
|
|
376
|
+
value: p,
|
|
377
|
+
onChange: r,
|
|
378
|
+
placeholder: "Template description",
|
|
379
|
+
rows: 3,
|
|
380
|
+
"aria-label": "Template description"
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] })
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ i("div", { className: "template-editor__rules", children: [
|
|
386
|
+
/* @__PURE__ */ a("h3", { className: "template-editor__rules-title", children: "Validation Rules" }),
|
|
387
|
+
/* @__PURE__ */ a(M, { validationRules: u })
|
|
388
|
+
] })
|
|
389
|
+
] });
|
|
390
|
+
}
|
|
391
|
+
function j() {
|
|
392
|
+
const [, e] = b(0);
|
|
393
|
+
return T(() => e((n) => n + 1), []);
|
|
394
|
+
}
|
|
395
|
+
function G({ qualityRequirement: e }) {
|
|
396
|
+
const n = j(), c = C(e);
|
|
397
|
+
if (c.current = e, e == null || typeof e != "object")
|
|
398
|
+
return /* @__PURE__ */ a("div", { className: "quality-requirement-editor quality-requirement-editor--empty", children: "qualityRequirement must be an object" });
|
|
399
|
+
const l = c.current;
|
|
400
|
+
Array.isArray(l.nodes) || (l.nodes = []);
|
|
401
|
+
const t = (h) => {
|
|
402
|
+
l.name = h.target.value, n();
|
|
403
|
+
}, r = () => {
|
|
404
|
+
l.nodes.push({
|
|
405
|
+
node_name: "",
|
|
406
|
+
hook: "",
|
|
407
|
+
validation_rules: []
|
|
408
|
+
}), n();
|
|
409
|
+
}, o = (h) => {
|
|
410
|
+
l.nodes.splice(h, 1), n();
|
|
411
|
+
}, p = (h, _, y) => {
|
|
412
|
+
const v = l.nodes[h];
|
|
413
|
+
v && (v[_] = y, n());
|
|
414
|
+
}, u = l.name ?? "", m = l.nodes;
|
|
415
|
+
return /* @__PURE__ */ i("div", { className: "quality-requirement-editor", children: [
|
|
416
|
+
/* @__PURE__ */ a("div", { className: "quality-requirement-editor__meta", children: /* @__PURE__ */ i("label", { className: "quality-requirement-editor__field", children: [
|
|
417
|
+
/* @__PURE__ */ a("span", { className: "quality-requirement-editor__field-label", children: "Name" }),
|
|
418
|
+
/* @__PURE__ */ a(
|
|
419
|
+
"input",
|
|
420
|
+
{
|
|
421
|
+
type: "text",
|
|
422
|
+
className: "quality-requirement-editor__field-input",
|
|
423
|
+
value: u,
|
|
424
|
+
onChange: t,
|
|
425
|
+
placeholder: "Quality requirement name",
|
|
426
|
+
"aria-label": "Quality requirement name"
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] }) }),
|
|
430
|
+
/* @__PURE__ */ i("div", { className: "quality-requirement-editor__nodes", children: [
|
|
431
|
+
/* @__PURE__ */ i("div", { className: "quality-requirement-editor__nodes-header", children: [
|
|
432
|
+
/* @__PURE__ */ a("h3", { className: "quality-requirement-editor__nodes-title", children: "Nodes" }),
|
|
433
|
+
/* @__PURE__ */ a(
|
|
434
|
+
"button",
|
|
435
|
+
{
|
|
436
|
+
type: "button",
|
|
437
|
+
className: "quality-requirement-editor__add-node-btn",
|
|
438
|
+
onClick: r,
|
|
439
|
+
"aria-label": "Add node",
|
|
440
|
+
children: "Add node"
|
|
441
|
+
}
|
|
442
|
+
)
|
|
443
|
+
] }),
|
|
444
|
+
m.length === 0 && /* @__PURE__ */ a("p", { className: "quality-requirement-editor__empty-nodes", children: 'No nodes. Click "Add node" to add one.' }),
|
|
445
|
+
/* @__PURE__ */ a("ul", { className: "quality-requirement-editor__list", children: m.map((h, _) => /* @__PURE__ */ a("li", { className: "quality-requirement-editor__node", children: /* @__PURE__ */ a(
|
|
446
|
+
Y,
|
|
447
|
+
{
|
|
448
|
+
node: h,
|
|
449
|
+
index: _,
|
|
450
|
+
onRemove: () => o(_),
|
|
451
|
+
onFieldChange: (y, v) => p(_, y, v)
|
|
452
|
+
}
|
|
453
|
+
) }, _)) })
|
|
454
|
+
] })
|
|
455
|
+
] });
|
|
456
|
+
}
|
|
457
|
+
function Y({ node: e, index: n, onRemove: c, onFieldChange: l }) {
|
|
458
|
+
const t = C(e);
|
|
459
|
+
t.current = e;
|
|
460
|
+
const r = t.current;
|
|
461
|
+
return Array.isArray(r.validation_rules) || (r.validation_rules = []), /* @__PURE__ */ i("div", { className: "quality-requirement-editor__node-card", children: [
|
|
462
|
+
/* @__PURE__ */ i("div", { className: "quality-requirement-editor__node-header", children: [
|
|
463
|
+
/* @__PURE__ */ i("span", { className: "quality-requirement-editor__node-index", children: [
|
|
464
|
+
"Node ",
|
|
465
|
+
n + 1
|
|
466
|
+
] }),
|
|
467
|
+
/* @__PURE__ */ a(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
type: "button",
|
|
471
|
+
className: "quality-requirement-editor__node-remove",
|
|
472
|
+
onClick: c,
|
|
473
|
+
"aria-label": `Remove node ${n + 1}`,
|
|
474
|
+
children: "Remove"
|
|
475
|
+
}
|
|
476
|
+
)
|
|
477
|
+
] }),
|
|
478
|
+
/* @__PURE__ */ i("div", { className: "quality-requirement-editor__node-fields", children: [
|
|
479
|
+
/* @__PURE__ */ i("label", { className: "quality-requirement-editor__field", children: [
|
|
480
|
+
/* @__PURE__ */ a("span", { className: "quality-requirement-editor__field-label", children: "Node name" }),
|
|
481
|
+
/* @__PURE__ */ a(
|
|
482
|
+
"input",
|
|
483
|
+
{
|
|
484
|
+
type: "text",
|
|
485
|
+
className: "quality-requirement-editor__field-input",
|
|
486
|
+
value: r.node_name ?? "",
|
|
487
|
+
onChange: (o) => l("node_name", o.target.value),
|
|
488
|
+
placeholder: "node_name",
|
|
489
|
+
"aria-label": "Node name"
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
] }),
|
|
493
|
+
/* @__PURE__ */ i("label", { className: "quality-requirement-editor__field", children: [
|
|
494
|
+
/* @__PURE__ */ a("span", { className: "quality-requirement-editor__field-label", children: "Hook" }),
|
|
495
|
+
/* @__PURE__ */ a(
|
|
496
|
+
"input",
|
|
497
|
+
{
|
|
498
|
+
type: "text",
|
|
499
|
+
className: "quality-requirement-editor__field-input",
|
|
500
|
+
value: r.hook ?? "",
|
|
501
|
+
onChange: (o) => l("hook", o.target.value),
|
|
502
|
+
placeholder: "hook",
|
|
503
|
+
"aria-label": "Hook"
|
|
504
|
+
}
|
|
505
|
+
)
|
|
506
|
+
] })
|
|
507
|
+
] }),
|
|
508
|
+
/* @__PURE__ */ i("div", { className: "quality-requirement-editor__node-rules", children: [
|
|
509
|
+
/* @__PURE__ */ a("h4", { className: "quality-requirement-editor__node-rules-title", children: "Validation rules" }),
|
|
510
|
+
/* @__PURE__ */ a(M, { validationRules: r.validation_rules })
|
|
511
|
+
] })
|
|
512
|
+
] });
|
|
513
|
+
}
|
|
514
|
+
export {
|
|
515
|
+
G as QualityRequirementEditor,
|
|
516
|
+
w as TemplateEditor,
|
|
517
|
+
M as ValidationRulesEditor
|
|
518
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("sodas-sdk")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","sodas-sdk"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.SodasValidationUI={},h.jsxRuntime,h.React,h.sodasSdk))})(this,(function(h,e,u,n){"use strict";function y(){const[,a]=u.useState(0);return u.useCallback(()=>a(r=>r+1),[])}const b={[n.VALIDATION_TYPE.DATA_TYPE]:"Data Type",[n.VALIDATION_TYPE.RANGE]:"Range",[n.VALIDATION_TYPE.PATTERN]:"Pattern",[n.VALIDATION_TYPE.UNIQUENESS]:"Uniqueness",[n.VALIDATION_TYPE.CUSTOM]:"Custom",[n.VALIDATION_TYPE.COMPLETENESS]:"Completeness",[n.VALIDATION_TYPE.LENGTH]:"Length",[n.VALIDATION_TYPE.ALLOWED_VALUES]:"Allowed Values",[n.VALIDATION_TYPE.OUTLIER]:"Outlier",[n.VALIDATION_TYPE.STATISTICAL]:"Statistical"},E=Object.entries(n.COMPARISION_OPERATOR).map(([a,r])=>({value:r,label:a})),g=Object.entries(n.CUSTOM_CONDITION_TYPE).map(([a,r])=>({value:r,label:a})),f=Object.entries(n.OUTLIER_METHOD).map(([a,r])=>({value:r,label:a})),C=Object.entries(n.EXPECTED_TYPE).map(([a,r])=>({value:r,label:a})),O=Object.entries(n.DATETIME_FORMAT_TYPE).map(([a,r])=>({value:r,label:a}));function v({validationRules:a}){const r=y(),[d,t]=u.useState(""),l=c=>{if(!Array.isArray(a))return;const _=n.createRule(c);a.push(_),r()},i=()=>{d&&l(d)},o=c=>{Array.isArray(a)&&(a.splice(c,1),r())},N=(c,_,p)=>{_==="column"?c.setColumn(p):_==="name"&&c.setName(p),r()};return Array.isArray(a)?e.jsxs("div",{className:"validation-rules-editor",children:[e.jsxs("div",{className:"validation-rules-editor__toolbar",children:[e.jsx("label",{className:"validation-rules-editor__add-label",children:"Add rule:"}),e.jsxs("select",{className:"validation-rules-editor__add-select",value:d,onChange:c=>t(c.target.value),"aria-label":"Validation rule type",children:[e.jsx("option",{value:"",children:"-- Select type --"}),Object.entries(b).map(([c,_])=>e.jsx("option",{value:c,children:_},c))]}),e.jsx("button",{type:"button",className:"validation-rules-editor__append-btn",onClick:i,disabled:!d,"aria-label":"Append rule",children:"Append"})]}),e.jsx("ul",{className:"validation-rules-editor__list",children:a.map((c,_)=>e.jsx("li",{className:"validation-rules-editor__rule",children:e.jsx(I,{rule:c,index:_,onRemove:()=>o(_),onCommonChange:N,forceUpdate:r})},_))}),a.length===0&&e.jsx("p",{className:"validation-rules-editor__empty",children:"No rules. Select a type and click Append to add one."})]}):e.jsx("div",{className:"validation-rules-editor validation-rules-editor--empty",children:"validationRules must be an array"})}function I({rule:a,index:r,onRemove:d,onCommonChange:t,forceUpdate:l}){const i=a.getType;return e.jsxs("div",{className:"validation-rules-editor__rule-card",children:[e.jsxs("div",{className:"validation-rules-editor__rule-header",children:[e.jsx("span",{className:"validation-rules-editor__rule-type",children:b[i]??i}),e.jsx("button",{type:"button",className:"validation-rules-editor__rule-remove",onClick:d,"aria-label":`Remove rule ${r+1}`,children:"Remove"})]}),e.jsxs("div",{className:"validation-rules-editor__fields",children:[e.jsx(s,{label:"Column",value:a.getColumn,onChange:o=>t(a,"column",o)}),e.jsx(s,{label:"Name",value:a.getName,onChange:o=>t(a,"name",o)})]}),e.jsx("div",{className:"validation-rules-editor__type-fields",children:e.jsx(q,{rule:a,type:i,forceUpdate:l})})]})}function s({label:a,value:r="",type:d="text",onChange:t,options:l,checkbox:i}){return l?e.jsxs("label",{className:"validation-rules-editor__field",children:[e.jsx("span",{className:"validation-rules-editor__field-label",children:a}),e.jsx("select",{className:"validation-rules-editor__field-input",value:r,onChange:o=>t(o.target.value),"aria-label":a,children:l.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]}):d==="checkbox"||i?e.jsxs("label",{className:"validation-rules-editor__field validation-rules-editor__field--checkbox",children:[e.jsx("input",{type:"checkbox",className:"validation-rules-editor__field-input",checked:!!r,onChange:o=>t(o.target.checked),"aria-label":a}),e.jsx("span",{className:"validation-rules-editor__field-label",children:a})]}):e.jsxs("label",{className:"validation-rules-editor__field",children:[e.jsx("span",{className:"validation-rules-editor__field-label",children:a}),e.jsx("input",{type:d,className:"validation-rules-editor__field-input",value:r,onChange:o=>t(o.target.value),"aria-label":a})]})}function q({rule:a,type:r,forceUpdate:d}){const t=(l,i)=>{typeof l=="function"&&l.call(a,i),d()};switch(r){case n.VALIDATION_TYPE.UNIQUENESS:return e.jsx(s,{label:"Unique",type:"checkbox",value:a.getUnique,onChange:l=>t(a.setUnique,!!l),checkbox:!0});case n.VALIDATION_TYPE.PATTERN:return e.jsx(s,{label:"Pattern",value:a.getPattern??"",onChange:l=>t(a.setPattern,l)});case n.VALIDATION_TYPE.RANGE:return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Min value",type:"number",value:String(a.getMinValue??0),onChange:l=>t(a.setMinValue,Number(l)||0)}),e.jsx(s,{label:"Max value",type:"number",value:String(a.getMaxValue??0),onChange:l=>t(a.setMaxValue,Number(l)||0)})]});case n.VALIDATION_TYPE.LENGTH:return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Min length",type:"number",value:String(a.getMinLength??0),onChange:l=>t(a.setMinLength,Number(l)||0)}),e.jsx(s,{label:"Max length",type:"number",value:String(a.getMaxLength??0),onChange:l=>t(a.setMaxLength,Number(l)||0)})]});case n.VALIDATION_TYPE.ALLOWED_VALUES:{const l=a.getAllowedValues??[],i=Array.isArray(l)?l.join(", "):"";return e.jsx(s,{label:"Allowed values (comma-separated)",value:i,onChange:o=>t(a.setAllowedValues,o.split(",").map(N=>N.trim()).filter(Boolean))})}case n.VALIDATION_TYPE.COMPLETENESS:return e.jsx(s,{label:"Min completeness",type:"number",value:String(a.getMinCompleteness??0),onChange:l=>t(a.setMinCompleteness,Number(l)||0)});case n.VALIDATION_TYPE.DATA_TYPE:return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Expected type",value:a.getExpectedType??n.EXPECTED_TYPE.STRING,options:C,onChange:l=>t(a.setExpectedType,l)}),e.jsx(s,{label:"Datetime format",value:a.getDatetimeFormat??n.DATETIME_FORMAT_TYPE.YYYY_MM_DD_HH_MM_SS,options:O,onChange:l=>t(a.setDatetimeFormat,l)})]});case n.VALIDATION_TYPE.OUTLIER:return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Method",value:a.getMethod??n.OUTLIER_METHOD.Z_SCORE,options:f,onChange:l=>t(a.setMethod,l)}),e.jsx(s,{label:"Threshold",type:"number",value:String(a.getThreshold??0),onChange:l=>t(a.setThreshold,Number(l)||0)})]});case n.VALIDATION_TYPE.STATISTICAL:return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Check",value:a.getCheck??"",onChange:l=>t(a.setCheck,l)}),e.jsx(s,{label:"Threshold",type:"number",value:String(a.getThreshold??0),onChange:l=>t(a.setThreshold,Number(l)||0)}),e.jsx(s,{label:"Comparison",value:a.getComparision??n.COMPARISION_OPERATOR.EQUAL,options:E,onChange:l=>t(a.setComparision,l)})]});case n.VALIDATION_TYPE.CUSTOM:{const l=a.getCondition??{};return e.jsxs(e.Fragment,{children:[e.jsx(s,{label:"Condition type",value:l.type??n.CUSTOM_CONDITION_TYPE.ALL,options:g,onChange:i=>t(a.setCondition,{...l,type:i})}),e.jsx(s,{label:"Threshold (threholder)",type:"number",value:String(l.threholder??0),onChange:i=>t(a.setCondition,{...l,threholder:Number(i)||0})}),e.jsx(s,{label:"Comparison",value:l.comparision??n.COMPARISION_OPERATOR.EQUAL,options:E,onChange:i=>t(a.setCondition,{...l,comparision:i})})]})}default:return null}}function P(){const[,a]=u.useState(0);return u.useCallback(()=>a(r=>r+1),[])}function L({template:a}){const r=P(),d=u.useRef(a);if(d.current=a,a==null||typeof a!="object")return e.jsx("div",{className:"template-editor template-editor--empty",children:"template must be an object"});const t=d.current;Array.isArray(t.validationRules)||(t.validationRules=[]);const l=_=>{t.name=_.target.value,r()},i=_=>{t.description=_.target.value,r()},o=t.name??"",N=t.description??"",c=t.validationRules;return e.jsxs("div",{className:"template-editor",children:[e.jsxs("div",{className:"template-editor__meta",children:[e.jsxs("label",{className:"template-editor__field",children:[e.jsx("span",{className:"template-editor__field-label",children:"Name"}),e.jsx("input",{type:"text",className:"template-editor__field-input",value:o,onChange:l,placeholder:"Template name","aria-label":"Template name"})]}),e.jsxs("label",{className:"template-editor__field",children:[e.jsx("span",{className:"template-editor__field-label",children:"Description"}),e.jsx("textarea",{className:"template-editor__field-input template-editor__field-input--textarea",value:N,onChange:i,placeholder:"Template description",rows:3,"aria-label":"Template description"})]})]}),e.jsxs("div",{className:"template-editor__rules",children:[e.jsx("h3",{className:"template-editor__rules-title",children:"Validation Rules"}),e.jsx(v,{validationRules:c})]})]})}function D(){const[,a]=u.useState(0);return u.useCallback(()=>a(r=>r+1),[])}function M({qualityRequirement:a}){const r=D(),d=u.useRef(a);if(d.current=a,a==null||typeof a!="object")return e.jsx("div",{className:"quality-requirement-editor quality-requirement-editor--empty",children:"qualityRequirement must be an object"});const t=d.current;Array.isArray(t.nodes)||(t.nodes=[]);const l=p=>{t.name=p.target.value,r()},i=()=>{t.nodes.push({node_name:"",hook:"",validation_rules:[]}),r()},o=p=>{t.nodes.splice(p,1),r()},N=(p,T,A)=>{const m=t.nodes[p];m&&(m[T]=A,r())},c=t.name??"",_=t.nodes;return e.jsxs("div",{className:"quality-requirement-editor",children:[e.jsx("div",{className:"quality-requirement-editor__meta",children:e.jsxs("label",{className:"quality-requirement-editor__field",children:[e.jsx("span",{className:"quality-requirement-editor__field-label",children:"Name"}),e.jsx("input",{type:"text",className:"quality-requirement-editor__field-input",value:c,onChange:l,placeholder:"Quality requirement name","aria-label":"Quality requirement name"})]})}),e.jsxs("div",{className:"quality-requirement-editor__nodes",children:[e.jsxs("div",{className:"quality-requirement-editor__nodes-header",children:[e.jsx("h3",{className:"quality-requirement-editor__nodes-title",children:"Nodes"}),e.jsx("button",{type:"button",className:"quality-requirement-editor__add-node-btn",onClick:i,"aria-label":"Add node",children:"Add node"})]}),_.length===0&&e.jsx("p",{className:"quality-requirement-editor__empty-nodes",children:'No nodes. Click "Add node" to add one.'}),e.jsx("ul",{className:"quality-requirement-editor__list",children:_.map((p,T)=>e.jsx("li",{className:"quality-requirement-editor__node",children:e.jsx(V,{node:p,index:T,onRemove:()=>o(T),onFieldChange:(A,m)=>N(T,A,m)})},T))})]})]})}function V({node:a,index:r,onRemove:d,onFieldChange:t}){const l=u.useRef(a);l.current=a;const i=l.current;return Array.isArray(i.validation_rules)||(i.validation_rules=[]),e.jsxs("div",{className:"quality-requirement-editor__node-card",children:[e.jsxs("div",{className:"quality-requirement-editor__node-header",children:[e.jsxs("span",{className:"quality-requirement-editor__node-index",children:["Node ",r+1]}),e.jsx("button",{type:"button",className:"quality-requirement-editor__node-remove",onClick:d,"aria-label":`Remove node ${r+1}`,children:"Remove"})]}),e.jsxs("div",{className:"quality-requirement-editor__node-fields",children:[e.jsxs("label",{className:"quality-requirement-editor__field",children:[e.jsx("span",{className:"quality-requirement-editor__field-label",children:"Node name"}),e.jsx("input",{type:"text",className:"quality-requirement-editor__field-input",value:i.node_name??"",onChange:o=>t("node_name",o.target.value),placeholder:"node_name","aria-label":"Node name"})]}),e.jsxs("label",{className:"quality-requirement-editor__field",children:[e.jsx("span",{className:"quality-requirement-editor__field-label",children:"Hook"}),e.jsx("input",{type:"text",className:"quality-requirement-editor__field-input",value:i.hook??"",onChange:o=>t("hook",o.target.value),placeholder:"hook","aria-label":"Hook"})]})]}),e.jsxs("div",{className:"quality-requirement-editor__node-rules",children:[e.jsx("h4",{className:"quality-requirement-editor__node-rules-title",children:"Validation rules"}),e.jsx(v,{validationRules:i.validation_rules})]})]})}h.QualityRequirementEditor=M,h.TemplateEditor=L,h.ValidationRulesEditor=v,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sodas-validation-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/sodas-validation-ui.umd.cjs",
|
|
14
|
+
"module": "dist/sodas-validation-ui.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/sodas-validation-ui.js",
|
|
18
|
+
"require": "./dist/sodas-validation-ui.umd.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./style.css": "./dist/sodas-validation-ui.css"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
27
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
28
|
+
"sodas-sdk": ">=1.7.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@chromatic-com/storybook": "^5.0.0",
|
|
32
|
+
"@eslint/js": "^9.39.1",
|
|
33
|
+
"@storybook/addon-a11y": "^10.2.4",
|
|
34
|
+
"@storybook/addon-docs": "^10.2.4",
|
|
35
|
+
"@storybook/addon-onboarding": "^10.2.4",
|
|
36
|
+
"@storybook/addon-vitest": "^10.2.4",
|
|
37
|
+
"@storybook/react-vite": "^10.2.4",
|
|
38
|
+
"@types/react": "^19.2.5",
|
|
39
|
+
"@types/react-dom": "^19.2.3",
|
|
40
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
41
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
42
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
43
|
+
"eslint": "^9.39.1",
|
|
44
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
45
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
46
|
+
"globals": "^16.5.0",
|
|
47
|
+
"playwright": "^1.58.1",
|
|
48
|
+
"prop-types": "^15.8.1",
|
|
49
|
+
"react": "^18.3.1",
|
|
50
|
+
"react-dom": "^18.3.1",
|
|
51
|
+
"storybook": "^10.2.4",
|
|
52
|
+
"vite": "^7.2.4",
|
|
53
|
+
"sodas-sdk": "^1.7.0",
|
|
54
|
+
"vitest": "^4.0.18"
|
|
55
|
+
}
|
|
56
|
+
}
|