@inkbar/svelte 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +181 -2
- package/dist/components/InkAnnotation.svelte +73 -0
- package/dist/components/InkAnnotation.svelte.d.ts +13 -0
- package/dist/components/InkAnnotation.svelte.d.ts.map +1 -0
- package/dist/components/InkIcon.svelte +24 -0
- package/dist/components/InkIcon.svelte.d.ts +9 -0
- package/dist/components/InkIcon.svelte.d.ts.map +1 -0
- package/dist/components/InkNextPage.svelte +38 -0
- package/dist/components/InkNextPage.svelte.d.ts +5 -0
- package/dist/components/InkNextPage.svelte.d.ts.map +1 -0
- package/dist/components/InkNotePopover.svelte +193 -0
- package/dist/components/InkNotePopover.svelte.d.ts +9 -0
- package/dist/components/InkNotePopover.svelte.d.ts.map +1 -0
- package/dist/components/InkPage.svelte +125 -0
- package/dist/components/InkPage.svelte.d.ts +22 -0
- package/dist/components/InkPage.svelte.d.ts.map +1 -0
- package/dist/components/InkPageCount.svelte +20 -0
- package/dist/components/InkPageCount.svelte.d.ts +6 -0
- package/dist/components/InkPageCount.svelte.d.ts.map +1 -0
- package/dist/components/InkPageInput.svelte +49 -0
- package/dist/components/InkPageInput.svelte.d.ts +6 -0
- package/dist/components/InkPageInput.svelte.d.ts.map +1 -0
- package/dist/components/InkPrevPage.svelte +38 -0
- package/dist/components/InkPrevPage.svelte.d.ts +5 -0
- package/dist/components/InkPrevPage.svelte.d.ts.map +1 -0
- package/dist/components/InkRedo.svelte +38 -0
- package/dist/components/InkRedo.svelte.d.ts +5 -0
- package/dist/components/InkRedo.svelte.d.ts.map +1 -0
- package/dist/components/InkRoot.svelte +358 -0
- package/dist/components/InkRoot.svelte.d.ts +51 -0
- package/dist/components/InkRoot.svelte.d.ts.map +1 -0
- package/dist/components/InkSuggestionCard.svelte +121 -0
- package/dist/components/InkSuggestionCard.svelte.d.ts +9 -0
- package/dist/components/InkSuggestionCard.svelte.d.ts.map +1 -0
- package/dist/components/InkToolButton.svelte +68 -0
- package/dist/components/InkToolButton.svelte.d.ts +17 -0
- package/dist/components/InkToolButton.svelte.d.ts.map +1 -0
- package/dist/components/InkToolbar.svelte +40 -0
- package/dist/components/InkToolbar.svelte.d.ts +13 -0
- package/dist/components/InkToolbar.svelte.d.ts.map +1 -0
- package/dist/components/InkToolbarSeparator.svelte +18 -0
- package/dist/components/InkToolbarSeparator.svelte.d.ts +6 -0
- package/dist/components/InkToolbarSeparator.svelte.d.ts.map +1 -0
- package/dist/components/InkUndo.svelte +38 -0
- package/dist/components/InkUndo.svelte.d.ts +5 -0
- package/dist/components/InkUndo.svelte.d.ts.map +1 -0
- package/dist/components/InkViewport.svelte +306 -0
- package/dist/components/InkViewport.svelte.d.ts +27 -0
- package/dist/components/InkViewport.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomIn.svelte +36 -0
- package/dist/components/InkZoomIn.svelte.d.ts +5 -0
- package/dist/components/InkZoomIn.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomOut.svelte +36 -0
- package/dist/components/InkZoomOut.svelte.d.ts +5 -0
- package/dist/components/InkZoomOut.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomSelect.svelte +105 -0
- package/dist/components/InkZoomSelect.svelte.d.ts +7 -0
- package/dist/components/InkZoomSelect.svelte.d.ts.map +1 -0
- package/dist/components/ThreadForm.svelte +42 -0
- package/dist/components/ThreadForm.svelte.d.ts +11 -0
- package/dist/components/ThreadForm.svelte.d.ts.map +1 -0
- package/dist/components/annotation-element.svelte.d.ts +9 -0
- package/dist/components/annotation-element.svelte.d.ts.map +1 -0
- package/dist/components/annotation-element.svelte.js +25 -0
- package/dist/components/child-snippet.d.ts +22 -0
- package/dist/components/child-snippet.d.ts.map +1 -0
- package/dist/components/child-snippet.js +14 -0
- package/dist/components/history-button.d.ts +10 -0
- package/dist/components/history-button.d.ts.map +1 -0
- package/dist/components/history-button.js +1 -0
- package/dist/components/page-button.d.ts +10 -0
- package/dist/components/page-button.d.ts.map +1 -0
- package/dist/components/page-button.js +1 -0
- package/dist/components/popover-focus.d.ts +33 -0
- package/dist/components/popover-focus.d.ts.map +1 -0
- package/dist/components/popover-focus.js +63 -0
- package/dist/components/portal.d.ts +26 -0
- package/dist/components/portal.d.ts.map +1 -0
- package/dist/components/portal.js +55 -0
- package/dist/components/zoom-button.d.ts +10 -0
- package/dist/components/zoom-button.d.ts.map +1 -0
- package/dist/components/zoom-button.js +1 -0
- package/dist/context.d.ts +57 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/hooks/useAnnotations.svelte.d.ts +1683 -0
- package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -0
- package/dist/hooks/useAnnotations.svelte.js +33 -0
- package/dist/hooks/useDocument.svelte.d.ts +12 -0
- package/dist/hooks/useDocument.svelte.d.ts.map +1 -0
- package/dist/hooks/useDocument.svelte.js +28 -0
- package/dist/hooks/useEmbedded.svelte.d.ts +7 -0
- package/dist/hooks/useEmbedded.svelte.d.ts.map +1 -0
- package/dist/hooks/useEmbedded.svelte.js +17 -0
- package/dist/hooks/useHistory.svelte.d.ts +7 -0
- package/dist/hooks/useHistory.svelte.d.ts.map +1 -0
- package/dist/hooks/useHistory.svelte.js +8 -0
- package/dist/hooks/usePage.svelte.d.ts +10 -0
- package/dist/hooks/usePage.svelte.d.ts.map +1 -0
- package/dist/hooks/usePage.svelte.js +29 -0
- package/dist/hooks/useSelection.svelte.d.ts +6 -0
- package/dist/hooks/useSelection.svelte.d.ts.map +1 -0
- package/dist/hooks/useSelection.svelte.js +12 -0
- package/dist/hooks/useTool.svelte.d.ts +6 -0
- package/dist/hooks/useTool.svelte.d.ts.map +1 -0
- package/dist/hooks/useTool.svelte.js +10 -0
- package/dist/hooks/useZoom.svelte.d.ts +9 -0
- package/dist/hooks/useZoom.svelte.d.ts.map +1 -0
- package/dist/hooks/useZoom.svelte.js +18 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/use-readable.svelte.d.ts +13 -0
- package/dist/use-readable.svelte.d.ts.map +1 -0
- package/dist/use-readable.svelte.js +28 -0
- package/package.json +56 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { InkError } from '@inkbar/core'
|
|
3
|
+
import type { AnnotationSlotProps, PageMount } from '@inkbar/core/dom'
|
|
4
|
+
import type { Snippet } from 'svelte'
|
|
5
|
+
|
|
6
|
+
export interface InkPageProps {
|
|
7
|
+
page: number
|
|
8
|
+
host: HTMLElement
|
|
9
|
+
/** The engine's page mount in `host`. */
|
|
10
|
+
mount: PageMount
|
|
11
|
+
/** The engine's error for this page, `null` while it renders. */
|
|
12
|
+
error: InkError | null
|
|
13
|
+
/** Fixed for the life of the mount: the engine rebuilds when it changes. */
|
|
14
|
+
customAnnotations?: boolean
|
|
15
|
+
annotation?: Snippet<[AnnotationSlotProps]> | undefined
|
|
16
|
+
pageError?: Snippet<[{ error: InkError; page: number }]> | undefined
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
/*
|
|
22
|
+
* One page the viewer engine mounted. Renders nothing visible in place; the portal attachment
|
|
23
|
+
* moves the page error into the host and each custom annotation's content into its overlay
|
|
24
|
+
* element.
|
|
25
|
+
*
|
|
26
|
+
* The overlay creates and removes those elements as the annotation list changes, outside
|
|
27
|
+
* Svelte. So the portal targets come from a list read after every overlay render: this
|
|
28
|
+
* component subscribes to the store after the overlay does (the engine created the mount
|
|
29
|
+
* first), and core notifies subscribers in order, so the elements already exist when the list
|
|
30
|
+
* arrives here.
|
|
31
|
+
*
|
|
32
|
+
* The engine tracks page errors and sets `data-state="error"` on the host; this component
|
|
33
|
+
* portals the page error into it while `error` is set.
|
|
34
|
+
*/
|
|
35
|
+
import { untrack } from 'svelte'
|
|
36
|
+
|
|
37
|
+
import { useInkContext } from '../context.js'
|
|
38
|
+
|
|
39
|
+
import InkAnnotation from './InkAnnotation.svelte'
|
|
40
|
+
import { portal } from './portal.js'
|
|
41
|
+
|
|
42
|
+
import type { Annotation } from '@inkbar/core'
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
page,
|
|
46
|
+
host,
|
|
47
|
+
mount,
|
|
48
|
+
error,
|
|
49
|
+
customAnnotations = false,
|
|
50
|
+
annotation,
|
|
51
|
+
pageError,
|
|
52
|
+
}: InkPageProps = $props()
|
|
53
|
+
|
|
54
|
+
interface Target {
|
|
55
|
+
annotation: Annotation
|
|
56
|
+
el: HTMLElement
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function sameTargets(a: readonly Target[], b: readonly Target[]): boolean {
|
|
60
|
+
return (
|
|
61
|
+
a.length === b.length &&
|
|
62
|
+
a.every((t, i) => t.annotation === b[i]!.annotation && t.el === b[i]!.el)
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ctx = useInkContext('InkPage')
|
|
67
|
+
let targets = $state.raw<Target[]>([])
|
|
68
|
+
|
|
69
|
+
// Targets are read from the current mount, and read again when InkViewport hands this page a
|
|
70
|
+
// new one (the page left and came back within one tick, under the same key). The props are
|
|
71
|
+
// read through deriveds, which notify only when the value changes: InkViewport replaces this
|
|
72
|
+
// page's whole entry when its error changes, and that invalidates every prop without
|
|
73
|
+
// changing the mount.
|
|
74
|
+
const listPage = $derived(page)
|
|
75
|
+
const listMount = $derived(mount)
|
|
76
|
+
const listCustom = $derived(customAnnotations)
|
|
77
|
+
$effect(() => {
|
|
78
|
+
const p = listPage
|
|
79
|
+
const m = listMount
|
|
80
|
+
const custom = listCustom
|
|
81
|
+
const doc = untrack(() => ctx.document)
|
|
82
|
+
if (!doc || !custom) {
|
|
83
|
+
if (untrack(() => targets).length > 0) targets = []
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
const read = (): void => {
|
|
87
|
+
const next = doc.annotations.byPage(p).flatMap((a) => {
|
|
88
|
+
const el = m.overlay.elementFor(a.id)
|
|
89
|
+
return el ? [{ annotation: a, el }] : []
|
|
90
|
+
})
|
|
91
|
+
// A change elsewhere in the document leaves this page's targets as they were. The
|
|
92
|
+
// first read runs inside the effect, which must not come to depend on its own list.
|
|
93
|
+
if (
|
|
94
|
+
!sameTargets(
|
|
95
|
+
untrack(() => targets),
|
|
96
|
+
next
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
targets = next
|
|
100
|
+
}
|
|
101
|
+
const stop = doc.annotations.list.subscribe(read)
|
|
102
|
+
read()
|
|
103
|
+
return stop
|
|
104
|
+
})
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
{#if error}
|
|
108
|
+
<div hidden {@attach portal(host)}>
|
|
109
|
+
<div class="ink-page-error" data-ink-page-error="" role="alert">
|
|
110
|
+
{#if pageError}
|
|
111
|
+
{@render pageError({ error, page })}
|
|
112
|
+
{:else}
|
|
113
|
+
<p>Page {page + 1} could not be shown.</p>
|
|
114
|
+
<code class="ink-error-code">{error.code}</code>
|
|
115
|
+
{/if}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
{/if}
|
|
119
|
+
{#if annotation}
|
|
120
|
+
{#each targets as t (t.annotation.id)}
|
|
121
|
+
<div hidden {@attach portal(t.el)}>
|
|
122
|
+
<InkAnnotation annotation={t.annotation} element={t.el} children={annotation} />
|
|
123
|
+
</div>
|
|
124
|
+
{/each}
|
|
125
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InkError } from '@inkbar/core';
|
|
2
|
+
import type { AnnotationSlotProps, PageMount } from '@inkbar/core/dom';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export interface InkPageProps {
|
|
5
|
+
page: number;
|
|
6
|
+
host: HTMLElement;
|
|
7
|
+
/** The engine's page mount in `host`. */
|
|
8
|
+
mount: PageMount;
|
|
9
|
+
/** The engine's error for this page, `null` while it renders. */
|
|
10
|
+
error: InkError | null;
|
|
11
|
+
/** Fixed for the life of the mount: the engine rebuilds when it changes. */
|
|
12
|
+
customAnnotations?: boolean;
|
|
13
|
+
annotation?: Snippet<[AnnotationSlotProps]> | undefined;
|
|
14
|
+
pageError?: Snippet<[{
|
|
15
|
+
error: InkError;
|
|
16
|
+
page: number;
|
|
17
|
+
}]> | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare const InkPage: import("svelte").Component<InkPageProps, {}, "">;
|
|
20
|
+
type InkPage = ReturnType<typeof InkPage>;
|
|
21
|
+
export default InkPage;
|
|
22
|
+
//# sourceMappingURL=InkPage.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPage.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkPage.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;IACjB,yCAAyC;IACzC,KAAK,EAAE,SAAS,CAAA;IAChB,iEAAiE;IACjE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC,GAAG,SAAS,CAAA;IACvD,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GAAG,SAAS,CAAA;CACrE;AA4HH,QAAA,MAAM,OAAO,kDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
export type InkPageCountProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'>
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { usePage } from '../hooks/usePage.svelte.js'
|
|
9
|
+
|
|
10
|
+
let { class: className, ...rest }: InkPageCountProps = $props()
|
|
11
|
+
|
|
12
|
+
const page = usePage()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<span
|
|
16
|
+
class={['ink-page-count', className]}
|
|
17
|
+
data-ink-page-count=""
|
|
18
|
+
aria-live="polite"
|
|
19
|
+
{...rest}>of {page.count}</span
|
|
20
|
+
>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
export type InkPageCountProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'>;
|
|
3
|
+
declare const InkPageCount: import("svelte").Component<InkPageCountProps, {}, "">;
|
|
4
|
+
type InkPageCount = ReturnType<typeof InkPageCount>;
|
|
5
|
+
export default InkPageCount;
|
|
6
|
+
//# sourceMappingURL=InkPageCount.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageCount.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkPageCount.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,CAClF;AAkBD,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
export type InkPageInputProps = Omit<
|
|
5
|
+
HTMLInputAttributes,
|
|
6
|
+
'value' | 'onchange' | 'oninput' | 'type' | 'min' | 'max' | 'children'
|
|
7
|
+
>
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { usePage } from '../hooks/usePage.svelte.js'
|
|
12
|
+
|
|
13
|
+
let { class: className, onkeydown, ...rest }: InkPageInputProps = $props()
|
|
14
|
+
|
|
15
|
+
const page = usePage()
|
|
16
|
+
// Writable derived: follows the current page, and holds what the user types until then.
|
|
17
|
+
let draft = $derived(String(page.current + 1))
|
|
18
|
+
|
|
19
|
+
/** 1-based in the input, 0-based in the viewport. Out of range resets to the current page. */
|
|
20
|
+
function commit(value: string): void {
|
|
21
|
+
const n = Number(value)
|
|
22
|
+
if (Number.isInteger(n) && n >= 1 && n <= page.count) {
|
|
23
|
+
if (n - 1 !== page.current) page.goTo(n - 1)
|
|
24
|
+
} else draft = String(page.current + 1)
|
|
25
|
+
}
|
|
26
|
+
function onKeyDown(e: KeyboardEvent & { currentTarget: HTMLInputElement }): void {
|
|
27
|
+
onkeydown?.(e)
|
|
28
|
+
if (e.defaultPrevented || e.key !== 'Enter') return
|
|
29
|
+
e.preventDefault()
|
|
30
|
+
commit(draft)
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<!-- `onchange` is the native change event: it fires on blur after typing, and on each step of
|
|
35
|
+
the spinner or the arrow keys. `oninput` keeps the draft for Enter. -->
|
|
36
|
+
<input
|
|
37
|
+
class={['ink-page-input', className]}
|
|
38
|
+
data-ink-page-input=""
|
|
39
|
+
type="number"
|
|
40
|
+
inputmode="numeric"
|
|
41
|
+
aria-label="Page"
|
|
42
|
+
min={1}
|
|
43
|
+
max={page.count}
|
|
44
|
+
value={draft}
|
|
45
|
+
oninput={(e) => (draft = e.currentTarget.value)}
|
|
46
|
+
onchange={(e) => commit(e.currentTarget.value)}
|
|
47
|
+
onkeydown={onKeyDown}
|
|
48
|
+
{...rest}
|
|
49
|
+
/>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
export type InkPageInputProps = Omit<HTMLInputAttributes, 'value' | 'onchange' | 'oninput' | 'type' | 'min' | 'max' | 'children'>;
|
|
3
|
+
declare const InkPageInput: import("svelte").Component<InkPageInputProps, {}, "">;
|
|
4
|
+
type InkPageInput = ReturnType<typeof InkPageInput>;
|
|
5
|
+
export default InkPageInput;
|
|
6
|
+
//# sourceMappingURL=InkPageInput.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageInput.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkPageInput.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,mBAAmB,EACnB,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CACvE,CACF;AAmCD,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ChevronLeft } from '@inkbar/icons'
|
|
3
|
+
import { Toolbar } from 'bits-ui'
|
|
4
|
+
|
|
5
|
+
import { usePage } from '../hooks/usePage.svelte.js'
|
|
6
|
+
|
|
7
|
+
import { asBitsProps } from './child-snippet.js'
|
|
8
|
+
import InkIcon from './InkIcon.svelte'
|
|
9
|
+
|
|
10
|
+
import type { InkPageButtonProps } from './page-button.js'
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: className,
|
|
14
|
+
children,
|
|
15
|
+
child,
|
|
16
|
+
disabled,
|
|
17
|
+
onclick,
|
|
18
|
+
...rest
|
|
19
|
+
}: InkPageButtonProps = $props()
|
|
20
|
+
|
|
21
|
+
const page = usePage()
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<Toolbar.Button
|
|
25
|
+
class={['ink-prev-page', className]}
|
|
26
|
+
data-ink-prev-page=""
|
|
27
|
+
aria-label="Previous page"
|
|
28
|
+
title="Previous page"
|
|
29
|
+
disabled={page.current <= 0 || !!disabled}
|
|
30
|
+
{...child ? { child } : {}}
|
|
31
|
+
{...asBitsProps(rest)}
|
|
32
|
+
onclick={(e) => {
|
|
33
|
+
onclick?.(e)
|
|
34
|
+
if (!e.defaultPrevented) page.previous()
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{#if children}{@render children()}{:else}<InkIcon icon={ChevronLeft} />{/if}
|
|
38
|
+
</Toolbar.Button>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InkPageButtonProps } from './page-button.js';
|
|
2
|
+
declare const InkPrevPage: import("svelte").Component<InkPageButtonProps, {}, "">;
|
|
3
|
+
type InkPrevPage = ReturnType<typeof InkPrevPage>;
|
|
4
|
+
export default InkPrevPage;
|
|
5
|
+
//# sourceMappingURL=InkPrevPage.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPrevPage.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkPrevPage.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAkC3D,QAAA,MAAM,WAAW,wDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Redo2 } from '@inkbar/icons'
|
|
3
|
+
import { Toolbar } from 'bits-ui'
|
|
4
|
+
|
|
5
|
+
import { useHistory } from '../hooks/useHistory.svelte.js'
|
|
6
|
+
|
|
7
|
+
import { asBitsProps } from './child-snippet.js'
|
|
8
|
+
import InkIcon from './InkIcon.svelte'
|
|
9
|
+
|
|
10
|
+
import type { InkHistoryButtonProps } from './history-button.js'
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: className,
|
|
14
|
+
children,
|
|
15
|
+
child,
|
|
16
|
+
disabled,
|
|
17
|
+
onclick,
|
|
18
|
+
...rest
|
|
19
|
+
}: InkHistoryButtonProps = $props()
|
|
20
|
+
|
|
21
|
+
const history = useHistory()
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<Toolbar.Button
|
|
25
|
+
class={['ink-redo', className]}
|
|
26
|
+
data-ink-redo=""
|
|
27
|
+
aria-label="Redo"
|
|
28
|
+
title="Redo"
|
|
29
|
+
disabled={!history.canRedo || !!disabled}
|
|
30
|
+
{...child ? { child } : {}}
|
|
31
|
+
{...asBitsProps(rest)}
|
|
32
|
+
onclick={(e) => {
|
|
33
|
+
onclick?.(e)
|
|
34
|
+
if (!e.defaultPrevented) history.redo()
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{#if children}{@render children()}{:else}<InkIcon icon={Redo2} />{/if}
|
|
38
|
+
</Toolbar.Button>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkRedo.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkRedo.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAkCjE,QAAA,MAAM,OAAO,2DAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|