@jsenv/navi 0.0.1 → 0.1.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 (138) hide show
  1. package/dist/jsenv_navi.js +22954 -0
  2. package/index.js +66 -16
  3. package/package.json +22 -11
  4. package/src/actions.js +50 -26
  5. package/src/browser_integration/browser_integration.js +31 -6
  6. package/src/browser_integration/via_history.js +42 -9
  7. package/src/components/action_execution/render_actionable_component.jsx +6 -4
  8. package/src/components/action_execution/use_action.js +51 -282
  9. package/src/components/action_execution/use_execute_action.js +106 -92
  10. package/src/components/action_execution/use_run_on_mount.js +9 -0
  11. package/src/components/action_renderer.jsx +21 -32
  12. package/src/components/demos/0_button_demo.html +574 -103
  13. package/src/components/demos/10_column_reordering_debug.html +277 -0
  14. package/src/components/demos/11_table_selection_debug.html +432 -0
  15. package/src/components/demos/1_checkbox_demo.html +579 -202
  16. package/src/components/demos/2_input_textual_demo.html +81 -138
  17. package/src/components/demos/3_radio_demo.html +0 -2
  18. package/src/components/demos/4_select_demo.html +19 -23
  19. package/src/components/demos/6_tablist_demo.html +77 -0
  20. package/src/components/demos/7_table_selection_demo.html +176 -0
  21. package/src/components/demos/8_table_fixed_headers_demo.html +584 -0
  22. package/src/components/demos/9_table_column_drag_demo.html +325 -0
  23. package/src/components/demos/action/0_button_demo.html +2 -4
  24. package/src/components/demos/action/1_input_text_demo.html +643 -222
  25. package/src/components/demos/action/3_details_demo.html +146 -115
  26. package/src/components/demos/action/4_input_checkbox_demo.html +442 -322
  27. package/src/components/demos/action/5_input_checkbox_state_demo.html +270 -0
  28. package/src/components/demos/action/6_checkbox_list_demo.html +304 -72
  29. package/src/components/demos/action/7_radio_list_demo.html +310 -170
  30. package/src/components/demos/action/{8_editable_text_demo.html → 8_editable_demo.html} +65 -76
  31. package/src/components/demos/action/9_link_demo.html +84 -62
  32. package/src/components/demos/ui_transition/0_action_renderer_ui_transition_demo.html +695 -0
  33. package/src/components/demos/ui_transition/1_nested_ui_transition_demo.html +429 -0
  34. package/src/components/demos/ui_transition/2_height_transition_test.html +295 -0
  35. package/src/components/details/details.jsx +62 -64
  36. package/src/components/edition/editable.jsx +186 -0
  37. package/src/components/field/README.md +247 -0
  38. package/src/components/{input → field}/button.jsx +151 -130
  39. package/src/components/field/checkbox_list.jsx +184 -0
  40. package/src/components/{collect_form_element_values.js → field/collect_form_element_values.js} +7 -4
  41. package/src/components/{input → field}/field_css.js +4 -1
  42. package/src/components/field/form.jsx +211 -0
  43. package/src/components/{input → field}/input.jsx +1 -0
  44. package/src/components/{input → field}/input_checkbox.jsx +132 -155
  45. package/src/components/{input → field}/input_radio.jsx +135 -46
  46. package/src/components/{input → field}/input_textual.jsx +247 -173
  47. package/src/components/field/label.jsx +32 -0
  48. package/src/components/field/radio_list.jsx +182 -0
  49. package/src/components/{input → field}/select.jsx +17 -32
  50. package/src/components/field/use_action_events.js +132 -0
  51. package/src/components/field/use_form_events.js +55 -0
  52. package/src/components/field/use_ui_state_controller.js +506 -0
  53. package/src/components/item_tracker/README.md +461 -0
  54. package/src/components/item_tracker/use_isolated_item_tracker.jsx +209 -0
  55. package/src/components/item_tracker/use_isolated_item_tracker_demo.html +148 -0
  56. package/src/components/item_tracker/use_isolated_item_tracker_demo.jsx +460 -0
  57. package/src/components/item_tracker/use_item_tracker.jsx +143 -0
  58. package/src/components/item_tracker/use_item_tracker_demo.html +207 -0
  59. package/src/components/item_tracker/use_item_tracker_demo.jsx +216 -0
  60. package/src/components/keyboard_shortcuts/active_keyboard_shortcuts.jsx +87 -0
  61. package/src/components/keyboard_shortcuts/aria_key_shortcuts.js +61 -0
  62. package/src/components/keyboard_shortcuts/keyboard_key_meta.js +17 -0
  63. package/src/components/keyboard_shortcuts/keyboard_shortcuts.js +371 -0
  64. package/src/components/link/link.jsx +65 -102
  65. package/src/components/link/link_with_icon.jsx +52 -0
  66. package/src/components/loader/loader_background.jsx +85 -64
  67. package/src/components/loader/rectangle_loading.jsx +38 -19
  68. package/src/components/route.jsx +8 -4
  69. package/src/components/selection/selection.jsx +1583 -0
  70. package/src/components/svg/font_sized_svg.jsx +45 -0
  71. package/src/components/svg/icon_and_text.jsx +21 -0
  72. package/src/components/svg/svg_mask_overlay.jsx +105 -0
  73. package/src/components/table/drag/table_drag.jsx +506 -0
  74. package/src/components/table/resize/table_resize.jsx +650 -0
  75. package/src/components/table/resize/table_size.js +43 -0
  76. package/src/components/table/selection/table_selection.js +106 -0
  77. package/src/components/table/selection/table_selection.jsx +203 -0
  78. package/src/components/table/sticky/sticky_group.js +354 -0
  79. package/src/components/table/sticky/table_sticky.js +25 -0
  80. package/src/components/table/sticky/table_sticky.jsx +501 -0
  81. package/src/components/table/table.jsx +721 -0
  82. package/src/components/table/table_css.js +211 -0
  83. package/src/components/table/table_ui.jsx +49 -0
  84. package/src/components/table/use_cells_and_columns.js +90 -0
  85. package/src/components/table/use_object_array_to_cells.js +46 -0
  86. package/src/components/table/z_indexes.js +23 -0
  87. package/src/components/tablist/tablist.jsx +99 -0
  88. package/src/components/text/overflow.jsx +15 -0
  89. package/src/components/text/text_and_count.jsx +28 -0
  90. package/src/components/ui_transition.jsx +128 -0
  91. package/src/components/use_auto_focus.js +58 -7
  92. package/src/components/use_batch_during_render.js +33 -0
  93. package/src/components/use_debounce_true.js +7 -7
  94. package/src/components/use_dependencies_diff.js +35 -0
  95. package/src/components/use_focus_group.js +4 -3
  96. package/src/components/use_initial_value.js +8 -34
  97. package/src/components/use_signal_sync.js +1 -1
  98. package/src/components/use_stable_callback.js +68 -0
  99. package/src/components/use_state_array.js +16 -9
  100. package/src/docs/actions.md +22 -0
  101. package/src/notes.md +33 -12
  102. package/src/route/route.js +97 -47
  103. package/src/store/resource_graph.js +2 -1
  104. package/src/store/tests/{resource_graph_dependencies.test.js → resource_graph_dependencies.test_manual.js} +13 -13
  105. package/src/utils/is_signal.js +20 -0
  106. package/src/utils/stringify_for_display.js +4 -23
  107. package/src/validation/constraints/confirm_constraint.js +14 -0
  108. package/src/validation/constraints/create_unique_value_constraint.js +27 -0
  109. package/src/validation/constraints/native_constraints.js +313 -0
  110. package/src/validation/constraints/readonly_constraint.js +36 -0
  111. package/src/validation/constraints/single_space_constraint.js +13 -0
  112. package/src/validation/custom_constraint_validation.js +599 -0
  113. package/src/validation/custom_message.js +18 -0
  114. package/src/validation/demos/browser_style.png +0 -0
  115. package/src/validation/demos/form_validation_demo.html +142 -0
  116. package/src/validation/demos/form_validation_demo_preact.html +87 -0
  117. package/src/validation/demos/form_validation_native_popover_demo.html +168 -0
  118. package/src/validation/demos/form_validation_vs_native_demo.html +172 -0
  119. package/src/validation/demos/validation_message_demo.html +203 -0
  120. package/src/validation/hooks/use_constraints.js +23 -0
  121. package/src/validation/hooks/use_custom_validation_ref.js +73 -0
  122. package/src/validation/hooks/use_validation_message.js +19 -0
  123. package/src/validation/validation_message.js +741 -0
  124. package/src/components/editable_text/editable_text.jsx +0 -96
  125. package/src/components/form.jsx +0 -144
  126. package/src/components/input/checkbox_list.jsx +0 -294
  127. package/src/components/input/field.jsx +0 -61
  128. package/src/components/input/radio_list.jsx +0 -283
  129. package/src/components/input/use_form_event.js +0 -20
  130. package/src/components/input/use_on_change.js +0 -12
  131. package/src/components/selection/selection.js +0 -5
  132. package/src/components/selection/selection_context.jsx +0 -262
  133. package/src/components/shortcut/shortcut_context.jsx +0 -390
  134. package/src/components/use_action_events.js +0 -37
  135. package/src/utils/iterable_weak_set.js +0 -62
  136. /package/src/components/demos/action/{11_nested_shortcuts_demo.html → 11_nested_shortcuts_demo.xhtml} +0 -0
  137. /package/src/components/{shortcut → keyboard_shortcuts}/os.js +0 -0
  138. /package/src/route/{route.test.html → route.xtest.html} +0 -0
