svelte-ag 1.0.11 → 1.0.13

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 (124) hide show
  1. package/dist/lib/api/form.svelte.js +36 -96
  2. package/dist/lib/api/query/cache.svelte.js +27 -48
  3. package/dist/lib/api/query/entrypoint.svelte.js +10 -11
  4. package/dist/lib/api/query/query.svelte.js +134 -252
  5. package/dist/lib/api/query/utils.svelte.js +2 -2
  6. package/dist/lib/bits/internal/arrays.d.ts +1 -1
  7. package/dist/lib/bits/internal/arrays.d.ts.map +1 -1
  8. package/dist/lib/bits/internal/arrays.js +34 -39
  9. package/dist/lib/bits/internal/arrays.test.js +118 -118
  10. package/dist/lib/bits/internal/box-auto-reset.svelte.js +7 -9
  11. package/dist/lib/bits/internal/box.svelte.js +10 -11
  12. package/dist/lib/bits/internal/clamp.test.js +7 -7
  13. package/dist/lib/bits/internal/create-event-hook.svelte.js +11 -15
  14. package/dist/lib/bits/internal/create-shared-hook.svelte.js +8 -12
  15. package/dist/lib/bits/internal/date-time/announcer.d.ts +1 -1
  16. package/dist/lib/bits/internal/date-time/announcer.js +13 -15
  17. package/dist/lib/bits/internal/date-time/calendar-helpers.svelte.js +145 -180
  18. package/dist/lib/bits/internal/date-time/field/helpers.js +61 -78
  19. package/dist/lib/bits/internal/date-time/field/parts.js +6 -15
  20. package/dist/lib/bits/internal/date-time/field/segments.d.ts +4 -4
  21. package/dist/lib/bits/internal/date-time/field/segments.d.ts.map +1 -1
  22. package/dist/lib/bits/internal/date-time/field/segments.js +15 -15
  23. package/dist/lib/bits/internal/date-time/formatter.js +26 -39
  24. package/dist/lib/bits/internal/date-time/placeholders.js +4 -4
  25. package/dist/lib/bits/internal/date-time/utils.js +21 -33
  26. package/dist/lib/bits/internal/debounce.js +6 -11
  27. package/dist/lib/bits/internal/debounce.test.js +47 -134
  28. package/dist/lib/bits/internal/dom.d.ts +3 -3
  29. package/dist/lib/bits/internal/dom.d.ts.map +1 -1
  30. package/dist/lib/bits/internal/dom.js +6 -9
  31. package/dist/lib/bits/internal/elements.js +1 -2
  32. package/dist/lib/bits/internal/events.js +21 -30
  33. package/dist/lib/bits/internal/floating-svelte/floating-utils.svelte.js +9 -10
  34. package/dist/lib/bits/internal/floating-svelte/use-floating.svelte.js +32 -40
  35. package/dist/lib/bits/internal/focus.d.ts +5 -5
  36. package/dist/lib/bits/internal/focus.d.ts.map +1 -1
  37. package/dist/lib/bits/internal/focus.js +18 -22
  38. package/dist/lib/bits/internal/get-directional-keys.js +7 -22
  39. package/dist/lib/bits/internal/get-directional-keys.test.js +12 -12
  40. package/dist/lib/bits/internal/is.d.ts +1 -1
  41. package/dist/lib/bits/internal/is.d.ts.map +1 -1
  42. package/dist/lib/bits/internal/is.js +4 -5
  43. package/dist/lib/bits/internal/is.test.js +7 -7
  44. package/dist/lib/bits/internal/kbd-constants.js +40 -40
  45. package/dist/lib/bits/internal/locale.js +2 -2
  46. package/dist/lib/bits/internal/math.js +12 -13
  47. package/dist/lib/bits/internal/math.test.js +20 -20
  48. package/dist/lib/bits/internal/should-trap-focus.js +1 -2
  49. package/dist/lib/bits/internal/sleep.js +1 -1
  50. package/dist/lib/bits/internal/tabbable.js +11 -12
  51. package/dist/lib/bits/internal/use-after-animations.svelte.js +6 -6
  52. package/dist/lib/bits/internal/use-arrow-navigation.js +19 -21
  53. package/dist/lib/bits/internal/use-body-scroll-lock.svelte.d.ts +1 -1
  54. package/dist/lib/bits/internal/use-body-scroll-lock.svelte.d.ts.map +1 -1
  55. package/dist/lib/bits/internal/use-body-scroll-lock.svelte.js +36 -40
  56. package/dist/lib/bits/internal/use-data-typeahead.svelte.d.ts +1 -1
  57. package/dist/lib/bits/internal/use-data-typeahead.svelte.js +10 -11
  58. package/dist/lib/bits/internal/use-dom-typeahead.svelte.d.ts +1 -1
  59. package/dist/lib/bits/internal/use-dom-typeahead.svelte.js +11 -13
  60. package/dist/lib/bits/internal/use-form-control.svelte.js +2 -2
  61. package/dist/lib/bits/internal/use-grace-area.svelte.js +47 -60
  62. package/dist/lib/bits/internal/use-id.js +3 -5
  63. package/dist/lib/bits/internal/use-resize-observer.svelte.js +5 -5
  64. package/dist/lib/bits/internal/use-roving-focus.svelte.d.ts +2 -2
  65. package/dist/lib/bits/internal/use-roving-focus.svelte.js +32 -36
  66. package/dist/lib/bits/internal/use-size.svelte.d.ts +1 -1
  67. package/dist/lib/bits/internal/use-size.svelte.js +12 -12
  68. package/dist/lib/bits/internal/use-state-machine.svelte.js +6 -6
  69. package/dist/lib/bits/internal/use-timeout-fn.svelte.js +10 -15
  70. package/dist/lib/components/animated/animated.svelte.d.ts +1 -1
  71. package/dist/lib/components/animated/animated.svelte.d.ts.map +1 -1
  72. package/dist/lib/components/carousel/carousel-dots.svelte.d.ts +6 -1
  73. package/dist/lib/components/carousel/carousel-dots.svelte.d.ts.map +1 -1
  74. package/dist/lib/components/carousel/carousel-next.svelte.d.ts +21 -1
  75. package/dist/lib/components/carousel/carousel-next.svelte.d.ts.map +1 -1
  76. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts +21 -1
  77. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts.map +1 -1
  78. package/dist/lib/components/carousel/context.js +4 -7
  79. package/dist/lib/components/dnd/context.svelte.js +2 -2
  80. package/dist/lib/components/dnd/default.svelte.js +9 -15
  81. package/dist/lib/components/dnd/dnd-item.svelte.d.ts +20 -1
  82. package/dist/lib/components/dnd/dnd-item.svelte.d.ts.map +1 -1
  83. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts +5 -1
  84. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts.map +1 -1
  85. package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts +3 -1
  86. package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts.map +1 -1
  87. package/dist/lib/components/dnd/sortable.svelte.js +26 -29
  88. package/dist/lib/components/dnd/utils.svelte.d.ts +1 -1
  89. package/dist/lib/components/dnd/utils.svelte.js +6 -7
  90. package/dist/lib/components/form/form-message.svelte.d.ts +2 -1
  91. package/dist/lib/components/form/form-message.svelte.d.ts.map +1 -1
  92. package/dist/lib/components/gallery/gallery.svelte.d.ts +21 -1
  93. package/dist/lib/components/gallery/gallery.svelte.d.ts.map +1 -1
  94. package/dist/lib/components/gallery/utils.js +20 -24
  95. package/dist/lib/components/safe/safe.svelte.d.ts +1 -1
  96. package/dist/lib/components/safe/safe.svelte.d.ts.map +1 -1
  97. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts +2 -2
  98. package/dist/lib/components/search/search.svelte.d.ts +1 -1
  99. package/dist/lib/components/search/search.svelte.d.ts.map +1 -1
  100. package/dist/lib/components/search/search.svelte.js +135 -228
  101. package/dist/lib/components/sidebar/constants.js +6 -6
  102. package/dist/lib/components/sidebar/context.svelte.d.ts +1 -1
  103. package/dist/lib/components/sidebar/context.svelte.d.ts.map +1 -1
  104. package/dist/lib/components/sidebar/context.svelte.js +33 -51
  105. package/dist/lib/components/sidebar/sidebar-input.svelte.d.ts +9 -1
  106. package/dist/lib/components/sidebar/sidebar-input.svelte.d.ts.map +1 -1
  107. package/dist/lib/components/sidebar/sidebar-menu-button.svelte.d.ts +2 -2
  108. package/dist/lib/components/sidebar/sidebar-menu-button.svelte.d.ts.map +1 -1
  109. package/dist/lib/components/sidebar/sidebar-trigger.svelte.d.ts +7 -1
  110. package/dist/lib/components/sidebar/sidebar-trigger.svelte.d.ts.map +1 -1
  111. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts +1 -1
  112. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts.map +1 -1
  113. package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.d.ts +18 -18
  114. package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.d.ts.map +1 -1
  115. package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.js +210 -243
  116. package/dist/lib/utils/asyncDerived.svelte.js +4 -4
  117. package/dist/lib/utils/bits.d.ts +11 -11
  118. package/dist/lib/utils/bits.d.ts.map +1 -1
  119. package/dist/lib/utils/reactive.svelte.js +3 -3
  120. package/dist/lib/utils/utils.d.ts +2 -2
  121. package/dist/lib/utils/utils.js +45 -45
  122. package/dist/lib/vite/vite-plugin-component-source-collector.js +73 -187
  123. package/dist/routes/+layout.svelte.d.ts +1 -1
  124. package/package.json +2 -1
