"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.
      Supports innerHTML, append, and other DOM manipulation methods.`,value:`Current value of the field (read-only).
      Contains the data value stored in this field.`,record:`Current record data object (read-only).
      Contains all field values of the parent record.`,collection:`Collection definition metadata (read-only).
      Provides schema information about the collection this field belongs to.`},methods:{onRefReady:`Wait for field container DOM element to be ready before executing callback.
      Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
      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:`
const text = String(ctx.value ?? '');

const wrapper = document.createElement('span');
wrapper.style.display = 'inline-flex';
wrapper.style.alignItems = 'center';
wrapper.style.gap = '8px';

const valueEl = document.createElement('span');
valueEl.textContent = text;
valueEl.style.color = '#666';

const copyEl = document.createElement('a');
copyEl.textContent = ctx.t('Copy');
copyEl.style.cursor = 'pointer';
copyEl.style.color = '#1677ff';

copyEl.addEventListener('click', async () => {
  if (navigator?.clipboard?.writeText) {
    await navigator.clipboard.writeText(text);
  } else {
    const ta = document.createElement('textarea');
    ta.value = text;
    document.body.appendChild(ta);
    ta.select();
    document.execCommand('copy');
    document.body.removeChild(ta);
  }
  ctx.message.success(ctx.t('Copied'));
});

wrapper.appendChild(valueEl);
wrapper.appendChild(copyEl);

ctx.render(wrapper);
`};n.default=l}}]);