@@ -0,0 +1,143 @@
1
+ import { createContext } from "preact";
2
+ import { useContext, useMemo, useRef } from "preact/hooks";
3
+
4
+ /*
5
+ * Item Tracker - For colocated producer/consumer scenarios
6
+ *
7
+ * USE CASE:
8
+ * This is for scenarios where producers and consumers are in the same
9
+ * component tree, such as:
10
+ * - TableRow components registering themselves
11
+ * - TableCell components accessing row data by index
12
+ * - Both happen within the same table structure
13
+ *
14
+ * Unlike the isolated producer/consumer system, this doesn't need complex
15
+ * synchronization because everything happens in the same render cycle.
16
+ *
17
+ * USAGE:
18
+ * ```jsx
19
+ * // Create domain-specific tracker hooks
20
+ * const [useRowTrackerProvider, useRegisterRow, useRow, useRows] = createItemTracker();
21
+ *
22
+ * function App() {
23
+ * const RowTrackerProvider = useRowTrackerProvider();
24
+ *
25
+ * return (
26
+ * <RowTrackerProvider>
27
+ * <table>
28
+ * <tbody>
29
+ * {rows.map(({ id, name, color }) => (
30
+ * <TableRow key={id} name={name} color={color}>
31
+ * <TableCell column="name" />
32
+ * <TableCell column="color" />
33
+ * </TableRow>
34
+ * ))}
35
+ * </tbody>
36
+ * </table>
37
+ * <TrackedRowsList />
38
+ * </RowTrackerProvider>
39
+ * );
40
+ * }
41
+ *
42
+ * function TableRow({ name, color, children }) {
43
+ * const rowIndex = useRegisterRow({ name, color });
44
+ * return (
45
+ * <tr>
46
+ * <TableRowIndexContext.Provider value={rowIndex}>
47
+ * {children}
48
+ * </TableRowIndexContext.Provider>
49
+ * </tr>
50
+ * );
51
+ * }
52
+ *
53
+ * function TableCell({ column }) {
54
+ * const rowIndex = useContext(TableRowIndexContext);
55
+ * const rowData = useRow(rowIndex);
56
+ * return <td>{rowData[column]}</td>;
57
+ * }
58
+ *
59
+ * function TrackedRowsList() {
60
+ * const rows = useRows();
61
+ * return <div>Total rows: {rows.length}</div>;
62
+ * }
63
+ * ```
64
+ */
65
+
66
+ export const createItemTracker = () => {
67
+ const ItemTrackerContext = createContext();
68
+
69
+ const useItemTrackerProvider = () => {
70
+ const itemsRef = useRef([]);
71
+ const items = itemsRef.current;
72
+ const itemCountRef = useRef(0);
73
+
74
+ const tracker = useMemo(() => {
75
+ const ItemTrackerProvider = ({ children }) => {
76
+ // Reset on each render to start fresh
77
+ tracker.reset();
78
+
79
+ return (
80
+ <ItemTrackerContext.Provider value={tracker}>
81
+ {children}
82
+ </ItemTrackerContext.Provider>
83
+ );
84
+ };
85
+ ItemTrackerProvider.items = items;
86
+
87
+ return {
88
+ ItemTrackerProvider,
89
+ items,
90
+ registerItem: (data) => {
91
+ const index = itemCountRef.current++;
92
+ items[index] = data;
93
+ return index;
94
+ },
95
+ getItem: (index) => {
96
+ return items[index];
97
+ },
98
+ getAllItems: () => {
99
+ return items;
100
+ },
101
+ reset: () => {
102
+ items.length = 0;
103
+ itemCountRef.current = 0;
104
+ },
105
+ };
106
+ }, []);
107
+
108
+ return tracker.ItemTrackerProvider;
109
+ };
110
+
111
+ const useTrackItem = (data) => {
112
+ const tracker = useContext(ItemTrackerContext);
113
+ if (!tracker) {
114
+ throw new Error(
115
+ "useTrackItem must be used within SimpleItemTrackerProvider",
116
+ );
117
+ }
118
+ return tracker.registerItem(data);
119
+ };
120
+
121
+ const useTrackedItem = (index) => {
122
+ const trackedItems = useTrackedItems();
123
+ const item = trackedItems[index];
124
+ return item;
125
+ };
126
+
127
+ const useTrackedItems = () => {
128
+ const tracker = useContext(ItemTrackerContext);
129
+ if (!tracker) {
130
+ throw new Error(
131
+ "useTrackedItems must be used within SimpleItemTrackerProvider",
132
+ );
133
+ }
134
+ return tracker.items;
135
+ };
136
+
137
+ return [
138
+ useItemTrackerProvider,
139
+ useTrackItem,
140
+ useTrackedItem,
141
+ useTrackedItems,
142
+ ];
143
+ };
@@ -0,0 +1,207 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Item Tracker Demo</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <link rel="icon" href="data:," />
8
+ <style>
9
+ body {
10
+ font-family: system-ui, sans-serif;
11
+ margin: 20px;
12
+ background: #f5f5f5;
13
+ }
14
+
15
+ .demo-container {
16
+ max-width: 800px;
17
+ margin: 0 auto;
18
+ background: white;
19
+ padding: 20px;
20
+ border-radius: 8px;
21
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
22
+ }
23
+
24
+ .section {
25
+ margin-bottom: 25px;
26
+ padding: 15px;
27
+ border: 1px solid #ddd;
28
+ border-radius: 6px;
29
+ background: #fafafa;
30
+ }
31
+
32
+ .section h3 {
33
+ margin: 0 0 15px 0;
34
+ font-size: 16px;
35
+ color: #333;
36
+ border-bottom: 1px solid #eee;
37
+ padding-bottom: 8px;
38
+ }
39
+
40
+ .table-container {
41
+ border: 1px solid #ccc;
42
+ border-radius: 4px;
43
+ overflow: hidden;
44
+ }
45
+
46
+ .table {
47
+ width: 100%;
48
+ border-collapse: collapse;
49
+ background: white;
50
+ }
51
+
52
+ .table th,
53
+ .table td {
54
+ padding: 8px 12px;
55
+ text-align: left;
56
+ border-bottom: 1px solid #eee;
57
+ font-size: 12px;
58
+ }
59
+
60
+ .table th {
61
+ background: #f8f9fa;
62
+ font-weight: 600;
63
+ color: #495057;
64
+ }
65
+
66
+ .table-row {
67
+ position: relative;
68
+ }
69
+
70
+ .table-row--red {
71
+ background-color: #ffebee;
72
+ }
73
+ .table-row--blue {
74
+ background-color: #e3f2fd;
75
+ }
76
+ .table-row--green {
77
+ background-color: #e8f5e8;
78
+ }
79
+ .table-row--yellow {
80
+ background-color: #fff8e1;
81
+ }
82
+
83
+ .controls {
84
+ display: flex;
85
+ gap: 8px;
86
+ align-items: center;
87
+ flex-wrap: wrap;
88
+ }
89
+
90
+ .btn {
91
+ padding: 4px 8px;
92
+ font-size: 11px;
93
+ border: 1px solid #ddd;
94
+ border-radius: 3px;
95
+ background: white;
96
+ cursor: pointer;
97
+ color: #333;
98
+ }
99
+
100
+ .btn:hover {
101
+ background: #f0f0f0;
102
+ }
103
+
104
+ .btn--primary {
105
+ background: #007bff;
106
+ color: white;
107
+ border-color: #007bff;
108
+ }
109
+
110
+ .btn--primary:hover {
111
+ background: #0056b3;
112
+ }
113
+
114
+ .btn--small {
115
+ padding: 2px 6px;
116
+ font-size: 10px;
117
+ }
118
+
119
+ .info-grid {
120
+ display: grid;
121
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
122
+ gap: 10px;
123
+ margin-top: 10px;
124
+ }
125
+
126
+ .info-item {
127
+ background: white;
128
+ padding: 8px;
129
+ border-radius: 4px;
130
+ border: 1px solid #e0e0e0;
131
+ font-size: 11px;
132
+ }
133
+
134
+ .info-item strong {
135
+ color: #333;
136
+ display: block;
137
+ margin-bottom: 4px;
138
+ }
139
+
140
+ .tracked-rows {
141
+ display: flex;
142
+ flex-direction: column;
143
+ gap: 4px;
144
+ }
145
+
146
+ .tracked-row-item {
147
+ background: white;
148
+ padding: 6px 8px;
149
+ border-radius: 3px;
150
+ border: 1px solid #ddd;
151
+ font-size: 10px;
152
+ display: flex;
153
+ justify-content: space-between;
154
+ align-items: center;
155
+ }
156
+
157
+ .log {
158
+ background: #f8f9fa;
159
+ border: 1px solid #dee2e6;
160
+ border-radius: 4px;
161
+ padding: 10px;
162
+ font-family: "Courier New", monospace;
163
+ font-size: 10px;
164
+ max-height: 200px;
165
+ overflow-y: auto;
166
+ white-space: pre-wrap;
167
+ }
168
+ </style>
169
+ </head>
170
+ <body>
171
+ <div class="demo-container">
172
+ <h1>Simple Item Tracker Demo</h1>
173
+ <p>
174
+ <strong>Use Case:</strong> TableRow components register themselves,
175
+ TableCell components access row data by index.
176
+ </p>
177
+ <p>
178
+ This demonstrates colocated producer/consumer usage - simpler than the
179
+ separated colgroup scenario.
180
+ </p>
181
+
182
+ <div id="app-root"></div>
183
+
184
+ <div class="section">
185
+ <h3>🔍 Debug Log</h3>
186
+ <div id="log" class="log"></div>
187
+ <button class="btn btn--small" onclick="window.clearLog()">
188
+ Clear Log
189
+ </button>
190
+ </div>
191
+ </div>
192
+
193
+ <script type="module" jsenv-type="module/jsx">
194
+ import { render } from "preact";
195
+ // eslint-disable-next-line no-unused-vars
196
+ import { App } from "./use_item_tracker_demo.jsx";
197
+
198
+ const logContainer = document.getElementById("log");
199
+ window.clearLog = () => {
200
+ logContainer.textContent = "";
201
+ };
202
+
203
+ // Render the app
204
+ render(<App />, document.getElementById("app-root"));
205
+ </script>
206
+ </body>
207
+ </html>
@@ -0,0 +1,216 @@
1
+ import { createContext } from "preact";
2
+ import { useContext, useState } from "preact/hooks";
3
+ import { createItemTracker } from "./use_item_tracker.jsx";
4
+
5
+ const [useRowTrackerProvider, useRegisterRow, useRow, useRows] =
6
+ createItemTracker();
7
+
8
+ // Main demo app
9
+ export const App = () => {
10
+ const [rows, setRows] = useState([
11
+ {
12
+ id: "a",
13
+ name: "First Row",
14
+ color: "red",
15
+ category: "Type A",
16
+ value: 100,
17
+ },
18
+ {
19
+ id: "b",
20
+ name: "Second Row",
21
+ color: "blue",
22
+ category: "Type B",
23
+ value: 200,
24
+ },
25
+ ]);
26
+ const [renderKey, setRenderKey] = useState(0);
27
+
28
+ log(`🎬 App render #${renderKey}`);
29
+
30
+ const RowTrackerProvider = useRowTrackerProvider();
31
+
32
+ const addRow = () => {
33
+ const colors = ["red", "blue", "green", "yellow"];
34
+ const newId = String.fromCharCode(97 + rows.length);
35
+
36
+ const newRow = {
37
+ id: newId,
38
+ name: `Row ${newId.toUpperCase()}`,
39
+ color: colors[Math.floor(Math.random() * colors.length)],
40
+ };
41
+
42
+ setRows((prev) => [...prev, newRow]);
43
+ log(`➕ Added row: ${JSON.stringify(newRow)}`);
44
+ };
45
+
46
+ const removeLastRow = () => {
47
+ if (rows.length > 0) {
48
+ const removed = rows[rows.length - 1];
49
+ setRows((prev) => prev.slice(0, -1));
50
+ log(`➖ Removed row: ${removed.name}`);
51
+ }
52
+ };
53
+
54
+ const forceRerender = () => {
55
+ setRenderKey((prev) => prev + 1);
56
+ log(`🔄 Forced re-render #${renderKey + 1}`);
57
+ };
58
+
59
+ return (
60
+ <div>
61
+ <div className="section">
62
+ <h3>🎮 Controls</h3>
63
+ <div className="controls">
64
+ <button className="btn btn--primary" onClick={addRow}>
65
+ ➕ Add Row
66
+ </button>
67
+ <button className="btn" onClick={removeLastRow}>
68
+ ➖ Remove Last Row
69
+ </button>
70
+ <button className="btn" onClick={forceRerender}>
71
+ 🔄 Force Re-render
72
+ </button>
73
+ <span style={{ fontSize: "11px", opacity: 0.7 }}>
74
+ Render #{renderKey}
75
+ </span>
76
+ </div>
77
+ </div>
78
+
79
+ <RowTrackerProvider>
80
+ <div className="section">
81
+ <h3>📋 Table with Tracked Rows</h3>
82
+ <p style={{ fontSize: "12px", margin: "0 0 10px 0", color: "#666" }}>
83
+ 💡 Change colors using the dropdown in each row to trigger
84
+ individual row re-renders. Notice how only that specific row
85
+ re-renders and updates its tracked data.
86
+ </p>
87
+ <div className="table-container">
88
+ <table className="table">
89
+ <thead>
90
+ <tr>
91
+ <th>Name</th>
92
+ <th>Color</th>
93
+ <th>Color Override</th>
94
+ </tr>
95
+ </thead>
96
+ <tbody>
97
+ {rows.map(({ id, name, color }) => (
98
+ <TableRow key={id} name={name} color={color}>
99
+ <TableCell column="name" />
100
+ <TableCell column="color" />
101
+ {/* Color selector is rendered directly in TableRow */}
102
+ </TableRow>
103
+ ))}
104
+ </tbody>
105
+ </table>
106
+ </div>
107
+ </div>
108
+
109
+ <div className="section">
110
+ <h3>🔍 Tracked Items Debug</h3>
111
+ <TrackedRowsList />
112
+ </div>
113
+ </RowTrackerProvider>
114
+ </div>
115
+ );
116
+ };
117
+
118
+ // Simple logging
119
+ const logContainer = document.getElementById("log");
120
+ const log = (message) => {
121
+ const timestamp = new Date().toLocaleTimeString();
122
+ logContainer.textContent += `[${timestamp}] ${message}\n`;
123
+ logContainer.scrollTop = logContainer.scrollHeight;
124
+ };
125
+
126
+ const TableRowIndexContext = createContext();
127
+
128
+ // Demo components
129
+ const TableRow = ({ children, name, color: initialColor }) => {
130
+ // Local state for color override
131
+ const [localColor, setLocalColor] = useState(initialColor);
132
+
133
+ // Use local color if it differs from initial, otherwise use initial
134
+ const currentColor = localColor !== initialColor ? localColor : initialColor;
135
+
136
+ // Register this row and get its index
137
+ const rowIndex = useRegisterRow({ name, color: currentColor });
138
+
139
+ log(`🎬 TableRow ${rowIndex} render (${name}, color: ${currentColor})`);
140
+
141
+ const handleColorChange = (event) => {
142
+ const newColor = event.target.value;
143
+ setLocalColor(newColor);
144
+ log(`🎨 Row ${rowIndex} color changed to ${newColor}`);
145
+ };
146
+
147
+ return (
148
+ <tr className={`table-row table-row--${currentColor}`}>
149
+ <TableRowIndexContext.Provider value={rowIndex}>
150
+ {children}
151
+ <td>
152
+ <select
153
+ value={currentColor}
154
+ onChange={handleColorChange}
155
+ style={{ fontSize: "10px", padding: "2px" }}
156
+ >
157
+ <option value="red">Red</option>
158
+ <option value="blue">Blue</option>
159
+ <option value="green">Green</option>
160
+ <option value="yellow">Yellow</option>
161
+ </select>
162
+ {localColor !== initialColor && (
163
+ <small style={{ marginLeft: "4px", opacity: 0.7 }}>
164
+ (overridden)
165
+ </small>
166
+ )}
167
+ </td>
168
+ </TableRowIndexContext.Provider>
169
+ </tr>
170
+ );
171
+ };
172
+
173
+ const TableCell = ({ column }) => {
174
+ const rowIndex = useContext(TableRowIndexContext);
175
+ const rowData = useRow(rowIndex);
176
+
177
+ if (!rowData) {
178
+ return <td>❌ Row {rowIndex} not found</td>;
179
+ }
180
+
181
+ const cellContent = rowData[column] || `${column}?`;
182
+
183
+ return (
184
+ <td title={`Row ${rowIndex}, Column ${column}`}>
185
+ {cellContent}
186
+ <small style={{ opacity: 0.6, marginLeft: "4px" }}>
187
+ (row {rowIndex})
188
+ </small>
189
+ </td>
190
+ );
191
+ };
192
+
193
+ const TrackedRowsList = () => {
194
+ const rows = useRows();
195
+
196
+ return (
197
+ <div className="tracked-rows">
198
+ <strong>All Tracked Rows ({rows.length}):</strong>
199
+ {rows.map((item, index) => (
200
+ <div key={index} className="tracked-row-item">
201
+ <span>
202
+ #{index}: {item.name}
203
+ </span>
204
+ <span style={{ color: item.color, fontWeight: "bold" }}>
205
+ {item.color}
206
+ </span>
207
+ </div>
208
+ ))}
209
+ {rows.length === 0 && (
210
+ <div style={{ opacity: 0.6, fontStyle: "italic" }}>
211
+ No rows tracked yet
212
+ </div>
213
+ )}
214
+ </div>
215
+ );
216
+ };
@@ -0,0 +1,87 @@
1
+ import { generateAriaKeyShortcuts } from "./aria_key_shortcuts.js";
2
+ import { activeShortcutsSignal } from "./keyboard_shortcuts.js";
3
+
4
+ import.meta.css = /* css */ `
5
+ .navi_shortcut_container[data-visually-hidden] {
6
+ /* Visually hidden container - doesn't affect layout */
7
+ position: absolute;
8
+ width: 1px;
9
+ height: 1px;
10
+ padding: 0;
11
+ margin: -1px;
12
+ overflow: hidden;
13
+ clip: rect(0, 0, 0, 0);
14
+ white-space: nowrap;
15
+ border: 0;
16
+
17
+ /* Ensure it's not interactable */
18
+ opacity: 0;
19
+ pointer-events: none;
20
+ }
21
+
22
+ .navi_shortcut_button[data-visually-hidden] {
23
+ /* Visually hidden but accessible to screen readers */
24
+ position: absolute;
25
+ width: 1px;
26
+ height: 1px;
27
+ padding: 0;
28
+ margin: -1px;
29
+ overflow: hidden;
30
+ clip: rect(0, 0, 0, 0);
31
+ white-space: nowrap;
32
+ border: 0;
33
+
34
+ /* Ensure it's not focusable via tab navigation */
35
+ opacity: 0;
36
+ pointer-events: none;
37
+ }
38
+ `;
39
+
40
+ export const ActiveKeyboardShortcuts = ({ visible }) => {
41
+ const activeShortcuts = activeShortcutsSignal.value;
42
+
43
+ return (
44
+ <div
45
+ className="navi_shortcut_container"
46
+ data-visually-hidden={visible ? undefined : ""}
47
+ >
48
+ {activeShortcuts.map((shortcut) => {
49
+ return (
50
+ <KeyboardShortcutAriaElement
51
+ key={shortcut.key}
52
+ visible={visible}
53
+ keyCombination={shortcut.key}
54
+ description={shortcut.description}
55
+ enabled={shortcut.enabled}
56
+ data-action={shortcut.action ? shortcut.action.name : undefined}
57
+ data-confirm-message={shortcut.confirmMessage}
58
+ />
59
+ );
60
+ })}
61
+ </div>
62
+ );
63
+ };
64
+ const KeyboardShortcutAriaElement = ({
65
+ visible,
66
+ keyCombination,
67
+ description,
68
+ enabled,
69
+ ...props
70
+ }) => {
71
+ if (typeof keyCombination === "function") {
72
+ return null;
73
+ }
74
+ const ariaKeyshortcuts = generateAriaKeyShortcuts(keyCombination);
75
+ return (
76
+ <button
77
+ className="navi_shortcut_button"
78
+ data-visually-hidden={visible ? undefined : ""}
79
+ aria-keyshortcuts={ariaKeyshortcuts}
80
+ tabIndex="-1"
81
+ disabled={!enabled}
82
+ {...props}
83
+ >
84
+ {description}
85
+ </button>
86
+ );
87
+ };
@@ -0,0 +1,61 @@
1
+ import { keyMapping } from "./keyboard_key_meta.js";
2
+ import { isMac } from "./os.js";
3
+
4
+ // http://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts
5
+ export const generateAriaKeyShortcuts = (key) => {
6
+ let actualCombination;
7
+
8
+ // Handle platform-specific combination objects
9
+ if (typeof key === "object" && key !== null) {
10
+ actualCombination = isMac ? key.mac : key.other;
11
+ } else {
12
+ actualCombination = key;
13
+ }
14
+
15
+ if (actualCombination) {
16
+ return normalizeKeyCombination(actualCombination);
17
+ }
18
+
19
+ return "";
20
+ };
21
+
22
+ const normalizeKeyCombination = (combination) => {
23
+ const lowerCaseCombination = combination.toLowerCase();
24
+ const keys = lowerCaseCombination.split("+");
25
+
26
+ // First normalize keys to their canonical form, then apply ARIA mapping
27
+ for (let i = 0; i < keys.length; i++) {
28
+ let key = normalizeKey(keys[i]);
29
+
30
+ // Then apply ARIA-specific mappings if they exist
31
+ if (keyToAriaKeyMapping[key]) {
32
+ key = keyToAriaKeyMapping[key];
33
+ }
34
+
35
+ keys[i] = key;
36
+ }
37
+
38
+ return keys.join("+");
39
+ };
40
+ const keyToAriaKeyMapping = {
41
+ // Platform-specific ARIA names
42
+ command: "meta",
43
+ option: "altgraph", // Mac option key uses "altgraph" in ARIA spec
44
+
45
+ // Regular keys - platform-specific normalization
46
+ delete: isMac ? "backspace" : "delete", // Mac delete key is backspace semantically
47
+ backspace: isMac ? "backspace" : "delete",
48
+ };
49
+ const normalizeKey = (key) => {
50
+ key = key.toLowerCase();
51
+
52
+ // Find the canonical form for this key
53
+ for (const [canonicalKey, config] of Object.entries(keyMapping)) {
54
+ const allKeys = [canonicalKey, ...config.alias];
55
+ if (allKeys.includes(key)) {
56
+ return canonicalKey;
57
+ }
58
+ }
59
+
60
+ return key;
61
+ };