vanilla-jui 1.4.8 → 1.5.1

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 (53) hide show
  1. package/README.md +10 -4
  2. package/dist/index.d.ts +402 -977
  3. package/dist/index.js +1 -1
  4. package/dist/index.umd.js +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +3 -3
  7. package/src/components/accordion.ts +467 -349
  8. package/src/components/flow.ts +779 -1133
  9. package/src/components/form.ts +666 -509
  10. package/src/components/menu.ts +199 -326
  11. package/src/components/modal.ts +510 -747
  12. package/src/components/offcanvas.ts +281 -361
  13. package/src/components/pagination.ts +207 -374
  14. package/src/components/swiper.ts +688 -1168
  15. package/src/components/tabs.ts +468 -788
  16. package/src/components/toc.ts +191 -244
  17. package/src/core/component.ts +332 -0
  18. package/src/core/motion.ts +298 -0
  19. package/src/core/presence.ts +233 -0
  20. package/src/core/scheduler.ts +91 -0
  21. package/src/core/view.ts +31 -0
  22. package/src/css/accordion.css +94 -3
  23. package/src/css/content.css +18 -24
  24. package/src/css/drop.css +4 -1
  25. package/src/css/form.css +8 -0
  26. package/src/css/menu.css +10 -5
  27. package/src/css/modal.css +2 -1
  28. package/src/css/offcanvas.css +5 -17
  29. package/src/css/swiper.css +2 -1
  30. package/src/css/tabs.css +8 -17
  31. package/src/css/themes/default/accordion.css +0 -48
  32. package/src/css/themes/default/swiper.css +1 -1
  33. package/src/css/themes/default/tabs.css +4 -6
  34. package/src/css/toast.css +1 -17
  35. package/src/css/tooltip.css +2 -1
  36. package/src/index.ts +8 -3
  37. package/src/locales/index.ts +3 -0
  38. package/src/primitives/drop.ts +253 -262
  39. package/src/primitives/loading.ts +22 -4
  40. package/src/primitives/parabola.ts +123 -164
  41. package/src/primitives/sticky.ts +297 -0
  42. package/src/primitives/theme.ts +164 -222
  43. package/src/primitives/toast.ts +309 -284
  44. package/src/primitives/tooltip.ts +65 -66
  45. package/src/utilities/browser.ts +38 -0
  46. package/src/utilities/dom.ts +0 -54
  47. package/src/utilities/refs.ts +61 -0
  48. package/src/utilities/state.ts +73 -0
  49. package/src/utilities/timer.ts +11 -31
  50. package/src/validation/validator.ts +289 -389
  51. package/src/components/sticky.ts +0 -297
  52. package/src/core/Component.ts +0 -377
  53. package/src/utilities/scheduler.ts +0 -156
@@ -1,156 +0,0 @@
1
- import { createWatch, untrack, unwrap } from 'vanilla-signal';
2
-
3
- interface QueueNode {
4
- queued: boolean;
5
- disposed: boolean;
6
- next: QueueNode | null;
7
- run: () => void;
8
- }
9
-
10
- interface ScheduledTask {
11
- schedule: () => void;
12
- flush: () => void;
13
- cancel: () => void;
14
- dispose: () => void;
15
- }
16
-
17
- interface StateSyncOptions {
18
- deferInitial?: boolean;
19
- flushInitial?: boolean;
20
- flush?: 'microtask' | 'sync';
21
- }
22
-
23
- let head: QueueNode | null = null;
24
- let tail: QueueNode | null = null;
25
- let pending = false;
26
-
27
- function queueTask(callback: () => void): void {
28
- if (typeof queueMicrotask === 'function') {
29
- queueMicrotask(callback);
30
- return;
31
- }
32
- void Promise.resolve().then(callback);
33
- }
34
-
35
- function requestFlush(): void {
36
- if (pending) return;
37
- pending = true;
38
- queueTask(flushQueue);
39
- }
40
-
41
- function enqueue(node: QueueNode): void {
42
- if (tail) tail.next = node;
43
- else head = node;
44
- tail = node;
45
- requestFlush();
46
- }
47
-
48
- function flushQueue(): void {
49
- pending = false;
50
- const start = head;
51
- head = null;
52
- tail = null;
53
-
54
- let node = start;
55
- while (node) {
56
- const next = node.next;
57
- node.next = null;
58
-
59
- if (!node.disposed && node.queued) {
60
- node.queued = false;
61
- node.run();
62
- }
63
-
64
- node = next;
65
- }
66
- }
67
-
68
- export function createScheduledTask(run: () => void): ScheduledTask {
69
- const node: QueueNode = {
70
- queued: false,
71
- disposed: false,
72
- next: null,
73
- run,
74
- };
75
-
76
- return {
77
- schedule() {
78
- if (node.disposed || node.queued) return;
79
- node.queued = true;
80
- enqueue(node);
81
- },
82
- flush() {
83
- if (node.disposed) return;
84
- node.queued = false;
85
- node.run();
86
- },
87
- cancel() {
88
- node.queued = false;
89
- },
90
- dispose() {
91
- node.disposed = true;
92
- node.queued = false;
93
- node.next = null;
94
- },
95
- };
96
- }
97
-
98
- export function getStoreVersion(value: unknown): number {
99
- if (value && typeof value === 'object') {
100
- const version = (value as { __version__?: unknown }).__version__;
101
- return typeof version === 'number' ? version : 0;
102
- }
103
- return 0;
104
- }
105
-
106
- export function trackStoreVersion<T>(value: T): T {
107
- getStoreVersion(value);
108
- return value;
109
- }
110
-
111
- export function stateSnapshot<T>(value: T): T {
112
- return unwrap(value) as T;
113
- }
114
-
115
- export function createStateSync<TSnapshot>(
116
- read: () => TSnapshot,
117
- sync: (snapshot: TSnapshot) => void | Promise<void>,
118
- {
119
- deferInitial = true,
120
- flushInitial = false,
121
- flush = 'microtask',
122
- }: StateSyncOptions = {}
123
- ): () => void {
124
- let initialized = false;
125
- let hasSnapshot = false;
126
- let latestSnapshot: TSnapshot;
127
-
128
- const task = createScheduledTask(() => {
129
- if (!hasSnapshot) return;
130
- hasSnapshot = false;
131
- void untrack(() => sync(latestSnapshot));
132
- });
133
-
134
- const watcher = createWatch(
135
- read,
136
- (snapshot) => {
137
- const isInitial = !initialized;
138
- initialized = true;
139
- latestSnapshot = snapshot as TSnapshot;
140
- hasSnapshot = true;
141
-
142
- if ((isInitial && flushInitial) || flush === 'sync') {
143
- task.flush();
144
- return;
145
- }
146
-
147
- task.schedule();
148
- },
149
- { defer: deferInitial }
150
- );
151
-
152
- return () => {
153
- task.dispose();
154
- watcher.dispose();
155
- };
156
- }