n-design-readonly-plugin 1.0.5 → 1.0.7
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 +2 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +94 -90
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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,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;
|
|
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),y=l===""||l||i.name==="loading"?"anticon-spin":"",g=c;g===void 0&&k&&(g=-1,h.tabindex=g);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:y,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:y,emptyText:g}){if(n)try{return n(e)||g}catch(s){console.warn("[ReadonlyHOC] valueToLabel error",s)}if(j){const s=y.checkedValue??y["checked-value"]??!0,m=y.uncheckedValue??y["un-checked-value"]??!1;return e===s?y.checkedChildren??y["checked-children"]??"开启":e===m?y.uncheckedChildren??y["un-checked-children"]??"关闭":String(e||g)}if(k&&Array.isArray(e)&&t?.length)return Mr(t,e,a).join(" / ")||g;if(h&&r?.length)return Rr(r,e,a).join(", ")||g;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(", ")||g:v(e)||g}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(", ")||g:v(e)||g}}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===""?g: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}`,y=/form$/i.test(r),g=/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);y&&(u.provide("nkReadonly",q),u.provide("copyable",G));const oe=u.computed(()=>s[h]!==void 0?s[h]:s.modelValue),Ae=b=>{m("update:modelValue",b),m(j,b)},S=u.useAttrs(),L=u.computed(()=>{if(!P.value)return"";const b=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:b,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();y&&w({validate:()=>P.value?Promise.resolve({}):I.value?.validate?.(),validateFields:b=>P.value?Promise.resolve({}):I.value?.validateFields?.(b),resetFields:b=>!P.value&&I.value?.resetFields?.(b),clearValidate:b=>!P.value&&I.value?.clearValidate?.(b),scrollToField:b=>!P.value&&I.value?.scrollToField?.(b)});const Ee=()=>{D.value=!0},Fe=()=>{D.value=!1};return()=>g?u.h(e,{...S,style:{...S.style||{},marginBottom:P.value?"10px":void 0}},v):y?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__){if(await window.gvUtil?.clipboard(null,L.value)===!1){p.message.error("您的浏览器不支持自动复制,请手动复制");return}p.message.success("复制成功")}else{const b=new Blob([L.value],{type:"text/plain"}),K=new ClipboardItem({"text/plain":b});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:y?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 Be, h as k, createVNode as
|
|
2
|
-
import { message as
|
|
1
|
+
import { nextTick as Be, h as k, createVNode as ne, defineComponent as ze, inject as ce, ref as H, computed as M, provide as ue, useAttrs as Ue } from "vue";
|
|
2
|
+
import { message as B, 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);
|
|
@@ -14,10 +14,10 @@ function Xe(e) {
|
|
|
14
14
|
function er(e) {
|
|
15
15
|
return e = parseFloat(e), (isNaN(e) || e < 0 || e > 1) && (e = 1), e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function z(e) {
|
|
18
18
|
return e <= 1 ? "".concat(Number(e) * 100, "%") : e;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function J(e) {
|
|
21
21
|
return e.length === 1 ? "0" + e : String(e);
|
|
22
22
|
}
|
|
23
23
|
function rr(e, t, r) {
|
|
@@ -27,7 +27,7 @@ function rr(e, t, r) {
|
|
|
27
27
|
b: C(r, 255) * 255
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Z(e, t, r) {
|
|
31
31
|
return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? e + (t - e) * (6 * r) : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
|
|
32
32
|
}
|
|
33
33
|
function tr(e, t, r) {
|
|
@@ -36,7 +36,7 @@ function tr(e, t, r) {
|
|
|
36
36
|
a = r, o = r, n = r;
|
|
37
37
|
else {
|
|
38
38
|
var i = r < 0.5 ? r * (1 + t) : r + t - r * t, l = 2 * r - i;
|
|
39
|
-
n =
|
|
39
|
+
n = Z(l, i, e + 1 / 3), a = Z(l, i, e), o = Z(l, i, e - 1 / 3);
|
|
40
40
|
}
|
|
41
41
|
return { r: n * 255, g: a * 255, b: o * 255 };
|
|
42
42
|
}
|
|
@@ -68,9 +68,9 @@ function ar(e, t, r) {
|
|
|
68
68
|
}
|
|
69
69
|
function or(e, t, r, n) {
|
|
70
70
|
var a = [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
J(Math.round(e).toString(16)),
|
|
72
|
+
J(Math.round(t).toString(16)),
|
|
73
|
+
J(Math.round(r).toString(16))
|
|
74
74
|
];
|
|
75
75
|
return a.join("");
|
|
76
76
|
}
|
|
@@ -232,7 +232,7 @@ var ge = {
|
|
|
232
232
|
};
|
|
233
233
|
function $(e) {
|
|
234
234
|
var t = { r: 0, g: 0, b: 0 }, r = 1, n = null, a = null, o = null, i = !1, l = !1;
|
|
235
|
-
return typeof e == "string" && (e = fr(e)), typeof e == "object" && (O(e.r) && O(e.g) && O(e.b) ? (t = rr(e.r, e.g, e.b), i = !0, l = String(e.r).substr(-1) === "%" ? "prgb" : "rgb") : O(e.h) && O(e.s) && O(e.v) ? (n =
|
|
235
|
+
return typeof e == "string" && (e = fr(e)), typeof e == "object" && (O(e.r) && O(e.g) && O(e.b) ? (t = rr(e.r, e.g, e.b), i = !0, l = String(e.r).substr(-1) === "%" ? "prgb" : "rgb") : O(e.h) && O(e.s) && O(e.v) ? (n = z(e.s), a = z(e.v), t = ar(e.h, n, a), i = !0, l = "hsv") : O(e.h) && O(e.s) && O(e.l) && (n = z(e.s), o = z(e.l), t = tr(e.h, n, o), i = !0, l = "hsl"), Object.prototype.hasOwnProperty.call(e, "a") && (r = e.a)), r = er(r), {
|
|
236
236
|
ok: i,
|
|
237
237
|
format: e.format || l,
|
|
238
238
|
r: Math.min(255, Math.max(t.r, 0)),
|
|
@@ -241,14 +241,14 @@ function $(e) {
|
|
|
241
241
|
a: r
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
|
-
var ir = "[-\\+]?\\d+%?", lr = "[-\\+]?\\d*\\.\\d+%?", P = "(?:".concat(lr, ")|(?:").concat(ir, ")"),
|
|
244
|
+
var ir = "[-\\+]?\\d+%?", lr = "[-\\+]?\\d*\\.\\d+%?", P = "(?:".concat(lr, ")|(?:").concat(ir, ")"), Q = "[\\s|\\(]+(".concat(P, ")[,|\\s]+(").concat(P, ")[,|\\s]+(").concat(P, ")\\s*\\)?"), X = "[\\s|\\(]+(".concat(P, ")[,|\\s]+(").concat(P, ")[,|\\s]+(").concat(P, ")[,|\\s]+(").concat(P, ")\\s*\\)?"), x = {
|
|
245
245
|
CSS_UNIT: new RegExp(P),
|
|
246
|
-
rgb: new RegExp("rgb" +
|
|
247
|
-
rgba: new RegExp("rgba" +
|
|
248
|
-
hsl: new RegExp("hsl" +
|
|
249
|
-
hsla: new RegExp("hsla" +
|
|
250
|
-
hsv: new RegExp("hsv" +
|
|
251
|
-
hsva: new RegExp("hsva" +
|
|
246
|
+
rgb: new RegExp("rgb" + Q),
|
|
247
|
+
rgba: new RegExp("rgba" + X),
|
|
248
|
+
hsl: new RegExp("hsl" + Q),
|
|
249
|
+
hsla: new RegExp("hsla" + X),
|
|
250
|
+
hsv: new RegExp("hsv" + Q),
|
|
251
|
+
hsva: new RegExp("hsva" + X),
|
|
252
252
|
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
253
253
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
254
254
|
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{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
|
|
293
|
+
var U = 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
|
}, {
|
|
@@ -329,7 +329,7 @@ function ve(e) {
|
|
|
329
329
|
v: a.v
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function W(e) {
|
|
333
333
|
var t = e.r, r = e.g, n = e.b;
|
|
334
334
|
return "#".concat(or(t, r, n));
|
|
335
335
|
}
|
|
@@ -343,7 +343,7 @@ function pr(e, t, r) {
|
|
|
343
343
|
}
|
|
344
344
|
function he(e, t, r) {
|
|
345
345
|
var n;
|
|
346
|
-
return Math.round(e.h) >= 60 && Math.round(e.h) <= 240 ? n = r ? Math.round(e.h) -
|
|
346
|
+
return Math.round(e.h) >= 60 && Math.round(e.h) <= 240 ? n = r ? Math.round(e.h) - U * t : Math.round(e.h) + U * t : n = r ? Math.round(e.h) + U * t : Math.round(e.h) - U * t, n < 0 ? n += 360 : n >= 360 && (n -= 360), n;
|
|
347
347
|
}
|
|
348
348
|
function we(e, t, r) {
|
|
349
349
|
if (e.h === 0 && e.s === 0)
|
|
@@ -355,18 +355,18 @@ 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
|
-
function
|
|
358
|
+
function ae(e) {
|
|
359
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 =
|
|
360
|
+
var o = ve(n), i = W($({
|
|
361
361
|
h: he(o, a, !0),
|
|
362
362
|
s: we(o, a, !0),
|
|
363
363
|
v: Ce(o, a, !0)
|
|
364
364
|
}));
|
|
365
365
|
r.push(i);
|
|
366
366
|
}
|
|
367
|
-
r.push(
|
|
367
|
+
r.push(W(n));
|
|
368
368
|
for (var l = 1; l <= Fe; l += 1) {
|
|
369
|
-
var f = ve(n), c =
|
|
369
|
+
var f = ve(n), c = W($({
|
|
370
370
|
h: he(f, l),
|
|
371
371
|
s: we(f, l),
|
|
372
372
|
v: Ce(f, l)
|
|
@@ -374,11 +374,11 @@ function ne(e) {
|
|
|
374
374
|
r.push(c);
|
|
375
375
|
}
|
|
376
376
|
return t.theme === "dark" ? dr.map(function(s) {
|
|
377
|
-
var S = s.index, g = s.opacity, T =
|
|
377
|
+
var S = s.index, g = s.opacity, T = W(pr($(t.backgroundColor || "#141414"), $(r[S]), g * 100));
|
|
378
378
|
return T;
|
|
379
379
|
}) : r;
|
|
380
380
|
}
|
|
381
|
-
var
|
|
381
|
+
var ee = {
|
|
382
382
|
red: "#F5222D",
|
|
383
383
|
volcano: "#FA541C",
|
|
384
384
|
orange: "#FA8C16",
|
|
@@ -392,12 +392,12 @@ var X = {
|
|
|
392
392
|
purple: "#722ED1",
|
|
393
393
|
magenta: "#EB2F96",
|
|
394
394
|
grey: "#666666"
|
|
395
|
-
},
|
|
396
|
-
Object.keys(
|
|
397
|
-
|
|
395
|
+
}, re = {}, te = {};
|
|
396
|
+
Object.keys(ee).forEach(function(e) {
|
|
397
|
+
re[e] = ae(ee[e]), re[e].primary = re[e][5], te[e] = ae(ee[e], {
|
|
398
398
|
theme: "dark",
|
|
399
399
|
backgroundColor: "#141414"
|
|
400
|
-
}),
|
|
400
|
+
}), te[e].primary = te[e][5];
|
|
401
401
|
});
|
|
402
402
|
var Se = [], R = [], br = "insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).";
|
|
403
403
|
function yr() {
|
|
@@ -449,19 +449,19 @@ function Cr(e, t) {
|
|
|
449
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
|
-
function
|
|
452
|
+
function oe(e, t, r) {
|
|
453
453
|
return r ? k(e.tag, xe({
|
|
454
454
|
key: t
|
|
455
455
|
}, r, e.attrs), (e.children || []).map(function(n, a) {
|
|
456
|
-
return
|
|
456
|
+
return oe(n, "".concat(t, "-").concat(e.tag, "-").concat(a));
|
|
457
457
|
})) : k(e.tag, xe({
|
|
458
458
|
key: t
|
|
459
459
|
}, e.attrs), (e.children || []).map(function(n, a) {
|
|
460
|
-
return
|
|
460
|
+
return oe(n, "".concat(t, "-").concat(e.tag, "-").concat(a));
|
|
461
461
|
}));
|
|
462
462
|
}
|
|
463
463
|
function Ie(e) {
|
|
464
|
-
return
|
|
464
|
+
return ae(e)[0];
|
|
465
465
|
}
|
|
466
466
|
function Me(e) {
|
|
467
467
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
@@ -545,7 +545,7 @@ function Tr(e, t) {
|
|
|
545
545
|
a = n[o], !(t.indexOf(a) >= 0) && (r[a] = e[a]);
|
|
546
546
|
return r;
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function G(e) {
|
|
549
549
|
for (var t = 1; t < arguments.length; t++) {
|
|
550
550
|
var r = arguments[t] != null ? Object(arguments[t]) : {}, n = Object.keys(r);
|
|
551
551
|
typeof Object.getOwnPropertySymbols == "function" && n.push.apply(n, Object.getOwnPropertySymbols(r).filter(function(a) {
|
|
@@ -583,19 +583,19 @@ function Er(e) {
|
|
|
583
583
|
N.primaryColor = t, N.secondaryColor = r || Ie(t), N.calculated = !!r;
|
|
584
584
|
}
|
|
585
585
|
function Fr() {
|
|
586
|
-
return
|
|
586
|
+
return G({}, N);
|
|
587
587
|
}
|
|
588
588
|
var E = function(t, r) {
|
|
589
|
-
var n =
|
|
589
|
+
var n = G({}, 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
592
|
secondaryColor: i || Ie(o)
|
|
593
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
|
-
return c && typeof c.icon == "function" && (c =
|
|
596
|
+
return c && typeof c.icon == "function" && (c = G({}, c, {
|
|
597
597
|
icon: c.icon(f.primaryColor, f.secondaryColor)
|
|
598
|
-
})),
|
|
598
|
+
})), oe(c.icon, "svg-".concat(c.name), G({}, l, {
|
|
599
599
|
"data-icon": c.name,
|
|
600
600
|
width: "1em",
|
|
601
601
|
height: "1em",
|
|
@@ -713,12 +713,12 @@ function je(e) {
|
|
|
713
713
|
typeof Object.getOwnPropertySymbols == "function" && n.push.apply(n, Object.getOwnPropertySymbols(r).filter(function(a) {
|
|
714
714
|
return Object.getOwnPropertyDescriptor(r, a).enumerable;
|
|
715
715
|
})), n.forEach(function(a) {
|
|
716
|
-
|
|
716
|
+
ie(e, a, r[a]);
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
return e;
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function ie(e, t, r) {
|
|
722
722
|
return t = Wr(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
|
|
723
723
|
}
|
|
724
724
|
function Wr(e) {
|
|
@@ -756,20 +756,20 @@ $e("#1890ff");
|
|
|
756
756
|
var I = function(t, r) {
|
|
757
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
|
-
},
|
|
760
|
-
|
|
759
|
+
}, ie(n, "anticon-".concat(i.name), !!i.name), ie(n, o, o), n), p = l === "" || l || i.name === "loading" ? "anticon-spin" : "", b = c;
|
|
760
|
+
b === void 0 && S && (b = -1, g.tabindex = b);
|
|
761
761
|
var u = f ? {
|
|
762
762
|
msTransform: "rotate(".concat(f, "deg)"),
|
|
763
763
|
transform: "rotate(".concat(f, "deg)")
|
|
764
764
|
} : void 0, y = Me(s), m = Dr(y, 2), v = m[0], A = m[1];
|
|
765
|
-
return
|
|
765
|
+
return ne("span", je({
|
|
766
766
|
role: "img",
|
|
767
767
|
"aria-label": i.name
|
|
768
768
|
}, g, {
|
|
769
769
|
onClick: S,
|
|
770
770
|
class: T
|
|
771
|
-
}), [
|
|
772
|
-
class:
|
|
771
|
+
}), [ne(E, {
|
|
772
|
+
class: p,
|
|
773
773
|
icon: i,
|
|
774
774
|
primaryColor: v,
|
|
775
775
|
secondaryColor: A,
|
|
@@ -815,14 +815,14 @@ function Zr(e, t) {
|
|
|
815
815
|
}
|
|
816
816
|
return (t === "string" ? String : Number)(e);
|
|
817
817
|
}
|
|
818
|
-
var
|
|
818
|
+
var le = function(t, r) {
|
|
819
819
|
var n = Pe({}, t, r.attrs);
|
|
820
|
-
return
|
|
820
|
+
return ne(I, Pe({}, n, {
|
|
821
821
|
icon: Vr
|
|
822
822
|
}), null);
|
|
823
823
|
};
|
|
824
|
-
|
|
825
|
-
|
|
824
|
+
le.displayName = "CopyOutlined";
|
|
825
|
+
le.inheritAttrs = !1;
|
|
826
826
|
function _(e) {
|
|
827
827
|
if (e == null) return "";
|
|
828
828
|
if (typeof e == "string") return e;
|
|
@@ -898,35 +898,35 @@ function et({
|
|
|
898
898
|
isCascader: S,
|
|
899
899
|
isTreeSelect: g,
|
|
900
900
|
isSwitch: T,
|
|
901
|
-
attrs:
|
|
902
|
-
emptyText:
|
|
901
|
+
attrs: p,
|
|
902
|
+
emptyText: b
|
|
903
903
|
}) {
|
|
904
904
|
if (n)
|
|
905
905
|
try {
|
|
906
|
-
return n(e) ||
|
|
906
|
+
return n(e) || b;
|
|
907
907
|
} catch (u) {
|
|
908
908
|
console.warn("[ReadonlyHOC] valueToLabel error", u);
|
|
909
909
|
}
|
|
910
910
|
if (T) {
|
|
911
|
-
const u =
|
|
912
|
-
return e === u ?
|
|
911
|
+
const u = p.checkedValue ?? p["checked-value"] ?? !0, y = p.uncheckedValue ?? p["un-checked-value"] ?? !1;
|
|
912
|
+
return e === u ? p.checkedChildren ?? p["checked-children"] ?? "开启" : e === y ? p.uncheckedChildren ?? p["un-checked-children"] ?? "关闭" : String(e || b);
|
|
913
913
|
}
|
|
914
914
|
if (S && Array.isArray(e) && t?.length)
|
|
915
|
-
return Qr(t, e, a).join(" / ") ||
|
|
915
|
+
return Qr(t, e, a).join(" / ") || b;
|
|
916
916
|
if (g && r?.length)
|
|
917
|
-
return Xr(r, e, a).join(", ") ||
|
|
917
|
+
return Xr(r, e, a).join(", ") || b;
|
|
918
918
|
if (t?.length) {
|
|
919
919
|
const u = a.value || "value", y = a.label || "label", m = (v) => {
|
|
920
|
-
const A = t.find((
|
|
920
|
+
const A = t.find((q) => q[u] === v);
|
|
921
921
|
return A ? A[y] || A[u] : v == null ? "" : String(v);
|
|
922
922
|
};
|
|
923
|
-
return Array.isArray(e) ? e.map(m).join(", ") ||
|
|
923
|
+
return Array.isArray(e) ? e.map(m).join(", ") || b : m(e) || b;
|
|
924
924
|
} else if ((i || l || f) && o?.default)
|
|
925
925
|
try {
|
|
926
926
|
const u = o.default(), y = Re(u, a);
|
|
927
927
|
if (y.size > 0) {
|
|
928
928
|
const m = (v) => v == null ? "" : y.get(v) || String(v);
|
|
929
|
-
return Array.isArray(e) ? e.map(m).join(", ") ||
|
|
929
|
+
return Array.isArray(e) ? e.map(m).join(", ") || b : m(e) || b;
|
|
930
930
|
}
|
|
931
931
|
} catch (u) {
|
|
932
932
|
console.warn("[ReadonlyHOC] Failed to parse slot options", u);
|
|
@@ -937,12 +937,12 @@ function et({
|
|
|
937
937
|
if (y) return y;
|
|
938
938
|
} catch {
|
|
939
939
|
}
|
|
940
|
-
return e == null || e === "" ?
|
|
940
|
+
return e == null || e === "" ? b : Array.isArray(e) ? e.join(", ") : String(e);
|
|
941
941
|
}
|
|
942
942
|
function rt(e) {
|
|
943
943
|
if (typeof e == "function")
|
|
944
944
|
return e;
|
|
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}`,
|
|
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}`, p = /form$/i.test(r), b = /form.*item/i.test(r);
|
|
946
946
|
return ze({
|
|
947
947
|
name: t,
|
|
948
948
|
inheritAttrs: !1,
|
|
@@ -956,19 +956,19 @@ function rt(e) {
|
|
|
956
956
|
},
|
|
957
957
|
emits: ["update:modelValue", T],
|
|
958
958
|
setup(u, { emit: y, slots: m, expose: v }) {
|
|
959
|
-
const A =
|
|
960
|
-
|
|
961
|
-
const
|
|
962
|
-
y("update:modelValue",
|
|
959
|
+
const A = ce("nkReadonly", H(!1)), q = ce("copyable", H(!0)), j = M(() => u.readonly ?? A.value), K = M(() => u.readonly ?? A.value), V = M(() => u.copyable ?? q.value ?? !0), L = H(!1);
|
|
960
|
+
p && (ue("nkReadonly", K), ue("copyable", V));
|
|
961
|
+
const fe = M(() => u[g] !== void 0 ? u[g] : u.modelValue), Ne = (d) => {
|
|
962
|
+
y("update:modelValue", d), y(T, d);
|
|
963
963
|
}, w = Ue(), D = M(() => {
|
|
964
964
|
if (!j.value) return "";
|
|
965
|
-
const
|
|
965
|
+
const d = w.fieldNames ?? w["field-names"] ?? {}, Y = w.options, He = w.treeData ?? w["tree-data"];
|
|
966
966
|
return et({
|
|
967
|
-
modelValue:
|
|
968
|
-
options:
|
|
967
|
+
modelValue: fe.value,
|
|
968
|
+
options: Y,
|
|
969
969
|
treeData: He,
|
|
970
970
|
valueToLabel: u.valueToLabel,
|
|
971
|
-
fieldNames:
|
|
971
|
+
fieldNames: d,
|
|
972
972
|
slots: m,
|
|
973
973
|
isSelect: n,
|
|
974
974
|
isRadioGroup: o,
|
|
@@ -994,31 +994,31 @@ function rt(e) {
|
|
|
994
994
|
border: "none",
|
|
995
995
|
backgroundColor: "none"
|
|
996
996
|
}, F = H();
|
|
997
|
-
|
|
997
|
+
p && v({
|
|
998
998
|
validate: () => j.value ? Promise.resolve({}) : F.value?.validate?.(),
|
|
999
|
-
validateFields: (
|
|
1000
|
-
resetFields: (
|
|
1001
|
-
clearValidate: (
|
|
1002
|
-
scrollToField: (
|
|
999
|
+
validateFields: (d) => j.value ? Promise.resolve({}) : F.value?.validateFields?.(d),
|
|
1000
|
+
resetFields: (d) => !j.value && F.value?.resetFields?.(d),
|
|
1001
|
+
clearValidate: (d) => !j.value && F.value?.clearValidate?.(d),
|
|
1002
|
+
scrollToField: (d) => !j.value && F.value?.scrollToField?.(d)
|
|
1003
1003
|
});
|
|
1004
1004
|
const Le = () => {
|
|
1005
1005
|
L.value = !0;
|
|
1006
1006
|
}, De = () => {
|
|
1007
1007
|
L.value = !1;
|
|
1008
1008
|
};
|
|
1009
|
-
return () =>
|
|
1009
|
+
return () => b ? k(
|
|
1010
1010
|
e,
|
|
1011
1011
|
{
|
|
1012
1012
|
...w,
|
|
1013
1013
|
style: { ...w.style || {}, marginBottom: j.value ? "10px" : void 0 }
|
|
1014
1014
|
},
|
|
1015
1015
|
m
|
|
1016
|
-
) :
|
|
1016
|
+
) : p ? k(
|
|
1017
1017
|
e,
|
|
1018
1018
|
{
|
|
1019
1019
|
...w,
|
|
1020
|
-
rules:
|
|
1021
|
-
disabled:
|
|
1020
|
+
rules: K.value ? null : w.rules,
|
|
1021
|
+
disabled: K.value ? !0 : w.disabled,
|
|
1022
1022
|
ref: F
|
|
1023
1023
|
},
|
|
1024
1024
|
m
|
|
@@ -1030,12 +1030,12 @@ function rt(e) {
|
|
|
1030
1030
|
class: "nk-readonly-wrapper",
|
|
1031
1031
|
style: {
|
|
1032
1032
|
..._e,
|
|
1033
|
-
color:
|
|
1033
|
+
color: V.value && L.value ? "#6e9eff" : "rgba(0, 0, 0, 0.65)"
|
|
1034
1034
|
}
|
|
1035
1035
|
},
|
|
1036
1036
|
[
|
|
1037
1037
|
k("span", { style: { marginRight: "8px" } }, D.value),
|
|
1038
|
-
|
|
1038
|
+
V.value && D.value !== u.emptyText ? k(
|
|
1039
1039
|
"span",
|
|
1040
1040
|
{
|
|
1041
1041
|
class: "copy-icon",
|
|
@@ -1046,18 +1046,22 @@ function rt(e) {
|
|
|
1046
1046
|
},
|
|
1047
1047
|
[
|
|
1048
1048
|
k(
|
|
1049
|
-
|
|
1049
|
+
le,
|
|
1050
1050
|
{
|
|
1051
1051
|
onClick: async () => {
|
|
1052
1052
|
try {
|
|
1053
|
-
if (window.__POWERED_BY_WUJIE__)
|
|
1054
|
-
await window.gvUtil?.clipboard(null, D.value)
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1053
|
+
if (window.__POWERED_BY_WUJIE__) {
|
|
1054
|
+
if (await window.gvUtil?.clipboard(null, D.value) === !1) {
|
|
1055
|
+
B.error("您的浏览器不支持自动复制,请手动复制");
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
B.success("复制成功");
|
|
1059
|
+
} else {
|
|
1060
|
+
const d = new Blob([D.value], { type: "text/plain" }), Y = new ClipboardItem({ "text/plain": d });
|
|
1061
|
+
await navigator.clipboard.write([Y]), B.success("复制成功");
|
|
1058
1062
|
}
|
|
1059
1063
|
} catch {
|
|
1060
|
-
|
|
1064
|
+
B.error("您的浏览器不支持自动复制,请手动复制");
|
|
1061
1065
|
}
|
|
1062
1066
|
},
|
|
1063
1067
|
style: {
|
|
@@ -1077,9 +1081,9 @@ function rt(e) {
|
|
|
1077
1081
|
e,
|
|
1078
1082
|
{
|
|
1079
1083
|
...w,
|
|
1080
|
-
[g]:
|
|
1084
|
+
[g]: fe.value,
|
|
1081
1085
|
[`onUpdate:${g}`]: Ne,
|
|
1082
|
-
ref:
|
|
1086
|
+
ref: p ? F : void 0
|
|
1083
1087
|
},
|
|
1084
1088
|
m
|
|
1085
1089
|
);
|