@sit-onyx/headless 1.0.0-beta.21 → 1.0.0-beta.23

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 (86) hide show
  1. package/dist/composables/comboBox/SelectOnlyCombobox.d.vue.ts +299 -0
  2. package/dist/composables/comboBox/TestCombobox.ct.d.ts +1 -0
  3. package/dist/composables/comboBox/TestCombobox.d.vue.ts +299 -0
  4. package/dist/composables/comboBox/createComboBox.d.ts +370 -0
  5. package/dist/composables/comboBox/createComboBox.testing.d.ts +10 -0
  6. package/dist/composables/helpers/useDismissible.d.ts +10 -0
  7. package/dist/composables/helpers/useGlobalListener.d.ts +10 -0
  8. package/dist/composables/helpers/useGlobalListener.spec.d.ts +1 -0
  9. package/dist/composables/helpers/useOutsideClick.d.ts +26 -0
  10. package/dist/composables/helpers/useOutsideClick.spec.d.ts +1 -0
  11. package/dist/composables/helpers/useTypeAhead.d.ts +11 -0
  12. package/dist/composables/helpers/useTypeAhead.spec.d.ts +1 -0
  13. package/dist/composables/listbox/TestListbox.ct.d.ts +1 -0
  14. package/dist/composables/listbox/TestListbox.d.vue.ts +2 -0
  15. package/dist/composables/listbox/createListbox.d.ts +102 -0
  16. package/dist/composables/listbox/createListbox.testing.d.ts +24 -0
  17. package/dist/composables/menuButton/TestMenuButton.ct.d.ts +1 -0
  18. package/dist/composables/menuButton/TestMenuButton.d.vue.ts +2 -0
  19. package/dist/composables/menuButton/createMenuButton.d.ts +78 -0
  20. package/dist/composables/menuButton/createMenuButton.testing.d.ts +24 -0
  21. package/dist/composables/navigationMenu/TestMenu.ct.d.ts +1 -0
  22. package/dist/composables/navigationMenu/TestMenu.d.vue.ts +2 -0
  23. package/dist/composables/navigationMenu/createMenu.d.ts +21 -0
  24. package/dist/composables/navigationMenu/createMenu.testing.d.ts +16 -0
  25. package/dist/composables/tabs/TestTabs.ct.d.ts +1 -0
  26. package/dist/composables/tabs/TestTabs.d.vue.ts +2 -0
  27. package/dist/composables/tabs/createTabs.d.ts +48 -0
  28. package/dist/composables/tabs/createTabs.testing.d.ts +13 -0
  29. package/dist/composables/tooltip/createToggletip.d.ts +36 -0
  30. package/dist/composables/tooltip/createTooltip.d.ts +42 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.js +1089 -0
  33. package/dist/playwright.d.ts +5 -0
  34. package/dist/playwright.js +369 -0
  35. package/dist/utils/builder.d.ts +85 -0
  36. package/dist/utils/keyboard.d.ts +26 -0
  37. package/dist/utils/keyboard.spec.d.ts +1 -0
  38. package/dist/utils/math.d.ts +6 -0
  39. package/dist/utils/math.spec.d.ts +1 -0
  40. package/dist/utils/object.d.ts +5 -0
  41. package/dist/utils/object.spec.d.ts +1 -0
  42. package/dist/utils/timer.d.ts +10 -0
  43. package/{src/utils/types.ts → dist/utils/types.d.ts} +4 -12
  44. package/dist/utils/vitest.d.ts +12 -0
  45. package/package.json +18 -9
  46. package/src/composables/comboBox/SelectOnlyCombobox.vue +0 -90
  47. package/src/composables/comboBox/TestCombobox.ct.tsx +0 -24
  48. package/src/composables/comboBox/TestCombobox.vue +0 -84
  49. package/src/composables/comboBox/createComboBox.testing.ts +0 -168
  50. package/src/composables/comboBox/createComboBox.ts +0 -280
  51. package/src/composables/helpers/useDismissible.ts +0 -19
  52. package/src/composables/helpers/useGlobalListener.spec.ts +0 -93
  53. package/src/composables/helpers/useGlobalListener.ts +0 -64
  54. package/src/composables/helpers/useOutsideClick.spec.ts +0 -117
  55. package/src/composables/helpers/useOutsideClick.ts +0 -69
  56. package/src/composables/helpers/useTypeAhead.spec.ts +0 -29
  57. package/src/composables/helpers/useTypeAhead.ts +0 -26
  58. package/src/composables/listbox/TestListbox.ct.tsx +0 -17
  59. package/src/composables/listbox/TestListbox.vue +0 -92
  60. package/src/composables/listbox/createListbox.testing.ts +0 -141
  61. package/src/composables/listbox/createListbox.ts +0 -234
  62. package/src/composables/menuButton/TestMenuButton.ct.tsx +0 -14
  63. package/src/composables/menuButton/TestMenuButton.vue +0 -29
  64. package/src/composables/menuButton/createMenuButton.testing.ts +0 -91
  65. package/src/composables/menuButton/createMenuButton.ts +0 -206
  66. package/src/composables/navigationMenu/TestMenu.ct.tsx +0 -12
  67. package/src/composables/navigationMenu/TestMenu.vue +0 -16
  68. package/src/composables/navigationMenu/createMenu.testing.ts +0 -37
  69. package/src/composables/navigationMenu/createMenu.ts +0 -55
  70. package/src/composables/tabs/TestTabs.ct.tsx +0 -12
  71. package/src/composables/tabs/TestTabs.vue +0 -28
  72. package/src/composables/tabs/createTabs.testing.ts +0 -151
  73. package/src/composables/tabs/createTabs.ts +0 -129
  74. package/src/composables/tooltip/createToggletip.ts +0 -58
  75. package/src/composables/tooltip/createTooltip.ts +0 -71
  76. package/src/index.ts +0 -11
  77. package/src/playwright.ts +0 -5
  78. package/src/utils/builder.ts +0 -135
  79. package/src/utils/keyboard.spec.ts +0 -53
  80. package/src/utils/keyboard.ts +0 -351
  81. package/src/utils/math.spec.ts +0 -14
  82. package/src/utils/math.ts +0 -6
  83. package/src/utils/object.spec.ts +0 -33
  84. package/src/utils/object.ts +0 -8
  85. package/src/utils/timer.ts +0 -22
  86. package/src/utils/vitest.ts +0 -36
