@nocopypaste/vue-grid 0.6.0 → 0.7.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/AGENTS.md +7 -1
- package/CHANGELOG.md +24 -0
- package/README.md +143 -67
- package/agent/api.json +51 -9
- package/agent/api.md +14 -6
- package/agent/grid-config.schema.json +9 -11
- package/dist/agent/api.js +51 -9
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +545 -520
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +4 -3
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js +58 -53
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js +50 -49
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js +151 -146
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js +44 -43
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +10 -8
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +62 -57
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js +59 -58
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js +62 -55
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +60 -59
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js +27 -26
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +12 -11
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js +37 -30
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useGridExport.js +21 -6
- package/dist/composables/useGridExport.js.map +1 -1
- package/dist/composables/useGridMenus.js +41 -41
- package/dist/composables/useGridMenus.js.map +1 -1
- package/dist/composables/useStatusBar.js +9 -0
- package/dist/composables/useStatusBar.js.map +1 -1
- package/dist/features/export.js.map +1 -1
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/messages.js +20 -0
- package/dist/internal/messages.js.map +1 -0
- package/dist/internal/print.js +51 -0
- package/dist/internal/print.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js +31 -30
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js +28 -27
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js +22 -21
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js +37 -36
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js +16 -15
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js +18 -17
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/types/components/VGrid.vue.d.ts +34 -7
- package/dist/types/components/VGridColumnMenu.vue.d.ts +4 -5
- package/dist/types/components/VGridMenu.vue.d.ts +1 -1
- package/dist/types/components/VGridPagination.vue.d.ts +8 -3
- package/dist/types/components/VGridSearch.vue.d.ts +2 -2
- package/dist/types/composables/useGridExport.d.ts +2 -1
- package/dist/types/composables/useGridMenus.d.ts +3 -1
- package/dist/types/composables/useStatusBar.d.ts +7 -0
- package/dist/types/features/export.d.ts +2 -1
- package/dist/types/internal/context.d.ts +5 -1
- package/dist/types/internal/messages.d.ts +16 -0
- package/dist/types/internal/print.d.ts +16 -0
- package/dist/types/renderers/parts/CopyButton.vue.d.ts +1 -3
- package/dist/types/types.d.ts +300 -0
- package/llms-full.txt +164 -74
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { anchorNameFor as e, trackAnchor as t } from "../internal/anchor.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useMessages as n } from "../internal/messages.js";
|
|
3
|
+
import { Fragment as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, openBlock as p, ref as m, renderList as h, resolveDynamicComponent as g, shallowRef as _, toDisplayString as v, toRaw as y, unref as b, useId as x, withModifiers as S } from "vue";
|
|
3
4
|
// src/components/VGridMenu.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var
|
|
5
|
+
var C = [
|
|
5
6
|
"id",
|
|
6
7
|
"aria-label",
|
|
7
8
|
"data-placement"
|
|
8
|
-
],
|
|
9
|
+
], w = {
|
|
9
10
|
key: 0,
|
|
10
11
|
role: "separator",
|
|
11
12
|
class: "vg-menu-separator"
|
|
12
|
-
},
|
|
13
|
+
}, T = ["disabled", "onClick"], E = { class: "vg-menu-label" }, D = {
|
|
13
14
|
key: 1,
|
|
14
15
|
class: "vg-menu-hint"
|
|
15
|
-
},
|
|
16
|
+
}, O = /*@__PURE__*/ c({
|
|
16
17
|
__name: "VGridMenu",
|
|
17
18
|
props: {
|
|
18
19
|
items: {},
|
|
19
|
-
label: {
|
|
20
|
+
label: {},
|
|
20
21
|
placement: { default: "bottom-end" },
|
|
21
22
|
id: {},
|
|
22
23
|
anchorName: {}
|
|
@@ -26,34 +27,34 @@ var S = [
|
|
|
26
27
|
"open",
|
|
27
28
|
"close"
|
|
28
29
|
],
|
|
29
|
-
setup(
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
function
|
|
34
|
-
|
|
30
|
+
setup(c, { expose: O, emit: k }) {
|
|
31
|
+
let A = c, j = n(), M = k, N = x(), P = A.id ?? `vg-menu-${N}`, F = e(N), I = `${F}-pt`, L = _(), R = m(null), z = m(A.placement), B = m(A.anchorName ?? F), V = m(!1), H = null, U = null, W = null, G = () => {};
|
|
32
|
+
f(() => G());
|
|
33
|
+
let K = (e) => !("separator" in e), q = () => Array.from(L.value?.querySelectorAll("[role=\"menuitem\"]:not(:disabled)") ?? []);
|
|
34
|
+
function J() {
|
|
35
|
+
H?.style.getPropertyValue("anchor-name") === F && H.style.removeProperty("anchor-name"), H = null;
|
|
35
36
|
}
|
|
36
|
-
async function
|
|
37
|
-
|
|
37
|
+
async function Y(e, t) {
|
|
38
|
+
V.value && L.value?.hidePopover?.(), J(), W = t ?? document.activeElement, U = e, e instanceof HTMLElement ? (R.value = null, e.style.setProperty("anchor-name", F), H = e, B.value = F, z.value = A.placement === "point" ? "bottom-start" : A.placement) : (R.value = {
|
|
38
39
|
x: e.x,
|
|
39
40
|
y: e.y
|
|
40
|
-
},
|
|
41
|
+
}, B.value = I, z.value = "point"), await l(), L.value?.showPopover?.();
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
43
|
+
function X() {
|
|
44
|
+
L.value?.hidePopover?.();
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function Z(e) {
|
|
46
47
|
let n = e.newState === "open";
|
|
47
|
-
if (
|
|
48
|
-
if (!
|
|
49
|
-
let e = document.querySelector(`[popovertarget="${CSS.escape(
|
|
50
|
-
|
|
48
|
+
if (V.value = n, n) {
|
|
49
|
+
if (!U) {
|
|
50
|
+
let e = document.querySelector(`[popovertarget="${CSS.escape(P)}"]`);
|
|
51
|
+
W = e, U = e, B.value = A.anchorName ?? F, z.value = A.placement;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
} else (!document.activeElement || document.activeElement === document.body ||
|
|
53
|
+
U && L.value && (G = t(L.value, U, z.value)), l(() => q()[0]?.focus({ preventScroll: !0 })), M("open");
|
|
54
|
+
} else (!document.activeElement || document.activeElement === document.body || L.value?.contains(document.activeElement)) && W?.isConnected && W.focus({ preventScroll: !0 }), G(), J(), R.value = null, U = null, W = null, M("close");
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
let t =
|
|
56
|
+
function Q(e) {
|
|
57
|
+
let t = q(), n = t.indexOf(document.activeElement), r = (e) => t[(e + t.length) % t.length]?.focus({ preventScroll: !0 });
|
|
57
58
|
switch (e.key) {
|
|
58
59
|
case "ArrowDown":
|
|
59
60
|
r(n + 1);
|
|
@@ -68,7 +69,7 @@ var S = [
|
|
|
68
69
|
r(t.length - 1);
|
|
69
70
|
break;
|
|
70
71
|
case "Tab":
|
|
71
|
-
|
|
72
|
+
X();
|
|
72
73
|
return;
|
|
73
74
|
default: {
|
|
74
75
|
if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
@@ -78,56 +79,56 @@ var S = [
|
|
|
78
79
|
}
|
|
79
80
|
e.preventDefault(), e.stopPropagation();
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
82
|
+
function $(e) {
|
|
83
|
+
X(), M("select", e);
|
|
83
84
|
}
|
|
84
|
-
return
|
|
85
|
-
id:
|
|
86
|
-
openAt:
|
|
87
|
-
close:
|
|
88
|
-
isOpen:
|
|
89
|
-
}), (e, t) => (
|
|
85
|
+
return O({
|
|
86
|
+
id: P,
|
|
87
|
+
openAt: Y,
|
|
88
|
+
close: X,
|
|
89
|
+
isOpen: V
|
|
90
|
+
}), (e, t) => (p(), o(r, null, [R.value ? (p(), o("span", {
|
|
90
91
|
key: 0,
|
|
91
92
|
class: "vg-menu-point",
|
|
92
93
|
"aria-hidden": "true",
|
|
93
|
-
style:
|
|
94
|
-
left: `${
|
|
95
|
-
top: `${
|
|
96
|
-
"anchor-name":
|
|
94
|
+
style: d({
|
|
95
|
+
left: `${R.value.x}px`,
|
|
96
|
+
top: `${R.value.y}px`,
|
|
97
|
+
"anchor-name": I
|
|
97
98
|
})
|
|
98
|
-
}, null, 4)) :
|
|
99
|
-
id:
|
|
99
|
+
}, null, 4)) : a("", !0), s("div", {
|
|
100
|
+
id: b(P),
|
|
100
101
|
ref_key: "menu",
|
|
101
|
-
ref:
|
|
102
|
+
ref: L,
|
|
102
103
|
popover: "auto",
|
|
103
104
|
role: "menu",
|
|
104
|
-
"aria-label":
|
|
105
|
+
"aria-label": c.label || b(j).menu || "Menu",
|
|
105
106
|
class: "vg-menu",
|
|
106
|
-
"data-placement":
|
|
107
|
-
style:
|
|
108
|
-
onToggle:
|
|
109
|
-
onKeydown:
|
|
110
|
-
onClick: t[0] ||=
|
|
111
|
-
onContextmenu: t[1] ||=
|
|
112
|
-
}, [(
|
|
107
|
+
"data-placement": z.value,
|
|
108
|
+
style: d({ "position-anchor": B.value }),
|
|
109
|
+
onToggle: Z,
|
|
110
|
+
onKeydown: Q,
|
|
111
|
+
onClick: t[0] ||= S(() => {}, ["stop"]),
|
|
112
|
+
onContextmenu: t[1] ||= S(() => {}, ["prevent"])
|
|
113
|
+
}, [(p(!0), o(r, null, h(c.items, (e, t) => (p(), o(r, { key: K(e) ? e.name : `sep-${t}` }, [K(e) ? (p(), o("button", {
|
|
113
114
|
key: 1,
|
|
114
115
|
type: "button",
|
|
115
116
|
role: "menuitem",
|
|
116
117
|
tabindex: "-1",
|
|
117
118
|
disabled: e.disabled,
|
|
118
|
-
class:
|
|
119
|
-
onClick: (t) =>
|
|
119
|
+
class: u(["vg-menu-item", e.tone && `vg-tone-${e.tone}`]),
|
|
120
|
+
onClick: (t) => $(e)
|
|
120
121
|
}, [
|
|
121
|
-
e.icon ? (
|
|
122
|
+
e.icon ? (p(), i(g(y(e.icon)), {
|
|
122
123
|
key: 0,
|
|
123
124
|
class: "vg-menu-icon",
|
|
124
125
|
"aria-hidden": "true"
|
|
125
|
-
})) :
|
|
126
|
-
|
|
127
|
-
e.hint ? (
|
|
128
|
-
], 10,
|
|
126
|
+
})) : a("", !0),
|
|
127
|
+
s("span", E, v(e.label), 1),
|
|
128
|
+
e.hint ? (p(), o("span", D, v(e.hint), 1)) : a("", !0)
|
|
129
|
+
], 10, T)) : (p(), o("div", w))], 64))), 128))], 44, C)], 64));
|
|
129
130
|
}
|
|
130
131
|
});
|
|
131
|
-
export {
|
|
132
|
+
export { O as default };
|
|
132
133
|
|
|
133
134
|
//# sourceMappingURL=VGridMenu.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VGridMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_normalizeStyle","_createElementVNode","_unref","_withModifiers","_renderList","_normalizeClass","_createBlock","_resolveDynamicComponent","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","VGridMenu_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","uid","useId","menuId","ownAnchor","anchorNameFor","pointAnchor","menu","shallowRef","point","ref","placement","anchorName","isOpen","anchoredElement","fallbackTarget","returnFocus","stopTracking","isAction","item","enabledItems","releaseAnchor","openAt","focusAfterClose","target","nextTick","close","onToggle","open","event","invoker","trackAnchor","onKeydown","list","index","move","i","ch","b","choose","openBlock","createElementBlock","Fragment","normalizeStyle","createCommentVNode","createElementVNode","unref","_cache","withModifiers","renderList","normalizeClass","createBlock","resolveDynamicComponent","toRaw","toDisplayString"],"sources":["../../src/components/VGridMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { nextTick, onBeforeUnmount, ref, shallowRef, toRaw, useId } from 'vue'\nimport { anchorNameFor, trackAnchor, type AnchorTarget, type Placement } from '../internal/anchor'\nimport type { MenuAction, MenuItem } from '../types'\n\n/**\n * Accessible menu rendered with the Popover API (top layer: never clipped by the grid's overflow;\n * light-dismiss on outside click / Esc) and placed with CSS anchor positioning.\n *\n * Two ways to open it:\n * - declaratively: a trigger with `popovertarget=\"<id>\"` and `style=\"anchor-name: <anchorName>\"`\n * (pass the same `anchor-name` prop) — see the `actions-menu` renderer;\n * - imperatively: `openAt(element | { x, y })` — used for context menus.\n */\nconst props = withDefaults(\n defineProps<{\n items: readonly MenuItem[]\n label?: string\n placement?: Placement\n /** Popover id (for `popovertarget`). Generated when omitted. */\n id?: string\n /** `anchor-name` set on an external trigger (declarative mode). */\n anchorName?: string\n }>(),\n { label: 'Menu', placement: 'bottom-end' },\n)\n\nconst emit = defineEmits<{\n select: [item: MenuAction]\n open: []\n close: []\n}>()\n\nconst uid = useId()\nconst menuId = props.id ?? `vg-menu-${uid}`\nconst ownAnchor = anchorNameFor(uid)\nconst pointAnchor = `${ownAnchor}-pt`\n\nconst menu = shallowRef<HTMLElement>()\nconst point = ref<{ x: number; y: number } | null>(null)\nconst placement = ref<Placement>(props.placement)\nconst anchorName = ref(props.anchorName ?? ownAnchor)\nconst isOpen = ref(false)\nlet anchoredElement: HTMLElement | null = null\nlet fallbackTarget: AnchorTarget | null = null\nlet returnFocus: HTMLElement | null = null\nlet stopTracking = () => {}\nonBeforeUnmount(() => stopTracking())\n\nconst isAction = (item: MenuItem): item is MenuAction => !('separator' in item)\nconst enabledItems = () =>\n Array.from(\n menu.value?.querySelectorAll<HTMLButtonElement>('[role=\"menuitem\"]:not(:disabled)') ?? [],\n )\n\nfunction releaseAnchor() {\n if (anchoredElement?.style.getPropertyValue('anchor-name') === ownAnchor) {\n anchoredElement.style.removeProperty('anchor-name')\n }\n anchoredElement = null\n}\n\n/** Opens the menu anchored to an element (keyboard / cell) or a viewport point (pointer). */\nasync function openAt(target: AnchorTarget, focusAfterClose?: HTMLElement | null) {\n if (isOpen.value) menu.value?.hidePopover?.()\n releaseAnchor()\n returnFocus = focusAfterClose ?? (document.activeElement as HTMLElement | null)\n fallbackTarget = target\n if (target instanceof HTMLElement) {\n point.value = null\n target.style.setProperty('anchor-name', ownAnchor)\n anchoredElement = target\n anchorName.value = ownAnchor\n placement.value = props.placement === 'point' ? 'bottom-start' : props.placement\n } else {\n point.value = { x: target.x, y: target.y }\n anchorName.value = pointAnchor\n placement.value = 'point'\n }\n await nextTick() // render the point anchor / new anchor name before showing\n menu.value?.showPopover?.()\n}\n\nfunction close() {\n menu.value?.hidePopover?.()\n}\n\nfunction onToggle(event: Event) {\n const open = (event as ToggleEvent).newState === 'open'\n isOpen.value = open\n if (open) {\n if (!fallbackTarget) {\n // Declarative mode: opened by a `popovertarget` trigger.\n const invoker = document.querySelector<HTMLElement>(`[popovertarget=\"${CSS.escape(menuId)}\"]`)\n returnFocus = invoker\n fallbackTarget = invoker\n anchorName.value = props.anchorName ?? ownAnchor\n placement.value = props.placement\n }\n // Placed, followed and hidden by CSS; JS only where the browser can't (see trackAnchor).\n if (fallbackTarget && menu.value)\n stopTracking = trackAnchor(menu.value, fallbackTarget, placement.value)\n nextTick(() => enabledItems()[0]?.focus({ preventScroll: true }))\n emit('open')\n } else {\n const focusInside =\n !document.activeElement ||\n document.activeElement === document.body ||\n menu.value?.contains(document.activeElement)\n if (focusInside && returnFocus?.isConnected) returnFocus.focus({ preventScroll: true })\n stopTracking()\n releaseAnchor()\n point.value = null\n fallbackTarget = null\n returnFocus = null\n emit('close')\n }\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n const list = enabledItems()\n const index = list.indexOf(document.activeElement as HTMLButtonElement)\n const move = (i: number) => list[(i + list.length) % list.length]?.focus({ preventScroll: true })\n switch (event.key) {\n case 'ArrowDown':\n move(index + 1)\n break\n case 'ArrowUp':\n move(index - 1)\n break\n case 'Home':\n move(0)\n break\n case 'End':\n move(list.length - 1)\n break\n case 'Tab':\n close()\n return\n default: {\n // Typeahead: jump to the next item starting with the typed character.\n if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return\n const ch = event.key.toLowerCase()\n const order = [...list.slice(index + 1), ...list.slice(0, index + 1)]\n order\n .find((b) => b.textContent?.trim().toLowerCase().startsWith(ch))\n ?.focus({ preventScroll: true })\n }\n }\n event.preventDefault()\n event.stopPropagation()\n}\n\nfunction choose(item: MenuAction) {\n close()\n emit('select', item)\n}\n\ndefineExpose({ id: menuId, openAt, close, isOpen })\n</script>\n\n<template>\n <span\n v-if=\"point\"\n class=\"vg-menu-point\"\n aria-hidden=\"true\"\n :style=\"{ left: `${point.x}px`, top: `${point.y}px`, 'anchor-name': pointAnchor }\"\n />\n <div\n :id=\"menuId\"\n ref=\"menu\"\n popover=\"auto\"\n role=\"menu\"\n :aria-label=\"label\"\n class=\"vg-menu\"\n :data-placement=\"placement\"\n :style=\"{ 'position-anchor': anchorName }\"\n @toggle=\"onToggle\"\n @keydown=\"onKeydown\"\n @click.stop\n @contextmenu.prevent\n >\n <template v-for=\"(item, i) in items\" :key=\"isAction(item) ? item.name : `sep-${i}`\">\n <div v-if=\"!isAction(item)\" role=\"separator\" class=\"vg-menu-separator\" />\n <button\n v-else\n type=\"button\"\n role=\"menuitem\"\n tabindex=\"-1\"\n :disabled=\"item.disabled\"\n :class=\"['vg-menu-item', item.tone && `vg-tone-${item.tone}`]\"\n @click=\"choose(item)\"\n >\n <component\n :is=\"toRaw(item.icon)\"\n v-if=\"item.icon\"\n class=\"vg-menu-icon\"\n aria-hidden=\"true\"\n />\n <span class=\"vg-menu-label\">{{ item.label }}</span>\n <span v-if=\"item.hint\" class=\"vg-menu-hint\">{{ item.hint }}</span>\n </button>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcA,IAAMoB,IAAQC,GAaRC,IAAOH,GAMPI,IAAMC,EAAM,GACZC,IAASL,EAAM,MAAM,WAAWG,KAChCG,IAAYC,EAAcJ,CAAG,GAC7BK,IAAc,GAAGF,EAAU,MAE3BG,IAAOC,EAAwB,GAC/BC,IAAQC,EAAqC,IAAI,GACjDC,IAAYD,EAAeZ,EAAM,SAAS,GAC1Cc,IAAaF,EAAIZ,EAAM,cAAcM,CAAS,GAC9CS,IAASH,EAAI,EAAK,GACpBI,IAAsC,MACtCC,IAAsC,MACtCC,IAAkC,MAClCC,UAAqB,CAAC;EAC1B,QAAsBA,EAAa,CAAC;EAEpC,IAAMC,KAAY,MAAuC,EAAE,eAAeC,IACpEC,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["_openBlock","_createElementBlock","_Fragment","_normalizeStyle","_createElementVNode","_unref","_withModifiers","_renderList","_normalizeClass","_createBlock","_resolveDynamicComponent","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","VGridMenu_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","m","useMessages","emit","uid","useId","menuId","ownAnchor","anchorNameFor","pointAnchor","menu","shallowRef","point","ref","placement","anchorName","isOpen","anchoredElement","fallbackTarget","returnFocus","stopTracking","isAction","item","enabledItems","releaseAnchor","openAt","focusAfterClose","target","nextTick","close","onToggle","open","event","invoker","trackAnchor","onKeydown","list","index","move","i","ch","b","choose","openBlock","createElementBlock","Fragment","normalizeStyle","createCommentVNode","createElementVNode","unref","_cache","withModifiers","renderList","normalizeClass","createBlock","resolveDynamicComponent","toRaw","toDisplayString"],"sources":["../../src/components/VGridMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { nextTick, onBeforeUnmount, ref, shallowRef, toRaw, useId } from 'vue'\nimport { anchorNameFor, trackAnchor, type AnchorTarget, type Placement } from '../internal/anchor'\nimport type { MenuAction, MenuItem } from '../types'\nimport { useMessages } from '../internal/messages'\n\n/**\n * Accessible menu rendered with the Popover API (top layer: never clipped by the grid's overflow;\n * light-dismiss on outside click / Esc) and placed with CSS anchor positioning.\n *\n * Two ways to open it:\n * - declaratively: a trigger with `popovertarget=\"<id>\"` and `style=\"anchor-name: <anchorName>\"`\n * (pass the same `anchor-name` prop) — see the `actions-menu` renderer;\n * - imperatively: `openAt(element | { x, y })` — used for context menus.\n */\nconst props = withDefaults(\n defineProps<{\n items: readonly MenuItem[]\n /** The menu's name for screen readers. Default: `messages.menu`, else `Menu`. */\n label?: string\n placement?: Placement\n /** Popover id (for `popovertarget`). Generated when omitted. */\n id?: string\n /** `anchor-name` set on an external trigger (declarative mode). */\n anchorName?: string\n }>(),\n { placement: 'bottom-end' },\n)\nconst m = useMessages()\n\nconst emit = defineEmits<{\n select: [item: MenuAction]\n open: []\n close: []\n}>()\n\nconst uid = useId()\nconst menuId = props.id ?? `vg-menu-${uid}`\nconst ownAnchor = anchorNameFor(uid)\nconst pointAnchor = `${ownAnchor}-pt`\n\nconst menu = shallowRef<HTMLElement>()\nconst point = ref<{ x: number; y: number } | null>(null)\nconst placement = ref<Placement>(props.placement)\nconst anchorName = ref(props.anchorName ?? ownAnchor)\nconst isOpen = ref(false)\nlet anchoredElement: HTMLElement | null = null\nlet fallbackTarget: AnchorTarget | null = null\nlet returnFocus: HTMLElement | null = null\nlet stopTracking = () => {}\nonBeforeUnmount(() => stopTracking())\n\nconst isAction = (item: MenuItem): item is MenuAction => !('separator' in item)\nconst enabledItems = () =>\n Array.from(\n menu.value?.querySelectorAll<HTMLButtonElement>('[role=\"menuitem\"]:not(:disabled)') ?? [],\n )\n\nfunction releaseAnchor() {\n if (anchoredElement?.style.getPropertyValue('anchor-name') === ownAnchor) {\n anchoredElement.style.removeProperty('anchor-name')\n }\n anchoredElement = null\n}\n\n/** Opens the menu anchored to an element (keyboard / cell) or a viewport point (pointer). */\nasync function openAt(target: AnchorTarget, focusAfterClose?: HTMLElement | null) {\n if (isOpen.value) menu.value?.hidePopover?.()\n releaseAnchor()\n returnFocus = focusAfterClose ?? (document.activeElement as HTMLElement | null)\n fallbackTarget = target\n if (target instanceof HTMLElement) {\n point.value = null\n target.style.setProperty('anchor-name', ownAnchor)\n anchoredElement = target\n anchorName.value = ownAnchor\n placement.value = props.placement === 'point' ? 'bottom-start' : props.placement\n } else {\n point.value = { x: target.x, y: target.y }\n anchorName.value = pointAnchor\n placement.value = 'point'\n }\n await nextTick() // render the point anchor / new anchor name before showing\n menu.value?.showPopover?.()\n}\n\nfunction close() {\n menu.value?.hidePopover?.()\n}\n\nfunction onToggle(event: Event) {\n const open = (event as ToggleEvent).newState === 'open'\n isOpen.value = open\n if (open) {\n if (!fallbackTarget) {\n // Declarative mode: opened by a `popovertarget` trigger.\n const invoker = document.querySelector<HTMLElement>(`[popovertarget=\"${CSS.escape(menuId)}\"]`)\n returnFocus = invoker\n fallbackTarget = invoker\n anchorName.value = props.anchorName ?? ownAnchor\n placement.value = props.placement\n }\n // Placed, followed and hidden by CSS; JS only where the browser can't (see trackAnchor).\n if (fallbackTarget && menu.value)\n stopTracking = trackAnchor(menu.value, fallbackTarget, placement.value)\n nextTick(() => enabledItems()[0]?.focus({ preventScroll: true }))\n emit('open')\n } else {\n const focusInside =\n !document.activeElement ||\n document.activeElement === document.body ||\n menu.value?.contains(document.activeElement)\n if (focusInside && returnFocus?.isConnected) returnFocus.focus({ preventScroll: true })\n stopTracking()\n releaseAnchor()\n point.value = null\n fallbackTarget = null\n returnFocus = null\n emit('close')\n }\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n const list = enabledItems()\n const index = list.indexOf(document.activeElement as HTMLButtonElement)\n const move = (i: number) => list[(i + list.length) % list.length]?.focus({ preventScroll: true })\n switch (event.key) {\n case 'ArrowDown':\n move(index + 1)\n break\n case 'ArrowUp':\n move(index - 1)\n break\n case 'Home':\n move(0)\n break\n case 'End':\n move(list.length - 1)\n break\n case 'Tab':\n close()\n return\n default: {\n // Typeahead: jump to the next item starting with the typed character.\n if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return\n const ch = event.key.toLowerCase()\n const order = [...list.slice(index + 1), ...list.slice(0, index + 1)]\n order\n .find((b) => b.textContent?.trim().toLowerCase().startsWith(ch))\n ?.focus({ preventScroll: true })\n }\n }\n event.preventDefault()\n event.stopPropagation()\n}\n\nfunction choose(item: MenuAction) {\n close()\n emit('select', item)\n}\n\ndefineExpose({ id: menuId, openAt, close, isOpen })\n</script>\n\n<template>\n <span\n v-if=\"point\"\n class=\"vg-menu-point\"\n aria-hidden=\"true\"\n :style=\"{ left: `${point.x}px`, top: `${point.y}px`, 'anchor-name': pointAnchor }\"\n />\n <div\n :id=\"menuId\"\n ref=\"menu\"\n popover=\"auto\"\n role=\"menu\"\n :aria-label=\"label || m.menu || 'Menu'\"\n class=\"vg-menu\"\n :data-placement=\"placement\"\n :style=\"{ 'position-anchor': anchorName }\"\n @toggle=\"onToggle\"\n @keydown=\"onKeydown\"\n @click.stop\n @contextmenu.prevent\n >\n <template v-for=\"(item, i) in items\" :key=\"isAction(item) ? item.name : `sep-${i}`\">\n <div v-if=\"!isAction(item)\" role=\"separator\" class=\"vg-menu-separator\" />\n <button\n v-else\n type=\"button\"\n role=\"menuitem\"\n tabindex=\"-1\"\n :disabled=\"item.disabled\"\n :class=\"['vg-menu-item', item.tone && `vg-tone-${item.tone}`]\"\n @click=\"choose(item)\"\n >\n <component\n :is=\"toRaw(item.icon)\"\n v-if=\"item.icon\"\n class=\"vg-menu-icon\"\n aria-hidden=\"true\"\n />\n <span class=\"vg-menu-label\">{{ item.label }}</span>\n <span v-if=\"item.hint\" class=\"vg-menu-hint\">{{ item.hint }}</span>\n </button>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,IAAMoB,IAAQC,GAaRC,IAAIC,EAAY,GAEhBC,IAAOL,GAMPM,IAAMC,EAAM,GACZC,IAASP,EAAM,MAAM,WAAWK,KAChCG,IAAYC,EAAcJ,CAAG,GAC7BK,IAAc,GAAGF,EAAU,MAE3BG,IAAOC,EAAwB,GAC/BC,IAAQC,EAAqC,IAAI,GACjDC,IAAYD,EAAed,EAAM,SAAS,GAC1CgB,IAAaF,EAAId,EAAM,cAAcQ,CAAS,GAC9CS,IAASH,EAAI,EAAK,GACpBI,IAAsC,MACtCC,IAAsC,MACtCC,IAAkC,MAClCC,UAAqB,CAAC;EAC1B,QAAsBA,EAAa,CAAC;EAEpC,IAAMC,KAAY,MAAuC,EAAE,eAAeC,IACpEC,UACJ,MAAM,KACJb,EAAK,OAAO,iBAAoC,oCAAkC,KAAK,CAAC,CAC1F;EAEF,SAASc,IAAgB;GAIvB,AAHIP,GAAiB,MAAM,iBAAiB,aAAa,MAAMV,KAC7DU,EAAgB,MAAM,eAAe,aA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,EAAAsB,CAAA;GACD,SAAA;GAAJ,KAAII;GACJ,SAAQ;GACR,MAAK;GACJ,cAAYV,EAAA,SAAShB,EAAAiB,CAAA,CAAC,CAAC,QAAI;GAC5B,OAAM;GACL,kBAAgBa,EAAA;GAChB,OAAKhC,EAAA,EAAA,mBAAuBiC,EAAA,MAAU,CAAA;GAC9B;GACC;GACT,SAAK,AAAAmC,EAAA,OAAAjE,QAAN,CAAA,GAAW,CAAA,MAAA,CAAA;GACV,eAAW,AAAAiE,EAAA,OAAAjE,QAAZ,CAAA,GAAoB,CAAA,SAAA,CAAA;E,KAEpBN,EAAA,EAAA,GAAAC,EAoBWC,GAAA,MAAAK,EApBmBc,EAAA,QAAZ,GAAM,O,YAAmB,KAAAqB,EAASC,CAAI,IAAIA,EAAK,OAAI,OAAUiB,I,IACjElB,EAASC,CAAI,KACzB3C,EAAA,GAAAC,EAiBS,UAAA;;GAfP,MAAK;GACL,MAAK;GACL,UAAS;GACR,UAAU0C,EAAK;GACf,OAAKnC,EAAA,CAAA,gBAAmBmC,EAAK,QAAI,WAAeA,EAAK,MAAI,CAAA;GACzD,UAAK,MAAEoB,EAAOpB,CAAI;;GAIXA,EAAK,QAFb3C,EAAA,GAAAS,EAKEC,EAJKmE,EAAMlC,EAAK,IAAI,CAAA,GAAA;;IAEpB,OAAM;IACN,eAAY;;GAEdvC,EAAmD,QAAnDW,GAAmDJ,EAApBgC,EAAK,KAAK,GAAA,CAAA;GAC7BA,EAAK,QAAjB3C,EAAA,GAAAC,EAAkE,QAAlEe,GAAkEL,EAAnBgC,EAAK,IAAI,GAAA,CAAA,K;E,cAjB1D3C,EAAA,GAAAC,EAAyE,OAAzEY,CAAyE,E"}
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
import { pageItems as e } from "../core/pagination.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useMessages as t } from "../internal/messages.js";
|
|
3
|
+
import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, mergeModels as c, openBlock as l, renderList as u, toDisplayString as d, unref as f, useModel as p } from "vue";
|
|
3
4
|
// src/components/VGridPagination.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var
|
|
5
|
+
var m = ["aria-label"], h = {
|
|
5
6
|
key: 0,
|
|
6
7
|
class: "vg-pagination-summary"
|
|
7
|
-
},
|
|
8
|
+
}, g = {
|
|
8
9
|
key: 1,
|
|
9
10
|
class: "vg-pagination-size"
|
|
10
|
-
},
|
|
11
|
+
}, _ = { class: "vg-sr-only" }, v = ["value"], y = ["value"], b = { class: "vg-pagination-pages" }, x = ["disabled", "aria-label"], S = ["disabled", "aria-label"], C = {
|
|
11
12
|
key: 0,
|
|
12
13
|
class: "vg-page-ellipsis",
|
|
13
14
|
"aria-hidden": "true"
|
|
14
|
-
},
|
|
15
|
+
}, w = [
|
|
15
16
|
"aria-current",
|
|
16
17
|
"aria-label",
|
|
17
18
|
"onClick"
|
|
18
|
-
],
|
|
19
|
+
], T = ["disabled", "aria-label"], E = ["disabled", "aria-label"], D = /*@__PURE__*/ s({
|
|
19
20
|
__name: "VGridPagination",
|
|
20
|
-
props: /*@__PURE__*/
|
|
21
|
+
props: /*@__PURE__*/ c({
|
|
21
22
|
total: {},
|
|
22
23
|
pageSizes: {},
|
|
23
24
|
siblings: { default: 1 },
|
|
24
|
-
ariaLabel: {
|
|
25
|
-
summary: {
|
|
25
|
+
ariaLabel: {},
|
|
26
|
+
summary: {},
|
|
27
|
+
firstLast: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: !0
|
|
30
|
+
}
|
|
26
31
|
}, {
|
|
27
32
|
page: { default: 1 },
|
|
28
33
|
pageModifiers: {},
|
|
@@ -30,73 +35,75 @@ var f = ["aria-label"], p = {
|
|
|
30
35
|
pageSizeModifiers: {}
|
|
31
36
|
}),
|
|
32
37
|
emits: ["update:page", "update:pageSize"],
|
|
33
|
-
setup(
|
|
34
|
-
let s =
|
|
35
|
-
if (
|
|
36
|
-
let e = (
|
|
37
|
-
return
|
|
38
|
+
setup(s) {
|
|
39
|
+
let c = s, D = t(), O = p(s, "page"), k = p(s, "pageSize"), A = r(() => Math.max(1, Math.ceil(c.total / Math.max(1, k.value)))), j = r(() => Math.min(Math.max(1, O.value), A.value)), M = r(() => e(j.value, A.value, c.siblings)), N = r(() => {
|
|
40
|
+
if (c.summary === "" || c.total <= 0) return "";
|
|
41
|
+
let e = (j.value - 1) * k.value + 1, t = Math.min(c.total, j.value * k.value);
|
|
42
|
+
return c.summary === void 0 && D.value.pageSummary ? D.value.pageSummary(String(e), String(t), String(c.total)) : (c.summary ?? "{from}–{to} of {total}").replace("{from}", String(e)).replace("{to}", String(t)).replace("{total}", String(c.total));
|
|
38
43
|
});
|
|
39
|
-
function
|
|
40
|
-
let t = Math.min(Math.max(1, e),
|
|
41
|
-
t !==
|
|
44
|
+
function P(e) {
|
|
45
|
+
let t = Math.min(Math.max(1, e), A.value);
|
|
46
|
+
t !== O.value && (O.value = t);
|
|
42
47
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
48
|
+
function F(e) {
|
|
49
|
+
k.value = Number(e.target.value), O.value = 1;
|
|
45
50
|
}
|
|
46
|
-
return (e,
|
|
51
|
+
return (e, t) => (l(), a("nav", {
|
|
47
52
|
class: "vg-pagination",
|
|
48
|
-
"aria-label":
|
|
53
|
+
"aria-label": s.ariaLabel ?? f(D).pagination ?? "Pagination"
|
|
49
54
|
}, [
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
N.value ? (l(), a("span", h, d(N.value), 1)) : i("", !0),
|
|
56
|
+
s.pageSizes?.length ? (l(), a("label", g, [o("span", _, d(f(D).rowsPerPage ?? "Rows per page"), 1), o("select", {
|
|
52
57
|
class: "vg-select",
|
|
53
|
-
value:
|
|
54
|
-
onChange:
|
|
55
|
-
}, [(
|
|
58
|
+
value: k.value,
|
|
59
|
+
onChange: F
|
|
60
|
+
}, [(l(!0), a(n, null, u(s.pageSizes, (e) => (l(), a("option", {
|
|
56
61
|
key: e,
|
|
57
62
|
value: e
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
a("button", {
|
|
63
|
+
}, d(f(D).pageSize?.(e) ?? `${e} / page`), 9, y))), 128))], 40, v)])) : i("", !0),
|
|
64
|
+
o("div", b, [
|
|
65
|
+
s.firstLast ? (l(), a("button", {
|
|
66
|
+
key: 0,
|
|
61
67
|
type: "button",
|
|
62
68
|
class: "vg-page vg-page-nav vg-page-first",
|
|
63
|
-
disabled:
|
|
64
|
-
"aria-label": "First page",
|
|
65
|
-
onClick:
|
|
66
|
-
}, " « ", 8,
|
|
67
|
-
|
|
69
|
+
disabled: j.value <= 1,
|
|
70
|
+
"aria-label": f(D).firstPage ?? "First page",
|
|
71
|
+
onClick: t[0] ||= (e) => P(1)
|
|
72
|
+
}, " « ", 8, x)) : i("", !0),
|
|
73
|
+
o("button", {
|
|
68
74
|
type: "button",
|
|
69
75
|
class: "vg-page vg-page-nav",
|
|
70
|
-
disabled:
|
|
71
|
-
"aria-label": "Previous page",
|
|
72
|
-
onClick:
|
|
73
|
-
}, " ‹ ", 8,
|
|
74
|
-
(
|
|
76
|
+
disabled: j.value <= 1,
|
|
77
|
+
"aria-label": f(D).previousPage ?? "Previous page",
|
|
78
|
+
onClick: t[1] ||= (e) => P(j.value - 1)
|
|
79
|
+
}, " ‹ ", 8, S),
|
|
80
|
+
(l(!0), a(n, null, u(M.value, (e, t) => (l(), a(n, { key: e === "ellipsis" ? `e${t}` : e }, [e === "ellipsis" ? (l(), a("span", C, "…")) : (l(), a("button", {
|
|
75
81
|
key: 1,
|
|
76
82
|
type: "button",
|
|
77
83
|
class: "vg-page",
|
|
78
|
-
"aria-current": e ===
|
|
79
|
-
"aria-label": `Page ${e}`,
|
|
80
|
-
onClick: (t) =>
|
|
81
|
-
},
|
|
82
|
-
|
|
84
|
+
"aria-current": e === j.value ? "page" : void 0,
|
|
85
|
+
"aria-label": f(D).page?.(Number(e)) ?? `Page ${e}`,
|
|
86
|
+
onClick: (t) => P(e)
|
|
87
|
+
}, d(e), 9, w))], 64))), 128)),
|
|
88
|
+
o("button", {
|
|
83
89
|
type: "button",
|
|
84
90
|
class: "vg-page vg-page-nav",
|
|
85
|
-
disabled:
|
|
86
|
-
"aria-label": "Next page",
|
|
87
|
-
onClick:
|
|
88
|
-
}, " › ", 8,
|
|
89
|
-
a("button", {
|
|
91
|
+
disabled: j.value >= A.value,
|
|
92
|
+
"aria-label": f(D).nextPage ?? "Next page",
|
|
93
|
+
onClick: t[2] ||= (e) => P(j.value + 1)
|
|
94
|
+
}, " › ", 8, T),
|
|
95
|
+
s.firstLast ? (l(), a("button", {
|
|
96
|
+
key: 1,
|
|
90
97
|
type: "button",
|
|
91
98
|
class: "vg-page vg-page-nav vg-page-last",
|
|
92
|
-
disabled:
|
|
93
|
-
"aria-label": "Last page",
|
|
94
|
-
onClick:
|
|
95
|
-
}, " » ", 8,
|
|
99
|
+
disabled: j.value >= A.value,
|
|
100
|
+
"aria-label": f(D).lastPage ?? "Last page",
|
|
101
|
+
onClick: t[3] ||= (e) => P(A.value)
|
|
102
|
+
}, " » ", 8, E)) : i("", !0)
|
|
96
103
|
])
|
|
97
|
-
], 8,
|
|
104
|
+
], 8, m));
|
|
98
105
|
}
|
|
99
106
|
});
|
|
100
|
-
export {
|
|
107
|
+
export { D as default };
|
|
101
108
|
|
|
102
109
|
//# sourceMappingURL=VGridPagination.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VGridPagination.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_toDisplayString","_createElementVNode","_Fragment","_renderList","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","VGridPagination_vue_vue_type_script_setup_true_lang_default","\"page\"","\"pageModifiers\"","\"pageSize\"","\"pageSizeModifiers\"","props","__props","page","useModel","pageSize","pageCount","computed","current","items","pageItems","summaryText","from","to","go","next","target","onSizeChange","event","openBlock","createElementBlock","
|
|
1
|
+
{"version":3,"file":"VGridPagination.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_unref","_toDisplayString","_createElementVNode","_Fragment","_renderList","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","VGridPagination_vue_vue_type_script_setup_true_lang_default","\"page\"","\"pageModifiers\"","\"pageSize\"","\"pageSizeModifiers\"","props","__props","m","useMessages","page","useModel","pageSize","pageCount","computed","current","items","pageItems","summaryText","from","to","go","next","target","onSizeChange","event","openBlock","createElementBlock","unref","toDisplayString","createCommentVNode","createElementVNode","Fragment","renderList","size","_cache","item","i"],"sources":["../../src/components/VGridPagination.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { pageItems } from '../core/pagination'\nimport { useMessages } from '../internal/messages'\n\nconst props = withDefaults(\n defineProps<{\n total: number\n /** Page-size choices; renders a selector when given. */\n pageSizes?: number[]\n siblings?: number\n /** Default: `messages.pagination`, else `Pagination`. */\n ariaLabel?: string\n /**\n * Use `{from}`, `{to}` and `{total}` placeholders; an empty string hides the summary. Default:\n * `messages.pageSummary`, else `{from}–{to} of {total}`.\n */\n summary?: string\n /** The first and last page buttons (« »). Default `true`. */\n firstLast?: boolean\n }>(),\n { siblings: 1, firstLast: true },\n)\nconst m = useMessages()\n\nconst page = defineModel<number>('page', { default: 1 })\nconst pageSize = defineModel<number>('pageSize', { default: 25 })\n\nconst pageCount = computed(() => Math.max(1, Math.ceil(props.total / Math.max(1, pageSize.value))))\nconst current = computed(() => Math.min(Math.max(1, page.value), pageCount.value))\nconst items = computed(() => pageItems(current.value, pageCount.value, props.siblings))\nconst summaryText = computed(() => {\n if (props.summary === '' || props.total <= 0) return ''\n const from = (current.value - 1) * pageSize.value + 1\n const to = Math.min(props.total, current.value * pageSize.value)\n if (props.summary === undefined && m.value.pageSummary)\n return m.value.pageSummary(String(from), String(to), String(props.total))\n return (props.summary ?? '{from}–{to} of {total}')\n .replace('{from}', String(from))\n .replace('{to}', String(to))\n .replace('{total}', String(props.total))\n})\n\nfunction go(target: number) {\n const next = Math.min(Math.max(1, target), pageCount.value)\n if (next !== page.value) page.value = next\n}\n\nfunction onSizeChange(event: Event) {\n pageSize.value = Number((event.target as HTMLSelectElement).value)\n page.value = 1\n}\n</script>\n\n<template>\n <nav class=\"vg-pagination\" :aria-label=\"ariaLabel ?? m.pagination ?? 'Pagination'\">\n <span v-if=\"summaryText\" class=\"vg-pagination-summary\">{{ summaryText }}</span>\n <label v-if=\"pageSizes?.length\" class=\"vg-pagination-size\">\n <span class=\"vg-sr-only\">{{ m.rowsPerPage ?? 'Rows per page' }}</span>\n <select class=\"vg-select\" :value=\"pageSize\" @change=\"onSizeChange\">\n <option v-for=\"size in pageSizes\" :key=\"size\" :value=\"size\">\n {{ m.pageSize?.(size) ?? `${size} / page` }}\n </option>\n </select>\n </label>\n <div class=\"vg-pagination-pages\">\n <button\n v-if=\"firstLast\"\n type=\"button\"\n class=\"vg-page vg-page-nav vg-page-first\"\n :disabled=\"current <= 1\"\n :aria-label=\"m.firstPage ?? 'First page'\"\n @click=\"go(1)\"\n >\n «\n </button>\n <button\n type=\"button\"\n class=\"vg-page vg-page-nav\"\n :disabled=\"current <= 1\"\n :aria-label=\"m.previousPage ?? 'Previous page'\"\n @click=\"go(current - 1)\"\n >\n ‹\n </button>\n <template v-for=\"(item, i) in items\" :key=\"item === 'ellipsis' ? `e${i}` : item\">\n <span v-if=\"item === 'ellipsis'\" class=\"vg-page-ellipsis\" aria-hidden=\"true\">…</span>\n <button\n v-else\n type=\"button\"\n class=\"vg-page\"\n :aria-current=\"item === current ? 'page' : undefined\"\n :aria-label=\"m.page?.(Number(item)) ?? `Page ${item}`\"\n @click=\"go(item)\"\n >\n {{ item }}\n </button>\n </template>\n <button\n type=\"button\"\n class=\"vg-page vg-page-nav\"\n :disabled=\"current >= pageCount\"\n :aria-label=\"m.nextPage ?? 'Next page'\"\n @click=\"go(current + 1)\"\n >\n ›\n </button>\n <button\n v-if=\"firstLast\"\n type=\"button\"\n class=\"vg-page vg-page-nav vg-page-last\"\n :disabled=\"current >= pageCount\"\n :aria-label=\"m.lastPage ?? 'Last page'\"\n @click=\"go(pageCount)\"\n >\n »\n </button>\n </div>\n </nav>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKA,IAAM0B,IAAQC,GAkBRC,IAAIC,EAAY,GAEhBC,IAAO9B,EAAmB2B,GAAC,MAAsB,GACjDK,IAAWhC,EAAmB2B,GAAC,UAA2B,GAE1DM,IAAYC,QAAe,KAAK,IAAI,GAAG,KAAK,KAAKR,EAAM,QAAQ,KAAK,IAAI,GAAGM,EAAS,KAAK,CAAC,CAAC,CAAC,GAC5FG,IAAUD,QAAe,KAAK,IAAI,KAAK,IAAI,GAAGJ,EAAK,KAAK,GAAGG,EAAU,KAAK,CAAC,GAC3EG,IAAQF,QAAeG,EAAUF,EAAQ,OAAOF,EAAU,OAAOP,EAAM,QAAQ,CAAC,GAChFY,IAAcJ,QAAe;GACjC,IAAIR,EAAM,YAAY,MAAMA,EAAM,SAAS,GAAG,OAAO;GACrD,IAAMa,KAAQJ,EAAQ,QAAQ,KAAKH,EAAS,QAAQ,GAC9CQ,IAAK,KAAK,IAAId,EAAM,OAAOS,EAAQ,QAAQH,EAAS,KAAK;GAG/D,OAFIN,EAAM,YAAY,KAAA,KAAaE,EAAE,MAAM,cAClCA,EAAE,MAAM,YAAY,OAAOW,CAAI,GAAG,OAAOC,CAAE,GAAG,OAAOd,EAAM,KAAK,CAAC,KAClEA,EAAM,WAAW,yBAAA,CACtB,QAAQ,UAAU,OAAOa,CAAI,CAAC,CAAA,CAC9B,QAAQ,QAAQ,OAAOC,C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separator",
|
|
35
35
|
"aria-orientation": "vertical",
|
|
36
|
-
"aria-label": `Resize ${n.label}`,
|
|
36
|
+
"aria-label": o(d).messages.value.resizeColumn?.(n.label) ?? `Resize ${n.label}`,
|
|
37
37
|
"aria-valuenow": h.value,
|
|
38
38
|
"aria-valuemin": "0",
|
|
39
39
|
"aria-valuemax": Math.max(h.value, 1e4),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VGridResizeHandle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_unref","_withModifiers","_hoisted_1","VGridResizeHandle_vue_vue_type_script_setup_true_lang_default","props","__props","grid","useInternalGrid","resize","onKeyDown","rtl","event","step","handle","shallowRef","width","observer","watch","cell","el","onBeforeUnmount","openBlock","createElementBlock","unref","_cache","$event","withModifiers"],"sources":["../../src/components/VGridResizeHandle.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onBeforeUnmount, shallowRef, watch } from 'vue'\nimport { useInternalGrid } from '../internal/context'\n\n/** The grip on a header's end edge (column resizing feature): drag, double-click, or ←/→ when focused. */\nconst props = defineProps<{ columnKey: string; label: string }>()\nconst grid = useInternalGrid()\n// Rendered by the resizing feature only, so the grid always has it here.\nconst resize = grid.resize!\n\n/** ←/→ (Shift: bigger steps); Enter fits the content. */\nfunction onKeyDown(event: KeyboardEvent) {\n const rtl = getComputedStyle(event.currentTarget as Element).direction === 'rtl'\n const step = event.shiftKey ? 64 : 16\n if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {\n resize.step(props.columnKey, ((event.key === 'ArrowRight') !== rtl ? 1 : -1) * step)\n } else if (event.key === 'Enter') {\n resize.autosize(props.columnKey)\n } else return\n event.preventDefault()\n event.stopPropagation()\n}\n\n// A focusable separator is a range: screen readers announce the column's width as its value.\nconst handle = shallowRef<HTMLElement>()\nconst width = shallowRef(0)\nlet observer: ResizeObserver | undefined\nwatch(\n handle,\n (el) => {\n observer?.disconnect()\n const cell = el?.parentElement\n if (!cell) return\n width.value = Math.round(cell.getBoundingClientRect().width)\n if (typeof ResizeObserver === 'undefined') return\n observer = new ResizeObserver(\n () => (width.value = Math.round(cell.getBoundingClientRect().width)),\n )\n observer.observe(cell)\n },\n { flush: 'post' },\n)\nonBeforeUnmount(() => observer?.disconnect())\n</script>\n\n<template>\n <span\n ref=\"handle\"\n class=\"vg-resize-handle\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n :aria-label=\"`Resize ${label}`\"\n :aria-valuenow=\"width\"\n aria-valuemin=\"0\"\n :aria-valuemax=\"Math.max(width, 10000)\"\n :aria-valuetext=\"`${width} pixels wide`\"\n :tabindex=\"grid.keyboardNav ? -1 : 0\"\n @pointerdown=\"resize.start($event, columnKey)\"\n @click.stop\n @dblclick.stop=\"resize.autosize(columnKey)\"\n @keydown=\"onKeyDown\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAKA,IAAMM,IAAQC,GACRC,IAAOC,EAAgB,GAEvBC,IAASF,EAAK;EAGpB,SAASG,EAAU,GAAsB;GACvC,IAAMC,IAAM,iBAAiBC,EAAM,aAAwB,CAAC,CAAC,cAAc,OACrEC,IAAOD,EAAM,WAAW,KAAK;GACnC,IAAIA,EAAM,QAAQ,gBAAgBA,EAAM,QAAQ,aAC9C,EAAO,KAAKP,EAAM,YAAaO,EAAM,QAAQ,iBAAkBD,IAAU,KAAJ,KAAUE,CAAI;QAC9E,IAAID,EAAM,QAAQ,SACvB,EAAO,SAASP,EAAM,SAAS;QAC1B;GAEP,AADAO,EAAM,eAAe,GACrBA,EAAM,gBAAgB;EACxB;EAGA,IAAME,IAASC,EAAwB,GACjCC,IAAQD,EAAW,CAAC,GACtBE;E,OACJC,EACEJ,IACC,MAAO;GACN,GAAU,WAAW;GACrB,IAAMK,IAAOC,GAAI;GACjB,AAAKD,MACL,EAAM,QAAQ,KAAK,MAAMA,EAAK,sBAAsB,CAAC,CAAC,KAAK,GACvD,OAAO,iBAAmB,QAC9B,IAAW,IAAI,qBACN,EAAM,QAAQ,KAAK,MAAMA,EAAK,sBAAsB,CAAC,CAAC,KAAK,CACpE,GACAF,EAAS,QAAQE,CAAI;EACvB,GACA,EAAE,OAAO,OAAO,CAClB,GACAE,QAAsBJ,GAAU,WAAW,CAAC,I,UAI1ClB,EAAA,GAAAC,EAeE,QAAA;GAdI,SAAA;GAAJ,KAAIc;GACJ,OAAM;GACN,MAAK;GACL,oBAAiB;GAChB,
|
|
1
|
+
{"version":3,"file":"VGridResizeHandle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_unref","_withModifiers","_hoisted_1","VGridResizeHandle_vue_vue_type_script_setup_true_lang_default","props","__props","grid","useInternalGrid","resize","onKeyDown","rtl","event","step","handle","shallowRef","width","observer","watch","cell","el","onBeforeUnmount","openBlock","createElementBlock","unref","_cache","$event","withModifiers"],"sources":["../../src/components/VGridResizeHandle.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onBeforeUnmount, shallowRef, watch } from 'vue'\nimport { useInternalGrid } from '../internal/context'\n\n/** The grip on a header's end edge (column resizing feature): drag, double-click, or ←/→ when focused. */\nconst props = defineProps<{ columnKey: string; label: string }>()\nconst grid = useInternalGrid()\n// Rendered by the resizing feature only, so the grid always has it here.\nconst resize = grid.resize!\n\n/** ←/→ (Shift: bigger steps); Enter fits the content. */\nfunction onKeyDown(event: KeyboardEvent) {\n const rtl = getComputedStyle(event.currentTarget as Element).direction === 'rtl'\n const step = event.shiftKey ? 64 : 16\n if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {\n resize.step(props.columnKey, ((event.key === 'ArrowRight') !== rtl ? 1 : -1) * step)\n } else if (event.key === 'Enter') {\n resize.autosize(props.columnKey)\n } else return\n event.preventDefault()\n event.stopPropagation()\n}\n\n// A focusable separator is a range: screen readers announce the column's width as its value.\nconst handle = shallowRef<HTMLElement>()\nconst width = shallowRef(0)\nlet observer: ResizeObserver | undefined\nwatch(\n handle,\n (el) => {\n observer?.disconnect()\n const cell = el?.parentElement\n if (!cell) return\n width.value = Math.round(cell.getBoundingClientRect().width)\n if (typeof ResizeObserver === 'undefined') return\n observer = new ResizeObserver(\n () => (width.value = Math.round(cell.getBoundingClientRect().width)),\n )\n observer.observe(cell)\n },\n { flush: 'post' },\n)\nonBeforeUnmount(() => observer?.disconnect())\n</script>\n\n<template>\n <span\n ref=\"handle\"\n class=\"vg-resize-handle\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n :aria-label=\"grid.messages.value.resizeColumn?.(label) ?? `Resize ${label}`\"\n :aria-valuenow=\"width\"\n aria-valuemin=\"0\"\n :aria-valuemax=\"Math.max(width, 10000)\"\n :aria-valuetext=\"`${width} pixels wide`\"\n :tabindex=\"grid.keyboardNav ? -1 : 0\"\n @pointerdown=\"resize.start($event, columnKey)\"\n @click.stop\n @dblclick.stop=\"resize.autosize(columnKey)\"\n @keydown=\"onKeyDown\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAKA,IAAMM,IAAQC,GACRC,IAAOC,EAAgB,GAEvBC,IAASF,EAAK;EAGpB,SAASG,EAAU,GAAsB;GACvC,IAAMC,IAAM,iBAAiBC,EAAM,aAAwB,CAAC,CAAC,cAAc,OACrEC,IAAOD,EAAM,WAAW,KAAK;GACnC,IAAIA,EAAM,QAAQ,gBAAgBA,EAAM,QAAQ,aAC9C,EAAO,KAAKP,EAAM,YAAaO,EAAM,QAAQ,iBAAkBD,IAAU,KAAJ,KAAUE,CAAI;QAC9E,IAAID,EAAM,QAAQ,SACvB,EAAO,SAASP,EAAM,SAAS;QAC1B;GAEP,AADAO,EAAM,eAAe,GACrBA,EAAM,gBAAgB;EACxB;EAGA,IAAME,IAASC,EAAwB,GACjCC,IAAQD,EAAW,CAAC,GACtBE;E,OACJC,EACEJ,IACC,MAAO;GACN,GAAU,WAAW;GACrB,IAAMK,IAAOC,GAAI;GACjB,AAAKD,MACL,EAAM,QAAQ,KAAK,MAAMA,EAAK,sBAAsB,CAAC,CAAC,KAAK,GACvD,OAAO,i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