@leav/ui 0.0.1-alpha-1

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.
@@ -0,0 +1,12 @@
1
+ import { s, u as e, j as r } from "./index-PMijvJqf.js";
2
+ import "./minimatch-x8aONUPa.js";
3
+ const n = s.div`
4
+ text-align: center;
5
+ `;
6
+ function i() {
7
+ const { t } = e();
8
+ return /* @__PURE__ */ r.jsx(n, { "data-test-id": "processing", children: t("global.processing") + "..." });
9
+ }
10
+ export {
11
+ i as default
12
+ };
@@ -0,0 +1,17 @@
1
+ import { u as e, b as i, j as p, R as n } from "./index-PMijvJqf.js";
2
+ import "./minimatch-x8aONUPa.js";
3
+ function u({ resultExtraButtons: r }) {
4
+ const { t: o } = e(), { state: s } = i(), { importError: t } = s;
5
+ return /* @__PURE__ */ p.jsx(
6
+ n,
7
+ {
8
+ status: t ? "error" : "success",
9
+ title: o(t ? "import.import_failure" : "import.import_done"),
10
+ subTitle: t || o("import.import_done_description"),
11
+ extra: t ? [] : r
12
+ }
13
+ );
14
+ }
15
+ export {
16
+ u as default
17
+ };
@@ -0,0 +1,322 @@
1
+ import { r as w, d as q, _ as B, s as z, u as P, I as j, a as G, j as e, N as Y, t as A, b as D, f as V, C as E, g as J, A as v, l as W, F as T, P as C, h as ee, T as te, i as ne, k as re, c as le } from "./index-PMijvJqf.js";
2
+ import "./minimatch-x8aONUPa.js";
3
+ var ie = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5l-41.1 41.1-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-65.3 65.3a8.03 8.03 0 000 11.3l42.3 42.3c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.06 304.06 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112zm161.2 465.2C726.2 620.3 668.9 644 608 644c-60.9 0-118.2-23.7-161.2-66.8-43.1-43-66.8-100.3-66.8-161.2 0-60.9 23.7-118.2 66.8-161.2 43-43.1 100.3-66.8 161.2-66.8 60.9 0 118.2 23.7 161.2 66.8 43.1 43 66.8 100.3 66.8 161.2 0 60.9-23.7 118.2-66.8 161.2z" } }] }, name: "key", theme: "outlined" };
4
+ const oe = ie;
5
+ var Q = function(i, p) {
6
+ return /* @__PURE__ */ w.createElement(q, B({}, i, {
7
+ ref: p,
8
+ icon: oe
9
+ }));
10
+ };
11
+ process.env.NODE_ENV !== "production" && (Q.displayName = "KeyOutlined");
12
+ const ae = /* @__PURE__ */ w.forwardRef(Q);
13
+ var se = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M574 665.4a8.03 8.03 0 00-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 00-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 000 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 000 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 00-11.3 0L372.3 598.7a8.03 8.03 0 000 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z" } }] }, name: "link", theme: "outlined" };
14
+ const ce = se;
15
+ var U = function(i, p) {
16
+ return /* @__PURE__ */ w.createElement(q, B({}, i, {
17
+ ref: p,
18
+ icon: ce
19
+ }));
20
+ };
21
+ process.env.NODE_ENV !== "production" && (U.displayName = "LinkOutlined");
22
+ const pe = /* @__PURE__ */ w.forwardRef(U);
23
+ var de = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z" } }] }, name: "warning", theme: "outlined" };
24
+ const ue = de;
25
+ var X = function(i, p) {
26
+ return /* @__PURE__ */ w.createElement(q, B({}, i, {
27
+ ref: p,
28
+ icon: ue
29
+ }));
30
+ };
31
+ process.env.NODE_ENV !== "production" && (X.displayName = "WarningOutlined");
32
+ const me = /* @__PURE__ */ w.forwardRef(X), ye = z.div`
33
+ display: grid;
34
+ grid-template-columns: 7rem 3rem;
35
+ grid-column-gap: 0.5em;
36
+ grid-row-gap: 1em;
37
+ `;
38
+ function ge({ columnIndex: l, sheet: i, onChange: p }) {
39
+ const { t: h } = P(), _ = i.type === j.LINK, x = (L) => {
40
+ p("key", L);
41
+ }, y = (L) => {
42
+ p("keyTo", L);
43
+ }, u = _ || i.mode !== G.insert, o = _;
44
+ return !u && !o ? null : /* @__PURE__ */ e.jsxs(ye, { $hasKeyTo: _, children: [
45
+ u && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
46
+ /* @__PURE__ */ e.jsxs("label", { children: [
47
+ h("import.import_key"),
48
+ ": "
49
+ ] }),
50
+ /* @__PURE__ */ e.jsx(Y, { checked: i.keyColumnIndex === l, onChange: x })
51
+ ] }),
52
+ o && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
53
+ /* @__PURE__ */ e.jsxs("label", { children: [
54
+ h("import.link_key"),
55
+ ": "
56
+ ] }),
57
+ /* @__PURE__ */ e.jsx(Y, { checked: i.keyToColumnIndex === l, onChange: y })
58
+ ] })
59
+ ] });
60
+ }
61
+ const ke = z(E)`
62
+ font-weight: bold;
63
+ margin: 0.5em 0;
64
+ color: ${A.errorColor};
65
+ `;
66
+ function be({ sheet: l }) {
67
+ var x;
68
+ const { state: i } = D(), { t: p } = P(), h = ((x = i == null ? void 0 : i.settingsError) == null ? void 0 : x[l.name]) ?? [], _ = [V.MAPPING, V.KEY, V.KEY_TO];
69
+ return /* @__PURE__ */ e.jsxs(E, { direction: "vertical", children: [
70
+ p("import.mapping"),
71
+ /* @__PURE__ */ e.jsx(ke, { direction: "vertical", size: "small", children: _.map((y) => h.includes(y) ? p(`import.settings_errors.${y}`) : null) })
72
+ ] });
73
+ }
74
+ const he = (l) => l.type === v.simple_link || l.type === v.advanced_link || l.type === v.tree, fe = z(E)`
75
+ && .ant-form-item-label {
76
+ padding: 0;
77
+ font-weight: bold;
78
+ }
79
+ `;
80
+ function _e({
81
+ sheetIndex: l,
82
+ libraries: i,
83
+ onLibrarySelect: p,
84
+ onImportTypeSelect: h,
85
+ onImportModeSelect: _,
86
+ onLinkAttributeSelect: x,
87
+ onTreeLinkLibrarySelect: y
88
+ }) {
89
+ var s, c, k, f;
90
+ const { lang: u } = J(), { t: o } = P(), { state: L } = D(), a = L.sheets[l], R = a.type === j.IGNORE, K = a.type === j.LINK && ((s = a.linkAttributeProps) == null ? void 0 : s.type) === v.tree ? (((k = (c = a.linkAttributeProps) == null ? void 0 : c.linked_tree) == null ? void 0 : k.libraries) ?? []).map((n) => ({
91
+ key: n.library.id,
92
+ value: n.library.id,
93
+ label: W(n.library.label, u)
94
+ })) : null, $ = Object.values(j).map((n) => ({
95
+ key: n,
96
+ value: n,
97
+ label: o(`import.types.${n}`)
98
+ })), M = Object.values(G).map((n) => ({
99
+ key: n,
100
+ value: n,
101
+ label: o(`import.modes.${n}`)
102
+ })), t = i.map((n) => ({
103
+ key: n.id,
104
+ value: n.id,
105
+ label: W(n.label, u) || n.id
106
+ })), r = a.attributes.filter(he).map((n) => ({
107
+ key: n.id,
108
+ value: n.id,
109
+ label: W(n.label, u) || n.id
110
+ }));
111
+ return /* @__PURE__ */ e.jsx(T, { layout: "vertical", children: /* @__PURE__ */ e.jsxs(fe, { direction: "horizontal", size: "middle", wrap: !0, children: [
112
+ /* @__PURE__ */ e.jsx(T.Item, { label: o("import.type"), required: !0, children: /* @__PURE__ */ e.jsx(
113
+ C,
114
+ {
115
+ style: { minWidth: 200 },
116
+ defaultValue: a.type,
117
+ placeholder: o("import.select_type"),
118
+ onChange: (n) => h(l, n),
119
+ options: $
120
+ }
121
+ ) }),
122
+ !R && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
123
+ /* @__PURE__ */ e.jsx(T.Item, { label: o("import.mode"), required: !0, children: /* @__PURE__ */ e.jsx(
124
+ C,
125
+ {
126
+ style: { minWidth: 240 },
127
+ defaultValue: a.mode,
128
+ placeholder: o("import.select_mode"),
129
+ onChange: (n) => _(l, n),
130
+ options: M
131
+ }
132
+ ) }),
133
+ /* @__PURE__ */ e.jsx(T.Item, { label: o("import.library"), required: !0, children: /* @__PURE__ */ e.jsx(
134
+ C,
135
+ {
136
+ style: { minWidth: 200 },
137
+ defaultValue: a.library ?? L.defaultLibrary,
138
+ placeholder: o("import.select_library"),
139
+ onChange: (n) => p(l, n),
140
+ options: t
141
+ }
142
+ ) }),
143
+ a.type === j.LINK && a.library && /* @__PURE__ */ e.jsx(T.Item, { label: o("import.link_attribute"), required: !0, children: /* @__PURE__ */ e.jsx(
144
+ C,
145
+ {
146
+ style: { minWidth: 200 },
147
+ defaultValue: a.linkAttribute,
148
+ value: a.linkAttribute,
149
+ placeholder: o("import.select_link_attribute"),
150
+ onChange: (n) => x(l, n),
151
+ options: r
152
+ }
153
+ ) }),
154
+ a.type === j.LINK && ((f = a.linkAttributeProps) == null ? void 0 : f.type) === v.tree && /* @__PURE__ */ e.jsx(T.Item, { label: o("import.tree_link_library"), required: !0, children: /* @__PURE__ */ e.jsx(
155
+ C,
156
+ {
157
+ style: { minWidth: 200 },
158
+ value: a.treeLinkLibrary,
159
+ placeholder: o("import.select_library"),
160
+ onChange: (n) => y(l, n),
161
+ options: K
162
+ }
163
+ ) })
164
+ ] })
165
+ ] }) });
166
+ }
167
+ const je = z.div`
168
+ width: 100%;
169
+ display: flex;
170
+ flex-direction: column;
171
+ `;
172
+ function Oe({ libraries: l, onGetAttributes: i }) {
173
+ const { lang: p } = J(), { t: h } = P(), { state: _, dispatch: x } = D(), { sheets: y } = _, u = (t, r) => {
174
+ y[t] = { ...y[t], ...r }, x({ type: le.SET_SHEETS, sheets: [...y] });
175
+ }, o = async (t, r) => {
176
+ const s = await i(r);
177
+ u(t, {
178
+ library: r,
179
+ attributes: s,
180
+ mapping: [],
181
+ linkAttribute: null,
182
+ keyToAttributes: null
183
+ });
184
+ }, L = (t, r) => {
185
+ u(t, {
186
+ type: r,
187
+ linkAttribute: null,
188
+ keyToAttributes: null
189
+ });
190
+ }, a = (t, r) => {
191
+ u(t, { mode: r });
192
+ }, R = async (t, r) => {
193
+ var I;
194
+ const s = y[t], c = s.attributes.find((O) => O.id === r), k = c.type === v.tree ? s.treeLinkLibrary : (I = c == null ? void 0 : c.linked_library) == null ? void 0 : I.id;
195
+ let f = [];
196
+ k && (f = await i(k));
197
+ const n = s.mapping;
198
+ u(t, {
199
+ linkAttribute: r,
200
+ linkAttributeProps: c,
201
+ mapping: n,
202
+ keyToAttributes: f,
203
+ treeLinkLibrary: c.type === v.tree && c.linked_tree.libraries.map((O) => O.library.id).includes(s.treeLinkLibrary) ? s.treeLinkLibrary : null
204
+ });
205
+ }, K = (t, r, s) => {
206
+ const c = y[t];
207
+ let k = [...c.mapping];
208
+ k[r] = s, k = k.map((f, n) => n !== r && f === s && c.keyToColumnIndex !== n && c.keyToColumnIndex !== r ? null : f), u(t, { mapping: k });
209
+ }, $ = async (t, r) => {
210
+ const s = r ? await i(r) : null;
211
+ u(t, { treeLinkLibrary: r, keyToAttributes: s });
212
+ }, M = y.map((t, r) => {
213
+ const s = t.type === j.IGNORE, c = t.data.slice(0, 3), k = (b) => (g, S) => {
214
+ const m = {}, F = t.mapping[b], N = g, d = g === "key" ? "keyTo" : "key", Z = g === "key" ? "keyColumnIndex" : "keyToColumnIndex", H = g === "key" ? "keyToColumnIndex" : "keyColumnIndex";
215
+ m[N] = S ? F : null, m[Z] = S ? b : null, t[H] === b && (m[d] = null, m[H] = null), g === "keyTo" && (m.mapping = [...t.mapping], m.mapping[b] = null), u(r, m);
216
+ }, f = (b, g) => ({
217
+ style: {
218
+ verticalAlign: "top",
219
+ background: g === c.length ? A.secondaryBg : A.defaultBg
220
+ }
221
+ }), n = [
222
+ {
223
+ value: "import_key",
224
+ label: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
225
+ /* @__PURE__ */ e.jsx(ae, {}),
226
+ " ",
227
+ h("import.import_key")
228
+ ] })
229
+ }
230
+ ];
231
+ t.type === j.LINK && n.push({
232
+ value: "link_key",
233
+ label: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
234
+ /* @__PURE__ */ e.jsx(pe, {}),
235
+ " ",
236
+ h("import.link_key")
237
+ ] })
238
+ });
239
+ const I = Object.keys(t.data[0]).map((b, g) => ({
240
+ title: b,
241
+ dataIndex: b,
242
+ onCell: f,
243
+ render: (S) => /* @__PURE__ */ e.jsx(ee.Paragraph, { ellipsis: { rows: 2 }, children: S })
244
+ }));
245
+ I.unshift({
246
+ title: /* @__PURE__ */ e.jsx(e.Fragment, {}),
247
+ dataIndex: "__root",
248
+ onCell: f,
249
+ width: "250px"
250
+ });
251
+ const O = c.map((b, g) => ({ ...b, key: g }));
252
+ if (t.type && t.library && (t.type !== j.LINK || t.linkAttribute)) {
253
+ const b = {
254
+ key: O.length,
255
+ __root: /* @__PURE__ */ e.jsx(be, { sheet: t }),
256
+ ...Object.keys(t.data[0]).reduce((g, S, m) => {
257
+ var N;
258
+ const F = (t.keyToColumnIndex === m ? (t == null ? void 0 : t.keyToAttributes) ?? [] : ((t == null ? void 0 : t.attributes) ?? []).filter(
259
+ (d) => (d == null ? void 0 : d.type) === v.simple || (d == null ? void 0 : d.type) === v.advanced
260
+ )).map((d) => ({
261
+ value: d.id,
262
+ key: d.id,
263
+ label: W(d.label, p) || d.id
264
+ }));
265
+ return g[S] = /* @__PURE__ */ e.jsxs(E, { direction: "vertical", style: { width: "100%" }, children: [
266
+ /* @__PURE__ */ e.jsx(
267
+ C,
268
+ {
269
+ style: { width: "100%" },
270
+ placeholder: h("import.do_not_import"),
271
+ value: (N = t.mapping) == null ? void 0 : N[m],
272
+ allowClear: !0,
273
+ onClear: () => K(r, m, null),
274
+ onSelect: (d) => K(r, m, d),
275
+ options: F
276
+ }
277
+ ),
278
+ /* @__PURE__ */ e.jsx(ge, { sheet: t, columnIndex: m, onChange: k(m) })
279
+ ] }), g;
280
+ }, {})
281
+ };
282
+ O.push(b);
283
+ }
284
+ return {
285
+ label: /* @__PURE__ */ e.jsxs(E, { children: [
286
+ t.name,
287
+ !!_.settingsError[t.name] && /* @__PURE__ */ e.jsx(me, { style: { color: A.errorColor } })
288
+ ] }),
289
+ key: String(r),
290
+ children: /* @__PURE__ */ e.jsxs(je, { children: [
291
+ /* @__PURE__ */ e.jsx(
292
+ _e,
293
+ {
294
+ sheetIndex: r,
295
+ libraries: l,
296
+ onLibrarySelect: o,
297
+ onImportTypeSelect: L,
298
+ onImportModeSelect: a,
299
+ onLinkAttributeSelect: R,
300
+ onTreeLinkLibrarySelect: $
301
+ }
302
+ ),
303
+ !s && /* @__PURE__ */ e.jsx(
304
+ te,
305
+ {
306
+ title: () => /* @__PURE__ */ e.jsx(ne.Title, { level: 5, children: h("import.data_overview") }),
307
+ columns: I,
308
+ dataSource: O,
309
+ size: "small",
310
+ tableLayout: "auto",
311
+ pagination: { hideOnSinglePage: !0 },
312
+ style: { width: "100%", overflow: "auto" }
313
+ }
314
+ )
315
+ ] })
316
+ };
317
+ });
318
+ return /* @__PURE__ */ e.jsx(re, { type: "card", items: M });
319
+ }
320
+ export {
321
+ Oe as default
322
+ };