Files
PORTAL_COD2/front/dist/assets/group-50132b40.js
T
2023-10-18 10:21:41 +03:00

2 lines
2.8 KiB
JavaScript

import{p,d as x,h as B,e as w,i as V,al as y,c as h,l as C,w as E,a as P,aa as k,o as M,ba as U,be as $,f as q}from"./index-6dd2646c.js";const O=p({modelValue:{type:null,default:void 0},multiple:Boolean,mandatory:[Boolean,String],max:Number,selectedClass:String,disabled:Boolean},"group"),R=p({value:null,disabled:Boolean,selectedClass:String},"group-item");function W(t,o){let d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;const e=x("useGroupItem");if(!e)throw new Error("[Vuetify] useGroupItem composable must be used inside a component setup function");const n=B();w(Symbol.for(`${o.description}:id`),n);const l=V(o,null);if(!l){if(!d)return l;throw new Error(`[Vuetify] Could not find useGroup injection with symbol ${o.description}`)}const m=y(t,"value"),v=h(()=>l.disabled.value||t.disabled);l.register({id:n,value:m,disabled:v},e),C(()=>{l.unregister(n)});const f=h(()=>l.isSelected(n)),I=h(()=>f.value&&[l.selectedClass.value,t.selectedClass]);return E(f,g=>{e.emit("group:selected",{value:g})}),{id:n,isSelected:f,toggle:()=>l.select(n,!f.value),select:g=>l.select(n,g),selectedClass:I,value:m,disabled:v,group:l}}function z(t,o){let d=!1;const e=P([]),n=k(t,"modelValue",[],s=>s==null?[]:S(e,$(s)),s=>{const i=F(e,s);return t.multiple?i:i[0]}),l=x("useGroup");function m(s,i){const a=s,u=Symbol.for(`${o.description}:id`),c=q(u,l==null?void 0:l.vnode).indexOf(i);c>-1?e.splice(c,0,a):e.push(a)}function v(s){if(d)return;f();const i=e.findIndex(a=>a.id===s);e.splice(i,1)}function f(){const s=e.find(i=>!i.disabled);s&&t.mandatory==="force"&&!n.value.length&&(n.value=[s.id])}M(()=>{f()}),C(()=>{d=!0});function I(s,i){const a=e.find(u=>u.id===s);if(!(i&&(a!=null&&a.disabled)))if(t.multiple){const u=n.value.slice(),r=u.findIndex(G=>G===s),c=~r;if(i=i??!c,c&&t.mandatory&&u.length<=1||!c&&t.max!=null&&u.length+1>t.max)return;r<0&&i?u.push(s):r>=0&&!i&&u.splice(r,1),n.value=u}else{const u=n.value.includes(s);if(t.mandatory&&u)return;n.value=i??!u?[s]:[]}}function g(s){if(t.multiple,n.value.length){const i=n.value[0],a=e.findIndex(c=>c.id===i);let u=(a+s)%e.length,r=e[u];for(;r.disabled&&u!==a;)u=(u+s)%e.length,r=e[u];if(r.disabled)return;n.value=[e[u].id]}else{const i=e.find(a=>!a.disabled);i&&(n.value=[i.id])}}const b={register:m,unregister:v,selected:n,select:I,disabled:y(t,"disabled"),prev:()=>g(e.length-1),next:()=>g(1),isSelected:s=>n.value.includes(s),selectedClass:h(()=>t.selectedClass),items:h(()=>e),getItemIndex:s=>A(e,s)};return w(o,b),b}function A(t,o){const d=S(t,[o]);return d.length?t.findIndex(e=>e.id===d[0]):-1}function S(t,o){const d=[];return o.forEach(e=>{const n=t.find(m=>U(e,m.value)),l=t[e];(n==null?void 0:n.value)!=null?d.push(n.id):l!=null&&d.push(l.id)}),d}function F(t,o){const d=[];return o.forEach(e=>{const n=t.findIndex(l=>l.id===e);if(~n){const l=t[n];d.push(l.value!=null?l.value:n)}}),d}export{W as a,O as b,R as m,z as u};