@jsenv/navi 0.10.2 → 0.11.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.
- package/dist/jsenv_navi.js +13838 -23291
- package/dist/jsenv_navi.js.map +1281 -0
- package/package.json +5 -7
- package/index.js +0 -122
- package/src/action_private_properties.js +0 -11
- package/src/action_proxy_test.html +0 -353
- package/src/action_run_states.js +0 -5
- package/src/actions.js +0 -1401
- package/src/browser_integration/browser_integration.js +0 -216
- package/src/browser_integration/document_back_and_forward.js +0 -17
- package/src/browser_integration/document_loading_signal.js +0 -100
- package/src/browser_integration/document_state_signal.js +0 -9
- package/src/browser_integration/document_url_signal.js +0 -9
- package/src/browser_integration/use_is_visited.js +0 -19
- package/src/browser_integration/via_history.js +0 -232
- package/src/browser_integration/via_navigation.js +0 -168
- package/src/components/action_execution/form_context.js +0 -5
- package/src/components/action_execution/render_actionable_component.jsx +0 -29
- package/src/components/action_execution/use_action.js +0 -99
- package/src/components/action_execution/use_execute_action.js +0 -193
- package/src/components/action_execution/use_run_on_mount.js +0 -9
- package/src/components/action_renderer.jsx +0 -125
- package/src/components/callout/callout.js +0 -990
- package/src/components/callout/callout_demo.html +0 -201
- package/src/components/callout/test_dynamic_positioning.html +0 -161
- package/src/components/callout/test_html_document_iframe.html +0 -182
- package/src/components/demos/0_button_demo.html +0 -707
- package/src/components/demos/10_column_reordering_debug.html +0 -277
- package/src/components/demos/11_table_selection_debug.html +0 -432
- package/src/components/demos/1_checkbox_demo.html +0 -754
- package/src/components/demos/2_input_textual_demo.html +0 -286
- package/src/components/demos/3_radio_demo.html +0 -874
- package/src/components/demos/4_select_demo.html +0 -100
- package/src/components/demos/5_list_scrollable_demo.html +0 -153
- package/src/components/demos/6_tablist_demo.html +0 -77
- package/src/components/demos/7_table_selection_demo.html +0 -176
- package/src/components/demos/8_table_fixed_headers_demo.html +0 -584
- package/src/components/demos/9_table_column_drag_demo.html +0 -325
- package/src/components/demos/action/0_button_demo.html +0 -204
- package/src/components/demos/action/10_shortcuts_demo.html +0 -189
- package/src/components/demos/action/11_nested_shortcuts_demo.xhtml +0 -401
- package/src/components/demos/action/1_input_text_demo.html +0 -876
- package/src/components/demos/action/2_form_multiple.html +0 -303
- package/src/components/demos/action/3_details_demo.html +0 -203
- package/src/components/demos/action/4_input_checkbox_demo.html +0 -731
- package/src/components/demos/action/5_input_checkbox_state_demo.html +0 -270
- package/src/components/demos/action/6_checkbox_list_demo.html +0 -341
- package/src/components/demos/action/7_radio_list_demo.html +0 -357
- package/src/components/demos/action/8_editable_demo.html +0 -431
- package/src/components/demos/action/9_link_demo.html +0 -194
- package/src/components/demos/demo.md +0 -0
- package/src/components/demos/route/basic/basic.html +0 -14
- package/src/components/demos/route/basic/basic_route_demo.jsx +0 -224
- package/src/components/demos/route/multi/multi.html +0 -14
- package/src/components/demos/route/multi/multi_route_demo.jsx +0 -277
- package/src/components/demos/ui_transition/0_action_renderer_ui_transition_demo.html +0 -695
- package/src/components/demos/ui_transition/1_nested_ui_transition_demo.html +0 -429
- package/src/components/demos/ui_transition/2_height_transition_test.html +0 -295
- package/src/components/details/details.jsx +0 -245
- package/src/components/details/summary_marker.jsx +0 -141
- package/src/components/edition/editable.jsx +0 -186
- package/src/components/error_boundary_context.js +0 -9
- package/src/components/field/README.md +0 -247
- package/src/components/field/button.jsx +0 -429
- package/src/components/field/checkbox_list.jsx +0 -185
- package/src/components/field/collect_form_element_values.js +0 -82
- package/src/components/field/custom_field.js +0 -106
- package/src/components/field/form.jsx +0 -209
- package/src/components/field/input.jsx +0 -16
- package/src/components/field/input_checkbox.jsx +0 -434
- package/src/components/field/input_radio.jsx +0 -432
- package/src/components/field/input_textual.jsx +0 -389
- package/src/components/field/label.jsx +0 -46
- package/src/components/field/radio_list.jsx +0 -183
- package/src/components/field/select.jsx +0 -256
- package/src/components/field/use_action_events.js +0 -132
- package/src/components/field/use_form_events.js +0 -59
- package/src/components/field/use_ui_state_controller.js +0 -506
- package/src/components/item_tracker/README.md +0 -461
- package/src/components/item_tracker/use_isolated_item_tracker.jsx +0 -209
- package/src/components/item_tracker/use_isolated_item_tracker_demo.html +0 -148
- package/src/components/item_tracker/use_isolated_item_tracker_demo.jsx +0 -460
- package/src/components/item_tracker/use_item_tracker.jsx +0 -143
- package/src/components/item_tracker/use_item_tracker_demo.html +0 -207
- package/src/components/item_tracker/use_item_tracker_demo.jsx +0 -216
- package/src/components/keyboard_shortcuts/active_keyboard_shortcuts.jsx +0 -87
- package/src/components/keyboard_shortcuts/aria_key_shortcuts.js +0 -61
- package/src/components/keyboard_shortcuts/keyboard_key_meta.js +0 -17
- package/src/components/keyboard_shortcuts/keyboard_shortcuts.js +0 -371
- package/src/components/keyboard_shortcuts/os.js +0 -9
- package/src/components/layout/demos/demo_flex.html +0 -638
- package/src/components/layout/demos/demo_layout_style_buttons.html +0 -351
- package/src/components/layout/demos/demo_layout_style_input.html +0 -226
- package/src/components/layout/demos/demo_layout_style_text.html +0 -514
- package/src/components/layout/flex.jsx +0 -109
- package/src/components/layout/layout_context.jsx +0 -3
- package/src/components/layout/spacing.jsx +0 -20
- package/src/components/layout/use_layout_style.js +0 -249
- package/src/components/link/link.jsx +0 -267
- package/src/components/link/link_with_icon.jsx +0 -52
- package/src/components/loader/loader_background.jsx +0 -372
- package/src/components/loader/loading_spinner.jsx +0 -68
- package/src/components/loader/network_speed.js +0 -83
- package/src/components/loader/rectangle_loading.jsx +0 -244
- package/src/components/props_composition/demos/demo_with_props_style.html +0 -81
- package/src/components/props_composition/with_props_class_name.js +0 -37
- package/src/components/props_composition/with_props_style.js +0 -26
- package/src/components/route.jsx +0 -19
- package/src/components/selection/selection.jsx +0 -1583
- package/src/components/svg/font_sized_svg.jsx +0 -59
- package/src/components/svg/icon_and_text.jsx +0 -21
- package/src/components/svg/svg_mask_overlay.jsx +0 -105
- package/src/components/table/drag/table_drag.jsx +0 -506
- package/src/components/table/resize/table_resize.jsx +0 -650
- package/src/components/table/resize/table_size.js +0 -43
- package/src/components/table/selection/table_selection.js +0 -106
- package/src/components/table/selection/table_selection.jsx +0 -203
- package/src/components/table/sticky/sticky_group.js +0 -354
- package/src/components/table/sticky/table_sticky.js +0 -25
- package/src/components/table/sticky/table_sticky.jsx +0 -501
- package/src/components/table/table.jsx +0 -721
- package/src/components/table/table_css.js +0 -211
- package/src/components/table/table_ui.jsx +0 -49
- package/src/components/table/use_cells_and_columns.js +0 -90
- package/src/components/table/use_object_array_to_cells.js +0 -46
- package/src/components/table/z_indexes.js +0 -23
- package/src/components/tablist/tablist.jsx +0 -99
- package/src/components/text/demos/demo_text_and_icon.html +0 -421
- package/src/components/text/overflow.jsx +0 -15
- package/src/components/text/text.jsx +0 -83
- package/src/components/text/text_and_count.jsx +0 -28
- package/src/components/ui_transition.jsx +0 -128
- package/src/components/use_auto_focus.js +0 -94
- package/src/components/use_batch_during_render.js +0 -33
- package/src/components/use_debounce_true.js +0 -31
- package/src/components/use_dependencies_diff.js +0 -35
- package/src/components/use_focus_group.js +0 -20
- package/src/components/use_initial_value.js +0 -78
- package/src/components/use_is_visited.js +0 -19
- package/src/components/use_ref_array.js +0 -38
- package/src/components/use_signal_sync.js +0 -50
- package/src/components/use_stable_callback.js +0 -68
- package/src/components/use_state_array.js +0 -47
- package/src/docs/actions.md +0 -250
- package/src/docs/demos/resource/action_status.jsx +0 -42
- package/src/docs/demos/resource/demo.md +0 -1
- package/src/docs/demos/resource/resource_demo_0.html +0 -84
- package/src/docs/demos/resource/resource_demo_10_post_gc.html +0 -364
- package/src/docs/demos/resource/resource_demo_11_describe_many.html +0 -362
- package/src/docs/demos/resource/resource_demo_2.html +0 -173
- package/src/docs/demos/resource/resource_demo_3_filtered_users.html +0 -415
- package/src/docs/demos/resource/resource_demo_4_details.html +0 -284
- package/src/docs/demos/resource/resource_demo_5_renderer_lazy.html +0 -115
- package/src/docs/demos/resource/resource_demo_6_gc.html +0 -217
- package/src/docs/demos/resource/resource_demo_7_child_gc.html +0 -240
- package/src/docs/demos/resource/resource_demo_8_proxy_gc.html +0 -319
- package/src/docs/demos/resource/resource_demo_9_describe_one.html +0 -472
- package/src/docs/demos/resource/tata.jsx +0 -3
- package/src/docs/demos/resource/toto.jsx +0 -3
- package/src/docs/demos/user_nav/user_nav.html +0 -12
- package/src/docs/demos/user_nav/user_nav.jsx +0 -330
- package/src/docs/resource_dependencies.md +0 -103
- package/src/docs/resource_with_params.md +0 -80
- package/src/navi_css_vars.js +0 -14
- package/src/notes.md +0 -34
- package/src/route/route.js +0 -596
- package/src/route/route.xtest.html +0 -228
- package/src/store/array_signal_store.js +0 -537
- package/src/store/local_storage_signal.js +0 -17
- package/src/store/resource_graph.js +0 -1304
- package/src/store/tests/resource_graph_autoreload_demo.html +0 -12
- package/src/store/tests/resource_graph_autoreload_demo.jsx +0 -964
- package/src/store/tests/resource_graph_dependencies.test_manual.js +0 -95
- package/src/store/value_in_local_storage.js +0 -187
- package/src/symbol_object_signal.js +0 -1
- package/src/use_action_data.js +0 -10
- package/src/use_action_status.js +0 -47
- package/src/utils/add_many_event_listeners.js +0 -15
- package/src/utils/array_add_remove.js +0 -61
- package/src/utils/array_signal.js +0 -15
- package/src/utils/compare_two_js_values.js +0 -172
- package/src/utils/execute_with_cleanup.js +0 -21
- package/src/utils/get_caller_info.js +0 -85
- package/src/utils/is_signal.js +0 -20
- package/src/utils/js_value_weak_map.js +0 -162
- package/src/utils/js_value_weak_map_demo.html +0 -690
- package/src/utils/merge_two_js_values.js +0 -53
- package/src/utils/stringify_for_display.js +0 -131
- package/src/utils/weak_effect.js +0 -48
- package/src/validation/constraints/confirm_constraint.js +0 -14
- package/src/validation/constraints/create_unique_value_constraint.js +0 -27
- package/src/validation/constraints/native_constraints.js +0 -338
- package/src/validation/constraints/readonly_constraint.js +0 -41
- package/src/validation/constraints/same_as_constraint.js +0 -42
- package/src/validation/constraints/single_space_constraint.js +0 -13
- package/src/validation/custom_constraint_validation.js +0 -793
- package/src/validation/custom_message.js +0 -18
- package/src/validation/demos/browser_style.png +0 -0
- package/src/validation/demos/demo_same_as_constraint.html +0 -259
- package/src/validation/demos/form_validation_demo.html +0 -142
- package/src/validation/demos/form_validation_demo_preact.html +0 -87
- package/src/validation/demos/form_validation_native_popover_demo.html +0 -168
- package/src/validation/demos/form_validation_vs_native_demo.html +0 -172
- package/src/validation/hooks/use_constraints.js +0 -23
- package/src/validation/hooks/use_custom_validation_ref.js +0 -73
- package/src/validation/hooks/use_validation_message.js +0 -19
- package/src/validation/input_change_effect.js +0 -106
|
@@ -1,143 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,207 +0,0 @@
|
|
|
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>
|
|
@@ -1,216 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
};
|