@steedos-widgets/antd 6.10.52-beta.9 → 6.10.52

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/antd.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  (function (global, factory) {
3
- (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('antd'), require('react-dom'), require('liquidjs')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'antd', 'react-dom', 'liquidjs'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderAntd = {}, global.React, global.antd, global.ReactDOM, global.liquidjs));
4
- })(this, function (exports, React, antd, reactDom, liquidjs) {
3
+ (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('antd'), require('react-dom'), require('liquidjs'), require('lodash')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'antd', 'react-dom', 'liquidjs', 'lodash'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderAntd = {}, global.React, global.antd, global.ReactDOM, global.liquidjs, global._));
4
+ })(this, function (exports, React, antd, reactDom, liquidjs, lodash) {
5
5
  var global = window;
6
6
  function _interopDefaultLegacy(e) {
7
7
  return e && _typeof(e) === 'object' && 'default' in e ? e : {
@@ -22,7 +22,26 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
22
22
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
23
  PERFORMANCE OF THIS SOFTWARE.
24
24
  ***************************************************************************** */
25
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
26
 
27
+ var _extendStatics = function extendStatics(d, b) {
28
+ _extendStatics = Object.setPrototypeOf || {
29
+ __proto__: []
30
+ } instanceof Array && function (d, b) {
31
+ d.__proto__ = b;
32
+ } || function (d, b) {
33
+ for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
34
+ };
35
+ return _extendStatics(d, b);
36
+ };
37
+ function __extends(d, b) {
38
+ if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
39
+ _extendStatics(d, b);
40
+ function __() {
41
+ this.constructor = d;
42
+ }
43
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44
+ }
26
45
  var _assign = function __assign() {
27
46
  _assign = Object.assign || function __assign(t) {
28
47
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -174,6 +193,15 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
174
193
  }
175
194
  return ar;
176
195
  }
196
+ function __spreadArray(to, from, pack) {
197
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
198
+ if (ar || !(i in from)) {
199
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
200
+ ar[i] = from[i];
201
+ }
202
+ }
203
+ return to.concat(ar || Array.prototype.slice.call(from));
204
+ }
177
205
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
178
206
  var e = new Error(message);
179
207
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -297,6 +325,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
297
325
  try {
298
326
  return JSON.parse(cleanStr);
299
327
  } catch (e) {
328
+ console.error(e, cleanStr);
300
329
  try {
301
330
  return new Function("return " + cleanStr)();
302
331
  } catch (e2) {
@@ -341,25 +370,155 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
341
370
  return flattened;
342
371
  }
343
372
  // --- 组件实现 ---
344
- var LiquidComponent = function LiquidComponent(_a) {
345
- var _b;
346
- var template = _a.template,
347
- tpl = _a.tpl,
348
- data = _a.data,
349
- className = _a.className,
350
- $schema = _a.$schema,
351
- amisRender = _a.render,
352
- dispatchEvent = _a.dispatchEvent,
353
- propsPartials = _a.partials;
354
- __rest(_a, ["template", "tpl", "data", "className", "$schema", "render", "dispatchEvent", "partials"]);
355
- var doAction = (_b = data._scoped) === null || _b === void 0 ? void 0 : _b.doAction;
373
+ // --- 错误边界组件 ---
374
+ var ErrorBoundary = /** @class */function (_super) {
375
+ __extends(ErrorBoundary, _super);
376
+ function ErrorBoundary(props) {
377
+ var _this = _super.call(this, props) || this;
378
+ _this.state = {
379
+ hasError: false,
380
+ error: null
381
+ };
382
+ return _this;
383
+ }
384
+ ErrorBoundary.getDerivedStateFromError = function (error) {
385
+ return {
386
+ hasError: true,
387
+ error: error
388
+ };
389
+ };
390
+ ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
391
+ console.error("Liquid Component ErrorBoundary caught error:", error, errorInfo);
392
+ };
393
+ ErrorBoundary.prototype.render = function () {
394
+ if (this.state.hasError) {
395
+ // 如果提供了 fallback 则使用 fallback,否则不显示(静默失败,符合“不影响整体显示”的要求)
396
+ // 但对于顶层错误,可能需要显示。这里用于 amisRender 的局部包裹。
397
+ return this.props.fallback || null;
398
+ }
399
+ return this.props.children;
400
+ };
401
+ return ErrorBoundary;
402
+ }(React__default["default"].Component);
403
+ // --- Portal 渲染器(React.memo 防止不必要的 remount)---
404
+ // amisRender 执行后可能窃取焦点,需要在每次 Portal 渲染后恢复焦点
405
+ var PortalRenderer = React__default["default"].memo(function PortalItem(_a) {
406
+ var _b, _c;
407
+ var portalKey = _a.portalKey,
408
+ schema = _a.schema,
409
+ domNode = _a.domNode,
410
+ amisRenderRef = _a.amisRenderRef,
411
+ dataRef = _a.dataRef;
412
+ // 记录焦点恢复定时器,确保组件卸载时清理
413
+ var focusTimerRef = React.useRef(null);
414
+ // render 阶段捕获当前焦点(在 amisRender 执行前)
415
+ var savedFocusRef = React.useRef({
416
+ element: null,
417
+ selectionStart: null,
418
+ selectionEnd: null
419
+ });
420
+ var active = document.activeElement;
421
+ if (active && active instanceof HTMLElement && active !== document.body) {
422
+ savedFocusRef.current = {
423
+ element: active,
424
+ selectionStart: (_b = active.selectionStart) !== null && _b !== void 0 ? _b : null,
425
+ selectionEnd: (_c = active.selectionEnd) !== null && _c !== void 0 ? _c : null
426
+ };
427
+ }
428
+ // amisRender 执行(可能会窃取焦点)
429
+ var rendered = amisRenderRef.current("partial-".concat(portalKey), schema, {
430
+ data: dataRef.current
431
+ });
432
+ // DOM 更新后恢复焦点(延迟 10ms,等待 amis 内部异步 DOM 操作完成)
433
+ React.useLayoutEffect(function () {
434
+ var _a = savedFocusRef.current,
435
+ element = _a.element,
436
+ selectionStart = _a.selectionStart,
437
+ selectionEnd = _a.selectionEnd;
438
+ if (!element || !(element instanceof HTMLElement)) return;
439
+ // 清理上一次未执行的定时器
440
+ if (focusTimerRef.current) {
441
+ clearTimeout(focusTimerRef.current);
442
+ }
443
+ focusTimerRef.current = setTimeout(function () {
444
+ focusTimerRef.current = null;
445
+ // 焦点已不在原元素上,且原元素仍在 DOM 中
446
+ if (document.activeElement !== element && document.body.contains(element)) {
447
+ element.focus();
448
+ // 恢复光标位置(input/textarea)
449
+ try {
450
+ if (selectionStart !== null && 'setSelectionRange' in element) {
451
+ element.setSelectionRange(selectionStart, selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : selectionStart);
452
+ }
453
+ } catch (_) {/* 某些 input type 不支持 setSelectionRange */}
454
+ }
455
+ }, 10);
456
+ });
457
+ // 组件卸载时清理定时器
458
+ React.useEffect(function () {
459
+ return function () {
460
+ if (focusTimerRef.current) {
461
+ clearTimeout(focusTimerRef.current);
462
+ }
463
+ };
464
+ }, []);
465
+ return reactDom.createPortal(React__default["default"].createElement(ErrorBoundary, {
466
+ fallback: null
467
+ }, rendered), domNode, portalKey);
468
+ }, function (prev, next) {
469
+ // 仅在 portalKey、DOM 节点或 schema 内容变化时才重新渲染
470
+ return prev.portalKey === next.portalKey && prev.domNode === next.domNode && lodash.isEqual(prev.schema, next.schema);
471
+ });
472
+ // --- 错误显示组件 ---
473
+ var ErrorDisplay = function ErrorDisplay(_a) {
474
+ var error = _a.error;
475
+ var _b = __read(React.useState(false), 2),
476
+ expanded = _b[0],
477
+ setExpanded = _b[1];
478
+ if (!error) return null;
479
+ return React__default["default"].createElement("div", {
480
+ className: "border border-red-500 bg-red-50 text-red-700 p-4 rounded mb-4 text-sm font-mono"
481
+ }, React__default["default"].createElement("div", {
482
+ className: "flex justify-between items-start"
483
+ }, React__default["default"].createElement("div", {
484
+ className: "font-bold"
485
+ }, "Template Render Error"), React__default["default"].createElement("button", {
486
+ onClick: function onClick() {
487
+ return setExpanded(!expanded);
488
+ },
489
+ className: "text-blue-600 hover:underline text-xs ml-4 whitespace-nowrap"
490
+ }, expanded ? 'Hide Details' : 'Show Details')), React__default["default"].createElement("div", {
491
+ className: "mt-1"
492
+ }, error.message), expanded && React__default["default"].createElement("div", {
493
+ className: "mt-2 pt-2 border-t border-red-200 text-xs overflow-auto max-h-60"
494
+ }, React__default["default"].createElement("pre", null, error.stack)));
495
+ };
496
+ var LiquidComponent = function LiquidComponent(props) {
497
+ var _a;
498
+ var template = props.template,
499
+ tpl = props.tpl,
500
+ data = props.data,
501
+ className = props.className,
502
+ $schema = props.$schema,
503
+ amisRender = props.render,
504
+ dispatchEvent = props.dispatchEvent,
505
+ propsPartials = props.partials;
506
+ __rest(props, ["template", "tpl", "data", "className", "$schema", "render", "dispatchEvent", "partials"]);
507
+ var doAction = (_a = data._scoped) === null || _a === void 0 ? void 0 : _a.doAction;
356
508
  // 支持 tpl 作为 template 的别名
357
509
  if (tpl && !template) {
358
510
  template = tpl;
359
511
  }
360
- var _c = __read(React.useState(''), 2),
361
- html = _c[0],
362
- setHtml = _c[1];
512
+ if (!template) {
513
+ template = props.$schema.template;
514
+ }
515
+ // console.log('template =============>', template, props);
516
+ var _b = __read(React.useState(''), 2),
517
+ html = _b[0],
518
+ setHtml = _b[1];
519
+ var _c = __read(React.useState(null), 2),
520
+ error = _c[0],
521
+ setError = _c[1];
363
522
  var _d = __read(React.useState([]), 2),
364
523
  parsedTemplates = _d[0],
365
524
  setParsedTemplates = _d[1];
@@ -367,6 +526,18 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
367
526
  mountNodes = _e[0],
368
527
  setMountNodes = _e[1];
369
528
  var containerRef = React.useRef(null);
529
+ // 焦点保护:跟踪当前聚焦元素,防止 re-render 导致焦点丢失
530
+ var focusInfoRef = React.useRef({
531
+ element: null,
532
+ inContainer: false
533
+ });
534
+ // 防抖的数据状态,用于减少 HTML 重建频率
535
+ // 保持最新 data 的引用,供脚本使用
536
+ var dataRef = React.useRef(data);
537
+ dataRef.current = data;
538
+ // 稳定引用 amisRender,防止因父组件 re-render 产生新函数引用导致 portals 重建
539
+ var amisRenderRef = React.useRef(amisRender);
540
+ amisRenderRef.current = amisRender;
370
541
  // 用于存储脚本清理函数的引用,以便在组件卸载或更新时清理副作用
371
542
  var scriptCleanupsRef = React.useRef([]);
372
543
  var finalPartials = React.useMemo(function () {
@@ -375,6 +546,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
375
546
  var partialsRef = React.useRef(finalPartials);
376
547
  partialsRef.current = finalPartials;
377
548
  var inlineSchemasRef = React.useRef({});
549
+ // 深比较稳定的 finalPartials 引用,防止 $schema 每次 render 产生新引用导致 portals 不必要重建
550
+ var stableFinalPartialsRef = React.useRef(finalPartials);
551
+ if (!lodash.isEqual(stableFinalPartialsRef.current, finalPartials)) {
552
+ stableFinalPartialsRef.current = finalPartials;
553
+ }
554
+ var stableFinalPartials = stableFinalPartialsRef.current;
378
555
  // 1. 初始化 Liquid Engine
379
556
  var engine = React.useMemo(function () {
380
557
  var liq = new liquidjs.Liquid({
@@ -453,6 +630,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
453
630
  return [2 /*return*/, ""];
454
631
  }
455
632
  } catch (e) {
633
+ console.error(e);
456
634
  return [2 /*return*/, "<div style=\"color:red\">JSON Parse Error: ".concat(e.message, "</div>")];
457
635
  }
458
636
  return [2 /*return*/];
@@ -462,76 +640,148 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
462
640
  });
463
641
  return liq;
464
642
  }, []);
465
- var dataFingerprint = JSON.stringify(data);
466
- var partialsFingerprint = JSON.stringify(finalPartials);
643
+ // 用于处理异步渲染竞态条件的计数器,确保只应用最新一次渲染的结果
644
+ var renderIdRef = React.useRef(0);
467
645
  React.useEffect(function () {
646
+ // console.log('template', template)
468
647
  var isMounted = true;
469
648
  try {
649
+ if (!template) {
650
+ if (isMounted) {
651
+ setParsedTemplates([]);
652
+ setError(null);
653
+ }
654
+ return;
655
+ }
470
656
  var tpl_1 = engine.parse(template);
471
657
  if (isMounted) {
472
658
  setParsedTemplates(tpl_1);
659
+ setError(null);
473
660
  }
474
661
  } catch (e) {
475
662
  console.error("Liquid Parse Error:", e);
663
+ if (isMounted) {
664
+ setError(e);
665
+ setParsedTemplates(null);
666
+ }
476
667
  }
477
668
  return function () {
478
669
  isMounted = false;
479
670
  };
480
671
  }, [engine, template]);
481
- // 2. Liquid 渲染 HTML
672
+ // 2. Liquid 渲染 HTML(当模板、partials 或数据变化时重新渲染)
482
673
  React.useEffect(function () {
483
- if (!parsedTemplates) return;
674
+ // 跳过空模板或未解析的模板(parsedTemplates 为 null、undefined 或空数组时)
675
+ if (!parsedTemplates || parsedTemplates.length === 0) return;
484
676
  var isMounted = true;
485
- inlineSchemasRef.current = {};
677
+ var currentRenderId = ++renderIdRef.current;
486
678
  var contextData = _assign(_assign({}, flattenObjectChain(data)), {
487
679
  __registerInlineSchema: function __registerInlineSchema(id, schema) {
488
680
  inlineSchemasRef.current[id] = schema;
489
681
  }
490
682
  });
491
683
  engine.render(parsedTemplates, contextData).then(function (result) {
492
- if (isMounted) {
684
+ // 仅应用最新一次渲染的结果,丢弃过期的异步结果(处理竞态条件)
685
+ if (isMounted && currentRenderId === renderIdRef.current) {
686
+ // 仅在渲染结果真正变化时才更新 state,避免不必要的 DOM 重建
493
687
  setHtml(function (prev) {
494
- return prev !== result ? result : prev;
688
+ return prev === result ? prev : result;
495
689
  });
690
+ setError(null);
496
691
  }
497
692
  })["catch"](function (err) {
498
- console.log("render error: ", template, contextData);
499
- if (isMounted) console.error("Liquid Render Error:", err);
693
+ if (isMounted && currentRenderId === renderIdRef.current) {
694
+ console.error("Liquid Render Error:", err);
695
+ setError(err);
696
+ }
500
697
  });
501
698
  return function () {
502
699
  isMounted = false;
503
700
  };
504
- }, [engine, parsedTemplates, dataFingerprint, partialsFingerprint]);
701
+ }, [engine, parsedTemplates, finalPartials, data]); // data 变化时重新渲染模板
505
702
  // 3. Portals 挂载检测
506
703
  React.useEffect(function () {
507
704
  if (!containerRef.current) return;
508
705
  var nodes = {};
509
706
  var elements = containerRef.current.querySelectorAll('[data-amis-partial]');
510
- var hasChanges = false;
511
707
  elements.forEach(function (el) {
512
708
  var key = el.getAttribute('data-amis-partial');
513
- if (key && (inlineSchemasRef.current[key] || partialsRef.current[key])) {
709
+ var hasInlineSchema = key && inlineSchemasRef.current[key];
710
+ var hasPartialSchema = key && partialsRef.current[key];
711
+ if (key && (hasInlineSchema || hasPartialSchema)) {
514
712
  nodes[key] = el;
515
- hasChanges = true;
516
713
  }
517
714
  });
518
- if (hasChanges) setMountNodes(nodes);
715
+ // 每次 html 变化都需要更新 DOM 节点引用,因为 dangerouslySetInnerHTML 会销毁并重建节点
716
+ // 但仅在节点实际变化时更新,避免不必要的 Portal 重新创建
717
+ setMountNodes(function (prev) {
718
+ var prevKeys = Object.keys(prev).sort().join(',');
719
+ var newKeys = Object.keys(nodes).sort().join(',');
720
+ var keysChanged = prevKeys !== newKeys;
721
+ // 仅在 keys 实际变化时更新(新增或删除了 Portal 挂载点)
722
+ if (keysChanged) {
723
+ return nodes;
724
+ }
725
+ // Keys 相同但 html 变了,需要更新 DOM 节点引用(dangerouslySetInnerHTML 销毁重建了节点)
726
+ // 但不能创建新对象,否则会触发 Portal useMemo 重新执行
727
+ // 所以我们更新 prev 对象中的节点引用
728
+ Object.keys(nodes).forEach(function (key) {
729
+ if (prev[key] !== nodes[key]) {
730
+ prev[key] = nodes[key];
731
+ }
732
+ });
733
+ return prev;
734
+ });
735
+ }, [html]);
736
+ // 3.5 阻止容器内原生表单的默认提交行为
737
+ // 防止在 input 中按回车键时触发浏览器默认的表单 submit,导致页面刷新、所有表单值丢失
738
+ React.useEffect(function () {
739
+ var container = containerRef.current;
740
+ if (!container) return;
741
+ // 拦截 form submit 事件(覆盖显式提交和 Enter 键隐式提交)
742
+ var handleSubmit = function handleSubmit(e) {
743
+ e.preventDefault();
744
+ };
745
+ // 拦截 input 中的 Enter 键,防止触发外层 form 的隐式提交
746
+ // (适用于 form 在容器之上的情况,此时 submit 事件无法在容器层拦截)
747
+ var handleKeyDown = function handleKeyDown(e) {
748
+ if (e.key !== 'Enter') return;
749
+ var target = e.target;
750
+ // 仅拦截单行 input,不影响 textarea 的换行行为
751
+ if (target.tagName === 'INPUT') {
752
+ var form = target.closest('form');
753
+ if (form) {
754
+ e.preventDefault();
755
+ }
756
+ }
757
+ };
758
+ container.addEventListener('submit', handleSubmit);
759
+ container.addEventListener('keydown', handleKeyDown);
760
+ return function () {
761
+ container.removeEventListener('submit', handleSubmit);
762
+ container.removeEventListener('keydown', handleKeyDown);
763
+ };
519
764
  }, [html]);
520
765
  // 4. 创建 Portals
766
+ // 使用 PortalRenderer (React.memo) 包裹每个 Portal,确保只有 schema 实际变化的 Portal 才会重新渲染
767
+ // 移除 amisRender 依赖(使用 ref),避免父组件 re-render 导致所有 Portal 被销毁重建
521
768
  var portals = React.useMemo(function () {
522
769
  return Object.keys(mountNodes).map(function (key) {
523
770
  var domNode = mountNodes[key];
524
771
  var schema = inlineSchemasRef.current[key] || partialsRef.current[key];
525
- if (!schema || !domNode) return null;
526
- try {
527
- return reactDom.createPortal(amisRender("partial-".concat(key), schema, {
528
- data: data
529
- }), domNode);
530
- } catch (e) {
772
+ if (!schema || !domNode) {
531
773
  return null;
532
774
  }
775
+ return React__default["default"].createElement(PortalRenderer, {
776
+ key: key,
777
+ portalKey: key,
778
+ schema: schema,
779
+ domNode: domNode,
780
+ amisRenderRef: amisRenderRef,
781
+ dataRef: dataRef
782
+ });
533
783
  });
534
- }, [mountNodes, partialsFingerprint, dataFingerprint, amisRender, data]);
784
+ }, [mountNodes, stableFinalPartials]); // 使用稳定引用,避免不必要的 Portal 重建
535
785
  // ==================================================================================
536
786
  // 5. 核心逻辑:顺序加载器 (等待外部脚本加载完再执行内联脚本)
537
787
  // ==================================================================================
@@ -578,7 +828,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
578
828
  // 标记当前节点已处理,防止下次 render 重复
579
829
  scriptNode.dataset.executed = "true";
580
830
  if (isGlobalLoaded) {
581
- console.log("[Liquid] Script already loaded: ".concat(src));
831
+ // console.log(`[Liquid] Script already loaded: ${src}`);
582
832
  resolve(); // 已存在,直接视为成功
583
833
  return;
584
834
  }
@@ -593,7 +843,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
593
843
  }
594
844
  });
595
845
  newScript.onload = function () {
596
- console.log("[Liquid] Loaded: ".concat(src));
846
+ // console.log(`[Liquid] Loaded: ${src}`);
597
847
  resolve();
598
848
  };
599
849
  newScript.onerror = function () {
@@ -615,7 +865,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
615
865
  var debugName = "steedos-liquid-".concat(Math.random().toString(36).slice(2), ".js");
616
866
  var debuggableCode = code + "\n//# sourceURL=".concat(debugName);
617
867
  var func = new Function('data', 'dom', 'doAction', 'dispatchEvent', debuggableCode);
618
- var cleanupResult = func(data, scriptNode.parentElement, doAction, dispatchEvent);
868
+ // 使用 dataRef.current 获取最新的 data
869
+ var cleanupResult = func(dataRef.current, scriptNode.parentElement, doAction, dispatchEvent);
619
870
  if (typeof cleanupResult === 'function') {
620
871
  scriptCleanupsRef.current.push(cleanupResult);
621
872
  }
@@ -637,14 +888,68 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
637
888
  return cleanup && cleanup();
638
889
  });
