@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,325 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Table Column Drag Demo - Reorder Columns</title>
7
+ <style>
8
+ body {
9
+ font-family:
10
+ system-ui,
11
+ -apple-system,
12
+ sans-serif;
13
+ margin: 0px;
14
+ padding: 0;
15
+ background: #f5f5f5;
16
+ }
17
+
18
+ .demo-container {
19
+ max-width: 1000px;
20
+ margin: 0 auto;
21
+ background: white;
22
+ padding: 20px;
23
+ border-radius: 8px;
24
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
25
+ }
26
+
27
+ /* Container with fixed size to show drag behavior */
28
+ .table-container {
29
+ height: 500px;
30
+ width: 800px;
31
+ overflow: auto;
32
+ margin: 20px 0;
33
+ border: 1px solid #ddd;
34
+ border-radius: 4px;
35
+ }
36
+
37
+ /* Status display */
38
+ .status {
39
+ margin-top: 20px;
40
+ padding: 10px;
41
+ background: #f0f8ff;
42
+ border-radius: 4px;
43
+ font-family: monospace;
44
+ font-size: 14px;
45
+ }
46
+
47
+ .actions {
48
+ margin-top: 15px;
49
+ }
50
+
51
+ .action-button {
52
+ background: #007acc;
53
+ color: white;
54
+ border: none;
55
+ padding: 8px 16px;
56
+ border-radius: 4px;
57
+ cursor: pointer;
58
+ margin-right: 10px;
59
+ }
60
+
61
+ .action-button:hover {
62
+ background: #005a9e;
63
+ }
64
+
65
+ .info {
66
+ background: #e8f4fd;
67
+ border: 1px solid #bee5eb;
68
+ border-radius: 4px;
69
+ padding: 15px;
70
+ margin-bottom: 20px;
71
+ }
72
+
73
+ .info h3 {
74
+ margin-top: 0;
75
+ color: #0c5460;
76
+ }
77
+
78
+ .info ul {
79
+ margin-bottom: 0;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <div class="demo-container">
85
+ <h1>Table Column Drag Demo</h1>
86
+
87
+ <div class="info">
88
+ <h3>Column Drag & Drop Features</h3>
89
+ <ul>
90
+ <li>
91
+ <strong>Drag to Reorder:</strong> Grab any column header and drag it
92
+ to reorder columns
93
+ </li>
94
+ <li>
95
+ <strong>Visual Feedback:</strong> Drag clone provides visual
96
+ indication of the column being moved
97
+ </li>
98
+ <li>
99
+ <strong>Real Data:</strong> Table contains realistic user data with
100
+ ID, name, email, and dates
101
+ </li>
102
+ <li>
103
+ <strong>No Sticky Headers:</strong> Focus on drag behavior without
104
+ sticky positioning complexity
105
+ </li>
106
+ </ul>
107
+ </div>
108
+
109
+ <div class="table-container">
110
+ <div id="root"></div>
111
+ </div>
112
+ </div>
113
+
114
+ <script type="module" jsenv-type="module/jsx">
115
+ import { render } from "preact";
116
+ import { useState, useRef } from "preact/hooks";
117
+ // eslint-disable-next-line no-unused-vars
118
+ import { Table } from "@jsenv/navi";
119
+
120
+ // Generate realistic user data
121
+ const firstNames = [
122
+ "John",
123
+ "Jane",
124
+ "Michael",
125
+ "Sarah",
126
+ "David",
127
+ "Emily",
128
+ "Chris",
129
+ "Lisa",
130
+ "Mark",
131
+ "Anna",
132
+ "Tom",
133
+ "Kate",
134
+ "Alex",
135
+ "Maria",
136
+ "Paul",
137
+ "Susan",
138
+ "Jake",
139
+ "Emma",
140
+ "Luke",
141
+ "Nina",
142
+ ];
143
+ const lastNames = [
144
+ "Smith",
145
+ "Johnson",
146
+ "Williams",
147
+ "Brown",
148
+ "Jones",
149
+ "Garcia",
150
+ "Miller",
151
+ "Davis",
152
+ "Rodriguez",
153
+ "Martinez",
154
+ "Hernandez",
155
+ "Lopez",
156
+ "Gonzalez",
157
+ "Wilson",
158
+ "Anderson",
159
+ "Thomas",
160
+ "Taylor",
161
+ "Moore",
162
+ "Jackson",
163
+ "Martin",
164
+ ];
165
+ const domains = [
166
+ "example.com",
167
+ "test.org",
168
+ "demo.net",
169
+ "sample.io",
170
+ "users.co",
171
+ ];
172
+
173
+ function generateRandomUser(id) {
174
+ const firstName =
175
+ firstNames[Math.floor(Math.random() * firstNames.length)];
176
+ const lastName =
177
+ lastNames[Math.floor(Math.random() * lastNames.length)];
178
+ const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@${domains[Math.floor(Math.random() * domains.length)]}`;
179
+ const creationDate = new Date(
180
+ 2020 + Math.random() * 4,
181
+ Math.floor(Math.random() * 12),
182
+ Math.floor(Math.random() * 28) + 1,
183
+ );
184
+
185
+ return {
186
+ id,
187
+ name: `${firstName} ${lastName}`,
188
+ email,
189
+ creation_date: creationDate.toLocaleDateString("en-US", {
190
+ year: "numeric",
191
+ month: "short",
192
+ day: "numeric",
193
+ }),
194
+ };
195
+ }
196
+
197
+ // Initial dataset
198
+ const initialData = [];
199
+ for (let i = 1; i <= 50; i++) {
200
+ initialData.push(generateRandomUser(i));
201
+ }
202
+
203
+ const initialColumns = [
204
+ { accessorKey: "id", value: "ID", width: 80 },
205
+ { accessorKey: "name", value: "Full Name", width: 180 },
206
+ { accessorKey: "email", value: "Email Address", width: 220 },
207
+ { accessorKey: "creation_date", value: "Created", width: 120 },
208
+ ];
209
+
210
+ // eslint-disable-next-line no-unused-vars
211
+ const TableDemo = () => {
212
+ const tableRef = useRef(null);
213
+ const [data, setData] = useState(initialData);
214
+ const [columns, setColumns] = useState(initialColumns);
215
+ const [lastAction, setLastAction] = useState(
216
+ "Ready for column dragging",
217
+ );
218
+
219
+ const resetColumns = () => {
220
+ setColumns(initialColumns);
221
+ setLastAction("Column order reset to default");
222
+ };
223
+
224
+ const addRandomUser = () => {
225
+ const newId = Math.max(...data.map((u) => u.id)) + 1;
226
+ const newUser = generateRandomUser(newId);
227
+ setData([...data, newUser]);
228
+ setLastAction(`Added new user: ${newUser.name}`);
229
+ };
230
+
231
+ const clearTable = () => {
232
+ setData([]);
233
+ setLastAction("Table cleared");
234
+ };
235
+
236
+ const handleColumnDrag = (fromIndex, toIndex) => {
237
+ const newColumns = [...columns];
238
+ const [movedColumn] = newColumns.splice(fromIndex, 1);
239
+ newColumns.splice(toIndex, 0, movedColumn);
240
+ setColumns(newColumns);
241
+ setLastAction(
242
+ `Moved column from position ${fromIndex + 1} to position ${toIndex + 1}`,
243
+ );
244
+ };
245
+
246
+ const handleSelectionChange = (selection) => {
247
+ const count = Object.keys(selection).length;
248
+ if (count > 0) {
249
+ setLastAction(`Selected ${count} row${count !== 1 ? "s" : ""}`);
250
+ }
251
+ };
252
+
253
+ return (
254
+ <div className="demo-container">
255
+ <h1>Table Column Drag Demo</h1>
256
+
257
+ <div className="info">
258
+ <h3>Column Drag & Drop Features</h3>
259
+ <ul>
260
+ <li>
261
+ <strong>Drag to Reorder:</strong> Grab any column header and
262
+ drag it to reorder columns
263
+ </li>
264
+ <li>
265
+ <strong>Visual Feedback:</strong> Drag clone provides visual
266
+ indication of the column being moved
267
+ </li>
268
+ <li>
269
+ <strong>Real Data:</strong> Table contains realistic user data
270
+ with ID, name, email, and dates
271
+ </li>
272
+ <li>
273
+ <strong>No Sticky Headers:</strong> Focus on drag behavior
274
+ without sticky positioning complexity
275
+ </li>
276
+ </ul>
277
+ </div>
278
+
279
+ <div className="table-container">
280
+ <Table
281
+ ref={tableRef}
282
+ data={data}
283
+ columns={columns}
284
+ // stickyColumn={false}
285
+ // stickyHeader={false}
286
+ onColumnDrag={handleColumnDrag}
287
+ onSelectionChange={handleSelectionChange}
288
+ />
289
+ </div>
290
+
291
+ <div className="status">
292
+ <div>
293
+ <strong>Column Order:</strong>{" "}
294
+ <span>{columns.map((col) => col.key).join(", ")}</span>
295
+ </div>
296
+ <div>
297
+ <strong>Last Action:</strong> <span>{lastAction}</span>
298
+ </div>
299
+ </div>
300
+
301
+ <div className="actions">
302
+ <button className="action-button" onClick={resetColumns}>
303
+ Reset Column Order
304
+ </button>
305
+ <button className="action-button" onClick={addRandomUser}>
306
+ Add Random User
307
+ </button>
308
+ <button className="action-button" onClick={clearTable}>
309
+ Clear Table
310
+ </button>
311
+ </div>
312
+ </div>
313
+ );
314
+ };
315
+
316
+ // Render the app
317
+ render(<TableDemo />, document.getElementById("root"));
318
+
319
+ console.log("Column drag demo loaded. Try:");
320
+ console.log("- Drag column headers to reorder columns");
321
+ console.log("- Click cells to select/deselect");
322
+ console.log("- Use the buttons to manipulate data");
323
+ </script>
324
+ </body>
325
+ </html>
@@ -103,7 +103,7 @@
103
103
  );
104
104
  };
105
105
 
106
- const TIME_TO_WAIT = 1_000;
106
+ const TIME_TO_WAIT = 2_000;
107
107
 
108
108
  // eslint-disable-next-line no-unused-vars
109
109
  const OutsideForm = () => {
@@ -165,9 +165,7 @@
165
165
  min="5"
166
166
  name="count"
167
167
  value={count}
168
- onInput={(e) => {
169
- setCount(e.target.valueAsNumber);
170
- }}
168
+ onValueChange={setCount}
171
169
  />
172
170
 
173
171
  <Form