geekin-devtoys 0.4.2 → 0.5.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),W=["data-size","data-disabled"],q=["aria-expanded","aria-controls","aria-activedescendant","aria-label","disabled"],F=["data-empty"],Z=["data-side","data-align"],J=["id","aria-label","data-live"],Q=["id","aria-selected","data-index"],X={class:"g-dropdown__option-label"},ee={key:0,class:"g-dropdown__option-tag"},te=["data-on"],oe=4,ne=1,ae=6,g=t.defineComponent({__name:"index",props:{options:{default:()=>["One","Two","Three"]},value:{default:void 0},defaultValue:{default:void 0},placeholder:{default:"Select…"},showTags:{type:Boolean,default:!0},accentColor:{default:"#f5f5f5"},surfaceColor:{default:"#27272a"},highlightColor:{default:"#3f3f46"},textColor:{default:"#f5f5f5"},size:{default:"md"},radius:{default:10},menuWidth:{default:176},placement:{default:"bottom"},align:{default:"left"},popDuration:{default:180},glideDuration:{default:220},rememberPosition:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},ariaLabel:{default:"Select"},className:{default:""}},emits:["change"],setup(_,{emit:A}){const $={sm:{chip:28,row:26,font:12},md:{chip:32,row:30,font:13},lg:{chip:44,row:40,font:14}},M=e=>typeof e=="string"?{value:e,label:e}:e,R=(e,o,n)=>{const r=n.toLowerCase(),u=e.length;for(let i=1;i<=u;i++){const V=(o+i)%u;if(e[V].label.toLowerCase().startsWith(r))return V}return o},a=_,I=A,f=t.computed(()=>a.options.map(M)),N=t.ref(a.defaultValue??""),k=t.computed(()=>a.value??N.value),c=t.computed(()=>f.value.findIndex(e=>e.value===k.value)),s=t.ref("closed"),l=t.ref(null),E=t.ref(a.placement),p=t.ref(null),T=t.ref(null),D=t.ref(null),x=t.ref(null);let v=!1,h,d=null;const w=t.useId(),y=t.computed(()=>$[a.size]??$.md),b=t.computed(()=>y.value.row+ne),L=t.computed(()=>Math.round(a.popDuration*2/3));t.watch(s,e=>{if(e!=="open")return;const o=D.value,n=p.value;if(!o||!n)return;const r=n.getBoundingClientRect(),u=o.offsetHeight+ae;E.value=a.placement==="bottom"&&r.bottom+u>window.innerHeight?"top":a.placement==="top"&&r.top-u<0?"bottom":a.placement,o.style.transitionDuration=v?"0ms":"",o.dataset.state="closed",o.offsetHeight,o.dataset.state="open";const i=x.value;i&&(i.style.transition="none",i.style.transform=`translateY(${Math.max(0,c.value)*b.value}px)`,i.style.opacity="0",i.offsetHeight,i.style.transition="")},{flush:"post"}),t.watch([l,s,b],()=>{const e=x.value;if(!e||s.value!=="open")return;if(l.value===null){e.style.opacity="0";return}const o=v||e.style.opacity!=="1";e.style.transitionDuration=o?"0ms, 150ms":"",e.style.transform=`translateY(${l.value*b.value}px)`,e.style.opacity="1",v=!1},{flush:"post"});const P=e=>{a.disabled||(clearTimeout(h),v=!0,l.value=c.value>=0?c.value:e?0:null,s.value="open")},m=e=>{l.value=null,clearTimeout(h);const o=D.value;if(e==="instant"||!o){s.value="closed";return}o.style.transitionDuration="",o.dataset.state="closed",s.value="closing",h=setTimeout(()=>s.value="closed",L.value+20)},S=(e,o)=>{const n=f.value[e];if(!n){m("instant");return}n.value!==k.value&&(a.value===void 0&&(N.value=n.value),I("change",n.value,n),!o&&p.value&&(p.value.dataset.swap="")),m("instant"),T.value?.focus({preventScroll:!0})},z=e=>{const o=e.key,n=f.value.length,r=l.value??Math.max(0,c.value);if(s.value!=="open"){(o==="Enter"||o===" "||o==="ArrowDown"||o==="ArrowUp")&&(e.preventDefault(),P(!0));return}const u=i=>{e.preventDefault(),v=!0,l.value=Math.min(n-1,Math.max(0,i))};o==="ArrowDown"||o==="ArrowUp"?u(l.value===null?r:r+(o==="ArrowDown"?1:-1)):o==="Home"||o==="End"?u(o==="Home"?0:n-1):o==="Enter"||o===" "?(e.preventDefault(),S(r,!0)):o==="Escape"||o==="Tab"?(o==="Escape"&&e.preventDefault(),m("instant")):o.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&u(R(f.value,r,o))},H=e=>{e.button!==0||a.disabled||(e.currentTarget.focus({preventScroll:!0}),s.value==="open"?m("pop"):P(!1))};t.watch(s,(e,o,n)=>{if(e==="closed")return;const r=u=>{p.value&&!p.value.contains(u.target)&&m("pop")};document.addEventListener("pointerdown",r,!0),n(()=>document.removeEventListener("pointerdown",r,!0))}),t.watch(()=>a.disabled,e=>{e&&s.value!=="closed"&&m("instant")}),t.onUnmounted(()=>clearTimeout(h));const B=e=>{const o=d;if(!o)return null;const n=Math.floor((e-o.top-oe)/b.value);return n>=0&&n<f.value.length?n:null},K=e=>{if(d)return;const o=e.currentTarget;try{o.setPointerCapture(e.pointerId)}catch{}d={id:e.pointerId,top:o.getBoundingClientRect().top},v=!0,l.value=B(e.clientY)},U=e=>{if(!d||d.id!==e.pointerId)return;const o=B(e.clientY);o!==l.value&&(l.value=o)},C=e=>{if(!d||d.id!==e.pointerId)return;const o=e.type==="pointerup"?B(e.clientY):null;d=null,o!==null?S(o,!1):a.rememberPosition||(l.value=null)},Y=e=>{if(e.pointerType==="touch"||d)return;const o=e.target.closest("[data-index]");if(!o)return;const n=Number(o.dataset.index);n!==l.value&&(l.value=n)},j=()=>{!d&&!a.rememberPosition&&(l.value=null)},O=e=>{e.animationName==="gs-swap"&&p.value&&delete p.value.dataset.swap},G=t.computed(()=>({"--gs-accent":a.accentColor,"--gs-surface":a.surfaceColor,"--gs-highlight":a.highlightColor,"--gs-text":a.textColor,"--gs-radius":`${a.radius}px`,"--gs-inner-radius":`${Math.max(3,a.radius-4)}px`,"--gs-chip":`${y.value.chip}px`,"--gs-row":`${y.value.row}px`,"--gs-font":`${y.value.font}px`,"--gs-menu-w":`${a.menuWidth}px`,"--gs-pop":`${a.popDuration}ms`,"--gs-pop-out":`${L.value}ms`,"--gs-glide":`${a.glideDuration}ms`,"--gs-origin":`${E.value==="bottom"?"top":"bottom"} ${a.align}`}));return(e,o)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootRef",ref:p,class:t.normalizeClass(["g-dropdown",e.className]),"data-size":e.size,"data-disabled":e.disabled?"":void 0,style:t.normalizeStyle(G.value),onAnimationend:O},[t.createElementVNode("button",{ref_key:"triggerRef",ref:T,type:"button",role:"combobox","aria-haspopup":"listbox","aria-expanded":s.value==="open","aria-controls":`${t.unref(w)}-list`,"aria-activedescendant":l.value!==null?`${t.unref(w)}-${l.value}`:void 0,"aria-label":e.ariaLabel,disabled:e.disabled,class:"g-dropdown__trigger",onPointerdown:H,onKeydown:z},[(t.openBlock(),t.createElementBlock("span",{key:k.value,class:"g-dropdown__label","data-empty":c.value<0?"":void 0},t.toDisplayString(c.value>=0?f.value[c.value].label:e.placeholder),9,F)),o[0]||(o[0]=t.createElementVNode("span",{class:"g-dropdown__arrow","aria-hidden":"true"},[t.createElementVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[t.createElementVNode("path",{d:"m6 9 6 6 6-6"})])],-1))],40,q),s.value!=="closed"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuRef",ref:D,class:"g-dropdown__menu","data-state":"open","data-side":E.value,"data-align":e.align},[t.createElementVNode("div",{id:`${t.unref(w)}-list`,role:"listbox","aria-label":e.ariaLabel,class:"g-dropdown__list","data-live":l.value!==null?"":void 0,onPointerover:Y,onPointerleave:j,onPointerdown:K,onPointermove:U,onPointerup:C,onPointercancel:C,onLostpointercapture:C},[t.createElementVNode("span",{ref_key:"pillRef",ref:x,class:"g-dropdown__pill","aria-hidden":"true"},null,512),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f.value,(n,r)=>(t.openBlock(),t.createElementBlock("div",{id:`${t.unref(w)}-${r}`,key:n.value,role:"option","aria-selected":r===c.value,"data-index":r,class:"g-dropdown__option"},[t.createElementVNode("span",X,t.toDisplayString(n.label),1),e.showTags&&n.tag?(t.openBlock(),t.createElementBlock("span",ee,t.toDisplayString(n.tag),1)):t.createCommentVNode("",!0),t.createElementVNode("span",{class:"g-dropdown__option-check","data-on":r===c.value?"":void 0,"aria-hidden":"true"},o[1]||(o[1]=[t.createElementVNode("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[t.createElementVNode("path",{d:"m5 12 5 5 9-9"})],-1)]),8,te)],8,Q))),128))],40,J)],8,Z)):t.createCommentVNode("",!0)],46,W))}});g.install=_=>{_.component(g.name,g)};exports.GDropdown=g;exports.default=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),ee=["data-size","data-disabled"],te=["data-custom","aria-expanded","aria-controls","aria-activedescendant","aria-label","disabled"],oe=["data-empty"],ae=["data-side","data-align","data-slot","data-teleported"],ne=["id","aria-label","data-live"],le=["id","aria-selected","data-index"],re={class:"g-dropdown__option-label"},se={key:0,class:"g-dropdown__option-tag"},ie=["data-on"],ue=4,de=1,S=6,g=t.defineComponent({__name:"index",props:{options:{default:()=>["One","Two","Three"]},value:{default:void 0},defaultValue:{default:void 0},placeholder:{default:"Select…"},showTags:{type:Boolean,default:!0},accentColor:{default:"#f5f5f5"},surfaceColor:{default:"#27272a"},highlightColor:{default:"#3f3f46"},textColor:{default:"#f5f5f5"},size:{default:"md"},radius:{default:10},menuWidth:{default:176},placement:{default:"bottom"},align:{default:"left"},popDuration:{default:180},glideDuration:{default:220},rememberPosition:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},ariaLabel:{default:"Select"},className:{default:""},teleported:{type:Boolean,default:!1}},emits:["change"],setup(E,{emit:I}){const C={sm:{chip:28,row:26,font:12},md:{chip:32,row:30,font:13},lg:{chip:44,row:40,font:14}},H=e=>typeof e=="string"?{value:e,label:e}:e,K=(e,o,n)=>{const l=n.toLowerCase(),u=e.length;for(let s=1;s<=u;s++){const z=(o+s)%u;if(e[z].label.toLowerCase().startsWith(l))return z}return o},a=E,T=t.useSlots(),U=!!T.trigger,Y=!!T.menu,j=I,p=t.computed(()=>a.options.map(H)),N=t.ref(a.defaultValue??""),$=t.computed(()=>a.value??N.value),c=t.computed(()=>p.value.findIndex(e=>e.value===$.value)),i=t.ref("closed"),r=t.ref(null),h=t.ref(a.placement),f=t.ref(null),P=t.ref(null),w=t.ref(null),L=t.ref({}),B=t.ref(null);let m=!1,y,d=null;const b=t.useId(),k=t.computed(()=>C[a.size]??C.md),_=t.computed(()=>k.value.row+de),V=t.computed(()=>Math.round(a.popDuration*2/3));t.watch(i,e=>{if(e!=="open")return;const o=w.value,n=f.value;if(!o||!n)return;const l=n.getBoundingClientRect(),u=o.offsetHeight+S;h.value=a.placement==="bottom"&&l.bottom+u>window.innerHeight?"top":a.placement==="top"&&l.top-u<0?"bottom":a.placement,a.teleported&&(L.value={position:"fixed",top:`${h.value==="bottom"?l.bottom+S:l.top-o.offsetHeight-S}px`,left:`${a.align==="right"?l.right-o.offsetWidth:l.left}px`,right:"auto",bottom:"auto",zIndex:2e3}),o.dataset.state="closed",o.offsetHeight,o.dataset.state="open";const s=B.value;s&&(s.style.transition="none",s.style.transform=`translateY(${Math.max(0,c.value)*_.value}px)`,s.style.opacity="0",s.offsetHeight,s.style.transition="")},{flush:"post"}),t.watch([r,i,_],()=>{const e=B.value;if(!e||i.value!=="open")return;if(r.value===null){e.style.opacity="0";return}const o=m||e.style.opacity!=="1";e.style.transitionDuration=o?"0ms, 150ms":"",e.style.transform=`translateY(${r.value*_.value}px)`,e.style.opacity="1",m=!1},{flush:"post"});const M=e=>{a.disabled||(clearTimeout(y),m=!0,r.value=c.value>=0?c.value:e?0:null,i.value="open")},v=e=>{r.value=null,clearTimeout(y);const o=w.value;if(e==="instant"||!o){i.value="closed";return}o.style.transitionDuration="",o.dataset.state="closed",i.value="closing",y=setTimeout(()=>i.value="closed",V.value+20)},O=()=>v("pop"),A=(e,o)=>{const n=p.value[e];if(!n){v("instant");return}n.value!==$.value&&(a.value===void 0&&(N.value=n.value),j("change",n.value,n),!o&&f.value&&(f.value.dataset.swap="")),v("instant"),P.value?.focus({preventScroll:!0})},W=e=>{const o=e.key,n=p.value.length,l=r.value??Math.max(0,c.value);if(i.value!=="open"){(o==="Enter"||o===" "||o==="ArrowDown"||o==="ArrowUp")&&(e.preventDefault(),M(!0));return}const u=s=>{e.preventDefault(),m=!0,r.value=Math.min(n-1,Math.max(0,s))};o==="ArrowDown"||o==="ArrowUp"?u(r.value===null?l:l+(o==="ArrowDown"?1:-1)):o==="Home"||o==="End"?u(o==="Home"?0:n-1):o==="Enter"||o===" "?(e.preventDefault(),A(l,!0)):o==="Escape"||o==="Tab"?(o==="Escape"&&e.preventDefault(),v("instant")):o.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&u(K(p.value,l,o))},G=e=>{e.button!==0||a.disabled||(e.currentTarget.focus({preventScroll:!0}),i.value==="open"?v("pop"):M(!1))};t.watch(i,(e,o,n)=>{if(e==="closed")return;const l=u=>{const s=u.target;f.value?.contains(s)||w.value?.contains(s)||v("pop")};document.addEventListener("pointerdown",l,!0),n(()=>document.removeEventListener("pointerdown",l,!0))}),t.watch(()=>a.disabled,e=>{e&&i.value!=="closed"&&v("instant")}),t.onUnmounted(()=>clearTimeout(y));const D=e=>{const o=d;if(!o)return null;const n=Math.floor((e-o.top-ue)/_.value);return n>=0&&n<p.value.length?n:null},q=e=>{if(d)return;const o=e.currentTarget;try{o.setPointerCapture(e.pointerId)}catch{}d={id:e.pointerId,top:o.getBoundingClientRect().top},m=!0,r.value=D(e.clientY)},F=e=>{if(!d||d.id!==e.pointerId)return;const o=D(e.clientY);o!==r.value&&(r.value=o)},x=e=>{if(!d||d.id!==e.pointerId)return;const o=e.type==="pointerup"?D(e.clientY):null;d=null,o!==null?A(o,!1):a.rememberPosition||(r.value=null)},Z=e=>{if(e.pointerType==="touch"||d)return;const o=e.target.closest("[data-index]");if(!o)return;const n=Number(o.dataset.index);n!==r.value&&(r.value=n)},J=()=>{!d&&!a.rememberPosition&&(r.value=null)},Q=e=>{e.animationName==="gs-swap"&&f.value&&delete f.value.dataset.swap},R=t.computed(()=>({"--gs-accent":a.accentColor,"--gs-surface":a.surfaceColor,"--gs-highlight":a.highlightColor,"--gs-text":a.textColor,"--gs-radius":`${a.radius}px`,"--gs-inner-radius":`${Math.max(3,a.radius-4)}px`,"--gs-chip":`${k.value.chip}px`,"--gs-row":`${k.value.row}px`,"--gs-font":`${k.value.font}px`,"--gs-menu-w":`${a.menuWidth}px`,"--gs-pop":`${a.popDuration}ms`,"--gs-pop-out":`${V.value}ms`,"--gs-glide":`${a.glideDuration}ms`,"--gs-origin":`${h.value==="bottom"?"top":"bottom"} ${a.align}`})),X=t.computed(()=>a.teleported?{...R.value,...L.value}:{});return(e,o)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootRef",ref:f,class:t.normalizeClass(["g-dropdown",e.className]),"data-size":e.size,"data-disabled":e.disabled?"":void 0,style:t.normalizeStyle(R.value),onAnimationend:Q},[t.createElementVNode("button",{ref_key:"triggerRef",ref:P,type:"button",role:"combobox","aria-haspopup":"listbox","data-custom":U?"":void 0,"aria-expanded":i.value==="open","aria-controls":`${t.unref(b)}-list`,"aria-activedescendant":r.value!==null?`${t.unref(b)}-${r.value}`:void 0,"aria-label":e.ariaLabel,disabled:e.disabled,class:"g-dropdown__trigger",onPointerdown:G,onKeydown:W},[t.renderSlot(e.$slots,"trigger",{},()=>[(t.openBlock(),t.createElementBlock("span",{key:$.value,class:"g-dropdown__label","data-empty":c.value<0?"":void 0},t.toDisplayString(c.value>=0?p.value[c.value].label:e.placeholder),9,oe)),o[0]||(o[0]=t.createElementVNode("span",{class:"g-dropdown__arrow","aria-hidden":"true"},[t.createElementVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[t.createElementVNode("path",{d:"m6 9 6 6 6-6"})])],-1))])],40,te),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.teleported},[i.value!=="closed"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuRef",ref:w,class:"g-dropdown__menu","data-state":"open","data-side":h.value,"data-align":e.align,"data-slot":Y?"":void 0,"data-teleported":e.teleported?"":void 0,style:t.normalizeStyle(X.value)},[t.renderSlot(e.$slots,"menu",{close:O},()=>[t.createElementVNode("div",{id:`${t.unref(b)}-list`,role:"listbox","aria-label":e.ariaLabel,class:"g-dropdown__list","data-live":r.value!==null?"":void 0,onPointerover:Z,onPointerleave:J,onPointerdown:q,onPointermove:F,onPointerup:x,onPointercancel:x,onLostpointercapture:x},[t.createElementVNode("span",{ref_key:"pillRef",ref:B,class:"g-dropdown__pill","aria-hidden":"true"},null,512),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,(n,l)=>(t.openBlock(),t.createElementBlock("div",{id:`${t.unref(b)}-${l}`,key:n.value,role:"option","aria-selected":l===c.value,"data-index":l,class:"g-dropdown__option"},[t.createElementVNode("span",re,t.toDisplayString(n.label),1),e.showTags&&n.tag?(t.openBlock(),t.createElementBlock("span",se,t.toDisplayString(n.tag),1)):t.createCommentVNode("",!0),t.createElementVNode("span",{class:"g-dropdown__option-check","data-on":l===c.value?"":void 0,"aria-hidden":"true"},o[1]||(o[1]=[t.createElementVNode("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},[t.createElementVNode("path",{d:"m5 12 5 5 9-9"})],-1)]),8,ie)],8,le))),128))],40,ne)])],12,ae)):t.createCommentVNode("",!0)],8,["disabled"]))],46,ee))}});g.install=E=>{E.component(g.name,g)};exports.GDropdown=g;exports.default=g;
@@ -1,8 +1,8 @@
1
- import { defineComponent as te, computed as m, ref as f, useId as oe, watch as D, onUnmounted as ae, createElementBlock as w, openBlock as y, normalizeStyle as ne, normalizeClass as le, createElementVNode as d, createCommentVNode as Y, unref as $, toDisplayString as S, Fragment as se, renderList as ie } from "vue";
2
- const re = ["data-size", "data-disabled"], ue = ["aria-expanded", "aria-controls", "aria-activedescendant", "aria-label", "disabled"], de = ["data-empty"], ce = ["data-side", "data-align"], pe = ["id", "aria-label", "data-live"], fe = ["id", "aria-selected", "data-index"], ve = { class: "g-dropdown__option-label" }, me = {
1
+ import { defineComponent as de, useSlots as ce, computed as f, ref as p, useId as pe, watch as C, onUnmounted as fe, createElementBlock as w, openBlock as h, normalizeStyle as G, normalizeClass as ve, createElementVNode as d, createBlock as ge, unref as T, renderSlot as O, toDisplayString as B, Teleport as me, createCommentVNode as F, Fragment as he, renderList as we } from "vue";
2
+ const be = ["data-size", "data-disabled"], ye = ["data-custom", "aria-expanded", "aria-controls", "aria-activedescendant", "aria-label", "disabled"], _e = ["data-empty"], ke = ["data-side", "data-align", "data-slot", "data-teleported"], $e = ["id", "aria-label", "data-live"], xe = ["id", "aria-selected", "data-index"], De = { class: "g-dropdown__option-label" }, Ce = {
3
3
  key: 0,
4
4
  class: "g-dropdown__option-tag"
5
- }, ge = ["data-on"], he = 4, we = 1, ye = 6, B = /* @__PURE__ */ te({
5
+ }, Te = ["data-on"], Le = 4, Pe = 1, M = 6, R = /* @__PURE__ */ de({
6
6
  __name: "index",
7
7
  props: {
8
8
  options: { default: () => ["One", "Two", "Three"] },
@@ -24,255 +24,279 @@ const re = ["data-size", "data-disabled"], ue = ["aria-expanded", "aria-controls
24
24
  rememberPosition: { type: Boolean, default: !0 },
25
25
  disabled: { type: Boolean, default: !1 },
26
26
  ariaLabel: { default: "Select" },
27
- className: { default: "" }
27
+ className: { default: "" },
28
+ teleported: { type: Boolean, default: !1 }
28
29
  },
29
30
  emits: ["change"],
30
- setup(C, { emit: V }) {
31
- const M = {
31
+ setup(L, { emit: Z }) {
32
+ const I = {
32
33
  sm: { chip: 28, row: 26, font: 12 },
33
34
  md: { chip: 32, row: 30, font: 13 },
34
35
  lg: { chip: 44, row: 40, font: 14 }
35
- }, j = (e) => typeof e == "string" ? { value: e, label: e } : e, G = (e, t, o) => {
36
- const l = o.toLowerCase(), r = e.length;
37
- for (let i = 1; i <= r; i++) {
38
- const U = (t + i) % r;
39
- if (e[U].label.toLowerCase().startsWith(l)) return U;
36
+ }, q = (e) => typeof e == "string" ? { value: e, label: e } : e, J = (e, t, a) => {
37
+ const n = a.toLowerCase(), i = e.length;
38
+ for (let s = 1; s <= i; s++) {
39
+ const j = (t + s) % i;
40
+ if (e[j].label.toLowerCase().startsWith(n)) return j;
40
41
  }
41
42
  return t;
42
- }, a = C, O = V, v = m(() => a.options.map(j)), I = f(a.defaultValue ?? ""), L = m(() => a.value ?? I.value), c = m(() => v.value.findIndex((e) => e.value === L.value)), s = f("closed"), n = f(null), T = f(a.placement), p = f(null), z = f(null), P = f(null), E = f(null);
43
- let g = !1, b, u = null;
44
- const _ = oe(), k = m(() => M[a.size] ?? M.md), x = m(() => k.value.row + we), N = m(() => Math.round(a.popDuration * 2 / 3));
45
- D(
46
- s,
43
+ }, o = L, z = ce(), Q = !!z.trigger, X = !!z.menu, ee = Z, v = f(() => o.options.map(q)), H = p(o.defaultValue ?? ""), P = f(() => o.value ?? H.value), c = f(() => v.value.findIndex((e) => e.value === P.value)), r = p("closed"), l = p(null), y = p(o.placement), g = p(null), N = p(null), _ = p(null), K = p({}), S = p(null);
44
+ let b = !1, k, u = null;
45
+ const $ = pe(), x = f(() => I[o.size] ?? I.md), D = f(() => x.value.row + Pe), U = f(() => Math.round(o.popDuration * 2 / 3));
46
+ C(
47
+ r,
47
48
  (e) => {
48
49
  if (e !== "open") return;
49
- const t = P.value, o = p.value;
50
- if (!t || !o) return;
51
- const l = o.getBoundingClientRect(), r = t.offsetHeight + ye;
52
- T.value = a.placement === "bottom" && l.bottom + r > window.innerHeight ? "top" : a.placement === "top" && l.top - r < 0 ? "bottom" : a.placement, t.style.transitionDuration = g ? "0ms" : "", t.dataset.state = "closed", t.offsetHeight, t.dataset.state = "open";
53
- const i = E.value;
54
- i && (i.style.transition = "none", i.style.transform = `translateY(${Math.max(0, c.value) * x.value}px)`, i.style.opacity = "0", i.offsetHeight, i.style.transition = "");
50
+ const t = _.value, a = g.value;
51
+ if (!t || !a) return;
52
+ const n = a.getBoundingClientRect(), i = t.offsetHeight + M;
53
+ y.value = o.placement === "bottom" && n.bottom + i > window.innerHeight ? "top" : o.placement === "top" && n.top - i < 0 ? "bottom" : o.placement, o.teleported && (K.value = {
54
+ position: "fixed",
55
+ top: `${y.value === "bottom" ? n.bottom + M : n.top - t.offsetHeight - M}px`,
56
+ left: `${o.align === "right" ? n.right - t.offsetWidth : n.left}px`,
57
+ right: "auto",
58
+ bottom: "auto",
59
+ zIndex: 2e3
60
+ }), t.dataset.state = "closed", t.offsetHeight, t.dataset.state = "open";
61
+ const s = S.value;
62
+ s && (s.style.transition = "none", s.style.transform = `translateY(${Math.max(0, c.value) * D.value}px)`, s.style.opacity = "0", s.offsetHeight, s.style.transition = "");
55
63
  },
56
64
  { flush: "post" }
57
- ), D(
58
- [n, s, x],
65
+ ), C(
66
+ [l, r, D],
59
67
  () => {
60
- const e = E.value;
61
- if (!e || s.value !== "open") return;
62
- if (n.value === null) {
68
+ const e = S.value;
69
+ if (!e || r.value !== "open") return;
70
+ if (l.value === null) {
63
71
  e.style.opacity = "0";
64
72
  return;
65
73
  }
66
- const t = g || e.style.opacity !== "1";
67
- e.style.transitionDuration = t ? "0ms, 150ms" : "", e.style.transform = `translateY(${n.value * x.value}px)`, e.style.opacity = "1", g = !1;
74
+ const t = b || e.style.opacity !== "1";
75
+ e.style.transitionDuration = t ? "0ms, 150ms" : "", e.style.transform = `translateY(${l.value * D.value}px)`, e.style.opacity = "1", b = !1;
68
76
  },
69
77
  { flush: "post" }
70
78
  );
71
- const H = (e) => {
72
- a.disabled || (clearTimeout(b), g = !0, n.value = c.value >= 0 ? c.value : e ? 0 : null, s.value = "open");
73
- }, h = (e) => {
74
- n.value = null, clearTimeout(b);
75
- const t = P.value;
79
+ const Y = (e) => {
80
+ o.disabled || (clearTimeout(k), b = !0, l.value = c.value >= 0 ? c.value : e ? 0 : null, r.value = "open");
81
+ }, m = (e) => {
82
+ l.value = null, clearTimeout(k);
83
+ const t = _.value;
76
84
  if (e === "instant" || !t) {
77
- s.value = "closed";
85
+ r.value = "closed";
78
86
  return;
79
87
  }
80
- t.style.transitionDuration = "", t.dataset.state = "closed", s.value = "closing", b = setTimeout(() => s.value = "closed", N.value + 20);
81
- }, K = (e, t) => {
82
- const o = v.value[e];
83
- if (!o) {
84
- h("instant");
88
+ t.style.transitionDuration = "", t.dataset.state = "closed", r.value = "closing", k = setTimeout(() => r.value = "closed", U.value + 20);
89
+ }, te = () => m("pop"), V = (e, t) => {
90
+ const a = v.value[e];
91
+ if (!a) {
92
+ m("instant");
85
93
  return;
86
94
  }
87
- o.value !== L.value && (a.value === void 0 && (I.value = o.value), O("change", o.value, o), !t && p.value && (p.value.dataset.swap = "")), h("instant"), z.value?.focus({ preventScroll: !0 });
88
- }, W = (e) => {
89
- const t = e.key, o = v.value.length, l = n.value ?? Math.max(0, c.value);
90
- if (s.value !== "open") {
91
- (t === "Enter" || t === " " || t === "ArrowDown" || t === "ArrowUp") && (e.preventDefault(), H(!0));
95
+ a.value !== P.value && (o.value === void 0 && (H.value = a.value), ee("change", a.value, a), !t && g.value && (g.value.dataset.swap = "")), m("instant"), N.value?.focus({ preventScroll: !0 });
96
+ }, oe = (e) => {
97
+ const t = e.key, a = v.value.length, n = l.value ?? Math.max(0, c.value);
98
+ if (r.value !== "open") {
99
+ (t === "Enter" || t === " " || t === "ArrowDown" || t === "ArrowUp") && (e.preventDefault(), Y(!0));
92
100
  return;
93
101
  }
94
- const r = (i) => {
95
- e.preventDefault(), g = !0, n.value = Math.min(o - 1, Math.max(0, i));
102
+ const i = (s) => {
103
+ e.preventDefault(), b = !0, l.value = Math.min(a - 1, Math.max(0, s));
96
104
  };
97
- t === "ArrowDown" || t === "ArrowUp" ? r(n.value === null ? l : l + (t === "ArrowDown" ? 1 : -1)) : t === "Home" || t === "End" ? r(t === "Home" ? 0 : o - 1) : t === "Enter" || t === " " ? (e.preventDefault(), K(l, !0)) : t === "Escape" || t === "Tab" ? (t === "Escape" && e.preventDefault(), h("instant")) : t.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey && r(G(v.value, l, t));
98
- }, F = (e) => {
99
- e.button !== 0 || a.disabled || (e.currentTarget.focus({ preventScroll: !0 }), s.value === "open" ? h("pop") : H(!1));
105
+ t === "ArrowDown" || t === "ArrowUp" ? i(l.value === null ? n : n + (t === "ArrowDown" ? 1 : -1)) : t === "Home" || t === "End" ? i(t === "Home" ? 0 : a - 1) : t === "Enter" || t === " " ? (e.preventDefault(), V(n, !0)) : t === "Escape" || t === "Tab" ? (t === "Escape" && e.preventDefault(), m("instant")) : t.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey && i(J(v.value, n, t));
106
+ }, ae = (e) => {
107
+ e.button !== 0 || o.disabled || (e.currentTarget.focus({ preventScroll: !0 }), r.value === "open" ? m("pop") : Y(!1));
100
108
  };
101
- D(s, (e, t, o) => {
109
+ C(r, (e, t, a) => {
102
110
  if (e === "closed") return;
103
- const l = (r) => {
104
- p.value && !p.value.contains(r.target) && h("pop");
111
+ const n = (i) => {
112
+ const s = i.target;
113
+ g.value?.contains(s) || _.value?.contains(s) || m("pop");
105
114
  };
106
- document.addEventListener("pointerdown", l, !0), o(() => document.removeEventListener("pointerdown", l, !0));
107
- }), D(
108
- () => a.disabled,
115
+ document.addEventListener("pointerdown", n, !0), a(() => document.removeEventListener("pointerdown", n, !0));
116
+ }), C(
117
+ () => o.disabled,
109
118
  (e) => {
110
- e && s.value !== "closed" && h("instant");
119
+ e && r.value !== "closed" && m("instant");
111
120
  }
112
- ), ae(() => clearTimeout(b));
113
- const A = (e) => {
121
+ ), fe(() => clearTimeout(k));
122
+ const E = (e) => {
114
123
  const t = u;
115
124
  if (!t) return null;
116
- const o = Math.floor((e - t.top - he) / x.value);
117
- return o >= 0 && o < v.value.length ? o : null;
118
- }, Z = (e) => {
125
+ const a = Math.floor((e - t.top - Le) / D.value);
126
+ return a >= 0 && a < v.value.length ? a : null;
127
+ }, ne = (e) => {
119
128
  if (u) return;
120
129
  const t = e.currentTarget;
121
130
  try {
122
131
  t.setPointerCapture(e.pointerId);
123
132
  } catch {
124
133
  }
125
- u = { id: e.pointerId, top: t.getBoundingClientRect().top }, g = !0, n.value = A(e.clientY);
126
- }, q = (e) => {
134
+ u = { id: e.pointerId, top: t.getBoundingClientRect().top }, b = !0, l.value = E(e.clientY);
135
+ }, le = (e) => {
127
136
  if (!u || u.id !== e.pointerId) return;
128
- const t = A(e.clientY);
129
- t !== n.value && (n.value = t);
130
- }, R = (e) => {
137
+ const t = E(e.clientY);
138
+ t !== l.value && (l.value = t);
139
+ }, A = (e) => {
131
140
  if (!u || u.id !== e.pointerId) return;
132
- const t = e.type === "pointerup" ? A(e.clientY) : null;
133
- u = null, t !== null ? K(t, !1) : a.rememberPosition || (n.value = null);
134
- }, J = (e) => {
141
+ const t = e.type === "pointerup" ? E(e.clientY) : null;
142
+ u = null, t !== null ? V(t, !1) : o.rememberPosition || (l.value = null);
143
+ }, se = (e) => {
135
144
  if (e.pointerType === "touch" || u) return;
136
145
  const t = e.target.closest("[data-index]");
137
146
  if (!t) return;
138
- const o = Number(t.dataset.index);
139
- o !== n.value && (n.value = o);
140
- }, Q = () => {
141
- !u && !a.rememberPosition && (n.value = null);
142
- }, X = (e) => {
143
- e.animationName === "gs-swap" && p.value && delete p.value.dataset.swap;
144
- }, ee = m(
147
+ const a = Number(t.dataset.index);
148
+ a !== l.value && (l.value = a);
149
+ }, re = () => {
150
+ !u && !o.rememberPosition && (l.value = null);
151
+ }, ie = (e) => {
152
+ e.animationName === "gs-swap" && g.value && delete g.value.dataset.swap;
153
+ }, W = f(
145
154
  () => ({
146
- "--gs-accent": a.accentColor,
147
- "--gs-surface": a.surfaceColor,
148
- "--gs-highlight": a.highlightColor,
149
- "--gs-text": a.textColor,
150
- "--gs-radius": `${a.radius}px`,
151
- "--gs-inner-radius": `${Math.max(3, a.radius - 4)}px`,
152
- "--gs-chip": `${k.value.chip}px`,
153
- "--gs-row": `${k.value.row}px`,
154
- "--gs-font": `${k.value.font}px`,
155
- "--gs-menu-w": `${a.menuWidth}px`,
156
- "--gs-pop": `${a.popDuration}ms`,
157
- "--gs-pop-out": `${N.value}ms`,
158
- "--gs-glide": `${a.glideDuration}ms`,
159
- "--gs-origin": `${T.value === "bottom" ? "top" : "bottom"} ${a.align}`
155
+ "--gs-accent": o.accentColor,
156
+ "--gs-surface": o.surfaceColor,
157
+ "--gs-highlight": o.highlightColor,
158
+ "--gs-text": o.textColor,
159
+ "--gs-radius": `${o.radius}px`,
160
+ "--gs-inner-radius": `${Math.max(3, o.radius - 4)}px`,
161
+ "--gs-chip": `${x.value.chip}px`,
162
+ "--gs-row": `${x.value.row}px`,
163
+ "--gs-font": `${x.value.font}px`,
164
+ "--gs-menu-w": `${o.menuWidth}px`,
165
+ "--gs-pop": `${o.popDuration}ms`,
166
+ "--gs-pop-out": `${U.value}ms`,
167
+ "--gs-glide": `${o.glideDuration}ms`,
168
+ "--gs-origin": `${y.value === "bottom" ? "top" : "bottom"} ${o.align}`
160
169
  })
170
+ ), ue = f(
171
+ () => o.teleported ? { ...W.value, ...K.value } : {}
161
172
  );
162
- return (e, t) => (y(), w("div", {
173
+ return (e, t) => (h(), w("div", {
163
174
  ref_key: "rootRef",
164
- ref: p,
165
- class: le(["g-dropdown", e.className]),
175
+ ref: g,
176
+ class: ve(["g-dropdown", e.className]),
166
177
  "data-size": e.size,
167
178
  "data-disabled": e.disabled ? "" : void 0,
168
- style: ne(ee.value),
169
- onAnimationend: X
179
+ style: G(W.value),
180
+ onAnimationend: ie
170
181
  }, [
171
182
  d("button", {
172
183
  ref_key: "triggerRef",
173
- ref: z,
184
+ ref: N,
174
185
  type: "button",
175
186
  role: "combobox",
176
187
  "aria-haspopup": "listbox",
177
- "aria-expanded": s.value === "open",
178
- "aria-controls": `${$(_)}-list`,
179
- "aria-activedescendant": n.value !== null ? `${$(_)}-${n.value}` : void 0,
188
+ "data-custom": Q ? "" : void 0,
189
+ "aria-expanded": r.value === "open",
190
+ "aria-controls": `${T($)}-list`,
191
+ "aria-activedescendant": l.value !== null ? `${T($)}-${l.value}` : void 0,
180
192
  "aria-label": e.ariaLabel,
181
193
  disabled: e.disabled,
182
194
  class: "g-dropdown__trigger",
183
- onPointerdown: F,
184
- onKeydown: W
195
+ onPointerdown: ae,
196
+ onKeydown: oe
185
197
  }, [
186
- (y(), w("span", {
187
- key: L.value,
188
- class: "g-dropdown__label",
189
- "data-empty": c.value < 0 ? "" : void 0
190
- }, S(c.value >= 0 ? v.value[c.value].label : e.placeholder), 9, de)),
191
- t[0] || (t[0] = d("span", {
192
- class: "g-dropdown__arrow",
193
- "aria-hidden": "true"
194
- }, [
195
- d("svg", {
196
- viewBox: "0 0 24 24",
197
- width: "12",
198
- height: "12",
199
- fill: "none",
200
- stroke: "currentColor",
201
- "stroke-width": "2.5",
202
- "stroke-linecap": "round",
203
- "stroke-linejoin": "round"
198
+ O(e.$slots, "trigger", {}, () => [
199
+ (h(), w("span", {
200
+ key: P.value,
201
+ class: "g-dropdown__label",
202
+ "data-empty": c.value < 0 ? "" : void 0
203
+ }, B(c.value >= 0 ? v.value[c.value].label : e.placeholder), 9, _e)),
204
+ t[0] || (t[0] = d("span", {
205
+ class: "g-dropdown__arrow",
206
+ "aria-hidden": "true"
204
207
  }, [
205
- d("path", { d: "m6 9 6 6 6-6" })
206
- ])
207
- ], -1))
208
- ], 40, ue),
209
- s.value !== "closed" ? (y(), w("div", {
210
- key: 0,
211
- ref_key: "menuRef",
212
- ref: P,
213
- class: "g-dropdown__menu",
214
- "data-state": "open",
215
- "data-side": T.value,
216
- "data-align": e.align
208
+ d("svg", {
209
+ viewBox: "0 0 24 24",
210
+ width: "12",
211
+ height: "12",
212
+ fill: "none",
213
+ stroke: "currentColor",
214
+ "stroke-width": "2.5",
215
+ "stroke-linecap": "round",
216
+ "stroke-linejoin": "round"
217
+ }, [
218
+ d("path", { d: "m6 9 6 6 6-6" })
219
+ ])
220
+ ], -1))
221
+ ])
222
+ ], 40, ye),
223
+ (h(), ge(me, {
224
+ to: "body",
225
+ disabled: !e.teleported
217
226
  }, [
218
- d("div", {
219
- id: `${$(_)}-list`,
220
- role: "listbox",
221
- "aria-label": e.ariaLabel,
222
- class: "g-dropdown__list",
223
- "data-live": n.value !== null ? "" : void 0,
224
- onPointerover: J,
225
- onPointerleave: Q,
226
- onPointerdown: Z,
227
- onPointermove: q,
228
- onPointerup: R,
229
- onPointercancel: R,
230
- onLostpointercapture: R
227
+ r.value !== "closed" ? (h(), w("div", {
228
+ key: 0,
229
+ ref_key: "menuRef",
230
+ ref: _,
231
+ class: "g-dropdown__menu",
232
+ "data-state": "open",
233
+ "data-side": y.value,
234
+ "data-align": e.align,
235
+ "data-slot": X ? "" : void 0,
236
+ "data-teleported": e.teleported ? "" : void 0,
237
+ style: G(ue.value)
231
238
  }, [
232
- d("span", {
233
- ref_key: "pillRef",
234
- ref: E,
235
- class: "g-dropdown__pill",
236
- "aria-hidden": "true"
237
- }, null, 512),
238
- (y(!0), w(se, null, ie(v.value, (o, l) => (y(), w("div", {
239
- id: `${$(_)}-${l}`,
240
- key: o.value,
241
- role: "option",
242
- "aria-selected": l === c.value,
243
- "data-index": l,
244
- class: "g-dropdown__option"
245
- }, [
246
- d("span", ve, S(o.label), 1),
247
- e.showTags && o.tag ? (y(), w("span", me, S(o.tag), 1)) : Y("", !0),
248
- d("span", {
249
- class: "g-dropdown__option-check",
250
- "data-on": l === c.value ? "" : void 0,
251
- "aria-hidden": "true"
252
- }, t[1] || (t[1] = [
253
- d("svg", {
254
- viewBox: "0 0 24 24",
255
- width: "13",
256
- height: "13",
257
- fill: "none",
258
- stroke: "currentColor",
259
- "stroke-width": "2.5",
260
- "stroke-linecap": "round",
261
- "stroke-linejoin": "round"
239
+ O(e.$slots, "menu", { close: te }, () => [
240
+ d("div", {
241
+ id: `${T($)}-list`,
242
+ role: "listbox",
243
+ "aria-label": e.ariaLabel,
244
+ class: "g-dropdown__list",
245
+ "data-live": l.value !== null ? "" : void 0,
246
+ onPointerover: se,
247
+ onPointerleave: re,
248
+ onPointerdown: ne,
249
+ onPointermove: le,
250
+ onPointerup: A,
251
+ onPointercancel: A,
252
+ onLostpointercapture: A
253
+ }, [
254
+ d("span", {
255
+ ref_key: "pillRef",
256
+ ref: S,
257
+ class: "g-dropdown__pill",
258
+ "aria-hidden": "true"
259
+ }, null, 512),
260
+ (h(!0), w(he, null, we(v.value, (a, n) => (h(), w("div", {
261
+ id: `${T($)}-${n}`,
262
+ key: a.value,
263
+ role: "option",
264
+ "aria-selected": n === c.value,
265
+ "data-index": n,
266
+ class: "g-dropdown__option"
262
267
  }, [
263
- d("path", { d: "m5 12 5 5 9-9" })
264
- ], -1)
265
- ]), 8, ge)
266
- ], 8, fe))), 128))
267
- ], 40, pe)
268
- ], 8, ce)) : Y("", !0)
269
- ], 46, re));
268
+ d("span", De, B(a.label), 1),
269
+ e.showTags && a.tag ? (h(), w("span", Ce, B(a.tag), 1)) : F("", !0),
270
+ d("span", {
271
+ class: "g-dropdown__option-check",
272
+ "data-on": n === c.value ? "" : void 0,
273
+ "aria-hidden": "true"
274
+ }, t[1] || (t[1] = [
275
+ d("svg", {
276
+ viewBox: "0 0 24 24",
277
+ width: "13",
278
+ height: "13",
279
+ fill: "none",
280
+ stroke: "currentColor",
281
+ "stroke-width": "2.5",
282
+ "stroke-linecap": "round",
283
+ "stroke-linejoin": "round"
284
+ }, [
285
+ d("path", { d: "m5 12 5 5 9-9" })
286
+ ], -1)
287
+ ]), 8, Te)
288
+ ], 8, xe))), 128))
289
+ ], 40, $e)
290
+ ])
291
+ ], 12, ke)) : F("", !0)
292
+ ], 8, ["disabled"]))
293
+ ], 46, be));
270
294
  }
271
295
  });
272
- B.install = (C) => {
273
- C.component(B.name, B);
296
+ R.install = (L) => {
297
+ L.component(R.name, R);
274
298
  };
275
299
  export {
276
- B as GDropdown,
277
- B as default
300
+ R as GDropdown,
301
+ R as default
278
302
  };
@@ -1 +1 @@
1
- .g-dropdown{position:relative;display:inline-block}.g-dropdown[data-disabled]{opacity:.5}.g-dropdown__trigger{position:relative;display:inline-flex;align-items:center;gap:6px;height:var(--gs-chip);margin:0;padding:0 8px 0 10px;border:0;border-radius:var(--gs-inner-radius);outline:none;background:var(--gs-surface);color:var(--gs-text);font-family:inherit;font-size:var(--gs-font);font-weight:500;line-height:1;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .1s ease,transform .16s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger:disabled{cursor:default}.g-dropdown__trigger:not(:disabled):active{transform:scale(.97)}.g-dropdown__trigger[aria-expanded=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}@media(hover:hover)and (pointer:fine){.g-dropdown__trigger:not(:disabled):hover{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}}.g-dropdown__label[data-empty]{opacity:.6}.g-dropdown[data-swap] .g-dropdown__label{animation:gs-swap .16s ease}.g-dropdown__arrow{display:inline-flex;color:color-mix(in srgb,var(--gs-text) 55%,transparent);transition:transform .2s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger[aria-expanded=true] .g-dropdown__arrow{transform:rotate(180deg)}.g-dropdown__menu{position:absolute;z-index:20;top:calc(100% + 6px);left:0;min-width:100%;width:var(--gs-menu-w);padding:4px;border-radius:var(--gs-radius);background:var(--gs-surface);box-shadow:0 4px 16px color-mix(in srgb,#000 22%,transparent);transform:scale(.95);transform-origin:var(--gs-origin);opacity:0;pointer-events:none;transition:opacity var(--gs-pop) cubic-bezier(.23,1,.32,1),transform var(--gs-pop) cubic-bezier(.23,1,.32,1)}.g-dropdown__menu[data-side=top]{top:auto;bottom:calc(100% + 6px)}.g-dropdown__menu[data-align=right]{left:auto;right:0}.g-dropdown__menu[data-state=open]{transform:scale(1);opacity:1;pointer-events:auto}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out);pointer-events:none}.g-dropdown__list{position:relative;display:grid;gap:1px;touch-action:none}.g-dropdown__pill{position:absolute;top:0;right:0;left:0;height:var(--gs-row);border-radius:var(--gs-inner-radius);background:var(--gs-highlight);opacity:0;pointer-events:none;transition:transform var(--gs-glide) cubic-bezier(.23,1,.32,1),opacity .15s ease}.g-dropdown__option{position:relative;z-index:1;display:flex;align-items:center;gap:8px;height:var(--gs-row);padding:0 8px 0 10px;border-radius:var(--gs-inner-radius);color:var(--gs-text);font-size:var(--gs-font);cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease}.g-dropdown__option[aria-selected=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,transparent)}.g-dropdown__list[data-live] .g-dropdown__option[aria-selected=true]{background:transparent}.g-dropdown__option-label{flex:1 1 0%;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.g-dropdown__option-tag{flex-shrink:0;color:color-mix(in srgb,var(--gs-text) 55%,transparent);font-size:calc(var(--gs-font) - 2px)}.g-dropdown__option-check{display:inline-flex;flex-shrink:0;visibility:hidden;color:var(--gs-accent)}.g-dropdown__option-check[data-on]{visibility:visible}@keyframes gs-swap{0%{opacity:.6;filter:blur(2px)}}@media(prefers-reduced-motion:reduce){.g-dropdown__trigger{transition:background-color .1s ease}.g-dropdown__trigger:not(:disabled):active{transform:none}.g-dropdown[data-swap] .g-dropdown__label{animation:none}.g-dropdown__arrow{transition:none}.g-dropdown__menu{transform:none!important;transition:opacity var(--gs-pop) ease}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out)}.g-dropdown__pill{transition:opacity .15s ease}}
1
+ .g-dropdown{position:relative;display:inline-block}.g-dropdown[data-disabled]{opacity:.5}.g-dropdown__trigger{position:relative;display:inline-flex;align-items:center;gap:6px;height:var(--gs-chip);margin:0;padding:0 8px 0 10px;border:0;border-radius:var(--gs-inner-radius);outline:none;background:var(--gs-surface);color:var(--gs-text);font-family:inherit;font-size:var(--gs-font);font-weight:500;line-height:1;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .1s ease,transform .16s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger:disabled{cursor:default}.g-dropdown__trigger:not(:disabled):active{transform:scale(.97)}.g-dropdown__trigger[aria-expanded=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}@media(hover:hover)and (pointer:fine){.g-dropdown__trigger:not(:disabled):hover{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}}.g-dropdown__trigger[data-custom]{height:auto;padding:0;gap:0;background:transparent;border-radius:0}.g-dropdown__trigger[data-custom][aria-expanded=true]{background:transparent}@media(hover:hover)and (pointer:fine){.g-dropdown__trigger[data-custom]:not(:disabled):hover{background:transparent}}.g-dropdown__trigger[data-custom]:not(:disabled):active{transform:none}.g-dropdown__label[data-empty]{opacity:.6}.g-dropdown[data-swap] .g-dropdown__label{animation:gs-swap .16s ease}.g-dropdown__arrow{display:inline-flex;color:color-mix(in srgb,var(--gs-text) 55%,transparent);transition:transform .2s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger[aria-expanded=true] .g-dropdown__arrow{transform:rotate(180deg)}.g-dropdown__menu{position:absolute;z-index:20;top:calc(100% + 6px);left:0;min-width:100%;width:var(--gs-menu-w);padding:4px;border-radius:var(--gs-radius);background:var(--gs-surface);box-shadow:0 4px 16px color-mix(in srgb,#000 22%,transparent);transform:scale(.95);transform-origin:var(--gs-origin);opacity:0;pointer-events:none;transition:opacity var(--gs-pop) cubic-bezier(.23,1,.32,1),transform var(--gs-pop) cubic-bezier(.23,1,.32,1)}.g-dropdown__menu[data-side=top]{top:auto;bottom:calc(100% + 6px)}.g-dropdown__menu[data-align=right]{left:auto;right:0}.g-dropdown__menu[data-state=open]{transform:scale(1);opacity:1;pointer-events:auto}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out);pointer-events:none}.g-dropdown__menu[data-slot]{width:auto;min-width:0}.g-dropdown__menu[data-teleported]{min-width:0;z-index:2000}.g-dropdown__list{position:relative;display:grid;gap:1px;touch-action:none}.g-dropdown__pill{position:absolute;top:0;right:0;left:0;height:var(--gs-row);border-radius:var(--gs-inner-radius);background:var(--gs-highlight);opacity:0;pointer-events:none;transition:transform var(--gs-glide) cubic-bezier(.23,1,.32,1),opacity .15s ease}.g-dropdown__option{position:relative;z-index:1;display:flex;align-items:center;gap:8px;height:var(--gs-row);padding:0 8px 0 10px;border-radius:var(--gs-inner-radius);color:var(--gs-text);font-size:var(--gs-font);cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease}.g-dropdown__option[aria-selected=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,transparent)}.g-dropdown__list[data-live] .g-dropdown__option[aria-selected=true]{background:transparent}.g-dropdown__option-label{flex:1 1 0%;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.g-dropdown__option-tag{flex-shrink:0;color:color-mix(in srgb,var(--gs-text) 55%,transparent);font-size:calc(var(--gs-font) - 2px)}.g-dropdown__option-check{display:inline-flex;flex-shrink:0;visibility:hidden;color:var(--gs-accent)}.g-dropdown__option-check[data-on]{visibility:visible}@keyframes gs-swap{0%{opacity:.6;filter:blur(2px)}}@media(prefers-reduced-motion:reduce){.g-dropdown__trigger{transition:background-color .1s ease}.g-dropdown__trigger:not(:disabled):active{transform:none}.g-dropdown[data-swap] .g-dropdown__label{animation:none}.g-dropdown__arrow{transition:none}.g-dropdown__menu{transform:none!important;transition:opacity var(--gs-pop) ease}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out)}.g-dropdown__pill{transition:opacity .15s ease}}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),K=require("../GBranched-BtF7heMk.js"),k={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",width:"1em",height:"1em"},R=()=>e.h("svg",k,[e.h("path",{d:"m15 18-6-6 6-6"})]),q=()=>e.h("svg",k,[e.h("path",{d:"m9 18 6-6-6-6"})]),A=()=>e.h("svg",k,[e.h("path",{d:"m6 9 6 6 6-6"})]),J=["aria-disabled","aria-label"],U={key:0,class:"g-pagination__total"},Z=["disabled","aria-expanded","aria-label"],H=["data-open"],Q={key:0,class:"g-pagination__menu",role:"listbox"},W=["aria-selected","onClick"],X=["disabled"],Y=["disabled","aria-current","aria-label","onClick"],ee=["disabled","aria-label","onClick"],te=["disabled"],ae={key:5,class:"g-pagination__jump"},ne=["disabled","placeholder","aria-label"],N=5,oe=e.defineComponent({name:"GPagination",__name:"index",props:{total:{default:0},currentPage:{default:void 0},pageSize:{default:void 0},pageSizes:{default:()=>[10,20,50,100]},layout:{default:"total, sizes, prev, pager, next, jumper"},pageCount:{default:void 0},size:{default:"middle"},hideOnSinglePage:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},className:{default:""}},emits:["update:current-page","update:page-size","current-change","size-change","prev-click","next-click"],setup(m,{emit:x}){const b={small:{height:24,font:12},middle:{height:32,font:14},large:{height:40,font:16}},n=m,s=x,w=(t,o,a)=>Math.min(a,Math.max(o,t)),h=e.ref(1),_=e.ref(10),l=e.computed(()=>n.currentPage!==void 0?n.currentPage:h.value),c=e.computed(()=>n.pageSize!==void 0?n.pageSize:_.value),r=e.computed(()=>{if(n.pageCount)return Math.max(1,n.pageCount);const t=Math.ceil(n.total/c.value);return Math.max(1,Number.isFinite(t)?t:1)}),V=e.computed(()=>{const t=r.value,o=l.value;return t<=7?Array.from({length:t},(a,g)=>g+1):o<=4?[1,2,3,4,5,"next",t]:o>=t-3?[1,"prev",t-4,t-3,t-2,t-1,t]:[1,"prev",o-1,o,o+1,"next",t]}),P=e.computed(()=>n.hideOnSinglePage&&r.value<=1),u=(t,o)=>{if(n.disabled)return;const a=w(Math.floor(t)||1,1,r.value);a!==l.value&&(n.currentPage===void 0&&(h.value=a),s("update:current-page",a),s("current-change",a),o==="prev"&&s("prev-click",a),o==="next"&&s("next-click",a))},$=()=>u(l.value-1,"prev"),L=()=>u(l.value+1,"next"),T=t=>u(t==="prev"?l.value-N:l.value+N);e.watch(r,t=>{l.value>t&&u(t)});const i=e.ref(!1),y=e.ref(null),z=e.computed(()=>n.pageSizes.map(t=>({value:t,label:`${t} 条/页`}))),B=e.computed(()=>z.value.find(t=>t.value===c.value)?.label??`${c.value} 条/页`),D=()=>{n.disabled||(i.value=!i.value)},M=t=>{i.value=!1,t!==c.value&&(n.pageSize===void 0&&(_.value=t),s("update:page-size",t),s("size-change",t))},C=t=>t.key?.toLowerCase()==="enter"||t.code==="Enter",j=t=>t.key?.toLowerCase()==="escape",I=t=>{if(!n.disabled){if(j(t)){i.value=!1;return}!i.value&&(C(t)||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),i.value=!0)}},f=t=>{y.value?.contains(t.target)||(i.value=!1)};e.watch(i,t=>{t?document.addEventListener("pointerdown",f):document.removeEventListener("pointerdown",f)}),e.onBeforeUnmount(()=>document.removeEventListener("pointerdown",f));const v=e.ref(""),S=()=>{const t=parseInt(v.value,10);v.value="",!Number.isNaN(t)&&u(t)},O=t=>{C(t)&&(t.preventDefault(),S())},d=e.computed(()=>n.layout.split(",").map(t=>t.trim()).filter(Boolean)),E=e.computed(()=>b[n.size]||b.middle),F=e.computed(()=>({"--pg-h":`var(--g-size-${n.size}-height, ${E.value.height}px)`,"--pg-font":`var(--g-size-${n.size}-font-size, ${E.value.font}px)`}));return(t,o)=>P.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("nav",{key:0,class:e.normalizeClass(["g-pagination",t.className]),style:e.normalizeStyle(F.value),"aria-disabled":t.disabled||void 0,"aria-label":`Pagination, page ${l.value} of ${r.value}`,role:"navigation"},[d.value.includes("total")?(e.openBlock(),e.createElementBlock("span",U," 共 "+e.toDisplayString(t.total)+" 条 ",1)):e.createCommentVNode("",!0),d.value.includes("sizes")?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"sizesRef",ref:y,class:"g-pagination__sizes"},[e.createElementVNode("button",{type:"button",class:"g-pagination__cell g-pagination__select",disabled:t.disabled,"aria-expanded":i.value,"aria-haspopup":"listbox","aria-label":`每页条数,当前 ${B.value}`,onClick:D,onKeydown:I},[e.createTextVNode(e.toDisplayString(B.value)+" ",1),e.createElementVNode("span",{class:"g-pagination__select-icon","data-open":i.value||void 0},[e.createVNode(e.unref(A))],8,H)],40,Z),e.createVNode(e.Transition,{name:"g-pagination-pop"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createElementBlock("ul",Q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,a=>(e.openBlock(),e.createElementBlock("li",{key:a.value,role:"option","aria-selected":a.value===c.value,class:e.normalizeClass([{"is-active":a.value===c.value},"g-pagination__option"]),tabindex:"-1",onClick:g=>M(a.value)},e.toDisplayString(a.label),11,W))),128))])):e.createCommentVNode("",!0)]),_:1})],512)):e.createCommentVNode("",!0),d.value.includes("prev")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"g-pagination__cell",disabled:t.disabled||l.value<=1,"aria-label":"上一页",onClick:$},[e.createVNode(e.unref(R))],8,X)):e.createCommentVNode("",!0),d.value.includes("pager")?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:3},e.renderList(V.value,(a,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${a}-${g}`},[typeof a=="number"?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["g-pagination__cell g-pagination__pager",{"is-active":a===l.value}]),disabled:t.disabled,"aria-current":a===l.value?"page":void 0,"aria-label":`第 ${a} 页`,onClick:G=>u(a)},e.toDisplayString(a),11,Y)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"g-pagination__cell g-pagination__ellipsis",disabled:t.disabled,"aria-label":a==="prev"?"向前 5 页":"向后 5 页",onClick:G=>T(a)}," ••• ",8,ee))],64))),128)):e.createCommentVNode("",!0),d.value.includes("next")?(e.openBlock(),e.createElementBlock("button",{key:4,type:"button",class:"g-pagination__cell",disabled:t.disabled||l.value>=r.value,"aria-label":"下一页",onClick:L},[e.createVNode(e.unref(q))],8,te)):e.createCommentVNode("",!0),d.value.includes("jumper")?(e.openBlock(),e.createElementBlock("span",ae,[o[1]||(o[1]=e.createTextVNode(" 前往 ")),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":o[0]||(o[0]=a=>v.value=a),class:"g-pagination__input",type:"text",inputmode:"numeric",disabled:t.disabled,placeholder:String(l.value),"aria-label":`跳转到指定页,共 ${r.value} 页`,onKeydown:O,onBlur:S},null,40,ne),[[e.vModelText,v.value]]),o[2]||(o[2]=e.createTextVNode(" 页 "))])):e.createCommentVNode("",!0)],14,J))}}),p=K._export_sfc(oe,[["__scopeId","data-v-f8c5bc28"]]);p.install=m=>{m.component(p.name,p)};exports.GPagination=p;exports.default=p;