639
890
  };
640
- }, [html, dataFingerprint]);
641
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", {
642
- className: "liquid-amis-container flex flex-col h-full w-full overflow-hidden ".concat(className || ''),
643
- ref: containerRef,
644
- dangerouslySetInnerHTML: {
645
- __html: html
891
+ }, [html]); // 仅依赖 html 变化,不依赖 data 变化
892
+ // ==================================================================================
893
+ // 6. 焦点保护机制
894
+ // 在 render 阶段捕获当前焦点状态,在 DOM 更新后延迟恢复意外丢失的焦点
895
+ // ==================================================================================
896
+ var outerFocusTimerRef = React.useRef(null);
897
+ if (containerRef.current) {
898
+ var active = document.activeElement;
899
+ focusInfoRef.current = {
900
+ element: active,
901
+ inContainer: !!active && containerRef.current.contains(active)
902
+ };
903
+ } else {
904
+ focusInfoRef.current = {
905
+ element: null,
906
+ inContainer: false
907
+ };
908
+ }
909
+ React.useLayoutEffect(function () {
910
+ var _a = focusInfoRef.current,
911
+ element = _a.element,
912
+ inContainer = _a.inContainer;
913
+ if (!inContainer || !element || !(element instanceof HTMLElement)) return;
914
+ if (outerFocusTimerRef.current) {
915
+ clearTimeout(outerFocusTimerRef.current);
646
916
  }
647
- }), portals);
917
+ outerFocusTimerRef.current = setTimeout(function () {
918
+ outerFocusTimerRef.current = null;
919
+ if (document.activeElement !== element && (document.activeElement === document.body || document.activeElement === null) && document.body.contains(element)) {
920
+ element.focus();
921
+ }
922
+ }, 10);
923
+ });
924
+ // 组件卸载时清理外层焦点定时器
925
+ React.useEffect(function () {
926
+ return function () {
927
+ if (outerFocusTimerRef.current) {
928
+ clearTimeout(outerFocusTimerRef.current);
929
+ }
930
+ };
931
+ }, []);
932
+ // 7. 缓存容器元素,避免 data 变化时 React 对 dangerouslySetInnerHTML div 进行不必要的协调
933
+ var innerHtml = React.useMemo(function () {
934
+ return {
935
+ __html: html
936
+ };
937
+ }, [html]);
938
+ var containerElement = React.useMemo(function () {
939
+ return React__default["default"].createElement("div", {
940
+ className: "liquid-amis-container flex flex-col w-full overflow-hidden ".concat(className || ''),
941
+ ref: containerRef,
942
+ dangerouslySetInnerHTML: innerHtml
943
+ });
944
+ }, [innerHtml, className]);
945
+ if (error) {
946
+ return React__default["default"].createElement("div", {
947
+ className: "liquid-amis-container flex flex-col w-full overflow-auto p-4 ".concat(className || '')
948
+ }, React__default["default"].createElement(ErrorDisplay, {
949
+ error: error
950
+ }));
951
+ }
952
+ return React__default["default"].createElement(React__default["default"].Fragment, null, containerElement, portals);
648
953
  };
