@nocobase/app 2.1.0-beta.42 → 2.1.0-beta.43

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.
Files changed (104) hide show
  1. package/dist/client/assets/1507-be1bb59f.js +7 -0
  2. package/dist/client/assets/2702-2229ffce.js +5 -0
  3. package/dist/client/assets/3475-c853dcfb.js +1 -0
  4. package/dist/client/assets/3660-ae135b62.js +6 -0
  5. package/dist/client/assets/3916-03cc08e1.js +6 -0
  6. package/dist/client/assets/4687-cb88a94b.js +1 -0
  7. package/dist/client/assets/6269-d8f21ee9.js +1 -0
  8. package/dist/client/assets/{index-d8e97233.js → index-4951d7f9.js} +256 -256
  9. package/dist/client/assets/runtime-6964d231.js +1 -0
  10. package/dist/client/index.html +1 -1
  11. package/dist/client/index.html.tpl +1 -1
  12. package/dist/client/v2/assets/1310-c0031389.js +59 -0
  13. package/dist/client/v2/assets/1425-69534606.js +42 -0
  14. package/dist/client/v2/assets/1507-9a211af0.js +7 -0
  15. package/dist/client/v2/assets/158-5273dfbb.js +23 -0
  16. package/dist/client/v2/assets/1725-d9ce2582.js +83 -0
  17. package/dist/client/v2/assets/1786-e6c321bb.js +16 -0
  18. package/dist/client/v2/assets/1951-84be8ebc.js +55 -0
  19. package/dist/client/v2/assets/2017-29a9879a.js +26 -0
  20. package/dist/client/v2/assets/212-0f8a26a2.js +18 -0
  21. package/dist/client/v2/assets/2335-669f21bd.js +22 -0
  22. package/dist/client/v2/assets/2555-4ca49e21.js +31 -0
  23. package/dist/client/v2/assets/2702-5ce93acd.js +5 -0
  24. package/dist/client/v2/assets/2710-e7286996.js +36 -0
  25. package/dist/client/v2/assets/2726-4d19faa1.js +23 -0
  26. package/dist/client/v2/assets/2898-7656f7f9.js +17 -0
  27. package/dist/client/v2/assets/2958-93de29a6.js +27 -0
  28. package/dist/client/v2/assets/3117-cc936eae.js +33 -0
  29. package/dist/client/v2/assets/3475-be655098.js +1 -0
  30. package/dist/client/v2/assets/3660-280439df.js +6 -0
  31. package/dist/client/v2/assets/3662-8dff1ffe.js +28 -0
  32. package/dist/client/v2/assets/3727-1cfef422.js +44 -0
  33. package/dist/client/v2/assets/3916-3b34f216.js +6 -0
  34. package/dist/client/v2/assets/3989-c8fcfd6c.js +27 -0
  35. package/dist/client/v2/assets/4313-ab774fd9.js +28 -0
  36. package/dist/client/v2/assets/5501-387a31be.js +17 -0
  37. package/dist/client/v2/assets/5721-af25e047.js +18 -0
  38. package/dist/client/v2/assets/5759-2b3bdcc6.js +47 -0
  39. package/dist/client/v2/assets/5761-857b6bbb.js +28 -0
  40. package/dist/client/v2/assets/6269-a8a1ea3f.js +1 -0
  41. package/dist/client/v2/assets/6437-3865fd7e.js +12 -0
  42. package/dist/client/v2/assets/6738-c6598897.js +20 -0
  43. package/dist/client/v2/assets/700-e75b7faa.js +15 -0
  44. package/dist/client/v2/assets/7021-4975d54d.js +45 -0
  45. package/dist/client/v2/assets/7201-5b49ce84.js +14 -0
  46. package/dist/client/v2/assets/7959-f7ef21c6.js +40 -0
  47. package/dist/client/v2/assets/8138-e90c290e.js +24 -0
  48. package/dist/client/v2/assets/8434-9140d106.js +25 -0
  49. package/dist/client/v2/assets/8438-d2ff6bc1.js +37 -0
  50. package/dist/client/v2/assets/8562-ffa35312.js +17 -0
  51. package/dist/client/v2/assets/9836-fcbb81f6.js +22 -0
  52. package/dist/client/v2/assets/{index-48dce4e9.js → index-fa6a31c0.js} +115 -115
  53. package/dist/client/v2/assets/{runtime-0629701e.js → runtime-afd2b4ee.js} +1 -1
  54. package/dist/client/v2/index.html +1 -1
  55. package/package.json +7 -7
  56. package/dist/client/assets/1507-bfaf088d.js +0 -7
  57. package/dist/client/assets/2702-448a397f.js +0 -5
  58. package/dist/client/assets/3475-9e7a0395.js +0 -1
  59. package/dist/client/assets/3660-fdea8689.js +0 -6
  60. package/dist/client/assets/3916-a8888466.js +0 -6
  61. package/dist/client/assets/6269-5467af50.js +0 -1
  62. package/dist/client/assets/runtime-1dde2b80.js +0 -1
  63. package/dist/client/v2/assets/1310-21e5c8a8.js +0 -59
  64. package/dist/client/v2/assets/1425-a2b446a6.js +0 -42
  65. package/dist/client/v2/assets/1507-a673a0c0.js +0 -7
  66. package/dist/client/v2/assets/158-6a033567.js +0 -23
  67. package/dist/client/v2/assets/1725-6f5b8d53.js +0 -83
  68. package/dist/client/v2/assets/1786-8969223a.js +0 -16
  69. package/dist/client/v2/assets/1951-f63bc4b3.js +0 -55
  70. package/dist/client/v2/assets/2017-b35f125d.js +0 -26
  71. package/dist/client/v2/assets/212-59d29e60.js +0 -18
  72. package/dist/client/v2/assets/2335-1d33c3cf.js +0 -22
  73. package/dist/client/v2/assets/2555-dee484a1.js +0 -31
  74. package/dist/client/v2/assets/2702-8d5ab2a8.js +0 -5
  75. package/dist/client/v2/assets/2710-93d67bf0.js +0 -36
  76. package/dist/client/v2/assets/2726-f6cc5db9.js +0 -23
  77. package/dist/client/v2/assets/2898-2a7d5793.js +0 -17
  78. package/dist/client/v2/assets/2958-5a85effa.js +0 -27
  79. package/dist/client/v2/assets/3117-3d38bb4d.js +0 -33
  80. package/dist/client/v2/assets/3475-c42974e1.js +0 -1
  81. package/dist/client/v2/assets/3660-27f9c6c5.js +0 -6
  82. package/dist/client/v2/assets/3662-135bbea1.js +0 -28
  83. package/dist/client/v2/assets/3727-b74fc29b.js +0 -44
  84. package/dist/client/v2/assets/3916-ba5b43b5.js +0 -6
  85. package/dist/client/v2/assets/3989-e72345bb.js +0 -27
  86. package/dist/client/v2/assets/4313-9687f912.js +0 -28
  87. package/dist/client/v2/assets/5501-a3b5b97f.js +0 -17
  88. package/dist/client/v2/assets/5721-f00ddbf2.js +0 -18
  89. package/dist/client/v2/assets/5759-d5b1d946.js +0 -47
  90. package/dist/client/v2/assets/5761-8ab1974d.js +0 -28
  91. package/dist/client/v2/assets/6269-35e90156.js +0 -1
  92. package/dist/client/v2/assets/6437-2f91d29a.js +0 -12
  93. package/dist/client/v2/assets/6738-eb09fa59.js +0 -20
  94. package/dist/client/v2/assets/700-5f166286.js +0 -15
  95. package/dist/client/v2/assets/7021-01608dc5.js +0 -45
  96. package/dist/client/v2/assets/7201-8e6e91a3.js +0 -14
  97. package/dist/client/v2/assets/7959-ab57fce2.js +0 -40
  98. package/dist/client/v2/assets/8138-704104a5.js +0 -24
  99. package/dist/client/v2/assets/8434-79232eec.js +0 -25
  100. package/dist/client/v2/assets/8438-9d210970.js +0 -37
  101. package/dist/client/v2/assets/8562-215edc37.js +0 -17
  102. package/dist/client/v2/assets/9836-288424d8.js +0 -22
  103. /package/dist/client/assets/{index-d8e97233.js.LICENSE.txt → index-4951d7f9.js.LICENSE.txt} +0 -0
  104. /package/dist/client/v2/assets/{index-48dce4e9.js.LICENSE.txt → index-fa6a31c0.js.LICENSE.txt} +0 -0
