@wells-nelson/interactions 0.0.0-stage → 1.0.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.
Files changed (54) hide show
  1. package/README.md +84 -2
  2. package/dist/ActiveList.svelte +168 -0
  3. package/dist/ActiveList.svelte.d.ts +54 -0
  4. package/dist/AddRow.svelte +69 -0
  5. package/dist/AddRow.svelte.d.ts +8 -0
  6. package/dist/Checkbox.svelte +65 -0
  7. package/dist/Checkbox.svelte.d.ts +9 -0
  8. package/dist/CollapsibleSection.svelte +225 -0
  9. package/dist/CollapsibleSection.svelte.d.ts +34 -0
  10. package/dist/Combobox.svelte +201 -0
  11. package/dist/Combobox.svelte.d.ts +22 -0
  12. package/dist/DevWipeButton.svelte +36 -0
  13. package/dist/DevWipeButton.svelte.d.ts +10 -0
  14. package/dist/SearchBar.svelte +60 -0
  15. package/dist/SearchBar.svelte.d.ts +8 -0
  16. package/dist/Segmented.svelte +96 -0
  17. package/dist/Segmented.svelte.d.ts +33 -0
  18. package/dist/TextField.svelte +42 -0
  19. package/dist/TextField.svelte.d.ts +10 -0
  20. package/dist/Toggle.svelte +72 -0
  21. package/dist/Toggle.svelte.d.ts +9 -0
  22. package/dist/UndoButton.svelte +41 -0
  23. package/dist/UndoButton.svelte.d.ts +8 -0
  24. package/dist/account/AccountPanel.svelte +71 -0
  25. package/dist/account/AccountPanel.svelte.d.ts +15 -0
  26. package/dist/account/ContainerEditModal.svelte +284 -0
  27. package/dist/account/ContainerEditModal.svelte.d.ts +27 -0
  28. package/dist/account/LocalItemsPrompt.svelte +83 -0
  29. package/dist/account/LocalItemsPrompt.svelte.d.ts +15 -0
  30. package/dist/account/ShareModal.svelte +297 -0
  31. package/dist/account/ShareModal.svelte.d.ts +27 -0
  32. package/dist/account/SignInCard.svelte +178 -0
  33. package/dist/account/SignInCard.svelte.d.ts +14 -0
  34. package/dist/account/SignOutCard.svelte +75 -0
  35. package/dist/account/SignOutCard.svelte.d.ts +13 -0
  36. package/dist/account/SyncStatusCard.svelte +134 -0
  37. package/dist/account/SyncStatusCard.svelte.d.ts +14 -0
  38. package/dist/account/index.d.ts +8 -0
  39. package/dist/account/index.js +8 -0
  40. package/dist/account/types.d.ts +64 -0
  41. package/dist/account/types.js +17 -0
  42. package/dist/dnd.d.ts +32 -0
  43. package/dist/dnd.js +237 -0
  44. package/dist/index.d.ts +16 -0
  45. package/dist/index.js +16 -0
  46. package/dist/longpress.d.ts +11 -0
  47. package/dist/longpress.js +63 -0
  48. package/dist/press.d.ts +18 -0
  49. package/dist/press.js +36 -0
  50. package/dist/undo.svelte.d.ts +25 -0
  51. package/dist/undo.svelte.js +53 -0
  52. package/dist/wipe.d.ts +15 -0
  53. package/dist/wipe.js +24 -0
  54. package/package.json +49 -4