649
954
  var Inject = function Inject(props) {
650
955
  var _a = props.assets,
@@ -736,6 +1041,323 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
736
1041
  if (!body) return null;
737
1042
  return React__default["default"].createElement(React__default["default"].Fragment, null, children, render('body', body, {}));
738
1043
  };
1044
+ var AntdRelatedInstances = function AntdRelatedInstances(props) {
1045
+ var value = props.value,
1046
+ onChange = props.onChange,
1047
+ rootUrl = props.rootUrl,
1048
+ tenantId = props.tenantId,
1049
+ authToken = props.authToken,
1050
+ _a = props.placeholder,
1051
+ placeholder = _a === void 0 ? '搜索申请单' : _a,
1052
+ disabled = props.disabled,
1053
+ cx = props.classnames,
1054
+ env = props.env,
1055
+ amisData = props.data,
1056
+ _b = props.pageSize,
1057
+ pageSize = _b === void 0 ? 20 : _b,
1058
+ _c = props.filterMonths,
1059
+ filterMonths = _c === void 0 ? 6 : _c;
1060
+ // 归一化 value:可能是 string[] 或 {_id, name}[] 对象数组
1061
+ var normalizeValue = React.useCallback(function (val) {
1062
+ if (!val || !Array.isArray(val)) return [];
1063
+ return val.map(function (item) {
1064
+ if (typeof item === 'string') return item;
1065
+ if (_typeof(item) === 'object' && item._id) return item._id;
1066
+ return String(item);
1067
+ });
1068
+ }, []);
1069
+ // 从对象数组中提取名称映射
1070
+ var extractNamesFromValue = React.useCallback(function (val) {
1071
+ if (!val || !Array.isArray(val)) return {};
1072
+ var map = {};
1073
+ val.forEach(function (item) {
1074
+ if (_typeof(item) === 'object' && item._id && item.name) {
1075
+ map[item._id] = item.name;
1076
+ }
1077
+ });
1078
+ return map;
1079
+ }, []);
1080
+ var _d = __read(React.useState([]), 2),
1081
+ items = _d[0],
1082
+ setItems = _d[1];
1083
+ var _e = __read(React.useState(0), 2),
1084
+ total = _e[0],
1085
+ setTotal = _e[1];
1086
+ var _f = __read(React.useState(false), 2),
1087
+ loading = _f[0],
1088
+ setLoading = _f[1];
1089
+ var _g = __read(React.useState(''), 2),
1090
+ keywords = _g[0],
1091
+ setKeywords = _g[1];
1092
+ var _h = __read(React.useState(1), 2),
1093
+ currentPage = _h[0],
1094
+ setCurrentPage = _h[1];
1095
+ var debounceTimer = React.useRef(null);
1096
+ // 缓存已选项信息,翻页后仍可展示
1097
+ var _j = __read(React.useState(function () {
1098
+ return extractNamesFromValue(value);
1099
+ }), 2),
1100
+ selectedItemsMap = _j[0],
1101
+ setSelectedItemsMap = _j[1];
1102
+ // 内部管理选中状态,不完全依赖外部 value
1103
+ var _k = __read(React.useState(function () {
1104
+ return normalizeValue(value);
1105
+ }), 2),
1106
+ selectedKeys = _k[0],
1107
+ setSelectedKeys = _k[1];
1108
+ var getAuthHeader = React.useCallback(function () {
1109
+ var tid = tenantId || amisData && amisData.context && amisData.context.tenantId || env && env.session && env.session.tenantId || '';
1110
+ var token = authToken || amisData && amisData.context && amisData.context.authToken || env && env.session && env.session.authToken || '';
1111
+ return "Bearer ".concat(tid, ",").concat(token);
1112
+ }, [tenantId, authToken, amisData, env]);
1113
+ var getGraphqlUrl = React.useCallback(function () {
1114
+ var root = rootUrl || amisData && amisData.context && amisData.context.rootUrl || env && env.session && env.session.rootUrl || '';
1115
+ return "".concat(root, "/graphql");
1116
+ }, [rootUrl, amisData, env]);
1117
+ var buildDateFilters = React.useCallback(function () {
1118
+ var now = new Date();
1119
+ var start = new Date(now);
1120
+ start.setMonth(start.getMonth() - filterMonths);
1121
+ start.setHours(0, 0, 0, 0);
1122
+ var end = new Date(now);
1123
+ end.setHours(23, 59, 59, 999);
1124
+ var startStr = start.toISOString();
1125
+ var endStr = end.toISOString();
1126
+ return "[[\"submit_date\",\"between\",[\"".concat(startStr, "\",\"").concat(endStr, "\"]]]");
1127
+ }, [filterMonths]);
1128
+ var fetchInstances = React.useCallback(function (searchKeywords, page) {
1129
+ return __awaiter(void 0, void 0, void 0, function () {
1130
+ var skip, filters, query, response, result, rows_1, count;
1131
+ return __generator(this, function (_a) {
1132
+ switch (_a.label) {
1133
+ case 0:
1134
+ setLoading(true);
1135
+ _a.label = 1;
1136
+ case 1:
1137
+ _a.trys.push([1, 4, 5, 6]);
1138
+ skip = (page - 1) * pageSize;
1139
+ filters = buildDateFilters();
1140
+ query = "\n query{\n rows: instances__getRelatedInstances(keywords: ".concat(JSON.stringify(searchKeywords), ", top: ").concat(pageSize, ", skip: ").concat(skip, ", filters: ").concat(filters, "){\n _id,\n name,\n flow_name,\n submit_date,\n submitter\n _display:_ui{\n submit_date,\n submitter\n }\n },\n count: instances__getRelatedInstances__count(filters: ").concat(filters, ", keywords: ").concat(JSON.stringify(searchKeywords), ")\n }\n ");
1141
+ return [4 /*yield*/, fetch(getGraphqlUrl(), {
1142
+ method: 'POST',
1143
+ headers: {
1144
+ 'Content-Type': 'application/json',
1145
+ 'Authorization': getAuthHeader()
1146
+ },
1147
+ body: JSON.stringify({
1148
+ query: query
1149
+ })
1150
+ })];
1151
+ case 2:
1152
+ response = _a.sent();
1153
+ return [4 /*yield*/, response.json()];
1154
+ case 3:
1155
+ result = _a.sent();
1156
+ rows_1 = result && result.data && result.data.rows || [];
1157
+ count = result && result.data && result.data.count || 0;
1158
+ setItems(rows_1);
1159
+ setTotal(count);
1160
+ // 缓存当前页项的名称
1161
+ setSelectedItemsMap(function (prev) {
1162
+ var next = _assign({}, prev);
1163
+ rows_1.forEach(function (r) {
1164
+ next[r._id] = r.name;
1165
+ });
1166
+ return next;
1167
+ });
1168
+ return [3 /*break*/, 6];
1169
+ case 4:
1170
+ _a.sent();
1171
+ setItems([]);
1172
+ setTotal(0);
1173
+ return [3 /*break*/, 6];
1174
+ case 5:
1175
+ setLoading(false);
1176
+ return [7 /*endfinally*/];
1177
+ case 6:
1178
+ return [2 /*return*/];
1179
+ }
1180
+ });
1181
+ });
1182
+ }, [getGraphqlUrl, getAuthHeader, pageSize, buildDateFilters]);
1183
+ React.useEffect(function () {
1184
+ fetchInstances(keywords, currentPage);
1185
+ }, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
1186
+ React.useEffect(function () {
1187
+ fetchInstances('', 1);
1188
+ }, [fetchInstances]);
1189
+ var handleSearch = React.useCallback(function (searchValue) {
1190
+ setKeywords(searchValue);
1191
+ if (debounceTimer.current) {
1192
+ clearTimeout(debounceTimer.current);
1193
+ }
1194
+ debounceTimer.current = setTimeout(function () {
1195
+ setCurrentPage(1);
1196
+ fetchInstances(searchValue, 1);
1197
+ }, 300);
1198
+ }, [fetchInstances]);
1199
+ var handlePageChange = React.useCallback(function (page) {
1200
+ setCurrentPage(page);
1201
+ fetchInstances(keywords, page);
1202
+ }, [fetchInstances, keywords]);
1203
+ // 外部 value 变化时同步到内部
1204
+ React.useEffect(function () {
1205
+ if (value !== undefined) {
1206
+ var keys = normalizeValue(value);
1207
+ setSelectedKeys(keys);
1208
+ var names_1 = extractNamesFromValue(value);
1209
+ if (Object.keys(names_1).length > 0) {
1210
+ setSelectedItemsMap(function (prev) {
1211
+ return _assign(_assign({}, prev), names_1);
1212
+ });
1213
+ }
1214
+ }
1215
+ }, [value, normalizeValue, extractNamesFromValue]);
1216
+ var selectedSet = React.useMemo(function () {
1217
+ return new Set(selectedKeys);
1218
+ }, [selectedKeys]);
1219
+ var updateSelection = React.useCallback(function (next) {
1220
+ setSelectedKeys(next);
1221
+ if (onChange) {
1222
+ onChange(next);
1223
+ }
1224
+ }, [onChange]);
1225
+ var handleToggle = React.useCallback(function (id) {
1226
+ if (disabled) return;
1227
+ var next = selectedSet.has(id) ? selectedKeys.filter(function (v) {
1228
+ return v !== id;
1229
+ }) : __spreadArray(__spreadArray([], __read(selectedKeys), false), [id], false);
1230
+ updateSelection(next);
1231
+ }, [selectedKeys, disabled, selectedSet, updateSelection]);
1232
+ var handleRemoveSelected = React.useCallback(function (id) {
1233
+ if (disabled) return;
1234
+ var next = selectedKeys.filter(function (v) {
1235
+ return v !== id;
1236
+ });
1237
+ updateSelection(next);
1238
+ }, [selectedKeys, disabled, updateSelection]);
1239
+ var getDisplayValue = function getDisplayValue(field) {
1240
+ if (!field) return '';
1241
+ if (_typeof(field) === 'object') {
1242
+ if (field.label) return field.label;
1243
+ if (field.name) return field.name;
1244
+ return '';
1245
+ }
1246
+ return String(field);
1247
+ };
1248
+ var columns = [{
1249
+ title: '申请单',
1250
+ dataIndex: 'name',
1251
+ key: 'name',
1252
+ ellipsis: true
1253
+ }, {
1254
+ title: '流程',
1255
+ dataIndex: 'flow_name',
1256
+ key: 'flow_name',
1257
+ width: 150,
1258
+ ellipsis: true
1259
+ }, {
1260
+ title: '提交人',
1261
+ key: 'submitter',
1262
+ width: 100,
1263
+ render: function render(_, record) {
1264
+ var _a;
1265
+ return getDisplayValue((_a = record._display) === null || _a === void 0 ? void 0 : _a.submitter) || getDisplayValue(record.submitter);
1266
+ }
1267
+ }, {
1268
+ title: '提交日期',
1269
+ key: 'submit_date',
1270
+ width: 160,
1271
+ render: function render(_, record) {
1272
+ var _a;
1273
+ return getDisplayValue((_a = record._display) === null || _a === void 0 ? void 0 : _a.submit_date) || getDisplayValue(record.submit_date);
1274
+ }
1275
+ }];
1276
+ var selectedTags = selectedKeys.map(function (id) {
1277
+ return {
1278
+ id: id,
1279
+ name: selectedItemsMap[id] || id
1280
+ };
1281
+ });
1282
+ return React__default["default"].createElement("div", {
1283
+ className: cx ? cx('AntdRelatedInstances-Wrapper') : undefined
1284
+ }, selectedTags.length > 0 && React__default["default"].createElement("div", {
1285
+ style: {
1286
+ marginBottom: 8,
1287
+ lineHeight: '28px'
1288
+ }
1289
+ }, React__default["default"].createElement("span", {
1290
+ style: {
1291
+ marginRight: 8,
1292
+ color: '#666',
1293
+ fontSize: 13
1294
+ }
1295
+ }, "\u5DF2\u9009 ", selectedTags.length, " \u9879:"), selectedTags.map(function (item) {
1296
+ return React__default["default"].createElement(antd.Tag, {
1297
+ key: item.id,
1298
+ closable: !disabled,
1299
+ onClose: function onClose() {
1300
+ return handleRemoveSelected(item.id);
1301
+ },
1302
+ style: {
1303
+ marginBottom: 4
1304
+ }
1305
+ }, item.name);
1306
+ })), React__default["default"].createElement(antd.Input.Search, {
1307
+ placeholder: placeholder,
1308
+ allowClear: true,
1309
+ onSearch: handleSearch,
1310
+ onChange: function onChange(e) {
1311
+ return handleSearch(e.target.value);
1312
+ },
1313
+ style: {
1314
+ marginBottom: 8
1315
+ },
1316
+ disabled: disabled
1317
+ }), React__default["default"].createElement(antd.Table, {
1318
+ rowKey: "_id",
1319
+ columns: columns,
1320
+ dataSource: items,
1321
+ loading: loading,
1322
+ size: "small",
1323
+ scroll: {
1324
+ y: 350
1325
+ },
1326
+ locale: {
1327
+ emptyText: '暂无数据'
1328
+ },
1329
+ rowSelection: {
1330
+ selectedRowKeys: selectedKeys,
1331
+ onChange: function onChange(keys) {
1332
+ updateSelection(keys);
1333
+ },
1334
+ getCheckboxProps: function getCheckboxProps() {
1335
+ return {
1336
+ disabled: disabled
1337
+ };
1338
+ }
1339
+ },
1340
+ onRow: function onRow(record) {
1341
+ return {
1342
+ onClick: function onClick() {
1343
+ return handleToggle(record._id);
1344
+ },
1345
+ style: {
1346
+ cursor: disabled ? 'default' : 'pointer'
1347
+ }
1348
+ };
1349
+ },
1350
+ pagination: total > pageSize ? {
1351
+ size: 'small',
1352
+ current: currentPage,
1353
+ pageSize: pageSize,
1354
+ total: total,
1355
+ onChange: handlePageChange,
1356
+ showSizeChanger: false
1357
+ } : false
1358
+ }));
1359
+ };
1360
+ exports.AntdRelatedInstances = AntdRelatedInstances;
739
1361
  exports.AntdSelect = AntdSelect;
740
1362
  exports.Inject = Inject;
741
1363
  exports.LiquidComponent = LiquidComponent;
package/dist/assets.json CHANGED
@@ -31,8 +31,8 @@
31
31
  {
32
32
  "package": "@steedos-widgets/antd",
33
33
  "urls": [
34
- "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.9/dist/antd.umd.js",
35
- "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.9/dist/antd.umd.css"
34
+ "https://unpkg.com/@steedos-widgets/antd@6.10.52/dist/antd.umd.js",
35
+ "https://unpkg.com/@steedos-widgets/antd@6.10.52/dist/antd.umd.css"
36
36
  ],
37
37
  "library": "BuilderAntd"
38
38
  }
@@ -43,10 +43,10 @@
43
43
  "npm": {
44
44
  "package": "@steedos-widgets/antd"
45
45
  },
46
- "url": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.9/dist/meta.js",
46
+ "url": "https://unpkg.com/@steedos-widgets/antd@6.10.52/dist/meta.js",
47
47
  "urls": {
48
- "default": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.9/dist/meta.js",
49
- "design": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.9/dist/meta.js"
48
+ "default": "https://unpkg.com/@steedos-widgets/antd@6.10.52/dist/meta.js",
49
+ "design": "https://unpkg.com/@steedos-widgets/antd@6.10.52/dist/meta.js"
50
50
  }
51
51
  }