@@ -0,0 +1,47 @@
1
+ export const __rspack_esm_id="5759";export const __rspack_esm_ids=["5759"];export const __webpack_modules__={25831(e,t,n){n.r(t),n.d(t,{FormJSFieldItemRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"FormJSFieldItem RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for form field rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:"Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).",record:`Current record data object (read-only).
3
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
+ Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
+ Example: ctx.setProps(fieldModel, { value: "new value" })`}}),o.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表单字段容器"),value:"字段值(展示模式为只读;受控场景用 setProps 修改)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪回调",setProps:"设置表单项属性:`setProps(fieldModel, { value })`(由联动/表单上下文提供)"}},{locale:"zh-CN"})},98542(e,t,n){n.r(t),n.d(t,{JSFieldRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"JSField RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for field rendering.
7
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:`Current value of the field (read-only).
8
+ Contains the data value stored in this field.`,record:`Current record data object (read-only).
9
+ Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
10
+ Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
11
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
12
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),o.define({label:"JS 字段 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作"),value:"字段当前值(只读)",record:"当前记录对象(只读,包含父记录全部字段值)",collection:"集合定义元数据(只读,描述字段所属集合的 Schema)"},methods:{onRefReady:"在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},73330(e,t,n){n.r(t),n.d(t,{default:()=>o});var i=n(98542),r=n(25831);let o={contexts:[i.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext],prefix:"sn-jsf-percent",label:"Display number field as percentage bar",description:"Render numeric values as a percentage progress bar",locales:{"zh-CN":{label:"将数字字段显示为百分比进度条",description:"将数字格式化为百分比并显示进度条"}},content:`
13
+ const value = Number(ctx.value ?? 0);
14
+
15
+ if (!Number.isFinite(value)) {
16
+ ctx.render('-');
17
+ return;
18
+ }
19
+
20
+ // Ensure value is between 0 and 100
21
+ const percent = Math.max(0, Math.min(100, value));
22
+
23
+ // Color based on value
24
+ const getColor = (val) => {
25
+ if (val >= 80) return '#52c41a';
26
+ if (val >= 50) return '#faad14';
27
+ return '#f5222d';
28
+ };
29
+
30
+ const color = getColor(percent);
31
+
32
+ ctx.render(\`
33
+ <div style="display: flex; align-items: center; gap: 8px;">
34
+ <div style="flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden;">
35
+ <div style="
36
+ width: \${percent}%;
37
+ height: 100%;
38
+ background: \${color};
39
+ transition: width 0.3s ease;
40
+ "></div>
41
+ </div>
42
+ <span style="color: \${color}; font-weight: 500; min-width: 45px; text-align: right;">
43
+ \${percent.toFixed(1)}%
44
+ </span>
45
+ </div>
46
+ \`);
47
+ `}}};
@@ -0,0 +1,28 @@
1
+ export const __rspack_esm_id="5761";export const __rspack_esm_ids=["5761"];export const __webpack_modules__={32221(e,t,n){n.r(t),n.d(t,{JSItemRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"JSItem RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for form item rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),resource:`Current resource instance (read-only).
3
+ Provides access to the data resource associated with the current form context.`,record:`Current record data object (read-only).
4
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form item container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`}}),o.define({label:"JS 表单项 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作"),resource:"当前资源(只读)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪后执行回调。参数:(ref, callback, timeout?)"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},30008(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-visibility",label:"Toggle visible",description:"Show or hide another field within linkage scripts",locales:{"zh-CN":{label:"切换可见性",description:"在联动脚本中设置字段显示或隐藏"}},content:`
6
+ const targetFieldUid = 'FIELD_UID_OR_NAME';
7
+ const shouldHide = true;
8
+
9
+ const items = ctx.model?.subModels?.grid?.subModels?.items;
10
+ const candidates = Array.isArray(items)
11
+ ? items
12
+ : Array.from(items?.values?.() || items || []);
13
+ const fieldModel =
14
+ candidates.find((item) => item?.uid === targetFieldUid) ||
15
+ candidates.find((item) => item?.props?.name === targetFieldUid);
16
+
17
+ if (!fieldModel) {
18
+ ctx.message?.warning?.(ctx.t('Field {{name}} not found', { name: targetFieldUid }));
19
+ return;
20
+ }
21
+
22
+ fieldModel.setProps({ hiddenModel: shouldHide });
23
+ ctx.message?.success?.(
24
+ ctx.t(shouldHide ? 'Hidden field {{name}}' : 'Shown field {{name}}', {
25
+ name: fieldModel?.props?.label || targetFieldUid,
26
+ }),
27
+ );
28
+ `}}};
@@ -0,0 +1 @@
1
+ export const __rspack_esm_id="6269";export const __rspack_esm_ids=["6269"];export const __webpack_modules__={96108(e,t,n){n.r(t),n.d(t,{JSColumnRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"JSColumn RunJS context",properties:{element:(0,r.e)("ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs."),record:"Current row record object (read-only).",recordIndex:"Index of the current row in the page (0-based).",collection:"Collection definition metadata (read-only).",viewer:"View controller providing dialog/drawer/embed helpers for interactions initiated from the cell (e.g., open details).",React:"React library",antd:"Ant Design library"},methods:{onRefReady:"Wait for cell DOM element to be ready before executing callback. Parameters: (ref, callback, timeout?) => void",requireAsync:"Load external library by URL: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import ESM module by URL: `const mod = await ctx.importAsync(url)`"}}),o.define({label:"JS 列 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等"),record:"当前行记录对象(只读)",recordIndex:"当前行索引(从 0 开始)",collection:"集合定义元数据(只读)",viewer:"视图控制器,可用于在单元格中触发抽屉/对话框/内嵌等交互",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"等待单元格 DOM 就绪后执行回调。参数:(ref, callback, timeout?)",requireAsync:"按 URL 异步加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}}};
@@ -0,0 +1,12 @@
1
+ export const __rspack_esm_id="6437";export const __rspack_esm_ids=["6437"];export const __webpack_modules__={32221(e,t,n){n.r(t),n.d(t,{JSItemRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"JSItem RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for form item rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),resource:`Current resource instance (read-only).
3
+ Provides access to the data resource associated with the current form context.`,record:`Current record data object (read-only).
4
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form item container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`}}),o.define({label:"JS 表单项 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作"),resource:"当前资源(只读)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪后执行回调。参数:(ref, callback, timeout?)"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},29924(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-jsitem-basic",label:"Render form item",description:"Render custom content inside a form item container",locales:{"zh-CN":{label:"渲染表单项",description:"在表单项容器中渲染自定义内容"}},content:`
6
+ ctx.render(\`
7
+ <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6;">
8
+ <h3 style="color: #1890ff; margin: 0 0 12px 0; font-size: 18px; font-weight: 600;">\${ctx.t('JS Item')}</h3>
9
+ <div style="color:#555">\${ctx.t('This area is rendered by your JavaScript code.')}</div>
10
+ </div>
11
+ \`);
12
+ `}}};
@@ -0,0 +1,20 @@
1
+ export const __rspack_esm_id="6738";export const __rspack_esm_ids=["6738"];export const __webpack_modules__={79271(e,t,n){n.r(t),n.d(t,{JSBlockRunJSContext:()=>o});var r=n(29007),i=n(4418);class o extends r.uk{}o.define({label:"RunJS context",properties:{element:(0,i.e)(`ElementProxy instance providing a safe DOM container.
2
+ Supports innerHTML, append, and other DOM manipulation methods.
3
+ Use this to render content in the JS block.`),record:`Current record data object (read-only).
4
+ Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),o.define({label:"RunJS 上下文",properties:{element:(0,i.V)("ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等"),record:"当前记录(只读,用于数据区块/详情等场景)",value:"当前值(若存在)",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`。\n注意:当模块只有 default 一个导出时,ctx.importAsync 会直接返回 default 值(无需再写 `.default`)。"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let r={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},i={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}},25481(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-resource-example",label:"Resource example",description:"Create a resource via ctx.makeResource and render JSON output",locales:{"zh-CN":{label:"资源示例",description:"使用 ctx.initResource 加载数据并渲染 JSON 输出"}},content:`
7
+ // Create a resource and load a single record
8
+ const resource = ctx.makeResource('SingleRecordResource');
9
+ resource.setDataSourceKey('main');
10
+ resource.setResourceName('users');
11
+ // Optionally set filterByTk to target a specific record:
12
+ // resource.setRequestOptions('params', { filterByTk: 1 });
13
+ await resource.refresh();
14
+
15
+ ctx.render(\`
16
+ <pre style="padding: 12px; background: #f5f5f5; border-radius: 6px;">
17
+ \${JSON.stringify(resource.getData(), null, 2)}
18
+ </pre>
19
+ \`);
20
+ `}}};
@@ -0,0 +1,15 @@
1
+ export const __rspack_esm_id="700";export const __rspack_esm_ids=["700"];export const __webpack_modules__={25831(e,t,n){n.r(t),n.d(t,{FormJSFieldItemRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"FormJSFieldItem RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for form field rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:"Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).",record:`Current record data object (read-only).
3
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
+ Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
+ Example: ctx.setProps(fieldModel, { value: "new value" })`}}),l.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表单字段容器"),value:"字段值(展示模式为只读;受控场景用 setProps 修改)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪回调",setProps:"设置表单项属性:`setProps(fieldModel, { value })`(由联动/表单上下文提供)"}},{locale:"zh-CN"})},98542(e,t,n){n.r(t),n.d(t,{JSFieldRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"JSField RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for field rendering.
7
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:`Current value of the field (read-only).
8
+ Contains the data value stored in this field.`,record:`Current record data object (read-only).
9
+ Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
10
+ Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
11
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
12
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),l.define({label:"JS 字段 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作"),value:"字段当前值(只读)",record:"当前记录对象(只读,包含父记录全部字段值)",collection:"集合定义元数据(只读,描述字段所属集合的 Schema)"},methods:{onRefReady:"在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>o,e:()=>l});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},99287(e,t,n){n.r(t),n.d(t,{default:()=>l});var i=n(98542),r=n(25831);let l={contexts:[i.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext],prefix:"sn-jsf-value",label:"Display text field as highlighted text",description:"Render the current text field value with simple highlight styling",locales:{"zh-CN":{label:"将文本字段显示为高亮文本",description:"将字段值写入容器并添加高亮样式"}},content:`
13
+ const v = String(ctx.value ?? '');
14
+ ctx.render(\`<span class="nb-js-field-value" style="color:#1890ff;font-weight:600">\${v}</span>\`);
15
+ `}}};
@@ -0,0 +1,45 @@
1
+ export const __rspack_esm_id="7021";export const __rspack_esm_ids=["7021"];export const __webpack_modules__={25831(e,t,n){n.r(t),n.d(t,{FormJSFieldItemRunJSContext:()=>i});var o=n(29007),r=n(4418);class i extends o.uk{}i.define({label:"FormJSFieldItem RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for form field rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:"Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).",record:`Current record data object (read-only).
3
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
+ Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
+ Example: ctx.setProps(fieldModel, { value: "new value" })`}}),i.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表单字段容器"),value:"字段值(展示模式为只读;受控场景用 setProps 修改)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪回调",setProps:"设置表单项属性:`setProps(fieldModel, { value })`(由联动/表单上下文提供)"}},{locale:"zh-CN"})},98542(e,t,n){n.r(t),n.d(t,{JSFieldRunJSContext:()=>i});var o=n(29007),r=n(4418);class i extends o.uk{}i.define({label:"JSField RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container for field rendering.
7
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:`Current value of the field (read-only).
8
+ Contains the data value stored in this field.`,record:`Current record data object (read-only).
9
+ Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
10
+ Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
11
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
12
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),i.define({label:"JS 字段 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作"),value:"字段当前值(只读)",record:"当前记录对象(只读,包含父记录全部字段值)",collection:"集合定义元数据(只读,描述字段所属集合的 Schema)"},methods:{onRefReady:"在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>i});let o={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:o}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},37420(e,t,n){n.r(t),n.d(t,{default:()=>i});var o=n(98542),r=n(25831);let i={contexts:[o.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext],prefix:"sn-jsf-relative-time",label:"Display date field as relative time",description:"Render date values as “3 days ago”, “just now”, etc.",locales:{"zh-CN":{label:"将日期字段显示为相对时间",description:"将日期显示为“3天前”、“刚刚”等相对时间"}},content:`
13
+ const formatRelativeTime = (date) => {
14
+ const now = new Date();
15
+ const diff = now - new Date(date);
16
+ const seconds = Math.floor(diff / 1000);
17
+ const minutes = Math.floor(seconds / 60);
18
+ const hours = Math.floor(minutes / 60);
19
+ const days = Math.floor(hours / 24);
20
+ const months = Math.floor(days / 30);
21
+ const years = Math.floor(days / 365);
22
+
23
+ if (seconds < 60) return ctx.t('just now');
24
+ if (minutes < 60) return ctx.t('{{count}} minutes ago', { count: minutes });
25
+ if (hours < 24) return ctx.t('{{count}} hours ago', { count: hours });
26
+ if (days < 30) return ctx.t('{{count}} days ago', { count: days });
27
+ if (months < 12) return ctx.t('{{count}} months ago', { count: months });
28
+ return ctx.t('{{count}} years ago', { count: years });
29
+ };
30
+
31
+ const dateStr = ctx.value;
32
+ if (!dateStr) {
33
+ ctx.render('-');
34
+ return;
35
+ }
36
+
37
+ const relativeTime = formatRelativeTime(dateStr);
38
+ const fullDate = new Date(dateStr).toLocaleString();
39
+
40
+ ctx.render(\`
41
+ <span title="\${fullDate}" style="cursor: help; color: #666;">
42
+ \${relativeTime}
43
+ </span>
44
+ \`);
45
+ `}}};
@@ -0,0 +1,14 @@
1
+ export const __rspack_esm_id="7201";export const __rspack_esm_ids=["7201"];export const __webpack_modules__={79271(e,t,n){n.r(t),n.d(t,{JSBlockRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container.
2
+ Supports innerHTML, append, and other DOM manipulation methods.
3
+ Use this to render content in the JS block.`),record:`Current record data object (read-only).
4
+ Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),l.define({label:"RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等"),record:"当前记录(只读,用于数据区块/详情等场景)",value:"当前值(若存在)",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`。\n注意:当模块只有 default 一个导出时,ctx.importAsync 会直接返回 default 值(无需再写 `.default`)。"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>o,e:()=>l});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},93512(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-button",label:"Render button handler",description:"Render a button and handle click events inside the block",locales:{"zh-CN":{label:"按钮事件处理",description:"在区块中渲染按钮并绑定点击处理逻辑"}},content:`
7
+ const { Button } = ctx.libs.antd;
8
+
9
+ ctx.render(
10
+ <Button type="primary" onClick={() => ctx.message.success(ctx.t('Clicked!'))}>
11
+ {ctx.t('Button')}
12
+ </Button>
13
+ );
14
+ `}}};
@@ -0,0 +1,40 @@
1
+ export const __rspack_esm_id="7959";export const __rspack_esm_ids=["7959"];export const __webpack_modules__={32221(e,t,n){n.r(t),n.d(t,{JSItemRunJSContext:()=>o});var r=n(29007),i=n(4418);class o extends r.uk{}o.define({label:"JSItem RunJS context",properties:{element:(0,i.e)(`ElementProxy instance providing a safe DOM container for form item rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),resource:`Current resource instance (read-only).
3
+ Provides access to the data resource associated with the current form context.`,record:`Current record data object (read-only).
4
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form item container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`}}),o.define({label:"JS 表单项 RunJS 上下文",properties:{element:(0,i.V)("ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作"),resource:"当前资源(只读)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪后执行回调。参数:(ref, callback, timeout?)"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let r={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},i={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}},79242(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-cascade",label:"Cascade select (load child roles)",description:"Load child roles based on the selected parent role",locales:{"zh-CN":{label:"级联选择(加载子角色)",description:"根据选择的父角色加载对应子角色"}},content:`
6
+ // Get selected parent role (adjust field name to match your form)
7
+ const parentRoleId = ctx.record?.parentRole?.id;
8
+
9
+ if (!parentRoleId) {
10
+ return;
11
+ }
12
+
13
+ const res = await ctx.request({
14
+ url: 'roles:list',
15
+ method: 'get',
16
+ params: {
17
+ pageSize: 100,
18
+ filter: {
19
+ parentId: parentRoleId,
20
+ },
21
+ },
22
+ });
23
+
24
+ const childRoles = res?.data?.data || [];
25
+
26
+ const items = ctx.model?.subModels?.grid?.subModels?.items;
27
+ const candidates = Array.isArray(items) ? items : Array.from(items?.values?.() || items || []);
28
+
29
+ const roleField = candidates.find((item) => item?.props?.name === 'role');
30
+
31
+ if (roleField) {
32
+ roleField.setProps({
33
+ dataSource: childRoles.map((role) => ({
34
+ value: role.id,
35
+ label: role.name,
36
+ })),
37
+ value: undefined,
38
+ });
39
+ }
40
+ `}}};
@@ -0,0 +1,24 @@
1
+ export const __rspack_esm_id="8138";export const __rspack_esm_ids=["8138"];export const __webpack_modules__={79271(e,t,n){n.r(t),n.d(t,{JSBlockRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container.
2
+ Supports innerHTML, append, and other DOM manipulation methods.
3
+ Use this to render content in the JS block.`),record:`Current record data object (read-only).
4
+ Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),l.define({label:"RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等"),record:"当前记录(只读,用于数据区块/详情等场景)",value:"当前值(若存在)",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`。\n注意:当模块只有 default 一个导出时,ctx.importAsync 会直接返回 default 值(无需再写 `.default`)。"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>o,e:()=>l});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},26177(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-fetch-list",label:"Fetch & render list",description:"Fetch a small list via ctx.api and render basic HTML",locales:{"zh-CN":{label:"拉取并渲染列表",description:"使用 ctx.api 拉取少量数据,并渲染基础 HTML 列表"}},content:`
7
+ // Fetch users
8
+ const { data } = await ctx.request({
9
+ url: 'users:list',
10
+ method: 'get',
11
+ params: { pageSize: 5 },
12
+ });
13
+ const rows = Array.isArray(data?.data) ? data.data : (Array.isArray(data) ? data : []);
14
+
15
+ // Render as a simple HTML list
16
+ ctx.render([
17
+ '<div style="padding:12px">',
18
+ '<h4 style="margin:0 0 8px">' + ctx.t('Users') + '</h4>',
19
+ '<ul style="margin:0; padding-left:20px">',
20
+ ...rows.map((r, i) => '<li>#' + (i + 1) + ': ' + String((r && (r.nickname ?? r.username ?? r.id)) ?? '') + '</li>'),
21
+ '</ul>',
22
+ '</div>'
23
+ ].join(''));
24
+ `}}};
@@ -0,0 +1,25 @@
1
+ export const __rspack_esm_id="8434";export const __rspack_esm_ids=["8434"];export const __webpack_modules__={79271(e,t,n){n.r(t),n.d(t,{JSBlockRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container.
2
+ Supports innerHTML, append, and other DOM manipulation methods.
3
+ Use this to render content in the JS block.`),record:`Current record data object (read-only).
4
+ Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),o.define({label:"RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等"),record:"当前记录(只读,用于数据区块/详情等场景)",value:"当前值(若存在)",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`。\n注意:当模块只有 default 一个导出时,ctx.importAsync 会直接返回 default 值(无需再写 `.default`)。"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},84953(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-antd-icons",label:"Render Ant Design icons",description:"Render Ant Design icons with buttons inside the block container",locales:{"zh-CN":{label:"渲染 Ant Design 图标",description:"在区块容器中使用 Ant Design 图标与按钮进行渲染"}},content:`
7
+ // Render Ant Design icons with buttons via ctx.libs
8
+ const { React, antd, antdIcons } = ctx.libs;
9
+ const { Button, Space } = antd;
10
+ const { PlusOutlined, EditOutlined, DeleteOutlined } = antdIcons;
11
+
12
+ const IconButtons = () => (
13
+ <Space style={{ padding: 12 }}>
14
+ <Button type="primary" icon={<PlusOutlined />}>
15
+ {ctx.t('Add')}
16
+ </Button>
17
+ <Button icon={<EditOutlined />}>{ctx.t('Edit')}</Button>
18
+ <Button danger icon={<DeleteOutlined />}>
19
+ {ctx.t('Delete')}
20
+ </Button>
21
+ </Space>
22
+ );
23
+
24
+ ctx.render(<IconButtons />);
25
+ `}}};
@@ -0,0 +1,37 @@
1
+ export const __rspack_esm_id="8438";export const __rspack_esm_ids=["8438"];export const __webpack_modules__={25831(e,t,n){n.r(t),n.d(t,{FormJSFieldItemRunJSContext:()=>i});var r=n(29007),o=n(4418);class i extends r.uk{}i.define({label:"FormJSFieldItem RunJS context",properties:{element:(0,o.e)(`ElementProxy instance providing a safe DOM container for form field rendering.
2
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:"Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).",record:`Current record data object (read-only).
3
+ Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
+ Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
+ Example: ctx.setProps(fieldModel, { value: "new value" })`}}),i.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:(0,o.V)("ElementProxy,表单字段容器"),value:"字段值(展示模式为只读;受控场景用 setProps 修改)",record:"当前记录(只读)",formValues:{description:"当前表单值快照(对象)。仅表单相关上下文可用(Create/Edit Form)。",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"容器就绪回调",setProps:"设置表单项属性:`setProps(fieldModel, { value })`(由联动/表单上下文提供)"}},{locale:"zh-CN"})},96108(e,t,n){n.r(t),n.d(t,{JSColumnRunJSContext:()=>i});var r=n(29007),o=n(4418);class i extends r.uk{}i.define({label:"JSColumn RunJS context",properties:{element:(0,o.e)("ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs."),record:"Current row record object (read-only).",recordIndex:"Index of the current row in the page (0-based).",collection:"Collection definition metadata (read-only).",viewer:"View controller providing dialog/drawer/embed helpers for interactions initiated from the cell (e.g., open details).",React:"React library",antd:"Ant Design library"},methods:{onRefReady:"Wait for cell DOM element to be ready before executing callback. Parameters: (ref, callback, timeout?) => void",requireAsync:"Load external library by URL: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import ESM module by URL: `const mod = await ctx.importAsync(url)`"}}),i.define({label:"JS 列 RunJS 上下文",properties:{element:(0,o.V)("ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等"),record:"当前行记录对象(只读)",recordIndex:"当前行索引(从 0 开始)",collection:"集合定义元数据(只读)",viewer:"视图控制器,可用于在单元格中触发抽屉/对话框/内嵌等交互",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"等待单元格 DOM 就绪后执行回调。参数:(ref, callback, timeout?)",requireAsync:"按 URL 异步加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},98542(e,t,n){n.r(t),n.d(t,{JSFieldRunJSContext:()=>i});var r=n(29007),o=n(4418);class i extends r.uk{}i.define({label:"JSField RunJS context",properties:{element:(0,o.e)(`ElementProxy instance providing a safe DOM container for field rendering.
7
+ Supports innerHTML, append, and other DOM manipulation methods.`),value:`Current value of the field (read-only).
8
+ Contains the data value stored in this field.`,record:`Current record data object (read-only).
9
+ Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
10
+ Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
11
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
12
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),i.define({label:"JS 字段 RunJS 上下文",properties:{element:(0,o.V)("ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作"),value:"字段当前值(只读)",record:"当前记录对象(只读,包含父记录全部字段值)",collection:"集合定义元数据(只读,描述字段所属集合的 Schema)"},methods:{onRefReady:"在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>i});let r={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},o={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:o}}},7765(e,t,n){n.r(t),n.d(t,{default:()=>l});var r=n(98542),o=n(25831),i=n(96108);let l={contexts:[r.JSFieldRunJSContext,o.FormJSFieldItemRunJSContext,i.JSColumnRunJSContext],scenes:["detail","table"],prefix:"sn-jsf-status-tag",label:"Display status field as colored tag",description:"Display status values using colored tags",locales:{"zh-CN":{label:"将状态字段显示为彩色标签",description:"根据状态值显示不同颜色的标签"}},content:`
13
+ const statusColors = {
14
+ active: 'green',
15
+ pending: 'orange',
16
+ inactive: 'gray',
17
+ error: 'red',
18
+ success: 'blue',
19
+ };
20
+
21
+ const status = String(ctx.value || 'unknown');
22
+ const color = statusColors[status] || 'default';
23
+
24
+ ctx.render(\`
25
+ <span style="
26
+ display: inline-block;
27
+ padding: 2px 8px;
28
+ border-radius: 4px;
29
+ font-size: 12px;
30
+ background-color: var(--\${color}-1, #f0f0f0);
31
+ color: var(--\${color}-6, #333);
32
+ border: 1px solid var(--\${color}-3, #d9d9d9);
33
+ ">
34
+ \${ctx.t(status)}
35
+ </span>
36
+ \`);
37
+ `}}};
@@ -0,0 +1,17 @@
1
+ export const __rspack_esm_id="8562";export const __rspack_esm_ids=["8562"];export const __webpack_modules__={79271(e,t,n){n.r(t),n.d(t,{JSBlockRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"RunJS context",properties:{element:(0,r.e)(`ElementProxy instance providing a safe DOM container.
2
+ Supports innerHTML, append, and other DOM manipulation methods.
3
+ Use this to render content in the JS block.`),record:`Current record data object (read-only).
4
+ Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
+ Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
+ Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),l.define({label:"RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等"),record:"当前记录(只读,用于数据区块/详情等场景)",value:"当前值(若存在)",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"容器 ref 就绪回调:\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`。\n注意:当模块只有 default 一个导出时,ctx.importAsync 会直接返回 default 值(无需再写 `.default`)。"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>o,e:()=>l});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},25417(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-iframe",label:"Render iframe",description:"Embed example.com as a sandboxed iframe inside the block element",locales:{"zh-CN":{label:"渲染 iframe",description:"在区块中以 sandbox 限制嵌入 example.com 页面"}},content:`
7
+ // Create an iframe that fills the current block container
8
+ const iframe = document.createElement('iframe');
9
+ iframe.src = 'https://example.com';
10
+ iframe.setAttribute('sandbox', 'allow-scripts');
11
+ iframe.style.width = '100%';
12
+ iframe.style.height = '100%';
13
+ iframe.style.border = 'none';
14
+
15
+ // Render the iframe as the only content
16
+ ctx.render(iframe);
17
+ `}}};
@@ -0,0 +1,22 @@
1
+ export const __rspack_esm_id="9836";export const __rspack_esm_ids=["9836"];export const __webpack_modules__={96108(e,t,n){n.r(t),n.d(t,{JSColumnRunJSContext:()=>o});var i=n(29007),r=n(4418);class o extends i.uk{}o.define({label:"JSColumn RunJS context",properties:{element:(0,r.e)("ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs."),record:"Current row record object (read-only).",recordIndex:"Index of the current row in the page (0-based).",collection:"Collection definition metadata (read-only).",viewer:"View controller providing dialog/drawer/embed helpers for interactions initiated from the cell (e.g., open details).",React:"React library",antd:"Ant Design library"},methods:{onRefReady:"Wait for cell DOM element to be ready before executing callback. Parameters: (ref, callback, timeout?) => void",requireAsync:"Load external library by URL: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import ESM module by URL: `const mod = await ctx.importAsync(url)`"}}),o.define({label:"JS 列 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等"),record:"当前行记录对象(只读)",recordIndex:"当前行索引(从 0 开始)",collection:"集合定义元数据(只读)",viewer:"视图控制器,可用于在单元格中触发抽屉/对话框/内嵌等交互",React:"React 库",antd:"Ant Design 库"},methods:{onRefReady:"等待单元格 DOM 就绪后执行回调。参数:(ref, callback, timeout?)",requireAsync:"按 URL 异步加载外部库:`const lib = await ctx.requireAsync(url)`",importAsync:"按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},4418(e,t,n){n.d(t,{V:()=>l,e:()=>o});let i={innerHTML:"Sanitized inner HTML string.",outerHTML:"Sanitized outer HTML string.",textContent:"Text content.",style:"Inline style declaration.",classList:"DOMTokenList for CSS classes.",appendChild:{type:"function",description:"Append a DOM node or text.",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"Set an HTML attribute.",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"Read an HTML attribute.",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"Find the first matching descendant.",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"Find all matching descendants.",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"Attach an event listener to the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"Remove an event listener from the element.",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}},r={innerHTML:"已消毒的 innerHTML 字符串。",outerHTML:"已消毒的 outerHTML 字符串。",textContent:"文本内容。",style:"内联样式声明。",classList:"CSS class 列表。",appendChild:{type:"function",description:"追加 DOM 节点或文本。",detail:"(child: Node | string) => void",completion:{insertText:"ctx.element.appendChild('text')"}},setAttribute:{type:"function",description:"设置 HTML 属性。",detail:"(name: string, value: string) => void",completion:{insertText:"ctx.element.setAttribute('data-key', 'value')"}},getAttribute:{type:"function",description:"读取 HTML 属性。",detail:"(name: string) => string | null",completion:{insertText:"ctx.element.getAttribute('data-key')"}},querySelector:{type:"function",description:"查询第一个匹配的后代元素。",detail:"(selectors: string) => Element | null",completion:{insertText:"ctx.element.querySelector('.selector')"}},querySelectorAll:{type:"function",description:"查询所有匹配的后代元素。",detail:"(selectors: string) => NodeListOf<Element>",completion:{insertText:"ctx.element.querySelectorAll('.selector')"}},addEventListener:{type:"function",description:"给元素添加事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.addEventListener('click', (event) => {})"}},removeEventListener:{type:"function",description:"移除元素事件监听。",detail:"(type: string, listener: EventListener) => void",completion:{insertText:"ctx.element.removeEventListener('click', handler)"}}};function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Current DOM container for this RunJS context. Usually an ElementProxy.";return{description:e,detail:"HTMLElement | ElementProxy",properties:i}}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},72103(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(96108).JSColumnRunJSContext],prefix:"sn-col-open-dialog",label:"Cell dialog with row data",description:"Render a button in cell to open dialog via ctx.openView with current row context",locales:{"zh-CN":{label:"单元格对话框(显示行数据)",description:"在单元格渲染按钮,点击后通过 ctx.openView 打开弹窗并传入当前行上下文"}},content:`
2
+ // Render a button inside the cell
3
+ const button = document.createElement('button');
4
+ button.className = 'nb-cell-btn';
5
+ button.style.padding = '4px 8px';
6
+ button.textContent = ctx.t('View');
7
+ const popupUid = ctx.model.uid + '-1'; // popupUid should be stable and better bound to ctx.model.uid
8
+ const primaryKey = ctx.collection?.primaryKey || 'id';
9
+
10
+ button?.addEventListener('click', async () => {
11
+ await ctx.openView(popupUid, {
12
+ mode: 'dialog',
13
+ title: ctx.t('Row detail'),
14
+ params: {
15
+ filterByTk: ctx.record?.[primaryKey],
16
+ record: ctx.record,
17
+ },
18
+ });
19
+ });
20
+
21
+ ctx.render(button);
22
+ `}}};