@jsenv/navi 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_navi.js +13838 -23291
- package/dist/jsenv_navi.js.map +1281 -0
- package/package.json +5 -7
- package/index.js +0 -122
- package/src/action_private_properties.js +0 -11
- package/src/action_proxy_test.html +0 -353
- package/src/action_run_states.js +0 -5
- package/src/actions.js +0 -1401
- package/src/browser_integration/browser_integration.js +0 -216
- package/src/browser_integration/document_back_and_forward.js +0 -17
- package/src/browser_integration/document_loading_signal.js +0 -100
- package/src/browser_integration/document_state_signal.js +0 -9
- package/src/browser_integration/document_url_signal.js +0 -9
- package/src/browser_integration/use_is_visited.js +0 -19
- package/src/browser_integration/via_history.js +0 -232
- package/src/browser_integration/via_navigation.js +0 -168
- package/src/components/action_execution/form_context.js +0 -5
- package/src/components/action_execution/render_actionable_component.jsx +0 -29
- package/src/components/action_execution/use_action.js +0 -99
- package/src/components/action_execution/use_execute_action.js +0 -193
- package/src/components/action_execution/use_run_on_mount.js +0 -9
- package/src/components/action_renderer.jsx +0 -125
- package/src/components/callout/callout.js +0 -990
- package/src/components/callout/callout_demo.html +0 -201
- package/src/components/callout/test_dynamic_positioning.html +0 -161
- package/src/components/callout/test_html_document_iframe.html +0 -182
- package/src/components/demos/0_button_demo.html +0 -707
- package/src/components/demos/10_column_reordering_debug.html +0 -277
- package/src/components/demos/11_table_selection_debug.html +0 -432
- package/src/components/demos/1_checkbox_demo.html +0 -754
- package/src/components/demos/2_input_textual_demo.html +0 -286
- package/src/components/demos/3_radio_demo.html +0 -874
- package/src/components/demos/4_select_demo.html +0 -100
- package/src/components/demos/5_list_scrollable_demo.html +0 -153
- package/src/components/demos/6_tablist_demo.html +0 -77
- package/src/components/demos/7_table_selection_demo.html +0 -176
- package/src/components/demos/8_table_fixed_headers_demo.html +0 -584
- package/src/components/demos/9_table_column_drag_demo.html +0 -325
- package/src/components/demos/action/0_button_demo.html +0 -204
- package/src/components/demos/action/10_shortcuts_demo.html +0 -189
- package/src/components/demos/action/11_nested_shortcuts_demo.xhtml +0 -401
- package/src/components/demos/action/1_input_text_demo.html +0 -876
- package/src/components/demos/action/2_form_multiple.html +0 -303
- package/src/components/demos/action/3_details_demo.html +0 -203
- package/src/components/demos/action/4_input_checkbox_demo.html +0 -731
- package/src/components/demos/action/5_input_checkbox_state_demo.html +0 -270
- package/src/components/demos/action/6_checkbox_list_demo.html +0 -341
- package/src/components/demos/action/7_radio_list_demo.html +0 -357
- package/src/components/demos/action/8_editable_demo.html +0 -431
- package/src/components/demos/action/9_link_demo.html +0 -194
- package/src/components/demos/demo.md +0 -0
- package/src/components/demos/route/basic/basic.html +0 -14
- package/src/components/demos/route/basic/basic_route_demo.jsx +0 -224
- package/src/components/demos/route/multi/multi.html +0 -14
- package/src/components/demos/route/multi/multi_route_demo.jsx +0 -277
- package/src/components/demos/ui_transition/0_action_renderer_ui_transition_demo.html +0 -695
- package/src/components/demos/ui_transition/1_nested_ui_transition_demo.html +0 -429
- package/src/components/demos/ui_transition/2_height_transition_test.html +0 -295
- package/src/components/details/details.jsx +0 -245
- package/src/components/details/summary_marker.jsx +0 -141
- package/src/components/edition/editable.jsx +0 -186
- package/src/components/error_boundary_context.js +0 -9
- package/src/components/field/README.md +0 -247
- package/src/components/field/button.jsx +0 -429
- package/src/components/field/checkbox_list.jsx +0 -185
- package/src/components/field/collect_form_element_values.js +0 -82
- package/src/components/field/custom_field.js +0 -106
- package/src/components/field/form.jsx +0 -209
- package/src/components/field/input.jsx +0 -16
- package/src/components/field/input_checkbox.jsx +0 -434
- package/src/components/field/input_radio.jsx +0 -432
- package/src/components/field/input_textual.jsx +0 -389
- package/src/components/field/label.jsx +0 -46
- package/src/components/field/radio_list.jsx +0 -183
- package/src/components/field/select.jsx +0 -256
- package/src/components/field/use_action_events.js +0 -132
- package/src/components/field/use_form_events.js +0 -59
- package/src/components/field/use_ui_state_controller.js +0 -506
- package/src/components/item_tracker/README.md +0 -461
- package/src/components/item_tracker/use_isolated_item_tracker.jsx +0 -209
- package/src/components/item_tracker/use_isolated_item_tracker_demo.html +0 -148
- package/src/components/item_tracker/use_isolated_item_tracker_demo.jsx +0 -460
- package/src/components/item_tracker/use_item_tracker.jsx +0 -143
- package/src/components/item_tracker/use_item_tracker_demo.html +0 -207
- package/src/components/item_tracker/use_item_tracker_demo.jsx +0 -216
- package/src/components/keyboard_shortcuts/active_keyboard_shortcuts.jsx +0 -87
- package/src/components/keyboard_shortcuts/aria_key_shortcuts.js +0 -61
- package/src/components/keyboard_shortcuts/keyboard_key_meta.js +0 -17
- package/src/components/keyboard_shortcuts/keyboard_shortcuts.js +0 -371
- package/src/components/keyboard_shortcuts/os.js +0 -9
- package/src/components/layout/demos/demo_flex.html +0 -638
- package/src/components/layout/demos/demo_layout_style_buttons.html +0 -351
- package/src/components/layout/demos/demo_layout_style_input.html +0 -226
- package/src/components/layout/demos/demo_layout_style_text.html +0 -514
- package/src/components/layout/flex.jsx +0 -109
- package/src/components/layout/layout_context.jsx +0 -3
- package/src/components/layout/spacing.jsx +0 -20
- package/src/components/layout/use_layout_style.js +0 -249
- package/src/components/link/link.jsx +0 -267
- package/src/components/link/link_with_icon.jsx +0 -52
- package/src/components/loader/loader_background.jsx +0 -372
- package/src/components/loader/loading_spinner.jsx +0 -68
- package/src/components/loader/network_speed.js +0 -83
- package/src/components/loader/rectangle_loading.jsx +0 -244
- package/src/components/props_composition/demos/demo_with_props_style.html +0 -81
- package/src/components/props_composition/with_props_class_name.js +0 -37
- package/src/components/props_composition/with_props_style.js +0 -26
- package/src/components/route.jsx +0 -19
- package/src/components/selection/selection.jsx +0 -1583
- package/src/components/svg/font_sized_svg.jsx +0 -59
- package/src/components/svg/icon_and_text.jsx +0 -21
- package/src/components/svg/svg_mask_overlay.jsx +0 -105
- package/src/components/table/drag/table_drag.jsx +0 -506
- package/src/components/table/resize/table_resize.jsx +0 -650
- package/src/components/table/resize/table_size.js +0 -43
- package/src/components/table/selection/table_selection.js +0 -106
- package/src/components/table/selection/table_selection.jsx +0 -203
- package/src/components/table/sticky/sticky_group.js +0 -354
- package/src/components/table/sticky/table_sticky.js +0 -25
- package/src/components/table/sticky/table_sticky.jsx +0 -501
- package/src/components/table/table.jsx +0 -721
- package/src/components/table/table_css.js +0 -211
- package/src/components/table/table_ui.jsx +0 -49
- package/src/components/table/use_cells_and_columns.js +0 -90
- package/src/components/table/use_object_array_to_cells.js +0 -46
- package/src/components/table/z_indexes.js +0 -23
- package/src/components/tablist/tablist.jsx +0 -99
- package/src/components/text/demos/demo_text_and_icon.html +0 -421
- package/src/components/text/overflow.jsx +0 -15
- package/src/components/text/text.jsx +0 -83
- package/src/components/text/text_and_count.jsx +0 -28
- package/src/components/ui_transition.jsx +0 -128
- package/src/components/use_auto_focus.js +0 -94
- package/src/components/use_batch_during_render.js +0 -33
- package/src/components/use_debounce_true.js +0 -31
- package/src/components/use_dependencies_diff.js +0 -35
- package/src/components/use_focus_group.js +0 -20
- package/src/components/use_initial_value.js +0 -78
- package/src/components/use_is_visited.js +0 -19
- package/src/components/use_ref_array.js +0 -38
- package/src/components/use_signal_sync.js +0 -50
- package/src/components/use_stable_callback.js +0 -68
- package/src/components/use_state_array.js +0 -47
- package/src/docs/actions.md +0 -250
- package/src/docs/demos/resource/action_status.jsx +0 -42
- package/src/docs/demos/resource/demo.md +0 -1
- package/src/docs/demos/resource/resource_demo_0.html +0 -84
- package/src/docs/demos/resource/resource_demo_10_post_gc.html +0 -364
- package/src/docs/demos/resource/resource_demo_11_describe_many.html +0 -362
- package/src/docs/demos/resource/resource_demo_2.html +0 -173
- package/src/docs/demos/resource/resource_demo_3_filtered_users.html +0 -415
- package/src/docs/demos/resource/resource_demo_4_details.html +0 -284
- package/src/docs/demos/resource/resource_demo_5_renderer_lazy.html +0 -115
- package/src/docs/demos/resource/resource_demo_6_gc.html +0 -217
- package/src/docs/demos/resource/resource_demo_7_child_gc.html +0 -240
- package/src/docs/demos/resource/resource_demo_8_proxy_gc.html +0 -319
- package/src/docs/demos/resource/resource_demo_9_describe_one.html +0 -472
- package/src/docs/demos/resource/tata.jsx +0 -3
- package/src/docs/demos/resource/toto.jsx +0 -3
- package/src/docs/demos/user_nav/user_nav.html +0 -12
- package/src/docs/demos/user_nav/user_nav.jsx +0 -330
- package/src/docs/resource_dependencies.md +0 -103
- package/src/docs/resource_with_params.md +0 -80
- package/src/navi_css_vars.js +0 -14
- package/src/notes.md +0 -34
- package/src/route/route.js +0 -596
- package/src/route/route.xtest.html +0 -228
- package/src/store/array_signal_store.js +0 -537
- package/src/store/local_storage_signal.js +0 -17
- package/src/store/resource_graph.js +0 -1304
- package/src/store/tests/resource_graph_autoreload_demo.html +0 -12
- package/src/store/tests/resource_graph_autoreload_demo.jsx +0 -964
- package/src/store/tests/resource_graph_dependencies.test_manual.js +0 -95
- package/src/store/value_in_local_storage.js +0 -187
- package/src/symbol_object_signal.js +0 -1
- package/src/use_action_data.js +0 -10
- package/src/use_action_status.js +0 -47
- package/src/utils/add_many_event_listeners.js +0 -15
- package/src/utils/array_add_remove.js +0 -61
- package/src/utils/array_signal.js +0 -15
- package/src/utils/compare_two_js_values.js +0 -172
- package/src/utils/execute_with_cleanup.js +0 -21
- package/src/utils/get_caller_info.js +0 -85
- package/src/utils/is_signal.js +0 -20
- package/src/utils/js_value_weak_map.js +0 -162
- package/src/utils/js_value_weak_map_demo.html +0 -690
- package/src/utils/merge_two_js_values.js +0 -53
- package/src/utils/stringify_for_display.js +0 -131
- package/src/utils/weak_effect.js +0 -48
- package/src/validation/constraints/confirm_constraint.js +0 -14
- package/src/validation/constraints/create_unique_value_constraint.js +0 -27
- package/src/validation/constraints/native_constraints.js +0 -338
- package/src/validation/constraints/readonly_constraint.js +0 -41
- package/src/validation/constraints/same_as_constraint.js +0 -42
- package/src/validation/constraints/single_space_constraint.js +0 -13
- package/src/validation/custom_constraint_validation.js +0 -793
- package/src/validation/custom_message.js +0 -18
- package/src/validation/demos/browser_style.png +0 -0
- package/src/validation/demos/demo_same_as_constraint.html +0 -259
- package/src/validation/demos/form_validation_demo.html +0 -142
- package/src/validation/demos/form_validation_demo_preact.html +0 -87
- package/src/validation/demos/form_validation_native_popover_demo.html +0 -168
- package/src/validation/demos/form_validation_vs_native_demo.html +0 -172
- package/src/validation/hooks/use_constraints.js +0 -23
- package/src/validation/hooks/use_custom_validation_ref.js +0 -73
- package/src/validation/hooks/use_validation_message.js +0 -19
- package/src/validation/input_change_effect.js +0 -106
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
import { resolveCSSSize } from "@jsenv/dom";
|
|
2
|
-
import { createPortal, forwardRef } from "preact/compat";
|
|
3
|
-
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
|
4
|
-
|
|
5
|
-
import { useDebounceTrue } from "../use_debounce_true.js";
|
|
6
|
-
import { RectangleLoading } from "./rectangle_loading.jsx";
|
|
7
|
-
|
|
8
|
-
import.meta.css = /* css */ `
|
|
9
|
-
.navi_inline_wrapper {
|
|
10
|
-
position: relative;
|
|
11
|
-
width: fit-content;
|
|
12
|
-
display: inline-flex;
|
|
13
|
-
height: fit-content;
|
|
14
|
-
border-radius: inherit;
|
|
15
|
-
cursor: inherit;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.navi_loading_rectangle_wrapper {
|
|
19
|
-
pointer-events: none;
|
|
20
|
-
position: absolute;
|
|
21
|
-
z-index: 1;
|
|
22
|
-
opacity: 0;
|
|
23
|
-
top: var(--rectangle-top, 0);
|
|
24
|
-
left: var(--rectangle-left, 0);
|
|
25
|
-
bottom: var(--rectangle-bottom, 0);
|
|
26
|
-
right: var(--rectangle-right, 0);
|
|
27
|
-
}
|
|
28
|
-
.navi_loading_rectangle_wrapper[data-visible] {
|
|
29
|
-
opacity: 1;
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
export const LoadableInlineElement = forwardRef((props, ref) => {
|
|
34
|
-
const {
|
|
35
|
-
// background props
|
|
36
|
-
loading,
|
|
37
|
-
containerRef,
|
|
38
|
-
targetSelector,
|
|
39
|
-
color,
|
|
40
|
-
inset,
|
|
41
|
-
spacingTop,
|
|
42
|
-
spacingLeft,
|
|
43
|
-
spacingBottom,
|
|
44
|
-
spacingRight,
|
|
45
|
-
// other props
|
|
46
|
-
width,
|
|
47
|
-
height,
|
|
48
|
-
children,
|
|
49
|
-
...rest
|
|
50
|
-
} = props;
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<span
|
|
54
|
-
{...rest}
|
|
55
|
-
ref={ref}
|
|
56
|
-
className="navi_inline_wrapper"
|
|
57
|
-
style={{
|
|
58
|
-
...rest.style,
|
|
59
|
-
...(width ? { width } : {}),
|
|
60
|
-
...(height ? { height } : {}),
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<LoaderBackground
|
|
64
|
-
{...{
|
|
65
|
-
loading,
|
|
66
|
-
containerRef,
|
|
67
|
-
targetSelector,
|
|
68
|
-
color,
|
|
69
|
-
inset,
|
|
70
|
-
spacingTop,
|
|
71
|
-
spacingLeft,
|
|
72
|
-
spacingBottom,
|
|
73
|
-
spacingRight,
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
{children}
|
|
77
|
-
</span>
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export const LoaderBackground = ({
|
|
82
|
-
loading,
|
|
83
|
-
containerRef,
|
|
84
|
-
targetSelector,
|
|
85
|
-
color,
|
|
86
|
-
inset = 0,
|
|
87
|
-
spacingTop = 0,
|
|
88
|
-
spacingLeft = 0,
|
|
89
|
-
spacingBottom = 0,
|
|
90
|
-
spacingRight = 0,
|
|
91
|
-
children,
|
|
92
|
-
}) => {
|
|
93
|
-
if (containerRef) {
|
|
94
|
-
const container = containerRef.current;
|
|
95
|
-
if (!container) {
|
|
96
|
-
return children;
|
|
97
|
-
}
|
|
98
|
-
return createPortal(
|
|
99
|
-
<LoaderBackgroundWithPortal
|
|
100
|
-
container={container}
|
|
101
|
-
loading={loading}
|
|
102
|
-
color={color}
|
|
103
|
-
inset={inset}
|
|
104
|
-
spacingTop={spacingTop}
|
|
105
|
-
spacingLeft={spacingLeft}
|
|
106
|
-
spacingBottom={spacingBottom}
|
|
107
|
-
spacingRight={spacingRight}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</LoaderBackgroundWithPortal>,
|
|
111
|
-
container,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<LoaderBackgroundBasic
|
|
117
|
-
targetSelector={targetSelector}
|
|
118
|
-
loading={loading}
|
|
119
|
-
color={color}
|
|
120
|
-
inset={inset}
|
|
121
|
-
spacingTop={spacingTop}
|
|
122
|
-
spacingLeft={spacingLeft}
|
|
123
|
-
spacingBottom={spacingBottom}
|
|
124
|
-
spacingRight={spacingRight}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</LoaderBackgroundBasic>
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const LoaderBackgroundWithPortal = ({
|
|
132
|
-
container,
|
|
133
|
-
loading,
|
|
134
|
-
color,
|
|
135
|
-
inset,
|
|
136
|
-
spacingTop,
|
|
137
|
-
spacingLeft,
|
|
138
|
-
spacingBottom,
|
|
139
|
-
spacingRight,
|
|
140
|
-
children,
|
|
141
|
-
}) => {
|
|
142
|
-
const shouldShowSpinner = useDebounceTrue(loading, 300);
|
|
143
|
-
|
|
144
|
-
if (!shouldShowSpinner) {
|
|
145
|
-
return children;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
container.style.position = "relative";
|
|
149
|
-
let paddingTop = 0;
|
|
150
|
-
if (container.nodeName === "DETAILS") {
|
|
151
|
-
paddingTop = container.querySelector("summary").offsetHeight;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<>
|
|
156
|
-
<div
|
|
157
|
-
style={{
|
|
158
|
-
position: "absolute",
|
|
159
|
-
top: `${inset + paddingTop + spacingTop}px`,
|
|
160
|
-
bottom: `${inset + spacingBottom}px`,
|
|
161
|
-
left: `${inset + spacingLeft}px`,
|
|
162
|
-
right: `${inset + spacingRight}px`,
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
{shouldShowSpinner && <RectangleLoading color={color} />}
|
|
166
|
-
</div>
|
|
167
|
-
{children}
|
|
168
|
-
</>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const LoaderBackgroundBasic = ({
|
|
173
|
-
loading,
|
|
174
|
-
targetSelector,
|
|
175
|
-
color,
|
|
176
|
-
spacingTop,
|
|
177
|
-
spacingLeft,
|
|
178
|
-
spacingBottom,
|
|
179
|
-
spacingRight,
|
|
180
|
-
inset,
|
|
181
|
-
children,
|
|
182
|
-
}) => {
|
|
183
|
-
const shouldShowSpinner = useDebounceTrue(loading, 300);
|
|
184
|
-
const rectangleRef = useRef(null);
|
|
185
|
-
const [, setOutlineOffset] = useState(0);
|
|
186
|
-
const [borderRadius, setBorderRadius] = useState(0);
|
|
187
|
-
const [borderTopWidth, setBorderTopWidth] = useState(0);
|
|
188
|
-
const [borderLeftWidth, setBorderLeftWidth] = useState(0);
|
|
189
|
-
const [borderRightWidth, setBorderRightWidth] = useState(0);
|
|
190
|
-
const [borderBottomWidth, setBorderBottomWidth] = useState(0);
|
|
191
|
-
const [marginTop, setMarginTop] = useState(0);
|
|
192
|
-
const [marginBottom, setMarginBottom] = useState(0);
|
|
193
|
-
const [marginLeft, setMarginLeft] = useState(0);
|
|
194
|
-
const [marginRight, setMarginRight] = useState(0);
|
|
195
|
-
const [paddingTop, setPaddingTop] = useState(0);
|
|
196
|
-
const [paddingLeft, setPaddingLeft] = useState(0);
|
|
197
|
-
const [paddingRight, setPaddingRight] = useState(0);
|
|
198
|
-
const [paddingBottom, setPaddingBottom] = useState(0);
|
|
199
|
-
|
|
200
|
-
const [currentColor, setCurrentColor] = useState(color);
|
|
201
|
-
|
|
202
|
-
useLayoutEffect(() => {
|
|
203
|
-
let animationFrame;
|
|
204
|
-
const updateStyles = () => {
|
|
205
|
-
const rectangle = rectangleRef.current;
|
|
206
|
-
if (!rectangle) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const container = rectangle.parentElement;
|
|
210
|
-
const containedElement = rectangle.nextElementSibling;
|
|
211
|
-
const target = targetSelector
|
|
212
|
-
? container.querySelector(targetSelector)
|
|
213
|
-
: containedElement;
|
|
214
|
-
if (target) {
|
|
215
|
-
const { width, height } = target.getBoundingClientRect();
|
|
216
|
-
|
|
217
|
-
const containedComputedStyle =
|
|
218
|
-
window.getComputedStyle(containedElement);
|
|
219
|
-
const targetComputedStyle = window.getComputedStyle(target);
|
|
220
|
-
|
|
221
|
-
const newBorderTopWidth = resolveCSSSize(
|
|
222
|
-
targetComputedStyle.borderTopWidth,
|
|
223
|
-
);
|
|
224
|
-
const newBorderLeftWidth = resolveCSSSize(
|
|
225
|
-
targetComputedStyle.borderLeftWidth,
|
|
226
|
-
);
|
|
227
|
-
const newBorderRightWidth = resolveCSSSize(
|
|
228
|
-
targetComputedStyle.borderRightWidth,
|
|
229
|
-
);
|
|
230
|
-
const newBorderBottomWidth = resolveCSSSize(
|
|
231
|
-
targetComputedStyle.borderBottomWidth,
|
|
232
|
-
);
|
|
233
|
-
const newBorderRadius = resolveCSSSize(
|
|
234
|
-
targetComputedStyle.borderRadius,
|
|
235
|
-
{
|
|
236
|
-
availableSize: Math.min(width, height),
|
|
237
|
-
},
|
|
238
|
-
);
|
|
239
|
-
const newOutlineColor = targetComputedStyle.outlineColor;
|
|
240
|
-
const newBorderColor = targetComputedStyle.borderColor;
|
|
241
|
-
const newDetectedColor = targetComputedStyle.color;
|
|
242
|
-
const newOutlineOffset = resolveCSSSize(
|
|
243
|
-
targetComputedStyle.outlineOffset,
|
|
244
|
-
);
|
|
245
|
-
const newMarginTop = resolveCSSSize(targetComputedStyle.marginTop);
|
|
246
|
-
const newMarginBottom = resolveCSSSize(
|
|
247
|
-
targetComputedStyle.marginBottom,
|
|
248
|
-
);
|
|
249
|
-
const newMarginLeft = resolveCSSSize(targetComputedStyle.marginLeft);
|
|
250
|
-
const newMarginRight = resolveCSSSize(targetComputedStyle.marginRight);
|
|
251
|
-
|
|
252
|
-
const paddingTop = resolveCSSSize(containedComputedStyle.paddingTop);
|
|
253
|
-
const paddingLeft = resolveCSSSize(containedComputedStyle.paddingLeft);
|
|
254
|
-
const paddingRight = resolveCSSSize(
|
|
255
|
-
containedComputedStyle.paddingRight,
|
|
256
|
-
);
|
|
257
|
-
const paddingBottom = resolveCSSSize(
|
|
258
|
-
containedComputedStyle.paddingBottom,
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
setBorderTopWidth(newBorderTopWidth);
|
|
262
|
-
setBorderLeftWidth(newBorderLeftWidth);
|
|
263
|
-
setBorderRightWidth(newBorderRightWidth);
|
|
264
|
-
setBorderBottomWidth(newBorderBottomWidth);
|
|
265
|
-
setBorderRadius(newBorderRadius);
|
|
266
|
-
setOutlineOffset(newOutlineOffset);
|
|
267
|
-
setMarginTop(newMarginTop);
|
|
268
|
-
setMarginBottom(newMarginBottom);
|
|
269
|
-
setMarginLeft(newMarginLeft);
|
|
270
|
-
setMarginRight(newMarginRight);
|
|
271
|
-
setPaddingTop(paddingTop);
|
|
272
|
-
setPaddingLeft(paddingLeft);
|
|
273
|
-
setPaddingRight(paddingRight);
|
|
274
|
-
setPaddingBottom(paddingBottom);
|
|
275
|
-
|
|
276
|
-
if (color) {
|
|
277
|
-
// const resolvedColor = resolveCSSColor(color, rectangle, "css");
|
|
278
|
-
// console.log(resolvedColor);
|
|
279
|
-
setCurrentColor(color);
|
|
280
|
-
} else if (
|
|
281
|
-
newOutlineColor &&
|
|
282
|
-
newOutlineColor !== "rgba(0, 0, 0, 0)" &&
|
|
283
|
-
(document.activeElement === containedElement ||
|
|
284
|
-
newBorderColor === "rgba(0, 0, 0, 0)")
|
|
285
|
-
) {
|
|
286
|
-
setCurrentColor(newOutlineColor);
|
|
287
|
-
} else if (newBorderColor && newBorderColor !== "rgba(0, 0, 0, 0)") {
|
|
288
|
-
setCurrentColor(newBorderColor);
|
|
289
|
-
} else {
|
|
290
|
-
setCurrentColor(newDetectedColor);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
// updateStyles is very cheap so we run it every frame
|
|
294
|
-
animationFrame = requestAnimationFrame(updateStyles);
|
|
295
|
-
};
|
|
296
|
-
updateStyles();
|
|
297
|
-
|
|
298
|
-
return () => {
|
|
299
|
-
cancelAnimationFrame(animationFrame);
|
|
300
|
-
};
|
|
301
|
-
}, [color, targetSelector]);
|
|
302
|
-
|
|
303
|
-
spacingTop += inset;
|
|
304
|
-
// spacingTop += outlineOffset;
|
|
305
|
-
// spacingTop -= borderTopWidth;
|
|
306
|
-
spacingTop += marginTop;
|
|
307
|
-
spacingLeft += inset;
|
|
308
|
-
// spacingLeft += outlineOffset;
|
|
309
|
-
// spacingLeft -= borderLeftWidth;
|
|
310
|
-
spacingLeft += marginLeft;
|
|
311
|
-
spacingRight += inset;
|
|
312
|
-
// spacingRight += outlineOffset;
|
|
313
|
-
// spacingRight -= borderRightWidth;
|
|
314
|
-
spacingRight += marginRight;
|
|
315
|
-
spacingBottom += inset;
|
|
316
|
-
// spacingBottom += outlineOffset;
|
|
317
|
-
// spacingBottom -= borderBottomWidth;
|
|
318
|
-
spacingBottom += marginBottom;
|
|
319
|
-
if (targetSelector) {
|
|
320
|
-
// oversimplification that actually works
|
|
321
|
-
// (simplified because it assumes the targeted element is a direct child of the contained element which may have padding)
|
|
322
|
-
spacingTop += paddingTop;
|
|
323
|
-
spacingLeft += paddingLeft;
|
|
324
|
-
spacingRight += paddingRight;
|
|
325
|
-
spacingBottom += paddingBottom;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const maxBorderWidth = Math.max(
|
|
329
|
-
borderTopWidth,
|
|
330
|
-
borderLeftWidth,
|
|
331
|
-
borderRightWidth,
|
|
332
|
-
borderBottomWidth,
|
|
333
|
-
);
|
|
334
|
-
const halfMaxBorderSize = maxBorderWidth / 2;
|
|
335
|
-
const size = halfMaxBorderSize < 2 ? 2 : halfMaxBorderSize;
|
|
336
|
-
const lineHalfSize = size / 2;
|
|
337
|
-
spacingTop -= lineHalfSize;
|
|
338
|
-
spacingLeft -= lineHalfSize;
|
|
339
|
-
spacingRight -= lineHalfSize;
|
|
340
|
-
spacingBottom -= lineHalfSize;
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<>
|
|
344
|
-
<span
|
|
345
|
-
ref={rectangleRef}
|
|
346
|
-
className="navi_loading_rectangle_wrapper"
|
|
347
|
-
data-visible={shouldShowSpinner ? "" : undefined}
|
|
348
|
-
style={{
|
|
349
|
-
"--rectangle-top": `${spacingTop}px`,
|
|
350
|
-
"--rectangle-left": `${spacingLeft}px`,
|
|
351
|
-
"--rectangle-bottom": `${spacingBottom}px`,
|
|
352
|
-
"--rectangle-right": `${spacingRight}px`,
|
|
353
|
-
}}
|
|
354
|
-
>
|
|
355
|
-
{/* We want to start rendering the loading asap
|
|
356
|
-
so it can start to rotate as soon as we start to load
|
|
357
|
-
This feels more natural when the loader appears with some initial rotation
|
|
358
|
-
correspondong to the time it took to display it. It feels like it was busy
|
|
359
|
-
And we don't display immeditaly in case it's very fast (<300ms) */}
|
|
360
|
-
{loading && (
|
|
361
|
-
<RectangleLoading
|
|
362
|
-
shouldShowSpinner={shouldShowSpinner}
|
|
363
|
-
color={currentColor}
|
|
364
|
-
radius={borderRadius}
|
|
365
|
-
size={size}
|
|
366
|
-
/>
|
|
367
|
-
)}
|
|
368
|
-
</span>
|
|
369
|
-
{children}
|
|
370
|
-
</>
|
|
371
|
-
);
|
|
372
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export const LoadingSpinner = ({ color = "FF156D" }) => {
|
|
2
|
-
return (
|
|
3
|
-
<svg
|
|
4
|
-
viewBox="0 0 200 200"
|
|
5
|
-
width="100%"
|
|
6
|
-
height="100%"
|
|
7
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
-
>
|
|
9
|
-
<rect
|
|
10
|
-
fill={color}
|
|
11
|
-
stroke={color}
|
|
12
|
-
stroke-width="15"
|
|
13
|
-
width="30"
|
|
14
|
-
height="30"
|
|
15
|
-
x="25"
|
|
16
|
-
y="85"
|
|
17
|
-
>
|
|
18
|
-
<animate
|
|
19
|
-
attributeName="opacity"
|
|
20
|
-
calcMode="spline"
|
|
21
|
-
dur="2"
|
|
22
|
-
values="1;0;1;"
|
|
23
|
-
keySplines=".5 0 .5 1;.5 0 .5 1"
|
|
24
|
-
repeatCount="indefinite"
|
|
25
|
-
begin="-.4"
|
|
26
|
-
></animate>
|
|
27
|
-
</rect>
|
|
28
|
-
<rect
|
|
29
|
-
fill={color}
|
|
30
|
-
stroke={color}
|
|
31
|
-
stroke-width="15"
|
|
32
|
-
width="30"
|
|
33
|
-
height="30"
|
|
34
|
-
x="85"
|
|
35
|
-
y="85"
|
|
36
|
-
>
|
|
37
|
-
<animate
|
|
38
|
-
attributeName="opacity"
|
|
39
|
-
calcMode="spline"
|
|
40
|
-
dur="2"
|
|
41
|
-
values="1;0;1;"
|
|
42
|
-
keySplines=".5 0 .5 1;.5 0 .5 1"
|
|
43
|
-
repeatCount="indefinite"
|
|
44
|
-
begin="-.2"
|
|
45
|
-
></animate>
|
|
46
|
-
</rect>
|
|
47
|
-
<rect
|
|
48
|
-
fill={color}
|
|
49
|
-
stroke={color}
|
|
50
|
-
stroke-width="15"
|
|
51
|
-
width="30"
|
|
52
|
-
height="30"
|
|
53
|
-
x="145"
|
|
54
|
-
y="85"
|
|
55
|
-
>
|
|
56
|
-
<animate
|
|
57
|
-
attributeName="opacity"
|
|
58
|
-
calcMode="spline"
|
|
59
|
-
dur="2"
|
|
60
|
-
values="1;0;1;"
|
|
61
|
-
keySplines=".5 0 .5 1;.5 0 .5 1"
|
|
62
|
-
repeatCount="indefinite"
|
|
63
|
-
begin="0"
|
|
64
|
-
></animate>
|
|
65
|
-
</rect>
|
|
66
|
-
</svg>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { signal } from "@preact/signals";
|
|
2
|
-
|
|
3
|
-
export const useNetworkSpeed = () => {
|
|
4
|
-
return networkSpeedSignal.value;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const connection =
|
|
8
|
-
window.navigator.connection ||
|
|
9
|
-
window.navigator.mozConnection ||
|
|
10
|
-
window.navigator.webkitConnection;
|
|
11
|
-
|
|
12
|
-
const getNetworkSpeed = () => {
|
|
13
|
-
// ✅ Network Information API (support moderne)
|
|
14
|
-
if (!connection) {
|
|
15
|
-
return "3g";
|
|
16
|
-
}
|
|
17
|
-
if (connection) {
|
|
18
|
-
const effectiveType = connection.effectiveType;
|
|
19
|
-
if (effectiveType) {
|
|
20
|
-
return effectiveType; // "slow-2g", "2g", "3g", "4g", "5g"
|
|
21
|
-
}
|
|
22
|
-
const downlink = connection.downlink;
|
|
23
|
-
if (downlink) {
|
|
24
|
-
// downlink is in Mbps
|
|
25
|
-
if (downlink < 1) return "slow-2g"; // < 1 Mbps
|
|
26
|
-
if (downlink < 2.5) return "2g"; // 1-2.5 Mbps
|
|
27
|
-
if (downlink < 10) return "3g"; // 2.5-10 Mbps
|
|
28
|
-
return "4g"; // > 10 Mbps
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return "3g";
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const updateNetworkSpeed = () => {
|
|
35
|
-
networkSpeedSignal.value = getNetworkSpeed();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const networkSpeedSignal = signal(getNetworkSpeed());
|
|
39
|
-
|
|
40
|
-
const setupNetworkMonitoring = () => {
|
|
41
|
-
const cleanupFunctions = [];
|
|
42
|
-
|
|
43
|
-
// ✅ 1. Écouter les changements natifs
|
|
44
|
-
|
|
45
|
-
if (connection) {
|
|
46
|
-
connection.addEventListener("change", updateNetworkSpeed);
|
|
47
|
-
cleanupFunctions.push(() => {
|
|
48
|
-
connection.removeEventListener("change", updateNetworkSpeed);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// ✅ 2. Polling de backup (toutes les 60 secondes)
|
|
53
|
-
const pollInterval = setInterval(updateNetworkSpeed, 60000);
|
|
54
|
-
cleanupFunctions.push(() => clearInterval(pollInterval));
|
|
55
|
-
|
|
56
|
-
// ✅ 3. Vérifier lors de la reprise d'activité
|
|
57
|
-
const handleVisibilityChange = () => {
|
|
58
|
-
if (!document.hidden) {
|
|
59
|
-
updateNetworkSpeed();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
64
|
-
cleanupFunctions.push(() => {
|
|
65
|
-
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// ✅ 4. Vérifier lors de la reprise de connexion
|
|
69
|
-
const handleOnline = () => {
|
|
70
|
-
updateNetworkSpeed();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
window.addEventListener("online", handleOnline);
|
|
74
|
-
cleanupFunctions.push(() => {
|
|
75
|
-
window.removeEventListener("online", handleOnline);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Cleanup global
|
|
79
|
-
return () => {
|
|
80
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
setupNetworkMonitoring();
|