@nuwatop/code-canvas-runtime 0.1.2 → 0.1.3

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.esm.js CHANGED
@@ -1,33 +1,33 @@
1
- var de = Object.defineProperty;
2
- var ue = (e, t, r) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var z = (e, t, r) => ue(e, typeof t != "symbol" ? t + "" : t, r);
4
- import * as pe from "@nuwatop/code-canvas-core";
5
- import { useAndStore as v, parseAction as fe, getCoreConfig as x, useStoreByName as me } from "@nuwatop/code-canvas-core";
1
+ var le = Object.defineProperty;
2
+ var se = (t, e, r) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var z = (t, e, r) => se(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import * as ie from "@nuwatop/code-canvas-core";
5
+ import { parseAction as ce, useAndStore as g, getCoreConfig as w, useStoreByName as de } from "@nuwatop/code-canvas-core";
6
6
  export * from "@nuwatop/code-canvas-core";
7
- import { jsx as s, jsxs as E, Fragment as he } from "react/jsx-runtime";
8
- import P, { useState as H, useEffect as ye, useMemo as $, Suspense as L } from "react";
9
- import { Spin as I, ConfigProvider as Q, message as ve, Drawer as ge, Modal as be } from "antd";
10
- import { create as xe } from "zustand";
11
- import { produce as Ce } from "immer";
12
- import { createRoot as B } from "react-dom/client";
13
- function we(e) {
14
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
+ import { jsx as a, jsxs as T, Fragment as ue } from "react/jsx-runtime";
8
+ import P, { useState as V, useEffect as fe, useMemo as S, Suspense as L } from "react";
9
+ import { Spin as F, ConfigProvider as G, message as pe, Modal as me, Drawer as he } from "antd";
10
+ import { create as ye } from "zustand";
11
+ import { produce as ge } from "immer";
12
+ import { createRoot as J } from "react-dom/client";
13
+ function be(t) {
14
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
15
15
  }
16
- var O = {}, G = { exports: {} };
17
- (function(e) {
18
- function t(r) {
16
+ var A = {}, X = { exports: {} };
17
+ (function(t) {
18
+ function e(r) {
19
19
  return r && r.__esModule ? r : {
20
20
  default: r
21
21
  };
22
22
  }
23
- e.exports = t, e.exports.__esModule = !0, e.exports.default = e.exports;
24
- })(G);
25
- var M = G.exports, A = {};
26
- Object.defineProperty(A, "__esModule", {
23
+ t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
24
+ })(X);
25
+ var I = X.exports, D = {};
26
+ Object.defineProperty(D, "__esModule", {
27
27
  value: !0
28
28
  });
29
- A.default = void 0;
30
- var _e = {
29
+ D.default = void 0;
30
+ const ve = {
31
31
  // Options
32
32
  items_per_page: "条/页",
33
33
  jump_to: "跳至",
@@ -42,99 +42,70 @@ var _e = {
42
42
  next_3: "向后 3 页",
43
43
  page_size: "页码"
44
44
  };
45
- A.default = _e;
46
- var D = {}, C = {}, N = {}, J = { exports: {} }, K = { exports: {} }, X = { exports: {} }, Z = { exports: {} };
47
- (function(e) {
48
- function t(r) {
49
- "@babel/helpers - typeof";
50
- return e.exports = t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
51
- return typeof n;
52
- } : function(n) {
53
- return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
54
- }, e.exports.__esModule = !0, e.exports.default = e.exports, t(r);
55
- }
56
- e.exports = t, e.exports.__esModule = !0, e.exports.default = e.exports;
57
- })(Z);
58
- var ee = Z.exports, te = { exports: {} };
59
- (function(e) {
60
- var t = ee.default;
61
- function r(n, a) {
62
- if (t(n) != "object" || !n) return n;
63
- var o = n[Symbol.toPrimitive];
64
- if (o !== void 0) {
65
- var l = o.call(n, a || "default");
66
- if (t(l) != "object") return l;
67
- throw new TypeError("@@toPrimitive must return a primitive value.");
68
- }
69
- return (a === "string" ? String : Number)(n);
70
- }
71
- e.exports = r, e.exports.__esModule = !0, e.exports.default = e.exports;
72
- })(te);
73
- var $e = te.exports;
74
- (function(e) {
75
- var t = ee.default, r = $e;
76
- function n(a) {
77
- var o = r(a, "string");
78
- return t(o) == "symbol" ? o : o + "";
79
- }
80
- e.exports = n, e.exports.__esModule = !0, e.exports.default = e.exports;
81
- })(X);
82
- var Pe = X.exports;
83
- (function(e) {
84
- var t = Pe;
85
- function r(n, a, o) {
86
- return (a = t(a)) in n ? Object.defineProperty(n, a, {
87
- value: o,
88
- enumerable: !0,
89
- configurable: !0,
90
- writable: !0
91
- }) : n[a] = o, n;
92
- }
93
- e.exports = r, e.exports.__esModule = !0, e.exports.default = e.exports;
94
- })(K);
95
- var Se = K.exports;
96
- (function(e) {
97
- var t = Se;
98
- function r(a, o) {
99
- var l = Object.keys(a);
100
- if (Object.getOwnPropertySymbols) {
101
- var i = Object.getOwnPropertySymbols(a);
102
- o && (i = i.filter(function(d) {
103
- return Object.getOwnPropertyDescriptor(a, d).enumerable;
104
- })), l.push.apply(l, i);
105
- }
106
- return l;
107
- }
108
- function n(a) {
109
- for (var o = 1; o < arguments.length; o++) {
110
- var l = arguments[o] != null ? arguments[o] : {};
111
- o % 2 ? r(Object(l), !0).forEach(function(i) {
112
- t(a, i, l[i]);
113
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(l)) : r(Object(l)).forEach(function(i) {
114
- Object.defineProperty(a, i, Object.getOwnPropertyDescriptor(l, i));
115
- });
116
- }
117
- return a;
118
- }
119
- e.exports = n, e.exports.__esModule = !0, e.exports.default = e.exports;
120
- })(J);
121
- var je = J.exports, k = {};
122
- Object.defineProperty(k, "__esModule", {
45
+ D.default = ve;
46
+ var N = {}, _ = {}, M = {}, R = {};
47
+ Object.defineProperty(R, "__esModule", {
123
48
  value: !0
124
49
  });
125
- k.commonLocale = void 0;
126
- k.commonLocale = {
50
+ R.commonLocale = void 0;
51
+ R.commonLocale = {
127
52
  yearFormat: "YYYY",
128
53
  dayFormat: "D",
129
54
  cellMeridiemFormat: "A",
130
55
  monthBeforeYear: !0
131
56
  };
132
- var Oe = M.default;
133
- Object.defineProperty(N, "__esModule", {
57
+ Object.defineProperty(M, "__esModule", {
134
58
  value: !0
135
59
  });
136
- N.default = void 0;
137
- var V = Oe(je), Me = k, Ae = (0, V.default)((0, V.default)({}, Me.commonLocale), {}, {
60
+ M.default = void 0;
61
+ var Ce = R;
62
+ function C(t) {
63
+ "@babel/helpers - typeof";
64
+ return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
65
+ return typeof e;
66
+ } : function(e) {
67
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
68
+ }, C(t);
69
+ }
70
+ function Q(t, e) {
71
+ var r = Object.keys(t);
72
+ if (Object.getOwnPropertySymbols) {
73
+ var n = Object.getOwnPropertySymbols(t);
74
+ e && (n = n.filter(function(s) {
75
+ return Object.getOwnPropertyDescriptor(t, s).enumerable;
76
+ })), r.push.apply(r, n);
77
+ }
78
+ return r;
79
+ }
80
+ function B(t) {
81
+ for (var e = 1; e < arguments.length; e++) {
82
+ var r = arguments[e] != null ? arguments[e] : {};
83
+ e % 2 ? Q(Object(r), !0).forEach(function(n) {
84
+ we(t, n, r[n]);
85
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : Q(Object(r)).forEach(function(n) {
86
+ Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
87
+ });
88
+ }
89
+ return t;
90
+ }
91
+ function we(t, e, r) {
92
+ return e = _e(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
93
+ }
94
+ function _e(t) {
95
+ var e = $e(t, "string");
96
+ return C(e) == "symbol" ? e : String(e);
97
+ }
98
+ function $e(t, e) {
99
+ if (C(t) != "object" || !t) return t;
100
+ var r = t[Symbol.toPrimitive];
101
+ if (r !== void 0) {
102
+ var n = r.call(t, e);
103
+ if (C(n) != "object") return n;
104
+ throw new TypeError("@@toPrimitive must return a primitive value.");
105
+ }
106
+ return (e === "string" ? String : Number)(t);
107
+ }
108
+ var xe = B(B({}, Ce.commonLocale), {}, {
138
109
  locale: "zh_CN",
139
110
  today: "今天",
140
111
  now: "此刻",
@@ -162,25 +133,25 @@ var V = Oe(je), Me = k, Ae = (0, V.default)((0, V.default)({}, Me.commonLocale),
162
133
  cellDateFormat: "D",
163
134
  monthBeforeYear: !1
164
135
  });
165
- N.default = Ae;
166
- var w = {};
167
- Object.defineProperty(w, "__esModule", {
136
+ M.default = xe;
137
+ var $ = {};
138
+ Object.defineProperty($, "__esModule", {
168
139
  value: !0
169
140
  });
170
- w.default = void 0;
171
- const De = {
141
+ $.default = void 0;
142
+ const Se = {
172
143
  placeholder: "请选择时间",
173
144
  rangePlaceholder: ["开始时间", "结束时间"]
174
145
  };
175
- w.default = De;
176
- var re = M.default;
177
- Object.defineProperty(C, "__esModule", {
146
+ $.default = Se;
147
+ var Z = I.default;
148
+ Object.defineProperty(_, "__esModule", {
178
149
  value: !0
179
150
  });
180
- C.default = void 0;
181
- var Ne = re(N), ke = re(w);
182
- const ne = {
183
- lang: Object.assign({
151
+ _.default = void 0;
152
+ var Pe = Z(M), Oe = Z($);
153
+ const K = {
154
+ lang: {
184
155
  placeholder: "请选择日期",
185
156
  yearPlaceholder: "请选择年份",
186
157
  quarterPlaceholder: "请选择季度",
@@ -190,35 +161,39 @@ const ne = {
190
161
  rangeYearPlaceholder: ["开始年份", "结束年份"],
191
162
  rangeMonthPlaceholder: ["开始月份", "结束月份"],
192
163
  rangeQuarterPlaceholder: ["开始季度", "结束季度"],
193
- rangeWeekPlaceholder: ["开始周", "结束周"]
194
- }, Ne.default),
195
- timePickerLocale: Object.assign({}, ke.default)
164
+ rangeWeekPlaceholder: ["开始周", "结束周"],
165
+ ...Pe.default
166
+ },
167
+ timePickerLocale: {
168
+ ...Oe.default
169
+ }
196
170
  };
197
- ne.lang.ok = "确定";
198
- C.default = ne;
199
- var Re = M.default;
200
- Object.defineProperty(D, "__esModule", {
171
+ K.lang.ok = "确定";
172
+ _.default = K;
173
+ var je = I.default;
174
+ Object.defineProperty(N, "__esModule", {
201
175
  value: !0
202
176
  });
203
- D.default = void 0;
204
- var ze = Re(C);
205
- D.default = ze.default;
206
- var R = M.default;
207
- Object.defineProperty(O, "__esModule", {
177
+ N.default = void 0;
178
+ var Ae = je(_);
179
+ N.default = Ae.default;
180
+ var k = I.default;
181
+ Object.defineProperty(A, "__esModule", {
208
182
  value: !0
209
183
  });
210
- O.default = void 0;
211
- var Ee = R(A), Te = R(D), Le = R(C), Ie = R(w);
212
- const f = "${label}不是一个有效的${type}", Fe = {
184
+ A.default = void 0;
185
+ var De = k(D), Ne = k(N), Me = k(_), Re = k($);
186
+ const p = "${label}不是一个有效的${type}", ke = {
213
187
  locale: "zh-cn",
214
- Pagination: Ee.default,
215
- DatePicker: Le.default,
216
- TimePicker: Ie.default,
217
- Calendar: Te.default,
188
+ Pagination: De.default,
189
+ DatePicker: Me.default,
190
+ TimePicker: Re.default,
191
+ Calendar: Ne.default,
218
192
  // locales for all components
219
193
  global: {
220
194
  placeholder: "请选择",
221
- close: "关闭"
195
+ close: "关闭",
196
+ sortable: "可排序"
222
197
  },
223
198
  Table: {
224
199
  filterTitle: "筛选",
@@ -299,19 +274,19 @@ const f = "${label}不是一个有效的${type}", Fe = {
299
274
  invalid: "${label}是一个无效日期"
300
275
  },
301
276
  types: {
302
- string: f,
303
- method: f,
304
- array: f,
305
- object: f,
306
- number: f,
307
- date: f,
308
- boolean: f,
309
- integer: f,
310
- float: f,
311
- regexp: f,
312
- email: f,
313
- url: f,
314
- hex: f
277
+ string: p,
278
+ method: p,
279
+ array: p,
280
+ object: p,
281
+ number: p,
282
+ date: p,
283
+ boolean: p,
284
+ integer: p,
285
+ float: p,
286
+ regexp: p,
287
+ email: p,
288
+ url: p,
289
+ hex: p
315
290
  },
316
291
  string: {
317
292
  len: "${label}须为${len}个字符",
@@ -336,9 +311,6 @@ const f = "${label}不是一个有效的${type}", Fe = {
336
311
  }
337
312
  }
338
313
  },
339
- Image: {
340
- preview: "预览"
341
- },
342
314
  QRCode: {
343
315
  expired: "二维码过期",
344
316
  refresh: "点击刷新",
@@ -351,184 +323,184 @@ const f = "${label}不是一个有效的${type}", Fe = {
351
323
  gradientColor: "渐变色"
352
324
  }
353
325
  };
354
- O.default = Fe;
355
- var Ye = O;
356
- const F = /* @__PURE__ */ we(Ye), m = /* @__PURE__ */ new Map(), qe = () => {
357
- const e = pe;
358
- Object.keys(e).forEach((t) => {
359
- if (t.startsWith("And") && typeof e[t] == "function") {
360
- const r = t.toLowerCase().replace("and", "and-");
361
- m.set(r, e[t]), m.set(t, e[t]);
326
+ A.default = ke;
327
+ var ze = A;
328
+ const Y = /* @__PURE__ */ be(ze), m = /* @__PURE__ */ new Map(), Te = () => {
329
+ const t = ie;
330
+ Object.keys(t).forEach((e) => {
331
+ if (e.startsWith("And") && typeof t[e] == "function") {
332
+ const r = e.toLowerCase().replace("and", "and-");
333
+ m.set(r, t[e]), m.set(e, t[e]);
362
334
  }
363
335
  });
364
336
  };
365
- qe();
366
- const Ue = (e, t) => {
367
- m.set(e, t), m.set(e.toLowerCase(), t);
368
- }, Y = (e) => {
369
- let t = m.get(e);
370
- return t || (t = m.get(e.toLowerCase()), t) || !e.startsWith("And") && (t = m.get(`And${e}`), t) || e.startsWith("and-") || (t = m.get(`and-${e.toLowerCase()}`)), t;
371
- }, We = () => Array.from(m.keys()), gt = {
372
- register: Ue,
373
- get: Y,
374
- getAll: We,
375
- has: (e) => m.has(e) || m.has(e.toLowerCase())
376
- }, He = (e) => {
337
+ Te();
338
+ const Ee = (t, e) => {
339
+ m.set(t, e), m.set(t.toLowerCase(), e);
340
+ }, q = (t) => {
341
+ let e = m.get(t);
342
+ return e || (e = m.get(t.toLowerCase()), e) || !t.startsWith("And") && (e = m.get(`And${t}`), e) || t.startsWith("and-") || (e = m.get(`and-${t.toLowerCase()}`)), e;
343
+ }, Le = () => Array.from(m.keys()), ft = {
344
+ register: Ee,
345
+ get: q,
346
+ getAll: Le,
347
+ has: (t) => m.has(t) || m.has(t.toLowerCase())
348
+ }, Fe = (t) => {
377
349
  try {
378
- const t = JSON.parse(e);
379
- return Ve(t);
380
- } catch (t) {
381
- throw new Error(`Failed to parse page config: ${t}`);
350
+ const e = JSON.parse(t);
351
+ return Ie(e);
352
+ } catch (e) {
353
+ throw new Error(`Failed to parse page config: ${e}`);
382
354
  }
383
- }, Ve = (e) => {
384
- if (!e)
355
+ }, Ie = (t) => {
356
+ if (!t)
385
357
  throw new Error("Page config is empty");
386
- return e.html || e.components ? {
387
- id: e.id,
388
- title: e.title,
389
- style: e.style,
390
- components: T(e.components || []),
391
- dataSets: e.dataSets || {},
392
- actions: e.actions || {}
393
- } : e;
394
- }, T = (e) => Array.isArray(e) ? e.map((t) => {
358
+ return t.html || t.components ? {
359
+ id: t.id,
360
+ title: t.title,
361
+ style: t.style,
362
+ components: E(t.components || []),
363
+ dataSets: t.dataSets || {},
364
+ actions: t.actions || {}
365
+ } : t;
366
+ }, E = (t) => Array.isArray(t) ? t.map((e) => {
395
367
  var r;
396
- return t.tagName || t["data-gjs-type"] ? {
397
- id: ((r = t.attributes) == null ? void 0 : r.id) || t.id,
398
- type: t["data-gjs-type"] || t.tagName || "div",
399
- props: { ...t.attributes },
400
- children: t.components ? T(t.components) : void 0,
401
- style: t.style
368
+ return e.tagName || e["data-gjs-type"] ? {
369
+ id: ((r = e.attributes) == null ? void 0 : r.id) || e.id,
370
+ type: e["data-gjs-type"] || e.tagName || "div",
371
+ props: { ...e.attributes },
372
+ children: e.components ? E(e.components) : void 0,
373
+ style: e.style
402
374
  } : {
403
- id: t.id,
404
- type: t.type,
405
- props: t.props || {},
406
- children: t.children ? T(t.children) : void 0,
407
- style: t.style
375
+ id: e.id,
376
+ type: e.type,
377
+ props: e.props || {},
378
+ children: e.children ? E(e.children) : void 0,
379
+ style: e.style
408
380
  };
409
- }) : [], Qe = I, Be = Q, bt = ({
410
- pageConfig: e,
411
- sessionId: t = `runtime_${Date.now()}`,
381
+ }) : [], Ye = F, qe = G, pt = ({
382
+ pageConfig: t,
383
+ sessionId: e = `runtime_${Date.now()}`,
412
384
  develop: r = !1,
413
385
  theme: n,
414
- loading: a = !1,
415
- onError: o
386
+ loading: s = !1,
387
+ onError: l
416
388
  }) => {
417
- const [l, i] = H(null), [d, p] = H(null);
418
- ye(() => {
389
+ const [o, d] = V(null), [c, f] = V(null);
390
+ fe(() => {
419
391
  try {
420
- const c = typeof e == "string" ? He(e) : e;
421
- i(c), p(null);
422
- } catch (c) {
423
- const u = c instanceof Error ? c : new Error(String(c));
424
- p(u), o == null || o(u);
392
+ const i = typeof t == "string" ? Fe(t) : t;
393
+ d(i), f(null);
394
+ } catch (i) {
395
+ const u = i instanceof Error ? i : new Error(String(i));
396
+ f(u), l == null || l(u);
425
397
  }
426
- }, [e, o]);
427
- const h = (c, u) => {
428
- var W;
429
- const g = Y(c.type);
430
- if (!g)
431
- return r ? /* @__PURE__ */ E("div", { style: { padding: 8, background: "#fff1f0", border: "1px solid #ffa39e", borderRadius: 4 }, children: [
398
+ }, [t, l]);
399
+ const h = (i, u) => {
400
+ var H;
401
+ const b = q(i.type);
402
+ if (!b)
403
+ return r ? /* @__PURE__ */ T("div", { style: { padding: 8, background: "#fff1f0", border: "1px solid #ffa39e", borderRadius: 4 }, children: [
432
404
  "未知组件: ",
433
- c.type
434
- ] }, c.id || u) : (console.warn(`Unknown component type: ${c.type}`), null);
435
- const b = {
436
- ...c.props,
437
- id: c.id,
438
- sessionId: t,
405
+ i.type
406
+ ] }, i.id || u) : (console.warn(`Unknown component type: ${i.type}`), null);
407
+ const v = {
408
+ ...i.props,
409
+ id: i.id,
410
+ sessionId: e,
439
411
  develop: r,
440
- key: c.id || u
441
- }, se = (W = c.children) == null ? void 0 : W.map((ie, ce) => h(ie, ce));
442
- return P.createElement(g, b, se);
443
- }, y = $(() => a ? /* @__PURE__ */ s("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: 200 }, children: /* @__PURE__ */ s(Qe, { size: "large" }) }) : d ? /* @__PURE__ */ E("div", { style: { padding: 24, background: "#fff2f0", border: "1px solid #ffccc7", borderRadius: 8 }, children: [
444
- /* @__PURE__ */ s("h3", { style: { color: "#cf1322" }, children: "渲染错误" }),
445
- /* @__PURE__ */ s("p", { children: d.message })
446
- ] }) : l ? /* @__PURE__ */ s("div", { className: "runtime-container", style: l.style, children: l.components.map((c, u) => h(c, u)) }) : null, [a, d, l, t, r]);
447
- return /* @__PURE__ */ s(Be, { locale: F, theme: n, children: y });
448
- }, Ge = (e) => (t, r, n) => (n.setState = (a, o, ...l) => {
449
- const i = typeof a == "function" ? Ce(a) : a;
450
- return t(i, o, ...l);
451
- }, e(n.setState, r, n)), Je = Ge, xt = xe()(
452
- Je((e) => ({
412
+ key: i.id || u
413
+ }, ne = (H = i.children) == null ? void 0 : H.map((oe, ae) => h(oe, ae));
414
+ return P.createElement(b, v, ne);
415
+ }, y = S(() => s ? /* @__PURE__ */ a("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: 200 }, children: /* @__PURE__ */ a(Ye, { size: "large" }) }) : c ? /* @__PURE__ */ T("div", { style: { padding: 24, background: "#fff2f0", border: "1px solid #ffccc7", borderRadius: 8 }, children: [
416
+ /* @__PURE__ */ a("h3", { style: { color: "#cf1322" }, children: "渲染错误" }),
417
+ /* @__PURE__ */ a("p", { children: c.message })
418
+ ] }) : o ? /* @__PURE__ */ a("div", { className: "runtime-container", style: o.style, children: o.components.map((i, u) => h(i, u)) }) : null, [s, c, o, e, r]);
419
+ return /* @__PURE__ */ a(qe, { locale: Y, theme: n, children: y });
420
+ }, Ue = (t) => (e, r, n) => (n.setState = (s, l, ...o) => {
421
+ const d = typeof s == "function" ? ge(s) : s;
422
+ return e(d, l, ...o);
423
+ }, t(n.setState, r, n)), We = Ue, mt = ye()(
424
+ We((t) => ({
453
425
  currentPageId: null,
454
426
  pageConfigs: {},
455
427
  loading: !1,
456
428
  error: null,
457
- setCurrentPage: (t) => e((r) => {
458
- r.currentPageId = t;
429
+ setCurrentPage: (e) => t((r) => {
430
+ r.currentPageId = e;
459
431
  }),
460
- setPageConfig: (t, r) => e((n) => {
461
- n.pageConfigs[t] = r;
432
+ setPageConfig: (e, r) => t((n) => {
433
+ n.pageConfigs[e] = r;
462
434
  }),
463
- setLoading: (t) => e((r) => {
464
- r.loading = t;
435
+ setLoading: (e) => t((r) => {
436
+ r.loading = e;
465
437
  }),
466
- setError: (t) => e((r) => {
467
- r.error = t;
438
+ setError: (e) => t((r) => {
439
+ r.error = e;
468
440
  }),
469
- clearCache: () => e((t) => {
470
- t.pageConfigs = {};
441
+ clearCache: () => t((e) => {
442
+ e.pageConfigs = {};
471
443
  })
472
444
  }))
473
- ), q = /* @__PURE__ */ new Map(), _ = (e, t) => {
474
- q.set(e, t);
475
- }, Ke = async (e, t) => {
476
- const { actionName: r, arg: n } = fe(e, t.value), a = q.get(r);
477
- if (a)
478
- return a(t, n);
479
- const o = v.getState().addCommand;
480
- return o(t.sessionId, {
445
+ ), U = /* @__PURE__ */ new Map(), x = (t, e) => {
446
+ U.set(t, e);
447
+ }, He = async (t, e) => {
448
+ const { actionName: r, arg: n } = ce(t, e.value), s = U.get(r);
449
+ if (s)
450
+ return s(e, n);
451
+ const l = g.getState().addCommand;
452
+ return l(e.sessionId, {
481
453
  actionName: r,
482
454
  arg: n,
483
455
  timestamp: Date.now()
484
456
  }), { actionName: r, arg: n };
485
457
  };
486
- _("setDataSet", (e, t) => {
487
- const { setDataSet: r } = v.getState();
488
- t != null && t.dataSet && (t == null ? void 0 : t.field) !== void 0 && r(t.dataSet, t.field, t.value);
458
+ x("setDataSet", (t, e) => {
459
+ const { setDataSet: r } = g.getState();
460
+ e != null && e.dataSet && (e == null ? void 0 : e.field) !== void 0 && r(e.dataSet, e.field, e.value);
489
461
  });
490
- _("navigate", (e, t) => {
491
- typeof window < "u" && (t != null && t.url) && (t.target === "_blank" ? window.open(t.url, "_blank") : window.location.href = t.url);
462
+ x("navigate", (t, e) => {
463
+ typeof window < "u" && (e != null && e.url) && (e.target === "_blank" ? window.open(e.url, "_blank") : window.location.href = e.url);
492
464
  });
493
- _("alert", (e, t) => {
494
- typeof window < "u" && window.alert((t == null ? void 0 : t.message) || t);
465
+ x("alert", (t, e) => {
466
+ typeof window < "u" && window.alert((e == null ? void 0 : e.message) || e);
495
467
  });
496
- _("console", (e, t) => {
468
+ x("console", (t, e) => {
497
469
  });
498
- const Ct = {
499
- execute: Ke,
500
- register: _,
501
- hasHandler: (e) => q.has(e)
502
- }, Xe = I, wt = ({
503
- componentName: e,
504
- componentProps: t = {},
470
+ const ht = {
471
+ execute: He,
472
+ register: x,
473
+ hasHandler: (t) => U.has(t)
474
+ }, Ve = F, yt = ({
475
+ componentName: t,
476
+ componentProps: e = {},
505
477
  storePropsKey: r,
506
478
  sessionId: n,
507
- loadingFallback: a,
508
- notFoundFallback: o,
509
- onError: l
479
+ loadingFallback: s,
480
+ notFoundFallback: l,
481
+ onError: o
510
482
  }) => {
511
- const i = v((c) => {
483
+ const d = g((i) => {
512
484
  if (!r) return null;
513
- const g = r.split(".")[0];
514
- return c.dataSets[g];
515
- }), d = $(() => {
516
- if (!r || !i) return {};
485
+ const b = r.split(".")[0];
486
+ return i.dataSets[b];
487
+ }), c = S(() => {
488
+ if (!r || !d) return {};
517
489
  const u = r.split(".")[1];
518
- return u ? i[u] || {} : i;
519
- }, [r, i]), p = $(() => ({
520
- ...d,
521
- ...t,
490
+ return u ? d[u] || {} : d;
491
+ }, [r, d]), f = S(() => ({
492
+ ...c,
493
+ ...e,
522
494
  sessionId: n
523
- }), [d, t, n]), h = $(() => {
495
+ }), [c, e, n]), h = S(() => {
524
496
  try {
525
- return Y(e);
526
- } catch (c) {
527
- const u = c instanceof Error ? c : new Error(String(c));
528
- return l == null || l(u), null;
497
+ return q(t);
498
+ } catch (i) {
499
+ const u = i instanceof Error ? i : new Error(String(i));
500
+ return o == null || o(u), null;
529
501
  }
530
- }, [e, l]), y = /* @__PURE__ */ s("div", { style: { display: "flex", justifyContent: "center", padding: 24 }, children: /* @__PURE__ */ s(Xe, {}) });
531
- return h ? /* @__PURE__ */ s(L, { fallback: a || y, children: /* @__PURE__ */ s(h, { ...p }) }) : o ? /* @__PURE__ */ s(he, { children: o }) : /* @__PURE__ */ E("div", { style: {
502
+ }, [t, o]), y = /* @__PURE__ */ a("div", { style: { display: "flex", justifyContent: "center", padding: 24 }, children: /* @__PURE__ */ a(Ve, {}) });
503
+ return h ? /* @__PURE__ */ a(L, { fallback: s || y, children: /* @__PURE__ */ a(h, { ...f }) }) : l ? /* @__PURE__ */ a(ue, { children: l }) : /* @__PURE__ */ T("div", { style: {
532
504
  padding: 16,
533
505
  background: "#fff7e6",
534
506
  border: "1px solid #ffd591",
@@ -537,10 +509,10 @@ const Ct = {
537
509
  color: "#d46b08"
538
510
  }, children: [
539
511
  "组件未找到: ",
540
- e
512
+ t
541
513
  ] });
542
- }, Ze = ge, et = be, S = I, oe = Q;
543
- class tt {
514
+ }, Qe = he, Be = me, O = F, ee = G;
515
+ class Ge {
544
516
  constructor() {
545
517
  z(this, "drawers", /* @__PURE__ */ new Map());
546
518
  z(this, "isSetup", !1);
@@ -548,22 +520,22 @@ class tt {
548
520
  /**
549
521
  * 添加 Drawer 实例
550
522
  */
551
- add(t) {
552
- this.drawers.set(t.id, t), this.setupGlobalCleanup();
523
+ add(e) {
524
+ this.drawers.set(e.id, e), this.setupGlobalCleanup();
553
525
  }
554
526
  /**
555
527
  * 移除 Drawer 实例
556
528
  */
557
- remove(t) {
558
- this.drawers.delete(t);
529
+ remove(e) {
530
+ this.drawers.delete(e);
559
531
  }
560
532
  /**
561
533
  * 清理所有 Drawer
562
534
  */
563
535
  cleanupAll() {
564
- this.drawers.forEach((t) => {
536
+ this.drawers.forEach((e) => {
565
537
  try {
566
- t.cleanup();
538
+ e.cleanup();
567
539
  } catch (r) {
568
540
  console.error("Failed to cleanup drawer:", r);
569
541
  }
@@ -581,20 +553,20 @@ class tt {
581
553
  setupGlobalCleanup() {
582
554
  this.isSetup || typeof window > "u" || (this.isSetup = !0, window.addEventListener("beforeunload", () => {
583
555
  this.cleanupAll();
584
- }), typeof import.meta < "u");
556
+ }));
585
557
  }
586
558
  }
587
- const j = new tt(), ae = () => `drawer-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, rt = ({ options: e, onClose: t, Component: r }) => {
588
- const [n, a] = P.useState(!0), o = x(), l = () => {
559
+ const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Je = ({ options: t, onClose: e, Component: r }) => {
560
+ const [n, s] = P.useState(!0), l = w(), o = () => {
589
561
  var y;
590
- a(!1), (y = e.onClose) == null || y.call(e), setTimeout(() => {
591
- t();
562
+ s(!1), (y = t.onClose) == null || y.call(t), setTimeout(() => {
563
+ e();
592
564
  }, 300);
593
- }, { component: i, componentName: d, componentProps: p, ...h } = e;
594
- return /* @__PURE__ */ s(oe, { locale: F, theme: o.theme, children: /* @__PURE__ */ s(Ze, { ...h, open: n, onClose: l, destroyOnClose: !0, children: r ? /* @__PURE__ */ s(
565
+ }, { component: d, componentName: c, componentProps: f, ...h } = t;
566
+ return /* @__PURE__ */ a(ee, { locale: Y, theme: l.theme, children: /* @__PURE__ */ a(Qe, { ...h, open: n, onClose: o, destroyOnClose: !0, children: r ? /* @__PURE__ */ a(
595
567
  L,
596
568
  {
597
- fallback: /* @__PURE__ */ s(
569
+ fallback: /* @__PURE__ */ a(
598
570
  "div",
599
571
  {
600
572
  style: {
@@ -602,12 +574,12 @@ const j = new tt(), ae = () => `drawer-${Date.now()}-${Math.random().toString(36
602
574
  justifyContent: "center",
603
575
  padding: 40
604
576
  },
605
- children: /* @__PURE__ */ s(S, {})
577
+ children: /* @__PURE__ */ a(O, {})
606
578
  }
607
579
  ),
608
- children: /* @__PURE__ */ s(r, { ...p || {}, onClose: l })
580
+ children: /* @__PURE__ */ a(r, { ...f || {}, onClose: o })
609
581
  }
610
- ) : /* @__PURE__ */ s(
582
+ ) : /* @__PURE__ */ a(
611
583
  "div",
612
584
  {
613
585
  style: {
@@ -616,41 +588,41 @@ const j = new tt(), ae = () => `drawer-${Date.now()}-${Math.random().toString(36
616
588
  alignItems: "center",
617
589
  height: "100%"
618
590
  },
619
- children: /* @__PURE__ */ s(S, { tip: "加载中..." })
591
+ children: /* @__PURE__ */ a(O, { tip: "加载中..." })
620
592
  }
621
593
  ) }) });
622
- }, nt = ({ options: e, onClose: t, Component: r }) => {
623
- const [n, a] = P.useState(!0), [o, l] = P.useState(!1), i = x(), d = () => {
624
- var b;
625
- a(!1), (b = e.onClose) == null || b.call(e), setTimeout(() => {
626
- t();
594
+ }, Xe = ({ options: t, onClose: e, Component: r }) => {
595
+ const [n, s] = P.useState(!0), [l, o] = P.useState(!1), d = w(), c = () => {
596
+ var v;
597
+ s(!1), (v = t.onClose) == null || v.call(t), setTimeout(() => {
598
+ e();
627
599
  }, 300);
628
- }, p = async () => {
629
- if (e.onOk) {
630
- l(!0);
600
+ }, f = async () => {
601
+ if (t.onOk) {
602
+ o(!0);
631
603
  try {
632
- await e.onOk(), d();
633
- } catch (b) {
634
- console.error("Modal onOk error:", b);
604
+ await t.onOk(), c();
605
+ } catch (v) {
606
+ console.error("Modal onOk error:", v);
635
607
  } finally {
636
- l(!1);
608
+ o(!1);
637
609
  }
638
610
  } else
639
- d();
640
- }, { component: h, componentName: y, componentProps: c, onOk: u, ...g } = e;
641
- return /* @__PURE__ */ s(oe, { locale: F, theme: i.theme, children: /* @__PURE__ */ s(
642
- et,
611
+ c();
612
+ }, { component: h, componentName: y, componentProps: i, onOk: u, ...b } = t;
613
+ return /* @__PURE__ */ a(ee, { locale: Y, theme: d.theme, children: /* @__PURE__ */ a(
614
+ Be,
643
615
  {
644
- ...g,
616
+ ...b,
645
617
  open: n,
646
- onCancel: d,
647
- onOk: p,
648
- confirmLoading: o,
618
+ onCancel: c,
619
+ onOk: f,
620
+ confirmLoading: l,
649
621
  destroyOnClose: !0,
650
- children: r ? /* @__PURE__ */ s(
622
+ children: r ? /* @__PURE__ */ a(
651
623
  L,
652
624
  {
653
- fallback: /* @__PURE__ */ s(
625
+ fallback: /* @__PURE__ */ a(
654
626
  "div",
655
627
  {
656
628
  style: {
@@ -658,12 +630,12 @@ const j = new tt(), ae = () => `drawer-${Date.now()}-${Math.random().toString(36
658
630
  justifyContent: "center",
659
631
  padding: 40
660
632
  },
661
- children: /* @__PURE__ */ s(S, {})
633
+ children: /* @__PURE__ */ a(O, {})
662
634
  }
663
635
  ),
664
- children: /* @__PURE__ */ s(r, { ...c || {}, onClose: d })
636
+ children: /* @__PURE__ */ a(r, { ...i || {}, onClose: c })
665
637
  }
666
- ) : /* @__PURE__ */ s(
638
+ ) : /* @__PURE__ */ a(
667
639
  "div",
668
640
  {
669
641
  style: {
@@ -672,148 +644,148 @@ const j = new tt(), ae = () => `drawer-${Date.now()}-${Math.random().toString(36
672
644
  alignItems: "center",
673
645
  minHeight: 100
674
646
  },
675
- children: /* @__PURE__ */ s(S, { tip: "加载中..." })
647
+ children: /* @__PURE__ */ a(O, { tip: "加载中..." })
676
648
  }
677
649
  )
678
650
  }
679
651
  ) });
680
652
  };
681
- function ot(e) {
682
- const t = ae(), r = document.createElement("div");
683
- r.setAttribute("data-drawer-container", "true"), r.setAttribute("data-drawer-id", t), document.body.appendChild(r);
684
- const n = B(r), a = () => {
685
- var l;
653
+ function Ze(t) {
654
+ const e = te(), r = document.createElement("div");
655
+ r.setAttribute("data-drawer-container", "true"), r.setAttribute("data-drawer-id", e), document.body.appendChild(r);
656
+ const n = J(r), s = () => {
657
+ var o;
686
658
  try {
687
- j.remove(t), n.unmount(), r.remove(), (l = e.afterClose) == null || l.call(e);
688
- } catch (i) {
689
- console.error("Drawer cleanup failed:", i);
659
+ j.remove(e), n.unmount(), r.remove(), (o = t.afterClose) == null || o.call(t);
660
+ } catch (d) {
661
+ console.error("Drawer cleanup failed:", d);
690
662
  }
691
663
  };
692
- j.add({ id: t, root: n, mountNode: r, cleanup: a });
693
- let o = e.component || null;
694
- if (!o && e.componentName) {
695
- const l = x();
696
- l.componentResolver ? o = l.componentResolver(e.componentName) : console.warn(
664
+ j.add({ id: e, root: n, mountNode: r, cleanup: s });
665
+ let l = t.component || null;
666
+ if (!l && t.componentName) {
667
+ const o = w();
668
+ o.componentResolver ? l = o.componentResolver(t.componentName) : console.warn(
697
669
  "[UIUtils.showDrawer] componentResolver not configured. Cannot resolve component:",
698
- e.componentName
670
+ t.componentName
699
671
  );
700
672
  }
701
673
  return n.render(
702
- /* @__PURE__ */ s(rt, { options: e, onClose: a, Component: o })
703
- ), a;
674
+ /* @__PURE__ */ a(Je, { options: t, onClose: s, Component: l })
675
+ ), s;
704
676
  }
705
- function at(e) {
706
- const t = ae(), r = document.createElement("div");
707
- r.setAttribute("data-modal-container", "true"), r.setAttribute("data-modal-id", t), document.body.appendChild(r);
708
- const n = B(r), a = () => {
677
+ function Ke(t) {
678
+ const e = te(), r = document.createElement("div");
679
+ r.setAttribute("data-modal-container", "true"), r.setAttribute("data-modal-id", e), document.body.appendChild(r);
680
+ const n = J(r), s = () => {
709
681
  try {
710
682
  n.unmount(), r.remove();
711
- } catch (l) {
712
- console.error("Modal cleanup failed:", l);
683
+ } catch (o) {
684
+ console.error("Modal cleanup failed:", o);
713
685
  }
714
686
  };
715
- let o = e.component || null;
716
- if (!o && e.componentName) {
717
- const l = x();
718
- l.componentResolver ? o = l.componentResolver(e.componentName) : console.warn(
687
+ let l = t.component || null;
688
+ if (!l && t.componentName) {
689
+ const o = w();
690
+ o.componentResolver ? l = o.componentResolver(t.componentName) : console.warn(
719
691
  "[UIUtils.showModal] componentResolver not configured. Cannot resolve component:",
720
- e.componentName
692
+ t.componentName
721
693
  );
722
694
  }
723
695
  return n.render(
724
- /* @__PURE__ */ s(nt, { options: e, onClose: a, Component: o })
725
- ), a;
696
+ /* @__PURE__ */ a(Xe, { options: t, onClose: s, Component: l })
697
+ ), s;
726
698
  }
727
- function lt() {
699
+ function et() {
728
700
  j.cleanupAll();
729
701
  }
730
- function st() {
702
+ function tt() {
731
703
  return j.count;
732
704
  }
733
- function it(e, t, r, n) {
734
- ve[e](t, r, n);
705
+ function rt(t, e, r, n) {
706
+ pe[t](e, r, n);
735
707
  }
736
- const _t = {
737
- showDrawer: ot,
738
- showModal: at,
739
- cleanupAllDrawers: lt,
740
- getDrawerCount: st,
741
- msg: it
742
- }, U = { module: "Module1" }, le = { router: void 0 }, $t = (e) => {
743
- U.module = e;
744
- }, Pt = (e) => {
745
- le.router = e;
746
- }, ct = (e, t, r) => {
747
- r ? r(U.module).then((n) => {
748
- typeof n[e] == "function" ? n[e](t) : console.error(
749
- `Action "${e}" does not exist on the module.`
708
+ const gt = {
709
+ showDrawer: Ze,
710
+ showModal: Ke,
711
+ cleanupAllDrawers: et,
712
+ getDrawerCount: tt,
713
+ msg: rt
714
+ }, W = { module: "Module1" }, re = { router: void 0 }, bt = (t) => {
715
+ W.module = t;
716
+ }, vt = (t) => {
717
+ re.router = t;
718
+ }, nt = (t, e, r) => {
719
+ r ? r(W.module).then((n) => {
720
+ typeof n[t] == "function" ? n[t](e) : console.error(
721
+ `Action "${t}" does not exist on the module.`
750
722
  );
751
723
  }).catch((n) => {
752
- console.error(`Failed to execute action:${e}`, n);
724
+ console.error(`Failed to execute action:${t}`, n);
753
725
  }) : console.warn(
754
726
  "Module loader not configured. Please provide moduleLoader in initRuntime options."
755
727
  );
756
- }, St = (e) => {
757
- const { sessionId: t = "default", utils: r, moduleLoader: n } = e || {}, a = x();
758
- let o = 0;
759
- return v.subscribe((i) => {
760
- const d = i.commandQueues[t] ?? [];
761
- if (d.length <= o) {
762
- o = d.length;
728
+ }, Ct = (t) => {
729
+ const { sessionId: e = "default", utils: r, moduleLoader: n } = t || {}, s = w();
730
+ let l = 0;
731
+ return g.subscribe((d) => {
732
+ const c = d.commandQueues[e] ?? [];
733
+ if (c.length <= l) {
734
+ l = c.length;
763
735
  return;
764
736
  }
765
- const p = d[d.length - 1];
766
- !p || typeof p.actionName != "string" || (o = d.length, v.getState().popCommand(t), ct(
767
- p.actionName,
737
+ const f = c[c.length - 1];
738
+ !f || typeof f.actionName != "string" || (l = c.length, g.getState().popCommand(e), nt(
739
+ f.actionName,
768
740
  {
769
- ...p.arg,
770
- moduleName: U.module,
741
+ ...f.arg,
742
+ moduleName: W.module,
771
743
  ctx: {
772
744
  utils: r,
773
- useStoreByName: me,
774
- defHttp: a.request,
745
+ useStoreByName: de,
746
+ defHttp: s.request,
775
747
  useValidateWatchStore: void 0,
776
- router: le.router
748
+ router: re.router
777
749
  }
778
750
  },
779
751
  n
780
752
  ));
781
753
  });
782
754
  };
783
- function jt(e) {
784
- return e && typeof e == "object" ? Object.values(e).some(
785
- (t) => typeof t == "string" && t.trim().length > 0
755
+ function wt(t) {
756
+ return t && typeof t == "object" ? Object.values(t).some(
757
+ (e) => typeof e == "string" && e.trim().length > 0
786
758
  ) : !1;
787
759
  }
788
- function Ot(e, t) {
789
- v.getState().addCommand(e, {
790
- ...t,
760
+ function _t(t, e) {
761
+ g.getState().addCommand(t, {
762
+ ...e,
791
763
  timestamp: Date.now()
792
764
  });
793
765
  }
794
- function Mt(e, t) {
795
- return v.getState().getValidateResults(e, t) ?? {};
766
+ function $t(t, e) {
767
+ return g.getState().getValidateResults(t, e) ?? {};
796
768
  }
797
769
  export {
798
- Ct as ActionExecutor,
799
- gt as ComponentRegistry,
800
- wt as DynamicContainer,
801
- bt as RuntimeRenderer,
802
- _t as UIUtils,
803
- Ot as addCommand,
804
- lt as cleanupAllDrawers,
805
- Y as getComponent,
806
- st as getDrawerCount,
807
- Mt as getValidateResults,
808
- St as initRuntime,
809
- it as msg,
810
- He as parsePageConfig,
811
- Ue as registerComponent,
812
- Pt as setRoute,
813
- ot as showDrawer,
814
- at as showModal,
815
- $t as useModule,
816
- xt as useRuntimeStore,
817
- jt as validateFailed
770
+ ht as ActionExecutor,
771
+ ft as ComponentRegistry,
772
+ yt as DynamicContainer,
773
+ pt as RuntimeRenderer,
774
+ gt as UIUtils,
775
+ _t as addCommand,
776
+ et as cleanupAllDrawers,
777
+ q as getComponent,
778
+ tt as getDrawerCount,
779
+ $t as getValidateResults,
780
+ Ct as initRuntime,
781
+ rt as msg,
782
+ Fe as parsePageConfig,
783
+ Ee as registerComponent,
784
+ vt as setRoute,
785
+ Ze as showDrawer,
786
+ Ke as showModal,
787
+ bt as useModule,
788
+ mt as useRuntimeStore,
789
+ wt as validateFailed
818
790
  };
819
791
  //# sourceMappingURL=index.esm.js.map