@nocobase/app 2.0.59 → 2.0.61

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 (85) hide show
  1. package/dist/client/113.831ac6a5.async.js +7 -0
  2. package/dist/client/1161.642e74da.async.js +40 -0
  3. package/dist/client/1442.c27f741b.async.js +5 -0
  4. package/dist/client/1595.404be989.async.js +44 -0
  5. package/dist/client/1883.9fea02cf.async.js +17 -0
  6. package/dist/client/1905.517d6c21.async.js +12 -0
  7. package/dist/client/2097.b6edcf55.async.js +14 -0
  8. package/dist/client/2380.6ce35762.async.js +18 -0
  9. package/dist/client/2612.02bfe459.async.js +22 -0
  10. package/dist/client/2775.f856d6e1.async.js +47 -0
  11. package/dist/client/2936.1d087718.async.js +28 -0
  12. package/dist/client/3357.3f3bcb55.async.js +28 -0
  13. package/dist/client/341.b3dcaeaa.async.js +28 -0
  14. package/dist/client/3451.6ae8c407.async.js +24 -0
  15. package/dist/client/3781.ac6205ea.async.js +1 -0
  16. package/dist/client/4327.b6e18c14.async.js +16 -0
  17. package/dist/client/4351.01a446f7.async.js +15 -0
  18. package/dist/client/4356.4f3c326f.async.js +18 -0
  19. package/dist/client/4727.0b941280.async.js +1 -0
  20. package/dist/client/4750.e49cf86c.async.js +31 -0
  21. package/dist/client/4926.4250890b.async.js +17 -0
  22. package/dist/client/5501.9ec36683.async.js +23 -0
  23. package/dist/client/5662.07373cc2.async.js +26 -0
  24. package/dist/client/6021.0ccc90a2.async.js +22 -0
  25. package/dist/client/645.b2d175f4.async.js +55 -0
  26. package/dist/client/6534.5c0d5077.async.js +33 -0
  27. package/dist/client/6747.7020541a.async.js +27 -0
  28. package/dist/client/6920.515f6b57.async.js +59 -0
  29. package/dist/client/703.9c3bcc59.async.js +17 -0
  30. package/dist/client/7087.0b335cb8.async.js +6 -0
  31. package/dist/client/7483.ce5f7a24.async.js +23 -0
  32. package/dist/client/7534.55c90179.async.js +36 -0
  33. package/dist/client/7764.5741884c.async.js +25 -0
  34. package/dist/client/8408.73034abc.async.js +83 -0
  35. package/dist/client/8805.c1f34b9f.async.js +20 -0
  36. package/dist/client/9042.8ba2e8be.async.js +45 -0
  37. package/dist/client/935.ebd975fb.async.js +27 -0
  38. package/dist/client/95.341d19ce.async.js +6 -0
  39. package/dist/client/9547.d9afcc50.async.js +42 -0
  40. package/dist/client/9844.d7f15bf1.async.js +37 -0
  41. package/dist/client/index.html +1 -1
  42. package/dist/client/index.html.tpl +1 -1
  43. package/dist/client/{p__index.2d564012.async.js → p__index.9a5f5b1a.async.js} +329 -323
  44. package/dist/client/{umi.128a2813.js → umi.dac06e7c.js} +1 -1
  45. package/package.json +6 -6
  46. package/dist/client/113.470c21ad.async.js +0 -7
  47. package/dist/client/1161.1a2c10e3.async.js +0 -40
  48. package/dist/client/1442.fd65d046.async.js +0 -5
  49. package/dist/client/1595.6281d837.async.js +0 -44
  50. package/dist/client/1883.7bf62549.async.js +0 -17
  51. package/dist/client/1905.2e6345d8.async.js +0 -12
  52. package/dist/client/2097.469d41dd.async.js +0 -14
  53. package/dist/client/2380.ce39cb9d.async.js +0 -18
  54. package/dist/client/2612.99f32922.async.js +0 -22
  55. package/dist/client/2775.364c188c.async.js +0 -47
  56. package/dist/client/2936.745e500f.async.js +0 -28
  57. package/dist/client/3357.0dc001fc.async.js +0 -28
  58. package/dist/client/341.01fc2262.async.js +0 -28
  59. package/dist/client/3451.29052272.async.js +0 -24
  60. package/dist/client/3781.16f1bb74.async.js +0 -1
  61. package/dist/client/4327.d9c9bdf4.async.js +0 -16
  62. package/dist/client/4351.40ef71f0.async.js +0 -15
  63. package/dist/client/4356.a3863dfa.async.js +0 -18
  64. package/dist/client/4727.09926a61.async.js +0 -1
  65. package/dist/client/4750.0863f7b1.async.js +0 -31
  66. package/dist/client/4926.f49ba56d.async.js +0 -17
  67. package/dist/client/5501.7bed1ac8.async.js +0 -23
  68. package/dist/client/5662.3071d144.async.js +0 -26
  69. package/dist/client/6021.b3ab345b.async.js +0 -22
  70. package/dist/client/645.b70364b3.async.js +0 -55
  71. package/dist/client/6534.87203710.async.js +0 -33
  72. package/dist/client/6747.1009bdb8.async.js +0 -27
  73. package/dist/client/6920.d29cfa84.async.js +0 -59
  74. package/dist/client/703.8c09e144.async.js +0 -17
  75. package/dist/client/7087.e5b68989.async.js +0 -6
  76. package/dist/client/7483.c3bd056f.async.js +0 -23
  77. package/dist/client/7534.1a42bafc.async.js +0 -36
  78. package/dist/client/7764.f7b626cb.async.js +0 -25
  79. package/dist/client/8408.455572b7.async.js +0 -83
  80. package/dist/client/8805.00cfa044.async.js +0 -20
  81. package/dist/client/9042.9568dd16.async.js +0 -45
  82. package/dist/client/935.63a37ee3.async.js +0 -27
  83. package/dist/client/95.cf18a56e.async.js +0 -6
  84. package/dist/client/9547.a9f2ea1d.async.js +0 -42
  85. package/dist/client/9844.b905f4ce.async.js +0 -37
