@lyeve-labs/ui-kit 0.42.2 → 0.44.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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The order arithmetic and the sentences of a list a person reorders.
3
+ *
4
+ * SortableList moves a row by pointer and by key, and both paths land here,
5
+ * so a drop and an Alt+Arrow press agree on where a row ends up and on what
6
+ * the live region says about it. Each sentence is the one a screen reader
7
+ * hears, so a table-driven test pins the words.
8
+ *
9
+ * Not exported from the package entry point: this is an implementation detail.
10
+ */
11
+ /**
12
+ * How long a finger rests on a handle before its row lifts. A shorter press
13
+ * is a swipe, and the page scrolls under it as it always did.
14
+ */
15
+ export declare const TOUCH_HOLD_MS = 250;
16
+ /** How far a mouse moves with the button down before a press becomes a drag. */
17
+ export declare const DRAG_SLOP_PX = 4;
18
+ /** How far a resting finger may wander before the press counts as a swipe. */
19
+ export declare const HOLD_SLOP_PX = 10;
20
+ /**
21
+ * How close a lifted row's pointer comes to the edge of the box that scrolls
22
+ * the list before that box scrolls toward it.
23
+ */
24
+ export declare const EDGE_SCROLL_PX = 40;
25
+ /** A consumer's answer to a move: true allows it, and a sentence refuses it and says why. */
26
+ export type MoveCheck = true | string;
27
+ /** What one attempt at a move comes to, with the sentence to announce. */
28
+ export type MoveResult<T> = {
29
+ moved: true;
30
+ items: T[];
31
+ to: number;
32
+ text: string;
33
+ } | {
34
+ moved: false;
35
+ text: string;
36
+ };
37
+ /**
38
+ * Where a row taken from `from` lands when it is dropped in `gap`, the space
39
+ * before row `gap`. The space after the last row is the gap numbered by the
40
+ * list's length. The two gaps beside the row leave it where it was.
41
+ */
42
+ export declare function landing(from: number, gap: number): number;
43
+ /**
44
+ * Moves the row at `from` to `to` in a copy of the list, once the consumer's
45
+ * check allows it. A move off either end changes nothing and says so, and a
46
+ * move to where the row already is changes nothing and says nothing.
47
+ */
48
+ export declare function attempt<T extends {
49
+ label: string;
50
+ }>(items: readonly T[], from: number, to: number, canMove?: (item: T, from: number, to: number) => MoveCheck): MoveResult<T>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The order arithmetic and the sentences of a list a person reorders.
3
+ *
4
+ * SortableList moves a row by pointer and by key, and both paths land here,
5
+ * so a drop and an Alt+Arrow press agree on where a row ends up and on what
6
+ * the live region says about it. Each sentence is the one a screen reader
7
+ * hears, so a table-driven test pins the words.
8
+ *
9
+ * Not exported from the package entry point: this is an implementation detail.
10
+ */
11
+ /**
12
+ * How long a finger rests on a handle before its row lifts. A shorter press
13
+ * is a swipe, and the page scrolls under it as it always did.
14
+ */
15
+ export const TOUCH_HOLD_MS = 250;
16
+ /** How far a mouse moves with the button down before a press becomes a drag. */
17
+ export const DRAG_SLOP_PX = 4;
18
+ /** How far a resting finger may wander before the press counts as a swipe. */
19
+ export const HOLD_SLOP_PX = 10;
20
+ /**
21
+ * How close a lifted row's pointer comes to the edge of the box that scrolls
22
+ * the list before that box scrolls toward it.
23
+ */
24
+ export const EDGE_SCROLL_PX = 40;
25
+ /**
26
+ * Where a row taken from `from` lands when it is dropped in `gap`, the space
27
+ * before row `gap`. The space after the last row is the gap numbered by the
28
+ * list's length. The two gaps beside the row leave it where it was.
29
+ */
30
+ export function landing(from, gap) {
31
+ return gap > from ? gap - 1 : gap;
32
+ }
33
+ /**
34
+ * Moves the row at `from` to `to` in a copy of the list, once the consumer's
35
+ * check allows it. A move off either end changes nothing and says so, and a
36
+ * move to where the row already is changes nothing and says nothing.
37
+ */
38
+ export function attempt(items, from, to, canMove) {
39
+ const item = items[from];
40
+ if (to < 0)
41
+ return { moved: false, text: `${item.label} is already first.` };
42
+ if (to >= items.length)
43
+ return { moved: false, text: `${item.label} is already last.` };
44
+ if (to === from)
45
+ return { moved: false, text: '' };
46
+ const check = canMove?.(item, from, to) ?? true;
47
+ if (check !== true)
48
+ return { moved: false, text: check };
49
+ const next = items.slice();
50
+ next.splice(from, 1);
51
+ next.splice(to, 0, item);
52
+ return {
53
+ moved: true,
54
+ items: next,
55
+ to,
56
+ text: `${item.label} moved to position ${to + 1} of ${items.length}.`,
57
+ };
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyeve-labs/ui-kit",
3
- "version": "0.42.2",
3
+ "version": "0.44.0",
4
4
  "description": "A clean, accessible, palette-aware Svelte 5 component library. The design system behind LyEve.",
5
5
  "license": "MIT",
6
6
  "author": "LyEve Labs <hello@lyeve.com>",