@@ -1,351 +0,0 @@
1
- import { isSubsetMatching } from "./object.js";
2
-
3
- export type PressedKey =
4
- | string
5
- | Partial<Pick<KeyboardEvent, "altKey" | "key" | "ctrlKey" | "metaKey" | "shiftKey" | "code">>;
6
-
7
- /**
8
- * Check if a specified key was pressed.
9
- * @param event The KeyboardEvent
10
- * @param key The key, either the [key property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) as a string (e.g. "m")
11
- * or an object with the relevant key parameters, e.g. `{ key: "m", altKey: true }`
12
- * @returns true, if the key was pressed with the specified parameters
13
- */
14
- export const wasKeyPressed = (event: KeyboardEvent, key: PressedKey) => {
15
- if (typeof key === "string") {
16
- return event.key === key;
17
- }
18
- return isSubsetMatching(
19
- { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false, ...key },
20
- event,
21
- );
22
- };
23
-
24
- /**
25
- * Check if the `key` property of a KeyboardEvent is a printable character.
26
- *
27
- * There is no standardized or specified algorithm to check for [named keys](https://www.w3.org/TR/uievents-key/#named-key-attribute-values) vs printable characters.
28
- * For this check we use the provided list provided by the standard, which might be incomplete.
29
- */
30
- export const isPrintableCharacter = (key: string) => !NAMED_KEYS_SET.has(key);
31
-
32
- /**
33
- * Based on https://www.w3.org/TR/uievents-key/#named-key-attribute-values
34
- *
35
- * Extracted using
36
- * ```js
37
- * copy(JSON.stringify([...document.querySelectorAll(".key-table-key")].map(e => e.innerText.replaceAll("\"", ""))));
38
- * ```
39
- */
40
- export const NAMED_KEYS = [
41
- "Unidentified",
42
- "Alt",
43
- "AltGraph",
44
- "CapsLock",
45
- "Control",
46
- "Fn",
47
- "FnLock",
48
- "Meta",
49
- "NumLock",
50
- "ScrollLock",
51
- "Shift",
52
- "Symbol",
53
- "SymbolLock",
54
- "Hyper",
55
- "Super",
56
- "Enter",
57
- "Tab",
58
- "ArrowDown",
59
- "ArrowLeft",
60
- "ArrowRight",
61
- "ArrowUp",
62
- "End",
63
- "Home",
64
- "PageDown",
65
- "PageUp",
66
- "Backspace",
67
- "Clear",
68
- "Copy",
69
- "CrSel",
70
- "Cut",
71
- "Delete",
72
- "EraseEof",
73
- "ExSel",
74
- "Insert",
75
- "Paste",
76
- "Redo",
77
- "Undo",
78
- "Accept",
79
- "Again",
80
- "Attn",
81
- "Cancel",
82
- "ContextMenu",
83
- "Escape",
84
- "Execute",
85
- "Find",
86
- "Help",
87
- "Pause",
88
- "Play",
89
- "Props",
90
- "Select",
91
- "ZoomIn",
92
- "ZoomOut",
93
- "BrightnessDown",
94
- "BrightnessUp",
95
- "Eject",
96
- "LogOff",
97
- "Power",
98
- "PowerOff",
99
- "PrintScreen",
100
- "Hibernate",
101
- "Standby",
102
- "WakeUp",
103
- "AllCandidates",
104
- "Alphanumeric",
105
- "CodeInput",
106
- "Compose",
107
- "Convert",
108
- "Dead",
109
- "FinalMode",
110
- "GroupFirst",
111
- "GroupLast",
112
- "GroupNext",
113
- "GroupPrevious",
114
- "ModeChange",
115
- "NextCandidate",
116
- "NonConvert",
117
- "PreviousCandidate",
118
- "Process",
119
- "SingleCandidate",
120
- "HangulMode",
121
- "HanjaMode",
122
- "JunjaMode",
123
- "Eisu",
124
- "Hankaku",
125
- "Hiragana",
126
- "HiraganaKatakana",
127
- "KanaMode",
128
- "KanjiMode",
129
- "Katakana",
130
- "Romaji",
131
- "Zenkaku",
132
- "ZenkakuHankaku",
133
- "F1",
134
- "F2",
135
- "F3",
136
- "F4",
137
- "F5",
138
- "F6",
139
- "F7",
140
- "F8",
141
- "F9",
142
- "F10",
143
- "F11",
144
- "F12",
145
- "Soft1",
146
- "Soft2",
147
- "Soft3",
148
- "Soft4",
149
- "ChannelDown",
150
- "ChannelUp",
151
- "Close",
152
- "MailForward",
153
- "MailReply",
154
- "MailSend",
155
- "MediaClose",
156
- "MediaFastForward",
157
- "MediaPause",
158
- "MediaPlay",
159
- "MediaPlayPause",
160
- "MediaRecord",
161
- "MediaRewind",
162
- "MediaStop",
163
- "MediaTrackNext",
164
- "MediaTrackPrevious",
165
- "New",
166
- "Open",
167
- "Print",
168
- "Save",
169
- "SpellCheck",
170
- "Key11",
171
- "Key12",
172
- "AudioBalanceLeft",
173
- "AudioBalanceRight",
174
- "AudioBassBoostDown",
175
- "AudioBassBoostToggle",
176
- "AudioBassBoostUp",
177
- "AudioFaderFront",
178
- "AudioFaderRear",
179
- "AudioSurroundModeNext",
180
- "AudioTrebleDown",
181
- "AudioTrebleUp",
182
- "AudioVolumeDown",
183
- "AudioVolumeUp",
184
- "AudioVolumeMute",
185
- "MicrophoneToggle",
186
- "MicrophoneVolumeDown",
187
- "MicrophoneVolumeUp",
188
- "MicrophoneVolumeMute",
189
- "SpeechCorrectionList",
190
- "SpeechInputToggle",
191
- "LaunchApplication1",
192
- "LaunchApplication2",
193
- "LaunchCalendar",
194
- "LaunchContacts",
195
- "LaunchMail",
196
- "LaunchMediaPlayer",
197
- "LaunchMusicPlayer",
198
- "LaunchPhone",
199
- "LaunchScreenSaver",
200
- "LaunchSpreadsheet",
201
- "LaunchWebBrowser",
202
- "LaunchWebCam",
203
- "LaunchWordProcessor",
204
- "BrowserBack",
205
- "BrowserFavorites",
206
- "BrowserForward",
207
- "BrowserHome",
208
- "BrowserRefresh",
209
- "BrowserSearch",
210
- "BrowserStop",
211
- "AppSwitch",
212
- "Call",
213
- "Camera",
214
- "CameraFocus",
215
- "EndCall",
216
- "GoBack",
217
- "GoHome",
218
- "HeadsetHook",
219
- "LastNumberRedial",
220
- "Notification",
221
- "MannerMode",
222
- "VoiceDial",
223
- "TV",
224
- "TV3DMode",
225
- "TVAntennaCable",
226
- "TVAudioDescription",
227
- "TVAudioDescriptionMixDown",
228
- "TVAudioDescriptionMixUp",
229
- "TVContentsMenu",
230
- "TVDataService",
231
- "TVInput",
232
- "TVInputComponent1",
233
- "TVInputComponent2",
234
- "TVInputComposite1",
235
- "TVInputComposite2",
236
- "TVInputHDMI1",
237
- "TVInputHDMI2",
238
- "TVInputHDMI3",
239
- "TVInputHDMI4",
240
- "TVInputVGA1",
241
- "TVMediaContext",
242
- "TVNetwork",
243
- "TVNumberEntry",
244
- "TVPower",
245
- "TVRadioService",
246
- "TVSatellite",
247
- "TVSatelliteBS",
248
- "TVSatelliteCS",
249
- "TVSatelliteToggle",
250
- "TVTerrestrialAnalog",
251
- "TVTerrestrialDigital",
252
- "TVTimer",
253
- "AVRInput",
254
- "AVRPower",
255
- "ColorF0Red",
256
- "ColorF1Green",
257
- "ColorF2Yellow",
258
- "ColorF3Blue",
259
- "ColorF4Grey",
260
- "ColorF5Brown",
261
- "ClosedCaptionToggle",
262
- "Dimmer",
263
- "DisplaySwap",
264
- "DVR",
265
- "Exit",
266
- "FavoriteClear0",
267
- "FavoriteClear1",
268
- "FavoriteClear2",
269
- "FavoriteClear3",
270
- "FavoriteRecall0",
271
- "FavoriteRecall1",
272
- "FavoriteRecall2",
273
- "FavoriteRecall3",
274
- "FavoriteStore0",
275
- "FavoriteStore1",
276
- "FavoriteStore2",
277
- "FavoriteStore3",
278
- "Guide",
279
- "GuideNextDay",
280
- "GuidePreviousDay",
281
- "Info",
282
- "InstantReplay",
283
- "Link",
284
- "ListProgram",
285
- "LiveContent",
286
- "Lock",
287
- "MediaApps",
288
- "MediaAudioTrack",
289
- "MediaLast",
290
- "MediaSkipBackward",
291
- "MediaSkipForward",
292
- "MediaStepBackward",
293
- "MediaStepForward",
294
- "MediaTopMenu",
295
- "NavigateIn",
296
- "NavigateNext",
297
- "NavigateOut",
298
- "NavigatePrevious",
299
- "NextFavoriteChannel",
300
- "NextUserProfile",
301
- "OnDemand",
302
- "Pairing",
303
- "PinPDown",
304
- "PinPMove",
305
- "PinPToggle",
306
- "PinPUp",
307
- "PlaySpeedDown",
308
- "PlaySpeedReset",
309
- "PlaySpeedUp",
310
- "RandomToggle",
311
- "RcLowBattery",
312
- "RecordSpeedNext",
313
- "RfBypass",
314
- "ScanChannelsToggle",
315
- "ScreenModeNext",
316
- "Settings",
317
- "SplitScreenToggle",
318
- "STBInput",
319
- "STBPower",
320
- "Subtitle",
321
- "Teletext",
322
- "VideoModeNext",
323
- "Wink",
324
- "ZoomToggle",
325
- "AudioVolumeDown",
326
- "AudioVolumeUp",
327
- "AudioVolumeMute",
328
- "BrowserBack",
329
- "BrowserForward",
330
- "ChannelDown",
331
- "ChannelUp",
332
- "ContextMenu",
333
- "Eject",
334
- "End",
335
- "Enter",
336
- "Home",
337
- "MediaFastForward",
338
- "MediaPlay",
339
- "MediaPlayPause",
340
- "MediaRecord",
341
- "MediaRewind",
342
- "MediaStop",
343
- "MediaNextTrack",
344
- "MediaPause",
345
- "MediaPreviousTrack",
346
- "Power",
347
- "Unidentified",
348
- ] as const;
349
-
350
- // Create a Set, which is easier and faster to use.
351
- export const NAMED_KEYS_SET = new Set<string>(NAMED_KEYS);
@@ -1,14 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { MathUtils } from "./math.js";
3
-
4
- describe("MathUtils.clamp", () => {
5
- test.each([
6
- { number: 1, min: 1, max: 2, result: 1 },
7
- { number: 1, min: 2, max: 2, result: 2 },
8
- { number: 1, min: 0, max: 0, result: 0 },
9
- { number: 1, min: 1, max: 1, result: 1 },
10
- ])(
11
- "should return $result for key number:$number min:$min max:$max",
12
- ({ number, min, max, result }) => expect(MathUtils.clamp(number, min, max)).toBe(result),
13
- );
14
- });
package/src/utils/math.ts DELETED
@@ -1,6 +0,0 @@
1
- export const MathUtils = {
2
- /**
3
- * Ensures that a given `number` is or is between a given `min` and `max`.
4
- */
5
- clamp: (number: number, min: number, max: number) => Math.max(Math.min(number, max), min),
6
- };
@@ -1,33 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { isSubsetMatching } from "./object.js";
3
-
4
- const referenceObj = { a: 42, b: "foo", c: null, d: true };
5
-
6
- test.each([
7
- // ARRANGE
8
- { label: "with the same key-values", compareObj: { ...referenceObj } },
9
- {
10
- label: "with additional key-values in compared object",
11
- compareObj: { d: true, b: "foo", c: null, a: 42, f: 23 },
12
- },
13
- { label: "with undefined keys", compareObj: { ...referenceObj, e: undefined } },
14
- ])("should return true for objects $label", ({ compareObj }) => {
15
- // ACT
16
- const result = isSubsetMatching(referenceObj, compareObj);
17
-
18
- // ASSERT
19
- expect(result).toBeTruthy();
20
- });
21
-
22
- test.each([
23
- // ARRANGE
24
- { label: "only having a single entry", compareObj: { foo: 42 } },
25
- { label: "a value", compareObj: { ...referenceObj, a: 0 } },
26
- { label: "a value", compareObj: { ...referenceObj, a: undefined } },
27
- ])("should return false when objects differ by $label", ({ compareObj }) => {
28
- // ACT
29
- const result = isSubsetMatching(referenceObj, compareObj);
30
-
31
- // ASSERT
32
- expect(result).toBeFalsy();
33
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if every entry of a subset exists and matches the entry of a target object.
3
- * @returns `true`, if target contains the subset
4
- */
5
- export const isSubsetMatching = (subset: object, target: object) =>
6
- Object.entries(subset).every(
7
- ([key, value]) => (target as Record<string, unknown>)[key] === value,
8
- );
@@ -1,22 +0,0 @@
1
- import { toValue, type MaybeRefOrGetter } from "vue";
2
-
3
- /**
4
- * Debounces a given callback which will only be called when not called for the given timeout.
5
- *
6
- * @returns Callback to reset the debounce timer.
7
- */
8
- export const debounce = <TArgs extends unknown[]>(
9
- handler: (...args: TArgs) => void,
10
- timeout: MaybeRefOrGetter<number>,
11
- ) => {
12
- let timer: ReturnType<typeof setTimeout> | undefined;
13
-
14
- const func = (...lastArgs: TArgs) => {
15
- clearTimeout(timer);
16
- timer = setTimeout(() => handler(...lastArgs), toValue(timeout));
17
- };
18
- /** Abort the currently debounced action, if any. */
19
- func.abort = () => clearTimeout(timer);
20
-
21
- return func;
22
- };
@@ -1,36 +0,0 @@
1
- import { vi } from "vitest";
2
-
3
- type Callback = () => void | (() => Promise<void>);
4
-
5
- /**
6
- * Mocks the following vue lifecycle functions:
7
- * - onBeforeMount
8
- * - onMounted
9
- * - onBeforeUnmount
10
- * - onUnmounted
11
- *
12
- * `onBeforeMount` and `onMounted` callbacks are executed immediately.
13
- * `onBeforeUnmount` and `onUnmounted` are executed when the returned callback is run.
14
- * @returns a callback to trigger the run of `onBeforeUnmount` and `onUnmounted`
15
- */
16
- export const mockVueLifecycle = () => {
17
- const { callbacks } = vi.hoisted(() => ({
18
- callbacks: {
19
- onBeforeUnmountedCb: null as Callback | null,
20
- onUnmountedCb: null as Callback | null,
21
- },
22
- }));
23
-
24
- vi.mock("vue", async (original) => ({
25
- ...((await original()) as typeof import("vue")),
26
- onBeforeMount: vi.fn((cb: Callback) => cb()),
27
- onMounted: vi.fn((cb: Callback) => cb()),
28
- onBeforeUnmount: vi.fn((cb: Callback) => (callbacks.onBeforeUnmountedCb = cb)),
29
- onUnmounted: vi.fn((cb: Callback) => (callbacks.onUnmountedCb = cb)),
30
- }));
31
-
32
- return async () => {
33
- await callbacks.onBeforeUnmountedCb?.();
34
- await callbacks.onUnmountedCb?.();
35
- };
36
- };