@steedos-widgets/antd 6.10.47 → 6.10.49

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
@@ -306,23 +306,27 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
306
306
  };
307
307
  // --- 组件实现 ---
308
308
  var LiquidComponent = function LiquidComponent(_a) {
309
+ var _b;
309
310
  var template = _a.template,
310
311
  tpl = _a.tpl,
311
312
  data = _a.data,
312
313
  className = _a.className,
313
314
  $schema = _a.$schema,
314
315
  amisRender = _a.render,
316
+ dispatchEvent = _a.dispatchEvent,
315
317
  propsPartials = _a.partials;
318
+ __rest(_a, ["template", "tpl", "data", "className", "$schema", "render", "dispatchEvent", "partials"]);
319
+ var doAction = (_b = data._scoped) === null || _b === void 0 ? void 0 : _b.doAction;
316
320
  // 支持 tpl 作为 template 的别名
317
321
  if (tpl && !template) {
318
322
  template = tpl;
319
323
  }
320
- var _b = __read(React.useState(''), 2),
321
- html = _b[0],
322
- setHtml = _b[1];
323
- var _c = __read(React.useState({}), 2),
324
- mountNodes = _c[0],
325
- setMountNodes = _c[1];
324
+ var _c = __read(React.useState(''), 2),
325
+ html = _c[0],
326
+ setHtml = _c[1];
327
+ var _d = __read(React.useState({}), 2),
328
+ mountNodes = _d[0],
329
+ setMountNodes = _d[1];
326
330
  var containerRef = React.useRef(null);
327
331
  // 用于存储脚本清理函数的引用,以便在组件卸载或更新时清理副作用
328
332
  var scriptCleanupsRef = React.useRef([]);
@@ -554,8 +558,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
554
558
  try {
555
559
  var debugName = "steedos-liquid-".concat(Math.random().toString(36).slice(2), ".js");
556
560
  var debuggableCode = code + "\n//# sourceURL=".concat(debugName);
557
- var func = new Function('data', 'dom', debuggableCode);
558
- var cleanupResult = func(data, scriptNode.parentElement);
561
+ var func = new Function('data', 'dom', 'doAction', 'dispatchEvent', debuggableCode);
562
+ var cleanupResult = func(data, scriptNode.parentElement, doAction, dispatchEvent);
559
563
  if (typeof cleanupResult === 'function') {
560
564
  scriptCleanupsRef.current.push(cleanupResult);
561
565
  }
@@ -578,16 +582,106 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
578
582
  });
579
583
  };
580
584
  }, [html, dataFingerprint]);
581
- return React__default["default"].createElement("div", {
582
- className: "liquid-amis-container ".concat(className || ''),
583
- ref: containerRef
584
- }, React__default["default"].createElement("div", {
585
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", {
586
+ className: "liquid-amis-container flex flex-col h-full w-full overflow-hidden ".concat(className || ''),
587
+ ref: containerRef,
585
588
  dangerouslySetInnerHTML: {
586
589
  __html: html
587
590
  }
588
591
  }), portals);
589
592
  };
