@jsenv/navi 0.10.1 → 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 +13858 -23295
  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 -177
  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,244 +0,0 @@
1
- /**
2
- * RectangleLoading Component
3
- *
4
- * A responsive loading indicator that dynamically adjusts to fit its container.
5
- * Displays an animated outline with a traveling dot that follows the container's shape.
6
- *
7
- * Features:
8
- * - Adapts to any container dimensions using ResizeObserver
9
- * - Scales stroke width, margins and corner radius proportionally
10
- * - Animates using native SVG animations for smooth performance
11
- * - High-quality SVG rendering with proper path calculations
12
- *
13
- * @param {Object} props - Component props
14
- * @param {string} [props.color="#383a36"] - Color of the loading indicator
15
- * @param {number} [props.radius=0] - Corner radius of the rectangle (px)
16
- */
17
-
18
- import { useLayoutEffect, useRef, useState } from "preact/hooks";
19
- import { useNetworkSpeed } from "./network_speed.js";
20
-
21
- import.meta.css = /* css */ `
22
- .navi_rectangle_loading {
23
- position: relative;
24
- width: 100%;
25
- height: 100%;
26
- opacity: 0;
27
- display: block;
28
- }
29
-
30
- .navi_rectangle_loading[data-visible] {
31
- opacity: 1;
32
- }
33
- `;
34
-
35
- export const RectangleLoading = ({
36
- shouldShowSpinner,
37
- color = "currentColor",
38
- radius = 0,
39
- size = 2,
40
- }) => {
41
- const containerRef = useRef(null);
42
- const [containerWidth, setContainerWidth] = useState(0);
43
- const [containerHeight, setContainerHeight] = useState(0);
44
-
45
- useLayoutEffect(() => {
46
- const container = containerRef.current;
47
- if (!container) {
48
- return null;
49
- }
50
-
51
- const { width, height } = container.getBoundingClientRect();
52
- setContainerWidth(width);
53
- setContainerHeight(height);
54
-
55
- let animationFrameId = null;
56
- // Create a resize observer to detect changes in the container's dimensions
57
- const resizeObserver = new ResizeObserver((entries) => {
58
- // Use requestAnimationFrame to debounce updates
59
- if (animationFrameId) {
60
- cancelAnimationFrame(animationFrameId);
61
- }
62
-
63
- animationFrameId = requestAnimationFrame(() => {
64
- const [containerEntry] = entries;
65
- const { width, height } = containerEntry.contentRect;
66
- setContainerWidth(width);
67
- setContainerHeight(height);
68
- });
69
- });
70
- resizeObserver.observe(container);
71
- return () => {
72
- if (animationFrameId) {
73
- cancelAnimationFrame(animationFrameId);
74
- }
75
- resizeObserver.disconnect();
76
- };
77
- }, []);
78
-
79
- return (
80
- <span
81
- ref={containerRef}
82
- className="navi_rectangle_loading"
83
- data-visible={shouldShowSpinner ? "" : undefined}
84
- >
85
- {containerWidth > 0 && containerHeight > 0 && (
86
- <RectangleLoadingSvg
87
- radius={radius}
88
- color={color}
89
- width={containerWidth}
90
- height={containerHeight}
91
- strokeWidth={size}
92
- />
93
- )}
94
- </span>
95
- );
96
- };
97
-
98
- const RectangleLoadingSvg = ({
99
- width,
100
- height,
101
- color,
102
- radius,
103
- trailColor = "transparent",
104
- strokeWidth,
105
- }) => {
106
- const margin = Math.max(2, Math.min(width, height) * 0.03);
107
-
108
- // Calculate the drawable area
109
- const drawableWidth = width - margin * 2;
110
- const drawableHeight = height - margin * 2;
111
-
112
- // ✅ Check if this should be a circle
113
- const maxPossibleRadius = Math.min(drawableWidth, drawableHeight) / 2;
114
- const actualRadius = Math.min(
115
- radius || Math.min(drawableWidth, drawableHeight) * 0.05,
116
- maxPossibleRadius, // ✅ Limité au radius maximum possible
117
- );
118
-
119
- // ✅ Determine if we're dealing with a circle
120
- const isCircle = actualRadius >= maxPossibleRadius * 0.95; // 95% = virtually a circle
121
-
122
- let pathLength;
123
- let rectPath;
124
-
125
- if (isCircle) {
126
- // ✅ Circle: perimeter = 2πr
127
- pathLength = 2 * Math.PI * actualRadius;
128
-
129
- // ✅ Circle path centered in the drawable area
130
- const centerX = margin + drawableWidth / 2;
131
- const centerY = margin + drawableHeight / 2;
132
-
133
- rectPath = `
134
- M ${centerX + actualRadius},${centerY}
135
- A ${actualRadius},${actualRadius} 0 1 1 ${centerX - actualRadius},${centerY}
136
- A ${actualRadius},${actualRadius} 0 1 1 ${centerX + actualRadius},${centerY}
137
- `;
138
- } else {
139
- // ✅ Rectangle: calculate perimeter properly
140
- const straightEdges =
141
- 2 * (drawableWidth - 2 * actualRadius) +
142
- 2 * (drawableHeight - 2 * actualRadius);
143
- const cornerArcs = actualRadius > 0 ? 2 * Math.PI * actualRadius : 0;
144
- pathLength = straightEdges + cornerArcs;
145
-
146
- rectPath = `
147
- M ${margin + actualRadius},${margin}
148
- L ${margin + drawableWidth - actualRadius},${margin}
149
- A ${actualRadius},${actualRadius} 0 0 1 ${margin + drawableWidth},${margin + actualRadius}
150
- L ${margin + drawableWidth},${margin + drawableHeight - actualRadius}
151
- A ${actualRadius},${actualRadius} 0 0 1 ${margin + drawableWidth - actualRadius},${margin + drawableHeight}
152
- L ${margin + actualRadius},${margin + drawableHeight}
153
- A ${actualRadius},${actualRadius} 0 0 1 ${margin},${margin + drawableHeight - actualRadius}
154
- L ${margin},${margin + actualRadius}
155
- A ${actualRadius},${actualRadius} 0 0 1 ${margin + actualRadius},${margin}
156
- `;
157
- }
158
-
159
- // Fixed segment size in pixels
160
- const maxSegmentSize = 40;
161
- const segmentLength = Math.min(maxSegmentSize, pathLength * 0.25);
162
- const gapLength = pathLength - segmentLength;
163
-
164
- // Vitesse constante en pixels par seconde
165
- const networkSpeed = useNetworkSpeed();
166
- const pixelsPerSecond =
167
- {
168
- "slow-2g": 40,
169
- "2g": 60,
170
- "3g": 80,
171
- "4g": 120,
172
- }[networkSpeed] || 80;
173
- const animationDuration = Math.max(1.5, pathLength / pixelsPerSecond);
174
-
175
- // ✅ Calculate correct offset based on actual segment size
176
- const segmentRatio = segmentLength / pathLength;
177
- const circleOffset = -animationDuration * segmentRatio;
178
-
179
- return (
180
- <svg
181
- width="100%"
182
- height="100%"
183
- viewBox={`0 0 ${width} ${height}`}
184
- preserveAspectRatio="none"
185
- style="overflow: visible"
186
- xmlns="http://www.w3.org/2000/svg"
187
- shape-rendering="geometricPrecision"
188
- >
189
- {/* Base outline - circle ou rectangle */}
190
- {isCircle ? (
191
- <circle
192
- cx={margin + drawableWidth / 2}
193
- cy={margin + drawableHeight / 2}
194
- r={actualRadius}
195
- fill="none"
196
- stroke={trailColor}
197
- strokeWidth={strokeWidth}
198
- />
199
- ) : (
200
- <rect
201
- x={margin}
202
- y={margin}
203
- width={drawableWidth}
204
- height={drawableHeight}
205
- fill="none"
206
- stroke={trailColor}
207
- strokeWidth={strokeWidth}
208
- rx={actualRadius}
209
- />
210
- )}
211
-
212
- {/* Progress segment that grows and moves */}
213
- <path
214
- d={rectPath}
215
- fill="none"
216
- stroke={color}
217
- strokeWidth={strokeWidth}
218
- strokeLinecap="round"
219
- strokeDasharray={`${segmentLength} ${gapLength}`}
220
- pathLength={pathLength}
221
- >
222
- <animate
223
- attributeName="stroke-dashoffset"
224
- from={pathLength}
225
- to="0"
226
- dur={`${animationDuration}s`}
227
- repeatCount="indefinite"
228
- begin="0s"
229
- />
230
- </path>
231
-
232
- {/* Leading dot that follows the path */}
233
- <circle r={strokeWidth} fill={color}>
234
- <animateMotion
235
- path={rectPath}
236
- dur={`${animationDuration}s`}
237
- repeatCount="indefinite"
238
- rotate="auto"
239
- begin={`${circleOffset}s`}
240
- />
241
- </circle>
242
- </svg>
243
- );
244
- };
@@ -1,81 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>withPropsStyle Demo - Minimalist</title>
6
- <style>
7
- button {
8
- padding: 12px 20px;
9
- font-family: system-ui, sans-serif;
10
- border: 1px solid #ccc;
11
- border-radius: 4px;
12
- cursor: pointer;
13
- }
14
- </style>
15
- </head>
16
- <body>
17
- <div id="app"></div>
18
- <script type="module" jsenv-type="module/jsx">
19
- /* eslint-disable no-unused-vars */
20
- import { render } from "preact";
21
- import { withPropsStyle } from "../with_props_style.js";
22
-
23
- const Button = ({ style, children, ...rest }) => (
24
- <button
25
- style={withPropsStyle(
26
- {
27
- backgroundColor: "var(--background-color, #f8f9fa)",
28
- },
29
- style,
30
- )}
31
- {...rest}
32
- >
33
- {children}
34
- </button>
35
- );
36
-
37
- const Demo = () => {
38
- return (
39
- <div style={{ padding: "20px", fontFamily: "system-ui, sans-serif" }}>
40
- <h1>withPropsStyle Demo</h1>
41
-
42
- <section style={{ marginBottom: "30px" }}>
43
- <h2>1. Default Button</h2>
44
- <div>
45
- <Button>Default</Button>
46
- </div>
47
- </section>
48
-
49
- <section style={{ marginBottom: "30px" }}>
50
- <h2>2. Override via style + background-color</h2>
51
- <div style={{ display: "flex", gap: "10px", flexWrap: "wrap" }}>
52
- <Button style={{ backgroundColor: "#007bff" }}>
53
- Object notation
54
- </Button>
55
-
56
- <Button style="background-color: #28a745;">
57
- String notation
58
- </Button>
59
- </div>
60
- </section>
61
-
62
- <section>
63
- <h2>3. Override via style + CSS var</h2>
64
- <div style={{ display: "flex", gap: "10px", flexWrap: "wrap" }}>
65
- <Button style={{ "--background-color": "#dc3545" }}>
66
- Object notation
67
- </Button>
68
-
69
- <Button style="--background-color: #ffc107;">
70
- String notation
71
- </Button>
72
- </div>
73
- </section>
74
- </div>
75
- );
76
- };
77
-
78
- render(<Demo />, document.getElementById("app"));
79
- </script>
80
- </body>
81
- </html>
@@ -1,37 +0,0 @@
1
- /**
2
- * Merges a component's base className with className received from props.
3
- *
4
- * ```jsx
5
- * const MyButton = ({ className, children }) => (
6
- * <button className={withPropsClassName("btn", className)}>
7
- * {children}
8
- * </button>
9
- * );
10
- *
11
- * // Usage:
12
- * <MyButton className="primary large" /> // Results in "btn primary large"
13
- * <MyButton /> // Results in "btn"
14
- * ```
15
- *
16
- * @param {string} baseClassName - The component's base CSS class name
17
- * @param {string} [classNameFromProps] - Additional className from props (optional)
18
- * @returns {string} The merged className string
19
- */
20
- export const withPropsClassName = (baseClassName, classNameFromProps) => {
21
- if (!classNameFromProps) {
22
- return baseClassName;
23
- }
24
-
25
- // Trim and normalize whitespace from the props className
26
- const trimmedPropsClassName = classNameFromProps.trim();
27
- if (!trimmedPropsClassName) {
28
- return baseClassName;
29
- }
30
-
31
- // Normalize multiple spaces to single spaces and combine
32
- const normalizedPropsClassName = trimmedPropsClassName.replace(/\s+/g, " ");
33
- if (!baseClassName) {
34
- return normalizedPropsClassName;
35
- }
36
- return `${baseClassName} ${normalizedPropsClassName}`;
37
- };
@@ -1,26 +0,0 @@
1
- import { mergeStyles } from "@jsenv/dom";
2
-
3
- /**
4
- * Merges a component's base style with style received from props.
5
- * Automatically normalizes style values (e.g., adds "px" units where needed).
6
- *
7
- * ```jsx
8
- * const MyButton = ({ style, children }) => (
9
- * <button style={withPropsStyle({ padding: 10 }, style)}>
10
- * {children}
11
- * </button>
12
- * );
13
- *
14
- * // Usage:
15
- * <MyButton style={{ color: 'red', fontSize: 14 }} />
16
- * <MyButton style="color: blue; margin: 5px;" />
17
- * <MyButton /> // Just base styles
18
- * ```
19
- *
20
- * @param {string|object} baseStyle - The component's base style (string or object)
21
- * @param {string|object} [styleFromProps] - Additional style from props (optional)
22
- * @returns {object} The merged and normalized style object
23
- */
24
- export const withPropsStyle = (baseStyle, styleFromProps) => {
25
- return mergeStyles(baseStyle, styleFromProps, "css");
26
- };
@@ -1,19 +0,0 @@
1
- import { useRouteStatus } from "../route/route.js";
2
- import { ActionRenderer } from "./action_renderer.jsx";
3
- import { useContentKey } from "./ui_transition.jsx";
4
-
5
- export const Route = ({ route, children }) => {
6
- if (!route.action) {
7
- throw new Error(
8
- "Route component requires a route with an action to render.",
9
- );
10
- }
11
- const { active, url } = useRouteStatus(route);
12
- useContentKey(url, active);
13
-
14
- return (
15
- <ActionRenderer disabled={!active} action={route.action}>
16
- {children}
17
- </ActionRenderer>
18
- );
19
- };