@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.
Files changed (207) hide show
  1. package/dist/jsenv_navi.js +13838 -23291
  2. package/dist/jsenv_navi.js.map +1281 -0
  3. package/package.json +5 -7
  4. package/index.js +0 -122
  5. package/src/action_private_properties.js +0 -11
  6. package/src/action_proxy_test.html +0 -353
  7. package/src/action_run_states.js +0 -5
  8. package/src/actions.js +0 -1401
  9. package/src/browser_integration/browser_integration.js +0 -216
  10. package/src/browser_integration/document_back_and_forward.js +0 -17
  11. package/src/browser_integration/document_loading_signal.js +0 -100
  12. package/src/browser_integration/document_state_signal.js +0 -9
  13. package/src/browser_integration/document_url_signal.js +0 -9
  14. package/src/browser_integration/use_is_visited.js +0 -19
  15. package/src/browser_integration/via_history.js +0 -232
  16. package/src/browser_integration/via_navigation.js +0 -168
  17. package/src/components/action_execution/form_context.js +0 -5
  18. package/src/components/action_execution/render_actionable_component.jsx +0 -29
  19. package/src/components/action_execution/use_action.js +0 -99
  20. package/src/components/action_execution/use_execute_action.js +0 -193
  21. package/src/components/action_execution/use_run_on_mount.js +0 -9
  22. package/src/components/action_renderer.jsx +0 -125
  23. package/src/components/callout/callout.js +0 -990
  24. package/src/components/callout/callout_demo.html +0 -201
  25. package/src/components/callout/test_dynamic_positioning.html +0 -161
  26. package/src/components/callout/test_html_document_iframe.html +0 -182
  27. package/src/components/demos/0_button_demo.html +0 -707
  28. package/src/components/demos/10_column_reordering_debug.html +0 -277
  29. package/src/components/demos/11_table_selection_debug.html +0 -432
  30. package/src/components/demos/1_checkbox_demo.html +0 -754
  31. package/src/components/demos/2_input_textual_demo.html +0 -286
  32. package/src/components/demos/3_radio_demo.html +0 -874
  33. package/src/components/demos/4_select_demo.html +0 -100
  34. package/src/components/demos/5_list_scrollable_demo.html +0 -153
  35. package/src/components/demos/6_tablist_demo.html +0 -77
  36. package/src/components/demos/7_table_selection_demo.html +0 -176
  37. package/src/components/demos/8_table_fixed_headers_demo.html +0 -584
  38. package/src/components/demos/9_table_column_drag_demo.html +0 -325
  39. package/src/components/demos/action/0_button_demo.html +0 -204
  40. package/src/components/demos/action/10_shortcuts_demo.html +0 -189
  41. package/src/components/demos/action/11_nested_shortcuts_demo.xhtml +0 -401
  42. package/src/components/demos/action/1_input_text_demo.html +0 -876
  43. package/src/components/demos/action/2_form_multiple.html +0 -303
  44. package/src/components/demos/action/3_details_demo.html +0 -203
  45. package/src/components/demos/action/4_input_checkbox_demo.html +0 -731
  46. package/src/components/demos/action/5_input_checkbox_state_demo.html +0 -270
  47. package/src/components/demos/action/6_checkbox_list_demo.html +0 -341
  48. package/src/components/demos/action/7_radio_list_demo.html +0 -357
  49. package/src/components/demos/action/8_editable_demo.html +0 -431
  50. package/src/components/demos/action/9_link_demo.html +0 -194
  51. package/src/components/demos/demo.md +0 -0
  52. package/src/components/demos/route/basic/basic.html +0 -14
  53. package/src/components/demos/route/basic/basic_route_demo.jsx +0 -224
  54. package/src/components/demos/route/multi/multi.html +0 -14
  55. package/src/components/demos/route/multi/multi_route_demo.jsx +0 -277
  56. package/src/components/demos/ui_transition/0_action_renderer_ui_transition_demo.html +0 -695
  57. package/src/components/demos/ui_transition/1_nested_ui_transition_demo.html +0 -429
  58. package/src/components/demos/ui_transition/2_height_transition_test.html +0 -295
  59. package/src/components/details/details.jsx +0 -245
  60. package/src/components/details/summary_marker.jsx +0 -141
  61. package/src/components/edition/editable.jsx +0 -186
  62. package/src/components/error_boundary_context.js +0 -9
  63. package/src/components/field/README.md +0 -247
  64. package/src/components/field/button.jsx +0 -429
  65. package/src/components/field/checkbox_list.jsx +0 -185
  66. package/src/components/field/collect_form_element_values.js +0 -82
  67. package/src/components/field/custom_field.js +0 -106
  68. package/src/components/field/form.jsx +0 -209
  69. package/src/components/field/input.jsx +0 -16
  70. package/src/components/field/input_checkbox.jsx +0 -434
  71. package/src/components/field/input_radio.jsx +0 -432
  72. package/src/components/field/input_textual.jsx +0 -389
  73. package/src/components/field/label.jsx +0 -46
  74. package/src/components/field/radio_list.jsx +0 -183
  75. package/src/components/field/select.jsx +0 -256
  76. package/src/components/field/use_action_events.js +0 -132
  77. package/src/components/field/use_form_events.js +0 -59
  78. package/src/components/field/use_ui_state_controller.js +0 -506
  79. package/src/components/item_tracker/README.md +0 -461
  80. package/src/components/item_tracker/use_isolated_item_tracker.jsx +0 -209
  81. package/src/components/item_tracker/use_isolated_item_tracker_demo.html +0 -148
  82. package/src/components/item_tracker/use_isolated_item_tracker_demo.jsx +0 -460
  83. package/src/components/item_tracker/use_item_tracker.jsx +0 -143
  84. package/src/components/item_tracker/use_item_tracker_demo.html +0 -207
  85. package/src/components/item_tracker/use_item_tracker_demo.jsx +0 -216
  86. package/src/components/keyboard_shortcuts/active_keyboard_shortcuts.jsx +0 -87
  87. package/src/components/keyboard_shortcuts/aria_key_shortcuts.js +0 -61
  88. package/src/components/keyboard_shortcuts/keyboard_key_meta.js +0 -17
  89. package/src/components/keyboard_shortcuts/keyboard_shortcuts.js +0 -371
  90. package/src/components/keyboard_shortcuts/os.js +0 -9
  91. package/src/components/layout/demos/demo_flex.html +0 -638
  92. package/src/components/layout/demos/demo_layout_style_buttons.html +0 -351
  93. package/src/components/layout/demos/demo_layout_style_input.html +0 -226
  94. package/src/components/layout/demos/demo_layout_style_text.html +0 -514
  95. package/src/components/layout/flex.jsx +0 -109
  96. package/src/components/layout/layout_context.jsx +0 -3
  97. package/src/components/layout/spacing.jsx +0 -20
  98. package/src/components/layout/use_layout_style.js +0 -249
  99. package/src/components/link/link.jsx +0 -267
  100. package/src/components/link/link_with_icon.jsx +0 -52
  101. package/src/components/loader/loader_background.jsx +0 -372
  102. package/src/components/loader/loading_spinner.jsx +0 -68
  103. package/src/components/loader/network_speed.js +0 -83
  104. package/src/components/loader/rectangle_loading.jsx +0 -244
  105. package/src/components/props_composition/demos/demo_with_props_style.html +0 -81
  106. package/src/components/props_composition/with_props_class_name.js +0 -37
  107. package/src/components/props_composition/with_props_style.js +0 -26
  108. package/src/components/route.jsx +0 -19
  109. package/src/components/selection/selection.jsx +0 -1583
  110. package/src/components/svg/font_sized_svg.jsx +0 -59
  111. package/src/components/svg/icon_and_text.jsx +0 -21
  112. package/src/components/svg/svg_mask_overlay.jsx +0 -105
  113. package/src/components/table/drag/table_drag.jsx +0 -506
  114. package/src/components/table/resize/table_resize.jsx +0 -650
  115. package/src/components/table/resize/table_size.js +0 -43
  116. package/src/components/table/selection/table_selection.js +0 -106
  117. package/src/components/table/selection/table_selection.jsx +0 -203
  118. package/src/components/table/sticky/sticky_group.js +0 -354
  119. package/src/components/table/sticky/table_sticky.js +0 -25
  120. package/src/components/table/sticky/table_sticky.jsx +0 -501
  121. package/src/components/table/table.jsx +0 -721
  122. package/src/components/table/table_css.js +0 -211
  123. package/src/components/table/table_ui.jsx +0 -49
  124. package/src/components/table/use_cells_and_columns.js +0 -90
  125. package/src/components/table/use_object_array_to_cells.js +0 -46
  126. package/src/components/table/z_indexes.js +0 -23
  127. package/src/components/tablist/tablist.jsx +0 -99
  128. package/src/components/text/demos/demo_text_and_icon.html +0 -421
  129. package/src/components/text/overflow.jsx +0 -15
  130. package/src/components/text/text.jsx +0 -83
  131. package/src/components/text/text_and_count.jsx +0 -28
  132. package/src/components/ui_transition.jsx +0 -128
  133. package/src/components/use_auto_focus.js +0 -94
  134. package/src/components/use_batch_during_render.js +0 -33
  135. package/src/components/use_debounce_true.js +0 -31
  136. package/src/components/use_dependencies_diff.js +0 -35
  137. package/src/components/use_focus_group.js +0 -20
  138. package/src/components/use_initial_value.js +0 -78
  139. package/src/components/use_is_visited.js +0 -19
  140. package/src/components/use_ref_array.js +0 -38
  141. package/src/components/use_signal_sync.js +0 -50
  142. package/src/components/use_stable_callback.js +0 -68
  143. package/src/components/use_state_array.js +0 -47
  144. package/src/docs/actions.md +0 -250
  145. package/src/docs/demos/resource/action_status.jsx +0 -42
  146. package/src/docs/demos/resource/demo.md +0 -1
  147. package/src/docs/demos/resource/resource_demo_0.html +0 -84
  148. package/src/docs/demos/resource/resource_demo_10_post_gc.html +0 -364
  149. package/src/docs/demos/resource/resource_demo_11_describe_many.html +0 -362
  150. package/src/docs/demos/resource/resource_demo_2.html +0 -173
  151. package/src/docs/demos/resource/resource_demo_3_filtered_users.html +0 -415
  152. package/src/docs/demos/resource/resource_demo_4_details.html +0 -284
  153. package/src/docs/demos/resource/resource_demo_5_renderer_lazy.html +0 -115
  154. package/src/docs/demos/resource/resource_demo_6_gc.html +0 -217
  155. package/src/docs/demos/resource/resource_demo_7_child_gc.html +0 -240
  156. package/src/docs/demos/resource/resource_demo_8_proxy_gc.html +0 -319
  157. package/src/docs/demos/resource/resource_demo_9_describe_one.html +0 -472
  158. package/src/docs/demos/resource/tata.jsx +0 -3
  159. package/src/docs/demos/resource/toto.jsx +0 -3
  160. package/src/docs/demos/user_nav/user_nav.html +0 -12
  161. package/src/docs/demos/user_nav/user_nav.jsx +0 -330
  162. package/src/docs/resource_dependencies.md +0 -103
  163. package/src/docs/resource_with_params.md +0 -80
  164. package/src/navi_css_vars.js +0 -14
  165. package/src/notes.md +0 -34
  166. package/src/route/route.js +0 -596
  167. package/src/route/route.xtest.html +0 -228
  168. package/src/store/array_signal_store.js +0 -537
  169. package/src/store/local_storage_signal.js +0 -17
  170. package/src/store/resource_graph.js +0 -1304
  171. package/src/store/tests/resource_graph_autoreload_demo.html +0 -12
  172. package/src/store/tests/resource_graph_autoreload_demo.jsx +0 -964
  173. package/src/store/tests/resource_graph_dependencies.test_manual.js +0 -95
  174. package/src/store/value_in_local_storage.js +0 -187
  175. package/src/symbol_object_signal.js +0 -1
  176. package/src/use_action_data.js +0 -10
  177. package/src/use_action_status.js +0 -47
  178. package/src/utils/add_many_event_listeners.js +0 -15
  179. package/src/utils/array_add_remove.js +0 -61
  180. package/src/utils/array_signal.js +0 -15
  181. package/src/utils/compare_two_js_values.js +0 -172
  182. package/src/utils/execute_with_cleanup.js +0 -21
  183. package/src/utils/get_caller_info.js +0 -85
  184. package/src/utils/is_signal.js +0 -20
  185. package/src/utils/js_value_weak_map.js +0 -162
  186. package/src/utils/js_value_weak_map_demo.html +0 -690
  187. package/src/utils/merge_two_js_values.js +0 -53
  188. package/src/utils/stringify_for_display.js +0 -131
  189. package/src/utils/weak_effect.js +0 -48
  190. package/src/validation/constraints/confirm_constraint.js +0 -14
  191. package/src/validation/constraints/create_unique_value_constraint.js +0 -27
  192. package/src/validation/constraints/native_constraints.js +0 -338
  193. package/src/validation/constraints/readonly_constraint.js +0 -41
  194. package/src/validation/constraints/same_as_constraint.js +0 -42
  195. package/src/validation/constraints/single_space_constraint.js +0 -13
  196. package/src/validation/custom_constraint_validation.js +0 -793
  197. package/src/validation/custom_message.js +0 -18
  198. package/src/validation/demos/browser_style.png +0 -0
  199. package/src/validation/demos/demo_same_as_constraint.html +0 -259
  200. package/src/validation/demos/form_validation_demo.html +0 -142
  201. package/src/validation/demos/form_validation_demo_preact.html +0 -87
  202. package/src/validation/demos/form_validation_native_popover_demo.html +0 -168
  203. package/src/validation/demos/form_validation_vs_native_demo.html +0 -172
  204. package/src/validation/hooks/use_constraints.js +0 -23
  205. package/src/validation/hooks/use_custom_validation_ref.js +0 -73
  206. package/src/validation/hooks/use_validation_message.js +0 -19
  207. package/src/validation/input_change_effect.js +0 -106
