geekin-devtoys 0.4.3 → 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.
- package/lib/GDropdown/index.js +1 -1
- package/lib/GDropdown/index.mjs +210 -186
- package/lib/GDropdown/style.css +1 -1
- package/lib/GPagination/index.js +1 -0
- package/lib/GPagination/index.mjs +208 -0
- package/lib/GPagination.d.ts +1 -0
- package/lib/GTable/index.js +1 -1
- package/lib/GTable/index.mjs +279 -420
- package/lib/GTable/style.css +1 -1
- package/lib/assets/GPagination.css +1 -0
- package/lib/components/GDropdown/__tests__/index.test.d.ts +1 -0
- package/lib/components/GDropdown/__tests__/slots.tmp.test.d.ts +1 -0
- package/lib/components/GDropdown/index.d.ts +32 -6
- package/lib/components/GPagination/__tests__/index.test.d.ts +1 -0
- package/lib/components/GPagination/icons.d.ts +7 -0
- package/lib/components/GPagination/index.d.ts +30 -0
- package/lib/components/GPagination/types.d.ts +66 -0
- package/lib/components/GProgress/index.d.ts +1 -1
- package/lib/components/GRadio/index.d.ts +1 -1
- package/lib/components/GRing/index.d.ts +1 -1
- package/lib/components/GSegment/index.d.ts +3 -3
- package/lib/components/GSlider/index.d.ts +2 -2
- package/lib/components/GTable/__tests__/index.test.d.ts +1 -0
- package/lib/components/GTable/icons.d.ts +5 -0
- package/lib/components/GTable/index.d.ts +35 -18
- package/lib/components/GTable/types.d.ts +23 -0
- package/lib/components/GTree/index.d.ts +2 -4
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +35 -32
- package/lib/index/style.css +2 -2
- package/lib/index.d.ts +3 -1
- package/package.json +17 -10
package/lib/GDropdown/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),
|
|
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;
|
package/lib/GDropdown/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
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
|
-
},
|
|
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(
|
|
31
|
-
const
|
|
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
|
-
},
|
|
36
|
-
const
|
|
37
|
-
for (let
|
|
38
|
-
const
|
|
39
|
-
if (e[
|
|
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
|
-
},
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
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 =
|
|
50
|
-
if (!t || !
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
),
|
|
58
|
-
[
|
|
65
|
+
), C(
|
|
66
|
+
[l, r, D],
|
|
59
67
|
() => {
|
|
60
|
-
const e =
|
|
61
|
-
if (!e ||
|
|
62
|
-
if (
|
|
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 =
|
|
67
|
-
e.style.transitionDuration = t ? "0ms, 150ms" : "", e.style.transform = `translateY(${
|
|
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
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
const t =
|
|
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
|
-
|
|
85
|
+
r.value = "closed";
|
|
78
86
|
return;
|
|
79
87
|
}
|
|
80
|
-
t.style.transitionDuration = "", t.dataset.state = "closed",
|
|
81
|
-
},
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
|
|
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
|
-
|
|
88
|
-
},
|
|
89
|
-
const t = e.key,
|
|
90
|
-
if (
|
|
91
|
-
(t === "Enter" || t === " " || t === "ArrowDown" || t === "ArrowUp") && (e.preventDefault(),
|
|
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
|
|
95
|
-
e.preventDefault(),
|
|
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" ?
|
|
98
|
-
},
|
|
99
|
-
e.button !== 0 ||
|
|
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
|
-
|
|
109
|
+
C(r, (e, t, a) => {
|
|
102
110
|
if (e === "closed") return;
|
|
103
|
-
const
|
|
104
|
-
|
|
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",
|
|
107
|
-
}),
|
|
108
|
-
() =>
|
|
115
|
+
document.addEventListener("pointerdown", n, !0), a(() => document.removeEventListener("pointerdown", n, !0));
|
|
116
|
+
}), C(
|
|
117
|
+
() => o.disabled,
|
|
109
118
|
(e) => {
|
|
110
|
-
e &&
|
|
119
|
+
e && r.value !== "closed" && m("instant");
|
|
111
120
|
}
|
|
112
|
-
),
|
|
113
|
-
const
|
|
121
|
+
), fe(() => clearTimeout(k));
|
|
122
|
+
const E = (e) => {
|
|
114
123
|
const t = u;
|
|
115
124
|
if (!t) return null;
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
},
|
|
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 },
|
|
126
|
-
},
|
|
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 =
|
|
129
|
-
t !==
|
|
130
|
-
},
|
|
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" ?
|
|
133
|
-
u = null, t !== null ?
|
|
134
|
-
},
|
|
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
|
|
139
|
-
|
|
140
|
-
},
|
|
141
|
-
!u && !
|
|
142
|
-
},
|
|
143
|
-
e.animationName === "gs-swap" &&
|
|
144
|
-
},
|
|
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":
|
|
147
|
-
"--gs-surface":
|
|
148
|
-
"--gs-highlight":
|
|
149
|
-
"--gs-text":
|
|
150
|
-
"--gs-radius": `${
|
|
151
|
-
"--gs-inner-radius": `${Math.max(3,
|
|
152
|
-
"--gs-chip": `${
|
|
153
|
-
"--gs-row": `${
|
|
154
|
-
"--gs-font": `${
|
|
155
|
-
"--gs-menu-w": `${
|
|
156
|
-
"--gs-pop": `${
|
|
157
|
-
"--gs-pop-out": `${
|
|
158
|
-
"--gs-glide": `${
|
|
159
|
-
"--gs-origin": `${
|
|
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) => (
|
|
173
|
+
return (e, t) => (h(), w("div", {
|
|
163
174
|
ref_key: "rootRef",
|
|
164
|
-
ref:
|
|
165
|
-
class:
|
|
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:
|
|
169
|
-
onAnimationend:
|
|
179
|
+
style: G(W.value),
|
|
180
|
+
onAnimationend: ie
|
|
170
181
|
}, [
|
|
171
182
|
d("button", {
|
|
172
183
|
ref_key: "triggerRef",
|
|
173
|
-
ref:
|
|
184
|
+
ref: N,
|
|
174
185
|
type: "button",
|
|
175
186
|
role: "combobox",
|
|
176
187
|
"aria-haspopup": "listbox",
|
|
177
|
-
"
|
|
178
|
-
"aria-
|
|
179
|
-
"aria-
|
|
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:
|
|
184
|
-
onKeydown:
|
|
195
|
+
onPointerdown: ae,
|
|
196
|
+
onKeydown: oe
|
|
185
197
|
}, [
|
|
186
|
-
(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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("
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
class: "g-
|
|
223
|
-
"data-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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("
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
273
|
-
|
|
296
|
+
R.install = (L) => {
|
|
297
|
+
L.component(R.name, R);
|
|
274
298
|
};
|
|
275
299
|
export {
|
|
276
|
-
|
|
277
|
-
|
|
300
|
+
R as GDropdown,
|
|
301
|
+
R as default
|
|
278
302
|
};
|
package/lib/GDropdown/style.css
CHANGED
|
@@ -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;
|