n-design-readonly-plugin 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.5] - 2026-02-25
6
+
7
+ ### Added
8
+ - 复制时添加 ClipboardItem 不兼容提示
9
+
5
10
  ## [1.0.4] - 2026-02-11
6
11
 
7
12
  ### Added
package/dist/index.cjs.js CHANGED
@@ -54,4 +54,4 @@
54
54
  }
55
55
  `,ge=!1,ar=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nr;u.nextTick(function(){ge||(typeof window<"u"&&window.document&&window.document.documentElement&&Ze(t,{prepend:!0}),ge=!0)})},or=["icon","primaryColor","secondaryColor"];function ir(e,t){if(e==null)return{};var r=lr(e,t),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function lr(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,o;for(o=0;o<n.length;o++)a=n[o],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function U(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.forEach(function(a){fr(e,a,r[a])})}return e}function fr(e,t,r){return t=cr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cr(e){var t=ur(e,"string");return typeof t=="symbol"?t:String(t)}function ur(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var N={primaryColor:"#333",secondaryColor:"#E6E6E6",calculated:!1};function sr(e){var t=e.primaryColor,r=e.secondaryColor;N.primaryColor=t,N.secondaryColor=r||xe(t),N.calculated=!!r}function dr(){return U({},N)}var F=function(t,r){var n=U({},t,r.attrs),a=n.icon,o=n.primaryColor,i=n.secondaryColor,l=ir(n,or),f=N;if(o&&(f={primaryColor:o,secondaryColor:i||xe(o)}),ar(),tr(ye(a),"icon should be icon definiton, but got ".concat(a)),!ye(a))return null;var c=a;return c&&typeof c.icon=="function"&&(c=U({},c,{icon:c.icon(f.primaryColor,f.secondaryColor)})),te(c.icon,"svg-".concat(c.name),U({},l,{"data-icon":c.name,width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"}))};F.props={icon:Object,primaryColor:String,secondaryColor:String,focusable:String};F.inheritAttrs=!1;F.displayName="IconBase";F.getTwoToneColors=dr;F.setTwoToneColors=sr;function pr(e,t){return mr(e)||gr(e,t)||yr(e,t)||br()}function br(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
56
56
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yr(e,t){if(e){if(typeof e=="string")return me(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return me(e,t)}}function me(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function gr(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,o,i,l=[],f=!0,c=!1;try{if(o=(r=r.call(e)).next,t!==0)for(;!(f=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);f=!0);}catch(d){c=!0,a=d}finally{try{if(!f&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw a}}return l}}function mr(e){if(Array.isArray(e))return e}function Oe(e){var t=ke(e),r=pr(t,2),n=r[0],a=r[1];return F.setTwoToneColors({primaryColor:n,secondaryColor:a})}function hr(){var e=F.getTwoToneColors();return e.calculated?[e.primaryColor,e.secondaryColor]:e.primaryColor}var vr=["class","icon","spin","rotate","tabindex","twoToneColor","onClick"];function wr(e,t){return kr(e)||xr(e,t)||Sr(e,t)||Cr()}function Cr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
57
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(e,t){if(e){if(typeof e=="string")return he(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return he(e,t)}}function he(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function xr(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,o,i,l=[],f=!0,c=!1;try{if(o=(r=r.call(e)).next,t!==0)for(;!(f=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);f=!0);}catch(d){c=!0,a=d}finally{try{if(!f&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw a}}return l}}function kr(e){if(Array.isArray(e))return e}function ve(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.forEach(function(a){ne(e,a,r[a])})}return e}function ne(e,t,r){return t=Or(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Or(e){var t=Tr(e,"string");return typeof t=="symbol"?t:String(t)}function Tr(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jr(e,t){if(e==null)return{};var r=Ar(e,t),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Ar(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,o;for(o=0;o<n.length;o++)a=n[o],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}Oe("#1890ff");var M=function(t,r){var n,a=ve({},t,r.attrs),o=a.class,i=a.icon,l=a.spin,f=a.rotate,c=a.tabindex,d=a.twoToneColor,k=a.onClick,h=jr(a,vr),j=(n={anticon:!0},ne(n,"anticon-".concat(i.name),!!i.name),ne(n,o,o),n),b=l===""||l||i.name==="loading"?"anticon-spin":"",y=c;y===void 0&&k&&(y=-1,h.tabindex=y);var s=f?{msTransform:"rotate(".concat(f,"deg)"),transform:"rotate(".concat(f,"deg)")}:void 0,g=ke(d),v=wr(g,2),w=v[0],A=v[1];return u.createVNode("span",ve({role:"img","aria-label":i.name},h,{onClick:k,class:j}),[u.createVNode(F,{class:b,icon:i,primaryColor:w,secondaryColor:A,style:s},null)])};M.props={spin:Boolean,rotate:Number,icon:Object,twoToneColor:String};M.displayName="AntdIcon";M.inheritAttrs=!1;M.getTwoToneColor=hr;M.setTwoToneColor=Oe;var Pr={icon:{tag:"svg",attrs:{viewBox:"32 32 960 960",focusable:"false"},children:[{tag:"path",attrs:{d:"M384 32a96 96 0 00-96 96v96a32 32 0 0064 0v-96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32h-96a32 32 0 000 64h96a96 96 0 0096-96V128a96 96 0 00-96-96H384z"}},{tag:"path",attrs:{d:"M128 288a96 96 0 00-96 96v512a96 96 0 0096 96h512a96 96 0 0096-96V384a96 96 0 00-96-96H128zm-32 96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32H128a32 32 0 01-32-32V384z"}}]},name:"copy",theme:"outlined"};function we(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.forEach(function(a){Er(e,a,r[a])})}return e}function Er(e,t,r){return t=Fr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fr(e){var t=Ir(e,"string");return typeof t=="symbol"?t:String(t)}function Ir(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ae=function(t,r){var n=we({},t,r.attrs);return u.createVNode(M,we({},n,{icon:Pr}),null)};ae.displayName="CopyOutlined";ae.inheritAttrs=!1;function _(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(_).join("");if(typeof e=="object"){if(typeof e.children=="string")return e.children;if(e?.default&&typeof e.default=="function"){const t=e.default();if(Array.isArray(t))return _(t)}e.children&&_(e.children)}return""}function Te(e,t={}){const r=new Map,{value:n="value",label:a="label"}=t;if(!e)return r;const o=Array.isArray(e)?e:[e];for(const i of o)if(!(!i||typeof i!="object")){if(i.type&&(typeof i.type=="object"||typeof i.type=="function")){let l=i.type.name?.toLowerCase()||"";if(typeof i.type=="function"?l=i.type.displayName?.toLowerCase()||"":typeof i.type=="string"&&(l=i.type?.toLowerCase()||""),/option|radio|checkbox/i.test(l)){const f=i.props||{},c=f[n]??f.value,d=f[a]??f.label;if(c!=null){const k=_(i.children)||d||String(c);r.set(c,k)}}}i.children&&Te(i.children,t).forEach((f,c)=>{r.has(c)||r.set(c,f)})}return r}function Mr(e,t,r){const{value:n="value",label:a="label",children:o="children"}=r,i=[];let l=e;for(const f of t){const c=l.find(d=>d[n]===f);if(c)i.push(c[a]||c[n]||String(f)),l=c[o]||[];else{i.push(String(f));break}}return i}function Rr(e,t,r){const{value:n="value",label:a="title",children:o="children"}=r,i=[],l=new Set(Array.isArray(t)?t:[t]);function f(c){for(const d of c)l.has(d[n])&&i.push(d[a]||d[n]),d[o]&&f(d[o])}return f(e),i}function $r({modelValue:e,options:t,treeData:r,valueToLabel:n,fieldNames:a,slots:o,isSelect:i,isRadioGroup:l,isCheckboxGroup:f,isCheckbox:c,isRadio:d,isCascader:k,isTreeSelect:h,isSwitch:j,attrs:b,emptyText:y}){if(n)try{return n(e)||y}catch(s){console.warn("[ReadonlyHOC] valueToLabel error",s)}if(j){const s=b.checkedValue??b["checked-value"]??!0,g=b.uncheckedValue??b["un-checked-value"]??!1;return e===s?b.checkedChildren??b["checked-children"]??"开启":e===g?b.uncheckedChildren??b["un-checked-children"]??"关闭":String(e||y)}if(k&&Array.isArray(e)&&t?.length)return Mr(t,e,a).join(" / ")||y;if(h&&r?.length)return Rr(r,e,a).join(", ")||y;if(t?.length){const s=a.value||"value",g=a.label||"label",v=w=>{const A=t.find(W=>W[s]===w);return A?A[g]||A[s]:w==null?"":String(w)};return Array.isArray(e)?e.map(v).join(", ")||y:v(e)||y}else if((i||l||f)&&o?.default)try{const s=o.default(),g=Te(s,a);if(g.size>0){const v=w=>w==null?"":g.get(w)||String(w);return Array.isArray(e)?e.map(v).join(", ")||y:v(e)||y}}catch(s){console.warn("[ReadonlyHOC] Failed to parse slot options",s)}else if(o?.default&&(c||d)&&typeof e=="boolean")try{const s=o.default(),g=_(s);if(g)return g}catch{}return e==null||e===""?y:Array.isArray(e)?e.join(", "):String(e)}function je(e){if(typeof e=="function")return e;const t=e.name||"",r=t.toLowerCase(),n=/select/i.test(r)&&!/tree|cascader/i.test(r),a=/radio/i.test(r)&&!/group/i.test(r),o=/radio.*group/i.test(r),i=/checkbox/i.test(r)&&!/group/i.test(r),l=/checkbox.*group/i.test(r),f=/switch/i.test(r),c=/cascader/i.test(r),d=/tree.*select/i.test(r),h=i||f||a?"checked":"value",j=`update:${h}`,b=/form$/i.test(r),y=/form.*item/i.test(r);return u.defineComponent({name:t,inheritAttrs:!1,props:{modelValue:{type:[String,Number,Boolean,Array,Object],default:void 0},[h]:{type:[String,Number,Boolean,Array,Object],default:void 0},readonly:{type:Boolean,default:void 0},emptyText:{type:String,default:"--"},valueToLabel:{type:Function,default:null},copyable:{type:Boolean,default:void 0}},emits:["update:modelValue",j],setup(s,{emit:g,slots:v,expose:w}){const A=u.inject("nkReadonly",u.ref(!1)),W=u.inject("copyable",u.ref(!0)),P=u.computed(()=>s.readonly??A.value),q=u.computed(()=>s.readonly??A.value),G=u.computed(()=>s.copyable??W.value??!0),D=u.ref(!1);b&&(u.provide("nkReadonly",q),u.provide("copyable",G));const oe=u.computed(()=>s[h]!==void 0?s[h]:s.modelValue),Ae=m=>{g("update:modelValue",m),g(j,m)},S=u.useAttrs(),L=u.computed(()=>{if(!P.value)return"";const m=S.fieldNames??S["field-names"]??{},K=S.options,Ie=S.treeData??S["tree-data"];return $r({modelValue:oe.value,options:K,treeData:Ie,valueToLabel:s.valueToLabel,fieldNames:m,slots:v,isSelect:n,isRadioGroup:o,isCheckboxGroup:l,isCheckbox:i,isRadio:a,isCascader:c,isTreeSelect:d,isSwitch:f,attrs:S,emptyText:s.emptyText})}),Pe={lineHeight:"32px",padding:"0 6px",display:"inline-block",minHeight:"32px",cursor:"text",wordBreak:"break-all",color:"rgba(0, 0, 0, 0.85)",position:"relative",borderRadius:"4px",border:"none",backgroundColor:"none"},I=u.ref();b&&w({validate:()=>P.value?Promise.resolve({}):I.value?.validate?.(),validateFields:m=>P.value?Promise.resolve({}):I.value?.validateFields?.(m),resetFields:m=>!P.value&&I.value?.resetFields?.(m),clearValidate:m=>!P.value&&I.value?.clearValidate?.(m),scrollToField:m=>!P.value&&I.value?.scrollToField?.(m)});const Ee=()=>{D.value=!0},Fe=()=>{D.value=!1};return()=>y?u.h(e,{...S,style:{...S.style||{},marginBottom:P.value?"10px":void 0}},v):b?u.h(e,{...S,rules:q.value?null:S.rules,disabled:q.value?!0:S.disabled,ref:I},v):P.value?u.h("span",{onMouseenter:Ee,onMouseleave:Fe,class:"nk-readonly-wrapper",style:{...Pe,color:G.value&&D.value?"#6e9eff":"rgba(0, 0, 0, 0.65)"}},[u.h("span",{style:{marginRight:"8px"}},L.value),G.value&&L.value!==s.emptyText?u.h("span",{class:"copy-icon",style:{visibility:D.value?"visible":"hidden",marginLeft:"8px"}},[u.h(ae,{onClick:async()=>{if(window.__POWERED_BY_WUJIE__)await window.gvUtil?.clipboard(null,L.value);else{const m=new Blob([L.value],{type:"text/plain"}),K=new ClipboardItem({"text/plain":m});await navigator.clipboard.write([K]),p.message.success("复制成功")}},style:{cursor:"pointer",color:"#447dfd",fontSize:"12px",position:"absolute",top:"5px",right:"6px"}})]):null]):u.h(e,{...S,[h]:oe.value,[`onUpdate:${h}`]:Ae,ref:b?I:void 0},v)}})}const Nr={Input:p.Input,InputNumber:p.InputNumber,Textarea:p.Textarea,Select:p.Select,SelectOption:p.Select.Option,TreeSelect:p.TreeSelect,Cascader:p.Cascader,DatePicker:p.DatePicker,TimePicker:p.TimePicker,Radio:p.Radio,Checkbox:p.Checkbox,RadioGroup:p.Radio.Group,CheckboxGroup:p.Checkbox.Group,Switch:p.Switch,Form:p.Form,FormItem:p.Form.Item},_r={install(e){for(const[t,r]of Object.entries(Nr))if(r){const n=je(r);e.component(`Nk${t}`,n)}}};exports.default=_r;exports.withReadonly=je;
57
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(e,t){if(e){if(typeof e=="string")return he(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return he(e,t)}}function he(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function xr(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,o,i,l=[],f=!0,c=!1;try{if(o=(r=r.call(e)).next,t!==0)for(;!(f=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);f=!0);}catch(d){c=!0,a=d}finally{try{if(!f&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw a}}return l}}function kr(e){if(Array.isArray(e))return e}function ve(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.forEach(function(a){ne(e,a,r[a])})}return e}function ne(e,t,r){return t=Or(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Or(e){var t=Tr(e,"string");return typeof t=="symbol"?t:String(t)}function Tr(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jr(e,t){if(e==null)return{};var r=Ar(e,t),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Ar(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,o;for(o=0;o<n.length;o++)a=n[o],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}Oe("#1890ff");var M=function(t,r){var n,a=ve({},t,r.attrs),o=a.class,i=a.icon,l=a.spin,f=a.rotate,c=a.tabindex,d=a.twoToneColor,k=a.onClick,h=jr(a,vr),j=(n={anticon:!0},ne(n,"anticon-".concat(i.name),!!i.name),ne(n,o,o),n),b=l===""||l||i.name==="loading"?"anticon-spin":"",y=c;y===void 0&&k&&(y=-1,h.tabindex=y);var s=f?{msTransform:"rotate(".concat(f,"deg)"),transform:"rotate(".concat(f,"deg)")}:void 0,m=ke(d),v=wr(m,2),w=v[0],A=v[1];return u.createVNode("span",ve({role:"img","aria-label":i.name},h,{onClick:k,class:j}),[u.createVNode(F,{class:b,icon:i,primaryColor:w,secondaryColor:A,style:s},null)])};M.props={spin:Boolean,rotate:Number,icon:Object,twoToneColor:String};M.displayName="AntdIcon";M.inheritAttrs=!1;M.getTwoToneColor=hr;M.setTwoToneColor=Oe;var Pr={icon:{tag:"svg",attrs:{viewBox:"32 32 960 960",focusable:"false"},children:[{tag:"path",attrs:{d:"M384 32a96 96 0 00-96 96v96a32 32 0 0064 0v-96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32h-96a32 32 0 000 64h96a96 96 0 0096-96V128a96 96 0 00-96-96H384z"}},{tag:"path",attrs:{d:"M128 288a96 96 0 00-96 96v512a96 96 0 0096 96h512a96 96 0 0096-96V384a96 96 0 00-96-96H128zm-32 96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32H128a32 32 0 01-32-32V384z"}}]},name:"copy",theme:"outlined"};function we(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),n.forEach(function(a){Er(e,a,r[a])})}return e}function Er(e,t,r){return t=Fr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fr(e){var t=Ir(e,"string");return typeof t=="symbol"?t:String(t)}function Ir(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ae=function(t,r){var n=we({},t,r.attrs);return u.createVNode(M,we({},n,{icon:Pr}),null)};ae.displayName="CopyOutlined";ae.inheritAttrs=!1;function _(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(_).join("");if(typeof e=="object"){if(typeof e.children=="string")return e.children;if(e?.default&&typeof e.default=="function"){const t=e.default();if(Array.isArray(t))return _(t)}e.children&&_(e.children)}return""}function Te(e,t={}){const r=new Map,{value:n="value",label:a="label"}=t;if(!e)return r;const o=Array.isArray(e)?e:[e];for(const i of o)if(!(!i||typeof i!="object")){if(i.type&&(typeof i.type=="object"||typeof i.type=="function")){let l=i.type.name?.toLowerCase()||"";if(typeof i.type=="function"?l=i.type.displayName?.toLowerCase()||"":typeof i.type=="string"&&(l=i.type?.toLowerCase()||""),/option|radio|checkbox/i.test(l)){const f=i.props||{},c=f[n]??f.value,d=f[a]??f.label;if(c!=null){const k=_(i.children)||d||String(c);r.set(c,k)}}}i.children&&Te(i.children,t).forEach((f,c)=>{r.has(c)||r.set(c,f)})}return r}function Mr(e,t,r){const{value:n="value",label:a="label",children:o="children"}=r,i=[];let l=e;for(const f of t){const c=l.find(d=>d[n]===f);if(c)i.push(c[a]||c[n]||String(f)),l=c[o]||[];else{i.push(String(f));break}}return i}function Rr(e,t,r){const{value:n="value",label:a="title",children:o="children"}=r,i=[],l=new Set(Array.isArray(t)?t:[t]);function f(c){for(const d of c)l.has(d[n])&&i.push(d[a]||d[n]),d[o]&&f(d[o])}return f(e),i}function $r({modelValue:e,options:t,treeData:r,valueToLabel:n,fieldNames:a,slots:o,isSelect:i,isRadioGroup:l,isCheckboxGroup:f,isCheckbox:c,isRadio:d,isCascader:k,isTreeSelect:h,isSwitch:j,attrs:b,emptyText:y}){if(n)try{return n(e)||y}catch(s){console.warn("[ReadonlyHOC] valueToLabel error",s)}if(j){const s=b.checkedValue??b["checked-value"]??!0,m=b.uncheckedValue??b["un-checked-value"]??!1;return e===s?b.checkedChildren??b["checked-children"]??"开启":e===m?b.uncheckedChildren??b["un-checked-children"]??"关闭":String(e||y)}if(k&&Array.isArray(e)&&t?.length)return Mr(t,e,a).join(" / ")||y;if(h&&r?.length)return Rr(r,e,a).join(", ")||y;if(t?.length){const s=a.value||"value",m=a.label||"label",v=w=>{const A=t.find(W=>W[s]===w);return A?A[m]||A[s]:w==null?"":String(w)};return Array.isArray(e)?e.map(v).join(", ")||y:v(e)||y}else if((i||l||f)&&o?.default)try{const s=o.default(),m=Te(s,a);if(m.size>0){const v=w=>w==null?"":m.get(w)||String(w);return Array.isArray(e)?e.map(v).join(", ")||y:v(e)||y}}catch(s){console.warn("[ReadonlyHOC] Failed to parse slot options",s)}else if(o?.default&&(c||d)&&typeof e=="boolean")try{const s=o.default(),m=_(s);if(m)return m}catch{}return e==null||e===""?y:Array.isArray(e)?e.join(", "):String(e)}function je(e){if(typeof e=="function")return e;const t=e.name||"",r=t.toLowerCase(),n=/select/i.test(r)&&!/tree|cascader/i.test(r),a=/radio/i.test(r)&&!/group/i.test(r),o=/radio.*group/i.test(r),i=/checkbox/i.test(r)&&!/group/i.test(r),l=/checkbox.*group/i.test(r),f=/switch/i.test(r),c=/cascader/i.test(r),d=/tree.*select/i.test(r),h=i||f||a?"checked":"value",j=`update:${h}`,b=/form$/i.test(r),y=/form.*item/i.test(r);return u.defineComponent({name:t,inheritAttrs:!1,props:{modelValue:{type:[String,Number,Boolean,Array,Object],default:void 0},[h]:{type:[String,Number,Boolean,Array,Object],default:void 0},readonly:{type:Boolean,default:void 0},emptyText:{type:String,default:"--"},valueToLabel:{type:Function,default:null},copyable:{type:Boolean,default:void 0}},emits:["update:modelValue",j],setup(s,{emit:m,slots:v,expose:w}){const A=u.inject("nkReadonly",u.ref(!1)),W=u.inject("copyable",u.ref(!0)),P=u.computed(()=>s.readonly??A.value),q=u.computed(()=>s.readonly??A.value),G=u.computed(()=>s.copyable??W.value??!0),D=u.ref(!1);b&&(u.provide("nkReadonly",q),u.provide("copyable",G));const oe=u.computed(()=>s[h]!==void 0?s[h]:s.modelValue),Ae=g=>{m("update:modelValue",g),m(j,g)},S=u.useAttrs(),L=u.computed(()=>{if(!P.value)return"";const g=S.fieldNames??S["field-names"]??{},K=S.options,Ie=S.treeData??S["tree-data"];return $r({modelValue:oe.value,options:K,treeData:Ie,valueToLabel:s.valueToLabel,fieldNames:g,slots:v,isSelect:n,isRadioGroup:o,isCheckboxGroup:l,isCheckbox:i,isRadio:a,isCascader:c,isTreeSelect:d,isSwitch:f,attrs:S,emptyText:s.emptyText})}),Pe={lineHeight:"32px",padding:"0 6px",display:"inline-block",minHeight:"32px",cursor:"text",wordBreak:"break-all",color:"rgba(0, 0, 0, 0.85)",position:"relative",borderRadius:"4px",border:"none",backgroundColor:"none"},I=u.ref();b&&w({validate:()=>P.value?Promise.resolve({}):I.value?.validate?.(),validateFields:g=>P.value?Promise.resolve({}):I.value?.validateFields?.(g),resetFields:g=>!P.value&&I.value?.resetFields?.(g),clearValidate:g=>!P.value&&I.value?.clearValidate?.(g),scrollToField:g=>!P.value&&I.value?.scrollToField?.(g)});const Ee=()=>{D.value=!0},Fe=()=>{D.value=!1};return()=>y?u.h(e,{...S,style:{...S.style||{},marginBottom:P.value?"10px":void 0}},v):b?u.h(e,{...S,rules:q.value?null:S.rules,disabled:q.value?!0:S.disabled,ref:I},v):P.value?u.h("span",{onMouseenter:Ee,onMouseleave:Fe,class:"nk-readonly-wrapper",style:{...Pe,color:G.value&&D.value?"#6e9eff":"rgba(0, 0, 0, 0.65)"}},[u.h("span",{style:{marginRight:"8px"}},L.value),G.value&&L.value!==s.emptyText?u.h("span",{class:"copy-icon",style:{visibility:D.value?"visible":"hidden",marginLeft:"8px"}},[u.h(ae,{onClick:async()=>{try{if(window.__POWERED_BY_WUJIE__)await window.gvUtil?.clipboard(null,L.value);else{const g=new Blob([L.value],{type:"text/plain"}),K=new ClipboardItem({"text/plain":g});await navigator.clipboard.write([K]),p.message.success("复制成功")}}catch{p.message.error("您的浏览器不支持自动复制,请手动复制")}},style:{cursor:"pointer",color:"#447dfd",fontSize:"12px",position:"absolute",top:"5px",right:"6px"}})]):null]):u.h(e,{...S,[h]:oe.value,[`onUpdate:${h}`]:Ae,ref:b?I:void 0},v)}})}const Nr={Input:p.Input,InputNumber:p.InputNumber,Textarea:p.Textarea,Select:p.Select,SelectOption:p.Select.Option,TreeSelect:p.TreeSelect,Cascader:p.Cascader,DatePicker:p.DatePicker,TimePicker:p.TimePicker,Radio:p.Radio,Checkbox:p.Checkbox,RadioGroup:p.Radio.Group,CheckboxGroup:p.Checkbox.Group,Switch:p.Switch,Form:p.Form,FormItem:p.Form.Item},_r={install(e){for(const[t,r]of Object.entries(Nr))if(r){const n=je(r);e.component(`Nk${t}`,n)}}};exports.default=_r;exports.withReadonly=je;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { nextTick as He, h as k, createVNode as te, defineComponent as Be, inject as fe, ref as H, computed as M, provide as ce, useAttrs as ze } from "vue";
2
- import { message as Ue, Form as ue, Checkbox as se, Radio as de, Select as pe, Switch as We, TimePicker as Ge, DatePicker as qe, Cascader as Ke, TreeSelect as Ve, Textarea as Ye, InputNumber as Je, Input as Ze } from "n-designv3";
1
+ import { nextTick as Be, h as k, createVNode as te, defineComponent as ze, inject as fe, ref as H, computed as M, provide as ce, useAttrs as Ue } from "vue";
2
+ import { message as ue, Form as se, Checkbox as de, Radio as pe, Select as be, Switch as We, TimePicker as Ge, DatePicker as qe, Cascader as Ke, TreeSelect as Ve, Textarea as Ye, InputNumber as Je, Input as Ze } from "n-designv3";
3
3
  function C(e, t) {
4
4
  Qe(e) && (e = "100%");
5
5
  var r = Xe(e);
@@ -74,13 +74,13 @@ function or(e, t, r, n) {
74
74
  ];
75
75
  return a.join("");
76
76
  }
77
- function be(e) {
77
+ function ye(e) {
78
78
  return h(e) / 255;
79
79
  }
80
80
  function h(e) {
81
81
  return parseInt(e, 16);
82
82
  }
83
- var ye = {
83
+ var ge = {
84
84
  aliceblue: "#f0f8ff",
85
85
  antiquewhite: "#faebd7",
86
86
  aqua: "#00ffff",
@@ -258,8 +258,8 @@ function fr(e) {
258
258
  if (e = e.trim().toLowerCase(), e.length === 0)
259
259
  return !1;
260
260
  var t = !1;
261
- if (ye[e])
262
- e = ye[e], t = !0;
261
+ if (ge[e])
262
+ e = ge[e], t = !0;
263
263
  else if (e === "transparent")
264
264
  return { r: 0, g: 0, b: 0, a: 0, format: "name" };
265
265
  var r = x.rgb.exec(e);
@@ -267,7 +267,7 @@ function fr(e) {
267
267
  r: h(r[1]),
268
268
  g: h(r[2]),
269
269
  b: h(r[3]),
270
- a: be(r[4]),
270
+ a: ye(r[4]),
271
271
  format: t ? "name" : "hex8"
272
272
  } : (r = x.hex6.exec(e), r ? {
273
273
  r: h(r[1]),
@@ -278,7 +278,7 @@ function fr(e) {
278
278
  r: h(r[1] + r[1]),
279
279
  g: h(r[2] + r[2]),
280
280
  b: h(r[3] + r[3]),
281
- a: be(r[4] + r[4]),
281
+ a: ye(r[4] + r[4]),
282
282
  format: t ? "name" : "hex8"
283
283
  } : (r = x.hex3.exec(e), r ? {
284
284
  r: h(r[1] + r[1]),
@@ -290,7 +290,7 @@ function fr(e) {
290
290
  function O(e) {
291
291
  return !!x.CSS_UNIT.exec(String(e));
292
292
  }
293
- var z = 2, ge = 0.16, cr = 0.05, ur = 0.05, sr = 0.15, Pe = 5, Ee = 4, dr = [{
293
+ var z = 2, me = 0.16, cr = 0.05, ur = 0.05, sr = 0.15, Ee = 5, Fe = 4, dr = [{
294
294
  index: 7,
295
295
  opacity: 0.15
296
296
  }, {
@@ -321,7 +321,7 @@ var z = 2, ge = 0.16, cr = 0.05, ur = 0.05, sr = 0.15, Pe = 5, Ee = 4, dr = [{
321
321
  index: 1,
322
322
  opacity: 0.98
323
323
  }];
324
- function me(e) {
324
+ function ve(e) {
325
325
  var t = e.r, r = e.g, n = e.b, a = nr(t, r, n);
326
326
  return {
327
327
  h: a.h * 360,
@@ -341,35 +341,35 @@ function pr(e, t, r) {
341
341
  };
342
342
  return a;
343
343
  }
344
- function ve(e, t, r) {
344
+ function he(e, t, r) {
345
345
  var n;
346
346
  return Math.round(e.h) >= 60 && Math.round(e.h) <= 240 ? n = r ? Math.round(e.h) - z * t : Math.round(e.h) + z * t : n = r ? Math.round(e.h) + z * t : Math.round(e.h) - z * t, n < 0 ? n += 360 : n >= 360 && (n -= 360), n;
347
347
  }
348
- function he(e, t, r) {
348
+ function we(e, t, r) {
349
349
  if (e.h === 0 && e.s === 0)
350
350
  return e.s;
351
351
  var n;
352
- return r ? n = e.s - ge * t : t === Ee ? n = e.s + ge : n = e.s + cr * t, n > 1 && (n = 1), r && t === Pe && n > 0.1 && (n = 0.1), n < 0.06 && (n = 0.06), Number(n.toFixed(2));
352
+ return r ? n = e.s - me * t : t === Fe ? n = e.s + me : n = e.s + cr * t, n > 1 && (n = 1), r && t === Ee && n > 0.1 && (n = 0.1), n < 0.06 && (n = 0.06), Number(n.toFixed(2));
353
353
  }
354
- function we(e, t, r) {
354
+ function Ce(e, t, r) {
355
355
  var n;
356
356
  return r ? n = e.v + ur * t : n = e.v - sr * t, n > 1 && (n = 1), Number(n.toFixed(2));
357
357
  }
358
358
  function ne(e) {
359
- for (var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = [], n = $(e), a = Pe; a > 0; a -= 1) {
360
- var o = me(n), i = U($({
361
- h: ve(o, a, !0),
362
- s: he(o, a, !0),
363
- v: we(o, a, !0)
359
+ for (var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = [], n = $(e), a = Ee; a > 0; a -= 1) {
360
+ var o = ve(n), i = U($({
361
+ h: he(o, a, !0),
362
+ s: we(o, a, !0),
363
+ v: Ce(o, a, !0)
364
364
  }));
365
365
  r.push(i);
366
366
  }
367
367
  r.push(U(n));
368
- for (var l = 1; l <= Ee; l += 1) {
369
- var f = me(n), c = U($({
370
- h: ve(f, l),
371
- s: he(f, l),
372
- v: we(f, l)
368
+ for (var l = 1; l <= Fe; l += 1) {
369
+ var f = ve(n), c = U($({
370
+ h: he(f, l),
371
+ s: we(f, l),
372
+ v: Ce(f, l)
373
373
  }));
374
374
  r.push(c);
375
375
  }
@@ -399,7 +399,7 @@ Object.keys(X).forEach(function(e) {
399
399
  backgroundColor: "#141414"
400
400
  }), re[e].primary = re[e][5];
401
401
  });
402
- var Ce = [], R = [], br = "insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).";
402
+ var Se = [], R = [], br = "insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).";
403
403
  function yr() {
404
404
  var e = document.createElement("style");
405
405
  return e.setAttribute("type", "text/css"), e;
@@ -407,12 +407,12 @@ function yr() {
407
407
  function gr(e, t) {
408
408
  if (t = t || {}, e === void 0)
409
409
  throw new Error(br);
410
- var r = t.prepend === !0 ? "prepend" : "append", n = t.container !== void 0 ? t.container : document.querySelector("head"), a = Ce.indexOf(n);
411
- a === -1 && (a = Ce.push(n) - 1, R[a] = {});
410
+ var r = t.prepend === !0 ? "prepend" : "append", n = t.container !== void 0 ? t.container : document.querySelector("head"), a = Se.indexOf(n);
411
+ a === -1 && (a = Se.push(n) - 1, R[a] = {});
412
412
  var o;
413
413
  return R[a] !== void 0 && R[a][r] !== void 0 ? o = R[a][r] : (o = R[a][r] = yr(), r === "prepend" ? n.insertBefore(o, n.childNodes[0]) : n.appendChild(o)), e.charCodeAt(0) === 65279 && (e = e.substr(1, e.length)), o.styleSheet ? o.styleSheet.cssText += e : o.textContent += e, o;
414
414
  }
415
- function Se(e) {
415
+ function xe(e) {
416
416
  for (var t = 1; t < arguments.length; t++) {
417
417
  var r = arguments[t] != null ? Object(arguments[t]) : {}, n = Object.keys(r);
418
418
  typeof Object.getOwnPropertySymbols == "function" && n.push.apply(n, Object.getOwnPropertySymbols(r).filter(function(a) {
@@ -446,24 +446,24 @@ function wr(e, t) {
446
446
  function Cr(e, t) {
447
447
  wr(e, "[@nancal-icon/icons-vue] ".concat(t));
448
448
  }
449
- function xe(e) {
449
+ function Oe(e) {
450
450
  return typeof e == "object" && typeof e.name == "string" && typeof e.theme == "string" && (typeof e.icon == "object" || typeof e.icon == "function");
451
451
  }
452
452
  function ae(e, t, r) {
453
- return r ? k(e.tag, Se({
453
+ return r ? k(e.tag, xe({
454
454
  key: t
455
455
  }, r, e.attrs), (e.children || []).map(function(n, a) {
456
456
  return ae(n, "".concat(t, "-").concat(e.tag, "-").concat(a));
457
- })) : k(e.tag, Se({
457
+ })) : k(e.tag, xe({
458
458
  key: t
459
459
  }, e.attrs), (e.children || []).map(function(n, a) {
460
460
  return ae(n, "".concat(t, "-").concat(e.tag, "-").concat(a));
461
461
  }));
462
462
  }
463
- function Fe(e) {
463
+ function Ie(e) {
464
464
  return ne(e)[0];
465
465
  }
466
- function Ie(e) {
466
+ function Me(e) {
467
467
  return e ? Array.isArray(e) ? e : [e] : [];
468
468
  }
469
469
  var Sr = `