@@ -1,325 +0,0 @@
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>
@@ -1,204 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" href="data:," />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Button demo</title>
8
- </head>
9
- <body>
10
- <div id="root" style="position: relative"></div>
11
-
12
- <script type="module" jsenv-type="module/jsx">
13
- import { render } from "preact";
14
- import { useState } from "preact/hooks";
15
- import {
16
- // eslint-disable-next-line no-unused-vars
17
- Input,
18
- // eslint-disable-next-line no-unused-vars
19
- Button,
20
- // eslint-disable-next-line no-unused-vars
21
- Form,
22
- } from "@jsenv/navi";
23
-
24
- // eslint-disable-next-line no-unused-vars
25
- const App = () => {
26
- return (
27
- <div>
28
- <div style="display: flex; flex-direction: row; gap: 30px">
29
- <div>
30
- <p>
31
- <strong>Default</strong>
32
- </p>
33
- <Button>A</Button>
34
- </div>
35
-
36
- <div>
37
- <p>
38
- <strong>Big content</strong>
39
- </p>
40
- <Button>
41
- <div style="width: 50px; height: 50px;">B</div>
42
- </Button>
43
- </div>
44
-
45
- <div>
46
- <p>
47
- <strong>Border radius</strong>
48
- </p>
49
- <Button style={{ "--border-radius": "20px" }}>C</Button>
50
- </div>
51
- </div>
52
-
53
- <div style="display: flex; flex-direction: row; gap: 30px">
54
- <div>
55
- <p>
56
- <strong>Violet border</strong>
57
- </p>
58
- <Button style={{ "--border-color": "violet" }}>D</Button>
59
- </div>
60
-
61
- <div>
62
- <p>
63
- <strong>Border width</strong>
64
- </p>
65
- <Button style={{ "--border-width": "10px" }}>D</Button>
66
- </div>
67
-
68
- <div>
69
- <p>
70
- <strong>Outline width</strong>
71
- </p>
72
- <Button
73
- style={{ "--border-width": "5px", "--outline-width": "5px" }}
74
- >
75
- D
76
- </Button>
77
- </div>
78
- </div>
79
-
80
- <div style="display: flex; flex-direction: row; gap: 30px">
81
- <div>
82
- <p>
83
- <strong>Outside form</strong>
84
- </p>
85
- <OutsideForm />
86
- </div>
87
- </div>
88
-
89
- <div style="display: flex; flex-direction: row; gap: 30px">
90
- <div>
91
- <p>
92
- <strong>Inside form</strong>
93
- </p>
94
- <InsideForm />
95
- </div>
96
-
97
- <div>
98
- <p>
99
- <strong>Inside form (allow concurrent)</strong>
100
- </p>
101
- <InsideForm allowConcurrentActions />
102
- </div>
103
- </div>
104
- </div>
105
- );
106
- };
107
-
108
- const TIME_TO_WAIT = 2_000;
109
-
110
- // eslint-disable-next-line no-unused-vars
111
- const OutsideForm = () => {
112
- const [count, setCount] = useState(0);
113
-
114
- return (
115
- <div>
116
- <span>
117
- Count: {count}{" "}
118
- <button
119
- onClick={() => {
120
- setCount((count) => count + 1);
121
- }}
122
- >
123
- +
124
- </button>
125
- <button
126
- onClick={() => {
127
- setCount((count) => count - 1);
128
- }}
129
- >
130
- -
131
- </button>
132
- </span>
133
-
134
- <div>
135
- <Button
136
- action={async () => {
137
- setTimeout(() => {
138
- setCount((count) => count + 1);
139
- }, 200);
140
- await new Promise((resolve) =>
141
- setTimeout(resolve, TIME_TO_WAIT),
142
- );
143
- throw new Error(`test: ${count}`);
144
- }}
145
- >
146
- Hello
147
- </Button>
148
- </div>
149
- </div>
150
- );
151
- };
152
-
153
- // eslint-disable-next-line no-unused-vars
154
- const InsideForm = (props) => {
155
- const [count, setCount] = useState(0);
156
-
157
- return (
158
- <div>
159
- <p>
160
- <i>
161
- This input is outside the form (it is not expected to become
162
- readonly), it can be used to force re-render
163
- </i>
164
- </p>
165
- <Input
166
- type="number"
167
- min="5"
168
- name="count"
169
- value={count}
170
- onValueChange={setCount}
171
- />
172
-
173
- <Form
174
- action={async ({ name }) => {
175
- await new Promise((resolve) =>
176
- setTimeout(resolve, TIME_TO_WAIT),
177
- );
178
- console.log(`form action: { count: ${count}, name: ${name} }`);
179
- }}
180
- {...props}
181
- >
182
- <Input type="hidden" name="name" value="dam" />
183
- <Button
184
- action={async ({ name }) => {
185
- await new Promise((resolve) =>
186
- setTimeout(resolve, TIME_TO_WAIT),
187
- );
188
- throw new Error(
189
- `button action: { count: ${count}, name: ${name} }`,
190
- );
191
- }}
192
- >
193
- Hello
194
- </Button>
195
- <Button type="submit">Submit</Button>
196
- </Form>
197
- </div>
198
- );
199
- };
200
-
201
- render(<App />, document.querySelector("#root"));
202
- </script>
203
- </body>
204
- </html>