@@ -0,0 +1,25 @@
1
+ /** Something that can be reversed. Capture whatever it needs in the closure. */
2
+ export interface UndoEntry {
3
+ undo(): void | Promise<void>;
4
+ }
5
+ export interface UndoStackOptions {
6
+ /** How long the Undo button stays visible after the latest push or undo (ms). */
7
+ visibleMs?: number;
8
+ /** History is dropped after this long without a push (ms). */
9
+ idleMs?: number;
10
+ }
11
+ /**
12
+ * Stackable undo for quick, reversible actions (e.g. ticking items off). Do the action, then
13
+ * `push` how to reverse it. The Undo button shows for 5 seconds after the latest push or undo;
14
+ * the history survives 1 minute without pushes, so a new push can bring older entries back.
15
+ */
16
+ export declare class UndoStack {
17
+ #private;
18
+ visible: boolean;
19
+ constructor({ visibleMs, idleMs }?: UndoStackOptions);
20
+ get size(): number;
21
+ push(entry: UndoEntry): void;
22
+ /** Reverse the latest entry. */
23
+ undo(): Promise<void>;
24
+ clear(): void;
25
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Stackable undo for quick, reversible actions (e.g. ticking items off). Do the action, then
3
+ * `push` how to reverse it. The Undo button shows for 5 seconds after the latest push or undo;
4
+ * the history survives 1 minute without pushes, so a new push can bring older entries back.
5
+ */
6
+ export class UndoStack {
7
+ visible = $state(false);
8
+ #stack = [];
9
+ #visibleMs;
10
+ #idleMs;
11
+ #hideTimer;
12
+ #dropTimer;
13
+ constructor({ visibleMs = 5_000, idleMs = 60_000 } = {}) {
14
+ this.#visibleMs = visibleMs;
15
+ this.#idleMs = idleMs;
16
+ }
17
+ get size() {
18
+ return this.#stack.length;
19
+ }
20
+ push(entry) {
21
+ this.#stack.push(entry);
22
+ this.#show();
23
+ clearTimeout(this.#dropTimer);
24
+ this.#dropTimer = setTimeout(() => (this.#stack = []), this.#idleMs);
25
+ }
26
+ /** Reverse the latest entry. */
27
+ async undo() {
28
+ const entry = this.#stack.pop();
29
+ if (!entry) {
30
+ this.#hide();
31
+ return;
32
+ }
33
+ if (this.#stack.length === 0)
34
+ this.#hide();
35
+ else
36
+ this.#show();
37
+ await entry.undo();
38
+ }
39
+ clear() {
40
+ this.#stack = [];
41
+ clearTimeout(this.#dropTimer);
42
+ this.#hide();
43
+ }
44
+ #show() {
45
+ this.visible = true;
46
+ clearTimeout(this.#hideTimer);
47
+ this.#hideTimer = setTimeout(() => (this.visible = false), this.#visibleMs);
48
+ }
49
+ #hide() {
50
+ clearTimeout(this.#hideTimer);
51
+ this.visible = false;
52
+ }
53
+ }
package/dist/wipe.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export interface WipeOptions {
2
+ /**
3
+ * App teardown to run first: unmount live queries, sign out locally, close and remove the
4
+ * app's databases. Errors are logged and the wipe continues.
5
+ */
6
+ beforeWipe?: () => void | Promise<void>;
7
+ /** Where to go afterwards (a full page load). Defaults to the site root. */
8
+ redirectTo?: string;
9
+ }
10
+ /**
11
+ * Development helper: delete every IndexedDB database, localStorage and sessionStorage entry on
12
+ * this origin, then reload at `redirectTo`. Nothing on the server is touched.
13
+ * Only wire this up in development builds.
14
+ */
15
+ export declare function wipeAllData({ beforeWipe, redirectTo }?: WipeOptions): Promise<void>;
package/dist/wipe.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Development helper: delete every IndexedDB database, localStorage and sessionStorage entry on
3
+ * this origin, then reload at `redirectTo`. Nothing on the server is touched.
4
+ * Only wire this up in development builds.
5
+ */
6
+ export async function wipeAllData({ beforeWipe, redirectTo = '/' } = {}) {
7
+ try {
8
+ await beforeWipe?.();
9
+ }
10
+ catch (err) {
11
+ console.warn('Teardown before wipe failed', err);
12
+ }
13
+ // Anything left over (e.g. other accounts' cloud databases).
14
+ const databases = (await indexedDB.databases?.()) ?? [];
15
+ await Promise.all(databases
16
+ .filter((d) => d.name)
17
+ .map((d) => new Promise((done) => {
18
+ const req = indexedDB.deleteDatabase(d.name);
19
+ req.onsuccess = req.onerror = req.onblocked = () => done();
20
+ })));
21
+ localStorage.clear();
22
+ sessionStorage.clear();
23
+ location.replace(redirectTo);
24
+ }
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@wells-nelson/interactions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Svelte 5 inputs, actions (long-press, drag and drop), undo, and account/sharing UI shared by Wells Nelson apps.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/bnelson729/wells-nelson-components.git",
9
+ "directory": "src/npm/interactions"
10
+ },
11
+ "homepage": "https://github.com/bnelson729/wells-nelson-components/tree/main/src/npm/interactions#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/bnelson729/wells-nelson-components/issues"
14
+ },
15
+ "type": "module",
16
+ "svelte": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "svelte": "./dist/index.js",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./account": {
25
+ "types": "./dist/account/index.d.ts",
26
+ "svelte": "./dist/account/index.js",
27
+ "default": "./dist/account/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "sideEffects": false,
34
+ "scripts": {
35
+ "build": "svelte-package -i src/lib -o dist",
36
+ "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings",
37
+ "test": "vitest run",
38
+ "lint:package": "publint"
39
+ },
40
+ "peerDependencies": {
41
+ "@wells-nelson/displays": ">=1.0.0 <2.0.0",
42
+ "svelte": "^5.40.0"
43
+ },
44
+ "devDependencies": {
45
+ "@wells-nelson/displays": "*"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "provenance": true
50
+ }
51
+ }