@nocobase/app 2.1.0-beta.42 → 2.1.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/1507-be1bb59f.js +7 -0
- package/dist/client/assets/2702-2229ffce.js +5 -0
- package/dist/client/assets/3475-c853dcfb.js +1 -0
- package/dist/client/assets/3660-ae135b62.js +6 -0
- package/dist/client/assets/3916-03cc08e1.js +6 -0
- package/dist/client/assets/4687-cb88a94b.js +1 -0
- package/dist/client/assets/6269-d8f21ee9.js +1 -0
- package/dist/client/assets/{index-d8e97233.js → index-2bb32c00.js} +287 -287
- package/dist/client/assets/runtime-6964d231.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.tpl +1 -1
- package/dist/client/v2/assets/1310-c0031389.js +59 -0
- package/dist/client/v2/assets/1425-69534606.js +42 -0
- package/dist/client/v2/assets/1507-9a211af0.js +7 -0
- package/dist/client/v2/assets/158-5273dfbb.js +23 -0
- package/dist/client/v2/assets/1725-d9ce2582.js +83 -0
- package/dist/client/v2/assets/1786-e6c321bb.js +16 -0
- package/dist/client/v2/assets/1951-84be8ebc.js +55 -0
- package/dist/client/v2/assets/2017-29a9879a.js +26 -0
- package/dist/client/v2/assets/212-0f8a26a2.js +18 -0
- package/dist/client/v2/assets/2335-669f21bd.js +22 -0
- package/dist/client/v2/assets/2555-4ca49e21.js +31 -0
- package/dist/client/v2/assets/2702-5ce93acd.js +5 -0
- package/dist/client/v2/assets/2710-e7286996.js +36 -0
- package/dist/client/v2/assets/2726-4d19faa1.js +23 -0
- package/dist/client/v2/assets/2898-7656f7f9.js +17 -0
- package/dist/client/v2/assets/2958-93de29a6.js +27 -0
- package/dist/client/v2/assets/3117-cc936eae.js +33 -0
- package/dist/client/v2/assets/3475-be655098.js +1 -0
- package/dist/client/v2/assets/3660-280439df.js +6 -0
- package/dist/client/v2/assets/3662-8dff1ffe.js +28 -0
- package/dist/client/v2/assets/3727-1cfef422.js +44 -0
- package/dist/client/v2/assets/3916-3b34f216.js +6 -0
- package/dist/client/v2/assets/3989-c8fcfd6c.js +27 -0
- package/dist/client/v2/assets/4313-ab774fd9.js +28 -0
- package/dist/client/v2/assets/5501-387a31be.js +17 -0
- package/dist/client/v2/assets/5721-af25e047.js +18 -0
- package/dist/client/v2/assets/5759-2b3bdcc6.js +47 -0
- package/dist/client/v2/assets/5761-857b6bbb.js +28 -0
- package/dist/client/v2/assets/6269-a8a1ea3f.js +1 -0
- package/dist/client/v2/assets/6437-3865fd7e.js +12 -0
- package/dist/client/v2/assets/6738-c6598897.js +20 -0
- package/dist/client/v2/assets/700-e75b7faa.js +15 -0
- package/dist/client/v2/assets/7021-4975d54d.js +45 -0
- package/dist/client/v2/assets/7201-5b49ce84.js +14 -0
- package/dist/client/v2/assets/7959-f7ef21c6.js +40 -0
- package/dist/client/v2/assets/8138-e90c290e.js +24 -0
- package/dist/client/v2/assets/8434-9140d106.js +25 -0
- package/dist/client/v2/assets/8438-d2ff6bc1.js +37 -0
- package/dist/client/v2/assets/8562-ffa35312.js +17 -0
- package/dist/client/v2/assets/9836-fcbb81f6.js +22 -0
- package/dist/client/v2/assets/{index-48dce4e9.js → index-496065db.js} +136 -136
- package/dist/client/v2/assets/{runtime-0629701e.js → runtime-afd2b4ee.js} +1 -1
- package/dist/client/v2/index.html +1 -1
- package/package.json +7 -7
- package/dist/client/assets/1507-bfaf088d.js +0 -7
- package/dist/client/assets/2702-448a397f.js +0 -5
- package/dist/client/assets/3475-9e7a0395.js +0 -1
- package/dist/client/assets/3660-fdea8689.js +0 -6
- package/dist/client/assets/3916-a8888466.js +0 -6
- package/dist/client/assets/6269-5467af50.js +0 -1
- package/dist/client/assets/runtime-1dde2b80.js +0 -1
- package/dist/client/v2/assets/1310-21e5c8a8.js +0 -59
- package/dist/client/v2/assets/1425-a2b446a6.js +0 -42
- package/dist/client/v2/assets/1507-a673a0c0.js +0 -7
- package/dist/client/v2/assets/158-6a033567.js +0 -23
- package/dist/client/v2/assets/1725-6f5b8d53.js +0 -83
- package/dist/client/v2/assets/1786-8969223a.js +0 -16
- package/dist/client/v2/assets/1951-f63bc4b3.js +0 -55
- package/dist/client/v2/assets/2017-b35f125d.js +0 -26
- package/dist/client/v2/assets/212-59d29e60.js +0 -18
- package/dist/client/v2/assets/2335-1d33c3cf.js +0 -22
- package/dist/client/v2/assets/2555-dee484a1.js +0 -31
- package/dist/client/v2/assets/2702-8d5ab2a8.js +0 -5
- package/dist/client/v2/assets/2710-93d67bf0.js +0 -36
- package/dist/client/v2/assets/2726-f6cc5db9.js +0 -23
- package/dist/client/v2/assets/2898-2a7d5793.js +0 -17
- package/dist/client/v2/assets/2958-5a85effa.js +0 -27
- package/dist/client/v2/assets/3117-3d38bb4d.js +0 -33
- package/dist/client/v2/assets/3475-c42974e1.js +0 -1
- package/dist/client/v2/assets/3660-27f9c6c5.js +0 -6
- package/dist/client/v2/assets/3662-135bbea1.js +0 -28
- package/dist/client/v2/assets/3727-b74fc29b.js +0 -44
- package/dist/client/v2/assets/3916-ba5b43b5.js +0 -6
- package/dist/client/v2/assets/3989-e72345bb.js +0 -27
- package/dist/client/v2/assets/4313-9687f912.js +0 -28
- package/dist/client/v2/assets/5501-a3b5b97f.js +0 -17
- package/dist/client/v2/assets/5721-f00ddbf2.js +0 -18
- package/dist/client/v2/assets/5759-d5b1d946.js +0 -47
- package/dist/client/v2/assets/5761-8ab1974d.js +0 -28
- package/dist/client/v2/assets/6269-35e90156.js +0 -1
- package/dist/client/v2/assets/6437-2f91d29a.js +0 -12
- package/dist/client/v2/assets/6738-eb09fa59.js +0 -20
- package/dist/client/v2/assets/700-5f166286.js +0 -15
- package/dist/client/v2/assets/7021-01608dc5.js +0 -45
- package/dist/client/v2/assets/7201-8e6e91a3.js +0 -14
- package/dist/client/v2/assets/7959-ab57fce2.js +0 -40
- package/dist/client/v2/assets/8138-704104a5.js +0 -24
- package/dist/client/v2/assets/8434-79232eec.js +0 -25
- package/dist/client/v2/assets/8438-9d210970.js +0 -37
- package/dist/client/v2/assets/8562-215edc37.js +0 -17
- package/dist/client/v2/assets/9836-288424d8.js +0 -22
- /package/dist/client/assets/{index-d8e97233.js.LICENSE.txt → index-2bb32c00.js.LICENSE.txt} +0 -0
- /package/dist/client/v2/assets/{index-48dce4e9.js.LICENSE.txt → index-496065db.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const __rspack_esm_id="2702";export const __rspack_esm_ids=["2702"];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}}}};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const __rspack_esm_id="2710";export const __rspack_esm_ids=["2710"];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}}},27733(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(96108).JSColumnRunJSContext],prefix:"sn-col-concat",label:"Concat two fields",description:"Combine two field values into the current column cell",locales:{"zh-CN":{label:"拼接两个字段值",description:"在自定义列中拼接两个字段的值作为显示内容"}},content:`
|
|
2
|
+
// Demo helper: infer previous columns' dataIndex values based on the current column position
|
|
3
|
+
// In production, hardcode field names to avoid surprises when columns are reordered
|
|
4
|
+
function resolvePreviousDataIndexes() {
|
|
5
|
+
const parent = ctx.model?.parent;
|
|
6
|
+
const list = parent?.subModels?.columns;
|
|
7
|
+
if (!Array.isArray(list)) return [];
|
|
8
|
+
const currentUid = ctx.model?.uid;
|
|
9
|
+
const currentIndex = list.findIndex((item) => item?.uid === currentUid);
|
|
10
|
+
if (currentIndex <= 0) return [];
|
|
11
|
+
return list
|
|
12
|
+
.slice(Math.max(0, currentIndex - 2), currentIndex)
|
|
13
|
+
.map((item) => (item && item.props ? item.props.dataIndex : undefined))
|
|
14
|
+
.filter((key) => typeof key === 'string' && key.length > 0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const [autoFieldA, autoFieldB] = resolvePreviousDataIndexes();
|
|
18
|
+
|
|
19
|
+
// Fallback: manually specify field keys when auto detection is not enough
|
|
20
|
+
const fieldA = autoFieldA || 'firstName';
|
|
21
|
+
const fieldB = autoFieldB || 'lastName';
|
|
22
|
+
|
|
23
|
+
const normalize = (value) => {
|
|
24
|
+
if (value === undefined || value === null) return '';
|
|
25
|
+
return String(value).trim();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const valueA = normalize(ctx.record?.[fieldA]);
|
|
29
|
+
const valueB = normalize(ctx.record?.[fieldB]);
|
|
30
|
+
|
|
31
|
+
const parts = [valueA, valueB].filter((item) => item.length > 0);
|
|
32
|
+
|
|
33
|
+
const result = document.createElement('span');
|
|
34
|
+
result.textContent = parts.length ? parts.join(' / ') : ctx.t('N/A');
|
|
35
|
+
ctx.render(result);
|
|
36
|
+
`}}};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const __rspack_esm_id="2726";export const __rspack_esm_ids=["2726"];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}}},37285(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-echarts",label:"Init ECharts",description:"Load ECharts and render a simple chart inside the block",locales:{"zh-CN":{label:"初始化 ECharts",description:"加载 ECharts 并在区块内渲染示例图表"}},content:`
|
|
7
|
+
const container = document.createElement('div');
|
|
8
|
+
container.style.height = '400px';
|
|
9
|
+
container.style.width = '100%';
|
|
10
|
+
ctx.render(container);
|
|
11
|
+
const echarts = await ctx.requireAsync('echarts@5/dist/echarts.min.js');
|
|
12
|
+
if (!echarts) {
|
|
13
|
+
throw new Error('ECharts library not loaded');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const chart = echarts.init(container);
|
|
17
|
+
chart.setOption({
|
|
18
|
+
title: { text: ctx.t('ECharts') },
|
|
19
|
+
series: [{ type: 'pie', data: [{ value: 1, name: ctx.t('A') }] }],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
chart.resize();
|
|
23
|
+
`}}};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const __rspack_esm_id="2898";export const __rspack_esm_ids=["2898"];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}}},17689(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-color",label:"Display number field as colored text",description:"Display numeric values using colors based on their sign",locales:{"zh-CN":{label:"将数字字段显示为彩色文本",description:"根据数值正负设置显示颜色"}},content:`
|
|
13
|
+
// Colorize based on numeric sign
|
|
14
|
+
const n = Number(ctx.value ?? 0);
|
|
15
|
+
const color = Number.isFinite(n) ? (n > 0 ? 'green' : n < 0 ? 'red' : '#999') : '#555';
|
|
16
|
+
ctx.render('<span style=' + JSON.stringify('color:' + color) + '>' + String(ctx.value ?? '') + '</span>');
|
|
17
|
+
`}}};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const __rspack_esm_id="2958";export const __rspack_esm_ids=["2958"];export const __webpack_modules__={25831(e,t,n){n.r(t),n.d(t,{FormJSFieldItemRunJSContext:()=>o});var r=n(29007),i=n(4418);class o extends r.uk{}o.define({label:"FormJSFieldItem RunJS context",properties:{element:(0,i.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,i.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"})},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.
|
|
7
|
+
Supports innerHTML, append, and other DOM manipulation methods.
|
|
8
|
+
Use this to render content in the JS block.`),record:`Current record data object (read-only).
|
|
9
|
+
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.
|
|
10
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
11
|
+
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"})},98542(e,t,n){n.r(t),n.d(t,{JSFieldRunJSContext:()=>o});var r=n(29007),i=n(4418);class o extends r.uk{}o.define({label:"JSField RunJS context",properties:{element:(0,i.e)(`ElementProxy instance providing a safe DOM container for field rendering.
|
|
12
|
+
Supports innerHTML, append, and other DOM manipulation methods.`),value:`Current value of the field (read-only).
|
|
13
|
+
Contains the data value stored in this field.`,record:`Current record data object (read-only).
|
|
14
|
+
Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
|
|
15
|
+
Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
|
|
16
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
17
|
+
Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),o.define({label:"JS 字段 RunJS 上下文",properties:{element:(0,i.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 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}}},93117(e,t,n){n.r(t),n.d(t,{default:()=>l});var r=n(79271),i=n(98542),o=n(25831);let l={contexts:[r.JSBlockRunJSContext,i.JSFieldRunJSContext,o.FormJSFieldItemRunJSContext],prefix:"sn-query-selector",label:"Query selector",description:"Find a child element inside rendered DOM using querySelector",locales:{"zh-CN":{label:"查询子元素",description:"使用 querySelector 在渲染的 DOM 内查找子元素"}},content:`
|
|
18
|
+
const wrapper = document.createElement('div');
|
|
19
|
+
wrapper.innerHTML = '<div class="child-class"></div>';
|
|
20
|
+
|
|
21
|
+
ctx.render(wrapper);
|
|
22
|
+
|
|
23
|
+
const child = wrapper.querySelector('.child-class');
|
|
24
|
+
if (child) {
|
|
25
|
+
child.textContent = ctx.t('Hello from querySelector');
|
|
26
|
+
}
|
|
27
|
+
`}}};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const __rspack_esm_id="3117";export const __rspack_esm_ids=["3117"];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:()=>s,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 s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"当前 RunJS 上下文的 DOM 容器,通常为 ElementProxy。";return{description:e,detail:"HTMLElement | ElementProxy",properties:r}}},80236(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-copy",label:"Copy value from another field",description:"Copy value from one field to another when checkbox is checked",locales:{"zh-CN":{label:"复制字段值",description:"勾选复选框时,将一个字段的值复制到另一个字段"}},content:`
|
|
6
|
+
// When 'sameAsAbove' is checked, copy billing address to shipping address
|
|
7
|
+
const sameAsAbove = ctx.record?.sameAsAbove;
|
|
8
|
+
|
|
9
|
+
if (!sameAsAbove) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const items = ctx.model?.subModels?.grid?.subModels?.items;
|
|
14
|
+
const candidates = Array.isArray(items) ? items : Array.from(items?.values?.() || items || []);
|
|
15
|
+
|
|
16
|
+
// Source and target field mappings
|
|
17
|
+
const fieldMappings = [
|
|
18
|
+
{ from: 'billingAddress', to: 'shippingAddress' },
|
|
19
|
+
{ from: 'billingCity', to: 'shippingCity' },
|
|
20
|
+
{ from: 'billingZipCode', to: 'shippingZipCode' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
fieldMappings.forEach(({ from, to }) => {
|
|
24
|
+
const sourceValue = ctx.record?.[from];
|
|
25
|
+
const targetField = candidates.find((item) => item?.props?.name === to);
|
|
26
|
+
|
|
27
|
+
if (targetField) {
|
|
28
|
+
targetField.setProps({ value: sourceValue });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
ctx.message?.success?.(ctx.t('Address copied successfully'));
|
|
33
|
+
`}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __rspack_esm_id="3475";export const __rspack_esm_ids=["3475"];export const __webpack_modules__={99502(e,t,n){n.r(t),n.d(t,{JSEditableFieldRunJSContext:()=>l});var i=n(29007),r=n(4418);class l extends i.uk{}l.define({label:"JSEditableField RunJS context",properties:{element:(0,r.e)("ElementProxy instance providing a safe DOM container for field rendering. In editable mode this container is typically a <span> element."),value:{description:"Current field value (read-only snapshot). In editable scenarios, prefer ctx.getValue()/ctx.setValue(v) for two-way binding.",detail:"any",examples:["const v = ctx.getValue?.() ?? ctx.value;",'ctx.setValue?.("new value");']},record:{description:"Current record data object (read-only). Available in forms that are bound to a record.",detail:"Record<string, any>"},form:{description:'Ant Design Form instance for reading/writing other fields. Example: ctx.form.getFieldValue("name")',detail:"FormInstance"},formValues:{description:"Snapshot of current form values (object). Prefer ctx.form.getFieldsValue() when you need the latest values.",detail:"Record<string, any>"},namePath:{description:"Field namePath in the form (array). Useful for advanced Form operations.",detail:"Array<string | number>"},disabled:"Whether the field is disabled (boolean).",readOnly:"Whether the field is read-only (boolean)."},methods:{getValue:{description:"Get current field value (recommended for editable custom fields).",detail:"() => any",completion:{insertText:"ctx.getValue?.()"}},setValue:{description:"Set current field value (two-way binding with the form).",detail:"(value: any) => void",completion:{insertText:"ctx.setValue?.(value)"},examples:["ctx.setValue?.(e.target.value);"]}}}),l.define({label:"JS 可编辑字段 RunJS 上下文",properties:{element:(0,r.V)("ElementProxy,字段渲染的安全容器(通常为 <span> 容器)。"),value:{description:"字段当前值(只读快照)。可编辑场景建议使用 ctx.getValue()/ctx.setValue(v) 做双向绑定。",detail:"any",examples:["const v = ctx.getValue?.() ?? ctx.value;",'ctx.setValue?.("新值");']},record:{description:"当前记录对象(只读;表单绑定记录时可用)。",detail:"Record<string, any>"},form:{description:"Ant Design Form 实例,可读写其它字段。",detail:"FormInstance"},formValues:{description:"当前表单值快照(对象)。需要最新值可用 ctx.form.getFieldsValue()。",detail:"Record<string, any>"},namePath:{description:"字段在表单中的 namePath(数组)。",detail:"Array<string | number>"},disabled:"是否禁用(boolean)",readOnly:"是否只读(boolean)"},methods:{getValue:{description:"获取字段当前值(可编辑字段推荐使用)。",detail:"() => any",completion:{insertText:"ctx.getValue?.()"}},setValue:{description:"设置字段当前值(与表单双向绑定)。",detail:"(value: any) => void",completion:{insertText:"ctx.setValue?.(value)"},examples:["ctx.setValue?.(e.target.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}}}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const __rspack_esm_id="3660";export const __rspack_esm_ids=["3660"];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}}}};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const __rspack_esm_id="3662";export const __rspack_esm_ids=["3662"];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}}},44637(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-required",label:"Set required",description:"Toggle required rule for another field within linkage",locales:{"zh-CN":{label:"设置必填",description:"在联动脚本中控制字段是否必填"}},content:`
|
|
6
|
+
const targetFieldUid = 'FIELD_UID_OR_NAME';
|
|
7
|
+
const required = 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({ required });
|
|
23
|
+
ctx.message?.success?.(
|
|
24
|
+
ctx.t(required ? 'Set field {{name}} as required' : 'Field {{name}} is optional', {
|
|
25
|
+
name: fieldModel?.props?.label || targetFieldUid,
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
`}}};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const __rspack_esm_id="3727";export const __rspack_esm_ids=["3727"];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}}},80626(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-timeline",label:"Render timeline from records",description:"Display records as a timeline using Ant Design Timeline",locales:{"zh-CN":{label:"渲染时间轴",description:"使用 Ant Design 时间轴组件显示记录历史"}},content:`
|
|
7
|
+
const { Timeline, Card } = ctx.libs.antd;
|
|
8
|
+
|
|
9
|
+
const res = await ctx.request({
|
|
10
|
+
url: 'users:list',
|
|
11
|
+
method: 'get',
|
|
12
|
+
params: {
|
|
13
|
+
pageSize: 20,
|
|
14
|
+
sort: ['-createdAt'],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const records = res?.data?.data || [];
|
|
19
|
+
|
|
20
|
+
if (!records.length) {
|
|
21
|
+
ctx.render('<div style="padding:16px;color:#999;">' + ctx.t('No data') + '</div>');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ctx.render(
|
|
26
|
+
<Card title={ctx.t('Activity Timeline')} bordered>
|
|
27
|
+
<Timeline mode="left">
|
|
28
|
+
{records.map((record) => (
|
|
29
|
+
<Timeline.Item
|
|
30
|
+
key={record.id}
|
|
31
|
+
label={record.createdAt ? new Date(record.createdAt).toLocaleString() : ''}
|
|
32
|
+
>
|
|
33
|
+
<div>
|
|
34
|
+
<strong>{record.nickname || record.username || ctx.t('Unnamed user')}</strong>
|
|
35
|
+
{record.email ? (
|
|
36
|
+
<div style={{ color: '#999', fontSize: '12px', marginTop: '4px' }}>{record.email}</div>
|
|
37
|
+
) : null}
|
|
38
|
+
</div>
|
|
39
|
+
</Timeline.Item>
|
|
40
|
+
))}
|
|
41
|
+
</Timeline>
|
|
42
|
+
</Card>
|
|
43
|
+
);
|
|
44
|
+
`}}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const __rspack_esm_id="3916";export const __rspack_esm_ids=["3916"];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"})},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,27 @@
|
|
|
1
|
+
export const __rspack_esm_id="3989";export const __rspack_esm_ids=["3989"];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}}},35876(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-set",label:"Set field value",description:"Programmatically update another field in linkage scripts",locales:{"zh-CN":{label:"设置字段值",description:"在联动脚本中为其他字段设置值"}},content:`
|
|
6
|
+
// Update another field in the same form/block
|
|
7
|
+
const targetFieldUid = 'FIELD_UID_OR_NAME';
|
|
8
|
+
const nextValue = ctx.record?.status ?? ctx.t('Updated value');
|
|
9
|
+
|
|
10
|
+
const items = ctx.model?.subModels?.grid?.subModels?.items;
|
|
11
|
+
const candidates = Array.isArray(items)
|
|
12
|
+
? items
|
|
13
|
+
: Array.from(items?.values?.() || items || []);
|
|
14
|
+
const fieldModel =
|
|
15
|
+
candidates.find((item) => item?.uid === targetFieldUid) ||
|
|
16
|
+
candidates.find((item) => item?.props?.name === targetFieldUid);
|
|
17
|
+
|
|
18
|
+
if (!fieldModel) {
|
|
19
|
+
ctx.message?.warning?.(ctx.t('Field {{name}} not found', { name: targetFieldUid }));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fieldModel.setProps({ value: nextValue });
|
|
24
|
+
ctx.message?.success?.(
|
|
25
|
+
ctx.t('Updated field {{name}}', { name: fieldModel?.props?.label || targetFieldUid }),
|
|
26
|
+
);
|
|
27
|
+
`}}};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const __rspack_esm_id="4313";export const __rspack_esm_ids=["4313"];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}}},66656(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(32221).JSItemRunJSContext],prefix:"sn-link-disable",label:"Set disabled",description:"Enable or disable another field in linkage scripts",locales:{"zh-CN":{label:"设置禁用",description:"在联动脚本中启用或禁用字段"}},content:`
|
|
6
|
+
const targetFieldUid = 'FIELD_UID_OR_NAME';
|
|
7
|
+
const disabled = 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({ disabled });
|
|
23
|
+
ctx.message?.success?.(
|
|
24
|
+
ctx.t(disabled ? 'Disabled field {{name}}' : 'Enabled field {{name}}', {
|
|
25
|
+
name: fieldModel?.props?.label || targetFieldUid,
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
`}}};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const __rspack_esm_id="5501";export const __rspack_esm_ids=["5501"];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}}},71868(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-jsb-react",label:"Render React",description:"Render a React element inside the block container",locales:{"zh-CN":{label:"渲染 React",description:"在区块容器中渲染 React 组件"}},content:`
|
|
7
|
+
// Render a React element into the current container
|
|
8
|
+
const { Button } = ctx.libs.antd;
|
|
9
|
+
|
|
10
|
+
ctx.render(
|
|
11
|
+
<div style={{ padding: 12 }}>
|
|
12
|
+
<Button type="primary" onClick={() => ctx.message.success(ctx.t('Clicked!'))}>
|
|
13
|
+
{ctx.t('Click')}
|
|
14
|
+
</Button>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
`}}};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const __rspack_esm_id="5721";export const __rspack_esm_ids=["5721"];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}}},91296(e,t,n){n.r(t),n.d(t,{default:()=>i});let i={contexts:[n(79271).JSBlockRunJSContext],prefix:"sn-react-jsx",label:"Render React (JSX)",description:"Render a simple React component using JSX syntax",locales:{"zh-CN":{label:"渲染 React(JSX)",description:"使用 JSX 语法渲染一个简单的 React 组件"}},content:`
|
|
7
|
+
// Render a React component with JSX
|
|
8
|
+
const { React } = ctx.libs;
|
|
9
|
+
|
|
10
|
+
const App = () => (
|
|
11
|
+
<div style={{ padding: 12 }}>
|
|
12
|
+
<h3 style={{ margin: 0, color: '#1890ff' }}>Hello JSX</h3>
|
|
13
|
+
<div style={{ color: '#555' }}>This block is rendered by JSX.</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
ctx.render(<App />);
|
|
18
|
+
`}}};
|