593
+ var Inject = function Inject(props) {
594
+ var _a = props.assets,
595
+ assets = _a === void 0 ? [] : _a,
596
+ body = props.body,
597
+ render = props.render,
598
+ children = props.children;
599
+ // 排除不需要透传的属性
600
+ props.className;
601
+ props.classnames;
602
+ props.env;
603
+ props.scope;
604
+ __rest(props, ["assets", "body", "render", "children", "className", "classnames", "env", "scope"]);
605
+ React.useEffect(function () {
606
+ // 记录本次渲染创建的所有 tag ID,以便卸载时清理
607
+ // 如果用户没传 ID,我们生成临时的,但建议用户传 ID
608
+ var mountedIds = [];
609
+ var injectOne = function injectOne(item, index) {
610
+ var type = item.type,
611
+ src = item.src,
612
+ content = item.content,
613
+ _a = item.location,
614
+ location = _a === void 0 ? 'start' : _a;
615
+ // 如果没有 id,生成一个临时的(注意:这种临时 ID 在组件更新时可能会导致资源重新加载)
616
+ var id = item.id || "amis-inject-".concat(type, "-").concat(index, "-").concat(Date.now());
617
+ mountedIds.push(id);
618
+ // 1. 清理旧资源 (避免重复或更新内容)
619
+ var oldElement = document.getElementById(id);
620
+ if (oldElement) {
621
+ oldElement.remove();
622
+ }
623
+ // 2. 创建 DOM 节点
624
+ var newTag = null;
625
+ if (type === 'css') {
626
+ // --- CSS 处理 ---
627
+ if (src) {
628
+ var link = document.createElement('link');
629
+ link.id = id;
630
+ link.rel = 'stylesheet';
631
+ link.type = 'text/css';
632
+ link.href = src;
633
+ newTag = link;
634
+ } else if (content) {
635
+ var style = document.createElement('style');
636
+ style.id = id;
637
+ style.type = 'text/css';
638
+ style.appendChild(document.createTextNode(content));
639
+ newTag = style;
640
+ }
641
+ } else if (type === 'js') {
642
+ // --- JS 处理 ---
643
+ var script = document.createElement('script');
644
+ script.id = id;
645
+ script.type = 'text/javascript';
646
+ if (src) {
647
+ script.src = src;
648
+ script.async = false; // 保持按顺序执行
649
+ } else if (content) {
650
+ script.text = content;
651
+ }
652
+ newTag = script;
653
+ }
654
+ // 3. 挂载节点
655
+ // CSS 始终挂载到 head
656
+ // JS 通常也可以挂载到 head,或者 body (这里为了统一管理,默认操作 head,如需 body 可自行扩展逻辑)
657
+ if (newTag) {
658
+ if (location === 'end') {
659
+ document.head.appendChild(newTag);
660
+ } else {
661
+ document.head.prepend(newTag);
662
+ }
663
+ }
664
+ };
665
+ // 批量执行注入
666
+ if (Array.isArray(assets)) {
667
+ assets.forEach(function (asset, index) {
668
+ return injectOne(asset, index);
669
+ });
670
+ }
671
+ // 4. 组件卸载时的清理函数
672
+ return function () {
673
+ mountedIds.forEach(function (id) {
674
+ var el = document.getElementById(id);
675
+ if (el) el.remove();
676
+ });
677
+ };
678
+ }, [JSON.stringify(assets)]); // 使用 JSON.stringify 深度监听数组变化
679
+ // --- 渲染子组件 (无外层 DIV) ---
680
+ if (!body) return null;
681
+ return React__default["default"].createElement(React__default["default"].Fragment, null, children, render('body', body, {}));
682
+ };
590
683
  exports.AntdSelect = AntdSelect;
684
+ exports.Inject = Inject;
591
685
  exports.LiquidComponent = LiquidComponent;
592
686
  Object.defineProperty(exports, '__esModule', {
593
687
  value: true
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.47/dist/antd.umd.js",
35
- "https://unpkg.com/@steedos-widgets/antd@6.10.47/dist/antd.umd.css"
34
+ "https://unpkg.com/@steedos-widgets/antd@6.10.49/dist/antd.umd.js",
35
+ "https://unpkg.com/@steedos-widgets/antd@6.10.49/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.47/dist/meta.js",
46
+ "url": "https://unpkg.com/@steedos-widgets/antd@6.10.49/dist/meta.js",
47
47
  "urls": {
48
- "default": "https://unpkg.com/@steedos-widgets/antd@6.10.47/dist/meta.js",
49
- "design": "https://unpkg.com/@steedos-widgets/antd@6.10.47/dist/meta.js"
48
+ "default": "https://unpkg.com/@steedos-widgets/antd@6.10.49/dist/meta.js",
49
+ "design": "https://unpkg.com/@steedos-widgets/antd@6.10.49/dist/meta.js"
50
50
  }
51
51
  }
52
52
  ]
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export type AssetType = 'css' | 'js';
3
+ export type AssetLocation = 'start' | 'end';
4
+ export interface AssetItem {
5
+ type: AssetType;
6
+ id?: string;
7
+ src?: string;
8
+ content?: string;
9
+ location?: AssetLocation;
10
+ }
11
+ interface InjectProps extends React.ComponentProps<any> {
12
+ assets?: AssetItem[];
13
+ body?: any;
14
+ render: (region: string, schema: any, props?: any) => React.ReactNode;
15
+ }
16
+ declare const Inject: React.FC<InjectProps>;
17
+ export { Inject };
@@ -7,6 +7,7 @@ interface LiquidTemplateProps {
7
7
  $schema?: Record<string, string | object>;
8
8
  partials?: Record<string, string | object>;
9
9
  className?: string;
10
+ dispatchEvent: any;
10
11
  render: (region: string, schema: SchemaObject, props?: any) => React.ReactNode;
11
12
  }
