@fusion.dev/helix-core 0.147.0 → 0.149.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/custom-elements.json +16160 -12084
- package/dist/controllers/aria-forward-controller/aria-forward-controller.js +1 -1
- package/dist/controllers/chart-pointer-controller/chart-pointer-controller.d.ts +2 -2
- package/dist/controllers/chart-pointer-controller/chart-pointer-controller.js +5 -4
- package/dist/controllers/children-controller/children-controller.d.ts +28 -0
- package/dist/controllers/children-controller/children-controller.js +18 -0
- package/dist/controllers/countdown-controller/countdown-controller.d.ts +15 -1
- package/dist/controllers/countdown-controller/countdown-controller.js +27 -2
- package/dist/controllers/floating-controller/floating-controller.d.ts +12 -1
- package/dist/controllers/floating-controller/floating-controller.js +2 -1
- package/dist/controllers/keyboard-navigation-controller/keyboard-navigation-controller.d.ts +25 -0
- package/dist/controllers/keyboard-navigation-controller/keyboard-navigation-controller.js +8 -0
- package/dist/controllers/machine-controller/machine-controller.d.ts +69 -0
- package/dist/controllers/machine-controller/machine-controller.js +78 -0
- package/dist/controllers/machine-controller/machine.d.ts +93 -0
- package/dist/controllers/machine-controller/machine.js +20 -0
- package/dist/controllers/open-phase-controller/open-phase-controller.d.ts +10 -0
- package/dist/controllers/open-phase-controller/open-phase-controller.js +7 -4
- package/dist/controllers/option-window-controller/option-window-controller.d.ts +96 -0
- package/dist/controllers/option-window-controller/option-window-controller.js +81 -0
- package/dist/controllers/popover-controller/popover-controller.js +1 -1
- package/dist/controllers/reorder-controller/reorder-controller.d.ts +285 -0
- package/dist/controllers/reorder-controller/reorder-controller.js +497 -0
- package/dist/controllers/source-controller/source-controller.js +1 -1
- package/dist/controllers/virtualize-controller/heights.js +1 -1
- package/dist/controllers/virtualize-controller/virtualize-controller.d.ts +117 -3
- package/dist/controllers/virtualize-controller/virtualize-controller.js +134 -32
- package/dist/events/before-reorder.d.ts +14 -0
- package/dist/events/before-reorder.js +11 -0
- package/dist/events/details.d.ts +28 -0
- package/dist/events/events.d.ts +4 -2
- package/dist/events/events.js +3 -1
- package/dist/events/names.js +1 -1
- package/dist/events/reorder.d.ts +18 -12
- package/dist/events/reordered.d.ts +4 -4
- package/dist/helix-element/helix-element.d.ts +14 -5
- package/dist/helix-element/helix-element.js +6 -3
- package/dist/helix-element/react-audit-off.d.ts +11 -0
- package/dist/helix-element/react-audit-off.js +1 -0
- package/dist/helix-element/react-audit.d.ts +20 -0
- package/dist/helix-element/react-audit.js +56 -0
- package/dist/helix-element/react-bridge.d.ts +2 -22
- package/dist/helix-element/react-bridge.js +1 -56
- package/dist/index.d.ts +34 -14
- package/dist/index.js +32 -12
- package/dist/mixins/mixin-chart-source/mixin-chart-source.d.ts +7 -2
- package/dist/mixins/mixin-chart-source/mixin-chart-source.js +6 -0
- package/dist/mixins/mixin-collection/mixin-collection.js +4 -0
- package/dist/mixins/mixin-dismissible/mixin-dismissible.js +3 -0
- package/dist/mixins/mixin-field/mixin-field.js +1 -1
- package/dist/mixins/mixin-segmented-field/mixin-segmented-field.d.ts +12 -0
- package/dist/mixins/mixin-segmented-field/mixin-segmented-field.js +15 -2
- package/dist/mixins/mixin-tokens/mixin-tokens.d.ts +5 -0
- package/dist/mixins/mixin-tokens/mixin-tokens.js +13 -2
- package/dist/mixins/mixin-viewport/mixin-viewport.d.ts +17 -15
- package/dist/mixins/mixin-viewport/mixin-viewport.js +23 -41
- package/dist/utils/assign-slots/assign-slots.d.ts +18 -0
- package/dist/utils/assign-slots/assign-slots.js +14 -0
- package/dist/utils/autofill-select/autofill-select.d.ts +40 -0
- package/dist/utils/autofill-select/autofill-select.js +14 -0
- package/dist/utils/calendar/calendar.d.ts +27 -0
- package/dist/utils/calendar/calendar.js +17 -0
- package/dist/utils/center-in-view/center-in-view.d.ts +18 -0
- package/dist/utils/center-in-view/center-in-view.js +14 -0
- package/dist/utils/chord/key-names.d.ts +30 -0
- package/dist/utils/chord/key-names.js +52 -0
- package/dist/utils/column-step/column-step.d.ts +13 -0
- package/dist/utils/column-step/column-step.js +9 -0
- package/dist/utils/count-label/count-label.d.ts +7 -4
- package/dist/utils/count-label/count-label.js +2 -5
- package/dist/utils/data-options/data-options.d.ts +60 -0
- package/dist/utils/data-options/data-options.js +46 -0
- package/dist/utils/date-segments/date-segments.d.ts +2 -1
- package/dist/utils/date-segments/date-segments.js +10 -0
- package/dist/utils/draw-tooltip/draw-tooltip.d.ts +7 -2
- package/dist/utils/draw-tooltip/draw-tooltip.js +1 -1
- package/dist/utils/draw-tooltip/spoken-reading.d.ts +3 -2
- package/dist/utils/draw-tooltip/spoken-reading.js +3 -2
- package/dist/utils/export-parts/export-parts.d.ts +14 -0
- package/dist/utils/export-parts/export-parts.js +1 -0
- package/dist/utils/fill-template/fill-template.d.ts +9 -0
- package/dist/utils/fill-template/fill-template.js +3 -0
- package/dist/utils/filter-marks/filter-marks.d.ts +36 -0
- package/dist/utils/filter-marks/filter-marks.js +41 -0
- package/dist/utils/focus-target/focus-target.d.ts +12 -0
- package/dist/utils/focus-target/focus-target.js +9 -0
- package/dist/utils/focusable-elements/focusable-elements.d.ts +17 -0
- package/dist/utils/focusable-elements/focusable-elements.js +8 -0
- package/dist/utils/grid-move/grid-move.d.ts +56 -0
- package/dist/utils/grid-move/grid-move.js +28 -0
- package/dist/utils/locale-of/locale-of.d.ts +5 -0
- package/dist/utils/locale-of/locale-of.js +8 -2
- package/dist/utils/number-format/number-format.d.ts +7 -0
- package/dist/utils/number-format/number-format.js +1 -0
- package/dist/utils/reorder/drag-preview.d.ts +46 -0
- package/dist/utils/reorder/drag-preview.js +58 -0
- package/dist/utils/reorder/reorder.d.ts +178 -0
- package/dist/utils/reorder/reorder.js +112 -0
- package/dist/utils/report-runtime/report-runtime.d.ts +14 -5
- package/dist/utils/report-values/report-values.d.ts +16 -4
- package/dist/utils/report-values/report-values.js +2 -2
- package/dist/utils/request-change/request-change.d.ts +11 -0
- package/dist/utils/request-change/request-change.js +10 -0
- package/dist/utils/scroll-item-into-view/scroll-item-into-view.d.ts +17 -0
- package/dist/utils/scroll-item-into-view/scroll-item-into-view.js +1 -0
- package/dist/utils/slot-filled/slot-filled.d.ts +8 -0
- package/dist/utils/slot-filled/slot-filled.js +1 -0
- package/dist/utils/slotted-words/slotted-words.d.ts +3 -2
- package/dist/utils/slotted-words/slotted-words.js +3 -1
- package/dist/utils/toolbar-around/toolbar-around.d.ts +18 -0
- package/dist/utils/toolbar-around/toolbar-around.js +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/words/index.d.ts +3 -0
- package/dist/words/index.js +3 -0
- package/dist/words/message.d.ts +47 -0
- package/dist/words/message.js +152 -0
- package/dist/words/registry.d.ts +89 -0
- package/dist/words/registry.js +101 -0
- package/dist/words/words-locale.d.ts +34 -0
- package/dist/words/words-locale.js +30 -0
- package/dist/words/words.d.ts +52 -0
- package/dist/words/words.js +100 -0
- package/package.json +40 -25
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type ReactiveController, type ReactiveControllerHost, type TemplateResult } from 'lit';
|
|
2
|
+
import { type DataOption, type DataOptionItem } from '../../utils/data-options/data-options.js';
|
|
3
|
+
/** What the controller needs of a list whose options can come as data. */
|
|
4
|
+
export interface OptionWindowOptions {
|
|
5
|
+
/** The value of the option the keyboard is on, which is kept drawn. */
|
|
6
|
+
current: () => string;
|
|
7
|
+
/** The options as data, or nothing for a list of child elements. */
|
|
8
|
+
items: () => readonly DataOptionItem[] | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Draws the options of a list handed over as data, a window of them at a
|
|
12
|
+
* time, for a list too long to draw whole.
|
|
13
|
+
*
|
|
14
|
+
* **The list keeps its logic and this keeps the drawing.** `records` are the
|
|
15
|
+
* options as the list reads them, built once per `items` array: the keyboard,
|
|
16
|
+
* the typeahead, the filter and the value work over all of them, and the list
|
|
17
|
+
* writes `hidden`, `selected` and `active` onto them as it would onto its
|
|
18
|
+
* option elements. This draws the ones in the window as option elements of
|
|
19
|
+
* the host's tier, between two spacers that hold the room of the rest, through
|
|
20
|
+
* `VirtualizeController`.
|
|
21
|
+
*
|
|
22
|
+
* **The option the keyboard is on is always drawn**, wherever the window is,
|
|
23
|
+
* because `aria-activedescendant` points at an element. `follow` brings it into
|
|
24
|
+
* view when it moves, in two steps where it is far: the arithmetic scrolls the
|
|
25
|
+
* window to it, and the host scrolls the drawn element into view on the next
|
|
26
|
+
* update, as it does for a list of children.
|
|
27
|
+
*
|
|
28
|
+
* **The scrolling box is the element `render` was drawn into**, so the host
|
|
29
|
+
* says nothing about it: it puts the template inside its box. A host's
|
|
30
|
+
* `isDisabled`, or else its `disabled`, holds every drawn option down.
|
|
31
|
+
*
|
|
32
|
+
* Listbox uses it, and so every list that holds a Listbox can.
|
|
33
|
+
*/
|
|
34
|
+
export declare class OptionWindowController implements ReactiveController {
|
|
35
|
+
private readonly host;
|
|
36
|
+
private readonly options;
|
|
37
|
+
/** The option elements drawn on the last update, in order. */
|
|
38
|
+
drawn: HTMLElement[];
|
|
39
|
+
/** The `items` array the records were built from. */
|
|
40
|
+
private source;
|
|
41
|
+
private built;
|
|
42
|
+
/** Which slice is drawn, made the first time there are records. */
|
|
43
|
+
private virtualize;
|
|
44
|
+
/** Where in the shown records the highlight is: `-1` for nowhere. */
|
|
45
|
+
private kept;
|
|
46
|
+
/** Whether the highlight is still being brought into view. */
|
|
47
|
+
private following;
|
|
48
|
+
/**
|
|
49
|
+
* The window as it was last drawn, which `follow` reads: the controller's
|
|
50
|
+
* own may have moved since, measured after the draw, and an option is in
|
|
51
|
+
* its place only in the window that drew it.
|
|
52
|
+
*/
|
|
53
|
+
private span;
|
|
54
|
+
constructor(host: ReactiveControllerHost & HTMLElement & {
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
isDisabled?: boolean;
|
|
57
|
+
}, options: OptionWindowOptions);
|
|
58
|
+
/**
|
|
59
|
+
* The options as the list reads them, or undefined for a list of children.
|
|
60
|
+
*
|
|
61
|
+
* Built when `items` is a new array, so a page that changes the set hands
|
|
62
|
+
* over a new one, as a property of any framework is set. The windowing is
|
|
63
|
+
* made then too, and only then: a list of children observes no size and
|
|
64
|
+
* listens to no scroll it does not need. Its estimate of 32 pixels is
|
|
65
|
+
* corrected by the rows it draws, on first sight.
|
|
66
|
+
*/
|
|
67
|
+
get records(): DataOption[] | undefined;
|
|
68
|
+
/** The box the window is drawn into, inside the scrolling one. */
|
|
69
|
+
private box;
|
|
70
|
+
/** The records a filter has left showing. */
|
|
71
|
+
private get shown();
|
|
72
|
+
/**
|
|
73
|
+
* The spacers and the box the window is drawn in, for the host's scrolling
|
|
74
|
+
* box, or undefined for a list of children, which draws its slot instead.
|
|
75
|
+
*
|
|
76
|
+
* A spacer never shrinks: in a column of rows that flexes, it shrank to
|
|
77
|
+
* nothing, and the list scrolled for a screenful.
|
|
78
|
+
*/
|
|
79
|
+
render(): TemplateResult | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Draws the window once the render has put its box in place, then measures
|
|
82
|
+
* it again. Before `VirtualizeController`'s own pass, which reads the rows.
|
|
83
|
+
*/
|
|
84
|
+
hostUpdated(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Brings the highlight into view where `moved` says it moved, and answers
|
|
87
|
+
* whether its drawn element is in place for the host to scroll to now.
|
|
88
|
+
*
|
|
89
|
+
* Only when it moved, or the filter did: the window moves on every scroll,
|
|
90
|
+
* and following then would pull a reader scrolling with a wheel back to the
|
|
91
|
+
* highlight.
|
|
92
|
+
*/
|
|
93
|
+
follow(moved: boolean): boolean;
|
|
94
|
+
/** Scrolls the box to put the option of `value` in its middle. */
|
|
95
|
+
center(value: string): void;
|
|
96
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { html, } from 'lit';
|
|
2
|
+
import { dataOptions, drawOptions, windowOf, } from '../../utils/data-options/data-options.js';
|
|
3
|
+
import { VirtualizeController } from '../virtualize-controller/virtualize-controller.js';
|
|
4
|
+
export class OptionWindowController {
|
|
5
|
+
constructor(host, options) {
|
|
6
|
+
this.drawn = [];
|
|
7
|
+
this.kept = -1;
|
|
8
|
+
this.following = false;
|
|
9
|
+
this.span = { first: 0, last: 0 };
|
|
10
|
+
this.host = host;
|
|
11
|
+
this.options = options;
|
|
12
|
+
host.addController(this);
|
|
13
|
+
}
|
|
14
|
+
get records() {
|
|
15
|
+
const items = this.options.items();
|
|
16
|
+
if (items !== this.source) {
|
|
17
|
+
this.source = items;
|
|
18
|
+
this.built = items && dataOptions(items);
|
|
19
|
+
if (items) {
|
|
20
|
+
this.virtualize ??= new VirtualizeController(this.host, {
|
|
21
|
+
container: () => this.box()?.parentElement,
|
|
22
|
+
count: () => this.shown.length,
|
|
23
|
+
estimate: () => 32,
|
|
24
|
+
measured: () => false,
|
|
25
|
+
rows: () => this.drawn.map((element) => ({
|
|
26
|
+
element,
|
|
27
|
+
index: Number(element.getAttribute('aria-posinset')) - 1,
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return this.built;
|
|
33
|
+
}
|
|
34
|
+
box() {
|
|
35
|
+
return this.host.shadowRoot?.querySelector('[data-rows]');
|
|
36
|
+
}
|
|
37
|
+
get shown() {
|
|
38
|
+
return this.records?.filter((record) => !record.hidden) ?? [];
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
if (!this.records || !this.virtualize) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const current = this.options.current();
|
|
45
|
+
this.kept = this.shown.findIndex((record) => record.value === current);
|
|
46
|
+
const { after, before } = this.virtualize.spacers(this.kept < 0 ? undefined : this.kept);
|
|
47
|
+
return html `<div style="flex: none; block-size: ${before}px"></div>
|
|
48
|
+
<div data-rows></div>
|
|
49
|
+
<div style="flex: none; block-size: ${after}px"></div>`;
|
|
50
|
+
}
|
|
51
|
+
hostUpdated() {
|
|
52
|
+
const box = this.box();
|
|
53
|
+
if (!this.records || !this.virtualize || !box) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { first, last } = this.virtualize.window;
|
|
57
|
+
const shown = this.shown;
|
|
58
|
+
this.span = { first, last };
|
|
59
|
+
this.drawn = drawOptions(box, `${this.host.constructor.tier}option`, shown, windowOf(first, last, shown.length, this.kept), Boolean(this.host.isDisabled ?? this.host.disabled));
|
|
60
|
+
this.virtualize.measure();
|
|
61
|
+
}
|
|
62
|
+
follow(moved) {
|
|
63
|
+
this.following ||= moved;
|
|
64
|
+
if (!this.virtualize || !this.following || this.kept < 0) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const { first, last } = this.span;
|
|
68
|
+
if (this.kept < first || this.kept >= last) {
|
|
69
|
+
this.virtualize.reveal(this.kept);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
this.following = false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
center(value) {
|
|
76
|
+
const at = this.shown.findIndex((record) => record.value === value);
|
|
77
|
+
if (at >= 0) {
|
|
78
|
+
this.virtualize?.reveal(at, 0, { align: 'center' });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { nothing, ReactiveController, ReactiveControllerHost, TemplateResult } from 'lit';
|
|
2
|
+
import type { ReorderDetail } from '../../events/details.js';
|
|
3
|
+
import { type ReorderAxis, type ReorderHold } from '../../utils/reorder/reorder.js';
|
|
4
|
+
/**
|
|
5
|
+
* What a screen reader hears as an item moves. `{name}` is the item's name,
|
|
6
|
+
* and `{position}` and `{count}` say where it would go.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReorderWords {
|
|
9
|
+
/** Said when a key or a click puts the item back where it was. */
|
|
10
|
+
canceled: string;
|
|
11
|
+
/** Said when the item is let go. */
|
|
12
|
+
dropped: string;
|
|
13
|
+
/** Said each time a key moves the held item. */
|
|
14
|
+
moved: string;
|
|
15
|
+
/** Said when a key or a click takes hold of the item. */
|
|
16
|
+
pickedUp: string;
|
|
17
|
+
}
|
|
18
|
+
/** A move a drop asks for, counted from 0 in the order the items are drawn. */
|
|
19
|
+
export interface ReorderMove {
|
|
20
|
+
from: number;
|
|
21
|
+
key: string;
|
|
22
|
+
to: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ReorderOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Every key the item with that key moves among, the ones a filter hides
|
|
27
|
+
* included, for a drop the controller asks for itself. `keys` where this is
|
|
28
|
+
* not given.
|
|
29
|
+
*/
|
|
30
|
+
all?: (key: string) => readonly string[];
|
|
31
|
+
/** Which way the items run: rows down the block axis, or columns along the inline one. */
|
|
32
|
+
axis: ReorderAxis;
|
|
33
|
+
/** The box an item is drawn in, or nothing for one a window did not draw. */
|
|
34
|
+
box: (key: string) => DOMRect | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Called when an item is let go at a new place. Returns whether the move
|
|
37
|
+
* stood: `false` where a listener refused it.
|
|
38
|
+
*
|
|
39
|
+
* Where this is not given, the controller asks the page itself, from the
|
|
40
|
+
* host: `helix-before-reorder`, then `helix-reorder`, with `kind` and
|
|
41
|
+
* every key of `all` in the new order, joined by commas in `value`. A key a
|
|
42
|
+
* filter hides keeps its place, as `placeKey` says.
|
|
43
|
+
*/
|
|
44
|
+
drop?: (move: ReorderMove) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The key of the item a key pressed in the host stands for: the one with
|
|
47
|
+
* focus, or the one `aria-activedescendant` names. Alt with Up or Down then
|
|
48
|
+
* moves that item a place at once, and Alt with Home or End to either end,
|
|
49
|
+
* as the rearrangeable listbox of the APG does, with no grip and nothing
|
|
50
|
+
* held. Alt with an arrow moves nothing where this is not given.
|
|
51
|
+
*/
|
|
52
|
+
current?: (event: KeyboardEvent) => string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Whether an item may be moved now. Where this is not given, the host's own
|
|
55
|
+
* `reorderable` says, and every item may on a host without one.
|
|
56
|
+
*/
|
|
57
|
+
enabled?: () => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The grip an event passed through, and the key of the item it moves, or
|
|
60
|
+
* nothing for an event that passed through none.
|
|
61
|
+
*/
|
|
62
|
+
grip: (event: Event) => {
|
|
63
|
+
element: HTMLElement;
|
|
64
|
+
key: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Whether a key or a click holds the item for the arrow keys. `true` where
|
|
68
|
+
* this is not given. Data Table's columns move a place for each arrow on the
|
|
69
|
+
* grip and say `false`, so they are only dragged. A listbox's options say
|
|
70
|
+
* `false` too: the whole option is what a pointer drags, and a click on it
|
|
71
|
+
* still chooses it.
|
|
72
|
+
*/
|
|
73
|
+
holds?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The key of the item an event passed through, anywhere in it. A click there
|
|
76
|
+
* drops a held item at that place, which is the move a single pointer makes
|
|
77
|
+
* without a drag.
|
|
78
|
+
*/
|
|
79
|
+
item?: (event: Event) => string | undefined;
|
|
80
|
+
/** What a drop the controller asks for itself moves: `item`, the default, or `row`. */
|
|
81
|
+
kind?: ReorderDetail['kind'];
|
|
82
|
+
/**
|
|
83
|
+
* The keys of the items the item with that key moves among, in the order
|
|
84
|
+
* they are drawn: every item of a list, or the item's siblings in a tree.
|
|
85
|
+
*/
|
|
86
|
+
keys: (key: string) => readonly string[];
|
|
87
|
+
/** An item's name, for the words. */
|
|
88
|
+
name?: (key: string) => string;
|
|
89
|
+
/**
|
|
90
|
+
* The element a pointer drag copies for the drag preview: a copy of what it
|
|
91
|
+
* draws follows the pointer, raised over the page, until the item is let go
|
|
92
|
+
* or Escape puts it back. A move made with the keys draws none. No preview
|
|
93
|
+
* is drawn where this is not given.
|
|
94
|
+
*
|
|
95
|
+
* The copy is drawn in the host's `drag-preview` part, which the host's
|
|
96
|
+
* template draws with `drawDragPreview`: a manual popover in its shadow
|
|
97
|
+
* root, hidden from assistive technology, shown in the top layer so no
|
|
98
|
+
* scrolling box clips it. The host's stylesheet gives it its look. No
|
|
99
|
+
* preview is drawn where the host draws no such part.
|
|
100
|
+
*/
|
|
101
|
+
preview?: (key: string) => Element | null | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Gives focus back to the item with that key, called after a move made from
|
|
104
|
+
* the keyboard stood, once the page has moved the item and focus went to the
|
|
105
|
+
* body with it. Focus the page put anywhere else is left there. Focus is left
|
|
106
|
+
* alone where this is not given.
|
|
107
|
+
*/
|
|
108
|
+
refocus?: (key: string) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Speaks words in the host's live region. Where this is not given, the
|
|
111
|
+
* words go to the host's `announced`, the region a collection draws, where
|
|
112
|
+
* it has one, and nowhere otherwise.
|
|
113
|
+
*/
|
|
114
|
+
say?: (words: string) => void;
|
|
115
|
+
/**
|
|
116
|
+
* The box to scroll while a dragged item nears one of its edges, or `null`
|
|
117
|
+
* for the window. Where this is not given, rows down the block axis scroll
|
|
118
|
+
* the nearest box around the host's first child that scrolls that way and
|
|
119
|
+
* has more to show, or the window, and items along the inline axis scroll
|
|
120
|
+
* nothing.
|
|
121
|
+
*/
|
|
122
|
+
scroller?: () => HTMLElement | null;
|
|
123
|
+
/**
|
|
124
|
+
* The words a screen reader hears. Where this is not given, they are the
|
|
125
|
+
* host's own `canceledLabel`, `droppedLabel`, `movedLabel`, and
|
|
126
|
+
* `pickedUpLabel`, which is what a family declares them as.
|
|
127
|
+
*/
|
|
128
|
+
words?: () => ReorderWords;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Asks to move a row or an item and reports whether the move stood:
|
|
132
|
+
* `helix-before-reorder`, which can refuse it, and then `helix-reorder`, which
|
|
133
|
+
* is when you move your data.
|
|
134
|
+
*/
|
|
135
|
+
export declare const requestReorder: (host: HTMLElement, detail: ReorderDetail) => boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Moves one item of a collection to a new place, by pointer, by keyboard, and
|
|
138
|
+
* by a screen reader, and says each step in words.
|
|
139
|
+
*
|
|
140
|
+
* - **A pointer** drags an item by its grip. The page under it scrolls near an
|
|
141
|
+
* edge, and `mark` says where a drop indicator goes.
|
|
142
|
+
* - **A key or a click** on a grip holds the item. The arrows move it, Home
|
|
143
|
+
* and End move it to either end, Enter, Space, or a second click drops it,
|
|
144
|
+
* and Escape puts it back. A click on another item drops it there, so one
|
|
145
|
+
* pointer can move an item without dragging, as WCAG 2.5.7 asks.
|
|
146
|
+
* - **Alt with an arrow** moves the item focus is on a place at once, where
|
|
147
|
+
* the host says which item that is with `current`. A collection whose own
|
|
148
|
+
* keys are the arrows, Enter, and Space, such as a listbox or a tree, moves
|
|
149
|
+
* its items this way.
|
|
150
|
+
*
|
|
151
|
+
* **It moves nothing.** A drop calls `drop`, and the host asks its page,
|
|
152
|
+
* which owns the items, to move them. The host reads `held` and `mark` when
|
|
153
|
+
* it renders, and this asks it for an update at each change of state.
|
|
154
|
+
*
|
|
155
|
+
* Each change of state is worked out by `reorderStep`, a pure function, and
|
|
156
|
+
* what it calls for runs here: the words, the scrolling, and the drop.
|
|
157
|
+
*/
|
|
158
|
+
export declare class ReorderController implements ReactiveController {
|
|
159
|
+
private readonly host;
|
|
160
|
+
private readonly options;
|
|
161
|
+
/** The state of the move. */
|
|
162
|
+
private state;
|
|
163
|
+
/** The grip a key or a click took hold of, which has to keep focus. */
|
|
164
|
+
private holder;
|
|
165
|
+
/** Where the pointer was last, for the scrolling to place the item by. */
|
|
166
|
+
private pointer;
|
|
167
|
+
/** The frame the next scroll waits for. */
|
|
168
|
+
private frame;
|
|
169
|
+
/** The copy of the dragged item that follows the pointer, while one is drawn. */
|
|
170
|
+
private shown;
|
|
171
|
+
/** Where the pointer went down on the item the preview copies. */
|
|
172
|
+
private anchor;
|
|
173
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: ReorderOptions);
|
|
174
|
+
/** The item held and where it would go, or nothing while none is. */
|
|
175
|
+
get held(): {
|
|
176
|
+
by: ReorderHold;
|
|
177
|
+
from: number;
|
|
178
|
+
key: string;
|
|
179
|
+
to: number;
|
|
180
|
+
} | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Where the drop indicator goes: before or after the item with that key, or
|
|
183
|
+
* nothing while no item is held away from its place.
|
|
184
|
+
*/
|
|
185
|
+
get mark(): {
|
|
186
|
+
edge: 'after' | 'before';
|
|
187
|
+
key: string;
|
|
188
|
+
} | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Where the item with that key stands in a move, for the host to mark it:
|
|
191
|
+
* the item held, the item the drop indicator is before or after, or nothing.
|
|
192
|
+
*/
|
|
193
|
+
moveOf(key: string): 'dragging' | 'drop-after' | 'drop-before' | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* The `drag-preview` part, for the host's template: an empty manual popover
|
|
196
|
+
* while items may be moved, which a pointer drag fills and shows.
|
|
197
|
+
*/
|
|
198
|
+
drawDragPreview(): TemplateResult | typeof nothing;
|
|
199
|
+
hostConnected(): void;
|
|
200
|
+
hostDisconnected(): void;
|
|
201
|
+
/** Puts a held item back where it was, as Escape does. */
|
|
202
|
+
cancel(): void;
|
|
203
|
+
/** Moves the state on, and runs what the change calls for. */
|
|
204
|
+
private send;
|
|
205
|
+
/** What a change of state calls for. */
|
|
206
|
+
private enter;
|
|
207
|
+
/** Asks for a move: through `drop`, or of the page where the host gives none. */
|
|
208
|
+
private drop;
|
|
209
|
+
/** Says one of the words, with the item's name and place filled in. */
|
|
210
|
+
private speak;
|
|
211
|
+
/** The place among the others that the pointer is over, for the item with that key. */
|
|
212
|
+
private placeAt;
|
|
213
|
+
private enabled;
|
|
214
|
+
/** The page's own watch for the move it was asked for, while one is awaited. */
|
|
215
|
+
private awaiting;
|
|
216
|
+
/**
|
|
217
|
+
* Gives focus back to a moved item once the page has moved it, where moving
|
|
218
|
+
* it sent focus to the body. A page that moves the item as it hears
|
|
219
|
+
* `helix-reorder` has done so already; one that renders later changes the
|
|
220
|
+
* host's children first.
|
|
221
|
+
*/
|
|
222
|
+
private follow;
|
|
223
|
+
private readonly handleDown;
|
|
224
|
+
private readonly handleMove;
|
|
225
|
+
/**
|
|
226
|
+
* Draws the drag preview: a copy of the item, where it is, in the host's
|
|
227
|
+
* `drag-preview` part, shown in the top layer. Measured before the host
|
|
228
|
+
* draws the item as dragged, so the copy is the item as it was.
|
|
229
|
+
*/
|
|
230
|
+
private lift;
|
|
231
|
+
/** Moves the drag preview with the pointer. */
|
|
232
|
+
private glide;
|
|
233
|
+
/** Takes the drag preview away: hides the part and empties it. */
|
|
234
|
+
private lower;
|
|
235
|
+
/** Places the dragged item under the pointer's last reading. */
|
|
236
|
+
private drag;
|
|
237
|
+
private readonly handleUp;
|
|
238
|
+
private readonly handleCancel;
|
|
239
|
+
/**
|
|
240
|
+
* Escape while a pointer drags puts the item back. Heard on the window,
|
|
241
|
+
* since focus may be anywhere while a pointer drags, and kept from the page,
|
|
242
|
+
* so a dialog the list is in stays open.
|
|
243
|
+
*/
|
|
244
|
+
private readonly handleEscape;
|
|
245
|
+
/** Starts or stops hearing the pointer on the window, and the scrolling with it. */
|
|
246
|
+
private listen;
|
|
247
|
+
/** Scrolls the box while the dragged item is near one of its edges, a frame at a time. */
|
|
248
|
+
private scroll;
|
|
249
|
+
/**
|
|
250
|
+
* A click on a grip takes hold of its item, and a second one drops it. While
|
|
251
|
+
* one is held, a click on another item drops it there. Heard in the capture
|
|
252
|
+
* phase, so the click that drops an item does not also select a row.
|
|
253
|
+
*/
|
|
254
|
+
private readonly handleClick;
|
|
255
|
+
/** Takes hold of an item from its grip, which keeps focus while it is held. */
|
|
256
|
+
private take;
|
|
257
|
+
/**
|
|
258
|
+
* The keys while an item is held: the arrows, Home and End move it, Enter and
|
|
259
|
+
* Space drop it, and Escape puts it back. Heard in the capture phase and kept
|
|
260
|
+
* from everything else, so an arrow moves the item and not focus.
|
|
261
|
+
*
|
|
262
|
+
* A grip that is a native button answers Enter and Space with a click, which
|
|
263
|
+
* `handleClick` hears. Any other grip, such as a cell of a grid, is answered
|
|
264
|
+
* here.
|
|
265
|
+
*/
|
|
266
|
+
private readonly handleKey;
|
|
267
|
+
/**
|
|
268
|
+
* Alt with an arrow, Home, or End: moves the item the key stands for at
|
|
269
|
+
* once, with nothing held, and says where it went. A move the page refuses
|
|
270
|
+
* is said as canceled. At an end the key is kept and nothing moves.
|
|
271
|
+
*/
|
|
272
|
+
private nudge;
|
|
273
|
+
/**
|
|
274
|
+
* A pointer went down while a key or a click holds an item. Its click may
|
|
275
|
+
* drop the item on another one, so the focus it moves does not put the item
|
|
276
|
+
* back until that click has been heard.
|
|
277
|
+
*/
|
|
278
|
+
private press;
|
|
279
|
+
/** Whether a pointer is down while an item is held, for `press`. */
|
|
280
|
+
private pressing;
|
|
281
|
+
/** Focus leaving the grip that holds an item puts the item back. */
|
|
282
|
+
private readonly handleFocusOut;
|
|
283
|
+
/** Puts a held item back where focus has left its grip. */
|
|
284
|
+
private keepOrCancel;
|
|
285
|
+
}
|