52
52
  ]
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface AntdRelatedInstancesProps {
3
+ instanceId?: string;
4
+ value?: any[];
5
+ onChange?: (value: string[]) => void;
6
+ rootUrl?: string;
7
+ tenantId?: string;
8
+ authToken?: string;
9
+ placeholder?: string;
10
+ disabled?: boolean;
11
+ classnames?: (...args: (string | false | null | undefined)[]) => string;
12
+ env?: any;
13
+ data?: any;
14
+ pageSize?: number;
15
+ /** 默认过滤月数,默认6个月 */
16
+ filterMonths?: number;
17
+ }
18
+ declare const AntdRelatedInstances: React.FC<AntdRelatedInstancesProps>;
19
+ export { AntdRelatedInstances };
@@ -1,3 +1,4 @@
1
1
  export * from './Select';
2
2
  export * from './Liquid';
3
3
  export * from './Inject';
4
+ export * from './RelatedInstances';
package/dist/meta.js CHANGED
@@ -39,7 +39,7 @@
39
39
  * @Description: Configuration definition for the Antd Select Amis Custom Component.
40
40
  */
41
41
  // Removed i18next dependency (t function)
42
- var config$2 = {
42
+ var config$3 = {
43
43
  // 1. Base Configuration
44
44
  group: 'General',
45
45
  componentName: "AntdSelect",
@@ -69,44 +69,44 @@
69
69
  icon: "fa-fw fas fa-caret-square-down"
70
70
  }
71
71
  };
