@nocobase/app 2.0.0-alpha.5 → 2.0.0-alpha.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/client/113.736e29a0.async.js +7 -0
  2. package/dist/client/1145.0351040a.async.js +3 -0
  3. package/dist/client/1161.0b3b5766.async.js +40 -0
  4. package/dist/client/1442.be509f94.async.js +5 -0
  5. package/dist/client/1595.9f992743.async.js +44 -0
  6. package/dist/client/1758.eeeacf43.async.js +5 -0
  7. package/dist/client/1883.6ee256ab.async.js +17 -0
  8. package/dist/client/1905.ff0793ff.async.js +12 -0
  9. package/dist/client/2042.feb4b9ac.async.js +10 -0
  10. package/dist/client/2097.919e4d8a.async.js +14 -0
  11. package/dist/client/{2190.90c718a9.async.js → 2190.4f5395e5.async.js} +1 -1
  12. package/dist/client/2380.900b7a22.async.js +15 -0
  13. package/dist/client/2612.0865e67e.async.js +19 -0
  14. package/dist/client/2775.455c3402.async.js +47 -0
  15. package/dist/client/2936.902710e4.async.js +28 -0
  16. package/dist/client/3357.be95167c.async.js +28 -0
  17. package/dist/client/341.fba65e23.async.js +28 -0
  18. package/dist/client/3451.a9466e73.async.js +24 -0
  19. package/dist/client/4327.68c0f17b.async.js +16 -0
  20. package/dist/client/4351.efe05af2.async.js +15 -0
  21. package/dist/client/4356.d61392c6.async.js +18 -0
  22. package/dist/client/4666.fb83d11a.async.js +9 -0
  23. package/dist/client/4727.0f6df8fb.async.js +1 -0
  24. package/dist/client/4750.ce3051f3.async.js +31 -0
  25. package/dist/client/4926.58238954.async.js +17 -0
  26. package/dist/client/5013.b14730ba.async.js +3 -0
  27. package/dist/client/5501.22d50b3a.async.js +23 -0
  28. package/dist/client/5505.a71c2922.async.js +2 -0
  29. package/dist/client/5662.8c643e63.async.js +26 -0
  30. package/dist/client/5882.abae55ef.async.js +50 -0
  31. package/dist/client/5950.179a885e.async.js +4 -0
  32. package/dist/client/6021.cdefa0d3.async.js +22 -0
  33. package/dist/client/645.ab5af584.async.js +55 -0
  34. package/dist/client/6474.49632e37.async.js +21 -0
  35. package/dist/client/6534.6ea6468b.async.js +33 -0
  36. package/dist/client/6747.de538558.async.js +22 -0
  37. package/dist/client/689.4de33d65.async.js +3 -0
  38. package/dist/client/6920.497d7e80.async.js +59 -0
  39. package/dist/client/6939.d7d780b7.async.js +17 -0
  40. package/dist/client/6996.ae27c9d6.async.js +9 -0
  41. package/dist/client/703.7ad807b0.async.js +17 -0
  42. package/dist/client/7087.5646e199.async.js +6 -0
  43. package/dist/client/7483.546ddcb6.async.js +23 -0
  44. package/dist/client/7534.0d69e071.async.js +34 -0
  45. package/dist/client/7764.a3ae7727.async.js +25 -0
  46. package/dist/client/8183.4c6f7e21.async.js +12 -0
  47. package/dist/client/8408.c0ef773c.async.js +84 -0
  48. package/dist/client/8805.819c4f44.async.js +20 -0
  49. package/dist/client/9017.4ae5c322.async.js +6 -0
  50. package/dist/client/9042.3d21f631.async.js +45 -0
  51. package/dist/client/908.0e8c8a54.async.js +14 -0
  52. package/dist/client/9317.fe6ffa9a.async.js +13 -0
  53. package/dist/client/935.97d45ffa.async.js +27 -0
  54. package/dist/client/95.24aa76c4.async.js +6 -0
  55. package/dist/client/9547.a442df93.async.js +25 -0
  56. package/dist/client/9801.34b13a74.async.js +9 -0
  57. package/dist/client/9844.6f484975.async.js +37 -0
  58. package/dist/client/index.html +1 -1
  59. package/dist/client/index.html.tpl +1 -1
  60. package/dist/client/npm._at_jridgewell.72fd4dd4.async.js +1 -0
  61. package/dist/client/{npm._at_umijs.47085d01.async.js → npm._at_umijs.f64c1387.async.js} +1 -1
  62. package/dist/client/npm.acorn.59eb4103.async.js +11 -0
  63. package/dist/client/npm.antd-mobile.55661292.async.js +2 -0
  64. package/dist/client/npm.babel-runtime.eed49798.async.js +1 -0
  65. package/dist/client/{npm.highlight.js.c1f693ec.async.js → npm.highlight.js.5db864c8.async.js} +2 -2
  66. package/dist/client/{npm.htmlparser2.a2f8d64d.async.js → npm.htmlparser2.ee1fb042.async.js} +1 -1
  67. package/dist/client/npm.liquidjs.7be2e0df.async.js +13 -0
  68. package/dist/client/npm.sucrase.1cb664e8.async.js +135 -0
  69. package/dist/client/{npm.unknown.1838c8f4.chunk.css → npm.unknown.d9b587d9.chunk.css} +26 -1
  70. package/dist/client/npm.vditor.eb5da290.async.js +233 -0
  71. package/dist/client/p__index.7b4d5c1a.async.js +2490 -0
  72. package/dist/client/{umi.121d6f3f.js → umi.817d16e7.js} +17 -17
  73. package/lib/config/telemetry.js +1 -0
  74. package/package.json +6 -6
  75. package/src/config/telemetry.ts +1 -0
  76. package/dist/client/1145.4029b0be.async.js +0 -3
  77. package/dist/client/1617.dd671a87.async.js +0 -6
  78. package/dist/client/1833.82373d30.async.js +0 -6
  79. package/dist/client/2134.1d86e440.async.js +0 -5
  80. package/dist/client/2498.be8b1194.async.js +0 -7
  81. package/dist/client/260.5b02a0a5.async.js +0 -4
  82. package/dist/client/2953.2e77d77c.async.js +0 -24
  83. package/dist/client/3170.6147bd19.async.js +0 -24
  84. package/dist/client/3255.e6303833.async.js +0 -10
  85. package/dist/client/3520.81fd6362.async.js +0 -24
  86. package/dist/client/3522.674f2264.async.js +0 -4
  87. package/dist/client/4088.0568ef31.async.js +0 -5
  88. package/dist/client/4205.c3eac46d.async.js +0 -9
  89. package/dist/client/4644.ae01f8a6.async.js +0 -4
  90. package/dist/client/4666.d20ff352.async.js +0 -8
  91. package/dist/client/4840.477401f9.async.js +0 -8
  92. package/dist/client/5068.72e9d750.async.js +0 -5
  93. package/dist/client/5087.468f5500.async.js +0 -6
  94. package/dist/client/5950.b83f8586.async.js +0 -4
  95. package/dist/client/6416.361c93ff.async.js +0 -4
  96. package/dist/client/6472.ac05f778.async.js +0 -7
  97. package/dist/client/6779.47fc1971.async.js +0 -10
  98. package/dist/client/6816.1ff200ac.async.js +0 -5
  99. package/dist/client/6996.836a3f7f.async.js +0 -8
  100. package/dist/client/7463.70ca58ce.async.js +0 -20
  101. package/dist/client/7482.3924bcd9.async.js +0 -1
  102. package/dist/client/7522.1f91be5c.async.js +0 -23
  103. package/dist/client/7596.232a7185.async.js +0 -10
  104. package/dist/client/7688.85d6d7bb.async.js +0 -4
  105. package/dist/client/8106.829fd6b5.async.js +0 -10
  106. package/dist/client/8541.e3110aaa.async.js +0 -8
  107. package/dist/client/9017.28eacc5a.async.js +0 -6
  108. package/dist/client/937.a55819ab.async.js +0 -5
  109. package/dist/client/9462.a7773548.async.js +0 -35
  110. package/dist/client/9489.25ca39a9.async.js +0 -7
  111. package/dist/client/9663.c04b2ad1.async.js +0 -5
  112. package/dist/client/9729.0d7a5c47.async.js +0 -8
  113. package/dist/client/9848.18f8d3db.async.js +0 -4
  114. package/dist/client/npm._at_babel.94b2dd75.async.js +0 -3
  115. package/dist/client/npm.acorn.1f389fab.async.js +0 -6
  116. package/dist/client/npm.antd-mobile.1a8a8320.async.js +0 -2
  117. package/dist/client/npm.async-validator.32d9020f.async.js +0 -12
  118. package/dist/client/p__index.b57f4995.async.js +0 -2316
