@spaced-out/ui-design-system 0.6.35-beta.0 → 0.6.35

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 (35) hide show
  1. package/.cspell/custom-words.txt +0 -9
  2. package/CHANGELOG.md +9 -0
  3. package/lib/components/Menu/Menu.d.ts +1 -71
  4. package/lib/components/Menu/Menu.d.ts.map +1 -1
  5. package/lib/components/Menu/Menu.js +221 -1035
  6. package/lib/components/Menu/Menu.module.css +27 -148
  7. package/lib/components/Menu/MenuOptionButton.d.ts +2 -23
  8. package/lib/components/Menu/MenuOptionButton.d.ts.map +1 -1
  9. package/lib/components/Menu/MenuOptionButton.js +38 -87
  10. package/lib/components/Menu/index.d.ts +0 -2
  11. package/lib/components/Menu/index.d.ts.map +1 -1
  12. package/lib/components/Menu/index.js +0 -22
  13. package/lib/hooks/index.d.ts +0 -1
  14. package/lib/hooks/index.d.ts.map +1 -1
  15. package/lib/hooks/index.js +0 -11
  16. package/lib/utils/click-away/click-away.d.ts +0 -3
  17. package/lib/utils/click-away/click-away.d.ts.map +1 -1
  18. package/lib/utils/click-away/click-away.js +0 -49
  19. package/mcp/package.json +1 -1
  20. package/package.json +1 -1
  21. package/lib/components/Menu/menuOptionId.d.ts +0 -12
  22. package/lib/components/Menu/menuOptionId.d.ts.map +0 -1
  23. package/lib/components/Menu/menuOptionId.js +0 -18
  24. package/lib/components/Menu/useMenuKeyboardNavigation.d.ts +0 -93
  25. package/lib/components/Menu/useMenuKeyboardNavigation.d.ts.map +0 -1
  26. package/lib/components/Menu/useMenuKeyboardNavigation.js +0 -471
  27. package/lib/components/Menu/useMenuTrigger.d.ts +0 -183
  28. package/lib/components/Menu/useMenuTrigger.d.ts.map +0 -1
  29. package/lib/components/Menu/useMenuTrigger.js +0 -347
  30. package/lib/hooks/useInteractionModality/index.d.ts +0 -2
  31. package/lib/hooks/useInteractionModality/index.d.ts.map +0 -1
  32. package/lib/hooks/useInteractionModality/index.js +0 -16
  33. package/lib/hooks/useInteractionModality/useInteractionModality.d.ts +0 -15
  34. package/lib/hooks/useInteractionModality/useInteractionModality.d.ts.map +0 -1
  35. package/lib/hooks/useInteractionModality/useInteractionModality.js +0 -103
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useInteractionModality = exports.getInteractionModality = void 0;
7
- var _react = require("react");
8
- /*
9
- * Input modality is a property of the SESSION, not of any one component, so it
10
- * lives in module scope rather than in state that each consumer would have to
11
- * thread around. This is the same shape the platform itself uses: `:focus-visible`
12
- * is implemented by the engine tracking the last interaction globally.
13
- *
14
- * Reach for this only when CSS cannot answer the question — `:focus-visible` is
15
- * the right tool whenever the element you need to style is the one that was
16
- * interacted with. This exists for the case where it is NOT: a popup deciding
17
- * whether to show a keyboard cursor has to know how its TRIGGER was operated,
18
- * and the trigger's own `:focus-visible` cannot be trusted for that, because
19
- * browsers always match it on text inputs (typing is expected there) — so an
20
- * input-triggered popup would always look keyboard-opened.
21
- */
22
- let currentModality = 'pointer';
23
- let listening = false;
24
- const subscribers = new Set();
25
-
26
- // Keys that navigate even when chorded with a modifier — Cmd+Down is "jump to
27
- // the end" on macOS and the menus honour it as such.
28
- const NAVIGATION_KEYS = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', 'Tab', 'Enter', ' ']);
29
- const MODIFIER_KEYS = new Set(['Shift', 'Meta', 'Alt', 'Control']);
30
- const set = modality => {
31
- if (currentModality === modality) {
32
- return;
33
- }
34
- currentModality = modality;
35
- subscribers.forEach(notify => notify(modality));
36
- };
37
- const handleKeyDown = event => {
38
- // A modifier pressed on its own — Shift held for a click, say — is not an
39
- // interaction, and a chorded shortcut (Cmd+C, Ctrl+S) is a command rather than
40
- // navigation. Neither should make the session look keyboard-driven. A chorded
41
- // NAVIGATION key (Cmd+Down) does count: it moves the highlight.
42
- if (MODIFIER_KEYS.has(event.key)) {
43
- return;
44
- }
45
- if ((event.metaKey || event.altKey || event.ctrlKey) && !NAVIGATION_KEYS.has(event.key)) {
46
- return;
47
- }
48
- set('keyboard');
49
- };
50
- const handlePointerDown = () => set('pointer');
51
-
52
- /*
53
- * Capture phase, so the modality is recorded before any component handler reacts
54
- * to the same event.
55
- *
56
- * Listening starts when this module is imported, NOT lazily on first read. It has
57
- * to: the interesting question is usually "how was the thing that just mounted
58
- * opened?", and the keypress that opened it happened before it existed. Attaching
59
- * on first read would miss exactly that event and report the default instead.
60
- */
61
- const subscribe = notify => {
62
- // Session-scoped by design: the listeners live for the life of the page, so
63
- // there is nothing to tear down.
64
- if (typeof document !== 'undefined' && !listening) {
65
- listening = true;
66
- document.addEventListener('keydown', handleKeyDown, true);
67
- document.addEventListener('pointerdown', handlePointerDown, true);
68
- }
69
- if (!notify) {
70
- return () => undefined;
71
- }
72
- subscribers.add(notify);
73
- return () => {
74
- subscribers.delete(notify);
75
- };
76
- };
77
-
78
- // Start listening at import time — see the note on `subscribe`.
79
- subscribe();
80
-
81
- /**
82
- * How the user last interacted with the page, read imperatively.
83
- *
84
- * Use this when the answer is needed during render or in an effect rather than
85
- * as reactive state — for example a popup deciding on mount whether it was opened
86
- * by keyboard, where re-rendering on later modality changes would be wrong.
87
- */
88
- const getInteractionModality = () => {
89
- subscribe();
90
- return currentModality;
91
- };
92
-
93
- /**
94
- * How the user last interacted with the page, as reactive state. Re-renders the
95
- * caller when the user switches between keyboard and pointer.
96
- */
97
- exports.getInteractionModality = getInteractionModality;
98
- const useInteractionModality = () => {
99
- const [modality, setModality] = (0, _react.useState)(() => getInteractionModality());
100
- (0, _react.useEffect)(() => subscribe(setModality), []);
101
- return modality;
102
- };
103
- exports.useInteractionModality = useInteractionModality;