@jsenv/navi 0.10.2 → 0.11.1
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 +6 -8
- 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,256 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from "preact/compat";
|
|
2
|
-
import { useEffect, useImperativeHandle, useRef, useState } from "preact/hooks";
|
|
3
|
-
|
|
4
|
-
import { useNavState } from "../../browser_integration/browser_integration.js";
|
|
5
|
-
import { useActionStatus } from "../../use_action_status.js";
|
|
6
|
-
import { requestAction } from "../../validation/custom_constraint_validation.js";
|
|
7
|
-
import { renderActionableComponent } from "../action_execution/render_actionable_component.jsx";
|
|
8
|
-
import { useActionBoundToOneParam } from "../action_execution/use_action.js";
|
|
9
|
-
import { useExecuteAction } from "../action_execution/use_execute_action.js";
|
|
10
|
-
import { LoaderBackground } from "../loader/loader_background.jsx";
|
|
11
|
-
import { useRefArray } from "../use_ref_array.js";
|
|
12
|
-
import { useActionEvents } from "./use_action_events.js";
|
|
13
|
-
import { useFormEvents } from "./use_form_events.js";
|
|
14
|
-
|
|
15
|
-
import.meta.css = /* css */ `
|
|
16
|
-
.navi_select[data-readonly] {
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
export const Select = forwardRef((props, ref) => {
|
|
22
|
-
const select = renderActionableComponent(props, ref, {
|
|
23
|
-
Basic: SelectBasic,
|
|
24
|
-
WithAction: SelectWithAction,
|
|
25
|
-
InsideForm: SelectInsideForm,
|
|
26
|
-
});
|
|
27
|
-
return select;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const SelectControlled = forwardRef((props, ref) => {
|
|
31
|
-
const { name, value, loading, disabled, readOnly, children, ...rest } = props;
|
|
32
|
-
|
|
33
|
-
const innerRef = useRef();
|
|
34
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
35
|
-
|
|
36
|
-
const selectElement = (
|
|
37
|
-
<select
|
|
38
|
-
className="navi_select"
|
|
39
|
-
ref={innerRef}
|
|
40
|
-
data-readonly={readOnly && !disabled ? "" : undefined}
|
|
41
|
-
onKeyDown={(e) => {
|
|
42
|
-
if (readOnly) {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
}
|
|
45
|
-
}}
|
|
46
|
-
{...rest}
|
|
47
|
-
>
|
|
48
|
-
{children.map((child) => {
|
|
49
|
-
const {
|
|
50
|
-
label,
|
|
51
|
-
readOnly: childReadOnly,
|
|
52
|
-
disabled: childDisabled,
|
|
53
|
-
loading: childLoading,
|
|
54
|
-
value: childValue,
|
|
55
|
-
...childRest
|
|
56
|
-
} = child;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<option
|
|
60
|
-
key={childValue}
|
|
61
|
-
name={name}
|
|
62
|
-
value={childValue}
|
|
63
|
-
selected={childValue === value}
|
|
64
|
-
readOnly={readOnly || childReadOnly}
|
|
65
|
-
disabled={disabled || childDisabled}
|
|
66
|
-
loading={loading || childLoading}
|
|
67
|
-
{...childRest}
|
|
68
|
-
>
|
|
69
|
-
{label}
|
|
70
|
-
</option>
|
|
71
|
-
);
|
|
72
|
-
})}
|
|
73
|
-
</select>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<LoaderBackground
|
|
78
|
-
loading={loading}
|
|
79
|
-
color="light-dark(#355fcc, #3b82f6)"
|
|
80
|
-
inset={-1}
|
|
81
|
-
>
|
|
82
|
-
{selectElement}
|
|
83
|
-
</LoaderBackground>
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const SelectBasic = forwardRef((props, ref) => {
|
|
88
|
-
const { value: initialValue, id, children, ...rest } = props;
|
|
89
|
-
|
|
90
|
-
const innerRef = useRef();
|
|
91
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
92
|
-
|
|
93
|
-
const [navState, setNavState] = useNavState(id);
|
|
94
|
-
const valueAtStart = navState === undefined ? initialValue : navState;
|
|
95
|
-
const [value, setValue] = useState(valueAtStart);
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
setNavState(value);
|
|
98
|
-
}, [value]);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<SelectControlled
|
|
102
|
-
ref={innerRef}
|
|
103
|
-
value={value}
|
|
104
|
-
onChange={(event) => {
|
|
105
|
-
const select = event.target;
|
|
106
|
-
const selectedValue = select.value;
|
|
107
|
-
setValue(selectedValue);
|
|
108
|
-
}}
|
|
109
|
-
{...rest}
|
|
110
|
-
>
|
|
111
|
-
{children}
|
|
112
|
-
</SelectControlled>
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const SelectWithAction = forwardRef((props, ref) => {
|
|
117
|
-
const {
|
|
118
|
-
id,
|
|
119
|
-
name,
|
|
120
|
-
value: externalValue,
|
|
121
|
-
valueSignal,
|
|
122
|
-
action,
|
|
123
|
-
children,
|
|
124
|
-
onCancel,
|
|
125
|
-
onActionPrevented,
|
|
126
|
-
onActionStart,
|
|
127
|
-
onActionAbort,
|
|
128
|
-
onActionError,
|
|
129
|
-
onActionEnd,
|
|
130
|
-
actionErrorEffect,
|
|
131
|
-
...rest
|
|
132
|
-
} = props;
|
|
133
|
-
|
|
134
|
-
const innerRef = useRef();
|
|
135
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
136
|
-
|
|
137
|
-
const [navState, setNavState, resetNavState] = useNavState(id);
|
|
138
|
-
const [boundAction, value, setValue, initialValue] = useActionBoundToOneParam(
|
|
139
|
-
action,
|
|
140
|
-
name,
|
|
141
|
-
valueSignal ? valueSignal : externalValue,
|
|
142
|
-
navState,
|
|
143
|
-
);
|
|
144
|
-
const { loading: actionLoading } = useActionStatus(boundAction);
|
|
145
|
-
const executeAction = useExecuteAction(innerRef, {
|
|
146
|
-
errorEffect: actionErrorEffect,
|
|
147
|
-
});
|
|
148
|
-
useEffect(() => {
|
|
149
|
-
setNavState(value);
|
|
150
|
-
}, [value]);
|
|
151
|
-
|
|
152
|
-
const actionRequesterRef = useRef(null);
|
|
153
|
-
useActionEvents(innerRef, {
|
|
154
|
-
onCancel: (e, reason) => {
|
|
155
|
-
resetNavState();
|
|
156
|
-
setValue(initialValue);
|
|
157
|
-
onCancel?.(e, reason);
|
|
158
|
-
},
|
|
159
|
-
onPrevented: onActionPrevented,
|
|
160
|
-
onAction: (actionEvent) => {
|
|
161
|
-
actionRequesterRef.current = actionEvent.detail.requester;
|
|
162
|
-
executeAction(actionEvent);
|
|
163
|
-
},
|
|
164
|
-
onStart: onActionStart,
|
|
165
|
-
onAbort: (e) => {
|
|
166
|
-
setValue(initialValue);
|
|
167
|
-
onActionAbort?.(e);
|
|
168
|
-
},
|
|
169
|
-
onError: (error) => {
|
|
170
|
-
setValue(initialValue);
|
|
171
|
-
onActionError?.(error);
|
|
172
|
-
},
|
|
173
|
-
onEnd: () => {
|
|
174
|
-
resetNavState();
|
|
175
|
-
onActionEnd?.();
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const childRefArray = useRefArray(children, (child) => child.value);
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<SelectControlled
|
|
183
|
-
ref={innerRef}
|
|
184
|
-
name={name}
|
|
185
|
-
value={value}
|
|
186
|
-
data-action={boundAction}
|
|
187
|
-
onChange={(event) => {
|
|
188
|
-
const select = event.target;
|
|
189
|
-
const selectedValue = select.value;
|
|
190
|
-
setValue(selectedValue);
|
|
191
|
-
const radioListContainer = innerRef.current;
|
|
192
|
-
const optionSelected = select.querySelector(
|
|
193
|
-
`option[value="${selectedValue}"]`,
|
|
194
|
-
);
|
|
195
|
-
requestAction(radioListContainer, boundAction, {
|
|
196
|
-
event,
|
|
197
|
-
requester: optionSelected,
|
|
198
|
-
});
|
|
199
|
-
}}
|
|
200
|
-
{...rest}
|
|
201
|
-
>
|
|
202
|
-
{children.map((child, i) => {
|
|
203
|
-
const childRef = childRefArray[i];
|
|
204
|
-
return {
|
|
205
|
-
...child,
|
|
206
|
-
ref: childRef,
|
|
207
|
-
loading:
|
|
208
|
-
child.loading ||
|
|
209
|
-
(actionLoading && actionRequesterRef.current === childRef.current),
|
|
210
|
-
readOnly: child.readOnly || actionLoading,
|
|
211
|
-
};
|
|
212
|
-
})}
|
|
213
|
-
</SelectControlled>
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const SelectInsideForm = forwardRef((props, ref) => {
|
|
218
|
-
const { id, name, value: externalValue, children, ...rest } = props;
|
|
219
|
-
|
|
220
|
-
const innerRef = useRef();
|
|
221
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
222
|
-
|
|
223
|
-
const [navState, setNavState] = useNavState(id);
|
|
224
|
-
const [value, setValue, initialValue] = [name, externalValue, navState];
|
|
225
|
-
useEffect(() => {
|
|
226
|
-
setNavState(value);
|
|
227
|
-
}, [value]);
|
|
228
|
-
|
|
229
|
-
useFormEvents(innerRef, {
|
|
230
|
-
onFormReset: () => {
|
|
231
|
-
setValue(undefined);
|
|
232
|
-
},
|
|
233
|
-
onFormActionAbort: () => {
|
|
234
|
-
setValue(initialValue);
|
|
235
|
-
},
|
|
236
|
-
onFormActionError: () => {
|
|
237
|
-
setValue(initialValue);
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
return (
|
|
242
|
-
<SelectControlled
|
|
243
|
-
ref={innerRef}
|
|
244
|
-
name={name}
|
|
245
|
-
value={value}
|
|
246
|
-
onChange={(event) => {
|
|
247
|
-
const select = event.target;
|
|
248
|
-
const selectedValue = select.checked;
|
|
249
|
-
setValue(selectedValue);
|
|
250
|
-
}}
|
|
251
|
-
{...rest}
|
|
252
|
-
>
|
|
253
|
-
{children}
|
|
254
|
-
</SelectControlled>
|
|
255
|
-
);
|
|
256
|
-
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "preact/hooks";
|
|
2
|
-
|
|
3
|
-
import { addManyEventListeners } from "../../utils/add_many_event_listeners.js";
|
|
4
|
-
import { useStableCallback } from "../use_stable_callback.js";
|
|
5
|
-
|
|
6
|
-
export const useActionEvents = (
|
|
7
|
-
elementRef,
|
|
8
|
-
{
|
|
9
|
-
actionOrigin = "action_prop",
|
|
10
|
-
/**
|
|
11
|
-
* @param {Event} e - L'événement original
|
|
12
|
-
* @param {"form_reset" | "blur_invalid" | "escape_key"} reason - Raison du cancel
|
|
13
|
-
*/
|
|
14
|
-
onCancel,
|
|
15
|
-
onRequested,
|
|
16
|
-
onPrevented,
|
|
17
|
-
onAction,
|
|
18
|
-
onStart,
|
|
19
|
-
onAbort,
|
|
20
|
-
onError,
|
|
21
|
-
onEnd,
|
|
22
|
-
},
|
|
23
|
-
) => {
|
|
24
|
-
onCancel = useStableCallback(onCancel);
|
|
25
|
-
onRequested = useStableCallback(onRequested);
|
|
26
|
-
onPrevented = useStableCallback(onPrevented);
|
|
27
|
-
onAction = useStableCallback(onAction);
|
|
28
|
-
onStart = useStableCallback(onStart);
|
|
29
|
-
onAbort = useStableCallback(onAbort);
|
|
30
|
-
onError = useStableCallback(onError);
|
|
31
|
-
onEnd = useStableCallback(onEnd);
|
|
32
|
-
|
|
33
|
-
useLayoutEffect(() => {
|
|
34
|
-
const element = elementRef.current;
|
|
35
|
-
if (!element) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return addManyEventListeners(element, {
|
|
40
|
-
cancel: (e) => {
|
|
41
|
-
// cancel don't need to check for actionOrigin because
|
|
42
|
-
// it's actually unrelated to a specific actions
|
|
43
|
-
// in that sense it should likely be moved elsewhere as it's related to
|
|
44
|
-
// interaction and constraint validation, not to a specific action
|
|
45
|
-
onCancel?.(e, e.detail.reason);
|
|
46
|
-
},
|
|
47
|
-
actionrequested: (e) => {
|
|
48
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
onRequested?.(e);
|
|
52
|
-
},
|
|
53
|
-
actionprevented: (e) => {
|
|
54
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
onPrevented?.(e);
|
|
58
|
-
},
|
|
59
|
-
action: (e) => {
|
|
60
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
onAction?.(e);
|
|
64
|
-
},
|
|
65
|
-
actionstart: (e) => {
|
|
66
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
onStart?.(e);
|
|
70
|
-
},
|
|
71
|
-
actionabort: (e) => {
|
|
72
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
onAbort?.(e);
|
|
76
|
-
},
|
|
77
|
-
actionerror: (e) => {
|
|
78
|
-
if (e.detail.actionOrigin !== actionOrigin) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
onError?.(e.detail.error, e);
|
|
82
|
-
},
|
|
83
|
-
actionend: onEnd,
|
|
84
|
-
});
|
|
85
|
-
}, [
|
|
86
|
-
actionOrigin,
|
|
87
|
-
onCancel,
|
|
88
|
-
onRequested,
|
|
89
|
-
onPrevented,
|
|
90
|
-
onAction,
|
|
91
|
-
onStart,
|
|
92
|
-
onAbort,
|
|
93
|
-
onError,
|
|
94
|
-
onEnd,
|
|
95
|
-
]);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const useRequestedActionStatus = (elementRef) => {
|
|
99
|
-
const [actionRequester, setActionRequester] = useState(null);
|
|
100
|
-
const [actionPending, setActionPending] = useState(false);
|
|
101
|
-
const [actionAborted, setActionAborted] = useState(false);
|
|
102
|
-
const [actionError, setActionError] = useState(null);
|
|
103
|
-
|
|
104
|
-
useActionEvents(elementRef, {
|
|
105
|
-
onAction: (actionEvent) => {
|
|
106
|
-
setActionRequester(actionEvent.detail.requester);
|
|
107
|
-
},
|
|
108
|
-
onStart: () => {
|
|
109
|
-
setActionPending(true);
|
|
110
|
-
setActionAborted(false);
|
|
111
|
-
setActionError(null);
|
|
112
|
-
},
|
|
113
|
-
onAbort: () => {
|
|
114
|
-
setActionPending(false);
|
|
115
|
-
setActionAborted(true);
|
|
116
|
-
},
|
|
117
|
-
onError: (error) => {
|
|
118
|
-
setActionPending(false);
|
|
119
|
-
setActionError(error);
|
|
120
|
-
},
|
|
121
|
-
onEnd: () => {
|
|
122
|
-
setActionPending(false);
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
actionRequester,
|
|
128
|
-
actionPending,
|
|
129
|
-
actionAborted,
|
|
130
|
-
actionError,
|
|
131
|
-
};
|
|
132
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect } from "preact/hooks";
|
|
2
|
-
|
|
3
|
-
import { addManyEventListeners } from "../../utils/add_many_event_listeners.js";
|
|
4
|
-
import { useStableCallback } from "../use_stable_callback.js";
|
|
5
|
-
|
|
6
|
-
export const useFormEvents = (
|
|
7
|
-
elementRef,
|
|
8
|
-
{
|
|
9
|
-
onFormReset,
|
|
10
|
-
onFormActionRequested,
|
|
11
|
-
onFormActionPrevented,
|
|
12
|
-
onFormActionStart,
|
|
13
|
-
onFormActionAbort,
|
|
14
|
-
onFormActionError,
|
|
15
|
-
onFormActionEnd,
|
|
16
|
-
},
|
|
17
|
-
) => {
|
|
18
|
-
onFormReset = useStableCallback(onFormReset);
|
|
19
|
-
onFormActionRequested = useStableCallback(onFormActionRequested);
|
|
20
|
-
onFormActionPrevented = useStableCallback(onFormActionPrevented);
|
|
21
|
-
onFormActionStart = useStableCallback(onFormActionStart);
|
|
22
|
-
onFormActionAbort = useStableCallback(onFormActionAbort);
|
|
23
|
-
onFormActionError = useStableCallback(onFormActionError);
|
|
24
|
-
onFormActionEnd = useStableCallback(onFormActionEnd);
|
|
25
|
-
|
|
26
|
-
useLayoutEffect(() => {
|
|
27
|
-
const element = elementRef.current;
|
|
28
|
-
if (!element) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let form = element.form;
|
|
33
|
-
if (!form) {
|
|
34
|
-
// some non input elements may want to listen form events (<RadioList> is a <div>)
|
|
35
|
-
form = element.closest("form");
|
|
36
|
-
if (!form) {
|
|
37
|
-
console.warn("No form found for element", element);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return addManyEventListeners(form, {
|
|
42
|
-
reset: onFormReset,
|
|
43
|
-
actionrequested: onFormActionRequested,
|
|
44
|
-
actionprevented: onFormActionPrevented,
|
|
45
|
-
actionstart: onFormActionStart,
|
|
46
|
-
actionabort: onFormActionAbort,
|
|
47
|
-
actionerror: onFormActionError,
|
|
48
|
-
actionend: onFormActionEnd,
|
|
49
|
-
});
|
|
50
|
-
}, [
|
|
51
|
-
onFormReset,
|
|
52
|
-
onFormActionRequested,
|
|
53
|
-
onFormActionPrevented,
|
|
54
|
-
onFormActionStart,
|
|
55
|
-
onFormActionAbort,
|
|
56
|
-
onFormActionError,
|
|
57
|
-
onFormActionEnd,
|
|
58
|
-
]);
|
|
59
|
-
};
|