12
13
  export declare const LiquidComponent: React.FC<LiquidTemplateProps>;
@@ -1,2 +1,3 @@
1
1
  export * from './Select';
2
2
  export * from './Liquid';
3
+ export * from './Inject';
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$1 = {
42
+ var config$2 = {
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$1), {
72
+ var Select = __assign(__assign({}, config$2), {
73
73
  // 3. Snippets Configuration
74
74
  snippets: [
75
75
  {
76
- title: config$1.title,
76
+ title: config$2.title,
77
77
  screenshot: "",
78
78
  schema: {
79
- componentName: config$1.componentName,
80
- props: config$1.preview
79
+ componentName: config$2.componentName,
80
+ props: config$2.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$1.amis.name,
87
+ type: config$2.amis.name,
88
88
  usage: "formitem",
89
89
  weight: 1,
90
90
  framework: "react"
91
91
  },
92
92
  plugin: {
93
- rendererName: config$1.amis.name,
93
+ rendererName: config$2.amis.name,
94
94
  $schema: '/schemas/UnkownSchema.json',
95
- name: config$1.title,
96
- description: config$1.title,
97
- tags: [config$1.group],
95
+ name: config$2.title,
96
+ description: config$2.title,
97
+ tags: [config$2.group],
98
98
  order: -9999,
99
- icon: config$1.amis.icon,
99
+ icon: config$2.amis.icon,
100
100
  scaffold: {
101
- type: config$1.amis.name,
102
- label: config$1.title,
101
+ type: config$2.amis.name,
102
+ label: config$2.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$1.amis.name, label: 'Preview', placeholder: 'Please select' },
109
+ previewSchema: { type: config$2.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 = {
232
+ var config$1 = {
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), {
259
+ var Liquid = __assign(__assign({}, config$1), {
260
260
  // 3. Snippets Configuration (拖拽组件时的默认代码片段)
261
261
  snippets: [
262
262
  {
263
- title: config.title,
263
+ title: config$1.title,
264
264
  screenshot: "",
265
265
  schema: {
266
- type: config.amis.name,
266
+ type: config$1.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.amis.name,
278
+ type: config$1.amis.name,
279
279
  usage: "renderer", // 这是一个展示型组件,不是表单项,所以用 renderer
280
280
  weight: 1,
281
281
  framework: "react"
282
282
  },
283
283
  plugin: {
284
- rendererName: config.amis.name,
284
+ rendererName: config$1.amis.name,
285
285
  $schema: '/schemas/UnkownSchema.json',
286
- name: config.title,
286
+ name: config$1.title,
287
287
  description: "Render HTML using LiquidJS template engine",
288
- tags: [config.group],
288
+ tags: [config$1.group],
289
289
  order: 99,
290
- icon: config.amis.icon,
290
+ icon: config$1.amis.icon,
291
291
  // 容器类组件必需字段
292
292
  regions: [
293
293
  {
@@ -297,11 +297,11 @@
297
297
  },
298
298
  ],
299
299
  scaffold: {
300
- type: config.amis.name,
300
+ type: config$1.amis.name,
301
301
  template: "Hello {{name}}",
302
302
  },
303
303
  previewSchema: {
304
- type: config.amis.name,
304
+ type: config$1.amis.name,
305
305
  template: "Preview: {{text}}",
306
306
  },
307
307
  panelTitle: 'Liquid Settings',
@@ -356,6 +356,64 @@
356
356
  }
357
357
  } });
358
358
 
359
+ /*
360
+ * @Description: Configuration definition for the Antd Select Amis Custom Component.
361
+ */
362
+ // Removed i18next dependency (t function)
363
+ var config = {
364
+ // 1. Base Configuration
365
+ group: 'General',
366
+ componentName: "Inject",
367
+ title: 'Inject',
368
+ docUrl: "",
369
+ screenshot: "",
370
+ npm: {
371
+ package: "@steedos-widgets/antd",
372
+ version: "{{version}}",
373
+ exportName: "Inject",
374
+ main: "",
375
+ destructuring: true,
376
+ subName: ""
377
+ },
378
+ targets: ["steedos__RecordPage", "steedos__AppPage", "steedos__HomePage"],
379
+ engines: ["amis"],
380
+ // 2. Amis Core Configuration
381
+ amis: {
382
+ name: 'inject',
383
+ icon: "fa-fw fas fa-caret-square-down"
384
+ }
385
+ };
386
+ var Inject = __assign(__assign({}, config), {
387
+ // 3. Snippets Configuration
388
+ snippets: [
389
+ {
390
+ title: config.title,
391
+ screenshot: "",
392
+ schema: {
393
+ componentName: config.componentName,
394
+ props: config.preview
395
+ }
396
+ }
397
+ ],
398
+ // 4. Amis Renderer and Editor Plugin Configuration
399
+ amis: {
400
+ render: {
401
+ type: config.amis.name,
402
+ usage: "renderer",
403
+ weight: 1,
404
+ framework: "react"
405
+ },
406
+ plugin: {
407
+ rendererName: config.amis.name,
408
+ $schema: '/schemas/UnkownSchema.json',
409
+ name: config.title,
410
+ description: "Inject css or js into the page head",
411
+ tags: [config.group],
412
+ order: 99,
413
+ icon: config.amis.icon,
414
+ }
415
+ } });
416
+
359
417
  /*
360
418
  * @Author: baozhoutao@steedos.com
361
419
  * @Date: 2022-08-31 16:32:35
@@ -363,7 +421,7 @@
363
421
  * @LastEditTime: 2022-09-01 18:46:29
364
422
  * @Description:
365
423
  */
366
- var components = [Select, Liquid];
424
+ var components = [Select, Liquid, Inject];
367
425
  var meta = {
368
426
  components: components
369
427
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export type AssetType = 'css' | 'js';
3
+ export type AssetLocation = 'start' | 'end';
4
+ export interface AssetItem {
5
+ type: AssetType;
6
+ id?: string;
7
+ src?: string;
8
+ content?: string;
9
+ location?: AssetLocation;
10
+ }
11
+ interface InjectProps extends React.ComponentProps<any> {
12
+ assets?: AssetItem[];
13
+ body?: any;
14
+ render: (region: string, schema: any, props?: any) => React.ReactNode;
15
+ }
16
+ declare const Inject: React.FC<InjectProps>;
17
+ export { Inject };
@@ -7,6 +7,7 @@ interface LiquidTemplateProps {
7
7
  $schema?: Record<string, string | object>;
8
8
  partials?: Record<string, string | object>;
9
9
  className?: string;
10
+ dispatchEvent: any;
10
11
  render: (region: string, schema: SchemaObject, props?: any) => React.ReactNode;
11
12
  }
12
13
  export declare const LiquidComponent: React.FC<LiquidTemplateProps>;
@@ -1,2 +1,3 @@
1
1
  export * from './Select';
2
2
  export * from './Liquid';
3
+ export * from './Inject';
@@ -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.47",
4
+ "version": "6.10.49",
5
5
  "main": "dist/antd.cjs.js",
6
6
  "module": "dist/antd.esm.js",
7
7
  "unpkg": "dist/antd.umd.js",
@@ -47,7 +47,7 @@
47
47
  "rollup-plugin-tslib-resolve-id": "^0.0.0",
48
48
  "rollup-plugin-visualizer": "^5.8.0"
49
49
  },
50
- "gitHead": "77e89d92cc0eed66fb50098dac63845633b1adbb",
50
+ "gitHead": "bd807f3646ba16317416ef5a445f74d6c9bba34a",
51
51
  "dependencies": {
52
52
  "liquidjs": "^10.24.0"
53
53
  }