n-design-readonly-plugin 1.0.6 → 1.0.8
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 +6 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.es.js +59 -55
- 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),p.message.success("复制成功");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.d.ts
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
|
-
import { Plugin } from 'vue';
|
|
1
|
+
import { Component, Plugin } from 'vue';
|
|
2
2
|
import { withReadonly } from './withReadonly';
|
|
3
|
+
import { InputProps, InputNumberProps, TextAreaProps, SelectProps, TreeSelectProps, CascaderProps, DatePickerProps, TimePickerProps, RadioProps, CheckboxProps, SwitchProps, SliderProps, RateProps, FormProps, FormItemProps } from 'n-designv3';
|
|
3
4
|
declare const NDesignReadolyPlugin: Plugin;
|
|
4
5
|
export default NDesignReadolyPlugin;
|
|
5
6
|
export { withReadonly };
|
|
7
|
+
export type FormModelValue = string | number | boolean | Array<any> | Object | null | undefined;
|
|
8
|
+
export interface ReadonlyExtraPropsType {
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
copyable?: boolean;
|
|
11
|
+
emptyText?: string;
|
|
12
|
+
valueToLabel?: (value: FormModelValue) => string;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
declare module 'vue' {
|
|
16
|
+
interface GlobalComponents {
|
|
17
|
+
NkInput: Component<Omit<InputProps, 'modelValue' | 'value'> & {
|
|
18
|
+
modelValue?: FormModelValue;
|
|
19
|
+
value?: FormModelValue;
|
|
20
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
21
|
+
NkInputNumber: Component<Omit<InputNumberProps, 'modelValue' | 'value'> & {
|
|
22
|
+
modelValue?: FormModelValue;
|
|
23
|
+
value?: FormModelValue;
|
|
24
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
25
|
+
NkTextarea: Component<Omit<TextAreaProps, 'modelValue' | 'value'> & {
|
|
26
|
+
modelValue?: FormModelValue;
|
|
27
|
+
value?: FormModelValue;
|
|
28
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
29
|
+
NkSelect: Component<Omit<SelectProps, 'modelValue' | 'value'> & {
|
|
30
|
+
modelValue?: FormModelValue;
|
|
31
|
+
value?: FormModelValue;
|
|
32
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
33
|
+
NkSelectOption: Component<SelectProps['options']>;
|
|
34
|
+
NkTreeSelect: Component<Omit<TreeSelectProps, 'modelValue' | 'value'> & {
|
|
35
|
+
modelValue?: FormModelValue;
|
|
36
|
+
value?: FormModelValue;
|
|
37
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
38
|
+
NkCascader: Component<Omit<CascaderProps, 'modelValue' | 'value'> & {
|
|
39
|
+
modelValue?: FormModelValue;
|
|
40
|
+
value?: FormModelValue;
|
|
41
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
42
|
+
NkDatePicker: Component<Omit<DatePickerProps, 'modelValue' | 'value'> & {
|
|
43
|
+
modelValue?: FormModelValue;
|
|
44
|
+
value?: FormModelValue;
|
|
45
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
46
|
+
NkTimePicker: Component<Omit<TimePickerProps, 'modelValue' | 'value'> & {
|
|
47
|
+
modelValue?: FormModelValue;
|
|
48
|
+
value?: FormModelValue;
|
|
49
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
50
|
+
NkRadio: Component<Omit<RadioProps, 'modelValue' | 'value' | 'checked'> & {
|
|
51
|
+
modelValue?: FormModelValue;
|
|
52
|
+
value?: FormModelValue;
|
|
53
|
+
checked?: boolean;
|
|
54
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
55
|
+
NkCheckbox: Component<Omit<CheckboxProps, 'modelValue' | 'value' | 'checked'> & {
|
|
56
|
+
modelValue?: FormModelValue;
|
|
57
|
+
value?: FormModelValue;
|
|
58
|
+
checked?: boolean;
|
|
59
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
60
|
+
NkRadioGroup: Component<Omit<RadioProps, 'modelValue' | 'value'> & {
|
|
61
|
+
modelValue?: FormModelValue;
|
|
62
|
+
value?: FormModelValue;
|
|
63
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
64
|
+
NkCheckboxGroup: Component<Omit<CheckboxProps, 'modelValue' | 'value'> & {
|
|
65
|
+
modelValue?: FormModelValue;
|
|
66
|
+
value?: FormModelValue;
|
|
67
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
68
|
+
NkSwitch: Component<Omit<SwitchProps, 'modelValue' | 'value' | 'checked'> & {
|
|
69
|
+
modelValue?: FormModelValue;
|
|
70
|
+
value?: FormModelValue;
|
|
71
|
+
checked?: boolean;
|
|
72
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
73
|
+
NkSlider: Component<Omit<SliderProps, 'modelValue' | 'value'> & {
|
|
74
|
+
modelValue?: FormModelValue;
|
|
75
|
+
value?: FormModelValue;
|
|
76
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
77
|
+
NkRate: Component<Omit<RateProps, 'modelValue' | 'value'> & {
|
|
78
|
+
modelValue?: FormModelValue;
|
|
79
|
+
value?: FormModelValue;
|
|
80
|
+
} & Partial<ReadonlyExtraPropsType>>;
|
|
81
|
+
NkForm: Component<FormProps> & {
|
|
82
|
+
readonly?: boolean;
|
|
83
|
+
};
|
|
84
|
+
NkFormItem: Component<FormItemProps>;
|
|
85
|
+
}
|
|
86
|
+
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
|
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,7 +14,7 @@ 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
20
|
function J(e) {
|
|
@@ -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)),
|
|
@@ -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)
|
|
@@ -357,16 +357,16 @@ function Ce(e, t, r) {
|
|
|
357
357
|
}
|
|
358
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,7 +374,7 @@ function ae(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
|
}
|
|
@@ -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
|
-
})), oe(c.icon, "svg-".concat(c.name),
|
|
598
|
+
})), oe(c.icon, "svg-".concat(c.name), G({}, l, {
|
|
599
599
|
"data-icon": c.name,
|
|
600
600
|
width: "1em",
|
|
601
601
|
height: "1em",
|
|
@@ -756,8 +756,8 @@ $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
|
-
}, ie(n, "anticon-".concat(i.name), !!i.name), ie(n, o, o), n),
|
|
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)")
|
|
@@ -769,7 +769,7 @@ var I = function(t, r) {
|
|
|
769
769
|
onClick: S,
|
|
770
770
|
class: T
|
|
771
771
|
}), [ne(E, {
|
|
772
|
-
class:
|
|
772
|
+
class: p,
|
|
773
773
|
icon: i,
|
|
774
774
|
primaryColor: v,
|
|
775
775
|
secondaryColor: A,
|
|
@@ -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 = ce("nkReadonly", H(!1)),
|
|
960
|
-
|
|
961
|
-
const fe = M(() => u[g] !== void 0 ? u[g] : u.modelValue), Ne = (
|
|
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
967
|
modelValue: fe.value,
|
|
968
|
-
options:
|
|
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",
|
|
@@ -1050,14 +1050,18 @@ function rt(e) {
|
|
|
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: {
|
|
@@ -1079,7 +1083,7 @@ function rt(e) {
|
|
|
1079
1083
|
...w,
|
|
1080
1084
|
[g]: fe.value,
|
|
1081
1085
|
[`onUpdate:${g}`]: Ne,
|
|
1082
|
-
ref:
|
|
1086
|
+
ref: p ? F : void 0
|
|
1083
1087
|
},
|
|
1084
1088
|
m
|
|
1085
1089
|
);
|