UNPKG

mltc-design-system

Version:

長照設計系統

3 lines (2 loc) 23.7 kB
(function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.MLTCDesignSystem={},k.Vue))})(this,function(k,e){"use strict";const z=e.defineComponent({name:"Button",props:{type:{type:String,default:"default",validator:t=>["default","primary","secondary","text","link","outline"].includes(t)},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1},plain:{type:Boolean,default:!1},color:{type:String,default:""}},emits:["click"],setup(t,{emit:l}){const r=s=>{t.disabled||t.loading||l("click",s)},a=e.computed(()=>!!t.color||!1),n=e.computed(()=>{if(!a.value)return{};const s=t.color,p=m(t.color,.1),u=o(t.color,.1),f=h=>{const i=h.startsWith("#")?h.substring(1):h,b=parseInt(i.substring(0,2),16),c=parseInt(i.substring(2,4),16),C=parseInt(i.substring(4,6),16);return`${b}, ${c}, ${C}`};return{"--button-bg-color":s,"--button-text-color":t.plain?s:"white","--button-border-color":s,"--button-hover-bg-color":p,"--button-active-bg-color":u,"--button-rgb-values":f(s),"--button-hover-rgb-values":f(p),"--button-active-rgb-values":f(u)}});function m(s,p){try{const u=s.startsWith("#")?s.substring(1):s;let f=parseInt(u.substring(0,2),16),h=parseInt(u.substring(2,4),16),i=parseInt(u.substring(4,6),16);return f=Math.min(255,f+Math.round(255*p)),h=Math.min(255,h+Math.round(255*p)),i=Math.min(255,i+Math.round(255*p)),`#${f.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}catch{return s}}function o(s,p){try{const u=s.startsWith("#")?s.substring(1):s;let f=parseInt(u.substring(0,2),16),h=parseInt(u.substring(2,4),16),i=parseInt(u.substring(4,6),16);return f=Math.max(0,f-Math.round(255*p)),h=Math.max(0,h-Math.round(255*p)),i=Math.max(0,i-Math.round(255*p)),`#${f.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}catch{return s}}return{handleClick:r,customColor:a,customColorStyle:n}}}),y=(t,l)=>{const r=t.__vccOpts||t;for(const[a,n]of l)r[a]=n;return r},T=["disabled"],A={key:0,class:"icon"},j={key:1,class:"icon"},q={key:2};function L(t,l,r,a,n,m){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["mltc-button",`mltc-button--${t.type}`,`mltc-button--${t.size}`,{"mltc-button--disabled":t.disabled,"mltc-button--block":t.block,"mltc-button--custom":t.customColor,"mltc-button--custom-plain":t.customColor&&t.plain}]),style:e.normalizeStyle(t.customColorStyle),disabled:t.disabled||t.loading,onClick:l[0]||(l[0]=(...o)=>t.handleClick&&t.handleClick(...o))},[t.loading?(e.openBlock(),e.createElementBlock("span",A,l[1]||(l[1]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1em",height:"1em",class:"animate-spin"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none",opacity:"0.25"}),e.createElementVNode("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor","stroke-width":"4","stroke-linecap":"round",fill:"none"})],-1)]))):e.createCommentVNode("",!0),t.$slots.icon&&!t.loading?(e.openBlock(),e.createElementBlock("span",j,[e.renderSlot(t.$slots,"icon")])):e.createCommentVNode("",!0),t.$slots.default?(e.openBlock(),e.createElementBlock("span",q,[e.renderSlot(t.$slots,"default")])):e.createCommentVNode("",!0)],14,T)}const $=y(z,[["render",L]]),R={class:"demo-container"},F={class:"demo-block"},W={class:"demo-content"},G={class:"demo-code-container"},H={class:"demo-code"},K={class:"language-html"},S=y(e.defineComponent({__name:"DemoBlock",props:{codeContent:{type:String,required:!0,description:"要顯示的程式碼內容"}},setup(t){e.defineComponent({name:"DemoBlock"});const l=e.ref(!1),r=()=>{l.value=!l.value};return(a,n)=>(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("div",F,[e.createElementVNode("div",W,[e.renderSlot(a.$slots,"default",{},void 0,!0)]),e.createElementVNode("div",G,[e.createElementVNode("div",{class:"demo-code-header",onClick:r},[n[1]||(n[1]=e.createElementVNode("span",null,"程式碼",-1)),e.createElementVNode("span",{class:e.normalizeClass(["code-expand-icon",{"is-active":l.value}])},n[0]||(n[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"6 9 12 15 18 9"})],-1)]),2)]),e.withDirectives(e.createElementVNode("div",H,[e.createElementVNode("pre",null,[e.createElementVNode("code",K,e.toDisplayString(t.codeContent),1)])],512),[[e.vShow,l.value]])])])]))}}),[["__scopeId","data-v-ca6763ac"]]);let E=0;function V(t=""){const l=new Date().getTime(),r=Math.floor(Math.random()*1e3);return E+=1,`${t}${l}-${r}-${E}`}const P=e.defineComponent({name:"Input",inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:""},type:{type:String,default:"text",validator:t=>["text","password","number","email","tel","url","search"].includes(t)},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},label:{type:String,default:""},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},prefixIcon:{type:[String,Object],default:null},suffixIcon:{type:[String,Object],default:null},error:{type:Boolean,default:!1},errorMessage:{type:String,default:""},helpText:{type:String,default:""}},emits:["update:modelValue","input","change","focus","blur","clear"],setup(t,{emit:l}){const r=e.ref(null),a=e.computed(()=>t.label?`mltc-input-${V()}`:void 0);return{inputRef:r,inputId:a,handleInput:i=>{const b=i.target;l("update:modelValue",b.value),l("input",i)},handleChange:i=>{l("change",i)},handleFocus:i=>{l("focus",i)},handleBlur:i=>{l("blur",i)},handleClear:()=>{l("update:modelValue",""),l("clear"),r.value&&r.value.focus()},focus:()=>{r.value&&r.value.focus()},blur:()=>{r.value&&r.value.blur()},select:()=>{r.value&&r.value.select()}}}}),Q=["for"],U={key:0,class:"required-mark"},J={key:0,class:"prefix-container"},X={key:0,class:"prefix-icon"},Y=["id","type","value","placeholder","readonly","disabled"],Z={key:2,class:"suffix-container"},x={key:0,class:"suffix-icon"},v={key:1,class:"error-message"},_={key:2,class:"help-text"};function ee(t,l,r,a,n,m){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["mltc-input-wrapper",{disabled:t.disabled}])},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:t.inputId,class:"mltc-input-label"},[e.createTextVNode(e.toDisplayString(t.label)+" ",1),t.required?(e.openBlock(),e.createElementBlock("span",U,"*")):e.createCommentVNode("",!0)],8,Q)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["mltc-input-container",[t.size,{error:t.error,disabled:t.disabled}]])},[t.$slots.prefix||t.prefixIcon?(e.openBlock(),e.createElementBlock("div",J,[e.renderSlot(t.$slots,"prefix",{},()=>[t.prefixIcon?(e.openBlock(),e.createElementBlock("span",X,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.prefixIcon)))])):e.createCommentVNode("",!0)],!0)])):e.createCommentVNode("",!0),e.createElementVNode("input",e.mergeProps({id:t.inputId,ref:"inputRef"},t.$attrs,{type:t.type,value:t.modelValue,placeholder:t.placeholder,readonly:t.readonly,disabled:t.disabled,class:["mltc-input",{"no-prefix":!t.$slots.prefix&&!t.prefixIcon,"no-suffix":!t.$slots.suffix&&!t.suffixIcon&&!t.clearable}],onInput:l[0]||(l[0]=(...o)=>t.handleInput&&t.handleInput(...o)),onFocus:l[1]||(l[1]=(...o)=>t.handleFocus&&t.handleFocus(...o)),onBlur:l[2]||(l[2]=(...o)=>t.handleBlur&&t.handleBlur(...o)),onChange:l[3]||(l[3]=(...o)=>t.handleChange&&t.handleChange(...o))}),null,16,Y),t.clearable&&t.modelValue&&!t.disabled&&!t.readonly?(e.openBlock(),e.createElementBlock("div",{key:1,class:"clear-button",onClick:l[4]||(l[4]=(...o)=>t.handleClear&&t.handleClear(...o))},l[5]||(l[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.createElementVNode("line",{x1:"9",y1:"9",x2:"15",y2:"15"})],-1)]))):e.createCommentVNode("",!0),t.$slots.suffix||t.suffixIcon?(e.openBlock(),e.createElementBlock("div",Z,[e.renderSlot(t.$slots,"suffix",{},()=>[t.suffixIcon?(e.openBlock(),e.createElementBlock("span",x,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.suffixIcon)))])):e.createCommentVNode("",!0)],!0)])):e.createCommentVNode("",!0)],2),t.error&&t.errorMessage?(e.openBlock(),e.createElementBlock("div",v,e.toDisplayString(t.errorMessage),1)):e.createCommentVNode("",!0),!t.error&&t.helpText?(e.openBlock(),e.createElementBlock("div",_,e.toDisplayString(t.helpText),1)):e.createCommentVNode("",!0)],2)}const N=y(P,[["render",ee],["__scopeId","data-v-126d3754"]]),te=e.defineComponent({name:"Select",props:{modelValue:{type:[String,Number,Array],default:""},options:{type:Array,default:()=>[]},placeholder:{type:String,default:"請選擇"},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},filterable:{type:Boolean,default:!1},searchPlaceholder:{type:String,default:"搜尋選項"},emptyText:{type:String,default:"無匹配選項"},label:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:Boolean,default:!1},errorMessage:{type:String,default:""},helpText:{type:String,default:""},dropdownWidth:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:300}},emits:["update:modelValue","change","focus","blur","clear","visible-change"],setup(t,{emit:l}){const r=e.computed(()=>t.label?`mltc-select-${V()}`:void 0),a=e.ref(!1),n=e.ref(""),m=e.ref(null),o=e.ref(null),s=e.ref(null),p=e.ref(null),u=e.computed(()=>{const d={};return t.dropdownWidth&&(d.width=typeof t.dropdownWidth=="number"?`${t.dropdownWidth}px`:t.dropdownWidth),t.maxHeight&&(d.maxHeight=typeof t.maxHeight=="number"?`${t.maxHeight}px`:t.maxHeight),d}),f=e.computed(()=>n.value?t.options.filter(d=>d.label.toLowerCase().includes(n.value.toLowerCase())):t.options),h=e.computed(()=>t.multiple?Array.isArray(t.modelValue)&&t.modelValue.length>0:t.modelValue!==""),i=e.computed(()=>!t.multiple||!Array.isArray(t.modelValue)?[]:t.options.filter(d=>t.modelValue.includes(d.value))),b=e.computed(()=>{if(t.multiple||Array.isArray(t.modelValue))return"";const d=t.options.find(g=>g.value===t.modelValue);return d?d.label:""}),c=d=>t.multiple&&Array.isArray(t.modelValue)?t.modelValue.includes(d.value):t.modelValue===d.value,C=d=>{if(t.multiple&&Array.isArray(t.modelValue)){const g=[...t.modelValue],B=g.indexOf(d.value);B===-1?g.push(d.value):g.splice(B,1),l("update:modelValue",g),l("change",g)}else l("update:modelValue",d.value),l("change",d.value),w()},qe=d=>{if(!t.multiple||!Array.isArray(t.modelValue))return;const g=t.modelValue.filter(B=>B!==d.value);l("update:modelValue",g),l("change",g)},Le=()=>{const d=t.multiple?[]:"";l("update:modelValue",d),l("clear")},Re=()=>{},Fe=()=>{a.value=!a.value,a.value?(n.value="",l("focus"),e.nextTick(()=>{t.filterable&&p.value&&p.value.focus()})):l("blur"),l("visible-change",a.value)},w=()=>{a.value&&(a.value=!1,n.value="",l("blur"),l("visible-change",!1))},O=d=>{const g=d.target;a.value&&m.value&&!m.value.contains(g)&&w()};return e.onMounted(()=>{document.addEventListener("click",O)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",O)}),{selectId:r,selectContainerRef:m,dropdownRef:o,optionsListRef:s,searchInputRef:p,isOpen:a,searchQuery:n,dropdownStyle:u,filteredOptions:f,hasSelected:h,selectedOptions:i,selectedLabel:b,isOptionSelected:c,selectOption:C,removeOption:qe,handleClear:Le,handleSearch:Re,toggleDropdown:Fe,closeDropdown:w}}}),le=["for"],oe={key:0,class:"required-mark"},ne={class:"mltc-select-selection"},re={key:0,class:"mltc-select-tags"},ae={class:"mltc-select-tag-text"},se=["onClick"],de={key:1,class:"mltc-select-selected"},ie={key:2,class:"mltc-select-placeholder"},ce={key:0,class:"mltc-select-search"},me=["placeholder"],pe={ref:"optionsListRef",class:"mltc-select-options-list"},ue=["onClick"],fe={key:0,class:"mltc-select-checkbox"},he={key:0,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},ke={key:1,class:"mltc-select-empty"},ge={key:1,class:"mltc-select-error"},ye={key:2,class:"mltc-select-help"};function be(t,l,r,a,n,m){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["mltc-select-wrapper",{disabled:t.disabled}])},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:t.selectId,class:"mltc-select-label"},[e.createTextVNode(e.toDisplayString(t.label)+" ",1),t.required?(e.openBlock(),e.createElementBlock("span",oe,"*")):e.createCommentVNode("",!0)],8,le)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref:"selectContainerRef",class:e.normalizeClass(["mltc-select-container",[t.size,{error:t.error,disabled:t.disabled,opened:t.isOpen,"is-multiple":t.multiple}]]),onClick:l[4]||(l[4]=o=>!t.disabled&&!t.readonly&&t.toggleDropdown()),onKeydown:[l[5]||(l[5]=e.withKeys(e.withModifiers(o=>!t.disabled&&!t.readonly&&t.toggleDropdown(),["stop","prevent"]),["enter"])),l[6]||(l[6]=e.withKeys(e.withModifiers(o=>!t.disabled&&!t.readonly&&t.toggleDropdown(),["stop","prevent"]),["space"])),l[7]||(l[7]=e.withKeys(e.withModifiers(o=>!t.disabled&&!t.readonly&&!t.isOpen&&t.toggleDropdown(),["prevent"]),["down"])),l[8]||(l[8]=e.withKeys(e.withModifiers(o=>t.isOpen&&t.closeDropdown(),["stop"]),["esc"])),l[9]||(l[9]=e.withKeys(o=>t.isOpen&&t.closeDropdown(),["tab"]))],tabindex:"0"},[e.createElementVNode("div",ne,[t.multiple&&t.selectedOptions.length>0?(e.openBlock(),e.createElementBlock("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.selectedOptions,o=>(e.openBlock(),e.createElementBlock("div",{key:o.value,class:"mltc-select-tag"},[e.createElementVNode("span",ae,e.toDisplayString(o.label),1),e.createElementVNode("span",{class:"mltc-select-tag-close",onClick:e.withModifiers(s=>t.removeOption(o),["stop"])},l[10]||(l[10]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)]),8,se)]))),128))])):!t.multiple&&t.selectedLabel?(e.openBlock(),e.createElementBlock("div",de,e.toDisplayString(t.selectedLabel),1)):(e.openBlock(),e.createElementBlock("div",ie,e.toDisplayString(t.placeholder),1))]),t.clearable&&t.hasSelected&&!t.disabled&&!t.readonly?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mltc-select-clear",onClick:l[0]||(l[0]=e.withModifiers((...o)=>t.handleClear&&t.handleClear(...o),["stop"]))},l[11]||(l[11]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.createElementVNode("line",{x1:"9",y1:"9",x2:"15",y2:"15"})],-1)]))):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["mltc-select-arrow",{"is-reverse":t.isOpen}])},l[12]||(l[12]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"6 9 12 15 18 9"})],-1)]),2),e.createVNode(e.Transition,{name:"mltc-select-dropdown"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref:"dropdownRef",class:"mltc-select-dropdown",style:e.normalizeStyle(t.dropdownStyle)},[t.filterable?(e.openBlock(),e.createElementBlock("div",ce,[e.withDirectives(e.createElementVNode("input",{ref:"searchInputRef","onUpdate:modelValue":l[1]||(l[1]=o=>t.searchQuery=o),type:"text",class:"mltc-select-search-input",placeholder:t.searchPlaceholder,onClick:l[2]||(l[2]=e.withModifiers(()=>{},["stop"])),onInput:l[3]||(l[3]=(...o)=>t.handleSearch&&t.handleSearch(...o))},null,40,me),[[e.vModelText,t.searchQuery]])])):e.createCommentVNode("",!0),e.createElementVNode("div",pe,[t.filteredOptions.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.filteredOptions,(o,s)=>(e.openBlock(),e.createElementBlock("div",{key:o.value,class:e.normalizeClass(["mltc-select-option",{"is-selected":t.isOptionSelected(o),"is-disabled":o.disabled}]),onClick:e.withModifiers(p=>!o.disabled&&t.selectOption(o),["stop"])},[t.multiple?(e.openBlock(),e.createElementBlock("span",fe,[t.isOptionSelected(o)?(e.openBlock(),e.createElementBlock("svg",he,l[13]||(l[13]=[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"},null,-1)]))):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(o.label),1)],10,ue))),128)):(e.openBlock(),e.createElementBlock("div",ke,e.toDisplayString(t.emptyText),1))],512)],4),[[e.vShow,t.isOpen]])]),_:1})],34),t.error&&t.errorMessage?(e.openBlock(),e.createElementBlock("div",ge,e.toDisplayString(t.errorMessage),1)):e.createCommentVNode("",!0),!t.error&&t.helpText?(e.openBlock(),e.createElementBlock("div",ye,e.toDisplayString(t.helpText),1)):e.createCommentVNode("",!0)],2)}const D=y(te,[["render",be]]),Be=e.defineComponent({name:"Checkbox",props:{modelValue:{type:Boolean,default:!1},label:{type:String,default:""},value:{type:[String,Number,Boolean],default:""},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},disabled:{type:Boolean,default:!1},indeterminate:{type:Boolean,default:!1},name:{type:String,default:""},error:{type:Boolean,default:!1},errorMessage:{type:String,default:""},trueValue:{type:[String,Number,Boolean],default:!0},falseValue:{type:[String,Number,Boolean],default:!1}},emits:["update:modelValue","change","focus","blur"],setup(t,{emit:l}){const r=e.ref(null),a=e.computed(()=>`mltc-checkbox-${V()}`),n=e.inject("checkboxGroup",null),m=e.computed(()=>!!n),o=e.computed(()=>{if(m.value&&n){const c=n.modelValue;return Array.isArray(c)&&c.includes(t.value)}return t.modelValue===t.trueValue}),s=e.computed(()=>m.value&&n&&n.disabled||t.disabled);return{checkboxRef:r,checkboxId:a,isChecked:o,isDisabled:s,handleClick:()=>{if(!s.value)if(m.value&&n){const{toggleOption:c}=n;c({value:t.value,label:t.label})}else l("update:modelValue",o.value?t.falseValue:t.trueValue)},handleChange:c=>{s.value||l("change",c)},handleFocus:c=>{l("focus",c)},handleBlur:c=>{l("blur",c)},focus:()=>{var c;(c=r.value)==null||c.focus()},blur:()=>{var c;(c=r.value)==null||c.blur()}}}}),Ve=["id","checked","disabled","value"],Ce={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",class:"checkbox-icon",width:"1em",height:"1em",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},we={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",class:"checkbox-icon",width:"1em",height:"1em",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},$e=["for"],Se={key:0,class:"error-message"};function Ee(t,l,r,a,n,m){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["mltc-checkbox-wrapper",[t.size,{disabled:t.isDisabled,error:t.error}]])},[e.createElementVNode("div",{class:"mltc-checkbox-container",onClick:l[3]||(l[3]=(...o)=>t.handleClick&&t.handleClick(...o))},[e.createElementVNode("input",{id:t.checkboxId,ref:"checkboxRef",type:"checkbox",class:"mltc-checkbox-input",checked:t.isChecked,disabled:t.isDisabled,value:t.label||t.value,onChange:l[0]||(l[0]=(...o)=>t.handleChange&&t.handleChange(...o)),onFocus:l[1]||(l[1]=(...o)=>t.handleFocus&&t.handleFocus(...o)),onBlur:l[2]||(l[2]=(...o)=>t.handleBlur&&t.handleBlur(...o))},null,40,Ve),e.createElementVNode("span",{class:e.normalizeClass(["mltc-checkbox-custom",{"is-checked":t.isChecked,"is-indeterminate":t.indeterminate}])},[t.isChecked&&!t.indeterminate?(e.openBlock(),e.createElementBlock("svg",Ce,l[4]||(l[4]=[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"},null,-1)]))):e.createCommentVNode("",!0),t.indeterminate?(e.openBlock(),e.createElementBlock("svg",we,l[5]||(l[5]=[e.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1)]))):e.createCommentVNode("",!0)],2),t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:t.checkboxId,class:"mltc-checkbox-label"},e.toDisplayString(t.label),9,$e)):e.createCommentVNode("",!0)]),t.error&&t.errorMessage?(e.openBlock(),e.createElementBlock("div",Se,e.toDisplayString(t.errorMessage),1)):e.createCommentVNode("",!0)],2)}const I=y(Be,[["render",Ee]]),Ne=e.defineComponent({name:"CheckboxGroup",props:{modelValue:{type:Array,required:!0},label:{type:String,default:""},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},direction:{type:String,default:"horizontal",validator:t=>["horizontal","vertical"].includes(t)},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},min:{type:Number,default:0},max:{type:Number,default:1/0},error:{type:Boolean,default:!1},errorMessage:{type:String,default:""},helpText:{type:String,default:""}},emits:["update:modelValue","change"],setup(t,{emit:l}){const r=a=>{const{modelValue:n}=t,m=n.indexOf(a.value),o=[...n];m===-1?n.length<t.max&&o.push(a.value):n.length>t.min&&o.splice(m,1),l("update:modelValue",o),l("change",o)};return e.provide("checkboxGroup",{modelValue:t.modelValue,disabled:t.disabled,toggleOption:r}),{}}}),De={key:0,class:"mltc-checkbox-group-label"},Ie={key:0,class:"required-mark"},Me={class:"mltc-checkbox-group-content"},Oe={key:1,class:"error-message"},ze={key:2,class:"help-text"};function Te(t,l,r,a,n,m){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["mltc-checkbox-group",[t.direction,t.size,{disabled:t.disabled,error:t.error}]])},[t.label?(e.openBlock(),e.createElementBlock("div",De,[e.createTextVNode(e.toDisplayString(t.label)+" ",1),t.required?(e.openBlock(),e.createElementBlock("span",Ie,"*")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Me,[e.renderSlot(t.$slots,"default")]),t.error&&t.errorMessage?(e.openBlock(),e.createElementBlock("div",Oe,e.toDisplayString(t.errorMessage),1)):e.createCommentVNode("",!0),!t.error&&t.helpText?(e.openBlock(),e.createElementBlock("div",ze,e.toDisplayString(t.helpText),1)):e.createCommentVNode("",!0)],2)}const M=y(Ne,[["render",Te]]),Ae=[$,S,N,D,I,M],je={install:t=>{Ae.forEach(l=>{l.name?t.component(`Mltc${l.name}`,l):console.warn("組件缺少name屬性: ",l)})}};k.Button=$,k.Checkbox=I,k.CheckboxGroup=M,k.DemoBlock=S,k.Input=N,k.Select=D,k.default=je,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); //# sourceMappingURL=mltc-design-system.umd.js.map