72
- var Select = __assign(__assign({}, config$2), {
72
+ var Select = __assign(__assign({}, config$3), {
73
73
  // 3. Snippets Configuration
74
74
  snippets: [
75
75
  {
76
- title: config$2.title,
76
+ title: config$3.title,
77
77
  screenshot: "",
78
78
  schema: {
79
- componentName: config$2.componentName,
80
- props: config$2.preview
79
+ componentName: config$3.componentName,
80
+ props: config$3.preview
81
81
  }
82
82
  }
83
83
  ],
84
84
  // 4. Amis Renderer and Editor Plugin Configuration
85
85
  amis: {
86
86
  render: {
87
- type: config$2.amis.name,
87
+ type: config$3.amis.name,
88
88
  usage: "formitem",
89
89
  weight: 1,
90
90
  framework: "react"
91
91
  },
92
92
  plugin: {
93
- rendererName: config$2.amis.name,
93
+ rendererName: config$3.amis.name,
94
94
  $schema: '/schemas/UnkownSchema.json',
95
- name: config$2.title,
96
- description: config$2.title,
97
- tags: [config$2.group],
95
+ name: config$3.title,
96
+ description: config$3.title,
97
+ tags: [config$3.group],
98
98
  order: -9999,
99
- icon: config$2.amis.icon,
99
+ icon: config$3.amis.icon,
100
100
  scaffold: {
101
- type: config$2.amis.name,
102
- label: config$2.title,
101
+ type: config$3.amis.name,
102
+ label: config$3.title,
103
103
  name: 'select_field',
104
104
  options: [
105
105
  { label: 'Option One', value: 'one' },
106
106
  { label: 'Option Two', value: 'two' },
107
107
  ]
108
108
  },
109
- previewSchema: { type: config$2.amis.name, label: 'Preview', placeholder: 'Please select' },
109
+ previewSchema: { type: config$3.amis.name, label: 'Preview', placeholder: 'Please select' },
110
110
  panelTitle: 'Select Dropdown Settings',
111
111
  // ====== OPTIMIZED PANEL CONTROLS (General & Advanced Tabs) START ======
112
112
  panelControls: [
@@ -229,7 +229,7 @@
229
229
  /*
230
230
  * @Description: Configuration definition for the Liquid Template Amis Custom Component.
231
231
  */
232
- var config$1 = {
232
+ var config$2 = {
233
233
  // 1. Base Configuration
234
234
  group: 'General', // 或者 'Display'
235
235
  componentName: "LiquidComponent",
@@ -256,14 +256,14 @@
256
256
  icon: "fa-fw fas fa-code"
257
257
  }
258
258
  };
259
- var Liquid = __assign(__assign({}, config$1), {
259
+ var Liquid = __assign(__assign({}, config$2), {
260
260
  // 3. Snippets Configuration (拖拽组件时的默认代码片段)
261
261
  snippets: [
262
262
  {
263
- title: config$1.title,
263
+ title: config$2.title,
264
264
  screenshot: "",
265
265
  schema: {
266
- type: config$1.amis.name,
266
+ type: config$2.amis.name,
267
267
  template: "<div>\n <h3>{{title}}</h3>\n <p>User: {{user.name}}</p>\n</div>",
268
268
  data: {
269
269
  title: "Demo",
@@ -275,19 +275,19 @@
275
275
  // 4. Amis Renderer and Editor Plugin Configuration
276
276
  amis: {
277
277
  render: {
278
- type: config$1.amis.name,
278
+ type: config$2.amis.name,
279
279
  usage: "renderer", // 这是一个展示型组件,不是表单项,所以用 renderer
280
280
  weight: 1,
281
281
  framework: "react"
282
282
  },
283
283
  plugin: {
284
- rendererName: config$1.amis.name,
284
+ rendererName: config$2.amis.name,
285
285
  $schema: '/schemas/UnkownSchema.json',
286
- name: config$1.title,
286
+ name: config$2.title,
287
287
  description: "Render HTML using LiquidJS template engine",
288
- tags: [config$1.group],
288
+ tags: [config$2.group],
289
289
  order: 99,
290
- icon: config$1.amis.icon,
290
+ icon: config$2.amis.icon,
291
291
  // 容器类组件必需字段
292
292
  regions: [
293
293
  {
@@ -297,11 +297,11 @@
297
297
  },
298
298
  ],
299
299
  scaffold: {
300
- type: config$1.amis.name,
300
+ type: config$2.amis.name,
301
301
  template: "Hello {{name}}",
302
302
  },
303
303
  previewSchema: {
304
- type: config$1.amis.name,
304
+ type: config$2.amis.name,
305
305
  template: "Preview: {{text}}",
306
306
  },
307
307
  panelTitle: 'Liquid Settings',
@@ -360,7 +360,7 @@
360
360
  * @Description: Configuration definition for the Antd Select Amis Custom Component.
361
361
  */
362
362
  // Removed i18next dependency (t function)
363
- var config = {
363
+ var config$1 = {
364
364
  // 1. Base Configuration
365
365
  group: 'General',
366
366
  componentName: "Inject",
@@ -383,35 +383,102 @@
383
383
  icon: "fa-fw fas fa-caret-square-down"
384
384
  }
385
385
  };
386
- var Inject = __assign(__assign({}, config), {
386
+ var Inject = __assign(__assign({}, config$1), {
387
387
  // 3. Snippets Configuration
388
388
  snippets: [
389
389
  {
390
- title: config.title,
390
+ title: config$1.title,
391
391
  screenshot: "",
392
392
  schema: {
393
- componentName: config.componentName,
394
- props: config.preview
393
+ componentName: config$1.componentName,
394
+ props: config$1.preview
395
395
  }
396
396
  }
397
397
  ],
398
398
  // 4. Amis Renderer and Editor Plugin Configuration
399
399
  amis: {
400
400
  render: {
401
- type: config.amis.name,
401
+ type: config$1.amis.name,
402
402
  usage: "renderer",
403
403
  weight: 1,
404
404
  framework: "react"
405
405
  },
406
+ plugin: {
407
+ rendererName: config$1.amis.name,
408
+ $schema: '/schemas/UnkownSchema.json',
409
+ name: config$1.title,
410
+ description: "Inject css or js into the page head",
411
+ tags: [config$1.group],
412
+ order: 99,
413
+ icon: config$1.amis.icon,
414
+ panelTitle: 'Inject Settings',
415
+ }
416
+ } });
417
+
418
+ var config = {
419
+ group: 'General',
420
+ componentName: 'AntdRelatedInstances',
421
+ title: 'Related Instances',
422
+ docUrl: '',
423
+ screenshot: '',
424
+ npm: {
425
+ package: '@steedos-widgets/antd',
426
+ version: '{{version}}',
427
+ exportName: 'AntdRelatedInstances',
428
+ main: '',
429
+ destructuring: true,
430
+ subName: '',
431
+ },
432
+ preview: {
433
+ placeholder: 'Please select',
434
+ },
435
+ targets: ['steedos__RecordPage', 'steedos__AppPage', 'steedos__HomePage'],
436
+ engines: ['amis'],
437
+ amis: {
438
+ name: 'antd-related-instances',
439
+ icon: 'fa-fw fas fa-sitemap',
440
+ },
441
+ };
442
+ var RelatedInstances = __assign(__assign({}, config), { snippets: [
443
+ {
444
+ title: config.title,
445
+ screenshot: '',
446
+ schema: {
447
+ componentName: config.componentName,
448
+ props: config.preview,
449
+ },
450
+ },
451
+ ], amis: {
452
+ render: {
453
+ type: config.amis.name,
454
+ usage: 'formitem',
455
+ weight: 1,
456
+ framework: 'react',
457
+ },
406
458
  plugin: {
407
459
  rendererName: config.amis.name,
408
460
  $schema: '/schemas/UnkownSchema.json',
409
461
  name: config.title,
410
- description: "Inject css or js into the page head",
462
+ description: config.title,
411
463
  tags: [config.group],
412
- order: 99,
464
+ order: -9999,
413
465
  icon: config.amis.icon,
414
- }
466
+ scaffold: {
467
+ type: config.amis.name,
468
+ label: config.title,
469
+ name: 'related_instances',
470
+ },
471
+ previewSchema: { type: config.amis.name, label: 'Preview', placeholder: 'Please select' },
472
+ panelTitle: 'Related Instances Settings',
473
+ panelControls: [
474
+ {
475
+ type: 'input-text',
476
+ name: 'placeholder',
477
+ label: 'Placeholder',
478
+ value: 'Please select',
479
+ },
480
+ ],
481
+ },
415
482
  } });
416
483
 
417
484
  /*
@@ -421,7 +488,7 @@
421
488
  * @LastEditTime: 2022-09-01 18:46:29
422
489
  * @Description:
423
490
  */
424
- var components = [Select, Liquid, Inject];
491
+ var components = [Select, Liquid, Inject, RelatedInstances];
425
492
  var meta = {
426
493
  components: components
427
494
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface AntdRelatedInstancesProps {
3
+ instanceId?: string;
4
+ value?: any[];
5
+ onChange?: (value: string[]) => void;
6
+ rootUrl?: string;
7
+ tenantId?: string;
8
+ authToken?: string;
9
+ placeholder?: string;
10
+ disabled?: boolean;
11
+ classnames?: (...args: (string | false | null | undefined)[]) => string;
12
+ env?: any;
13
+ data?: any;
14
+ pageSize?: number;
15
+ /** 默认过滤月数,默认6个月 */
16
+ filterMonths?: number;
17
+ }
18
+ declare const AntdRelatedInstances: React.FC<AntdRelatedInstancesProps>;
19
+ export { AntdRelatedInstances };
@@ -1,3 +1,4 @@
1
1
  export * from './Select';
2
2
  export * from './Liquid';
3
3
  export * from './Inject';
4
+ export * from './RelatedInstances';
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@steedos-widgets/antd",
3
3
  "private": false,
4
- "version": "6.10.52-beta.9",
4
+ "version": "6.10.52",
5
5
  "main": "dist/antd.cjs.js",
6
6
  "module": "dist/antd.esm.js",
7
7
  "unpkg": "dist/antd.umd.js",
@@ -25,11 +25,13 @@
25
25
  "@rollup/plugin-commonjs": "^29.0.0",
26
26
  "@rollup/plugin-node-resolve": "^13.1.3",
27
27
  "@rollup/plugin-typescript": "^8.4.0",
28
+ "@types/lodash": "^4.17.23",
28
29
  "@types/react": "^18.0.8",
29
30
  "@types/react-dom": "^18.0.6",
30
31
  "antd": "^5.29.2",
31
32
  "react": "18.2.0",
32
33
  "react-dom": "18.2.0",
34
+ "rimraf": "^6.1.2",
33
35
  "rollup": "^2.79.2",
34
36
  "rollup-plugin-alias": "^2.2.0",
35
37
  "rollup-plugin-external-globals": "^0.6.1",
@@ -45,10 +47,12 @@
45
47
  "rollup-plugin-svg": "^2.0.0",
46
48
  "rollup-plugin-terser": "^7.0.2",
47
49
  "rollup-plugin-tslib-resolve-id": "^0.0.0",
48
- "rollup-plugin-visualizer": "^5.8.0"
50
+ "rollup-plugin-visualizer": "^5.8.0",
51
+ "typescript": "^5.9.3"
49
52
  },
50
- "gitHead": "44a447ece3877e28b67139fe5b16b1cf6c4fdd9f",
53
+ "gitHead": "0a3d2f5bbccf37a3e1e1b62e704cca2ffa044f61",
51
54
  "dependencies": {
52
- "liquidjs": "^10.24.0"
55
+ "liquidjs": "^10.24.0",
56
+ "lodash": "^4.17.23"
53
57
  }
54
58
  }