@persagy2/meri-design
Version:
fork from meri-design and extend it.
7 lines • 8.88 kB
JavaScript
/*!
* @@persagy2/meri-design v1.4.9-extend.2
* (c) 2019-2020 xiongshuang
* Released under the MIT License.
* 2022-12-07 10:32:51
*/
var e,n;e=this,n=function(){return function(){"use strict";var e={1952:function(e,n,t){var c=t(5064);n.Z={name:"Checkbox",props:{checked:{type:String,default:"uncheck"},disabled:{type:Boolean,default:!1},stopPropagation:{type:Boolean,default:!1}},methods:{TextEllipsis:c.Z,handleChange:function(e){var n,t=this.disabled,c=this.checked;if(this.stopPropagation&&e.stopPropagation(),!t){var i=this.$el.dataset,r="";r="checked"===c?"uncheck":"checked",null!==(n=this._events)&&void 0!==n&&n.change?this.$emit("change",r,i):this.$emit("update:checked",r)}}}}},8349:function(e,n,t){t.d(n,{s:function(){return c},x:function(){return i}});var c=function(){var e=this,n=e._self._c;return n("div",{class:["p-checkbox",e.disabled&&"p-checkbox-disabled"],on:{click:e.handleChange}},[n("i",{class:["p-checkbox-box","p-checkbox-"+e.checked]}),e._v(" "),Object.keys(e.$slots).length?n("span",{staticClass:"p-checkbox-text",on:{mouseenter:e.TextEllipsis}},[e._t("default")],2):e._e()])},i=[]},6875:function(e,n,t){var c=t(3931);c.Z.install=function(e){return e.component(c.Z.name,c.Z)},n.default=c.Z},9570:function(e,n,t){t.d(n,{default:function(){return r}});var c={name:"Radio",props:{checked:{type:String,default:"uncheck"},disabled:{type:Boolean,default:!1}},methods:{handleChange:function(){this.disabled||("checked"===this.checked?this.$emit("change","uncheck"):this.$emit("change","checked"))}}},i=(0,t(1900).Z)(c,(function(){var e=this,n=e._self._c;return n("div",{class:["p-radio",e.disabled&&"p-radio-disabled"],on:{click:e.handleChange}},[n("i",{class:["p-radio-box","p-radio-"+e.checked]}),e._v(" "),Object.keys(e.$slots).length?n("span",{staticClass:"p-radio-text"},[e._t("default")],2):e._e()])}),[],!1,null,null,null).exports;i.install=function(e){return e.component(i.name,i)};var r=i},5064:function(e,n){n.Z=function(e){var n=e.target,t=n.clientWidth,c=n.scrollWidth;n.title=c>t?n.innerText:""}},7021:function(){},3931:function(e,n,t){var c=t(872),i=t(5242),r=(t(6921),(0,t(1900).Z)(i.Z,c.s,c.x,!1,null,null,null));n.Z=r.exports},5242:function(e,n,t){var c=t(1952);n.Z=c.Z},872:function(e,n,t){t.d(n,{s:function(){return c.s},x:function(){return c.x}});var c=t(8349)},6921:function(e,n,t){t(7021)},1900:function(e,n,t){function c(e,n,t,c,i,r,d,o){var a,u="function"==typeof e?e.options:e;if(n&&(u.render=n,u.staticRenderFns=t,u._compiled=!0),c&&(u.functional=!0),r&&(u._scopeId="data-v-"+r),d?(a=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(d)},u._ssrRegister=a):i&&(a=o?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(u.functional){u._injectStyles=a;var s=u.render;u.render=function(e,n){return a.call(n),s(e,n)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,a):[a]}return{exports:e,options:u}}t.d(n,{Z:function(){return c}})}},n={};function t(c){var i=n[c];if(void 0!==i)return i.exports;var r=n[c]={exports:{}};return e[c](r,r.exports,t),r.exports}t.d=function(e,n){for(var c in n)t.o(n,c)&&!t.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:n[c]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return function(){t.r(c),t.d(c,{default:function(){return d}});var e=t(6875),n=t(9570),i={name:"CheckboxGroup",components:{Checkbox:e.default,Radio:n.default},data:function(){return{groupBundle:[]}},props:{type:{type:String,default:"single"},groupData:{type:Array,default:function(){return[]}},title:{type:String,default:""},forbidden:{type:Object,default:function(){}}},created:function(){this.init()},methods:{init:function(){var e=JSON.parse(JSON.stringify(this.groupData));if(this.forbidden&&this.forbidden.checked){var n="uncheck"===this.forbidden.checked;e=e.map((function(e){return"notNull"===e.checked&&(e.checked="uncheck"),e.disabled=n,e.children=e.children.map((function(e){return e.disabled=n,e.children=e.children.map((function(e){return e.disabled=n,e})),e})),e}))}if(e.every((function(e){return"uncheck"===e.checked})))"multiple"===this.type&&(e[0].checked="checked"),this.groupBundle=e[0];else if(e.every((function(e){return"checked"===e.checked})))e.map((function(e){return e.checked="uncheck",e})),"multiple"===this.type&&(e[0].checked="checked"),this.groupBundle=e[0];else{var t=e.findIndex((function(e){return"checked"===e.checked}));e[t].checked="checked",this.groupBundle=e[t],e.map((function(e,n){return t!==n&&(e.checked="uncheck"),e}))}this.$emit("update:groupData",e)},handleChange:function(e,n){var t=JSON.parse(JSON.stringify(this.groupData));t[t.findIndex((function(n){return n.id===e}))].checked=n,this.$emit("update:groupData",t);var c=t.filter((function(e){return"checked"===e.checked&&!e.disabled}));c=c.map((function(e){return e.id})),this.$emit("change",c)},handleTitleChange:function(e){var n=JSON.parse(JSON.stringify(this.groupData)),t=JSON.parse(JSON.stringify(this.forbidden));t.checked=e;var c="uncheck"===t.checked;n=n.map((function(e){return"notNull"===e.checked&&(e.checked="uncheck"),e.disabled=c,e.children=e.children.map((function(e){return e.disabled=c,e.children=e.children.map((function(e){return e.disabled=c,e})),e})),e})),this.groupBundle=n[n.findIndex((function(e){return"checked"===e.checked}))],this.$emit("update:groupData",n),this.$emit("update:forbidden",t)},handleContentChange:function(e,n,t){var c=JSON.parse(JSON.stringify(this.groupBundle)).children,i=c.findIndex((function(n){return n.id===e}));if("radio"===c[i].type){if("uncheck"===t)return;c[i].children=c[i].children.map((function(e){return e.checked="uncheck",e}))}var r=c[i].children.findIndex((function(e){return e.id===n}));c[i].children[r].checked=t,this.groupBundle.children=c;var d=JSON.parse(JSON.stringify(this.groupData)),o=d.findIndex((function(e){return"checked"===e.checked}));d[o].children=c,this.$emit("update:groupData",d);var a=JSON.parse(JSON.stringify(this.groupBundle)),u=JSON.parse(JSON.stringify(c));a.children=u.map((function(e){var n=e.children.filter((function(e){return"checked"===e.checked&&!e.disabled}));return n=n.map((function(e){return e.id})),e.children=n,e})),this.$emit("change",a)},handleSelectChange:function(e,n){var t=this,c=JSON.parse(JSON.stringify(this.groupData));c=c.map((function(n){return n.id===e?"uncheck"===n.checked&&(n.checked="checked",t.groupBundle=n):n.checked="uncheck",n})),this.$emit("update:groupData",c)}}},r=(0,t(1900).Z)(i,(function(){var e=this,n=e._self._c;return e.groupData.length>0?n("div",{staticClass:"p-checkbox-group"},[e.title&&"single"===e.type?n("div",{staticClass:"p-checkbox-group-title"},[e._v(e._s(e.title))]):e._e(),e._v(" "),"multiple"===e.type?n("div",{staticClass:"p-checkbox-group-multiple"},[e.forbidden&&e.forbidden.checked?n("div",{staticClass:"p-checkbox-group-multiple-title"},[n("Checkbox",{staticClass:"p-checkbox-group-item",attrs:{checked:"checked"===e.forbidden.checked?"checked":"uncheck"},on:{change:function(n){return e.handleTitleChange(n)}}},[e._v(e._s(e.forbidden.name))])],1):e._e(),e._v(" "),n("div",{staticClass:"p-checkbox-group-single"},[e._l(e.groupData,(function(t){return[n("Radio",{key:t.id,staticClass:"p-checkbox-group-item",class:{disabled:t.disabled},attrs:{checked:"checked"===t.checked?"checked":"uncheck",disabled:t.disabled},on:{change:function(n){return e.handleSelectChange(t.id,n)}}},[e._v(e._s(t.name))])]}))],2),e._v(" "),e.groupBundle&&e.groupBundle.children?e._l(e.groupBundle.children,(function(t){return n("div",{staticClass:"p-checkbox-group-single"},[e._l(t.children,(function(c){return[n(t.type,{key:c.id,tag:"div",staticClass:"p-checkbox-group-item",class:{disabled:c.disabled},attrs:{checked:"checked"===c.checked?"checked":"uncheck",disabled:c.disabled},on:{change:function(n){return e.handleContentChange(t.id,c.id,n)}}},[e._v(e._s(c.name))])]}))],2)})):e._e()],2):n("div",{staticClass:"p-checkbox-group-single"},e._l(e.groupData,(function(t){return n("Checkbox",{key:t.id,staticClass:"p-checkbox-group-item",class:{disabled:t.disabled},attrs:{checked:"checked"===t.checked?"checked":"uncheck",disabled:t.disabled},on:{change:function(n){return e.handleChange(t.id,n)}}},[e._v(e._s(t.name))])})),1)]):e._e()}),[],!1,null,null,null).exports;r.install=function(e){return e.component(r.name,r)};var d=r}(),c}()},"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("CheckboxGroup",[],n):"object"==typeof exports?exports.CheckboxGroup=n():e.CheckboxGroup=n();