@@ -520,12 +520,12 @@ var Sr = `
520
520
  transform: rotate(360deg);
521
521
  }
522
522
  }
523
- `, Oe = !1, xr = function() {
523
+ `, ke = !1, xr = function() {
524
524
  var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Sr;
525
- He(function() {
526
- Oe || (typeof window < "u" && window.document && window.document.documentElement && gr(t, {
525
+ Be(function() {
526
+ ke || (typeof window < "u" && window.document && window.document.documentElement && gr(t, {
527
527
  prepend: !0
528
- }), Oe = !0);
528
+ }), ke = !0);
529
529
  });
530
530
  }, Or = ["icon", "primaryColor", "secondaryColor"];
531
531
  function kr(e, t) {
@@ -580,7 +580,7 @@ var N = {
580
580
  };
581
581
  function Er(e) {
582
582
  var t = e.primaryColor, r = e.secondaryColor;
583
- N.primaryColor = t, N.secondaryColor = r || Fe(t), N.calculated = !!r;
583
+ N.primaryColor = t, N.secondaryColor = r || Ie(t), N.calculated = !!r;
584
584
  }
585
585
  function Fr() {
586
586
  return W({}, N);
@@ -589,8 +589,8 @@ var E = function(t, r) {
589
589
  var n = W({}, t, r.attrs), a = n.icon, o = n.primaryColor, i = n.secondaryColor, l = kr(n, Or), f = N;
590
590
  if (o && (f = {
591
591
  primaryColor: o,
592
- secondaryColor: i || Fe(o)
593
- }), xr(), Cr(xe(a), "icon should be icon definiton, but got ".concat(a)), !xe(a))
592
+ secondaryColor: i || Ie(o)
593
+ }), xr(), Cr(Oe(a), "icon should be icon definiton, but got ".concat(a)), !Oe(a))
594
594
  return null;
595
595
  var c = a;
596
596
  return c && typeof c.icon == "function" && (c = W({}, c, {
@@ -622,13 +622,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
622
622
  }
623
623
  function $r(e, t) {
624
624
  if (e) {
625
- if (typeof e == "string") return ke(e, t);
625
+ if (typeof e == "string") return Te(e, t);
626
626
  var r = Object.prototype.toString.call(e).slice(8, -1);
627
627
  if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
628
- if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return ke(e, t);
628
+ if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return Te(e, t);
629
629
  }
630
630
  }
631
- function ke(e, t) {
631
+ function Te(e, t) {
632
632
  (t == null || t > e.length) && (t = e.length);
633
633
  for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
634
634
  return n;
@@ -654,8 +654,8 @@ function Rr(e, t) {
654
654
  function Nr(e) {
655
655
  if (Array.isArray(e)) return e;
656
656
  }
657
- function Me(e) {
658
- var t = Ie(e), r = Ir(t, 2), n = r[0], a = r[1];
657
+ function $e(e) {
658
+ var t = Me(e), r = Ir(t, 2), n = r[0], a = r[1];
659
659
  return E.setTwoToneColors({
660
660
  primaryColor: n,
661
661
  secondaryColor: a
@@ -675,13 +675,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
675
675
  }
676
676
  function Br(e, t) {
677
677
  if (e) {
678
- if (typeof e == "string") return Te(e, t);
678
+ if (typeof e == "string") return Ae(e, t);
679
679
  var r = Object.prototype.toString.call(e).slice(8, -1);
680
680
  if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
681
- if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return Te(e, t);
681
+ if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return Ae(e, t);
682
682
  }
683
683
  }
684
- function Te(e, t) {
684
+ function Ae(e, t) {
685
685
  (t == null || t > e.length) && (t = e.length);
686
686
  for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
687
687
  return n;
@@ -707,7 +707,7 @@ function zr(e, t) {
707
707
  function Ur(e) {
708
708
  if (Array.isArray(e)) return e;
709
709
  }
710
- function Ae(e) {
710
+ function je(e) {
711
711
  for (var t = 1; t < arguments.length; t++) {
712
712
  var r = arguments[t] != null ? Object(arguments[t]) : {}, n = Object.keys(r);
713
713
  typeof Object.getOwnPropertySymbols == "function" && n.push.apply(n, Object.getOwnPropertySymbols(r).filter(function(a) {
@@ -752,17 +752,17 @@ function Kr(e, t) {
752
752
  a = n[o], !(t.indexOf(a) >= 0) && (r[a] = e[a]);
753
753
  return r;
754
754
  }
755
- Me("#1890ff");
755
+ $e("#1890ff");
756
756
  var I = function(t, r) {
757
- var n, a = Ae({}, t, r.attrs), o = a.class, i = a.icon, l = a.spin, f = a.rotate, c = a.tabindex, s = a.twoToneColor, S = a.onClick, g = qr(a, Lr), T = (n = {
757
+ var n, a = je({}, t, r.attrs), o = a.class, i = a.icon, l = a.spin, f = a.rotate, c = a.tabindex, s = a.twoToneColor, S = a.onClick, g = qr(a, Lr), T = (n = {
758
758
  anticon: !0
759
759
  }, oe(n, "anticon-".concat(i.name), !!i.name), oe(n, o, o), n), d = l === "" || l || i.name === "loading" ? "anticon-spin" : "", p = c;
760
760
  p === void 0 && S && (p = -1, g.tabindex = p);
761
761
  var u = f ? {
762
762
  msTransform: "rotate(".concat(f, "deg)"),
763
763
  transform: "rotate(".concat(f, "deg)")
764
- } : void 0, b = Ie(s), m = Dr(b, 2), v = m[0], A = m[1];
765
- return te("span", Ae({
764
+ } : void 0, y = Me(s), m = Dr(y, 2), v = m[0], A = m[1];
765
+ return te("span", je({
766
766
  role: "img",
767
767
  "aria-label": i.name
768
768
  }, g, {
@@ -785,9 +785,9 @@ I.props = {
785
785
  I.displayName = "AntdIcon";
786
786
  I.inheritAttrs = !1;
787
787
  I.getTwoToneColor = _r;
788
- I.setTwoToneColor = Me;
788
+ I.setTwoToneColor = $e;
789
789
  var Vr = { icon: { tag: "svg", attrs: { viewBox: "32 32 960 960", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M384 32a96 96 0 00-96 96v96a32 32 0 0064 0v-96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32h-96a32 32 0 000 64h96a96 96 0 0096-96V128a96 96 0 00-96-96H384z" } }, { tag: "path", attrs: { d: "M128 288a96 96 0 00-96 96v512a96 96 0 0096 96h512a96 96 0 0096-96V384a96 96 0 00-96-96H128zm-32 96a32 32 0 0132-32h512a32 32 0 0132 32v512a32 32 0 01-32 32H128a32 32 0 01-32-32V384z" } }] }, name: "copy", theme: "outlined" };
790
- function je(e) {
790
+ function Pe(e) {
791
791
  for (var t = 1; t < arguments.length; t++) {
792
792
  var r = arguments[t] != null ? Object(arguments[t]) : {}, n = Object.keys(r);
793
793
  typeof Object.getOwnPropertySymbols == "function" && n.push.apply(n, Object.getOwnPropertySymbols(r).filter(function(a) {
@@ -816,8 +816,8 @@ function Zr(e, t) {
816
816
  return (t === "string" ? String : Number)(e);
817
817
  }
818
818
  var ie = function(t, r) {
819
- var n = je({}, t, r.attrs);
820
- return te(I, je({}, n, {
819
+ var n = Pe({}, t, r.attrs);
820
+ return te(I, Pe({}, n, {
821
821
  icon: Vr
822
822
  }), null);
823
823
  };
@@ -839,7 +839,7 @@ function _(e) {
839
839
  }
840
840
  return "";
841
841
  }
842
- function $e(e, t = {}) {
842
+ function Re(e, t = {}) {
843
843
  const r = /* @__PURE__ */ new Map(), { value: n = "value", label: a = "label" } = t;
844
844
  if (!e) return r;
845
845
  const o = Array.isArray(e) ? e : [e];
@@ -855,7 +855,7 @@ function $e(e, t = {}) {
855
855
  }
856
856
  }
857
857
  }
858
- i.children && $e(i.children, t).forEach((f, c) => {
858
+ i.children && Re(i.children, t).forEach((f, c) => {
859
859
  r.has(c) || r.set(c, f);
860
860
  });
861
861
  }
@@ -908,24 +908,24 @@ function et({
908
908
  console.warn("[ReadonlyHOC] valueToLabel error", u);
909
909
  }
910
910
  if (T) {
911
- const u = d.checkedValue ?? d["checked-value"] ?? !0, b = d.uncheckedValue ?? d["un-checked-value"] ?? !1;
912
- return e === u ? d.checkedChildren ?? d["checked-children"] ?? "开启" : e === b ? d.uncheckedChildren ?? d["un-checked-children"] ?? "关闭" : String(e || p);
911
+ const u = d.checkedValue ?? d["checked-value"] ?? !0, y = d.uncheckedValue ?? d["un-checked-value"] ?? !1;
912
+ return e === u ? d.checkedChildren ?? d["checked-children"] ?? "开启" : e === y ? d.uncheckedChildren ?? d["un-checked-children"] ?? "关闭" : String(e || p);
913
913
  }
914
914
  if (S && Array.isArray(e) && t?.length)
915
915
  return Qr(t, e, a).join(" / ") || p;
916
916
  if (g && r?.length)
917
917
  return Xr(r, e, a).join(", ") || p;
918
918
  if (t?.length) {
919
- const u = a.value || "value", b = a.label || "label", m = (v) => {
919
+ const u = a.value || "value", y = a.label || "label", m = (v) => {
920
920
  const A = t.find((G) => G[u] === v);
921
- return A ? A[b] || A[u] : v == null ? "" : String(v);
921
+ return A ? A[y] || A[u] : v == null ? "" : String(v);
922
922
  };
923
923
  return Array.isArray(e) ? e.map(m).join(", ") || p : m(e) || p;
924
924
  } else if ((i || l || f) && o?.default)
925
925
  try {
926
- const u = o.default(), b = $e(u, a);
927
- if (b.size > 0) {
928
- const m = (v) => v == null ? "" : b.get(v) || String(v);
926
+ const u = o.default(), y = Re(u, a);
927
+ if (y.size > 0) {
928
+ const m = (v) => v == null ? "" : y.get(v) || String(v);
929
929
  return Array.isArray(e) ? e.map(m).join(", ") || p : m(e) || p;
930
930
  }
931
931
  } catch (u) {
@@ -933,8 +933,8 @@ function et({
933
933
  }
934
934
  else if (o?.default && (c || s) && typeof e == "boolean")
935
935
  try {
936
- const u = o.default(), b = _(u);
937
- if (b) return b;
936
+ const u = o.default(), y = _(u);
937
+ if (y) return y;
938
938
  } catch {
939
939
  }
940
940
  return e == null || e === "" ? p : Array.isArray(e) ? e.join(", ") : String(e);
@@ -943,7 +943,7 @@ function rt(e) {
943
943
  if (typeof e == "function")
944
944
  return e;
945
945
  const t = e.name || "", r = t.toLowerCase(), n = /select/i.test(r) && !/tree|cascader/i.test(r), a = /radio/i.test(r) && !/group/i.test(r), o = /radio.*group/i.test(r), i = /checkbox/i.test(r) && !/group/i.test(r), l = /checkbox.*group/i.test(r), f = /switch/i.test(r), c = /cascader/i.test(r), s = /tree.*select/i.test(r), g = i || f || a ? "checked" : "value", T = `update:${g}`, d = /form$/i.test(r), p = /form.*item/i.test(r);
946
- return Be({
946
+ return ze({
947
947
  name: t,
948
948
  inheritAttrs: !1,
949
949
  props: {
@@ -955,20 +955,20 @@ function rt(e) {
955
955
  copyable: { type: Boolean, default: void 0 }
956
956
  },
957
957
  emits: ["update:modelValue", T],
958
- setup(u, { emit: b, slots: m, expose: v }) {
958
+ setup(u, { emit: y, slots: m, expose: v }) {
959
959
  const A = fe("nkReadonly", H(!1)), G = fe("copyable", H(!0)), j = M(() => u.readonly ?? A.value), q = M(() => u.readonly ?? A.value), K = M(() => u.copyable ?? G.value ?? !0), L = H(!1);
960
960
  d && (ce("nkReadonly", q), ce("copyable", K));
961
- const le = M(() => u[g] !== void 0 ? u[g] : u.modelValue), Re = (y) => {
962
- b("update:modelValue", y), b(T, y);
963
- }, w = ze(), D = M(() => {
961
+ const le = M(() => u[g] !== void 0 ? u[g] : u.modelValue), Ne = (b) => {
962
+ y("update:modelValue", b), y(T, b);
963
+ }, w = Ue(), D = M(() => {
964
964
  if (!j.value) return "";
965
- const y = w.fieldNames ?? w["field-names"] ?? {}, V = w.options, De = w.treeData ?? w["tree-data"];
965
+ const b = w.fieldNames ?? w["field-names"] ?? {}, V = w.options, He = w.treeData ?? w["tree-data"];
966
966
  return et({
967
967
  modelValue: le.value,
968
968
  options: V,
969
- treeData: De,
969
+ treeData: He,
970
970
  valueToLabel: u.valueToLabel,
971
- fieldNames: y,
971
+ fieldNames: b,
972
972
  slots: m,
973
973
  isSelect: n,
974
974
  isRadioGroup: o,
@@ -981,7 +981,7 @@ function rt(e) {
981
981
  attrs: w,
982
982
  emptyText: u.emptyText
983
983
  });
984
- }), Ne = {
984
+ }), _e = {
985
985
  lineHeight: "32px",
986
986
  padding: "0 6px",
987
987
  display: "inline-block",
@@ -996,14 +996,14 @@ function rt(e) {
996
996
  }, F = H();
997
997
  d && v({
998
998
  validate: () => j.value ? Promise.resolve({}) : F.value?.validate?.(),
999
- validateFields: (y) => j.value ? Promise.resolve({}) : F.value?.validateFields?.(y),
1000
- resetFields: (y) => !j.value && F.value?.resetFields?.(y),
1001
- clearValidate: (y) => !j.value && F.value?.clearValidate?.(y),
1002
- scrollToField: (y) => !j.value && F.value?.scrollToField?.(y)
999
+ validateFields: (b) => j.value ? Promise.resolve({}) : F.value?.validateFields?.(b),
1000
+ resetFields: (b) => !j.value && F.value?.resetFields?.(b),
1001
+ clearValidate: (b) => !j.value && F.value?.clearValidate?.(b),
1002
+ scrollToField: (b) => !j.value && F.value?.scrollToField?.(b)
1003
1003
  });
1004
- const _e = () => {
1004
+ const Le = () => {
1005
1005
  L.value = !0;
1006
- }, Le = () => {
1006
+ }, De = () => {
1007
1007
  L.value = !1;
1008
1008
  };
1009
1009
  return () => p ? k(
@@ -1025,11 +1025,11 @@ function rt(e) {
1025
1025
  ) : j.value ? k(
1026
1026
  "span",
1027
1027
  {
1028
- onMouseenter: _e,
1029
- onMouseleave: Le,
1028
+ onMouseenter: Le,
1029
+ onMouseleave: De,
1030
1030
  class: "nk-readonly-wrapper",
1031
1031
  style: {
1032
- ...Ne,
1032
+ ..._e,
1033
1033
  color: K.value && L.value ? "#6e9eff" : "rgba(0, 0, 0, 0.65)"
1034
1034
  }
1035
1035
  },
@@ -1049,11 +1049,15 @@ function rt(e) {
1049
1049
  ie,
1050
1050
  {
1051
1051
  onClick: async () => {
1052
- if (window.__POWERED_BY_WUJIE__)
1053
- await window.gvUtil?.clipboard(null, D.value);
1054
- else {
1055
- const y = new Blob([D.value], { type: "text/plain" }), V = new ClipboardItem({ "text/plain": y });
1056
- await navigator.clipboard.write([V]), Ue.success("复制成功");
1052
+ try {
1053
+ if (window.__POWERED_BY_WUJIE__)
1054
+ await window.gvUtil?.clipboard(null, D.value);
1055
+ else {
1056
+ const b = new Blob([D.value], { type: "text/plain" }), V = new ClipboardItem({ "text/plain": b });
1057
+ await navigator.clipboard.write([V]), ue.success("复制成功");
1058
+ }
1059
+ } catch {
1060
+ ue.error("您的浏览器不支持自动复制,请手动复制");
1057
1061
  }
1058
1062
  },
1059
1063
  style: {
@@ -1074,7 +1078,7 @@ function rt(e) {
1074
1078
  {
1075
1079
  ...w,
1076
1080
  [g]: le.value,
1077
- [`onUpdate:${g}`]: Re,
1081
+ [`onUpdate:${g}`]: Ne,
1078
1082
  ref: d ? F : void 0
1079
1083
  },
1080
1084
  m
@@ -1086,19 +1090,19 @@ const tt = {
1086
1090
  Input: Ze,
1087
1091
  InputNumber: Je,
1088
1092
  Textarea: Ye,
1089
- Select: pe,
1090
- SelectOption: pe.Option,
1093
+ Select: be,
1094
+ SelectOption: be.Option,
1091
1095
  TreeSelect: Ve,
1092
1096
  Cascader: Ke,
1093
1097
  DatePicker: qe,
1094
1098
  TimePicker: Ge,
1095
- Radio: de,
1096
- Checkbox: se,
1097
- RadioGroup: de.Group,
1098
- CheckboxGroup: se.Group,
1099
+ Radio: pe,
1100
+ Checkbox: de,
1101
+ RadioGroup: pe.Group,
1102
+ CheckboxGroup: de.Group,
1099
1103
  Switch: We,
1100
- Form: ue,
1101
- FormItem: ue.Item
1104
+ Form: se,
1105
+ FormItem: se.Item
1102
1106
  }, ot = {
1103
1107
  install(e) {
1104
1108
  for (const [t, r] of Object.entries(tt))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n-design-readonly-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "只读模式插件 for n-designv3",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",