@@ -1,33 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6534,1442],{41442:function(_,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return r}});var s=e(72004),t=e.n(s),a=e(12444),l=e.n(a),i=e(31996),m=e.n(i),d=e(26037),u=e.n(d),c=e(67946),r=function(b){m()(o,b);var p=u()(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.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form item container DOM element to be ready before executing callback.
5
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`}}),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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},76534:function(_,n,e){e.r(n);var s=e(41442),t={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=t}}]);
@@ -1,27 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6747,95,113,7087],{67087:function(f,o,e){e.r(o),e.d(o,{FormJSFieldItemRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),l=e(12444),a=e.n(l),s=e(31996),d=e.n(s),u=e(26037),i=e.n(u),m=e(67946),_=function(c){d()(n,c);var b=i()(n);function n(){return a()(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.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
- Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
- Example: ctx.setProps(fieldModel, { value: "new value" })`}}),_.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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},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(f,o,e){e.r(o),e.d(o,{JSBlockRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),l=e(12444),a=e.n(l),s=e(31996),d=e.n(s),u=e(26037),i=e.n(u),m=e(67946),_=function(c){d()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return r()(n)}(m.Uo);_.define({label:"RunJS context",properties:{element:{description:`ElementProxy instance providing a safe DOM container.
7
- Supports innerHTML, append, and other DOM manipulation methods.
8
- Use this to render content in the JS block.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},record:`Current record data object (read-only).
9
- Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
10
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
11
- Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),_.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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{locale:"zh-CN"})},40113:function(f,o,e){e.r(o),e.d(o,{JSFieldRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),l=e(12444),a=e.n(l),s=e(31996),d=e.n(s),u=e(26037),i=e.n(u),m=e(67946),_=function(c){d()(n,c);var b=i()(n);function n(){return a()(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.
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 })`}}),_.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(f,o,e){e.r(o);var t=e(10095),r=e(40113),l=e(67087),a={contexts:[t.JSBlockRunJSContext,r.JSFieldRunJSContext,l.FormJSFieldItemRunJSContext],prefix:"sn-query-selector",label:"Query selector",description:"Find a child element inside rendered DOM using querySelector",locales:{"zh-CN":{label:"\u67E5\u8BE2\u5B50\u5143\u7D20",description:"\u4F7F\u7528 querySelector \u5728\u6E32\u67D3\u7684 DOM \u5185\u67E5\u627E\u5B50\u5143\u7D20"}},content:`
18
- const wrapper = document.createElement('div');
19
- wrapper.innerHTML = '<div class="child-class"></div>';
20
-
21
- ctx.render(wrapper);
22
-
23
- const child = wrapper.querySelector('.child-class');
24
- if (child) {
25
- child.textContent = ctx.t('Hello from querySelector');
26
- }
27
- `};o.default=a}}]);
@@ -1,59 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[6920,95],{10095:function(s,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return o}});var r=e(72004),a=e.n(r),l=e(12444),_=e.n(l),d=e(31996),i=e.n(d),c=e(26037),u=e.n(c),m=e(67946),o=function(b){i()(t,b);var h=u()(t);function t(){return _()(this,t),h.apply(this,arguments)}return a()(t)}(m.Uo);o.define({label:"RunJS context",properties:{element:{description:`ElementProxy instance providing a safe DOM container.
2
- Supports innerHTML, append, and other DOM manipulation methods.
3
- Use this to render content in the JS block.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},record:`Current record data object (read-only).
4
- Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
- Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{locale:"zh-CN"})},96920:function(s,n,e){e.r(n);var r=e(10095),a={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.render(wrapper);
18
-
19
- async function renderChart() {
20
- const loaded = await ctx.requireAsync('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=a}}]);
@@ -1,17 +0,0 @@
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),l=e(12444),s=e.n(l),c=e(31996),i=e.n(c),u=e(26037),d=e.n(u),m=e(67946),r=function(b){i()(t,b);var p=d()(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 an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{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 the current container
8
- const { Button } = ctx.libs.antd;
9
-
10
- ctx.render(
11
- <div style={{ padding: 12 }}>
12
- <Button type="primary" onClick={() => ctx.message.success(ctx.t('Clicked!'))}>
13
- {ctx.t('Click')}
14
- </Button>
15
- </div>
16
- );
17
- `};n.default=_}}]);
@@ -1,6 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7087],{67087:function(p,n,e){e.r(n),e.d(n,{FormJSFieldItemRunJSContext:function(){return _}});var s=e(72004),r=e.n(s),a=e(12444),l=e.n(a),t=e(31996),m=e.n(t),d=e(26037),u=e.n(d),i=e(67946),_=function(b){m()(o,b);var c=u()(o);function o(){return l()(this,o),c.apply(this,arguments)}return r()(o)}(i.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.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
- Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
- Example: ctx.setProps(fieldModel, { value: "new value" })`}}),_.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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},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"})}}]);
@@ -1,23 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7483,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),u=e(26037),d=e.n(u),m=e(67946),a=function(b){c()(t,b);var h=d()(t);function t(){return l()(this,t),h.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 an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),a.define({label:"RunJS \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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{locale:"zh-CN"})},37483:function(_,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.render(container);
11
- const echarts = await ctx.requireAsync('echarts@5/dist/echarts.min.js');
12
- if (!echarts) {
13
- throw new Error('ECharts library not loaded');
14
- }
15
-
16
- const chart = echarts.init(container);
17
- chart.setOption({
18
- title: { text: ctx.t('ECharts') },
19
- series: [{ type: 'pie', data: [{ value: 1, name: ctx.t('A') }] }],
20
- });
21
-
22
- chart.resize();
23
- `};n.default=r}}]);
@@ -1,36 +0,0 @@
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(67946),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
- const result = document.createElement('span');
34
- result.textContent = parts.length ? parts.join(' / ') : ctx.t('N/A');
35
- ctx.render(result);
36
- `};n.default=r}}]);
@@ -1,25 +0,0 @@
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(67946),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 an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{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=_}}]);
@@ -1,83 +0,0 @@
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(67946),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 an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),a.define({label:"RunJS \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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{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.render(mountNode);
15
-
16
- async function bootstrap() {
17
- const mod = await ctx.importAsync('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
- app.mount(target);
77
- }
78
-
79
- bootstrap().catch((error) => {
80
- console.error('[RunJS] failed to mount Vue counter', error);
81
- mountNode.innerHTML = '<div style="color:#c00;">' + (error?.message || ctx.t('Vue initialization failed')) + '</div>';
82
- });
83
- `};n.default=r}}]);
@@ -1,20 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[8805,95],{10095:function(_,n,e){e.r(n),e.d(n,{JSBlockRunJSContext:function(){return a}});var t=e(72004),r=e.n(t),s=e(12444),l=e.n(s),u=e(31996),c=e.n(u),i=e(26037),d=e.n(i),m=e(67946),a=function(b){c()(o,b);var p=d()(o);function o(){return l()(this,o),p.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 an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),a.define({label:"RunJS \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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{locale:"zh-CN"})},8805:function(_,n,e){e.r(n);var t=e(10095),r={contexts:[t.JSBlockRunJSContext],prefix:"sn-resource-example",label:"Resource example",description:"Create a resource via ctx.makeResource and render JSON output",locales:{"zh-CN":{label:"\u8D44\u6E90\u793A\u4F8B",description:"\u4F7F\u7528 ctx.initResource \u52A0\u8F7D\u6570\u636E\u5E76\u6E32\u67D3 JSON \u8F93\u51FA"}},content:`
7
- // Create a resource and load a single record
8
- const resource = ctx.makeResource('SingleRecordResource');
9
- resource.setDataSourceKey('main');
10
- resource.setResourceName('users');
11
- // Optionally set filterByTk to target a specific record:
12
- // resource.setRequestOptions('params', { filterByTk: 1 });
13
- await resource.refresh();
14
-
15
- ctx.render(\`
16
- <pre style="padding: 12px; background: #f5f5f5; border-radius: 6px;">
17
- \${JSON.stringify(resource.getData(), null, 2)}
18
- </pre>
19
- \`);
20
- `};n.default=r}}]);
@@ -1,45 +0,0 @@
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 t}});var _=e(72004),s=e.n(_),r=e(12444),a=e.n(r),l=e(31996),u=e.n(l),d=e(26037),i=e.n(d),m=e(67946),t=function(c){u()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return s()(n)}(m.Uo);t.define({label:"FormJSFieldItem RunJS context",properties:{element:`ElementProxy instance providing a safe DOM container for form field rendering.
2
- Supports innerHTML, append, and other DOM manipulation methods.`,value:"Current field value (read-only in display mode; in controlled scenarios, use setProps to modify).",record:`Current record data object (read-only).
3
- Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
- Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
- Example: ctx.setProps(fieldModel, { value: "new value" })`}}),t.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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},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 t}});var _=e(72004),s=e.n(_),r=e(12444),a=e.n(r),l=e(31996),u=e.n(l),d=e(26037),i=e.n(d),m=e(67946),t=function(c){u()(n,c);var b=i()(n);function n(){return a()(this,n),b.apply(this,arguments)}return s()(n)}(m.Uo);t.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 })`}}),t.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 _=e(40113),s=e(67087),r={contexts:[_.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.render('-');
34
- return;
35
- }
36
-
37
- const relativeTime = formatRelativeTime(dateStr);
38
- const fullDate = new Date(dateStr).toLocaleString();
39
-
40
- ctx.render(\`
41
- <span title="\${fullDate}" style="cursor: help; color: #666;">
42
- \${relativeTime}
43
- </span>
44
- \`);
45
- `};o.default=r}}]);
@@ -1,27 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[935,1442],{41442:function(a,n,e){e.r(n),e.d(n,{JSItemRunJSContext:function(){return _}});var o=e(72004),s=e.n(o),r=e(12444),l=e.n(r),d=e(31996),i=e.n(d),m=e(26037),u=e.n(m),c=e(67946),_=function(b){i()(t,b);var f=u()(t);function t(){return l()(this,t),f.apply(this,arguments)}return s()(t)}(c.Uo);_.define({label:"JSItem RunJS context",properties:{element:`ElementProxy instance providing a safe DOM container for form item rendering.
2
- Supports innerHTML, append, and other DOM manipulation methods.`,resource:`Current resource instance (read-only).
3
- Provides access to the data resource associated with the current form context.`,record:`Current record data object (read-only).
4
- Contains all field values of the parent record.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form item container DOM element to be ready before executing callback.
5
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`}}),_.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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:"\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"}},{locale:"zh-CN"})},90935:function(a,n,e){e.r(n);var o=e(41442),s={contexts:[o.JSItemRunJSContext],prefix:"sn-link-set",label:"Set field value",description:"Programmatically update another field in linkage scripts",locales:{"zh-CN":{label:"\u8BBE\u7F6E\u5B57\u6BB5\u503C",description:"\u5728\u8054\u52A8\u811A\u672C\u4E2D\u4E3A\u5176\u4ED6\u5B57\u6BB5\u8BBE\u7F6E\u503C"}},content:`
6
- // Update another field in the same form/block
7
- const targetFieldUid = 'FIELD_UID_OR_NAME';
8
- const nextValue = ctx.record?.status ?? ctx.t('Updated value');
9
-
10
- const items = ctx.model?.subModels?.grid?.subModels?.items;
11
- const candidates = Array.isArray(items)
12
- ? items
13
- : Array.from(items?.values?.() || items || []);
14
- const fieldModel =
15
- candidates.find((item) => item?.uid === targetFieldUid) ||
16
- candidates.find((item) => item?.props?.name === targetFieldUid);
17
-
18
- if (!fieldModel) {
19
- ctx.message?.warning?.(ctx.t('Field {{name}} not found', { name: targetFieldUid }));
20
- return;
21
- }
22
-
23
- fieldModel.setProps({ value: nextValue });
24
- ctx.message?.success?.(
25
- ctx.t('Updated field {{name}}', { name: fieldModel?.props?.label || targetFieldUid }),
26
- );
27
- `};n.default=s}}]);
@@ -1,6 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[95],{10095:function(h,_,e){e.r(_),e.d(_,{JSBlockRunJSContext:function(){return o}});var t=e(72004),r=e.n(t),a=e(12444),l=e.n(a),s=e(31996),u=e.n(s),i=e(26037),c=e.n(i),d=e(67946),o=function(m){u()(n,m);var b=c()(n);function n(){return l()(this,n),b.apply(this,arguments)}return r()(n)}(d.Uo);o.define({label:"RunJS context",properties:{element:{description:`ElementProxy instance providing a safe DOM container.
2
- Supports innerHTML, append, and other DOM manipulation methods.
3
- Use this to render content in the JS block.`,detail:"ElementProxy",properties:{innerHTML:"Set or read the HTML content of the container element."}},record:`Current record data object (read-only).
4
- Available when the JS block is within a data block or detail view context.`,value:"Current value of the field or component, if available in the current context.",React:"React library",antd:"Ant Design library"},methods:{onRefReady:`Wait for container DOM element to be ready before executing callback.
5
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
6
- Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = "Ready!" })`,requireAsync:"Load external library: `const lib = await ctx.requireAsync(url)`",importAsync:"Dynamically import an ESM module by URL: `const mod = await ctx.importAsync(url)`.\nNote: if the module has only a default export, ctx.importAsync returns that default value directly (no `.default`)."}}),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)`\u3002\n\u6CE8\u610F\uFF1A\u5F53\u6A21\u5757\u53EA\u6709 default \u4E00\u4E2A\u5BFC\u51FA\u65F6\uFF0Cctx.importAsync \u4F1A\u76F4\u63A5\u8FD4\u56DE default \u503C\uFF08\u65E0\u9700\u518D\u5199 `.default`\uFF09\u3002"}},{locale:"zh-CN"})}}]);
@@ -1,42 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[9547,113],{40113:function(a,n,e){e.r(n),e.d(n,{JSFieldRunJSContext:function(){return _}});var t=e(72004),l=e.n(t),r=e(12444),s=e.n(r),d=e(31996),c=e.n(d),i=e(26037),u=e.n(i),m=e(67946),_=function(p){c()(o,p);var b=u()(o);function o(){return s()(this,o),b.apply(this,arguments)}return l()(o)}(m.Uo);_.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 })`}}),_.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"})},39547:function(a,n,e){e.r(n);var t=e(40113),l={contexts:[t.JSFieldRunJSContext],prefix:"sn-jsf-copy",label:"Display text field with copy button",description:"Render the text field value with a copy-to-clipboard button",locales:{"zh-CN":{label:"\u5C06\u6587\u672C\u5B57\u6BB5\u663E\u793A\u4E3A\u590D\u5236\u6309\u94AE",description:"\u5C55\u793A\u5B57\u6BB5\u503C\u5E76\u63D0\u4F9B\u5FEB\u6377\u590D\u5236\u5230\u526A\u8D34\u677F\u7684\u6309\u94AE"}},content:`
8
- const text = String(ctx.value ?? '');
9
-
10
- const wrapper = document.createElement('span');
11
- wrapper.style.display = 'inline-flex';
12
- wrapper.style.alignItems = 'center';
13
- wrapper.style.gap = '8px';
14
-
15
- const valueEl = document.createElement('span');
16
- valueEl.textContent = text;
17
- valueEl.style.color = '#666';
18
-
19
- const copyEl = document.createElement('a');
20
- copyEl.textContent = ctx.t('Copy');
21
- copyEl.style.cursor = 'pointer';
22
- copyEl.style.color = '#1677ff';
23
-
24
- copyEl.addEventListener('click', async () => {
25
- if (navigator?.clipboard?.writeText) {
26
- await navigator.clipboard.writeText(text);
27
- } else {
28
- const ta = document.createElement('textarea');
29
- ta.value = text;
30
- document.body.appendChild(ta);
31
- ta.select();
32
- document.execCommand('copy');
33
- document.body.removeChild(ta);
34
- }
35
- ctx.message.success(ctx.t('Copied'));
36
- });
37
-
38
- wrapper.appendChild(valueEl);
39
- wrapper.appendChild(copyEl);
40
-
41
- ctx.render(wrapper);
42
- `};n.default=l}}]);
@@ -1,37 +0,0 @@
1
- "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[9844,113,4727,7087],{67087:function(p,o,e){e.r(o),e.d(o,{FormJSFieldItemRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),s=e(12444),l=e.n(s),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(67946),_=function(c){u()(n,c);var b=i()(n);function n(){return l()(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.`,formValues:{description:"Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},methods:{onRefReady:`Wait for form field container DOM element to be ready before executing callback.
4
- Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,setProps:`Set form field properties programmatically.
5
- Parameters: (fieldModel: any, props: { value?: any, disabled?: boolean, visible?: boolean }) => void
6
- Example: ctx.setProps(fieldModel, { value: "new value" })`}}),_.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",formValues:{description:"\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",detail:"Record<string, any>",examples:["const { name, status } = ctx.formValues || {};"]}},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"})},64727:function(p,o,e){e.r(o),e.d(o,{JSColumnRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),s=e(12444),l=e.n(s),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(67946),_=function(c){u()(n,c);var b=i()(n);function n(){return l()(this,n),b.apply(this,arguments)}return r()(n)}(m.Uo);_.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)`"}}),_.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"})},40113:function(p,o,e){e.r(o),e.d(o,{JSFieldRunJSContext:function(){return _}});var t=e(72004),r=e.n(t),s=e(12444),l=e.n(s),a=e(31996),u=e.n(a),d=e(26037),i=e.n(d),m=e(67946),_=function(c){u()(n,c);var b=i()(n);function n(){return l()(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"})},69844:function(p,o,e){e.r(o);var t=e(40113),r=e(67087),s=e(64727),l={contexts:[t.JSFieldRunJSContext,r.FormJSFieldItemRunJSContext,s.JSColumnRunJSContext],scenes:["detail","table"],prefix:"sn-jsf-status-tag",label:"Display status field as colored tag",description:"Display status values using colored tags",locales:{"zh-CN":{label:"\u5C06\u72B6\u6001\u5B57\u6BB5\u663E\u793A\u4E3A\u5F69\u8272\u6807\u7B7E",description:"\u6839\u636E\u72B6\u6001\u503C\u663E\u793A\u4E0D\u540C\u989C\u8272\u7684\u6807\u7B7E"}},content:`
13
- const statusColors = {
14
- active: 'green',
15
- pending: 'orange',
16
- inactive: 'gray',
17
- error: 'red',
18
- success: 'blue',
19
- };
20
-
21
- const status = String(ctx.value || 'unknown');
22
- const color = statusColors[status] || 'default';
23
-
24
- ctx.render(\`
25
- <span style="
26
- display: inline-block;
27
- padding: 2px 8px;
28
- border-radius: 4px;
29
- font-size: 12px;
30
- background-color: var(--\${color}-1, #f0f0f0);
31
- color: var(--\${color}-6, #333);
32
- border: 1px solid var(--\${color}-3, #d9d9d9);
33
- ">
34
- \${ctx.t(status)}
35
- </span>
36
- \`);
37
- `};o.default=l}}]);