@@ -1,65 +1,65 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { arraysAreEqual, backward, chunk, forward, getNextMatch, isValidIndex, next, prev, wrapArray } from './arrays.js';
3
- describe('arraysAreEqual', function () {
4
- it('should return true for two empty arrays', function () {
3
+ describe('arraysAreEqual', () => {
4
+ it('should return true for two empty arrays', () => {
5
5
  expect(arraysAreEqual([], [])).toBe(true);
6
6
  });
7
- it('should return true for two arrays with the same elements in the same order', function () {
7
+ it('should return true for two arrays with the same elements in the same order', () => {
8
8
  expect(arraysAreEqual([1, 2, 3], [1, 2, 3])).toBe(true);
9
9
  });
10
- it('should return false for two arrays with different lengths', function () {
10
+ it('should return false for two arrays with different lengths', () => {
11
11
  expect(arraysAreEqual([1, 2, 3], [1, 2])).toBe(false);
12
12
  });
13
- it('should return false for two arrays with different elements', function () {
13
+ it('should return false for two arrays with different elements', () => {
14
14
  expect(arraysAreEqual([1, 2, 3], [1, 2, 4])).toBe(false);
15
15
  });
16
- it('should return false for two arrays with elements in different orders', function () {
16
+ it('should return false for two arrays with elements in different orders', () => {
17
17
  expect(arraysAreEqual([1, 2, 3], [3, 2, 1])).toBe(false);
18
18
  });
19
- it('should handle arrays with non-primitive values', function () {
20
- var obj1 = { foo: 'bar' };
21
- var obj2 = { foo: 'bar' };
19
+ it('should handle arrays with non-primitive values', () => {
20
+ const obj1 = { foo: 'bar' };
21
+ const obj2 = { foo: 'bar' };
22
22
  expect(arraysAreEqual([obj1], [obj2])).toBe(true);
23
23
  });
24
- it('should handle arrays with different non-primitive values', function () {
25
- var obj1 = { foo: 'baz' };
26
- var obj2 = { foo: 'bar' };
24
+ it('should handle arrays with different non-primitive values', () => {
25
+ const obj1 = { foo: 'baz' };
26
+ const obj2 = { foo: 'bar' };
27
27
  expect(arraysAreEqual([obj1], [obj2])).toBe(false);
28
28
  });
29
- it('should handle nested arrays', function () {
29
+ it('should handle nested arrays', () => {
30
30
  expect(arraysAreEqual([1, [2, 3]], [1, [2, 3]])).toBe(true);
31
31
  expect(arraysAreEqual([1, [2, 3]], [1, [3, 2]])).toBe(false);
32
32
  });
33
- it('should handle arrays with different types of elements', function () {
33
+ it('should handle arrays with different types of elements', () => {
34
34
  expect(arraysAreEqual([1, '2', true], [1, '2', true])).toBe(true);
35
35
  expect(arraysAreEqual([1, '2', true], [1, 2, true])).toBe(false);
36
36
  });
37
- it('should handle sparse arrays', function () {
37
+ it('should handle sparse arrays', () => {
38
38
  // eslint-disable-next-line no-sparse-arrays
39
- var arr1 = [1, , 3];
40
- var arr2 = [1, undefined, 3];
39
+ const arr1 = [1, , 3];
40
+ const arr2 = [1, undefined, 3];
41
41
  expect(arraysAreEqual(arr1, arr2)).toBe(true);
42
42
  });
43
- it('should handle NaN values', function () {
43
+ it('should handle NaN values', () => {
44
44
  expect(arraysAreEqual([Number.NaN], [Number.NaN])).toBe(true);
45
45
  });
46
46
  });
47
- describe('chunk', function () {
48
- it('should return an empty array when given an empty array', function () {
47
+ describe('chunk', () => {
48
+ it('should return an empty array when given an empty array', () => {
49
49
  expect(chunk([], 2)).toEqual([]);
50
50
  });
51
- it('should return an array with one chunk when size is greater than or equal to array length', function () {
51
+ it('should return an array with one chunk when size is greater than or equal to array length', () => {
52
52
  expect(chunk([1, 2, 3], 3)).toEqual([[1, 2, 3]]);
53
53
  expect(chunk([1, 2, 3], 4)).toEqual([[1, 2, 3]]);
54
54
  });
55
- it('should chunk the array into arrays of the specified size', function () {
55
+ it('should chunk the array into arrays of the specified size', () => {
56
56
  expect(chunk([1, 2, 3, 4], 2)).toEqual([
57
57
  [1, 2],
58
58
  [3, 4]
59
59
  ]);
60
60
  expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([[1, 2], [3, 4], [5]]);
61
61
  });
62
- it('should work with arrays containing different types', function () {
62
+ it('should work with arrays containing different types', () => {
63
63
  expect(chunk(['a', 'b', 'c', 'd'], 2)).toEqual([
64
64
  ['a', 'b'],
65
65
  ['c', 'd']
@@ -69,275 +69,275 @@ describe('chunk', function () {
69
69
  [true, null]
70
70
  ]);
71
71
  });
72
- it('should handle negative or zero size', function () {
72
+ it('should handle negative or zero size', () => {
73
73
  expect(chunk([1, 2, 3, 4], 0)).toEqual([]);
74
74
  expect(chunk([1, 2, 3, 4], -1)).toEqual([]);
75
75
  });
76
76
  });
77
- describe('isValidIndex', function () {
78
- it('should return true for valid indices', function () {
79
- var arr = [1, 2, 3, 4, 5];
77
+ describe('isValidIndex', () => {
78
+ it('should return true for valid indices', () => {
79
+ const arr = [1, 2, 3, 4, 5];
80
80
  expect(isValidIndex(0, arr)).toBe(true);
81
81
  expect(isValidIndex(2, arr)).toBe(true);
82
82
  expect(isValidIndex(4, arr)).toBe(true);
83
83
  });
84
- it('should return false for indices outside the array bounds', function () {
85
- var arr = [1, 2, 3, 4, 5];
84
+ it('should return false for indices outside the array bounds', () => {
85
+ const arr = [1, 2, 3, 4, 5];
86
86
  expect(isValidIndex(-1, arr)).toBe(false);
87
87
  expect(isValidIndex(5, arr)).toBe(false);
88
88
  expect(isValidIndex(10, arr)).toBe(false);
89
89
  });
90
- it('should return false for negative indices', function () {
91
- var arr = [1, 2, 3, 4, 5];
90
+ it('should return false for negative indices', () => {
91
+ const arr = [1, 2, 3, 4, 5];
92
92
  expect(isValidIndex(-1, arr)).toBe(false);
93
93
  expect(isValidIndex(-5, arr)).toBe(false);
94
94
  });
95
- it('should return true for an empty array and index 0', function () {
96
- var arr = [];
95
+ it('should return true for an empty array and index 0', () => {
96
+ const arr = [];
97
97
  expect(isValidIndex(0, arr)).toBe(false);
98
98
  });
99
- it('should work with arrays of different types', function () {
100
- var arr = ['a', 'b', 'c', 'd'];
99
+ it('should work with arrays of different types', () => {
100
+ const arr = ['a', 'b', 'c', 'd'];
101
101
  expect(isValidIndex(0, arr)).toBe(true);
102
102
  expect(isValidIndex(3, arr)).toBe(true);
103
103
  expect(isValidIndex(4, arr)).toBe(false);
104
104
  });
105
105
  });
106
- describe('next', function () {
107
- var testArray = ['a', 'b', 'c', 'd'];
108
- it('returns the next element in the array', function () {
106
+ describe('next', () => {
107
+ const testArray = ['a', 'b', 'c', 'd'];
108
+ it('returns the next element in the array', () => {
109
109
  expect(next(testArray, 0)).toBe('b');
110
110
  expect(next(testArray, 1)).toBe('c');
111
111
  expect(next(testArray, 2)).toBe('d');
112
112
  });
113
- it('loops to the beginning of the array when reaching the end (default behavior)', function () {
113
+ it('loops to the beginning of the array when reaching the end (default behavior)', () => {
114
114
  expect(next(testArray, 3)).toBe('a');
115
115
  });
116
- it('returns undefined when loop is false and at the end of the array', function () {
116
+ it('returns undefined when loop is false and at the end of the array', () => {
117
117
  expect(next(testArray, 3, false)).toBeUndefined();
118
118
  });
119
- it('works with arrays of different types', function () {
120
- var numberArray = [1, 2, 3, 4];
119
+ it('works with arrays of different types', () => {
120
+ const numberArray = [1, 2, 3, 4];
121
121
  expect(next(numberArray, 1)).toBe(3);
122
- var objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
122
+ const objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
123
123
  expect(next(objectArray, 0)).toEqual({ id: 2 });
124
124
  });
125
- it('handles arrays with one element', function () {
126
- var singleElementArray = ['solo'];
125
+ it('handles arrays with one element', () => {
126
+ const singleElementArray = ['solo'];
127
127
  expect(next(singleElementArray, 0)).toEqual('solo');
128
128
  expect(next(singleElementArray, 0, false)).toEqual('solo');
129
129
  });
130
- it('returns undefined for empty arrays', function () {
131
- var emptyArray = [];
130
+ it('returns undefined for empty arrays', () => {
131
+ const emptyArray = [];
132
132
  expect(next(emptyArray, 0)).toBeUndefined();
133
133
  });
134
- it('returns undefined for out-of-bounds indices', function () {
134
+ it('returns undefined for out-of-bounds indices', () => {
135
135
  expect(next(testArray, 4)).toBeUndefined();
136
136
  expect(next(testArray, -1)).toBeUndefined();
137
137
  });
138
- it('returns undefined for negative indices', function () {
138
+ it('returns undefined for negative indices', () => {
139
139
  expect(next(testArray, -1)).toBeUndefined();
140
140
  });
141
- it('returns undefined for indices equal to or greater than array length', function () {
141
+ it('returns undefined for indices equal to or greater than array length', () => {
142
142
  expect(next(testArray, 4)).toBeUndefined();
143
143
  expect(next(testArray, 5)).toBeUndefined();
144
144
  });
145
145
  });
146
- describe('prev', function () {
147
- var testArray = ['a', 'b', 'c', 'd'];
148
- it('returns the previous element in the array', function () {
146
+ describe('prev', () => {
147
+ const testArray = ['a', 'b', 'c', 'd'];
148
+ it('returns the previous element in the array', () => {
149
149
  expect(prev(testArray, 1)).toBe('a');
150
150
  expect(prev(testArray, 2)).toBe('b');
151
151
  expect(prev(testArray, 3)).toBe('c');
152
152
  });
153
- it('loops to the end of the array when at the beginning (default behavior)', function () {
153
+ it('loops to the end of the array when at the beginning (default behavior)', () => {
154
154
  expect(prev(testArray, 0)).toBe('d');
155
155
  });
156
- it('returns undefined when loop is false and at the beginning of the array', function () {
156
+ it('returns undefined when loop is false and at the beginning of the array', () => {
157
157
  expect(prev(testArray, 0, false)).toBeUndefined();
158
158
  });
159
- it('works with arrays of different types', function () {
160
- var numberArray = [1, 2, 3, 4];
159
+ it('works with arrays of different types', () => {
160
+ const numberArray = [1, 2, 3, 4];
161
161
  expect(prev(numberArray, 2)).toBe(2);
162
- var objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
162
+ const objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
163
163
  expect(prev(objectArray, 1)).toEqual({ id: 1 });
164
164
  });
165
- it('handles arrays with one element', function () {
166
- var singleElementArray = ['solo'];
165
+ it('handles arrays with one element', () => {
166
+ const singleElementArray = ['solo'];
167
167
  expect(prev(singleElementArray, 0)).toBe('solo');
168
168
  expect(prev(singleElementArray, 0, false)).toBe('solo');
169
169
  });
170
- it('returns undefined for empty arrays', function () {
171
- var emptyArray = [];
170
+ it('returns undefined for empty arrays', () => {
171
+ const emptyArray = [];
172
172
  expect(prev(emptyArray, 0)).toBeUndefined();
173
173
  });
174
- it('returns undefined for out-of-bounds indices', function () {
174
+ it('returns undefined for out-of-bounds indices', () => {
175
175
  expect(prev(testArray, 4)).toBeUndefined();
176
176
  expect(prev(testArray, -1)).toBeUndefined();
177
177
  });
178
- it('returns undefined for negative indices', function () {
178
+ it('returns undefined for negative indices', () => {
179
179
  expect(prev(testArray, -1)).toBeUndefined();
180
180
  });
181
- it('returns undefined for indices equal to or greater than array length', function () {
181
+ it('returns undefined for indices equal to or greater than array length', () => {
182
182
  expect(prev(testArray, 4)).toBeUndefined();
183
183
  expect(prev(testArray, 5)).toBeUndefined();
184
184
  });
185
- it('returns undefined for indices other than 0 in single-element arrays', function () {
186
- var singleElementArray = ['solo'];
185
+ it('returns undefined for indices other than 0 in single-element arrays', () => {
186
+ const singleElementArray = ['solo'];
187
187
  expect(prev(singleElementArray, 1)).toBeUndefined();
188
188
  expect(prev(singleElementArray, -1)).toBeUndefined();
189
189
  });
190
190
  });
191
- describe('forward function', function () {
192
- var testArray = ['a', 'b', 'c', 'd', 'e'];
193
- it('returns the element at the target index when within bounds', function () {
191
+ describe('forward function', () => {
192
+ const testArray = ['a', 'b', 'c', 'd', 'e'];
193
+ it('returns the element at the target index when within bounds', () => {
194
194
  expect(forward(testArray, 0, 2)).toBe('c');
195
195
  expect(forward(testArray, 1, 1)).toBe('c');
196
196
  expect(forward(testArray, 2, 2)).toBe('e');
197
197
  });
198
- it('wraps around the array when looping is enabled and target index is out of bounds', function () {
198
+ it('wraps around the array when looping is enabled and target index is out of bounds', () => {
199
199
  expect(forward(testArray, 3, 2)).toBe('a');
200
200
  expect(forward(testArray, 4, 1)).toBe('a');
201
201
  expect(forward(testArray, 0, 5)).toBe('a');
202
202
  expect(forward(testArray, 0, 7)).toBe('c');
203
203
  });
204
- it('returns the first or last element when looping is disabled and target index is out of bounds', function () {
204
+ it('returns the first or last element when looping is disabled and target index is out of bounds', () => {
205
205
  expect(forward(testArray, 3, 2, false)).toBe('e');
206
206
  expect(forward(testArray, 4, 1, false)).toBe('e');
207
207
  expect(forward(testArray, 0, 5, false)).toBe('e');
208
208
  expect(forward(testArray, 2, -3, false)).toBe('a');
209
209
  });
210
- it('handles zero increment', function () {
210
+ it('handles zero increment', () => {
211
211
  expect(forward(testArray, 2, 0)).toBe('c');
212
212
  expect(forward(testArray, 4, 0)).toBe('e');
213
213
  });
214
- it('works with arrays of different types', function () {
215
- var numberArray = [1, 2, 3, 4, 5];
214
+ it('works with arrays of different types', () => {
215
+ const numberArray = [1, 2, 3, 4, 5];
216
216
  expect(forward(numberArray, 1, 2)).toBe(4);
217
- var objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
217
+ const objectArray = [{ id: 1 }, { id: 2 }, { id: 3 }];
218
218
  expect(forward(objectArray, 0, 1)).toEqual({ id: 2 });
219
219
  });
220
- it('handles single-element arrays', function () {
221
- var singleElementArray = ['solo'];
220
+ it('handles single-element arrays', () => {
221
+ const singleElementArray = ['solo'];
222
222
  expect(forward(singleElementArray, 0, 1)).toBe('solo');
223
223
  expect(forward(singleElementArray, 0, 5)).toBe('solo');
224
224
  expect(forward(singleElementArray, 0, -1)).toBe('solo');
225
225
  });
226
- it('handles negative increments', function () {
226
+ it('handles negative increments', () => {
227
227
  expect(forward(testArray, 3, -1)).toBe('c');
228
228
  expect(forward(testArray, 4, -2)).toBe('c');
229
229
  expect(forward(testArray, 1, -1)).toBe('a'); // Correctly wraps to the end
230
230
  expect(forward(testArray, 0, -1)).toBe('e'); // Wraps to the last element
231
231
  });
232
- it('handles negative increments with looping disabled', function () {
232
+ it('handles negative increments with looping disabled', () => {
233
233
  expect(forward(testArray, 3, -1, false)).toBe('c');
234
234
  expect(forward(testArray, 4, -2, false)).toBe('c');
235
235
  expect(forward(testArray, 1, -2, false)).toBe('a'); // Returns first element
236
236
  expect(forward(testArray, 4, -5, false)).toBe('a'); // Returns first element
237
237
  });
238
- it('returns undefined for empty arrays', function () {
239
- var emptyArray = [];
238
+ it('returns undefined for empty arrays', () => {
239
+ const emptyArray = [];
240
240
  expect(forward(emptyArray, 0, 1)).toBeUndefined();
241
241
  });
242
- it('returns undefined for out-of-bounds initial indices', function () {
242
+ it('returns undefined for out-of-bounds initial indices', () => {
243
243
  expect(forward(testArray, -1, 1)).toBeUndefined();
244
244
  expect(forward(testArray, 5, 1)).toBeUndefined();
245
245
  });
246
- it('handles large positive and negative increments', function () {
246
+ it('handles large positive and negative increments', () => {
247
247
  expect(forward(testArray, 0, 15)).toBe('a'); // Loops around 3 times
248
248
  expect(forward(testArray, 0, -15)).toBe('a'); // Loops around -3 times
249
249
  expect(forward(testArray, 0, 15, false)).toBe('e');
250
250
  expect(forward(testArray, 0, -15, false)).toBe('a');
251
251
  });
252
252
  });
253
- describe('backward function', function () {
254
- var testArray = [1, 2, 3, 4, 5];
255
- it('should return the correct element when moving backward', function () {
253
+ describe('backward function', () => {
254
+ const testArray = [1, 2, 3, 4, 5];
255
+ it('should return the correct element when moving backward', () => {
256
256
  expect(backward(testArray, 2, 1)).toBe(2);
257
257
  expect(backward(testArray, 4, 2)).toBe(3);
258
258
  });
259
- it('should wrap around the array when looping is enabled', function () {
259
+ it('should wrap around the array when looping is enabled', () => {
260
260
  expect(backward(testArray, 0, 1)).toBe(5);
261
261
  expect(backward(testArray, 1, 3)).toBe(4);
262
262
  });
263
- it('should clamp to array bounds when looping is disabled', function () {
263
+ it('should clamp to array bounds when looping is disabled', () => {
264
264
  expect(backward(testArray, 0, 1, false)).toBe(1);
265
265
  expect(backward(testArray, 1, 3, false)).toBe(1);
266
266
  });
267
- it('should handle negative decrements (moving forward)', function () {
267
+ it('should handle negative decrements (moving forward)', () => {
268
268
  expect(backward(testArray, 2, -1)).toBe(4);
269
269
  expect(backward(testArray, 4, -2)).toBe(2);
270
270
  });
271
- it('should return undefined for empty arrays', function () {
271
+ it('should return undefined for empty arrays', () => {
272
272
  expect(backward([], 0, 1)).toBeUndefined();
273
273
  });
274
- it('should return undefined for out-of-bounds initial indices', function () {
274
+ it('should return undefined for out-of-bounds initial indices', () => {
275
275
  expect(backward(testArray, -1, 1)).toBeUndefined();
276
276
  expect(backward(testArray, 5, 1)).toBeUndefined();
277
277
  });
278
- it('should handle large decrements', function () {
278
+ it('should handle large decrements', () => {
279
279
  expect(backward(testArray, 4, 10)).toBe(5);
280
280
  expect(backward(testArray, 4, 11)).toBe(4);
281
281
  });
282
282
  });
283
- describe('getNextMatch', function () {
284
- var values = ['apple', 'banana', 'cherry', 'date', 'elderberry'];
285
- it('should return the first match when no current match is provided', function () {
283
+ describe('getNextMatch', () => {
284
+ const values = ['apple', 'banana', 'cherry', 'date', 'elderberry'];
285
+ it('should return the first match when no current match is provided', () => {
286
286
  expect(getNextMatch(values, 'b')).toBe('banana');
287
287
  });
288
- it('should return the next match when a current match is provided', function () {
288
+ it('should return the next match when a current match is provided', () => {
289
289
  expect(getNextMatch(values, 'c', 'cherry')).toBe(undefined);
290
290
  expect(getNextMatch(values, 'c', 'banana')).toBe('cherry');
291
291
  });
292
- it('should handle repeated characters in search', function () {
292
+ it('should handle repeated characters in search', () => {
293
293
  expect(getNextMatch(values, 'aaa', 'apple')).toBe(undefined);
294
294
  expect(getNextMatch(values, 'aaa', 'banana')).toBe('apple');
295
295
  });
296
- it('should wrap around the array when reaching the end', function () {
296
+ it('should wrap around the array when reaching the end', () => {
297
297
  expect(getNextMatch(values, 'd', 'date')).toBe(undefined);
298
298
  expect(getNextMatch(values, 'a', 'elderberry')).toBe('apple');
299
299
  });
300
- it('should be case-insensitive', function () {
300
+ it('should be case-insensitive', () => {
301
301
  expect(getNextMatch(values, 'B', 'apple')).toBe('banana');
302
302
  expect(getNextMatch(values, 'cH', 'banana')).toBe('cherry');
303
303
  });
304
- it('should handle empty search string', function () {
304
+ it('should handle empty search string', () => {
305
305
  expect(getNextMatch(values, '', 'banana')).toBe(undefined);
306
306
  });
307
- it('should handle empty values array', function () {
307
+ it('should handle empty values array', () => {
308
308
  expect(getNextMatch([], 'a')).toBe(undefined);
309
309
  });
310
- it('should exclude current match when search is a single character', function () {
310
+ it('should exclude current match when search is a single character', () => {
311
311
  expect(getNextMatch(values, 'a', 'apple')).toBe(undefined);
312
312
  expect(getNextMatch(values, 'b', 'banana')).toBe(undefined);
313
313
  });
314
- it('should not exclude current match when search is multiple characters', function () {
314
+ it('should not exclude current match when search is multiple characters', () => {
315
315
  expect(getNextMatch(values, 'ap', 'apple')).toBe(undefined);
316
316
  expect(getNextMatch(values, 'ba', 'banana')).toBe(undefined);
317
317
  });
318
- it('should handle values with common prefixes', function () {
319
- var prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
318
+ it('should handle values with common prefixes', () => {
319
+ const prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
320
320
  expect(getNextMatch(prefixValues, 'pre', 'prefix1')).toBe(undefined);
321
321
  expect(getNextMatch(prefixValues, 'pre', 'prefix2')).toBe(undefined);
322
322
  expect(getNextMatch(prefixValues, 'pre', 'prefix3')).toBe(undefined);
323
323
  expect(getNextMatch(prefixValues, 'pre', 'other')).toBe('prefix1');
324
324
  });
325
- it('should cycle through values with common prefixes using single character search', function () {
326
- var prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
325
+ it('should cycle through values with common prefixes using single character search', () => {
326
+ const prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
327
327
  expect(getNextMatch(prefixValues, 'p', 'other')).toBe('prefix1');
328
328
  expect(getNextMatch(prefixValues, 'p', 'prefix1')).toBe('prefix2');
329
329
  expect(getNextMatch(prefixValues, 'p', 'prefix2')).toBe('prefix3');
330
330
  expect(getNextMatch(prefixValues, 'p', 'prefix3')).toBe('prefix1');
331
331
  });
332
- it('should handle single character search with prefixed values', function () {
333
- var prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
332
+ it('should handle single character search with prefixed values', () => {
333
+ const prefixValues = ['prefix1', 'prefix2', 'prefix3', 'other'];
334
334
  expect(getNextMatch(prefixValues, 'p')).toBe('prefix1');
335
335
  expect(getNextMatch(prefixValues, 'p', 'prefix1')).toBe('prefix2');
336
336
  expect(getNextMatch(prefixValues, 'o')).toBe('other');
337
337
  expect(getNextMatch(prefixValues, 'o', 'other')).toBe(undefined);
338
338
  });
339
- it('should handle search with spaces', function () {
340
- var spaceValues = ['apple pie', 'banana split', 'banana bread', 'cherry tart'];
339
+ it('should handle search with spaces', () => {
340
+ const spaceValues = ['apple pie', 'banana split', 'banana bread', 'cherry tart'];
341
341
  expect(getNextMatch(spaceValues, 'b')).toBe('banana split');
342
342
  expect(getNextMatch(spaceValues, 'banana ')).toBe('banana split');
343
343
  expect(getNextMatch(spaceValues, 'banana b')).toBe('banana bread');
@@ -347,20 +347,20 @@ describe('getNextMatch', function () {
347
347
  expect(getNextMatch(spaceValues, 'apple p')).toBe('apple pie');
348
348
  });
349
349
  });
350
- describe('wrapArray', function () {
351
- it('should wrap the array starting from the given index', function () {
350
+ describe('wrapArray', () => {
351
+ it('should wrap the array starting from the given index', () => {
352
352
  expect(wrapArray(['a', 'b', 'c', 'd'], 2)).toEqual(['c', 'd', 'a', 'b']);
353
353
  });
354
- it('should handle start index 0 (no wrapping)', function () {
354
+ it('should handle start index 0 (no wrapping)', () => {
355
355
  expect(wrapArray([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);
356
356
  });
357
- it('should wrap correctly with start index equal to array length', function () {
357
+ it('should wrap correctly with start index equal to array length', () => {
358
358
  expect(wrapArray(['x', 'y', 'z'], 3)).toEqual(['x', 'y', 'z']);
359
359
  });
360
- it('should work with empty array', function () {
360
+ it('should work with empty array', () => {
361
361
  expect(wrapArray([], 2)).toEqual([]);
362
362
  });
363
- it('should work with array of different types', function () {
363
+ it('should work with array of different types', () => {
364
364
  expect(wrapArray([true, 42, 'test'], 1)).toEqual([42, 'test', true]);
365
365
  });
366
366
  });
@@ -6,24 +6,22 @@ import { noop } from './noop.js';
6
6
  * @param defaultValue The value which will be set.
7
7
  * @param afterMs A zero-or-greater delay in milliseconds.
8
8
  */
9
- export function boxAutoReset(defaultValue, afterMs, onChange) {
10
- if (afterMs === void 0) { afterMs = 10000; }
11
- if (onChange === void 0) { onChange = noop; }
12
- var timeout = null;
13
- var value = $state(defaultValue);
9
+ export function boxAutoReset(defaultValue, afterMs = 10000, onChange = noop) {
10
+ let timeout = null;
11
+ let value = $state(defaultValue);
14
12
  function resetAfter() {
15
- return window.setTimeout(function () {
13
+ return window.setTimeout(() => {
16
14
  value = defaultValue;
17
15
  onChange(defaultValue);
18
16
  }, afterMs);
19
17
  }
20
- $effect(function () {
21
- return function () {
18
+ $effect(() => {
19
+ return () => {
22
20
  if (timeout)
23
21
  clearTimeout(timeout);
24
22
  };
25
23
  });
26
- return box.with(function () { return value; }, function (v) {
24
+ return box.with(() => value, (v) => {
27
25
  value = v;
28
26
  onChange(v);
29
27
  if (timeout)
@@ -1,25 +1,24 @@
1
1
  import { untrack } from 'svelte';
2
- export function watch(box, callback, options) {
3
- if (options === void 0) { options = {}; }
4
- var prev = $state(box.current);
5
- var ranOnce = false;
6
- var watchEffect = $effect.root(function () {
7
- $effect.pre(function () {
2
+ export function watch(box, callback, options = {}) {
3
+ let prev = $state(box.current);
4
+ let ranOnce = false;
5
+ const watchEffect = $effect.root(() => {
6
+ $effect.pre(() => {
8
7
  if (prev === box.current || !options.immediate)
9
8
  return;
10
9
  if (options.once && ranOnce)
11
10
  return;
12
- callback(box.current, untrack(function () { return prev; }));
13
- untrack(function () { return (prev = box.current); });
11
+ callback(box.current, untrack(() => prev));
12
+ untrack(() => (prev = box.current));
14
13
  ranOnce = true;
15
14
  });
16
- $effect(function () {
15
+ $effect(() => {
17
16
  if (prev === box.current || options.immediate)
18
17
  return;
19
18
  if (options.once && ranOnce)
20
19
  return;
21
- callback(box.current, untrack(function () { return prev; }));
22
- untrack(function () { return (prev = box.current); });
20
+ callback(box.current, untrack(() => prev));
21
+ untrack(() => (prev = box.current));
23
22
  ranOnce = true;
24
23
  });
25
24
  });
@@ -1,29 +1,29 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { clamp } from './clamp.js';
3
- describe('clamp', function () {
4
- it('should return the number if it is within the range', function () {
3
+ describe('clamp', () => {
4
+ it('should return the number if it is within the range', () => {
5
5
  expect(clamp(5, 0, 10)).toBe(5);
6
6
  expect(clamp(0, 0, 10)).toBe(0);
7
7
  expect(clamp(10, 0, 10)).toBe(10);
8
8
  });
9
- it('should return the minimum value if the number is below the range', function () {
9
+ it('should return the minimum value if the number is below the range', () => {
10
10
  expect(clamp(-5, 0, 10)).toBe(0);
11
11
  expect(clamp(-10, -5, 5)).toBe(-5);
12
12
  });
13
- it('should return the maximum value if the number is above the range', function () {
13
+ it('should return the maximum value if the number is above the range', () => {
14
14
  expect(clamp(15, 0, 10)).toBe(10);
15
15
  expect(clamp(20, -5, 5)).toBe(5);
16
16
  });
17
- it('should handle equal minimum and maximum values', function () {
17
+ it('should handle equal minimum and maximum values', () => {
18
18
  expect(clamp(5, 10, 10)).toBe(10);
19
19
  expect(clamp(15, 10, 10)).toBe(10);
20
20
  });
21
- it('should handle negative minimum and maximum values', function () {
21
+ it('should handle negative minimum and maximum values', () => {
22
22
  expect(clamp(-15, -20, -10)).toBe(-15);
23
23
  expect(clamp(-25, -20, -10)).toBe(-20);
24
24
  expect(clamp(-5, -20, -10)).toBe(-10);
25
25
  });
26
- it('should handle decimal values', function () {
26
+ it('should handle decimal values', () => {
27
27
  expect(clamp(3.5, 1.2, 7.8)).toBe(3.5);
28
28
  expect(clamp(0.5, 1.2, 7.8)).toBe(1.2);
29
29
  expect(clamp(9.5, 1.2, 7.8)).toBe(7.8);
@@ -1,33 +1,29 @@
1
1
  import { executeCallbacks } from 'svelte-toolbelt';
2
2
  export function createEventHook() {
3
- var callbacks = new Set();
4
- var callbacksToDispose = [];
3
+ const callbacks = new Set();
4
+ const callbacksToDispose = [];
5
5
  function off(cb) {
6
6
  callbacks.delete(cb);
7
7
  }
8
8
  function on(cb) {
9
9
  callbacks.add(cb);
10
- var offFn = function () { return off(cb); };
10
+ const offFn = () => off(cb);
11
11
  callbacksToDispose.push(offFn);
12
12
  return { off: offFn };
13
13
  }
14
- var trigger = function () {
15
- var args = [];
16
- for (var _i = 0; _i < arguments.length; _i++) {
17
- args[_i] = arguments[_i];
18
- }
19
- return Promise.all(Array.from(callbacks).map(function (cb) {
20
- return Promise.resolve(cb.apply(void 0, args));
14
+ const trigger = (...args) => {
15
+ return Promise.all(Array.from(callbacks).map((cb) => {
16
+ return Promise.resolve(cb(...args));
21
17
  }));
22
18
  };
23
- $effect(function () {
24
- return function () {
19
+ $effect(() => {
20
+ return () => {
25
21
  executeCallbacks(callbacksToDispose);
26
22
  };
27
23
  });
28
24
  return {
29
- on: on,
30
- off: off,
31
- trigger: trigger
25
+ on,
26
+ off,
27
+ trigger
32
28
  };
33
29
  }