@grafctory/clay 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +57 -2
- package/dist/asset.d.ts +24 -0
- package/dist/asset.d.ts.map +1 -0
- package/dist/asset.js +69 -0
- package/dist/asset.js.map +1 -0
- package/dist/board.d.ts +176 -0
- package/dist/board.d.ts.map +1 -0
- package/dist/board.js +222 -0
- package/dist/board.js.map +1 -0
- package/dist/fetch.d.ts +70 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +97 -0
- package/dist/fetch.js.map +1 -0
- package/dist/focus.d.ts +70 -0
- package/dist/focus.d.ts.map +1 -0
- package/dist/focus.js +65 -0
- package/dist/focus.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +110 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +148 -0
- package/dist/model.js.map +1 -0
- package/dist/router.d.ts +207 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +828 -0
- package/dist/router.js.map +1 -0
- package/dist/storage.d.ts +38 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +83 -0
- package/dist/storage.js.map +1 -0
- package/dist/transfer.d.ts +402 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +732 -0
- package/dist/transfer.js.map +1 -0
- package/package.json +92 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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,CAAC,UAAU,EAAE,CAAC;QACtB,YAAY,CAAC,KAAK,CAAC,CAAC;QAEpB,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAExF,CAAC;AAEF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Storage state.
|
|
3
|
+
*
|
|
4
|
+
* Keeps component values in Web Storage rather than in the page, so they survive reloads. Values kept in
|
|
5
|
+
* `localStorage` are also shared by every page of the site open in the browser, and stay in step whichever page
|
|
6
|
+
* writes them.
|
|
7
|
+
*
|
|
8
|
+
* Values are stored as JSON: only values surviving a JSON round trip read back as they were set.
|
|
9
|
+
*
|
|
10
|
+
* @see [Web Storage API](https://developer.mozilla.org/docs/Web/API/Web_Storage_API)
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { type Lazy } from "@grafctory/core";
|
|
15
|
+
/**
|
|
16
|
+
* Binds a component to a value kept in Web Storage.
|
|
17
|
+
*
|
|
18
|
+
* The component renders the value the entry holds, or `initial` while the entry is empty. It stays in step with the
|
|
19
|
+
* entry whoever changes it: the returned setter, or another page writing the entry, removing it or clearing the
|
|
20
|
+
* storage area. Changes made by other pages arrive only for storage areas the browser shares across pages, in
|
|
21
|
+
* practice `localStorage`.
|
|
22
|
+
*
|
|
23
|
+
* The storage area and the key may change between renders. The component then renders and follows the new entry,
|
|
24
|
+
* and the previous entry is left untouched.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam T The type of the stored value
|
|
27
|
+
*
|
|
28
|
+
* @param storage The storage area holding the entry, usually `localStorage` or `sessionStorage`
|
|
29
|
+
* @param key The name of the entry in `storage`
|
|
30
|
+
* @param initial The value shown while the entry holds none, or a factory creating it
|
|
31
|
+
*
|
|
32
|
+
* @returns The value as it stands for this render, as a deeply frozen copy changing only through the setter, and a
|
|
33
|
+
* setter storing a new one; setting `undefined` removes the entry, so that the view shows `initial` again
|
|
34
|
+
*
|
|
35
|
+
* @throws {@link !SyntaxError SyntaxError} If the entry holds a value that is not well-formed JSON
|
|
36
|
+
*/
|
|
37
|
+
export declare function useStorage<T>(storage: Storage, key: string, initial: Lazy<T>): readonly [T, (value: undefined | T) => void];
|
|
38
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAS,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,CAAC,KAAK,IAAI,CAAC,CA6C3H"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 Metreeca srl
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Web Storage state.
|
|
18
|
+
*
|
|
19
|
+
* Keeps component values in Web Storage rather than in the page, so they survive reloads. Values kept in
|
|
20
|
+
* `localStorage` are also shared by every page of the site open in the browser, and stay in step whichever page
|
|
21
|
+
* writes them.
|
|
22
|
+
*
|
|
23
|
+
* Values are stored as JSON: only values surviving a JSON round trip read back as they were set.
|
|
24
|
+
*
|
|
25
|
+
* @see [Web Storage API](https://developer.mozilla.org/docs/Web/API/Web_Storage_API)
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { eager } from "@grafctory/core";
|
|
30
|
+
import { immutable } from "@grafctory/core/values";
|
|
31
|
+
import { useEffect, useState } from "preact/hooks";
|
|
32
|
+
/**
|
|
33
|
+
* Binds a component to a value kept in Web Storage.
|
|
34
|
+
*
|
|
35
|
+
* The component renders the value the entry holds, or `initial` while the entry is empty. It stays in step with the
|
|
36
|
+
* entry whoever changes it: the returned setter, or another page writing the entry, removing it or clearing the
|
|
37
|
+
* storage area. Changes made by other pages arrive only for storage areas the browser shares across pages, in
|
|
38
|
+
* practice `localStorage`.
|
|
39
|
+
*
|
|
40
|
+
* The storage area and the key may change between renders. The component then renders and follows the new entry,
|
|
41
|
+
* and the previous entry is left untouched.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam T The type of the stored value
|
|
44
|
+
*
|
|
45
|
+
* @param storage The storage area holding the entry, usually `localStorage` or `sessionStorage`
|
|
46
|
+
* @param key The name of the entry in `storage`
|
|
47
|
+
* @param initial The value shown while the entry holds none, or a factory creating it
|
|
48
|
+
*
|
|
49
|
+
* @returns The value as it stands for this render, as a deeply frozen copy changing only through the setter, and a
|
|
50
|
+
* setter storing a new one; setting `undefined` removes the entry, so that the view shows `initial` again
|
|
51
|
+
*
|
|
52
|
+
* @throws {@link !SyntaxError SyntaxError} If the entry holds a value that is not well-formed JSON
|
|
53
|
+
*/
|
|
54
|
+
export function useStorage(storage, key, initial) {
|
|
55
|
+
const [entry, setEntry] = useState(read);
|
|
56
|
+
const current = entry.storage === storage && entry.key === key ? entry : read();
|
|
57
|
+
if (current !== entry) {
|
|
58
|
+
setEntry(current);
|
|
59
|
+
}
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const sync = ({ storageArea, key: changed }) => {
|
|
62
|
+
if (storageArea === storage && (changed === null || changed === key)) {
|
|
63
|
+
setEntry(read());
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
window.addEventListener("storage", sync);
|
|
67
|
+
return () => window.removeEventListener("storage", sync);
|
|
68
|
+
}, [storage, key]);
|
|
69
|
+
return immutable([current.value, value => {
|
|
70
|
+
if (value === undefined) {
|
|
71
|
+
storage.removeItem(key);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
storage.setItem(key, JSON.stringify(value));
|
|
75
|
+
}
|
|
76
|
+
setEntry(read());
|
|
77
|
+
}]);
|
|
78
|
+
function read() {
|
|
79
|
+
const item = storage.getItem(key);
|
|
80
|
+
return { storage, key, value: immutable(item === null ? eager(initial) : JSON.parse(item)) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,UAAU,CAAI,OAAgB,EAAE,GAAW,EAAE,OAAgB;IAE5E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,KA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AS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;IAE9F,CAAC;AAEF,CAAC"}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item transfers.
|
|
3
|
+
*
|
|
4
|
+
* Lets the components of an interface move items between sources and targets, wherever they sit in the page: a card
|
|
5
|
+
* into another column, a row to a new place in its list, files from the desktop into an upload zone. Drag and drop is
|
|
6
|
+
* one way of moving an item; a menu listing the targets that take it is the other, so every move a pointer makes is
|
|
7
|
+
* open to the keyboard and to a single tap as well.
|
|
8
|
+
*
|
|
9
|
+
* The module carries state and behaviour only. Each component draws its own items, grips, menus and drop indicators,
|
|
10
|
+
* reading the state the hooks return, so a board, a list and a tree look the way each needs:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function Card({ card }: { card: Card }) {
|
|
14
|
+
*
|
|
15
|
+
* const element = useId();
|
|
16
|
+
* const { dragging, targets, move } = useTransferSource({
|
|
17
|
+
* id: card.id, name: card.title, element, type: "application/x-card"
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* return <article id={element} data-dragging={dragging || undefined}>
|
|
21
|
+
* {card.title}
|
|
22
|
+
* <Menu items={targets.map(target => ({ label: target.name, action: () => move(target.id) }))}/>
|
|
23
|
+
* </article>;
|
|
24
|
+
*
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* function Column({ column }: { column: Column }) {
|
|
28
|
+
*
|
|
29
|
+
* const element = useId();
|
|
30
|
+
* const { target } = useTransferTarget({
|
|
31
|
+
* id: column.id, name: column.title, element, accept: ["application/x-card"],
|
|
32
|
+
* onDrop: drop => drop.source ? store.move(drop.source.id, column.id) : false
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* return <section id={element} data-target={target || undefined}>…</section>;
|
|
36
|
+
*
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* Sources and targets meet by MIME type: a source states the type of what it carries, and a target the types it
|
|
41
|
+
* takes, its own items and outside content such as `Files` or `text/uri-list` alike. Types are compared regardless of
|
|
42
|
+
* case.
|
|
43
|
+
*
|
|
44
|
+
* Elements are reached by their DOM id rather than by a ref, so a component states the id it renders its element
|
|
45
|
+
* under and hands the same id to the hook binding it.
|
|
46
|
+
*
|
|
47
|
+
* Every move ends with an announcement to screen readers, in English, telling where the item went or that the move was
|
|
48
|
+
* refused. A moved item glides to its new place over the design system's normal duration, or at once if the reader
|
|
49
|
+
* prefers reduced motion, and the focus follows it wherever it is drawn afresh.
|
|
50
|
+
*
|
|
51
|
+
* # Design
|
|
52
|
+
*
|
|
53
|
+
* - **Moves, not keyboard drags**: a reader without a pointer moves an item through a menu of plain buttons rather
|
|
54
|
+
* than by steering it with the arrow keys; every screen reader handles a menu, and a menu meets WCAG 2.5.7, which
|
|
55
|
+
* asks a single-pointer alternative to every drag and which a keyboard drag mode leaves unmet
|
|
56
|
+
* - **Native drag and drop**: the browser performs drags, so files and links dropped from other apps are taken as
|
|
57
|
+
* readily as items of the page, with no third-party engine; touch drags are added where the browser leaves them out
|
|
58
|
+
* - **Targets settle their own drops**: a column knows what taking a card means and an upload zone what to do with
|
|
59
|
+
* files, so each target answers its drops and the context carries no handlers of its own
|
|
60
|
+
* - **Types, not scopes**: sources and targets meet by MIME type across the whole app, since the browser runs a single
|
|
61
|
+
* drag at a time anyway; two boards kept apart take distinct types, and their move menus list only their own
|
|
62
|
+
* - **Visuals in each widget**: the module draws nothing but the off-screen status region, so a board, a list and a
|
|
63
|
+
* tree each draw their items and indicators with the design system roles they need
|
|
64
|
+
*
|
|
65
|
+
* The approach follows Atlassian's Pragmatic drag and drop and its
|
|
66
|
+
* [accessibility guidelines](https://atlassian.design/components/pragmatic-drag-and-drop/accessibility-guidelines),
|
|
67
|
+
* which take menus rather than keyboard drags as the way a reader moves items without a pointer.
|
|
68
|
+
*
|
|
69
|
+
* # Accessibility
|
|
70
|
+
*
|
|
71
|
+
* Measured against WCAG 2.2 AA, the module guarantees the parts every widget would otherwise get wrong alike:
|
|
72
|
+
*
|
|
73
|
+
* - a path for every move needing no drag (2.5.7, 2.1.1), through the `targets` and `move` of {@link useTransferSource}
|
|
74
|
+
* - the focus following a moved item (2.4.3), and the announcement closing each move (4.1.3)
|
|
75
|
+
* - drops settled on release, a drop outside any target or `Escape` cancelling (2.5.2)
|
|
76
|
+
* - the glide skipped where the reader prefers reduced motion (2.3.3)
|
|
77
|
+
*
|
|
78
|
+
* Each widget still owes the parts that depend on how it is drawn:
|
|
79
|
+
*
|
|
80
|
+
* - a visible control opening the moves: the grip doubling as the menu button where moving is the item's sole action,
|
|
81
|
+
* or an overflow (⋯) menu button where the item is dragged by its whole surface, never both (2.5.7)
|
|
82
|
+
* - a native file input beside a zone taking files (2.5.7)
|
|
83
|
+
* - controls named after their item, with `aria-haspopup` and `aria-expanded` on menu buttons (4.1.2), menus closing
|
|
84
|
+
* on `Escape` and handing the focus back (2.1.2), and visible focus rings (2.4.7)
|
|
85
|
+
* - grips and buttons at least 24 by 24 CSS pixels (2.5.8), and menus and previews never covering the focus (2.4.11)
|
|
86
|
+
* - drag states and drop targets told by shape or outline rather than colour alone (1.4.1), with marks holding 3:1
|
|
87
|
+
* against their background (1.4.11), as the selected role of the design system does
|
|
88
|
+
*
|
|
89
|
+
* @module
|
|
90
|
+
*/
|
|
91
|
+
import { type Optional } from "@grafctory/core";
|
|
92
|
+
import { type Awaitable } from "@grafctory/core/async";
|
|
93
|
+
import { type ComponentChildren } from "preact";
|
|
94
|
+
/**
|
|
95
|
+
* The state of an item bound by {@link useTransferSource}, with the moves open to it.
|
|
96
|
+
*
|
|
97
|
+
* A component draws the drag states of the item from its flags and offers a move menu listing `targets`, each entry
|
|
98
|
+
* calling `move`, so every move a drag allows is also open to a single pointer and to the keyboard.
|
|
99
|
+
*/
|
|
100
|
+
export type TransferSource = {
|
|
101
|
+
/**
|
|
102
|
+
* Whether the item is being dragged.
|
|
103
|
+
*/
|
|
104
|
+
readonly dragging: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Whether the item is gliding into the place it was moved to.
|
|
107
|
+
*/
|
|
108
|
+
readonly dropping: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether a move of the item is waiting for its target to settle it.
|
|
111
|
+
*/
|
|
112
|
+
readonly pending: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* The targets taking the type of the item, in the order they were bound, for a move menu to list.
|
|
115
|
+
*/
|
|
116
|
+
readonly targets: readonly TargetBinding[];
|
|
117
|
+
/**
|
|
118
|
+
* Moves the item to a target without dragging it.
|
|
119
|
+
*
|
|
120
|
+
* @param target The identifier of the target to move the item to
|
|
121
|
+
* @param side The side of the target the item is to land on, such as `"before"` for *Move up*; none if omitted
|
|
122
|
+
*
|
|
123
|
+
* @returns A promise resolving once the move settles: to `true` if the target took the item, to `false` otherwise
|
|
124
|
+
*/
|
|
125
|
+
readonly move: (target: string, side?: Side) => Promise<boolean>;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* The state of a target bound by {@link useTransferTarget}.
|
|
129
|
+
*
|
|
130
|
+
* A component draws the drop indicator of the target from it, showing where a dragged item would land.
|
|
131
|
+
*/
|
|
132
|
+
export type TransferTarget = {
|
|
133
|
+
/**
|
|
134
|
+
* Whether an item or content the target takes is being dragged over it.
|
|
135
|
+
*/
|
|
136
|
+
readonly target: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The side of the target the pointer stands nearest while something it takes is dragged over it; undefined
|
|
139
|
+
* otherwise, and always for a target taking no `sides`, which only tells whether it is met.
|
|
140
|
+
*/
|
|
141
|
+
readonly side: Optional<Side>;
|
|
142
|
+
/**
|
|
143
|
+
* Whether a drop onto the target is waiting for it to be settled.
|
|
144
|
+
*/
|
|
145
|
+
readonly pending: boolean;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* A source or a target bound to the enclosing {@link Transfer} context, as a drop or a move menu names it.
|
|
149
|
+
*/
|
|
150
|
+
export interface Binding {
|
|
151
|
+
/**
|
|
152
|
+
* The identifier the source or the target was bound under.
|
|
153
|
+
*/
|
|
154
|
+
readonly id: string;
|
|
155
|
+
/**
|
|
156
|
+
* The data the source or the target was bound with; undefined if none. Left to the consumer to narrow, since a
|
|
157
|
+
* target takes items of several types, each bound with data of its own, none of which the module can name.
|
|
158
|
+
*/
|
|
159
|
+
readonly data?: unknown;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The item a drop moves.
|
|
163
|
+
*/
|
|
164
|
+
export interface SourceBinding extends Binding {
|
|
165
|
+
/**
|
|
166
|
+
* The MIME type the item was bound with.
|
|
167
|
+
*/
|
|
168
|
+
readonly type: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A target items may be moved to, as a drop lands on it or a move menu lists it.
|
|
172
|
+
*/
|
|
173
|
+
export interface TargetBinding extends Binding {
|
|
174
|
+
/**
|
|
175
|
+
* The accessible name of the target, telling it apart in move menus and in announcements.
|
|
176
|
+
*/
|
|
177
|
+
readonly name: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A drop handed to a target.
|
|
181
|
+
*
|
|
182
|
+
* Either an {@link Internal} drop, moving an item of the page, by drag or by menu, or an {@link External} one, bringing
|
|
183
|
+
* content from outside it; `drop.source` tells the two apart, standing for the item moved or undefined for content.
|
|
184
|
+
*/
|
|
185
|
+
export type Drop = Internal | External;
|
|
186
|
+
/**
|
|
187
|
+
* Where a drop landed: the target and, where it matters, the side of it.
|
|
188
|
+
*/
|
|
189
|
+
export interface Destination {
|
|
190
|
+
/**
|
|
191
|
+
* The target the drop landed on.
|
|
192
|
+
*/
|
|
193
|
+
readonly target: TargetBinding;
|
|
194
|
+
/**
|
|
195
|
+
* The side of the target the drop landed on; undefined for a target taking no sides, such as a board column, or
|
|
196
|
+
* for a move from a menu naming no side, as *Move to Done* names none where *Move up* names `before`.
|
|
197
|
+
*/
|
|
198
|
+
readonly side?: Side;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A drop moving an item of the page.
|
|
202
|
+
*/
|
|
203
|
+
export interface Internal extends Destination {
|
|
204
|
+
/**
|
|
205
|
+
* The item moved.
|
|
206
|
+
*/
|
|
207
|
+
readonly source: SourceBinding;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A drop bringing content from outside the page, such as files from the desktop or a link from another app.
|
|
211
|
+
*/
|
|
212
|
+
export interface External extends Destination {
|
|
213
|
+
/**
|
|
214
|
+
* No item of the page: the content came from outside it.
|
|
215
|
+
*/
|
|
216
|
+
readonly source?: undefined;
|
|
217
|
+
/**
|
|
218
|
+
* The files dropped, in the order the browser lists them; none if no file was dropped.
|
|
219
|
+
*/
|
|
220
|
+
readonly files: readonly File[];
|
|
221
|
+
/**
|
|
222
|
+
* The text content dropped, keyed by the lowercase MIME type it was offered as, limited to the types the target
|
|
223
|
+
* takes; the string items of the drag, as the browser calls them, beside its file items.
|
|
224
|
+
*/
|
|
225
|
+
readonly strings: Readonly<Record<string, string>>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The side of a target an item lands on, nearest the pointer along the vertical axis.
|
|
229
|
+
*/
|
|
230
|
+
export type Side = "before" | "after";
|
|
231
|
+
/**
|
|
232
|
+
* Offers item transfers to nested components.
|
|
233
|
+
*
|
|
234
|
+
* Mounted once, at the root of an app: every source and target inside it meets every other one by type, the browser
|
|
235
|
+
* running a single drag at a time across the page anyway. A source or a target outside any stays inert.
|
|
236
|
+
*
|
|
237
|
+
* Draws a status region announcing how each move ended, and lets touch readers drag on the browsers that fire no drag
|
|
238
|
+
* events from a finger. Only the `@grafctory/skin` stylesheet keeps the region from sight while leaving it to screen
|
|
239
|
+
* readers: an app running without that stylesheet must hide `[data-offscreen]` elements with a rule of its own.
|
|
240
|
+
*
|
|
241
|
+
* @param options The components transfers are offered to
|
|
242
|
+
*
|
|
243
|
+
* @returns The nested components, with transfers offered to them
|
|
244
|
+
*/
|
|
245
|
+
export declare function Transfer({ children }: {
|
|
246
|
+
/**
|
|
247
|
+
* The components transfers are offered to.
|
|
248
|
+
*/
|
|
249
|
+
children?: ComponentChildren;
|
|
250
|
+
}): import("preact").VNode<{
|
|
251
|
+
value: Optional<Transfer>;
|
|
252
|
+
children?: ComponentChildren;
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Makes an element an item that can be moved.
|
|
256
|
+
*
|
|
257
|
+
* The item is dragged by its handle or, with no handle, by its whole surface. Presses {@link isReserved | reserved}
|
|
258
|
+
* for a field inside the item stay with that field. The item is also moved without dragging, through the
|
|
259
|
+
* {@link TargetBinding | targets} taking its type and the `move` transition, which a component offers as a move menu.
|
|
260
|
+
*
|
|
261
|
+
* Renders the component again whenever the item starts or stops being dragged or waiting for a move to settle, glides
|
|
262
|
+
* into a new place, or the targets taking its type change, so a move menu always lists the current ones.
|
|
263
|
+
*
|
|
264
|
+
* @param options The source configuration
|
|
265
|
+
*
|
|
266
|
+
* @returns The state of the item and the moves open to it
|
|
267
|
+
*/
|
|
268
|
+
export declare function useTransferSource({ id, name, element, handle, focus, type, data, payload }: {
|
|
269
|
+
/**
|
|
270
|
+
* The identifier of the item, handed to targets as `drop.source.id`.
|
|
271
|
+
*/
|
|
272
|
+
id: string;
|
|
273
|
+
/**
|
|
274
|
+
* The accessible name of the item, telling it apart in announcements.
|
|
275
|
+
*/
|
|
276
|
+
name: string;
|
|
277
|
+
/**
|
|
278
|
+
* The DOM id of the element standing for the item, which glides into its new place once moved; the binding stays
|
|
279
|
+
* inert while no element carries the id.
|
|
280
|
+
*/
|
|
281
|
+
element: string;
|
|
282
|
+
/**
|
|
283
|
+
* The DOM id of the part of the element a drag starts from, such as a grip; the whole element if omitted.
|
|
284
|
+
*/
|
|
285
|
+
handle?: string;
|
|
286
|
+
/**
|
|
287
|
+
* The DOM id of the control taking back the focus once a move ends with the focus left on the page, such as the
|
|
288
|
+
* button opening the move menu; the handle if omitted, or the element itself with no handle either, which must then
|
|
289
|
+
* be focusable. Looked up by the identifier of the item, so a component drawn afresh after a move, under DOM ids
|
|
290
|
+
* of its own, still takes the focus back, wherever in the page the move has drawn it.
|
|
291
|
+
*/
|
|
292
|
+
focus?: string;
|
|
293
|
+
/**
|
|
294
|
+
* The MIME type of the item, matched against the types targets take.
|
|
295
|
+
*/
|
|
296
|
+
type: string;
|
|
297
|
+
/**
|
|
298
|
+
* The data handed to targets as `drop.source.data`; undefined if omitted.
|
|
299
|
+
*/
|
|
300
|
+
data?: unknown;
|
|
301
|
+
/**
|
|
302
|
+
* Text content offered to other apps the item is dragged into, keyed by MIME type, such as `text/plain` or
|
|
303
|
+
* `text/uri-list`; nothing offered if omitted.
|
|
304
|
+
*/
|
|
305
|
+
payload?: Readonly<Record<string, string>>;
|
|
306
|
+
}): TransferSource;
|
|
307
|
+
/**
|
|
308
|
+
* Makes an element a target items can be moved to.
|
|
309
|
+
*
|
|
310
|
+
* The target takes the items of the page whose type it accepts, by drag or by menu, and the outside content offered
|
|
311
|
+
* as one of those types; the innermost target taking a drag under the pointer is the one meeting it.
|
|
312
|
+
*
|
|
313
|
+
* Renders the component again whenever an item it takes starts or stops being dragged over it, the side the pointer
|
|
314
|
+
* stands nearest changes, or a drop onto it starts or stops waiting to be settled.
|
|
315
|
+
*
|
|
316
|
+
* @param options The target configuration
|
|
317
|
+
*
|
|
318
|
+
* @returns The state of the target
|
|
319
|
+
*/
|
|
320
|
+
export declare function useTransferTarget({ sides, id, name, element, accept, data, onDrop }: {
|
|
321
|
+
/**
|
|
322
|
+
* Whether the side of the target an item lands on matters, as it does for an item of an ordered list taking the
|
|
323
|
+
* item dropped before or after it; if so, drops carry their `side` and announcements name the side, as in *moved
|
|
324
|
+
* before*. A target taking items into itself, such as a board column, takes none.
|
|
325
|
+
*/
|
|
326
|
+
sides?: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* The identifier of the target, handed to it as `drop.target.id`.
|
|
329
|
+
*/
|
|
330
|
+
id: string;
|
|
331
|
+
/**
|
|
332
|
+
* The accessible name of the target, telling it apart in move menus and in announcements.
|
|
333
|
+
*/
|
|
334
|
+
name: string;
|
|
335
|
+
/**
|
|
336
|
+
* The DOM id of the element items are dropped onto; the binding stays inert while no element carries the id.
|
|
337
|
+
*/
|
|
338
|
+
element: string;
|
|
339
|
+
/**
|
|
340
|
+
* The MIME types the target takes, such as the type of the items of a board or `Files`.
|
|
341
|
+
*/
|
|
342
|
+
accept: readonly string[];
|
|
343
|
+
/**
|
|
344
|
+
* The data handed to the target as `drop.target.data`; undefined if omitted.
|
|
345
|
+
*/
|
|
346
|
+
data?: unknown;
|
|
347
|
+
/**
|
|
348
|
+
* Settles a drop onto the target; returns `false` to refuse it, or a promise keeping the drop waiting until it
|
|
349
|
+
* settles and refusing it if resolved to `false`. A rejected promise takes the drop and is passed on unhandled, so
|
|
350
|
+
* a target reporting failures catches them in the promise it returns. Every drop is taken if omitted.
|
|
351
|
+
*/
|
|
352
|
+
onDrop?: (drop: Drop) => Awaitable<boolean | void>;
|
|
353
|
+
}): TransferTarget;
|
|
354
|
+
/**
|
|
355
|
+
* A bound source, as held by the service while its component stands. Mutable: the hook copies the props of each
|
|
356
|
+
* render into the entry, so the service and the listeners holding it always read the current ones.
|
|
357
|
+
*/
|
|
358
|
+
type SourceEntry = Parameters<typeof useTransferSource>[0];
|
|
359
|
+
/**
|
|
360
|
+
* A bound target, as held by the service while its component stands, mutable as a {@link SourceEntry} is. Carries
|
|
361
|
+
* its `sides` settled and no `element`: the service never reaches the element, which only the listeners bound by the
|
|
362
|
+
* hook meet, where it does reach the element of a source to glide it and hand it the focus.
|
|
363
|
+
*/
|
|
364
|
+
type TargetEntry = Omit<Parameters<typeof useTransferTarget>[0], "element" | "sides"> & {
|
|
365
|
+
sides: boolean;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* The phase a move involving an item or a target stands in while under way.
|
|
369
|
+
*/
|
|
370
|
+
type Phase = "pending" | "dropping";
|
|
371
|
+
/**
|
|
372
|
+
* What lands on a target: an item of the page, with the box it was dropped from if it is to glide to its new place,
|
|
373
|
+
* or content brought from outside the page, such as files from the desktop or a link from another app. As with the
|
|
374
|
+
* drop handed to the target, `load.source` tells the two apart, standing for the item moved or undefined for content.
|
|
375
|
+
*/
|
|
376
|
+
type Load = {
|
|
377
|
+
readonly source: SourceEntry;
|
|
378
|
+
readonly from: Optional<DOMRect>;
|
|
379
|
+
} | {
|
|
380
|
+
readonly source?: undefined;
|
|
381
|
+
readonly files: External["files"];
|
|
382
|
+
readonly strings: External["strings"];
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* The transfer service behind {@link Transfer}, shared by the hooks of every component inside it.
|
|
386
|
+
*/
|
|
387
|
+
interface Transfer {
|
|
388
|
+
readonly targets: () => readonly TargetEntry[];
|
|
389
|
+
readonly addTarget: (entry: TargetEntry) => () => void;
|
|
390
|
+
readonly addSource: (entry: SourceEntry) => () => void;
|
|
391
|
+
readonly dragged: () => Optional<SourceEntry>;
|
|
392
|
+
readonly begin: (source: SourceEntry) => void;
|
|
393
|
+
readonly end: () => void;
|
|
394
|
+
readonly phase: (id: string) => Optional<Phase>;
|
|
395
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
396
|
+
readonly drop: (destination: {
|
|
397
|
+
readonly target: TargetEntry;
|
|
398
|
+
readonly side: Optional<Side>;
|
|
399
|
+
}, load: Load) => Promise<boolean>;
|
|
400
|
+
}
|
|
401
|
+
export {};
|
|
402
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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