@nocobase/app 2.1.0-beta.41 → 2.1.0-beta.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-af5cbcee.js → index-4951d7f9.js} +256 -256
- 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-e2a1234c.js → index-fa6a31c0.js} +126 -126
- 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-af5cbcee.js.LICENSE.txt → index-4951d7f9.js.LICENSE.txt} +0 -0
- /package/dist/client/v2/assets/{index-e2a1234c.js.LICENSE.txt → index-fa6a31c0.js.LICENSE.txt} +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
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 r=n(29007);class o extends r.uk{}o.define({label:"JSColumn RunJS context",properties:{element:"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:"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"})},27733(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={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
|
-
`}}};
|
|
@@ -1,23 +0,0 @@
|
|
|
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:()=>a});var r=n(29007);class a extends r.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})},37285(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={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
|
-
`}}};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="2898";export const __rspack_esm_ids=["2898"];export const __webpack_modules__={25831(e,t,o){o.r(t),o.d(t,{FormJSFieldItemRunJSContext:()=>r});var n=o(29007);class r extends n.uk{}r.define({label:"FormJSFieldItem RunJS context",properties:{element:`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" })`}}),r.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:"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,o){o.r(t),o.d(t,{JSFieldRunJSContext:()=>r});var n=o(29007);class r extends n.uk{}r.define({label:"JSField RunJS context",properties:{element:`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 })`}}),r.define({label:"JS 字段 RunJS 上下文",properties:{element:"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"})},17689(e,t,o){o.r(t),o.d(t,{default:()=>a});var n=o(98542),r=o(25831);let a={contexts:[n.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
|
-
`}}};
|
|
@@ -1,27 +0,0 @@
|
|
|
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);class o extends r.uk{}o.define({label:"FormJSFieldItem RunJS context",properties:{element:`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:"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);class o extends r.uk{}o.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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);class o extends r.uk{}o.define({label:"JSField RunJS context",properties:{element:`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:"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"})},93117(e,t,n){n.r(t),n.d(t,{default:()=>l});var r=n(79271),o=n(98542),a=n(25831);let l={contexts:[r.JSBlockRunJSContext,o.JSFieldRunJSContext,a.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
|
-
`}}};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3117";export const __rspack_esm_ids=["3117"];export const __webpack_modules__={32221(e,t,o){o.r(t),o.d(t,{JSItemRunJSContext:()=>s});var r=o(29007);class s extends r.uk{}s.define({label:"JSItem RunJS context",properties:{element:`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`}}),s.define({label:"JS 表单项 RunJS 上下文",properties:{element:"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"})},80236(e,t,o){o.r(t),o.d(t,{default:()=>r});let r={contexts:[o(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
|
-
`}}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3475";export const __rspack_esm_ids=["3475"];export const __webpack_modules__={99502(e,t,a){a.r(t),a.d(t,{JSEditableFieldRunJSContext:()=>i});var n=a(29007);class i extends n.uk{}i.define({label:"JSEditableField RunJS context",properties:{element:{description:"ElementProxy instance providing a safe DOM container for field rendering. In editable mode this container is typically a <span> element.",detail:"ElementProxy"},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);"]}}}),i.define({label:"JS 可编辑字段 RunJS 上下文",properties:{element:{description:"ElementProxy,字段渲染的安全容器(通常为 <span> 容器)。",detail:"ElementProxy"},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"})}};
|
|
@@ -1,6 +0,0 @@
|
|
|
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:()=>a});var r=n(29007);class a extends r.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})}};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3662";export const __rspack_esm_ids=["3662"];export const __webpack_modules__={32221(e,t,r){r.r(t),r.d(t,{JSItemRunJSContext:()=>n});var o=r(29007);class n extends o.uk{}n.define({label:"JSItem RunJS context",properties:{element:`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`}}),n.define({label:"JS 表单项 RunJS 上下文",properties:{element:"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"})},44637(e,t,r){r.r(t),r.d(t,{default:()=>o});let o={contexts:[r(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
|
-
`}}};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3727";export const __rspack_esm_ids=["3727"];export const __webpack_modules__={79271(e,t,r){r.r(t),r.d(t,{JSBlockRunJSContext:()=>a});var n=r(29007);class a extends n.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})},80626(e,t,r){r.r(t),r.d(t,{default:()=>n});let n={contexts:[r(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
|
-
`}}};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3916";export const __rspack_esm_ids=["3916"];export const __webpack_modules__={25831(e,o,r){r.r(o),r.d(o,{FormJSFieldItemRunJSContext:()=>a});var t=r(29007);class a extends t.uk{}a.define({label:"FormJSFieldItem RunJS context",properties:{element:`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" })`}}),a.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:"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"})}};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="3989";export const __rspack_esm_ids=["3989"];export const __webpack_modules__={32221(e,t,a){a.r(t),a.d(t,{JSItemRunJSContext:()=>o});var r=a(29007);class o extends r.uk{}o.define({label:"JSItem RunJS context",properties:{element:`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:"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"})},35876(e,t,a){a.r(t),a.d(t,{default:()=>r});let r={contexts:[a(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
|
-
`}}};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="4313";export const __rspack_esm_ids=["4313"];export const __webpack_modules__={32221(e,t,r){r.r(t),r.d(t,{JSItemRunJSContext:()=>n});var a=r(29007);class n extends a.uk{}n.define({label:"JSItem RunJS context",properties:{element:`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`}}),n.define({label:"JS 表单项 RunJS 上下文",properties:{element:"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"})},66656(e,t,r){r.r(t),r.d(t,{default:()=>a});let a={contexts:[r(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
|
-
`}}};
|
|
@@ -1,17 +0,0 @@
|
|
|
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:()=>a});var r=n(29007);class a extends r.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})},71868(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={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
|
-
`}}};
|
|
@@ -1,18 +0,0 @@
|
|
|
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:()=>a});var r=n(29007);class a extends r.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})},91296(e,t,n){n.r(t),n.d(t,{default:()=>r});let r={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
|
-
`}}};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="5759";export const __rspack_esm_ids=["5759"];export const __webpack_modules__={25831(e,t,r){r.r(t),r.d(t,{FormJSFieldItemRunJSContext:()=>n});var o=r(29007);class n extends o.uk{}n.define({label:"FormJSFieldItem RunJS context",properties:{element:`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" })`}}),n.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:"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,r){r.r(t),r.d(t,{JSFieldRunJSContext:()=>n});var o=r(29007);class n extends o.uk{}n.define({label:"JSField RunJS context",properties:{element:`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 })`}}),n.define({label:"JS 字段 RunJS 上下文",properties:{element:"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"})},73330(e,t,r){r.r(t),r.d(t,{default:()=>a});var o=r(98542),n=r(25831);let a={contexts:[o.JSFieldRunJSContext,n.FormJSFieldItemRunJSContext],prefix:"sn-jsf-percent",label:"Display number field as percentage bar",description:"Render numeric values as a percentage progress bar",locales:{"zh-CN":{label:"将数字字段显示为百分比进度条",description:"将数字格式化为百分比并显示进度条"}},content:`
|
|
13
|
-
const value = Number(ctx.value ?? 0);
|
|
14
|
-
|
|
15
|
-
if (!Number.isFinite(value)) {
|
|
16
|
-
ctx.render('-');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Ensure value is between 0 and 100
|
|
21
|
-
const percent = Math.max(0, Math.min(100, value));
|
|
22
|
-
|
|
23
|
-
// Color based on value
|
|
24
|
-
const getColor = (val) => {
|
|
25
|
-
if (val >= 80) return '#52c41a';
|
|
26
|
-
if (val >= 50) return '#faad14';
|
|
27
|
-
return '#f5222d';
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const color = getColor(percent);
|
|
31
|
-
|
|
32
|
-
ctx.render(\`
|
|
33
|
-
<div style="display: flex; align-items: center; gap: 8px;">
|
|
34
|
-
<div style="flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden;">
|
|
35
|
-
<div style="
|
|
36
|
-
width: \${percent}%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
background: \${color};
|
|
39
|
-
transition: width 0.3s ease;
|
|
40
|
-
"></div>
|
|
41
|
-
</div>
|
|
42
|
-
<span style="color: \${color}; font-weight: 500; min-width: 45px; text-align: right;">
|
|
43
|
-
\${percent.toFixed(1)}%
|
|
44
|
-
</span>
|
|
45
|
-
</div>
|
|
46
|
-
\`);
|
|
47
|
-
`}}};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="5761";export const __rspack_esm_ids=["5761"];export const __webpack_modules__={32221(e,t,r){r.r(t),r.d(t,{JSItemRunJSContext:()=>i});var o=r(29007);class i extends o.uk{}i.define({label:"JSItem RunJS context",properties:{element:`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`}}),i.define({label:"JS 表单项 RunJS 上下文",properties:{element:"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"})},30008(e,t,r){r.r(t),r.d(t,{default:()=>o});let o={contexts:[r(32221).JSItemRunJSContext],prefix:"sn-link-visibility",label:"Toggle visible",description:"Show or hide another field within linkage scripts",locales:{"zh-CN":{label:"切换可见性",description:"在联动脚本中设置字段显示或隐藏"}},content:`
|
|
6
|
-
const targetFieldUid = 'FIELD_UID_OR_NAME';
|
|
7
|
-
const shouldHide = true;
|
|
8
|
-
|
|
9
|
-
const items = ctx.model?.subModels?.grid?.subModels?.items;
|
|
10
|
-
const candidates = Array.isArray(items)
|
|
11
|
-
? items
|
|
12
|
-
: Array.from(items?.values?.() || items || []);
|
|
13
|
-
const fieldModel =
|
|
14
|
-
candidates.find((item) => item?.uid === targetFieldUid) ||
|
|
15
|
-
candidates.find((item) => item?.props?.name === targetFieldUid);
|
|
16
|
-
|
|
17
|
-
if (!fieldModel) {
|
|
18
|
-
ctx.message?.warning?.(ctx.t('Field {{name}} not found', { name: targetFieldUid }));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fieldModel.setProps({ hiddenModel: shouldHide });
|
|
23
|
-
ctx.message?.success?.(
|
|
24
|
-
ctx.t(shouldHide ? 'Hidden field {{name}}' : 'Shown field {{name}}', {
|
|
25
|
-
name: fieldModel?.props?.label || targetFieldUid,
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
`}}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="6269";export const __rspack_esm_ids=["6269"];export const __webpack_modules__={96108(e,r,t){t.r(r),t.d(r,{JSColumnRunJSContext:()=>o});var n=t(29007);class o extends n.uk{}o.define({label:"JSColumn RunJS context",properties:{element:"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:"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"})}};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="6437";export const __rspack_esm_ids=["6437"];export const __webpack_modules__={32221(e,t,r){r.r(t),r.d(t,{JSItemRunJSContext:()=>n});var o=r(29007);class n extends o.uk{}n.define({label:"JSItem RunJS context",properties:{element:`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`}}),n.define({label:"JS 表单项 RunJS 上下文",properties:{element:"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"})},29924(e,t,r){r.r(t),r.d(t,{default:()=>o});let o={contexts:[r(32221).JSItemRunJSContext],prefix:"sn-jsitem-basic",label:"Render form item",description:"Render custom content inside a form item container",locales:{"zh-CN":{label:"渲染表单项",description:"在表单项容器中渲染自定义内容"}},content:`
|
|
6
|
-
ctx.render(\`
|
|
7
|
-
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6;">
|
|
8
|
-
<h3 style="color: #1890ff; margin: 0 0 12px 0; font-size: 18px; font-weight: 600;">\${ctx.t('JS Item')}</h3>
|
|
9
|
-
<div style="color:#555">\${ctx.t('This area is rendered by your JavaScript code.')}</div>
|
|
10
|
-
</div>
|
|
11
|
-
\`);
|
|
12
|
-
`}}};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="6738";export const __rspack_esm_ids=["6738"];export const __webpack_modules__={79271(e,t,r){r.r(t),r.d(t,{JSBlockRunJSContext:()=>a});var n=r(29007);class a extends n.uk{}a.define({label:"RunJS context",properties:{element:{description:`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.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},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`)."}}),a.define({label:"RunJS 上下文",properties:{element:{description:"ElementProxy,安全的 DOM 容器,支持 innerHTML/append 等",detail:"ElementProxy",properties:{innerHTML:"读取或设置容器的 HTML 内容"}},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"})},25481(e,t,r){r.r(t),r.d(t,{default:()=>n});let n={contexts:[r(79271).JSBlockRunJSContext],prefix:"sn-resource-example",label:"Resource example",description:"Create a resource via ctx.makeResource and render JSON output",locales:{"zh-CN":{label:"资源示例",description:"使用 ctx.initResource 加载数据并渲染 JSON 输出"}},content:`
|
|
7
|
-
// Create a resource and load a single record
|
|
8
|
-
const resource = ctx.makeResource('SingleRecordResource');
|
|
9
|
-
resource.setDataSourceKey('main');
|
|
10
|
-
resource.setResourceName('users');
|
|
11
|
-
// Optionally set filterByTk to target a specific record:
|
|
12
|
-
// resource.setRequestOptions('params', { filterByTk: 1 });
|
|
13
|
-
await resource.refresh();
|
|
14
|
-
|
|
15
|
-
ctx.render(\`
|
|
16
|
-
<pre style="padding: 12px; background: #f5f5f5; border-radius: 6px;">
|
|
17
|
-
\${JSON.stringify(resource.getData(), null, 2)}
|
|
18
|
-
</pre>
|
|
19
|
-
\`);
|
|
20
|
-
`}}};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="700";export const __rspack_esm_ids=["700"];export const __webpack_modules__={25831(e,t,o){o.r(t),o.d(t,{FormJSFieldItemRunJSContext:()=>a});var n=o(29007);class a extends n.uk{}a.define({label:"FormJSFieldItem RunJS context",properties:{element:`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" })`}}),a.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:"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,o){o.r(t),o.d(t,{JSFieldRunJSContext:()=>a});var n=o(29007);class a extends n.uk{}a.define({label:"JSField RunJS context",properties:{element:`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 })`}}),a.define({label:"JS 字段 RunJS 上下文",properties:{element:"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"})},99287(e,t,o){o.r(t),o.d(t,{default:()=>l});var n=o(98542),a=o(25831);let l={contexts:[n.JSFieldRunJSContext,a.FormJSFieldItemRunJSContext],prefix:"sn-jsf-value",label:"Display text field as highlighted text",description:"Render the current text field value with simple highlight styling",locales:{"zh-CN":{label:"将文本字段显示为高亮文本",description:"将字段值写入容器并添加高亮样式"}},content:`
|
|
13
|
-
const v = String(ctx.value ?? '');
|
|
14
|
-
ctx.render(\`<span class="nb-js-field-value" style="color:#1890ff;font-weight:600">\${v}</span>\`);
|
|
15
|
-
`}}};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const __rspack_esm_id="7021";export const __rspack_esm_ids=["7021"];export const __webpack_modules__={25831(e,t,o){o.r(t),o.d(t,{FormJSFieldItemRunJSContext:()=>a});var n=o(29007);class a extends n.uk{}a.define({label:"FormJSFieldItem RunJS context",properties:{element:`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" })`}}),a.define({label:"表单 JS 字段项 RunJS 上下文",properties:{element:"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,o){o.r(t),o.d(t,{JSFieldRunJSContext:()=>a});var n=o(29007);class a extends n.uk{}a.define({label:"JSField RunJS context",properties:{element:`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 })`}}),a.define({label:"JS 字段 RunJS 上下文",properties:{element:"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"})},37420(e,t,o){o.r(t),o.d(t,{default:()=>r});var n=o(98542),a=o(25831);let r={contexts:[n.JSFieldRunJSContext,a.FormJSFieldItemRunJSContext],prefix:"sn-jsf-relative-time",label:"Display date field as relative time",description:"Render date values as “3 days ago”, “just now”, etc.",locales:{"zh-CN":{label:"将日期字段显示为相对时间",description:"将日期显示为“3天前”、“刚刚”等相对时间"}},content:`
|
|
13
|
-
const formatRelativeTime = (date) => {
|
|
14
|
-
const now = new Date();
|
|
15
|
-
const diff = now - new Date(date);
|
|
16
|
-
const seconds = Math.floor(diff / 1000);
|
|
17
|
-
const minutes = Math.floor(seconds / 60);
|
|
18
|
-
const hours = Math.floor(minutes / 60);
|
|
19
|
-
const days = Math.floor(hours / 24);
|
|
20
|
-
const months = Math.floor(days / 30);
|
|
21
|
-
const years = Math.floor(days / 365);
|
|
22
|
-
|
|
23
|
-
if (seconds < 60) return ctx.t('just now');
|
|
24
|
-
if (minutes < 60) return ctx.t('{{count}} minutes ago', { count: minutes });
|
|
25
|
-
if (hours < 24) return ctx.t('{{count}} hours ago', { count: hours });
|
|
26
|
-
if (days < 30) return ctx.t('{{count}} days ago', { count: days });
|
|
27
|
-
if (months < 12) return ctx.t('{{count}} months ago', { count: months });
|
|
28
|
-
return ctx.t('{{count}} years ago', { count: years });
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const dateStr = ctx.value;
|
|
32
|
-
if (!dateStr) {
|
|
33
|
-
ctx.render('-');
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const relativeTime = formatRelativeTime(dateStr);
|
|
38
|
-
const fullDate = new Date(dateStr).toLocaleString();
|
|
39
|
-
|
|
40
|
-
ctx.render(\`
|
|
41
|
-
<span title="\${fullDate}" style="cursor: help; color: #666;">
|
|
42
|
-
\${relativeTime}
|
|
43
|
-
</span>
|
|
44
|
-
\`);
|
|
45
|
-
`}}};
|