@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,211 +0,0 @@
1
- import { Z_INDEX_EDITING } from "./z_indexes.js";
2
-
3
- /*
4
- * Box-shadow border mapping template:
5
- *
6
- * box-shadow:
7
- * inset 0 1px 0 0 color, // Top border
8
- * inset 1px 0 0 0 color, // Left border
9
- * inset -1px 0 0 0 color, // Right border
10
- * inset 0 -1px 0 0 color; // Bottom border
11
- */
12
-
13
- import.meta.css = /* css */ `
14
- .navi_table_root {
15
- position: relative;
16
- max-width: var(--table-max-width, none);
17
- max-height: var(--table-max-height, none);
18
- }
19
-
20
- .navi_table_container {
21
- --border-color: #e1e1e1;
22
- --focus-border-color: #0078d4;
23
- position: relative;
24
- }
25
-
26
- .navi_table {
27
- border-radius: 2px;
28
- border-spacing: 0; /* Required for manual border collapse */
29
- }
30
- .navi_table_cell {
31
- white-space: nowrap;
32
- overflow: hidden;
33
- text-overflow: ellipsis;
34
- background-color: var(--background-color, transparent);
35
- }
36
-
37
- .navi_table_cell[data-align-x="start"] {
38
- text-align: left;
39
- }
40
- .navi_table_cell[data-align-x="center"] {
41
- text-align: center;
42
- }
43
- .navi_table_cell[data-align-y="end"] {
44
- text-align: right;
45
- }
46
- .navi_table_cell[data-align-x="start"] {
47
- vertical-align: top;
48
- }
49
- .navi_table_cell[data-align-y="center"] {
50
- vertical-align: middle;
51
- }
52
- .navi_table_cell[data-align-y="end"] {
53
- vertical-align: bottom;
54
- }
55
-
56
- /* Table borders using ::before pseudo-elements */
57
- /* Default: each cell draws all its own borders (no border-collapse) */
58
- .navi_table_cell {
59
- border: none; /* Remove default borders - we'll use pseudo-elements */
60
- /* Required for pseudo-element positioning */
61
- position: relative;
62
- }
63
-
64
- .navi_table_cell::before {
65
- content: "";
66
- position: absolute;
67
- inset: 0;
68
- pointer-events: none;
69
- box-shadow:
70
- inset 0 1px 0 0 var(--border-color),
71
- inset 1px 0 0 0 var(--border-color),
72
- inset -1px 0 0 0 var(--border-color),
73
- inset 0 -1px 0 0 var(--border-color);
74
- }
75
- .navi_table_cell::after {
76
- content: "";
77
- position: absolute;
78
- /* Default: include bottom and right borders (owned by this cell) */
79
- inset: 0;
80
- pointer-events: none;
81
- }
82
-
83
- /* padding */
84
- .navi_table_cell {
85
- padding-left: 12px;
86
- padding-right: 12px;
87
- padding-top: 8px;
88
- padding-bottom: 8px;
89
- }
90
- .navi_table_cell[data-width-xxs] {
91
- padding-left: 0;
92
- padding-right: 0;
93
- }
94
- .navi_table_cell[data-height-xxs] {
95
- padding-top: 0;
96
- padding-bottom: 0;
97
- }
98
- .navi_table_cell[data-editing] input {
99
- padding: 0;
100
- padding-left: 12px;
101
- }
102
- .navi_table [data-sticky-left-frontier] {
103
- /* padding-left: 12px; */
104
- /* 12 px + 5px of the sticky frontier */
105
- /* padding-right: 17px; */
106
- }
107
-
108
- .navi_table_cell {
109
- user-select: none;
110
- }
111
-
112
- /* Number column specific styling */
113
- .navi_row_number_cell {
114
- text-align: center;
115
- background: #fafafa;
116
- font-weight: 500;
117
- color: #666;
118
- user-select: none;
119
- }
120
-
121
- .navi_table_cell_content_bold_clone {
122
- font-weight: bold; /* force bold to compute max width */
123
- visibility: hidden; /* not visible */
124
- display: block; /* in-flow so it contributes to width */
125
- height: 0; /* zero height so it doesn't change layout height */
126
- overflow: hidden; /* avoid any accidental height */
127
- pointer-events: none; /* inert */
128
- }
129
-
130
- /* Border-collapse mode: each cell only owns specific borders to avoid doubling */
131
-
132
- /* Base rule: all cells get right and bottom borders */
133
- .navi_table[data-border-collapse] .navi_table_cell::before {
134
- box-shadow:
135
- inset -1px 0 0 0 var(--border-color),
136
- inset 0 -1px 0 0 var(--border-color);
137
- }
138
-
139
- /* Header cells (all th) get top border in addition to right and bottom */
140
- .navi_table[data-border-collapse] .navi_table_cell[data-first-row]::before {
141
- box-shadow:
142
- inset 0 1px 0 0 var(--border-color),
143
- inset -1px 0 0 0 var(--border-color),
144
- inset 0 -1px 0 0 var(--border-color);
145
- }
146
-
147
- /* First column cells get left border in addition to right and bottom */
148
- .navi_table[data-border-collapse]
149
- .navi_table_cell[data-first-column]::before {
150
- box-shadow:
151
- inset 1px 0 0 0 var(--border-color),
152
- inset -1px 0 0 0 var(--border-color),
153
- inset 0 -1px 0 0 var(--border-color);
154
- }
155
-
156
- /* Header first column gets all four borders */
157
- .navi_table[data-border-collapse]
158
- .navi_table_cell[data-first-row][data-first-column]::before {
159
- box-shadow:
160
- inset 0 1px 0 0 var(--border-color),
161
- inset 1px 0 0 0 var(--border-color),
162
- inset -1px 0 0 0 var(--border-color),
163
- inset 0 -1px 0 0 var(--border-color);
164
- }
165
-
166
- /* Focus styles */
167
- .navi_table_cell[data-focus] {
168
- outline: none; /* Remove default outline */
169
- }
170
-
171
- .navi_table_cell[data-focus]::after {
172
- box-shadow:
173
- inset 0 2px 0 0 var(--focus-border-color),
174
- inset -2px 0 0 0 var(--focus-border-color),
175
- inset 0 -2px 0 0 var(--focus-border-color),
176
- inset 2px 0 0 0 var(--focus-border-color) !important;
177
- }
178
-
179
- .navi_table {
180
- font-size: 16px;
181
- font-family: Arial;
182
-
183
- --editing-border-color: #a8c7fa;
184
- }
185
-
186
- .navi_table_cell[data-editing] .navi_table_cell_content {
187
- outline: 2px solid #a8c7fa;
188
- outline-offset: 0px;
189
- }
190
-
191
- .navi_table_cell[data-editing] input {
192
- width: 100%;
193
- height: 100%;
194
- display: inline-flex;
195
- flex-grow: 1;
196
- border-radius: 0; /* match table cell border-radius */
197
- border: none;
198
- font-size: 16px;
199
- }
200
-
201
- .navi_table_cell[data-editing]
202
- input[type="number"]::-webkit-inner-spin-button {
203
- width: 14px;
204
- height: 30px;
205
- }
206
-
207
- .navi_table_cell[data-editing] {
208
- outline: 2px solid var(--editing-border-color);
209
- z-index: ${Z_INDEX_EDITING};
210
- }
211
- `;
@@ -1,49 +0,0 @@
1
- import { visibleRectEffect } from "@jsenv/dom";
2
- import { createPortal, forwardRef } from "preact/compat";
3
- import { useLayoutEffect } from "preact/hooks";
4
-
5
- import { Z_INDEX_TABLE_UI } from "./z_indexes.js";
6
-
7
- import.meta.css = /* css */ `
8
- .navi_table_ui {
9
- position: fixed;
10
- z-index: ${Z_INDEX_TABLE_UI};
11
- overflow: hidden; /* Ensure UI elements cannot impact scrollbars of the document */
12
- inset: 0;
13
- pointer-events: none; /* UI elements must use pointer-events: auto if they need to be interactive */
14
- /* background: rgba(0, 255, 0, 0.2); */
15
- }
16
- `;
17
-
18
- export const TableUI = forwardRef((props, ref) => {
19
- const { tableRef, tableId, children } = props;
20
-
21
- // ui positioning
22
- useLayoutEffect(() => {
23
- const ui = ref.current;
24
- const table = tableRef.current;
25
- if (!ui || !table) {
26
- return null;
27
- }
28
-
29
- // TODO: external code should be able to call tableVisibleRectEffect.check();
30
- // (for the drag operation when we scroll)
31
- // -> actually not that important because browser will dispatch "scroll" events
32
- // cause by programmatic scrolls before re-painting
33
- // -> no intermediate state visible to the user where overlay is not in sync
34
- const tableVisibleRectEffect = visibleRectEffect(table, (visibleRect) => {
35
- ui.style.setProperty("--table-visual-left", `${visibleRect.left}px`);
36
- ui.style.setProperty("--table-visual-width", `${visibleRect.width}px`);
37
- ui.style.setProperty("--table-visual-top", `${visibleRect.top}px`);
38
- ui.style.setProperty("--table-visual-height", `${visibleRect.height}px`);
39
- });
40
- return tableVisibleRectEffect.disconnect;
41
- });
42
-
43
- return createPortal(
44
- <div ref={ref} className="navi_table_ui" data-overlay-for={tableId}>
45
- {children}
46
- </div>,
47
- document.body,
48
- );
49
- });
@@ -1,90 +0,0 @@
1
- import { useMemo, useState } from "preact/hooks";
2
-
3
- export const useCellsAndColumns = (cells, columns) => {
4
- const [columnIds, idToColumnMap] = useMemo(() => {
5
- const columnIds = [];
6
- const idToColumnMap = new Map();
7
- for (const column of columns) {
8
- const columnId = column.id;
9
- columnIds.push(columnId);
10
- idToColumnMap.set(columnId, column);
11
- }
12
- return [columnIds, idToColumnMap];
13
- }, [columns]);
14
- const [orderedAllColumnIds, setOrderedAllColumnIds] = useState(columnIds);
15
- const orderedColumnIds = [];
16
- for (const columnId of orderedAllColumnIds) {
17
- if (!columnIds.includes(columnId)) {
18
- // generated column (like the row column)
19
- continue;
20
- }
21
- orderedColumnIds.push(columnId);
22
- }
23
- const orderedColumns = [];
24
- for (const columnId of orderedColumnIds) {
25
- const column = idToColumnMap.get(columnId);
26
- orderedColumns.push(column);
27
- }
28
-
29
- // Base cell values in original column order (2D array: rows x columns)
30
- const [baseCells, setBaseCells] = useState(cells);
31
-
32
- // Memoized index mapping for performance - maps display index to original index
33
- const columnOrderedIndexMap = useMemo(() => {
34
- const indexMap = new Map();
35
- for (let columnIndex = 0; columnIndex < columnIds.length; columnIndex++) {
36
- const columnIdAtThisIndex = orderedColumnIds[columnIndex];
37
- const originalIndex = columnIds.indexOf(columnIdAtThisIndex);
38
- indexMap.set(columnIndex, originalIndex);
39
- }
40
- return indexMap;
41
- }, [columnIds, orderedColumnIds]);
42
-
43
- // Derived state: reorder cell values according to column display order
44
- const orderedCells = useMemo(() => {
45
- const reorderedCells = [];
46
- for (let y = 0; y < baseCells.length; y++) {
47
- const originalRow = baseCells[y];
48
- const reorderedRow = [];
49
- for (let x = 0; x < orderedColumnIds.length; x++) {
50
- const columnOrderedIndex = columnOrderedIndexMap.get(x);
51
- const cellValue = originalRow[columnOrderedIndex];
52
- reorderedRow.push(cellValue);
53
- }
54
- reorderedCells.push(reorderedRow);
55
- }
56
- return reorderedCells;
57
- }, [baseCells, columnOrderedIndexMap, orderedColumnIds.length]);
58
-
59
- const setCellValue = ({ columnIndex, rowIndex }, value) => {
60
- const originalColumnIndex = columnOrderedIndexMap.get(columnIndex);
61
- if (originalColumnIndex === undefined) {
62
- console.warn(`Invalid column index: ${columnIndex}`);
63
- return;
64
- }
65
- setBaseCells((previousCells) => {
66
- const newCells = [];
67
- for (let y = 0; y < previousCells.length; y++) {
68
- const currentRow = previousCells[y];
69
- if (y !== rowIndex) {
70
- newCells.push(currentRow);
71
- continue;
72
- }
73
- const newRow = [];
74
- for (let x = 0; x < currentRow.length; x++) {
75
- const cellValue = x === originalColumnIndex ? value : currentRow[x];
76
- newRow.push(cellValue);
77
- }
78
- newCells.push(newRow);
79
- }
80
- return newCells;
81
- });
82
- };
83
-
84
- return {
85
- cells: orderedCells,
86
- setCellValue,
87
- columns: orderedColumns,
88
- setColumnOrder: setOrderedAllColumnIds,
89
- };
90
- };
@@ -1,46 +0,0 @@
1
- import { useMemo } from "preact/hooks";
2
-
3
- /**
4
- * Custom hook for converting an array of objects into a 2D array of cell values.
5
- *
6
- * This hook is essential for table components that receive data as objects but need
7
- * to work with a 2D array structure for rendering and manipulation:
8
- *
9
- * 1. **Object to Array Conversion**: Extracts values from object properties based
10
- * on column definitions, creating a consistent 2D array structure.
11
- *
12
- * 2. **Column Mapping**: Uses column names/keys to determine which object property
13
- * corresponds to each column position.
14
- *
15
- * 3. **Missing Data Handling**: Provides fallback values when object properties
16
- * don't exist for specific columns.
17
- *
18
- * 4. **Performance**: Memoized to avoid unnecessary recalculations when data
19
- * or column definitions haven't changed.
20
- *
21
- * Common use case: Converting API response data (array of objects) into table-ready
22
- * format for rendering with existing cell management hooks.
23
- */
24
-
25
- /**
26
- * Convert an array of objects into a 2D array of cell values
27
- * @param {Array<Object>} data - Array of objects to convert
28
- * @param {Array<Object>} columns - Column definitions
29
- * @param {string} columns[].key - Property key to extract from each object
30
- * @param {*} [columns[].defaultValue] - Default value when property is missing (optional)
31
- * @returns {Array<Array>} 2D array of cell values
32
- */
33
- export const useObjectArrayToCells = (data, columns) => {
34
- // Convert object array to 2D cell values array
35
- const cellValues = useMemo(() => {
36
- return data.map((rowObject) =>
37
- columns.map((column) => {
38
- const value = rowObject[column.key];
39
- // Return the value if it exists, otherwise use default or empty string
40
- return value !== undefined ? value : (column.defaultValue ?? "");
41
- }),
42
- );
43
- }, [data, columns]);
44
-
45
- return cellValues;
46
- };
@@ -1,23 +0,0 @@
1
- export const Z_INDEX_EDITING = 1; /* To go above neighbours, but should not be too big to stay under the sticky cells */
2
-
3
- /* needed because cell uses position:relative, sticky must win even if before in DOM order */
4
- export const Z_INDEX_STICKY_COLUMN = Z_INDEX_EDITING + 1;
5
- export const Z_INDEX_STICKY_ROW = Z_INDEX_STICKY_COLUMN + 1;
6
- export const Z_INDEX_STICKY_CORNER = Z_INDEX_STICKY_ROW + 1;
7
-
8
- export const Z_INDEX_STICKY_FRONTIER_BACKDROP = Z_INDEX_STICKY_CORNER + 1;
9
- export const Z_INDEX_STICKY_FRONTIER_PREVIEW =
10
- Z_INDEX_STICKY_FRONTIER_BACKDROP + 1;
11
- export const Z_INDEX_STICKY_FRONTIER_GHOST =
12
- Z_INDEX_STICKY_FRONTIER_PREVIEW + 1;
13
-
14
- export const Z_INDEX_TABLE_UI_CONTAINER = Z_INDEX_STICKY_CORNER + 1;
15
- export const Z_INDEX_DRAGGING_CLONE = Z_INDEX_STICKY_CORNER + 1; // above sticky cells
16
- export const Z_INDEX_RESIZER_BACKDROP = Z_INDEX_STICKY_CORNER + 1; // above sticky cells
17
-
18
- export const Z_INDEX_CELL_FOREGROUND = 1;
19
- export const Z_INDEX_STICKY_FRONTIER_HANDLE = 2; // above the cell placeholder to keep the sticky frontier visible
20
- export const Z_INDEX_RESIZER_HANDLE = Z_INDEX_STICKY_FRONTIER_HANDLE + 1;
21
- export const Z_INDEX_DROP_PREVIEW = Z_INDEX_STICKY_CORNER + 1;
22
-
23
- export const Z_INDEX_TABLE_UI = Z_INDEX_STICKY_CORNER + 1;
@@ -1,99 +0,0 @@
1
- import.meta.css = /* css */ `
2
- .navi_tablist {
3
- display: flex;
4
- overflow-x: auto;
5
- overflow-y: hidden;
6
- justify-content: space-between;
7
- }
8
-
9
- .navi_tablist > ul {
10
- align-items: center;
11
- display: flex;
12
- gap: 0.5rem;
13
- list-style: none;
14
- margin: 0;
15
- padding: 0;
16
- }
17
-
18
- .navi_tablist > ul > li {
19
- display: inline-flex;
20
- position: relative;
21
- }
22
-
23
- .navi_tab {
24
- white-space: nowrap;
25
- display: flex;
26
- flex-direction: column;
27
- }
28
-
29
- .navi_tab_content {
30
- transition: background 0.12s ease-out;
31
- border-radius: 6px;
32
- text-decoration: none;
33
- line-height: 30px;
34
- display: flex;
35
- padding: 0 0.5rem;
36
- }
37
-
38
- .navi_tab:hover .navi_tab_content {
39
- background: #dae0e7;
40
- color: #010409;
41
- }
42
-
43
- .navi_tab .active_marker {
44
- display: flex;
45
- background: transparent;
46
- border-radius: 0.1px;
47
- width: 100%;
48
- z-index: 1;
49
- height: 2px;
50
- margin-top: 5px;
51
- }
52
-
53
- /* Hidden bold clone to reserve space for bold width without affecting height */
54
- .navi_tab_content_bold_clone {
55
- font-weight: 600; /* force bold to compute max width */
56
- visibility: hidden; /* not visible */
57
- display: block; /* in-flow so it contributes to width */
58
- height: 0; /* zero height so it doesn't change layout height */
59
- overflow: hidden; /* avoid any accidental height */
60
- pointer-events: none; /* inert */
61
- }
62
-
63
- .navi_tab[aria-selected="true"] .active_marker {
64
- background: rgb(205, 52, 37);
65
- }
66
-
67
- .navi_tab[aria-selected="true"] .navi_tab_content {
68
- font-weight: 600;
69
- }
70
- `;
71
-
72
- export const TabList = ({ children, ...props }) => {
73
- return (
74
- <nav className="navi_tablist" role="tablist" {...props}>
75
- <ul>
76
- {children.map((child) => {
77
- return <li key={child.props.key}>{child}</li>;
78
- })}
79
- </ul>
80
- </nav>
81
- );
82
- };
83
-
84
- export const Tab = ({ children, selected, ...props }) => {
85
- return (
86
- <div
87
- className="navi_tab"
88
- role="tab"
89
- aria-selected={selected ? "true" : "false"}
90
- {...props}
91
- >
92
- <div className="navi_tab_content">{children}</div>
93
- <div className="navi_tab_content_bold_clone" aria-hidden="true">
94
- {children}
95
- </div>
96
- <span className="active_marker"></span>
97
- </div>
98
- );
99
- };