@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.
- package/dist/jsenv_navi.js +13858 -23295
- 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 -177
- 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,303 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" href="data:," />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Form validation test - Multiple elements</title>
|
|
8
|
-
<style>
|
|
9
|
-
.test-container {
|
|
10
|
-
margin: 20px;
|
|
11
|
-
padding: 20px;
|
|
12
|
-
border: 1px solid #ccc;
|
|
13
|
-
border-radius: 4px;
|
|
14
|
-
}
|
|
15
|
-
.field {
|
|
16
|
-
margin-bottom: 15px;
|
|
17
|
-
}
|
|
18
|
-
.field label {
|
|
19
|
-
display: block;
|
|
20
|
-
margin-bottom: 5px;
|
|
21
|
-
font-weight: bold;
|
|
22
|
-
}
|
|
23
|
-
.status {
|
|
24
|
-
margin-top: 20px;
|
|
25
|
-
padding: 10px;
|
|
26
|
-
border-radius: 4px;
|
|
27
|
-
}
|
|
28
|
-
.status.success {
|
|
29
|
-
background-color: #d4edda;
|
|
30
|
-
color: #155724;
|
|
31
|
-
border: 1px solid #c3e6cb;
|
|
32
|
-
}
|
|
33
|
-
.status.error {
|
|
34
|
-
background-color: #f8d7da;
|
|
35
|
-
color: #721c24;
|
|
36
|
-
border: 1px solid #f5c6cb;
|
|
37
|
-
}
|
|
38
|
-
.validation-errors {
|
|
39
|
-
margin-top: 10px;
|
|
40
|
-
}
|
|
41
|
-
.validation-errors ul {
|
|
42
|
-
margin: 0;
|
|
43
|
-
padding-left: 20px;
|
|
44
|
-
}
|
|
45
|
-
/* ✅ Styles for form params display */
|
|
46
|
-
.form-params {
|
|
47
|
-
margin-top: 20px;
|
|
48
|
-
padding: 15px;
|
|
49
|
-
background-color: #f8f9fa;
|
|
50
|
-
border: 1px solid #dee2e6;
|
|
51
|
-
border-radius: 4px;
|
|
52
|
-
}
|
|
53
|
-
.form-params h3 {
|
|
54
|
-
margin-top: 0;
|
|
55
|
-
color: #495057;
|
|
56
|
-
}
|
|
57
|
-
.form-params pre {
|
|
58
|
-
background-color: #e9ecef;
|
|
59
|
-
padding: 10px;
|
|
60
|
-
border-radius: 4px;
|
|
61
|
-
overflow-x: auto;
|
|
62
|
-
margin: 0;
|
|
63
|
-
font-size: 14px;
|
|
64
|
-
}
|
|
65
|
-
</style>
|
|
66
|
-
</head>
|
|
67
|
-
<body>
|
|
68
|
-
<div id="root"></div>
|
|
69
|
-
|
|
70
|
-
<script type="module" jsenv-type="module/jsx">
|
|
71
|
-
import { render } from "preact";
|
|
72
|
-
import { useState } from "preact/hooks";
|
|
73
|
-
import {
|
|
74
|
-
// eslint-disable-next-line no-unused-vars
|
|
75
|
-
Input,
|
|
76
|
-
// eslint-disable-next-line no-unused-vars
|
|
77
|
-
Form,
|
|
78
|
-
// eslint-disable-next-line no-unused-vars
|
|
79
|
-
Button,
|
|
80
|
-
} from "@jsenv/navi";
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line no-unused-vars
|
|
83
|
-
const App = () => {
|
|
84
|
-
return (
|
|
85
|
-
<div>
|
|
86
|
-
<h1>Test de validation de formulaire multi-éléments</h1>
|
|
87
|
-
<MultiFieldValidationTest />
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// eslint-disable-next-line no-unused-vars
|
|
93
|
-
const MultiFieldValidationTest = () => {
|
|
94
|
-
const [submitStatus, setSubmitStatus] = useState(null);
|
|
95
|
-
const [validationErrors, setValidationErrors] = useState([]);
|
|
96
|
-
const [formParams, setFormParams] = useState(null); // ✅ New state for form params
|
|
97
|
-
|
|
98
|
-
const handleFormExecutePrevented = (event) => {
|
|
99
|
-
console.log("❌ Form execute prevented event:", event);
|
|
100
|
-
const reason = event.detail;
|
|
101
|
-
|
|
102
|
-
if (reason === "validation_failed") {
|
|
103
|
-
setSubmitStatus("error");
|
|
104
|
-
setFormParams(null); // ✅ Clear params on validation failure
|
|
105
|
-
|
|
106
|
-
// Collecter toutes les erreurs de validation
|
|
107
|
-
const form = event.target;
|
|
108
|
-
const errors = [];
|
|
109
|
-
|
|
110
|
-
// Parcourir tous les éléments du formulaire
|
|
111
|
-
const formElements = form.querySelectorAll(
|
|
112
|
-
"input, select, textarea",
|
|
113
|
-
);
|
|
114
|
-
formElements.forEach((element) => {
|
|
115
|
-
const validationInterface = element.__validationInterface__;
|
|
116
|
-
if (validationInterface) {
|
|
117
|
-
// Vérifier si l'élément a des erreurs
|
|
118
|
-
if (
|
|
119
|
-
!element.checkValidity() ||
|
|
120
|
-
!validationInterface.checkValidity?.()
|
|
121
|
-
) {
|
|
122
|
-
const fieldName = element.name || element.id || element.type;
|
|
123
|
-
const validationMessage =
|
|
124
|
-
element.validationMessage || "Invalid value";
|
|
125
|
-
errors.push(`${fieldName}: ${validationMessage}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
setValidationErrors(errors);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<div className="test-container">
|
|
136
|
-
<h2>Formulaire avec validation multiple</h2>
|
|
137
|
-
<p>
|
|
138
|
-
Ce formulaire contient plusieurs champs avec différentes
|
|
139
|
-
contraintes. Essayez de soumettre avec des valeurs invalides pour
|
|
140
|
-
voir toutes les erreurs.
|
|
141
|
-
</p>
|
|
142
|
-
|
|
143
|
-
<Form
|
|
144
|
-
onReset={() => {
|
|
145
|
-
setSubmitStatus(null);
|
|
146
|
-
setValidationErrors([]);
|
|
147
|
-
setFormParams(null); // ✅ Clear params on reset
|
|
148
|
-
}}
|
|
149
|
-
onExecutePrevented={handleFormExecutePrevented}
|
|
150
|
-
action={async (params) => {
|
|
151
|
-
console.log("🎯 Form execute event with params:", params);
|
|
152
|
-
|
|
153
|
-
// ✅ Store form params in state
|
|
154
|
-
setFormParams(params);
|
|
155
|
-
setSubmitStatus("executing...");
|
|
156
|
-
setValidationErrors([]);
|
|
157
|
-
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
|
158
|
-
setSubmitStatus("Form submitted successfully!");
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
161
|
-
{/* ✅ Champ requis */}
|
|
162
|
-
<div className="field">
|
|
163
|
-
<label htmlFor="required-field">Nom (obligatoire) :</label>
|
|
164
|
-
<Input
|
|
165
|
-
id="required-field"
|
|
166
|
-
name="name"
|
|
167
|
-
required
|
|
168
|
-
placeholder="Entrez votre nom"
|
|
169
|
-
/>
|
|
170
|
-
</div>
|
|
171
|
-
|
|
172
|
-
{/* ✅ Champ email avec validation type */}
|
|
173
|
-
<div className="field">
|
|
174
|
-
<label htmlFor="email-field">Email (format email) :</label>
|
|
175
|
-
<Input
|
|
176
|
-
id="email-field"
|
|
177
|
-
name="email"
|
|
178
|
-
type="email"
|
|
179
|
-
placeholder="exemple@domain.com"
|
|
180
|
-
/>
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
{/* ✅ Champ avec pattern */}
|
|
184
|
-
<div className="field">
|
|
185
|
-
<label htmlFor="phone-field">
|
|
186
|
-
Téléphone (format: 01-23-45-67-89) :
|
|
187
|
-
</label>
|
|
188
|
-
<Input
|
|
189
|
-
id="phone-field"
|
|
190
|
-
name="phone"
|
|
191
|
-
pattern="[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}"
|
|
192
|
-
pattern-validation-message="Doit respecter le format <strong>01-23-45-67-89</strong>."
|
|
193
|
-
placeholder="01-23-45-67-89"
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
{/* ✅ Champ avec longueur minimum */}
|
|
198
|
-
<div className="field">
|
|
199
|
-
<label htmlFor="password-field">
|
|
200
|
-
Mot de passe (min 8 caractères) :
|
|
201
|
-
</label>
|
|
202
|
-
<Input
|
|
203
|
-
id="password-field"
|
|
204
|
-
name="password"
|
|
205
|
-
type="password"
|
|
206
|
-
minLength="8"
|
|
207
|
-
placeholder="Au moins 8 caractères"
|
|
208
|
-
/>
|
|
209
|
-
</div>
|
|
210
|
-
|
|
211
|
-
{/* ✅ Champ avec contrainte personnalisée */}
|
|
212
|
-
<div className="field">
|
|
213
|
-
<label htmlFor="age-field">Âge (18-99 ans) :</label>
|
|
214
|
-
<Input
|
|
215
|
-
id="age-field"
|
|
216
|
-
name="age"
|
|
217
|
-
type="number"
|
|
218
|
-
min="18"
|
|
219
|
-
min-validation-message="L'age doit être de <strong>18</strong> ans ou plus."
|
|
220
|
-
max="99"
|
|
221
|
-
max-validation-message="L'age doit être de <strong>99</strong> ans ou moins."
|
|
222
|
-
placeholder="18"
|
|
223
|
-
/>
|
|
224
|
-
</div>
|
|
225
|
-
|
|
226
|
-
{/* ✅ Bouton de soumission */}
|
|
227
|
-
<div className="field">
|
|
228
|
-
<Button type="submit">Valider le formulaire</Button>
|
|
229
|
-
<Button type="reset">Reset Status</Button>
|
|
230
|
-
</div>
|
|
231
|
-
</Form>
|
|
232
|
-
|
|
233
|
-
{/* ✅ Affichage des paramètres du formulaire */}
|
|
234
|
-
{formParams && (
|
|
235
|
-
<div className="form-params">
|
|
236
|
-
<h3>📋 Paramètres du formulaire soumis :</h3>
|
|
237
|
-
<pre>{JSON.stringify(formParams, null, 2)}</pre>
|
|
238
|
-
</div>
|
|
239
|
-
)}
|
|
240
|
-
|
|
241
|
-
{/* ✅ Affichage du statut */}
|
|
242
|
-
{submitStatus && (
|
|
243
|
-
<div
|
|
244
|
-
className={`status ${submitStatus === "error" ? "error" : "success"}`}
|
|
245
|
-
>
|
|
246
|
-
{submitStatus === "error" ? (
|
|
247
|
-
<div>
|
|
248
|
-
<strong>❌ Validation échouée</strong>
|
|
249
|
-
{validationErrors.length > 0 && (
|
|
250
|
-
<div className="validation-errors">
|
|
251
|
-
<p>Erreurs détectées :</p>
|
|
252
|
-
<ul>
|
|
253
|
-
{validationErrors.map((error, index) => (
|
|
254
|
-
<li key={index}>{error}</li>
|
|
255
|
-
))}
|
|
256
|
-
</ul>
|
|
257
|
-
</div>
|
|
258
|
-
)}
|
|
259
|
-
</div>
|
|
260
|
-
) : (
|
|
261
|
-
<strong>✅ {submitStatus}</strong>
|
|
262
|
-
)}
|
|
263
|
-
</div>
|
|
264
|
-
)}
|
|
265
|
-
|
|
266
|
-
{/* ✅ Instructions de test */}
|
|
267
|
-
<div
|
|
268
|
-
style={{
|
|
269
|
-
marginTop: "30px",
|
|
270
|
-
padding: "15px",
|
|
271
|
-
backgroundColor: "#f8f9fa",
|
|
272
|
-
borderRadius: "4px",
|
|
273
|
-
}}
|
|
274
|
-
>
|
|
275
|
-
<h3>Instructions de test :</h3>
|
|
276
|
-
<ol>
|
|
277
|
-
<li>
|
|
278
|
-
<strong>Test 1</strong> : Laissez tous les champs vides et
|
|
279
|
-
cliquez "Valider" → Doit montrer toutes les erreurs
|
|
280
|
-
</li>
|
|
281
|
-
<li>
|
|
282
|
-
<strong>Test 2</strong> : Remplissez partiellement (ex: nom
|
|
283
|
-
seulement) → Doit montrer les erreurs restantes
|
|
284
|
-
</li>
|
|
285
|
-
<li>
|
|
286
|
-
<strong>Test 3</strong> : Entrez des valeurs invalides (ex:
|
|
287
|
-
email sans @, âge inf. 18) → Doit montrer les erreurs
|
|
288
|
-
spécifiques
|
|
289
|
-
</li>
|
|
290
|
-
<li>
|
|
291
|
-
<strong>Test 4</strong> : Remplissez tout correctement → Doit
|
|
292
|
-
permettre la soumission et afficher les paramètres
|
|
293
|
-
</li>
|
|
294
|
-
</ol>
|
|
295
|
-
</div>
|
|
296
|
-
</div>
|
|
297
|
-
);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
render(<App />, document.querySelector("#root"));
|
|
301
|
-
</script>
|
|
302
|
-
</body>
|
|
303
|
-
</html>
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" href="data:," />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Details demo</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root" style="position: relative"></div>
|
|
11
|
-
|
|
12
|
-
<script type="module" jsenv-type="module/jsx">
|
|
13
|
-
import { render } from "preact";
|
|
14
|
-
import {
|
|
15
|
-
createAction,
|
|
16
|
-
// eslint-disable-next-line no-unused-vars
|
|
17
|
-
Details,
|
|
18
|
-
// eslint-disable-next-line no-unused-vars
|
|
19
|
-
Form,
|
|
20
|
-
} from "@jsenv/navi";
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-unused-vars
|
|
23
|
-
const App = () => {
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
<div style="display: flex; flex-direction: row; gap: 30px">
|
|
27
|
-
<DetailsLoadSyncDemo />
|
|
28
|
-
<DetailsLoadAfter1sDemo />
|
|
29
|
-
<DetailsThrowSyncDemo />
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<DetailsFullControlDemo />
|
|
33
|
-
<DetailsWithActionPreloadedDemo />
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line no-unused-vars
|
|
39
|
-
const DetailsLoadSyncDemo = () => {
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<p>
|
|
43
|
-
<strong>Loaded sync</strong>
|
|
44
|
-
</p>
|
|
45
|
-
<Details
|
|
46
|
-
id="test"
|
|
47
|
-
action={() => {
|
|
48
|
-
return "Hello";
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
{(message) => <span>{message}</span>}
|
|
52
|
-
</Details>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line no-unused-vars
|
|
58
|
-
const DetailsLoadAfter1sDemo = () => {
|
|
59
|
-
return (
|
|
60
|
-
<div>
|
|
61
|
-
<p>
|
|
62
|
-
<strong>Loaded after 1s</strong>
|
|
63
|
-
</p>
|
|
64
|
-
<Details
|
|
65
|
-
id="test_2"
|
|
66
|
-
action={async () => {
|
|
67
|
-
await new Promise((resolve) => {
|
|
68
|
-
setTimeout(resolve, 1000);
|
|
69
|
-
});
|
|
70
|
-
return "Hello";
|
|
71
|
-
}}
|
|
72
|
-
label="Custom summary"
|
|
73
|
-
>
|
|
74
|
-
{(content) => content}
|
|
75
|
-
</Details>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// eslint-disable-next-line no-unused-vars
|
|
81
|
-
const DetailsThrowSyncDemo = () => {
|
|
82
|
-
return (
|
|
83
|
-
<div>
|
|
84
|
-
<p>
|
|
85
|
-
<strong>Throw sync</strong>
|
|
86
|
-
</p>
|
|
87
|
-
<Details
|
|
88
|
-
// id="test_3"
|
|
89
|
-
action={() => {
|
|
90
|
-
throw new Error("error");
|
|
91
|
-
}}
|
|
92
|
-
label={
|
|
93
|
-
<>
|
|
94
|
-
<span>A</span>
|
|
95
|
-
<span style="font-weight: bold">mixed summary</span>
|
|
96
|
-
</>
|
|
97
|
-
}
|
|
98
|
-
></Details>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line no-unused-vars
|
|
104
|
-
const DetailsFullControlDemo = () => {
|
|
105
|
-
return (
|
|
106
|
-
<div>
|
|
107
|
-
<p>
|
|
108
|
-
<strong>Full control (abort, reload)</strong>
|
|
109
|
-
</p>
|
|
110
|
-
<Details
|
|
111
|
-
id="test_4"
|
|
112
|
-
action={async (_, { signal }) => {
|
|
113
|
-
await new Promise((resolve) => {
|
|
114
|
-
const timeout = setTimeout(resolve, 1000);
|
|
115
|
-
signal.addEventListener("abort", () => {
|
|
116
|
-
clearTimeout(timeout);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
return "Hello";
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
{{
|
|
123
|
-
loading: (action) => {
|
|
124
|
-
return (
|
|
125
|
-
<span>
|
|
126
|
-
Loading...
|
|
127
|
-
<button
|
|
128
|
-
onClick={() => {
|
|
129
|
-
action.abort();
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
Abort
|
|
133
|
-
</button>
|
|
134
|
-
</span>
|
|
135
|
-
);
|
|
136
|
-
},
|
|
137
|
-
aborted: (action) => (
|
|
138
|
-
<>
|
|
139
|
-
<span style="color: red">Aborted</span>
|
|
140
|
-
<button
|
|
141
|
-
onClick={() => {
|
|
142
|
-
action.rerun();
|
|
143
|
-
}}
|
|
144
|
-
>
|
|
145
|
-
Reload
|
|
146
|
-
</button>
|
|
147
|
-
</>
|
|
148
|
-
),
|
|
149
|
-
completed: (message, action) => (
|
|
150
|
-
<>
|
|
151
|
-
<span>{message}</span>
|
|
152
|
-
<button
|
|
153
|
-
onClick={() => {
|
|
154
|
-
action.rerun();
|
|
155
|
-
}}
|
|
156
|
-
>
|
|
157
|
-
Reload
|
|
158
|
-
</button>
|
|
159
|
-
</>
|
|
160
|
-
),
|
|
161
|
-
}}
|
|
162
|
-
</Details>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const rootAction = createAction(
|
|
168
|
-
async ({ name = "default name" }) => {
|
|
169
|
-
await new Promise((resolve) => {
|
|
170
|
-
setTimeout(resolve, 500);
|
|
171
|
-
});
|
|
172
|
-
return name;
|
|
173
|
-
},
|
|
174
|
-
{ name: "load user" },
|
|
175
|
-
);
|
|
176
|
-
window.rootAction = rootAction;
|
|
177
|
-
// const boundAction = rootAction.bindParams({
|
|
178
|
-
// name: "dam",
|
|
179
|
-
// });
|
|
180
|
-
rootAction.prerun();
|
|
181
|
-
// eslint-disable-next-line no-unused-vars
|
|
182
|
-
const DetailsWithActionPreloadedDemo = () => {
|
|
183
|
-
return (
|
|
184
|
-
<div>
|
|
185
|
-
<p>
|
|
186
|
-
<strong>Action preloaded</strong>
|
|
187
|
-
</p>
|
|
188
|
-
|
|
189
|
-
<Details
|
|
190
|
-
id="bound"
|
|
191
|
-
action={rootAction}
|
|
192
|
-
label="Action using bind params"
|
|
193
|
-
>
|
|
194
|
-
{(content) => content}
|
|
195
|
-
</Details>
|
|
196
|
-
</div>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
render(<App />, document.querySelector("#root"));
|
|
201
|
-
</script>
|
|
202
|
-
</body>
|
|
203
|
-
</html>
|