@inkbar/vue 0.1.1 → 0.3.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/README.md +51 -5
- package/dist/components/InkIcon.js +7 -0
- package/dist/components/InkIcon.js.map +1 -0
- package/dist/components/InkIcon.vue.d.ts +11 -0
- package/dist/components/InkIcon.vue.d.ts.map +1 -0
- package/dist/components/InkIcon.vue_vue_type_script_setup_true_lang.js +22 -0
- package/dist/components/InkIcon.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkNextPage.js +7 -0
- package/dist/components/InkNextPage.js.map +1 -0
- package/dist/components/InkNextPage.vue.d.ts +19 -0
- package/dist/components/InkNextPage.vue.d.ts.map +1 -0
- package/dist/components/InkNextPage.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkNextPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkNotePopover.js.map +1 -1
- package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkPrevPage.js +7 -0
- package/dist/components/InkPrevPage.js.map +1 -0
- package/dist/components/InkPrevPage.vue.d.ts +19 -0
- package/dist/components/InkPrevPage.vue.d.ts.map +1 -0
- package/dist/components/InkPrevPage.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkPrevPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRedo.js +7 -0
- package/dist/components/InkRedo.js.map +1 -0
- package/dist/{compositions/DefaultToolbar.vue.d.ts → components/InkRedo.vue.d.ts} +5 -5
- package/dist/components/InkRedo.vue.d.ts.map +1 -0
- package/dist/components/InkRedo.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkRedo.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRoot.vue.d.ts +42 -42
- package/dist/components/InkToolButton.js.map +1 -1
- package/dist/components/InkToolButton.vue.d.ts.map +1 -1
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +26 -18
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkToolbarSeparator.js +7 -0
- package/dist/components/InkToolbarSeparator.js.map +1 -0
- package/dist/components/InkToolbarSeparator.vue.d.ts +4 -0
- package/dist/components/InkToolbarSeparator.vue.d.ts.map +1 -0
- package/dist/components/InkToolbarSeparator.vue_vue_type_script_setup_true_lang.js +17 -0
- package/dist/components/InkToolbarSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkUndo.js +7 -0
- package/dist/components/InkUndo.js.map +1 -0
- package/dist/components/InkUndo.vue.d.ts +19 -0
- package/dist/components/InkUndo.vue.d.ts.map +1 -0
- package/dist/components/InkUndo.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkUndo.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkZoomIn.js.map +1 -1
- package/dist/components/InkZoomIn.vue.d.ts.map +1 -1
- package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js +13 -11
- package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkZoomOut.js.map +1 -1
- package/dist/components/InkZoomOut.vue.d.ts.map +1 -1
- package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js +13 -11
- package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkZoomSelect.js.map +1 -1
- package/dist/components/InkZoomSelect.vue.d.ts.map +1 -1
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +105 -29
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useAnnotations.d.ts +112 -112
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -10
- package/package.json +5 -5
- package/dist/compositions/DefaultToolbar.js +0 -7
- package/dist/compositions/DefaultToolbar.js.map +0 -1
- package/dist/compositions/DefaultToolbar.vue.d.ts.map +0 -1
- package/dist/compositions/DefaultToolbar.vue_vue_type_script_setup_true_lang.js +0 -100
- package/dist/compositions/DefaultToolbar.vue_vue_type_script_setup_true_lang.js.map +0 -1
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import { useZoom as e } from "../composables/useZoom.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import t from "./InkIcon.js";
|
|
3
|
+
import { createBlock as n, createVNode as r, defineComponent as i, mergeProps as a, openBlock as o, renderSlot as s, unref as c, withCtx as l } from "vue";
|
|
4
|
+
import { ToolbarButton as u } from "reka-ui";
|
|
5
|
+
import { ZoomOut as d } from "@inkbar/icons";
|
|
4
6
|
//#region src/components/InkZoomOut.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
7
|
+
var f = /*@__PURE__*/ i({
|
|
6
8
|
__name: "InkZoomOut",
|
|
7
9
|
props: { asChild: {
|
|
8
10
|
type: Boolean,
|
|
9
11
|
default: !1
|
|
10
12
|
} },
|
|
11
|
-
setup(
|
|
12
|
-
let { zoomOut:
|
|
13
|
+
setup(i) {
|
|
14
|
+
let { zoomOut: f } = e(), p = {
|
|
13
15
|
"aria-label": "Zoom out",
|
|
14
16
|
title: "Zoom out",
|
|
15
|
-
onClick: () =>
|
|
17
|
+
onClick: () => f()
|
|
16
18
|
};
|
|
17
|
-
return (e,
|
|
18
|
-
"as-child":
|
|
19
|
+
return (e, f) => (o(), n(c(u), a({
|
|
20
|
+
"as-child": i.asChild,
|
|
19
21
|
class: "ink-zoom-out",
|
|
20
22
|
"data-ink-zoom-out": ""
|
|
21
|
-
},
|
|
22
|
-
default:
|
|
23
|
+
}, p), {
|
|
24
|
+
default: l(() => [s(e.$slots, "default", {}, () => [r(t, { icon: c(d) }, null, 8, ["icon"])])]),
|
|
23
25
|
_: 3
|
|
24
26
|
}, 16, ["as-child"]));
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
//#endregion
|
|
28
|
-
export {
|
|
30
|
+
export { f as default };
|
|
29
31
|
|
|
30
32
|
//# sourceMappingURL=InkZoomOut.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkZoomOut.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","
|
|
1
|
+
{"version":3,"file":"InkZoomOut.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","_createVNode","InkIcon","InkIcon_default","InkZoomOut_vue_vue_type_script_setup_true_lang_default","useZoom","attrs","zoomOut","openBlock","createBlock","unref","ToolbarButton","mergeProps","__props","withCtx","renderSlot","_ctx","createVNode","ZoomOut"],"sources":["../../src/components/InkZoomOut.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZoomOut } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport InkIcon from './InkIcon.vue'\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst { zoomOut } = useZoom()\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = {\n 'aria-label': 'Zoom out',\n title: 'Zoom out',\n onClick: () => zoomOut(),\n}\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-zoom-out\"\n data-ink-zoom-out\n v-bind=\"attrs\"\n >\n <slot><InkIcon :icon=\"ZoomOut\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;EASA,IAAM,EAAE,eAAYU,EAAQ,GAEtBC,IAAQ;GACZ,cAAc;GACd,OAAO;GACP,eAAeC,EAAQ;EACzB;oBAIEZ,EAAA,GAAAC,EAOgBC,EAAAc,CAAA,GAPhBb,EAOgB;GANb,YAAUe,EAAA;GACX,OAAM;GACN,qBAAA;EACQ,GAAAP,CAAK,GAAA;GAEb,SAAAP,QAAwC,CAAxCC,EAAwCgB,EAAA,QAAA,WAAA,CAAA,SAAA,CAAlCf,EAA2BC,GAAA,EAAjB,MAAML,EAAAqB,CAAA,EAAO,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkZoomSelect.js","names":["_sfc_main","InkZoomSelect_vue_vue_type_script_setup_true_lang_default","InkZoomSelect_default"],"sources":["../../src/components/InkZoomSelect.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZOOM_LEVELS } from '@inkbar/core/dom'\nimport { computed } from 'vue'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport type { ZoomValue } from '@inkbar/core/dom'\n\nconst CUSTOM = 'custom:'\n\nconst { zoom, scale, setZoom } = useZoom()\n\nconst level = (z: number) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < 0.001)\n/** A numeric zoom that is not one of the levels (zoom in and out multiply). */\nconst custom = computed(() =>\n typeof zoom.value === 'number' && level(zoom.value) === undefined ? zoom.value : null\n)\nconst value = computed(() => {\n const z = zoom.value\n if (typeof z !== 'number') return z\n return custom.value === null ? String(level(z)) : `${CUSTOM}${z}`\n})\n\nfunction onChange(
|
|
1
|
+
{"version":3,"file":"InkZoomSelect.js","names":["_sfc_main","InkZoomSelect_vue_vue_type_script_setup_true_lang_default","InkZoomSelect_default"],"sources":["../../src/components/InkZoomSelect.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZOOM_LEVELS } from '@inkbar/core/dom'\nimport { Check, ChevronDown } from '@inkbar/icons'\nimport {\n SelectContent,\n SelectIcon,\n SelectItem,\n SelectItemIndicator,\n SelectItemText,\n SelectPortal,\n SelectRoot,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n SelectViewport,\n} from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ZoomValue } from '@inkbar/core/dom'\n\nconst CUSTOM = 'custom:'\n\nconst { zoom, scale, setZoom } = useZoom()\n\nconst level = (z: number) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < 0.001)\n/** A numeric zoom that is not one of the levels (zoom in and out multiply). */\nconst custom = computed(() =>\n typeof zoom.value === 'number' && level(zoom.value) === undefined ? zoom.value : null\n)\nconst value = computed(() => {\n const z = zoom.value\n if (typeof z !== 'number') return z\n return custom.value === null ? String(level(z)) : `${CUSTOM}${z}`\n})\n\nfunction onChange(v: unknown): void {\n if (typeof v !== 'string' || v === value.value) return\n const next: ZoomValue =\n v === 'fit-width' || v === 'fit-page' ? v : Number(v.replace(CUSTOM, ''))\n setZoom(next)\n}\n\nconst FITS = [\n { value: 'fit-width', label: 'Fit width' },\n { value: 'fit-page', label: 'Fit page' },\n]\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst triggerAttrs = { 'aria-label': 'Zoom' }\nconst percent = (z: number) => `${Math.round(z * 100)}%`\n/** The levels, with a custom zoom in its place among them. */\nconst levels = computed(() => {\n const list = ZOOM_LEVELS.map((l) => ({ z: l, value: String(l), label: percent(l) }))\n const c = custom.value\n if (c !== null) list.push({ z: c, value: `${CUSTOM}${c}`, label: percent(scale.value) })\n return list.sort((a, b) => a.z - b.z)\n})\n</script>\n\n<template>\n <SelectRoot :model-value=\"value\" @update:model-value=\"onChange\">\n <SelectTrigger\n class=\"ink-zoom-select ink-select-trigger\"\n data-ink-zoom-select\n v-bind=\"triggerAttrs\"\n >\n <SelectValue class=\"ink-select-value\" />\n <SelectIcon class=\"ink-select-icon\">\n <InkIcon :icon=\"ChevronDown\" :size=\"16\" />\n </SelectIcon>\n </SelectTrigger>\n <SelectPortal>\n <SelectContent\n class=\"ink-select-content\"\n data-ink-select-content\n position=\"popper\"\n side=\"top\"\n :side-offset=\"4\"\n >\n <SelectViewport>\n <SelectItem\n v-for=\"o in FITS\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n <SelectSeparator class=\"ink-select-separator\" />\n <SelectItem\n v-for=\"o in levels\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n </SelectViewport>\n </SelectContent>\n </SelectPortal>\n </SelectRoot>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkZoomSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkZoomSelect.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InkZoomSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkZoomSelect.vue"],"names":[],"mappings":"AA8bA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1,39 +1,115 @@
|
|
|
1
1
|
import { useZoom as e } from "../composables/useZoom.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import t from "./InkIcon.js";
|
|
3
|
+
import { Fragment as n, computed as r, createBlock as i, createElementBlock as a, createTextVNode as o, createVNode as s, defineComponent as c, mergeProps as l, openBlock as u, renderList as d, toDisplayString as f, unref as p, withCtx as m } from "vue";
|
|
4
|
+
import { ZOOM_LEVELS as h } from "@inkbar/core/dom";
|
|
5
|
+
import { SelectContent as g, SelectIcon as _, SelectItem as v, SelectItemIndicator as y, SelectItemText as b, SelectPortal as x, SelectRoot as S, SelectSeparator as C, SelectTrigger as w, SelectValue as T, SelectViewport as E } from "reka-ui";
|
|
6
|
+
import { Check as D, ChevronDown as O } from "@inkbar/icons";
|
|
4
7
|
//#region src/components/InkZoomSelect.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
8
|
+
var k = "custom:", A = /*@__PURE__*/ c({
|
|
6
9
|
__name: "InkZoomSelect",
|
|
7
|
-
setup(
|
|
8
|
-
let { zoom:
|
|
9
|
-
let e =
|
|
10
|
-
return typeof e == "number" ?
|
|
10
|
+
setup(c) {
|
|
11
|
+
let { zoom: A, scale: j, setZoom: M } = e(), N = (e) => h.find((t) => Math.abs(t - e) < .001), P = r(() => typeof A.value == "number" && N(A.value) === void 0 ? A.value : null), F = r(() => {
|
|
12
|
+
let e = A.value;
|
|
13
|
+
return typeof e == "number" ? P.value === null ? String(N(e)) : `${k}${e}` : e;
|
|
11
14
|
});
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
function I(e) {
|
|
16
|
+
if (typeof e != "string" || e === F.value) return;
|
|
17
|
+
let t = e === "fit-width" || e === "fit-page" ? e : Number(e.replace(k, ""));
|
|
18
|
+
M(t);
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
value:
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
20
|
+
let L = [{
|
|
21
|
+
value: "fit-width",
|
|
22
|
+
label: "Fit width"
|
|
23
|
+
}, {
|
|
24
|
+
value: "fit-page",
|
|
25
|
+
label: "Fit page"
|
|
26
|
+
}], R = { "aria-label": "Zoom" }, z = (e) => `${Math.round(e * 100)}%`, B = r(() => {
|
|
27
|
+
let e = h.map((e) => ({
|
|
28
|
+
z: e,
|
|
29
|
+
value: String(e),
|
|
30
|
+
label: z(e)
|
|
31
|
+
})), t = P.value;
|
|
32
|
+
return t !== null && e.push({
|
|
33
|
+
z: t,
|
|
34
|
+
value: `${k}${t}`,
|
|
35
|
+
label: z(j.value)
|
|
36
|
+
}), e.sort((e, t) => e.z - t.z);
|
|
37
|
+
});
|
|
38
|
+
return (e, r) => (u(), i(p(S), {
|
|
39
|
+
"model-value": F.value,
|
|
40
|
+
"onUpdate:modelValue": I
|
|
41
|
+
}, {
|
|
42
|
+
default: m(() => [s(p(w), l({
|
|
43
|
+
class: "ink-zoom-select ink-select-trigger",
|
|
44
|
+
"data-ink-zoom-select": ""
|
|
45
|
+
}, R), {
|
|
46
|
+
default: m(() => [s(p(T), { class: "ink-select-value" }), s(p(_), { class: "ink-select-icon" }, {
|
|
47
|
+
default: m(() => [s(t, {
|
|
48
|
+
icon: p(O),
|
|
49
|
+
size: 16
|
|
50
|
+
}, null, 8, ["icon"])]),
|
|
51
|
+
_: 1
|
|
52
|
+
})]),
|
|
53
|
+
_: 1
|
|
54
|
+
}, 16), s(p(x), null, {
|
|
55
|
+
default: m(() => [s(p(g), {
|
|
56
|
+
class: "ink-select-content",
|
|
57
|
+
"data-ink-select-content": "",
|
|
58
|
+
position: "popper",
|
|
59
|
+
side: "top",
|
|
60
|
+
"side-offset": 4
|
|
61
|
+
}, {
|
|
62
|
+
default: m(() => [s(p(E), null, {
|
|
63
|
+
default: m(() => [
|
|
64
|
+
(u(), a(n, null, d(L, (e) => s(p(v), {
|
|
65
|
+
key: e.value,
|
|
66
|
+
value: e.value,
|
|
67
|
+
class: "ink-select-item",
|
|
68
|
+
"data-ink-select-item": ""
|
|
69
|
+
}, {
|
|
70
|
+
default: m(() => [s(p(b), null, {
|
|
71
|
+
default: m(() => [o(f(e.label), 1)]),
|
|
72
|
+
_: 2
|
|
73
|
+
}, 1024), s(p(y), { class: "ink-select-indicator" }, {
|
|
74
|
+
default: m(() => [s(t, {
|
|
75
|
+
icon: p(D),
|
|
76
|
+
size: 16
|
|
77
|
+
}, null, 8, ["icon"])]),
|
|
78
|
+
_: 1
|
|
79
|
+
})]),
|
|
80
|
+
_: 2
|
|
81
|
+
}, 1032, ["value"])), 64)),
|
|
82
|
+
s(p(C), { class: "ink-select-separator" }),
|
|
83
|
+
(u(!0), a(n, null, d(B.value, (e) => (u(), i(p(v), {
|
|
84
|
+
key: e.value,
|
|
85
|
+
value: e.value,
|
|
86
|
+
class: "ink-select-item",
|
|
87
|
+
"data-ink-select-item": ""
|
|
88
|
+
}, {
|
|
89
|
+
default: m(() => [s(p(b), null, {
|
|
90
|
+
default: m(() => [o(f(e.label), 1)]),
|
|
91
|
+
_: 2
|
|
92
|
+
}, 1024), s(p(y), { class: "ink-select-indicator" }, {
|
|
93
|
+
default: m(() => [s(t, {
|
|
94
|
+
icon: p(D),
|
|
95
|
+
size: 16
|
|
96
|
+
}, null, 8, ["icon"])]),
|
|
97
|
+
_: 1
|
|
98
|
+
})]),
|
|
99
|
+
_: 2
|
|
100
|
+
}, 1032, ["value"]))), 128))
|
|
101
|
+
]),
|
|
102
|
+
_: 1
|
|
103
|
+
})]),
|
|
104
|
+
_: 1
|
|
105
|
+
})]),
|
|
106
|
+
_: 1
|
|
107
|
+
})]),
|
|
108
|
+
_: 1
|
|
109
|
+
}, 8, ["model-value"]));
|
|
34
110
|
}
|
|
35
111
|
});
|
|
36
112
|
//#endregion
|
|
37
|
-
export {
|
|
113
|
+
export { A as default };
|
|
38
114
|
|
|
39
115
|
//# sourceMappingURL=InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkZoomSelect.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","
|
|
1
|
+
{"version":3,"file":"InkZoomSelect.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_mergeProps","InkIcon","_createElementBlock","_Fragment","_renderList","_createTextVNode","_toDisplayString","InkIcon_default","CUSTOM","InkZoomSelect_vue_vue_type_script_setup_true_lang_default","useZoom","level","ZOOM_LEVELS","l","z","custom","computed","zoom","value","onChange","v","next","FITS","triggerAttrs","percent","levels","list","c","scale","a","b","openBlock","createBlock","unref","SelectRoot","withCtx","createVNode","SelectTrigger","mergeProps","SelectValue","SelectIcon","ChevronDown","SelectPortal","SelectContent","SelectViewport","createElementBlock","Fragment","renderList","SelectItem","o","SelectItemText","createTextVNode","toDisplayString","SelectItemIndicator","Check","SelectSeparator"],"sources":["../../src/components/InkZoomSelect.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZOOM_LEVELS } from '@inkbar/core/dom'\nimport { Check, ChevronDown } from '@inkbar/icons'\nimport {\n SelectContent,\n SelectIcon,\n SelectItem,\n SelectItemIndicator,\n SelectItemText,\n SelectPortal,\n SelectRoot,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n SelectViewport,\n} from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ZoomValue } from '@inkbar/core/dom'\n\nconst CUSTOM = 'custom:'\n\nconst { zoom, scale, setZoom } = useZoom()\n\nconst level = (z: number) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < 0.001)\n/** A numeric zoom that is not one of the levels (zoom in and out multiply). */\nconst custom = computed(() =>\n typeof zoom.value === 'number' && level(zoom.value) === undefined ? zoom.value : null\n)\nconst value = computed(() => {\n const z = zoom.value\n if (typeof z !== 'number') return z\n return custom.value === null ? String(level(z)) : `${CUSTOM}${z}`\n})\n\nfunction onChange(v: unknown): void {\n if (typeof v !== 'string' || v === value.value) return\n const next: ZoomValue =\n v === 'fit-width' || v === 'fit-page' ? v : Number(v.replace(CUSTOM, ''))\n setZoom(next)\n}\n\nconst FITS = [\n { value: 'fit-width', label: 'Fit width' },\n { value: 'fit-page', label: 'Fit page' },\n]\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst triggerAttrs = { 'aria-label': 'Zoom' }\nconst percent = (z: number) => `${Math.round(z * 100)}%`\n/** The levels, with a custom zoom in its place among them. */\nconst levels = computed(() => {\n const list = ZOOM_LEVELS.map((l) => ({ z: l, value: String(l), label: percent(l) }))\n const c = custom.value\n if (c !== null) list.push({ z: c, value: `${CUSTOM}${c}`, label: percent(scale.value) })\n return list.sort((a, b) => a.z - b.z)\n})\n</script>\n\n<template>\n <SelectRoot :model-value=\"value\" @update:model-value=\"onChange\">\n <SelectTrigger\n class=\"ink-zoom-select ink-select-trigger\"\n data-ink-zoom-select\n v-bind=\"triggerAttrs\"\n >\n <SelectValue class=\"ink-select-value\" />\n <SelectIcon class=\"ink-select-icon\">\n <InkIcon :icon=\"ChevronDown\" :size=\"16\" />\n </SelectIcon>\n </SelectTrigger>\n <SelectPortal>\n <SelectContent\n class=\"ink-select-content\"\n data-ink-select-content\n position=\"popper\"\n side=\"top\"\n :side-offset=\"4\"\n >\n <SelectViewport>\n <SelectItem\n v-for=\"o in FITS\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n <SelectSeparator class=\"ink-select-separator\" />\n <SelectItem\n v-for=\"o in levels\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n </SelectViewport>\n </SelectContent>\n </SelectPortal>\n </SelectRoot>\n</template>\n"],"mappings":";;;;;;;AAwBA,IAAMa,IAAS;;;EAEf,IAAM,EAAE,SAAM,UAAO,eAAYE,EAAQ,GAEnCC,KAAS,MAAcC,EAAY,MAAM,MAAM,KAAK,IAAIC,IAAIC,CAAC,IAAI,IAAK,GAEtEC,IAASC,QACb,OAA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