@nocobase/app 2.0.0-alpha.7 → 2.0.0-alpha.9
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/113.736e29a0.async.js +7 -0
- package/dist/client/1145.0351040a.async.js +3 -0
- package/dist/client/1161.0b3b5766.async.js +40 -0
- package/dist/client/1442.be509f94.async.js +5 -0
- package/dist/client/1595.1827ce7f.async.js +45 -0
- package/dist/client/1758.eeeacf43.async.js +5 -0
- package/dist/client/1883.6ee256ab.async.js +17 -0
- package/dist/client/1905.ff0793ff.async.js +12 -0
- package/dist/client/2042.feb4b9ac.async.js +10 -0
- package/dist/client/2097.5a49892c.async.js +12 -0
- package/dist/client/{2190.90c718a9.async.js → 2190.4f5395e5.async.js} +1 -1
- package/dist/client/2380.900b7a22.async.js +15 -0
- package/dist/client/2612.0865e67e.async.js +19 -0
- package/dist/client/2775.455c3402.async.js +47 -0
- package/dist/client/2936.902710e4.async.js +28 -0
- package/dist/client/3357.be95167c.async.js +28 -0
- package/dist/client/341.fba65e23.async.js +28 -0
- package/dist/client/3451.a9466e73.async.js +24 -0
- package/dist/client/4327.68c0f17b.async.js +16 -0
- package/dist/client/4351.efe05af2.async.js +15 -0
- package/dist/client/4666.fb83d11a.async.js +9 -0
- package/dist/client/4727.0f6df8fb.async.js +1 -0
- package/dist/client/4750.044f647b.async.js +32 -0
- package/dist/client/4926.58238954.async.js +17 -0
- package/dist/client/5013.b14730ba.async.js +3 -0
- package/dist/client/5501.22d50b3a.async.js +23 -0
- package/dist/client/5662.8c643e63.async.js +26 -0
- package/dist/client/5950.179a885e.async.js +4 -0
- package/dist/client/6021.cdefa0d3.async.js +22 -0
- package/dist/client/645.ea6376fe.async.js +60 -0
- package/dist/client/6474.49632e37.async.js +21 -0
- package/dist/client/6534.6ea6468b.async.js +33 -0
- package/dist/client/6747.de538558.async.js +22 -0
- package/dist/client/689.4de33d65.async.js +3 -0
- package/dist/client/6920.497d7e80.async.js +59 -0
- package/dist/client/6996.ae27c9d6.async.js +9 -0
- package/dist/client/703.20003a5c.async.js +17 -0
- package/dist/client/7087.5646e199.async.js +6 -0
- package/dist/client/7197.bb3092b2.async.js +35 -0
- package/dist/client/7483.546ddcb6.async.js +23 -0
- package/dist/client/7534.0d69e071.async.js +34 -0
- package/dist/client/8183.4c6f7e21.async.js +12 -0
- package/dist/client/8408.c0ef773c.async.js +84 -0
- package/dist/client/8805.819c4f44.async.js +20 -0
- package/dist/client/9017.4ae5c322.async.js +6 -0
- package/dist/client/9042.3d21f631.async.js +45 -0
- package/dist/client/908.0e8c8a54.async.js +14 -0
- package/dist/client/9317.fe6ffa9a.async.js +13 -0
- package/dist/client/935.97d45ffa.async.js +27 -0
- package/dist/client/95.24aa76c4.async.js +6 -0
- package/dist/client/9547.a442df93.async.js +25 -0
- package/dist/client/9801.34b13a74.async.js +9 -0
- package/dist/client/9844.6f484975.async.js +37 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.tpl +1 -1
- package/dist/client/{npm._at_umijs.47085d01.async.js → npm._at_umijs.f64c1387.async.js} +1 -1
- package/dist/client/{npm.highlight.js.c1f693ec.async.js → npm.highlight.js.d3beb708.async.js} +1 -1
- package/dist/client/{npm.htmlparser2.a2f8d64d.async.js → npm.htmlparser2.ee1fb042.async.js} +1 -1
- package/dist/client/p__index.07478c80.async.js +2272 -0
- package/dist/client/{umi.743c1d73.js → umi.d90bd9c6.js} +2 -2
- package/package.json +6 -6
- package/dist/client/1145.4029b0be.async.js +0 -3
- package/dist/client/1617.dd671a87.async.js +0 -6
- package/dist/client/1833.82373d30.async.js +0 -6
- package/dist/client/2134.1d86e440.async.js +0 -5
- package/dist/client/2498.be8b1194.async.js +0 -7
- package/dist/client/260.5b02a0a5.async.js +0 -4
- package/dist/client/2953.2e77d77c.async.js +0 -24
- package/dist/client/3170.6147bd19.async.js +0 -24
- package/dist/client/3255.e6303833.async.js +0 -10
- package/dist/client/3520.81fd6362.async.js +0 -24
- package/dist/client/3522.674f2264.async.js +0 -4
- package/dist/client/4088.0568ef31.async.js +0 -5
- package/dist/client/4205.c3eac46d.async.js +0 -9
- package/dist/client/4644.ae01f8a6.async.js +0 -4
- package/dist/client/4666.d20ff352.async.js +0 -8
- package/dist/client/4840.477401f9.async.js +0 -8
- package/dist/client/5068.72e9d750.async.js +0 -5
- package/dist/client/5087.468f5500.async.js +0 -6
- package/dist/client/5950.b83f8586.async.js +0 -4
- package/dist/client/6416.361c93ff.async.js +0 -4
- package/dist/client/6472.ac05f778.async.js +0 -7
- package/dist/client/6779.47fc1971.async.js +0 -10
- package/dist/client/6816.1ff200ac.async.js +0 -5
- package/dist/client/6996.836a3f7f.async.js +0 -8
- package/dist/client/7463.70ca58ce.async.js +0 -20
- package/dist/client/7522.1f91be5c.async.js +0 -23
- package/dist/client/7596.232a7185.async.js +0 -10
- package/dist/client/7688.85d6d7bb.async.js +0 -4
- package/dist/client/8106.829fd6b5.async.js +0 -10
- package/dist/client/8541.e3110aaa.async.js +0 -8
- package/dist/client/9017.28eacc5a.async.js +0 -6
- package/dist/client/937.a55819ab.async.js +0 -5
- package/dist/client/9462.ea2d8827.async.js +0 -35
- package/dist/client/9489.25ca39a9.async.js +0 -7
- package/dist/client/9663.c04b2ad1.async.js +0 -5
- package/dist/client/9729.0d7a5c47.async.js +0 -8
- package/dist/client/9848.18f8d3db.async.js +0 -4
- package/dist/client/p__index.900597dd.async.js +0 -2316
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[113],{40113:function(h,o,e){e.r(o),e.d(o,{JSFieldRunJSContext:function(){return n}});var l=e(72004),a=e.n(l),t=e(12444),r=e.n(t),s=e(31996),u=e.n(s),d=e(26037),i=e.n(d),m=e(1772),n=function(c){u()(_,c);var b=i()(_);function _(){return r()(this,_),b.apply(this,arguments)}return a()(_)}(m.Uo);n.define({label:"JSField RunJS context",properties:{element:`ElementProxy instance providing a safe DOM container for field rendering.
|
|
2
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,value:`Current value of the field (read-only).
|
|
3
|
+
Contains the data value stored in this field.`,record:`Current record data object (read-only).
|
|
4
|
+
Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
|
|
5
|
+
Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
|
|
6
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
7
|
+
Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`}}),n.define({label:"JS \u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",value:"\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF0C\u5305\u542B\u7236\u8BB0\u5F55\u5168\u90E8\u5B57\u6BB5\u503C\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF0C\u63CF\u8FF0\u5B57\u6BB5\u6240\u5C5E\u96C6\u5408\u7684 Schema\uFF09"},methods:{onRefReady:"\u5728\u5B57\u6BB5\u5BB9\u5668 DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)\uFF1B\u793A\u4F8B\uFF1Actx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})}}]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1145],{41145:function(n,e,s){s.r(e);var c={contexts:["*"],prefix:"sn-msg",label:"Message success",description:"Show a success toast message",locales:{"zh-CN":{label:"\u6210\u529F\u6D88\u606F\u63D0\u793A",description:"\u663E\u793A\u4E00\u6761\u6210\u529F\u63D0\u793A\u6D88\u606F"}},content:`
|
|
2
|
+
ctx.message.success(ctx.t('Operation succeeded'));
|
|
3
|
+
`};e.default=c}}]);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1161,1442],{41442:function(s,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return r}});var _=e(72004),t=e.n(_),a=e(12444),l=e.n(a),d=e(31996),u=e.n(d),m=e(26037),i=e.n(m),c=e(1772),r=function(b){u()(o,b);var p=i()(o);function o(){return l()(this,o),p.apply(this,arguments)}return t()(o)}(c.Uo);r.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.`},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`}}),r.define({label:"JS \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},91161:function(s,n,e){e.r(n);var _=e(41442),t={contexts:[_.JSItemRunJSContext],prefix:"sn-link-cascade",label:"Cascade select (load child roles)",description:"Load child roles based on the selected parent role",locales:{"zh-CN":{label:"\u7EA7\u8054\u9009\u62E9\uFF08\u52A0\u8F7D\u5B50\u89D2\u8272\uFF09",description:"\u6839\u636E\u9009\u62E9\u7684\u7236\u89D2\u8272\u52A0\u8F7D\u5BF9\u5E94\u5B50\u89D2\u8272"}},content:`
|
|
6
|
+
// Get selected parent role (adjust field name to match your form)
|
|
7
|
+
const parentRoleId = ctx.record?.parentRole?.id;
|
|
8
|
+
|
|
9
|
+
if (!parentRoleId) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const res = await ctx.api.request({
|
|
14
|
+
url: 'roles:list',
|
|
15
|
+
method: 'get',
|
|
16
|
+
params: {
|
|
17
|
+
pageSize: 100,
|
|
18
|
+
filter: {
|
|
19
|
+
parentId: parentRoleId,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const childRoles = res?.data?.data || [];
|
|
25
|
+
|
|
26
|
+
const items = ctx.model?.subModels?.grid?.subModels?.items;
|
|
27
|
+
const candidates = Array.isArray(items) ? items : Array.from(items?.values?.() || items || []);
|
|
28
|
+
|
|
29
|
+
const roleField = candidates.find((item) => item?.props?.name === 'role');
|
|
30
|
+
|
|
31
|
+
if (roleField) {
|
|
32
|
+
roleField.setProps({
|
|
33
|
+
dataSource: childRoles.map((role) => ({
|
|
34
|
+
value: role.id,
|
|
35
|
+
label: role.name,
|
|
36
|
+
})),
|
|
37
|
+
value: undefined,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1442],{41442:function(h,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return o}});var r=e(72004),s=e.n(r),t=e(12444),a=e.n(t),l=e(31996),u=e.n(l),m=e(26037),d=e.n(m),i=e(1772),o=function(b){u()(_,b);var c=d()(_);function _(){return a()(this,_),c.apply(this,arguments)}return s()(_)}(i.Uo);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.`},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 \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})}}]);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1595,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return _}});var o=e(72004),r=e.n(o),l=e(12444),s=e.n(l),i=e(31996),c=e.n(i),d=e(26037),m=e.n(d),u=e(1772),_=function(b){c()(t,b);var p=m()(t);function t(){return s()(this,t),p.apply(this,arguments)}return r()(t)}(u.Uo);_.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 ESM module: `const mod = await ctx.importAsync(url)`"}}),_.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},41595:function(a,n,e){e.r(n);var o=e(10095),r={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-timeline",label:"Render timeline from records",description:"Display records as a timeline using Ant Design Timeline",locales:{"zh-CN":{label:"\u6E32\u67D3\u65F6\u95F4\u8F74",description:"\u4F7F\u7528 Ant Design \u65F6\u95F4\u8F74\u7EC4\u4EF6\u663E\u793A\u8BB0\u5F55\u5386\u53F2"}},content:`
|
|
7
|
+
const { Timeline, Card } = ctx.antd;
|
|
8
|
+
const { createElement: h } = ctx.React;
|
|
9
|
+
|
|
10
|
+
const res = await ctx.api.request({
|
|
11
|
+
url: 'users:list',
|
|
12
|
+
method: 'get',
|
|
13
|
+
params: {
|
|
14
|
+
pageSize: 20,
|
|
15
|
+
sort: ['-createdAt'],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const records = res?.data?.data || [];
|
|
20
|
+
|
|
21
|
+
if (!records.length) {
|
|
22
|
+
ctx.element.innerHTML = '<div style="padding:16px;color:#999;">' + ctx.t('No data') + '</div>';
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ctx.ReactDOM.createRoot(ctx.element).render(
|
|
27
|
+
h(Card, { title: ctx.t('Activity Timeline'), bordered: true },
|
|
28
|
+
h(Timeline, { mode: 'left' },
|
|
29
|
+
...records.map(record =>
|
|
30
|
+
h(Timeline.Item, {
|
|
31
|
+
key: record.id,
|
|
32
|
+
label: record.createdAt ? new Date(record.createdAt).toLocaleString() : '',
|
|
33
|
+
},
|
|
34
|
+
h('div', {},
|
|
35
|
+
h('strong', {}, record.nickname || record.username || ctx.t('Unnamed user')),
|
|
36
|
+
record.email
|
|
37
|
+
? h('div', { style: { color: '#999', fontSize: '12px', marginTop: '4px' } }, record.email)
|
|
38
|
+
: null,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
`};n.default=r}}]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1758],{51758:function(s,e,n){n.r(e);var a={contexts:["*"],prefix:"sn-require",label:"Load AMD module",description:"Dynamically load an AMD/RequireJS module by URL",locales:{"zh-CN":{label:"\u52A0\u8F7D AMD \u6A21\u5757",description:"\u901A\u8FC7 RequireJS \u6309 URL \u52A8\u6001\u52A0\u8F7D AMD \u6A21\u5757"}},content:`
|
|
2
|
+
// Load an external library (AMD/RequireJS)
|
|
3
|
+
const dayjs = await ctx.requireAsync('https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js');
|
|
4
|
+
console.log('dayjs loaded:', dayjs?.default || dayjs);
|
|
5
|
+
`};e.default=a}}]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1883,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),l=e(12444),s=e.n(l),i=e(31996),c=e.n(i),m=e(26037),u=e.n(m),d=e(1772),_=function(b){c()(o,b);var h=u()(o);function o(){return s()(this,o),h.apply(this,arguments)}return r()(o)}(d.Uo);_.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 ESM module: `const mod = await ctx.importAsync(url)`"}}),_.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},61883:function(a,n,e){e.r(n);var t=e(10095),r={contexts:[t.JSBlockRunJSContext],prefix:"sn-jsb-iframe",label:"Render iframe",description:"Embed example.com as a sandboxed iframe inside the block element",locales:{"zh-CN":{label:"\u6E32\u67D3 iframe",description:"\u5728\u533A\u5757\u4E2D\u4EE5 sandbox \u9650\u5236\u5D4C\u5165 example.com \u9875\u9762"}},content:`
|
|
7
|
+
// Create an iframe that fills the current block container
|
|
8
|
+
const iframe = document.createElement('iframe');
|
|
9
|
+
iframe.src = 'https://example.com';
|
|
10
|
+
iframe.setAttribute('sandbox', 'allow-scripts');
|
|
11
|
+
iframe.style.width = '100%';
|
|
12
|
+
iframe.style.height = '100%';
|
|
13
|
+
iframe.style.border = 'none';
|
|
14
|
+
|
|
15
|
+
// Replace existing children so the iframe is the only content
|
|
16
|
+
ctx.element.replaceChildren(iframe);
|
|
17
|
+
`};n.default=r}}]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[1905,1442],{41442:function(r,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return s}});var _=e(72004),t=e.n(_),a=e(12444),l=e.n(a),m=e(31996),u=e.n(m),i=e(26037),d=e.n(i),c=e(1772),s=function(b){u()(o,b);var h=d()(o);function o(){return l()(this,o),h.apply(this,arguments)}return t()(o)}(c.Uo);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.`},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 \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},71905:function(r,n,e){e.r(n);var _=e(41442),t={contexts:[_.JSItemRunJSContext],prefix:"sn-jsitem-basic",label:"Render form item",description:"Render custom content inside a form item container",locales:{"zh-CN":{label:"\u6E32\u67D3\u8868\u5355\u9879",description:"\u5728\u8868\u5355\u9879\u5BB9\u5668\u4E2D\u6E32\u67D3\u81EA\u5B9A\u4E49\u5185\u5BB9"}},content:`
|
|
6
|
+
ctx.element.innerHTML = \`
|
|
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
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2042,689],{689:function(l,_,e){e.r(_),e.d(_,{JSCollectionActionRunJSContext:function(){return t}});var n=e(72004),s=e.n(n),r=e(12444),u=e.n(r),a=e(31996),c=e.n(a),i=e(26037),d=e.n(i),m=e(1772),t=function(b){c()(o,b);var C=d()(o);function o(){return u()(this,o),C.apply(this,arguments)}return s()(o)}(m.Uo);t.define({label:"JSCollectionAction RunJS context",properties:{resource:`Collection resource instance providing access to selected rows, pagination, and data operations.
|
|
2
|
+
Use ctx.resource.selectedRows to get selected records.
|
|
3
|
+
Use ctx.resource.pagination for page info.`}}),t.define({label:"JS \u96C6\u5408\u52A8\u4F5C RunJS \u4E0A\u4E0B\u6587",properties:{resource:"\u5217\u8868\u8D44\u6E90\uFF08\u5305\u542B\u9009\u4E2D\u884C/\u5206\u9875\u4FE1\u606F\u7B49\uFF09"}},{locale:"zh-CN"})},32042:function(l,_,e){e.r(_);var n=e(689),s={contexts:[n.JSCollectionActionRunJSContext],prefix:"sn-act-selected-count",label:"Selected count",description:"Show number of selected rows in list action",locales:{"zh-CN":{label:"\u9009\u4E2D\u6570\u91CF",description:"\u63D0\u793A\u5F53\u524D\u9009\u4E2D\u884C\u7684\u6570\u91CF"}},content:`
|
|
4
|
+
const rows = ctx.resource?.getSelectedRows?.() || [];
|
|
5
|
+
if (!rows.length) {
|
|
6
|
+
ctx.message.warning(ctx.t('Please select data'));
|
|
7
|
+
} else {
|
|
8
|
+
ctx.message.success(ctx.t('Selected {{count}} rows', { count: rows.length }));
|
|
9
|
+
}
|
|
10
|
+
`};_.default=s}}]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2097,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return r}});var o=e(72004),_=e.n(o),s=e(12444),l=e.n(s),c=e(31996),i=e.n(c),u=e(26037),d=e.n(u),m=e(1772),r=function(b){i()(t,b);var h=d()(t);function t(){return l()(this,t),h.apply(this,arguments)}return _()(t)}(m.Uo);r.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 ESM module: `const mod = await ctx.importAsync(url)`"}}),r.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},82097:function(a,n,e){e.r(n);var o=e(10095),_={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-button",label:"Render button handler",description:"Render a button and handle click events inside the block",locales:{"zh-CN":{label:"\u6309\u94AE\u4E8B\u4EF6\u5904\u7406",description:"\u5728\u533A\u5757\u4E2D\u6E32\u67D3\u6309\u94AE\u5E76\u7ED1\u5B9A\u70B9\u51FB\u5904\u7406\u903B\u8F91"}},content:`
|
|
7
|
+
const { React, ReactDOM, antd } = ctx;
|
|
8
|
+
const { Button } = antd;
|
|
9
|
+
|
|
10
|
+
const node = React.createElement(Button, { type: 'primary', onClick: () => ctx.message.success(ctx.t('Clicked!')) }, ctx.t('Button'));
|
|
11
|
+
ReactDOM.createRoot(ctx.element).render(node);
|
|
12
|
+
`};n.default=_}}]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2190],{42190:function(r,e,s){s.r(e);var n={contexts:["*"],prefix:"sn-msg-error",label:"Message error",description:"Show an error toast message",content:`
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2190],{42190:function(r,e,s){s.r(e);var n={contexts:["*"],prefix:"sn-msg-error",label:"Message error",description:"Show an error toast message",locales:{"zh-CN":{label:"\u9519\u8BEF\u6D88\u606F\u63D0\u793A",description:"\u663E\u793A\u4E00\u6761\u9519\u8BEF\u63D0\u793A\u6D88\u606F"}},content:`
|
|
2
2
|
ctx.message.error(ctx.t('Operation failed'));
|
|
3
3
|
`};e.default=n}}]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2380,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return r}});var o=e(72004),_=e.n(o),l=e(12444),s=e.n(l),i=e(31996),c=e.n(i),d=e(26037),u=e.n(d),m=e(1772),r=function(b){c()(t,b);var p=u()(t);function t(){return s()(this,t),p.apply(this,arguments)}return _()(t)}(m.Uo);r.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 ESM module: `const mod = await ctx.importAsync(url)`"}}),r.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},12380:function(a,n,e){e.r(n);var o=e(10095),_={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-click",label:"Add click listener",description:"Render a button and bind a click event handler",locales:{"zh-CN":{label:"\u6DFB\u52A0\u70B9\u51FB\u76D1\u542C",description:"\u6E32\u67D3\u6309\u94AE\u5E76\u7ED1\u5B9A\u70B9\u51FB\u4E8B\u4EF6\u5904\u7406"}},content:`
|
|
7
|
+
// Render a button and bind a click handler
|
|
8
|
+
ctx.element.innerHTML = \`
|
|
9
|
+
<button id="nb-jsb-btn" style="padding:6px 12px">\${ctx.t('Click me')}</button>
|
|
10
|
+
\`;
|
|
11
|
+
const btn = document.getElementById('nb-jsb-btn');
|
|
12
|
+
if (btn) {
|
|
13
|
+
btn.addEventListener('click', () => ctx.message.success(ctx.t('Clicked!')));
|
|
14
|
+
}
|
|
15
|
+
`};n.default=_}}]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2612,4727],{64727:function(l,n,e){e.r(n),e.d(n,{JSColumnRunJSContext:function(){return r}});var t=e(72004),_=e.n(t),a=e(12444),s=e.n(a),i=e(31996),c=e.n(i),d=e(26037),u=e.n(d),m=e(1772),r=function(b){c()(o,b);var p=u()(o);function o(){return s()(this,o),p.apply(this,arguments)}return _()(o)}(m.Uo);r.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)`"}}),r.define({label:"JS \u5217 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u683C\u5355\u5143\u683C\u7684\u5B89\u5168 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",record:"\u5F53\u524D\u884C\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF09",recordIndex:"\u5F53\u524D\u884C\u7D22\u5F15\uFF08\u4ECE 0 \u5F00\u59CB\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF09",viewer:"\u89C6\u56FE\u63A7\u5236\u5668\uFF0C\u53EF\u7528\u4E8E\u5728\u5355\u5143\u683C\u4E2D\u89E6\u53D1\u62BD\u5C49/\u5BF9\u8BDD\u6846/\u5185\u5D4C\u7B49\u4EA4\u4E92",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u7B49\u5F85\u5355\u5143\u683C DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)",requireAsync:"\u6309 URL \u5F02\u6B65\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},82612:function(l,n,e){e.r(n);var t=e(64727),_={contexts:[t.JSColumnRunJSContext],prefix:"sn-col-open-dialog",label:"Cell dialog with row data",description:"Render a button in cell to open dialog via ctx.openView with current row context",locales:{"zh-CN":{label:"\u5355\u5143\u683C\u5BF9\u8BDD\u6846\uFF08\u663E\u793A\u884C\u6570\u636E\uFF09",description:"\u5728\u5355\u5143\u683C\u6E32\u67D3\u6309\u94AE\uFF0C\u70B9\u51FB\u540E\u901A\u8FC7 ctx.openView \u6253\u5F00\u5F39\u7A97\u5E76\u4F20\u5165\u5F53\u524D\u884C\u4E0A\u4E0B\u6587"}},content:`
|
|
2
|
+
// Render a button inside the cell
|
|
3
|
+
ctx.element.innerHTML = '<button class="nb-cell-btn" style="padding:4px 8px">' + ctx.t('View') + '</button>';
|
|
4
|
+
|
|
5
|
+
const button = ctx.element.querySelector('.nb-cell-btn');
|
|
6
|
+
const popupUid = ctx.model.uid + '-1'; // popupUid should be stable and better bound to ctx.model.uid
|
|
7
|
+
const primaryKey = ctx.collection?.primaryKey || 'id';
|
|
8
|
+
|
|
9
|
+
button?.addEventListener('click', async () => {
|
|
10
|
+
await ctx.openView(popupUid, {
|
|
11
|
+
mode: 'dialog',
|
|
12
|
+
title: ctx.t('Row detail'),
|
|
13
|
+
params: {
|
|
14
|
+
filterByTk: ctx.record?.[primaryKey],
|
|
15
|
+
record: ctx.record,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
`};n.default=_}}]);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2775,113,7087],{67087:function(f,o,e){e.r(o),e.d(o,{FormJSFieldItemRunJSContext:function(){return _}});var t=e(72004),l=e.n(t),r=e(12444),a=e.n(r),s=e(31996),d=e.n(s),u=e(26037),i=e.n(u),m=e(1772),_=function(c){d()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return l()(n)}(m.Uo);_.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.`},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" })`}}),_.define({label:"\u8868\u5355 JS \u5B57\u6BB5\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u5B57\u6BB5\u5BB9\u5668",value:"\u5B57\u6BB5\u503C\uFF08\u5C55\u793A\u6A21\u5F0F\u4E3A\u53EA\u8BFB\uFF1B\u53D7\u63A7\u573A\u666F\u7528 setProps \u4FEE\u6539\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u56DE\u8C03",setProps:"\u8BBE\u7F6E\u8868\u5355\u9879\u5C5E\u6027\uFF1A`setProps(fieldModel, { value })`\uFF08\u7531\u8054\u52A8/\u8868\u5355\u4E0A\u4E0B\u6587\u63D0\u4F9B\uFF09"}},{locale:"zh-CN"})},40113:function(f,o,e){e.r(o),e.d(o,{JSFieldRunJSContext:function(){return _}});var t=e(72004),l=e.n(t),r=e(12444),a=e.n(r),s=e(31996),d=e.n(s),u=e(26037),i=e.n(u),m=e(1772),_=function(c){d()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return l()(n)}(m.Uo);_.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 })`}}),_.define({label:"JS \u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",value:"\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF0C\u5305\u542B\u7236\u8BB0\u5F55\u5168\u90E8\u5B57\u6BB5\u503C\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF0C\u63CF\u8FF0\u5B57\u6BB5\u6240\u5C5E\u96C6\u5408\u7684 Schema\uFF09"},methods:{onRefReady:"\u5728\u5B57\u6BB5\u5BB9\u5668 DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)\uFF1B\u793A\u4F8B\uFF1Actx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},72775:function(f,o,e){e.r(o);var t=e(40113),l=e(67087),r={contexts:[t.JSFieldRunJSContext,l.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:"\u5C06\u6570\u5B57\u5B57\u6BB5\u663E\u793A\u4E3A\u767E\u5206\u6BD4\u8FDB\u5EA6\u6761",description:"\u5C06\u6570\u5B57\u683C\u5F0F\u5316\u4E3A\u767E\u5206\u6BD4\u5E76\u663E\u793A\u8FDB\u5EA6\u6761"}},content:`
|
|
13
|
+
const value = Number(ctx.value ?? 0);
|
|
14
|
+
|
|
15
|
+
if (!Number.isFinite(value)) {
|
|
16
|
+
ctx.element.innerHTML = '-';
|
|
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.element.innerHTML = \`
|
|
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
|
+
`};o.default=r}}]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[2936,1442],{41442:function(s,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return r}});var _=e(72004),t=e.n(_),a=e(12444),l=e.n(a),d=e(31996),i=e.n(d),u=e(26037),m=e.n(u),c=e(1772),r=function(b){i()(o,b);var f=m()(o);function o(){return l()(this,o),f.apply(this,arguments)}return t()(o)}(c.Uo);r.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.`},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`}}),r.define({label:"JS \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},42936:function(s,n,e){e.r(n);var _=e(41442),t={contexts:[_.JSItemRunJSContext],prefix:"sn-link-required",label:"Set required",description:"Toggle required rule for another field within linkage",locales:{"zh-CN":{label:"\u8BBE\u7F6E\u5FC5\u586B",description:"\u5728\u8054\u52A8\u811A\u672C\u4E2D\u63A7\u5236\u5B57\u6BB5\u662F\u5426\u5FC5\u586B"}},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
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[3357,1442],{41442:function(r,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return s}});var _=e(72004),t=e.n(_),a=e(12444),l=e.n(a),d=e(31996),i=e.n(d),m=e(26037),u=e.n(m),c=e(1772),s=function(b){i()(o,b);var h=u()(o);function o(){return l()(this,o),h.apply(this,arguments)}return t()(o)}(c.Uo);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.`},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 \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},93357:function(r,n,e){e.r(n);var _=e(41442),t={contexts:[_.JSItemRunJSContext],prefix:"sn-link-visibility",label:"Toggle visible",description:"Show or hide another field within linkage scripts",locales:{"zh-CN":{label:"\u5207\u6362\u53EF\u89C1\u6027",description:"\u5728\u8054\u52A8\u811A\u672C\u4E2D\u8BBE\u7F6E\u5B57\u6BB5\u663E\u793A\u6216\u9690\u85CF"}},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
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[341,1442],{41442:function(r,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return s}});var _=e(72004),t=e.n(_),a=e(12444),l=e.n(a),d=e(31996),i=e.n(d),m=e(26037),u=e.n(m),c=e(1772),s=function(b){i()(o,b);var f=u()(o);function o(){return l()(this,o),f.apply(this,arguments)}return t()(o)}(c.Uo);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.`},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 \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},10341:function(r,n,e){e.r(n);var _=e(41442),t={contexts:[_.JSItemRunJSContext],prefix:"sn-link-disable",label:"Set disabled",description:"Enable or disable another field in linkage scripts",locales:{"zh-CN":{label:"\u8BBE\u7F6E\u7981\u7528",description:"\u5728\u8054\u52A8\u811A\u672C\u4E2D\u542F\u7528\u6216\u7981\u7528\u5B57\u6BB5"}},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
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[3451,95],{10095:function(_,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return a}});var o=e(72004),r=e.n(o),s=e(12444),l=e.n(s),i=e(31996),c=e.n(i),d=e(26037),u=e.n(d),m=e(1772),a=function(b){c()(t,b);var p=u()(t);function t(){return l()(this,t),p.apply(this,arguments)}return r()(t)}(m.Uo);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 ESM module: `const mod = await ctx.importAsync(url)`"}}),a.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},3451:function(_,n,e){e.r(n);var o=e(10095),r={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-fetch-list",label:"Fetch & render list",description:"Fetch a small list via ctx.api and render basic HTML",locales:{"zh-CN":{label:"\u62C9\u53D6\u5E76\u6E32\u67D3\u5217\u8868",description:"\u4F7F\u7528 ctx.api \u62C9\u53D6\u5C11\u91CF\u6570\u636E\uFF0C\u5E76\u6E32\u67D3\u57FA\u7840 HTML \u5217\u8868"}},content:`
|
|
7
|
+
// Fetch users
|
|
8
|
+
const { data } = await ctx.api.request({
|
|
9
|
+
url: 'users:list',
|
|
10
|
+
method: 'get',
|
|
11
|
+
params: { pageSize: 5 },
|
|
12
|
+
});
|
|
13
|
+
const rows = Array.isArray(data?.data) ? data.data : (Array.isArray(data) ? data : []);
|
|
14
|
+
|
|
15
|
+
// Render as a simple HTML list
|
|
16
|
+
ctx.element.innerHTML = [
|
|
17
|
+
'<div style="padding:12px">',
|
|
18
|
+
'<h4 style="margin:0 0 8px">' + ctx.t('Users') + '</h4>',
|
|
19
|
+
'<ul style="margin:0; padding-left:20px">',
|
|
20
|
+
...rows.map((r, i) => '<li>#' + (i + 1) + ': ' + String((r && (r.nickname ?? r.username ?? r.id)) ?? '') + '</li>'),
|
|
21
|
+
'</ul>',
|
|
22
|
+
'</div>'
|
|
23
|
+
].join('');
|
|
24
|
+
`};n.default=r}}]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4327,113,7087],{67087:function(f,n,e){e.r(n),e.d(n,{FormJSFieldItemRunJSContext:function(){return o}});var l=e(72004),r=e.n(l),t=e(12444),s=e.n(t),a=e(31996),u=e.n(a),d=e(26037),m=e.n(d),i=e(1772),o=function(b){u()(_,b);var c=m()(_);function _(){return s()(this,_),c.apply(this,arguments)}return r()(_)}(i.Uo);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.`},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:"\u8868\u5355 JS \u5B57\u6BB5\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u5B57\u6BB5\u5BB9\u5668",value:"\u5B57\u6BB5\u503C\uFF08\u5C55\u793A\u6A21\u5F0F\u4E3A\u53EA\u8BFB\uFF1B\u53D7\u63A7\u573A\u666F\u7528 setProps \u4FEE\u6539\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u56DE\u8C03",setProps:"\u8BBE\u7F6E\u8868\u5355\u9879\u5C5E\u6027\uFF1A`setProps(fieldModel, { value })`\uFF08\u7531\u8054\u52A8/\u8868\u5355\u4E0A\u4E0B\u6587\u63D0\u4F9B\uFF09"}},{locale:"zh-CN"})},40113:function(f,n,e){e.r(n),e.d(n,{JSFieldRunJSContext:function(){return o}});var l=e(72004),r=e.n(l),t=e(12444),s=e.n(t),a=e(31996),u=e.n(a),d=e(26037),m=e.n(d),i=e(1772),o=function(b){u()(_,b);var c=m()(_);function _(){return s()(this,_),c.apply(this,arguments)}return r()(_)}(i.Uo);o.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 })`}}),o.define({label:"JS \u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",value:"\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF0C\u5305\u542B\u7236\u8BB0\u5F55\u5168\u90E8\u5B57\u6BB5\u503C\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF0C\u63CF\u8FF0\u5B57\u6BB5\u6240\u5C5E\u96C6\u5408\u7684 Schema\uFF09"},methods:{onRefReady:"\u5728\u5B57\u6BB5\u5BB9\u5668 DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)\uFF1B\u793A\u4F8B\uFF1Actx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},65:function(f,n,e){e.r(n);var l=e(40113),r=e(67087),t={contexts:[l.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext],prefix:"sn-jsf-num",label:"Display number field as localized number",description:"Format numeric values with locale-aware separators before rendering",locales:{"zh-CN":{label:"\u5C06\u6570\u5B57\u5B57\u6BB5\u663E\u793A\u4E3A\u672C\u5730\u5316\u683C\u5F0F",description:"\u6309\u672C\u5730\u5316\u683C\u5F0F\u8F93\u51FA\u6570\u503C"}},content:`
|
|
13
|
+
// Format number using locale
|
|
14
|
+
const n = Number(ctx.value ?? 0);
|
|
15
|
+
ctx.element.innerHTML = String(Number.isFinite(n) ? n.toLocaleString() : ctx.value ?? '');
|
|
16
|
+
`};n.default=t}}]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4351,113,7087],{67087:function(f,n,e){e.r(n),e.d(n,{FormJSFieldItemRunJSContext:function(){return o}});var l=e(72004),t=e.n(l),s=e(12444),r=e.n(s),a=e(31996),d=e.n(a),u=e(26037),i=e.n(u),m=e(1772),o=function(c){d()(_,c);var b=i()(_);function _(){return r()(this,_),b.apply(this,arguments)}return t()(_)}(m.Uo);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.`},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:"\u8868\u5355 JS \u5B57\u6BB5\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u5B57\u6BB5\u5BB9\u5668",value:"\u5B57\u6BB5\u503C\uFF08\u5C55\u793A\u6A21\u5F0F\u4E3A\u53EA\u8BFB\uFF1B\u53D7\u63A7\u573A\u666F\u7528 setProps \u4FEE\u6539\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u56DE\u8C03",setProps:"\u8BBE\u7F6E\u8868\u5355\u9879\u5C5E\u6027\uFF1A`setProps(fieldModel, { value })`\uFF08\u7531\u8054\u52A8/\u8868\u5355\u4E0A\u4E0B\u6587\u63D0\u4F9B\uFF09"}},{locale:"zh-CN"})},40113:function(f,n,e){e.r(n),e.d(n,{JSFieldRunJSContext:function(){return o}});var l=e(72004),t=e.n(l),s=e(12444),r=e.n(s),a=e(31996),d=e.n(a),u=e(26037),i=e.n(u),m=e(1772),o=function(c){d()(_,c);var b=i()(_);function _(){return r()(this,_),b.apply(this,arguments)}return t()(_)}(m.Uo);o.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 })`}}),o.define({label:"JS \u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",value:"\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF0C\u5305\u542B\u7236\u8BB0\u5F55\u5168\u90E8\u5B57\u6BB5\u503C\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF0C\u63CF\u8FF0\u5B57\u6BB5\u6240\u5C5E\u96C6\u5408\u7684 Schema\uFF09"},methods:{onRefReady:"\u5728\u5B57\u6BB5\u5BB9\u5668 DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)\uFF1B\u793A\u4F8B\uFF1Actx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},4351:function(f,n,e){e.r(n);var l=e(40113),t=e(67087),s={contexts:[l.JSFieldRunJSContext,t.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:"\u5C06\u6587\u672C\u5B57\u6BB5\u663E\u793A\u4E3A\u9AD8\u4EAE\u6587\u672C",description:"\u5C06\u5B57\u6BB5\u503C\u5199\u5165\u5BB9\u5668\u5E76\u6DFB\u52A0\u9AD8\u4EAE\u6837\u5F0F"}},content:`
|
|
13
|
+
const v = String(ctx.value ?? '');
|
|
14
|
+
ctx.element.innerHTML = \`<span class="nb-js-field-value" style="color:#1890ff;font-weight:600">\${v}</span>\`;
|
|
15
|
+
`};n.default=s}}]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4666],{74666:function(t,e,n){n.r(e);var a={contexts:["*"],versions:["*"],prefix:"sn-open-drawer",label:"Open view (drawer)",description:"Open a view in drawer via ctx.openView",locales:{"zh-CN":{label:"\u6253\u5F00\u89C6\u56FE\uFF08\u62BD\u5C49\uFF09",description:"\u901A\u8FC7 ctx.openView \u4EE5\u62BD\u5C49\u65B9\u5F0F\u6253\u5F00\u89C6\u56FE"}},content:`
|
|
2
|
+
// Open a view as drawer and pass arguments at top-level
|
|
3
|
+
const popupUid = ctx.model.uid + '-1'; // popupUid should be stable and better bound to ctx.model.uid
|
|
4
|
+
await ctx.openView(popupUid, {
|
|
5
|
+
mode: 'drawer',
|
|
6
|
+
title: ctx.t('Sample drawer'),
|
|
7
|
+
size: 'large',
|
|
8
|
+
});
|
|
9
|
+
`};e.default=a}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4727],{64727:function(h,n,e){e.r(n),e.d(n,{JSColumnRunJSContext:function(){return o}});var r=e(72004),t=e.n(r),s=e(12444),l=e.n(s),a=e(31996),u=e.n(a),i=e(26037),d=e.n(i),m=e(1772),o=function(c){u()(_,c);var b=d()(_);function _(){return l()(this,_),b.apply(this,arguments)}return t()(_)}(m.Uo);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 \u5217 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u683C\u5355\u5143\u683C\u7684\u5B89\u5168 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",record:"\u5F53\u524D\u884C\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF09",recordIndex:"\u5F53\u524D\u884C\u7D22\u5F15\uFF08\u4ECE 0 \u5F00\u59CB\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF09",viewer:"\u89C6\u56FE\u63A7\u5236\u5668\uFF0C\u53EF\u7528\u4E8E\u5728\u5355\u5143\u683C\u4E2D\u89E6\u53D1\u62BD\u5C49/\u5BF9\u8BDD\u6846/\u5185\u5D4C\u7B49\u4EA4\u4E92",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u7B49\u5F85\u5355\u5143\u683C DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)",requireAsync:"\u6309 URL \u5F02\u6B65\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})}}]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4750,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return _}});var o=e(72004),r=e.n(o),s=e(12444),l=e.n(s),c=e(31996),i=e.n(c),d=e(26037),u=e.n(d),m=e(1772),_=function(b){i()(t,b);var p=u()(t);function t(){return l()(this,t),p.apply(this,arguments)}return r()(t)}(m.Uo);_.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 ESM module: `const mod = await ctx.importAsync(url)`"}}),_.define({label:"RunJS \u4E0A\u4E0B\u6587",properties:{element:{description:"ElementProxy\uFF0C\u5B89\u5168\u7684 DOM \u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49",detail:"ElementProxy",properties:{innerHTML:"\u8BFB\u53D6\u6216\u8BBE\u7F6E\u5BB9\u5668\u7684 HTML \u5185\u5BB9"}},record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF0C\u7528\u4E8E\u6570\u636E\u533A\u5757/\u8BE6\u60C5\u7B49\u573A\u666F\uFF09",value:"\u5F53\u524D\u503C\uFF08\u82E5\u5B58\u5728\uFF09",React:"React \u5E93",antd:"Ant Design \u5E93"},methods:{onRefReady:"\u5BB9\u5668 ref \u5C31\u7EEA\u56DE\u8C03\uFF1A\n```js\nctx.onRefReady(ctx.ref, el => { /* ... */ })\n```",requireAsync:"\u52A0\u8F7D\u5916\u90E8\u5E93\uFF1A`const lib = await ctx.requireAsync(url)`",importAsync:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757\uFF1A`const mod = await ctx.importAsync(url)`"}},{locale:"zh-CN"})},24750:function(a,n,e){e.r(n);var o=e(10095),r={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-info-card",label:"Render record info card",description:"Display current record information in an Ant Design card",locales:{"zh-CN":{label:"\u6E32\u67D3\u8BB0\u5F55\u4FE1\u606F\u5361\u7247",description:"\u4F7F\u7528 Ant Design \u5361\u7247\u663E\u793A\u5F53\u524D\u8BB0\u5F55\u7684\u5173\u952E\u4FE1\u606F"}},content:`
|
|
7
|
+
const { Card, Descriptions, Tag, Typography } = ctx.antd;
|
|
8
|
+
const { createElement: h } = ctx.React;
|
|
9
|
+
|
|
10
|
+
if (!ctx.record) {
|
|
11
|
+
ctx.element.innerHTML = '<div style="padding:16px;color:#999;">' + ctx.t('No record data') + '</div>';
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const record = ctx.record;
|
|
16
|
+
|
|
17
|
+
ctx.ReactDOM.createRoot(ctx.element).render(
|
|
18
|
+
h(Card, { title: ctx.t('Record Details'), bordered: true, style: { margin: 0 } },
|
|
19
|
+
h(Descriptions, { column: 2, size: 'small' },
|
|
20
|
+
h(Descriptions.Item, { label: ctx.t('ID') }, record.id || '-'),
|
|
21
|
+
h(Descriptions.Item, { label: ctx.t('Status') },
|
|
22
|
+
h(Tag, { color: record.status === 'active' ? 'green' : 'default' }, record.status || '-')
|
|
23
|
+
),
|
|
24
|
+
h(Descriptions.Item, { label: ctx.t('Title') }, record.title || '-'),
|
|
25
|
+
h(Descriptions.Item, { label: ctx.t('Created At') },
|
|
26
|
+
record.createdAt ? new Date(record.createdAt).toLocaleString() : '-'
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
`};n.default=r}}]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[4926,113,7087],{67087:function(f,o,e){e.r(o),e.d(o,{FormJSFieldItemRunJSContext:function(){return _}});var l=e(72004),r=e.n(l),s=e(12444),t=e.n(s),a=e(31996),d=e.n(a),u=e(26037),i=e.n(u),m=e(1772),_=function(c){d()(n,c);var b=i()(n);function n(){return t()(this,n),b.apply(this,arguments)}return r()(n)}(m.Uo);_.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.`},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" })`}}),_.define({label:"\u8868\u5355 JS \u5B57\u6BB5\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u5B57\u6BB5\u5BB9\u5668",value:"\u5B57\u6BB5\u503C\uFF08\u5C55\u793A\u6A21\u5F0F\u4E3A\u53EA\u8BFB\uFF1B\u53D7\u63A7\u573A\u666F\u7528 setProps \u4FEE\u6539\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u56DE\u8C03",setProps:"\u8BBE\u7F6E\u8868\u5355\u9879\u5C5E\u6027\uFF1A`setProps(fieldModel, { value })`\uFF08\u7531\u8054\u52A8/\u8868\u5355\u4E0A\u4E0B\u6587\u63D0\u4F9B\uFF09"}},{locale:"zh-CN"})},40113:function(f,o,e){e.r(o),e.d(o,{JSFieldRunJSContext:function(){return _}});var l=e(72004),r=e.n(l),s=e(12444),t=e.n(s),a=e(31996),d=e.n(a),u=e(26037),i=e.n(u),m=e(1772),_=function(c){d()(n,c);var b=i()(n);function n(){return t()(this,n),b.apply(this,arguments)}return r()(n)}(m.Uo);_.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 })`}}),_.define({label:"JS \u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",value:"\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF0C\u5305\u542B\u7236\u8BB0\u5F55\u5168\u90E8\u5B57\u6BB5\u503C\uFF09",collection:"\u96C6\u5408\u5B9A\u4E49\u5143\u6570\u636E\uFF08\u53EA\u8BFB\uFF0C\u63CF\u8FF0\u5B57\u6BB5\u6240\u5C5E\u96C6\u5408\u7684 Schema\uFF09"},methods:{onRefReady:"\u5728\u5B57\u6BB5\u5BB9\u5668 DOM \u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)\uFF1B\u793A\u4F8B\uFF1Actx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })"}},{locale:"zh-CN"})},44926:function(f,o,e){e.r(o);var l=e(40113),r=e(67087),s={contexts:[l.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:"\u5C06\u6570\u5B57\u5B57\u6BB5\u663E\u793A\u4E3A\u5F69\u8272\u6587\u672C",description:"\u6839\u636E\u6570\u503C\u6B63\u8D1F\u8BBE\u7F6E\u663E\u793A\u989C\u8272"}},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.element.innerHTML = '<span style=' + JSON.stringify('color:' + color) + '>' + String(ctx.value ?? '') + '</span>';
|
|
17
|
+
`};o.default=s}}]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[5013],{55013:function(h,n,e){e.r(n),e.d(n,{JSRecordActionRunJSContext:function(){return o}});var s=e(72004),r=e.n(s),l=e(12444),t=e.n(l),a=e(31996),u=e.n(a),d=e(26037),m=e.n(d),i=e(1772),o=function(b){u()(_,b);var c=m()(_);function _(){return t()(this,_),c.apply(this,arguments)}return r()(_)}(i.Uo);o.define({label:"JSRecordAction RunJS context",properties:{record:`Current record data object (read-only).
|
|
2
|
+
Contains all field values of the record associated with this action.`,filterByTk:`Primary key or filter key of the current record (read-only).
|
|
3
|
+
Used to identify the specific record in database operations.`}}),o.define({label:"JS \u8BB0\u5F55\u52A8\u4F5C RunJS \u4E0A\u4E0B\u6587",properties:{record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09",filterByTk:"\u4E3B\u952E/\u8FC7\u6EE4\u952E\uFF08\u53EA\u8BFB\uFF09"}},{locale:"zh-CN"})}}]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[5501,1442],{41442:function(t,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return s}});var _=e(72004),r=e.n(_),a=e(12444),l=e.n(a),d=e(31996),i=e.n(d),u=e(26037),m=e.n(u),c=e(1772),s=function(b){i()(o,b);var p=m()(o);function o(){return l()(this,o),p.apply(this,arguments)}return r()(o)}(c.Uo);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.`},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 \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",properties:{element:"ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",resource:"\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",record:"\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},45501:function(t,n,e){e.r(n);var _=e(41442),r={contexts:[_.JSItemRunJSContext],prefix:"sn-link-require",label:"Conditional required field",description:"Make a field required based on another field's value",locales:{"zh-CN":{label:"\u6761\u4EF6\u5FC5\u586B",description:"\u6839\u636E\u53E6\u4E00\u4E2A\u5B57\u6BB5\u7684\u503C\u52A8\u6001\u8BBE\u7F6E\u5FC5\u586B\u72B6\u6001"}},content:`
|
|
6
|
+
// When 'needsApproval' is true, make 'approver' field required
|
|
7
|
+
const needsApproval = ctx.record?.needsApproval;
|
|
8
|
+
|
|
9
|
+
const items = ctx.model?.subModels?.grid?.subModels?.items;
|
|
10
|
+
const candidates = Array.isArray(items) ? items : Array.from(items?.values?.() || items || []);
|
|
11
|
+
|
|
12
|
+
const approverField = candidates.find((item) => item?.props?.name === 'approver');
|
|
13
|
+
|
|
14
|
+
if (approverField) {
|
|
15
|
+
approverField.setProps({
|
|
16
|
+
required: !!needsApproval,
|
|
17
|
+
// Also toggle visibility if needed
|
|
18
|
+
// display: needsApproval ? 'visible' : 'hidden',
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
console.warn('[Form snippet] approver field not found');
|
|
22
|
+
}
|
|
23
|
+
`};n.default=r}}]);
|