@@ -0,0 +1,4 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[5950],{45950:function(a,n,e){e.r(n);var o={contexts:["*"],prefix:"sn-window-open",label:"Open new window",description:"Safely open a new browser window/tab",locales:{"zh-CN":{label:"\u6253\u5F00\u65B0\u7A97\u53E3",description:"\u5B89\u5168\u5730\u6253\u5F00\u4E00\u4E2A\u65B0\u7684\u6D4F\u89C8\u5668\u7A97\u53E3\u6216\u6807\u7B7E\u9875"}},content:`
2
+ // Open a new window/tab
3
+ window.open('https://example.com', '_blank');
4
+ `};n.default=o}}]);
@@ -0,0 +1,22 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6021,1442],{41442:function(s,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return r}});var t=e(72004),_=e.n(t),a=e(12444),l=e.n(a),u=e(31996),i=e.n(u),d=e(26037),m=e.n(d),c=e(1772),r=function(b){i()(o,b);var p=m()(o);function o(){return l()(this,o),p.apply(this,arguments)}return _()(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"})},96021:function(s,n,e){e.r(n);var t=e(41442),_={contexts:[t.JSItemRunJSContext],prefix:"sn-link-calc",label:"Calculate total price (quantity \xD7 price)",description:"Automatically calculate total when quantity or unit price changes",locales:{"zh-CN":{label:"\u8BA1\u7B97\u603B\u4EF7\uFF08\u6570\u91CF \xD7 \u5355\u4EF7\uFF09",description:"\u5F53\u6570\u91CF\u6216\u5355\u4EF7\u53D8\u5316\u65F6\u81EA\u52A8\u8BA1\u7B97\u603B\u4EF7"}},content:`
6
+ // Get quantity and unit price from current record
7
+ const quantity = Number(ctx.record?.quantity) || 0;
8
+ const unitPrice = Number(ctx.record?.unitPrice) || 0;
9
+ const total = quantity * unitPrice;
10
+
11
+ // Find and update the 'totalPrice' field
12
+ const items = ctx.model?.subModels?.grid?.subModels?.items;
13
+ const candidates = Array.isArray(items) ? items : Array.from(items?.values?.() || items || []);
14
+
15
+ const totalField = candidates.find((item) => item?.props?.name === 'totalPrice');
16
+
17
+ if (totalField) {
18
+ totalField.setProps({ value: total.toFixed(2) });
19
+ } else {
20
+ console.warn('[Form snippet] totalPrice field not found');
21
+ }
22
+ `};n.default=_}}]);
@@ -0,0 +1,55 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[645,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return s}});var o=e(72004),r=e.n(o),l=e(12444),_=e.n(l),i=e(31996),u=e.n(i),c=e(26037),d=e.n(c),m=e(1772),s=function(b){u()(t,b);var p=d()(t);function t(){return _()(this,t),p.apply(this,arguments)}return r()(t)}(m.Uo);s.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)`"}}),s.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"})},10645:function(a,n,e){e.r(n);var o=e(10095),r={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-stats",label:"Render statistics cards",description:"Display multiple statistic cards with numbers from API",locales:{"zh-CN":{label:"\u6E32\u67D3\u7EDF\u8BA1\u5361\u7247",description:"\u663E\u793A\u591A\u4E2A\u7EDF\u8BA1\u6570\u5B57\u5361\u7247\uFF08\u4ECE API \u83B7\u53D6\u6570\u636E\uFF09"}},content:`
7
+ const { Card, Statistic, Row, Col } = ctx.libs.antd;
8
+
9
+ const res = await ctx.api.request({
10
+ url: 'users:list',
11
+ method: 'get',
12
+ params: {
13
+ pageSize: 100,
14
+ appends: ['roles'],
15
+ },
16
+ });
17
+
18
+ const users = res?.data?.data || [];
19
+
20
+ const total = users.length;
21
+ const adminCount = users.filter((user) =>
22
+ Array.isArray(user?.roles) && user.roles.some((role) => role?.name === 'admin')
23
+ ).length;
24
+ const withEmail = users.filter((user) => !!user?.email).length;
25
+ const distinctRoles = new Set(
26
+ users
27
+ .flatMap((user) => (Array.isArray(user?.roles) ? user.roles.map((role) => role?.name) : []))
28
+ .filter(Boolean),
29
+ ).size;
30
+
31
+ ctx.render(
32
+ <Row gutter={16}>
33
+ <Col span={6}>
34
+ <Card>
35
+ <Statistic title={ctx.t('Total users')} value={total} valueStyle={{ color: '#3f8600' }} />
36
+ </Card>
37
+ </Col>
38
+ <Col span={6}>
39
+ <Card>
40
+ <Statistic title={ctx.t('Administrators')} value={adminCount} valueStyle={{ color: '#1890ff' }} />
41
+ </Card>
42
+ </Col>
43
+ <Col span={6}>
44
+ <Card>
45
+ <Statistic title={ctx.t('Users with email')} value={withEmail} valueStyle={{ color: '#faad14' }} />
46
+ </Card>
47
+ </Col>
48
+ <Col span={6}>
49
+ <Card>
50
+ <Statistic title={ctx.t('Distinct roles')} value={distinctRoles} valueStyle={{ color: '#cf1322' }} />
51
+ </Card>
52
+ </Col>
53
+ </Row>
54
+ );
55
+ `};n.default=r}}]);
@@ -0,0 +1,21 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6474,689],{689:function(l,o,e){e.r(o),e.d(o,{JSCollectionActionRunJSContext:function(){return t}});var _=e(72004),s=e.n(_),r=e(12444),a=e.n(r),c=e(31996),u=e.n(c),i=e(26037),d=e.n(i),m=e(1772),t=function(b){u()(n,b);var C=d()(n);function n(){return a()(this,n),C.apply(this,arguments)}return s()(n)}(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"})},36474:function(l,o,e){e.r(o);var _=e(689),s={contexts:[_.JSCollectionActionRunJSContext],prefix:"sn-act-export",label:"Export selected rows as JSON",description:"Download selected rows as a JSON file",locales:{"zh-CN":{label:"\u5BFC\u51FA\u9009\u4E2D\u884C\u4E3A JSON",description:"\u5C06\u9009\u4E2D\u7684\u884C\u5BFC\u51FA\u4E3A JSON \u6587\u4EF6\u4E0B\u8F7D"}},content:`
4
+ const rows = ctx.resource?.getSelectedRows?.() || [];
5
+ if (!rows.length) {
6
+ ctx.message.warning(ctx.t('Please select at least one row'));
7
+ return;
8
+ }
9
+
10
+ // Create JSON file and download
11
+ const jsonStr = JSON.stringify(rows, null, 2);
12
+ const blob = new Blob([jsonStr], { type: 'application/json' });
13
+ const url = URL.createObjectURL(blob);
14
+ const link = document.createElement('a');
15
+ link.href = url;
16
+ link.download = \`export-\${new Date().toISOString().split('T')[0]}.json\`;
17
+ link.click();
18
+ URL.revokeObjectURL(url);
19
+
20
+ ctx.message.success(ctx.t('Exported {{count}} records', { count: rows.length }));
21
+ `};o.default=s}}]);
@@ -0,0 +1,33 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6534,1442],{41442:function(r,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return t}});var s=e(72004),_=e.n(s),a=e(12444),l=e.n(a),i=e(31996),d=e.n(i),m=e(26037),u=e.n(m),c=e(1772),t=function(b){d()(o,b);var p=u()(o);function o(){return l()(this,o),p.apply(this,arguments)}return _()(o)}(c.Uo);t.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`}}),t.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"})},76534:function(r,n,e){e.r(n);var s=e(41442),_={contexts:[s.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:"\u590D\u5236\u5B57\u6BB5\u503C",description:"\u52FE\u9009\u590D\u9009\u6846\u65F6\uFF0C\u5C06\u4E00\u4E2A\u5B57\u6BB5\u7684\u503C\u590D\u5236\u5230\u53E6\u4E00\u4E2A\u5B57\u6BB5"}},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
+ `};n.default=_}}]);
@@ -0,0 +1,22 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6747,95,113,7087],{67087:function(h,_,e){e.r(_),e.d(_,{FormJSFieldItemRunJSContext:function(){return o}});var t=e(72004),l=e.n(t),r=e(12444),s=e.n(r),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(1772),o=function(c){u()(n,c);var b=i()(n);function n(){return s()(this,n),b.apply(this,arguments)}return l()(n)}(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"})},10095:function(h,_,e){e.r(_),e.d(_,{JSBlockRunJSContext:function(){return o}});var t=e(72004),l=e.n(t),r=e(12444),s=e.n(r),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(1772),o=function(c){u()(n,c);var b=i()(n);function n(){return s()(this,n),b.apply(this,arguments)}return l()(n)}(m.Uo);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 ESM module: `const mod = await ctx.importAsync(url)`"}}),o.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"})},40113:function(h,_,e){e.r(_),e.d(_,{JSFieldRunJSContext:function(){return o}});var t=e(72004),l=e.n(t),r=e(12444),s=e.n(r),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(1772),o=function(c){u()(n,c);var b=i()(n);function n(){return s()(this,n),b.apply(this,arguments)}return l()(n)}(m.Uo);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 \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"})},86747:function(h,_,e){e.r(_);var t=e(10095),l=e(40113),r=e(67087),s={contexts:[t.JSBlockRunJSContext,l.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext],prefix:"sn-query-selector",label:"Query selector",description:"Find a child element inside ctx.element using querySelector",locales:{"zh-CN":{label:"\u67E5\u8BE2\u5B50\u5143\u7D20",description:"\u4F7F\u7528 querySelector \u5728 ctx.element \u5185\u67E5\u627E\u5B50\u5143\u7D20"}},content:`
18
+ const child = ctx.element.querySelector('.child-class');
19
+ if (child) {
20
+ child.textContent = ctx.t('Hello from querySelector');
21
+ }
22
+ `};_.default=s}}]);
@@ -0,0 +1,3 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[689],{689:function(C,n,e){e.r(n),e.d(n,{JSCollectionActionRunJSContext:function(){return o}});var s=e(72004),l=e.n(s),r=e(12444),t=e.n(r),u=e(31996),a=e.n(u),m=e(26037),c=e.n(m),d=e(1772),o=function(i){a()(_,i);var b=c()(_);function _(){return t()(this,_),b.apply(this,arguments)}return l()(_)}(d.Uo);o.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.`}}),o.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"})}}]);
@@ -0,0 +1,59 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6920,95],{10095:function(s,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return a}});var r=e(72004),o=e.n(r),_=e(12444),l=e.n(_),i=e(31996),d=e.n(i),c=e(26037),u=e.n(c),m=e(1772),a=function(b){d()(t,b);var p=u()(t);function t(){return l()(this,t),p.apply(this,arguments)}return o()(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"})},96920:function(s,n,e){e.r(n);var r=e(10095),o={contexts:[r.JSBlockRunJSContext],prefix:"sn-jsb-chartjs",label:"Render Chart.js bar chart",description:"Load Chart.js from CDN and render a basic bar chart inside the block",locales:{"zh-CN":{label:"\u6E32\u67D3 Chart.js \u67F1\u72B6\u56FE",description:"\u901A\u8FC7 CDN \u5F15\u5165 Chart.js \u5E76\u5728\u533A\u5757\u4E2D\u6E32\u67D3\u57FA\u7840\u67F1\u72B6\u56FE"}},content:`
7
+ const wrapper = document.createElement('div');
8
+ wrapper.style.padding = '16px';
9
+ wrapper.style.background = '#fff';
10
+ wrapper.style.borderRadius = '8px';
11
+ wrapper.style.boxShadow = '0 2px 8px rgba(0,0,0,0.05)';
12
+
13
+ const canvas = document.createElement('canvas');
14
+ canvas.width = 480;
15
+ canvas.height = 320;
16
+ wrapper.appendChild(canvas);
17
+ ctx.element.replaceChildren(wrapper);
18
+
19
+ async function renderChart() {
20
+ const loaded = await ctx.requireAsync('https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js');
21
+ const Chart = loaded?.Chart || loaded?.default?.Chart || loaded?.default;
22
+ if (!Chart) {
23
+ throw new Error('Chart.js is not available');
24
+ }
25
+
26
+ const labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
27
+ const data = [12, 18, 9, 15, 22];
28
+
29
+ new Chart(canvas.getContext('2d'), {
30
+ type: 'bar',
31
+ data: {
32
+ labels,
33
+ datasets: [
34
+ {
35
+ label: ctx.t('Daily visits'),
36
+ data,
37
+ backgroundColor: 'rgba(24, 144, 255, 0.6)',
38
+ borderColor: '#1890ff',
39
+ borderWidth: 1,
40
+ },
41
+ ],
42
+ },
43
+ options: {
44
+ plugins: {
45
+ legend: { display: true },
46
+ title: {
47
+ display: true,
48
+ text: ctx.t('Weekly overview'),
49
+ },
50
+ },
51
+ },
52
+ });
53
+ }
54
+
55
+ renderChart().catch((error) => {
56
+ console.error('[RunJS] failed to render chart', error);
57
+ wrapper.innerHTML = '<div style="color:#c00;">' + (error?.message || ctx.t('Chart initialization failed')) + '</div>';
58
+ });
59
+ `};n.default=o}}]);
@@ -0,0 +1,17 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6939],{96939:function(o,t,n){n.r(t);var e={contexts:["*"],prefix:"sn-clipboard-copy",label:"Copy text to clipboard (function)",description:"A reusable function that copies a given string to the clipboard.",locales:{"zh-CN":{label:"\u590D\u5236\u6587\u672C\u5230\u526A\u8D34\u677F\uFF08\u51FD\u6570\uFF09",description:"\u901A\u7528\u51FD\u6570\uFF1A\u63A5\u53D7\u4E00\u4E2A\u5B57\u7B26\u4E32\u53C2\u6570\u5E76\u590D\u5236\u5230\u526A\u8D34\u677F\u3002"}},content:`
2
+ // A general utility function that copies text to clipboard.
3
+ // Usage:
4
+ // const ok = await copyTextToClipboard('Hello');
5
+ // if (ok) { /* success */ } else { /* handle failure */ }
6
+ async function copyTextToClipboard(text) {
7
+ const s = String(text ?? '');
8
+ try {
9
+ if (navigator?.clipboard?.writeText) {
10
+ await navigator.clipboard.writeText(s);
11
+ return true;
12
+ }
13
+ } catch (_) {
14
+ // Fallback below
15
+ }
16
+ }
17
+ `};t.default=e}}]);
@@ -0,0 +1,9 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6996],{96996:function(o,e,n){n.r(e);var i={contexts:["*"],versions:["*"],prefix:"sn-open-dialog",label:"Open view (dialog)",description:"Open a view in dialog via ctx.openView",locales:{"zh-CN":{label:"\u6253\u5F00\u89C6\u56FE\uFF08\u5BF9\u8BDD\u6846\uFF09",description:"\u901A\u8FC7 ctx.openView \u4EE5\u5BF9\u8BDD\u6846\u65B9\u5F0F\u6253\u5F00\u89C6\u56FE"}},content:`
2
+ // Open a view as dialog 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: 'dialog',
6
+ title: ctx.t('Sample dialog'),
7
+ size: 'medium',
8
+ });
9
+ `};e.default=i}}]);
@@ -0,0 +1,17 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[703,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 p=d()(t);function t(){return l()(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"})},70703:function(a,n,e){e.r(n);var o=e(10095),_={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-react",label:"Render React",description:"Render a React element inside the block container",locales:{"zh-CN":{label:"\u6E32\u67D3 React",description:"\u5728\u533A\u5757\u5BB9\u5668\u4E2D\u6E32\u67D3 React \u7EC4\u4EF6"}},content:`
7
+ // Render a React element into ctx.element via ReactDOM
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
+ `};n.default=_}}]);
@@ -0,0 +1,6 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7087],{67087:function(p,n,e){e.r(n),e.d(n,{FormJSFieldItemRunJSContext:function(){return o}});var s=e(72004),r=e.n(s),l=e(12444),a=e.n(l),t=e(31996),d=e.n(t),m=e(26037),u=e.n(m),i=e(1772),o=function(b){d()(_,b);var c=u()(_);function _(){return a()(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"})}}]);
@@ -0,0 +1,23 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7483,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),i=e(31996),c=e.n(i),d=e(26037),u=e.n(d),m=e(1772),_=function(b){c()(t,b);var h=u()(t);function t(){return l()(this,t),h.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"})},37483:function(a,n,e){e.r(n);var o=e(10095),r={contexts:[o.JSBlockRunJSContext],prefix:"sn-echarts",label:"Init ECharts",description:"Load ECharts and render a simple chart inside the block",locales:{"zh-CN":{label:"\u521D\u59CB\u5316 ECharts",description:"\u52A0\u8F7D ECharts \u5E76\u5728\u533A\u5757\u5185\u6E32\u67D3\u793A\u4F8B\u56FE\u8868"}},content:`
7
+ const container = document.createElement('div');
8
+ container.style.height = '400px';
9
+ container.style.width = '100%';
10
+ ctx.element.replaceChildren(container);
11
+ const echarts = await ctx.requireAsync('https://cdn.jsdelivr.net/npm/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
+ `};n.default=r}}]);
@@ -0,0 +1,34 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7534,4727],{64727:function(s,n,e){e.r(n),e.d(n,{JSColumnRunJSContext:function(){return l}});var t=e(72004),r=e.n(t),a=e(12444),_=e.n(a),i=e(31996),u=e.n(i),d=e(26037),c=e.n(d),m=e(1772),l=function(b){u()(o,b);var p=c()(o);function o(){return _()(this,o),p.apply(this,arguments)}return r()(o)}(m.Uo);l.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)`"}}),l.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"})},67534:function(s,n,e){e.r(n);var t=e(64727),r={contexts:[t.JSColumnRunJSContext],prefix:"sn-col-concat",label:"Concat two fields",description:"Combine two field values into the current column cell",locales:{"zh-CN":{label:"\u62FC\u63A5\u4E24\u4E2A\u5B57\u6BB5\u503C",description:"\u5728\u81EA\u5B9A\u4E49\u5217\u4E2D\u62FC\u63A5\u4E24\u4E2A\u5B57\u6BB5\u7684\u503C\u4F5C\u4E3A\u663E\u793A\u5185\u5BB9"}},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
+ ctx.element.textContent = parts.length ? parts.join(' / ') : ctx.t('N/A');
34
+ `};n.default=r}}]);
@@ -0,0 +1,25 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7764,95],{10095:function(r,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return s}});var o=e(72004),_=e.n(o),a=e(12444),l=e.n(a),i=e(31996),c=e.n(i),u=e(26037),d=e.n(u),m=e(1772),s=function(b){c()(t,b);var p=d()(t);function t(){return l()(this,t),p.apply(this,arguments)}return _()(t)}(m.Uo);s.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)`"}}),s.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"})},17764:function(r,n,e){e.r(n);var o=e(10095),_={contexts:[o.JSBlockRunJSContext],prefix:"sn-jsb-antd-icons",label:"Render Ant Design icons",description:"Render Ant Design icons with buttons inside the block container",locales:{"zh-CN":{label:"\u6E32\u67D3 Ant Design \u56FE\u6807",description:"\u5728\u533A\u5757\u5BB9\u5668\u4E2D\u4F7F\u7528 Ant Design \u56FE\u6807\u4E0E\u6309\u94AE\u8FDB\u884C\u6E32\u67D3"}},content:`
7
+ // Render Ant Design icons with buttons via ctx.libs
8
+ const { React, antd, antdIcons } = ctx.libs;
9
+ const { Button, Space } = antd;
10
+ const { PlusOutlined, EditOutlined, DeleteOutlined } = antdIcons;
11
+
12
+ const IconButtons = () => (
13
+ <Space style={{ padding: 12 }}>
14
+ <Button type="primary" icon={<PlusOutlined />}>
15
+ {ctx.t('Add')}
16
+ </Button>
17
+ <Button icon={<EditOutlined />}>{ctx.t('Edit')}</Button>
18
+ <Button danger icon={<DeleteOutlined />}>
19
+ {ctx.t('Delete')}
20
+ </Button>
21
+ </Space>
22
+ );
23
+
24
+ ctx.render(<IconButtons />);
25
+ `};n.default=_}}]);
@@ -0,0 +1,12 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[8183,689],{689:function(l,o,e){e.r(o),e.d(o,{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),d=e(26037),i=e.n(d),m=e(1772),t=function(b){c()(_,b);var C=i()(_);function _(){return u()(this,_),C.apply(this,arguments)}return s()(_)}(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"})},58183:function(l,o,e){e.r(o);var n=e(689),s={contexts:[n.JSCollectionActionRunJSContext],prefix:"sn-act-destroy-selected",label:"Destroy selected rows",description:"Delete selected rows via resource.destroySelectedRows()",locales:{"zh-CN":{label:"\u5220\u9664\u9009\u4E2D\u884C",description:"\u901A\u8FC7 resource.destroySelectedRows() \u5220\u9664\u9009\u4E2D\u884C"}},content:`
4
+ const rows = ctx.resource?.getSelectedRows?.() || [];
5
+ if (!rows.length) {
6
+ ctx.message.warning(ctx.t('Please select data'));
7
+ return;
8
+ }
9
+
10
+ await ctx.resource.destroySelectedRows();
11
+ ctx.message.success(ctx.t('Deleted {{count}} rows', { count: rows.length }));
12
+ `};o.default=s}}]);
@@ -0,0 +1,84 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[8408,95],{10095:function(s,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return a}});var t=e(72004),r=e.n(t),l=e(12444),u=e.n(l),_=e(31996),c=e.n(_),i=e(26037),d=e.n(i),m=e(1772),a=function(p){c()(o,p);var b=d()(o);function o(){return u()(this,o),b.apply(this,arguments)}return r()(o)}(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"})},98408:function(s,n,e){e.r(n);var t=e(10095),r={contexts:[t.JSBlockRunJSContext],prefix:"sn-jsb-vue",label:"Embed Vue component",description:"Use ctx.importAsync to load Vue 3 ESM build and render a reactive widget",locales:{"zh-CN":{label:"\u5D4C\u5165 Vue \u7EC4\u4EF6",description:"\u901A\u8FC7 ctx.importAsync \u52A0\u8F7D Vue 3 ESM \u6784\u5EFA\u5E76\u6E32\u67D3\u4EA4\u4E92\u7EC4\u4EF6"}},content:`
7
+ const mountNode = document.createElement('div');
8
+ mountNode.style.padding = '16px';
9
+ mountNode.style.background = '#fff';
10
+ mountNode.style.borderRadius = '8px';
11
+ const target = document.createElement('div');
12
+ target.className = 'nb-vue-counter';
13
+ mountNode.appendChild(target);
14
+ ctx.element.replaceChildren(mountNode);
15
+
16
+ async function bootstrap() {
17
+ const mod = await ctx.importAsync('https://esm.sh/vue@3.4.27/dist/vue.runtime.esm-browser.js');
18
+ const createApp = mod?.createApp;
19
+ const ref = mod?.ref;
20
+ const h = mod?.h;
21
+ if (typeof createApp !== 'function' || typeof ref !== 'function' || typeof h !== 'function') {
22
+ throw new Error('Vue ESM module not available');
23
+ }
24
+
25
+ const Counter = {
26
+ setup() {
27
+ const count = ref(0);
28
+ const increase = () => {
29
+ count.value += 1;
30
+ };
31
+ const openPopup = async () => {
32
+ const popupUid = ctx.model?.uid ? ctx.model.uid + '-popup' : 'vue-popup';
33
+ await ctx.openView(popupUid, {
34
+ mode: 'drawer',
35
+ title: ctx.t('Hello from Vue'),
36
+ params: {
37
+ fromVue: true,
38
+ triggerCount: count.value,
39
+ },
40
+ });
41
+ };
42
+ return () =>
43
+ h(
44
+ 'div',
45
+ { style: 'display:flex;align-items:center;gap:12px;' },
46
+ [
47
+ h(
48
+ 'button',
49
+ {
50
+ style:
51
+ 'padding:6px 12px;border:1px solid #fa8c16;background:#fa8c16;color:#fff;border-radius:4px;cursor:pointer;',
52
+ onClick: increase,
53
+ },
54
+ ctx.t('Increase'),
55
+ ),
56
+ h(
57
+ 'button',
58
+ {
59
+ style:
60
+ 'padding:6px 12px;border:1px solid #1677ff;background:#1677ff;color:#fff;border-radius:4px;cursor:pointer;',
61
+ onClick: openPopup,
62
+ },
63
+ ctx.t('Open popup'),
64
+ ),
65
+ h(
66
+ 'span',
67
+ null,
68
+ ctx.t('Current count') + ': ' + count.value,
69
+ ),
70
+ ],
71
+ );
72
+ },
73
+ };
74
+
75
+ const app = createApp(Counter);
76
+ const mountTarget = ctx.element.querySelector('.nb-vue-counter');
77
+ app.mount(mountTarget || ctx.element);
78
+ }
79
+
80
+ bootstrap().catch((error) => {
81
+ console.error('[RunJS] failed to mount Vue counter', error);
82
+ mountNode.innerHTML = '<div style="color:#c00;">' + (error?.message || ctx.t('Vue initialization failed')) + '</div>';
83
+ });
84
+ `};n.default=r}}]);
@@ -0,0 +1,20 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[8805,95],{10095:function(a,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return _}});var r=e(72004),t=e.n(r),s=e(12444),l=e.n(s),c=e(31996),u=e.n(c),i=e(26037),d=e.n(i),m=e(1772),_=function(b){u()(o,b);var p=d()(o);function o(){return l()(this,o),p.apply(this,arguments)}return t()(o)}(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"})},8805:function(a,n,e){e.r(n);var r=e(10095),t={contexts:[r.JSBlockRunJSContext],prefix:"sn-resource-example",label:"Resource example",description:"Create a resource via ctx.createResource and render JSON output",locales:{"zh-CN":{label:"\u8D44\u6E90\u793A\u4F8B",description:"\u4F7F\u7528 ctx.useResource \u52A0\u8F7D\u6570\u636E\u5E76\u6E32\u67D3 JSON \u8F93\u51FA"}},content:`
7
+ // Create a resource and load a single record
8
+ const resource = ctx.createResource('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.element.innerHTML = \`
16
+ <pre style="padding: 12px; background: #f5f5f5; border-radius: 6px;">
17
+ \${JSON.stringify(resource.getData(), null, 2)}
18
+ </pre>
19
+ \`;
20
+ `};n.default=t}}]);
@@ -0,0 +1,6 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[9017],{79017:function(e,n,t){t.r(n);var i={contexts:["*"],prefix:"sn-notify",label:"Open notification",description:"Open an AntD notification with custom content",locales:{"zh-CN":{label:"\u6253\u5F00\u901A\u77E5",description:"\u5C55\u793A\u4E00\u6761\u81EA\u5B9A\u4E49\u5185\u5BB9\u7684\u901A\u77E5"}},content:`
2
+ ctx.notification.open({
3
+ message: ctx.t('Notification title'),
4
+ description: ctx.t('This is a notification description'),
5
+ });
6
+ `};n.default=i}}]);
@@ -0,0 +1,45 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[9042,113,7087],{67087:function(f,o,e){e.r(o),e.d(o,{FormJSFieldItemRunJSContext:function(){return _}});var t=e(72004),s=e.n(t),r=e(12444),a=e.n(r),l=e(31996),u=e.n(l),d=e(26037),i=e.n(d),m=e(1772),_=function(c){u()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return s()(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),s=e.n(t),r=e(12444),a=e.n(r),l=e(31996),u=e.n(l),d=e(26037),i=e.n(d),m=e(1772),_=function(c){u()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return s()(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"})},19042:function(f,o,e){e.r(o);var t=e(40113),s=e(67087),r={contexts:[t.JSFieldRunJSContext,s.FormJSFieldItemRunJSContext],prefix:"sn-jsf-relative-time",label:"Display date field as relative time",description:"Render date values as \u201C3 days ago\u201D, \u201Cjust now\u201D, etc.",locales:{"zh-CN":{label:"\u5C06\u65E5\u671F\u5B57\u6BB5\u663E\u793A\u4E3A\u76F8\u5BF9\u65F6\u95F4",description:"\u5C06\u65E5\u671F\u663E\u793A\u4E3A\u201C3\u5929\u524D\u201D\u3001\u201C\u521A\u521A\u201D\u7B49\u76F8\u5BF9\u65F6\u95F4"}},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.element.innerHTML = '-';
34
+ return;
35
+ }
36
+
37
+ const relativeTime = formatRelativeTime(dateStr);
38
+ const fullDate = new Date(dateStr).toLocaleString();
39
+
40
+ ctx.element.innerHTML = \`
41
+ <span title="\${fullDate}" style="cursor: help; color: #666;">
42
+ \${relativeTime}
43
+ </span>
44
+ \`;
45
+ `};o.default=r}}]);
@@ -0,0 +1,14 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[908],{30908:function(o,n,e){e.r(n);var t={contexts:["*"],prefix:"sn-import",label:"Import ESM module",description:"Dynamically import an ESM module by URL",locales:{"zh-CN":{label:"\u5BFC\u5165 ESM \u6A21\u5757",description:"\u6309 URL \u52A8\u6001\u5BFC\u5165 ESM \u6A21\u5757"}},content:`
2
+ // Import an ESM module by URL
3
+ // Works in yarn dev and yarn start
4
+ const mod = await ctx.importAsync('https://cdn.jsdelivr.net/npm/lit-html@2/+esm');
5
+ const { html, render } = mod;
6
+
7
+ ctx.element.innerHTML = '';
8
+ const container = document.createElement('div');
9
+ container.style.padding = '8px';
10
+ container.style.border = '1px dashed #999';
11
+ ctx.element.append(container);
12
+
13
+ render(html\`<span style="color:#52c41a;">lit-html loaded and rendered</span>\`, container);
14
+ `};n.default=t}}]);