@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,357 +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>Radio list 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 { useState } from "preact/hooks";
|
|
15
|
-
import {
|
|
16
|
-
// eslint-disable-next-line no-unused-vars
|
|
17
|
-
Button,
|
|
18
|
-
// eslint-disable-next-line no-unused-vars
|
|
19
|
-
Form,
|
|
20
|
-
// eslint-disable-next-line no-unused-vars
|
|
21
|
-
RadioList,
|
|
22
|
-
// eslint-disable-next-line no-unused-vars
|
|
23
|
-
Radio,
|
|
24
|
-
// eslint-disable-next-line no-unused-vars
|
|
25
|
-
Label,
|
|
26
|
-
} from "@jsenv/navi";
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line no-unused-vars
|
|
29
|
-
const App = () => {
|
|
30
|
-
return (
|
|
31
|
-
<div style="display: flex; flex-direction: column; gap: 40px">
|
|
32
|
-
<DynamicRadioListDemo />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line no-unused-vars
|
|
38
|
-
const DynamicRadioListDemo = () => {
|
|
39
|
-
// Available color choices with their selection state
|
|
40
|
-
const [colorChoices, setColorChoices] = useState([
|
|
41
|
-
{ id: 1, color: "red", selected: true },
|
|
42
|
-
{ id: 2, color: "blue", selected: false },
|
|
43
|
-
{ id: 3, color: "green", selected: false },
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
// Derived state: currently selected color in data state
|
|
47
|
-
const selectedColor =
|
|
48
|
-
colorChoices.find((choice) => choice.selected)?.color || null;
|
|
49
|
-
|
|
50
|
-
// UI FORM STATE - This represents the current form state (may differ from data state)
|
|
51
|
-
const [uiSelectedColor, setUiSelectedColor] = useState(selectedColor);
|
|
52
|
-
|
|
53
|
-
// Next ID for new colors
|
|
54
|
-
const [nextId, setNextId] = useState(4);
|
|
55
|
-
|
|
56
|
-
// Form submission feedback
|
|
57
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
58
|
-
const [submitMessage, setSubmitMessage] = useState("");
|
|
59
|
-
const [submitError, setSubmitError] = useState("");
|
|
60
|
-
const [forceError, setForceError] = useState(false);
|
|
61
|
-
|
|
62
|
-
// Random colors pool
|
|
63
|
-
const randomColors = [
|
|
64
|
-
"purple",
|
|
65
|
-
"orange",
|
|
66
|
-
"yellow",
|
|
67
|
-
"pink",
|
|
68
|
-
"cyan",
|
|
69
|
-
"magenta",
|
|
70
|
-
"lime",
|
|
71
|
-
"indigo",
|
|
72
|
-
"coral",
|
|
73
|
-
"teal",
|
|
74
|
-
"gold",
|
|
75
|
-
"silver",
|
|
76
|
-
"navy",
|
|
77
|
-
"maroon",
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
// Action that simulates submitting form data (takes 1s)
|
|
81
|
-
const submitForm = async ({ color }) => {
|
|
82
|
-
setIsSubmitting(true);
|
|
83
|
-
setSubmitError("");
|
|
84
|
-
setSubmitMessage(`Syncing color: ${color || "none"}...`);
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
console.log("Submitting form data:", color);
|
|
88
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
89
|
-
|
|
90
|
-
// Simulate error if checkbox is checked
|
|
91
|
-
if (forceError) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
"Simulated server error: Failed to update color preference",
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Update the data state to match the form submission
|
|
98
|
-
setColorChoices((prev) =>
|
|
99
|
-
prev.map((choice) => ({
|
|
100
|
-
...choice,
|
|
101
|
-
selected: choice.color === color,
|
|
102
|
-
})),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
setSubmitMessage(`✅ Successfully synced: ${color || "none"}`);
|
|
106
|
-
console.log("Data state updated from form:", color);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
setSubmitError(error.message);
|
|
109
|
-
setSubmitMessage("");
|
|
110
|
-
} finally {
|
|
111
|
-
setIsSubmitting(false);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// Add a new color to the data state
|
|
116
|
-
const addColorToState = (color) => {
|
|
117
|
-
setColorChoices((prev) => [
|
|
118
|
-
...prev,
|
|
119
|
-
{ id: nextId, color, selected: false },
|
|
120
|
-
]);
|
|
121
|
-
setNextId((prev) => prev + 1);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// Remove a color from the data state
|
|
125
|
-
const removeColorFromState = (colorId) => {
|
|
126
|
-
setColorChoices((prev) =>
|
|
127
|
-
prev.filter((choice) => choice.id !== colorId),
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Select a color in the data state (radio behavior - only one selected)
|
|
132
|
-
const selectColorInState = (colorId) => {
|
|
133
|
-
setColorChoices((prev) =>
|
|
134
|
-
prev.map((choice) => ({
|
|
135
|
-
...choice,
|
|
136
|
-
selected: choice.id === colorId,
|
|
137
|
-
})),
|
|
138
|
-
);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// Clear selection in the data state
|
|
142
|
-
const clearSelectionInState = () => {
|
|
143
|
-
setColorChoices((prev) =>
|
|
144
|
-
prev.map((choice) => ({
|
|
145
|
-
...choice,
|
|
146
|
-
selected: false,
|
|
147
|
-
})),
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Get the color that reset would sync to
|
|
152
|
-
const getResetColor = () => {
|
|
153
|
-
return colorChoices.find((choice) => choice.selected)?.color || null;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// Add a random color choice to the data state
|
|
157
|
-
const addRandomColor = () => {
|
|
158
|
-
const availableColors = randomColors.filter(
|
|
159
|
-
(color) => !colorChoices.some((choice) => choice.color === color),
|
|
160
|
-
);
|
|
161
|
-
if (availableColors.length > 0) {
|
|
162
|
-
const randomColor =
|
|
163
|
-
availableColors[
|
|
164
|
-
Math.floor(Math.random() * availableColors.length)
|
|
165
|
-
];
|
|
166
|
-
addColorToState(randomColor);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<div style="border: 2px solid #ddd; padding: 20px; border-radius: 8px; background: #f9f9f9;">
|
|
172
|
-
<h2>State ↔ UI Form Demo (Radio Selection)</h2>
|
|
173
|
-
|
|
174
|
-
<div style="display: flex; gap: 20px; margin: 20px 0;">
|
|
175
|
-
{/* DATA STATE SECTION */}
|
|
176
|
-
<div style="flex: 1; padding: 15px; background: #fff; border-radius: 6px; border: 1px solid #ccc;">
|
|
177
|
-
<h3 style="margin: 0 0 15px 0; color: #2196F3;">
|
|
178
|
-
🗄️ Data State
|
|
179
|
-
</h3>
|
|
180
|
-
<p style="margin: 0 0 15px 0; font-size: 14px; color: #666;">
|
|
181
|
-
Direct manipulation of the data source (single selection)
|
|
182
|
-
</p>
|
|
183
|
-
|
|
184
|
-
<div style="margin-bottom: 15px;">
|
|
185
|
-
<button
|
|
186
|
-
onClick={addRandomColor}
|
|
187
|
-
style="padding: 6px 12px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; margin-right: 8px;"
|
|
188
|
-
>
|
|
189
|
-
+ Add Random Color
|
|
190
|
-
</button>
|
|
191
|
-
<button
|
|
192
|
-
onClick={clearSelectionInState}
|
|
193
|
-
style="padding: 6px 12px; background: #ff9800; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px;"
|
|
194
|
-
>
|
|
195
|
-
Clear Selection
|
|
196
|
-
</button>
|
|
197
|
-
</div>
|
|
198
|
-
|
|
199
|
-
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
200
|
-
{colorChoices.map(({ id, color, selected }) => (
|
|
201
|
-
<div
|
|
202
|
-
key={id}
|
|
203
|
-
style={{
|
|
204
|
-
display: "flex",
|
|
205
|
-
alignItems: "center",
|
|
206
|
-
gap: "8px",
|
|
207
|
-
padding: "6px",
|
|
208
|
-
border: "1px solid #eee",
|
|
209
|
-
borderRadius: "3px",
|
|
210
|
-
background: selected ? "#e8f5e8" : "#fafafa",
|
|
211
|
-
borderColor: selected ? "#4CAF50" : "#eee",
|
|
212
|
-
}}
|
|
213
|
-
>
|
|
214
|
-
<span style="flex: 1; font-size: 14px;">
|
|
215
|
-
{color.charAt(0).toUpperCase() + color.slice(1)}
|
|
216
|
-
</span>
|
|
217
|
-
|
|
218
|
-
<button
|
|
219
|
-
onClick={() => selectColorInState(id)}
|
|
220
|
-
style={{
|
|
221
|
-
padding: "4px 8px",
|
|
222
|
-
fontSize: "11px",
|
|
223
|
-
background: selected ? "#4CAF50" : "#2196F3",
|
|
224
|
-
color: "white",
|
|
225
|
-
border: "none",
|
|
226
|
-
borderRadius: "3px",
|
|
227
|
-
cursor: "pointer",
|
|
228
|
-
minWidth: "60px",
|
|
229
|
-
}}
|
|
230
|
-
>
|
|
231
|
-
{selected ? "Selected" : "Select"}
|
|
232
|
-
</button>
|
|
233
|
-
|
|
234
|
-
<button
|
|
235
|
-
onClick={() => removeColorFromState(id)}
|
|
236
|
-
style="padding: 4px 6px; background: #f44336; color: white; border: none; border-radius: 3px; cursor: pointer; font-size: 11px;"
|
|
237
|
-
title="Remove this color"
|
|
238
|
-
>
|
|
239
|
-
🗑
|
|
240
|
-
</button>
|
|
241
|
-
</div>
|
|
242
|
-
))}
|
|
243
|
-
</div>
|
|
244
|
-
</div>
|
|
245
|
-
|
|
246
|
-
{/* UI FORM SECTION */}
|
|
247
|
-
<div style="flex: 1; padding: 15px; background: #fff; border-radius: 6px; border: 1px solid #ccc;">
|
|
248
|
-
<h3 style="margin: 0 0 15px 0; color: #FF9800;">📝 UI Form</h3>
|
|
249
|
-
<p style="margin: 0 0 15px 0; font-size: 14px; color: #666;">
|
|
250
|
-
Radio button interface for user interaction
|
|
251
|
-
</p>
|
|
252
|
-
|
|
253
|
-
<Form action={submitForm}>
|
|
254
|
-
<fieldset style="border: 1px solid #ddd; padding: 10px; border-radius: 4px;">
|
|
255
|
-
<legend>Select Favorite Color:</legend>
|
|
256
|
-
<RadioList
|
|
257
|
-
name="color"
|
|
258
|
-
onUIStateChange={(color) => {
|
|
259
|
-
setUiSelectedColor(color);
|
|
260
|
-
}}
|
|
261
|
-
>
|
|
262
|
-
{colorChoices.map(({ id, color }) => (
|
|
263
|
-
<Label key={id} style="display: block; margin: 5px 0;">
|
|
264
|
-
{color.charAt(0).toUpperCase() + color.slice(1)}
|
|
265
|
-
<Radio
|
|
266
|
-
value={color}
|
|
267
|
-
checked={selectedColor === color}
|
|
268
|
-
/>
|
|
269
|
-
</Label>
|
|
270
|
-
))}
|
|
271
|
-
</RadioList>
|
|
272
|
-
</fieldset>
|
|
273
|
-
|
|
274
|
-
{/* Error simulation checkbox */}
|
|
275
|
-
<div style="margin: 10px 0; padding: 8px; background: #ffebee; border-radius: 4px; border: 1px solid #ffcdd2;">
|
|
276
|
-
<label style="display: flex; align-items: center; gap: 8px; font-size: 12px; color: #d32f2f;">
|
|
277
|
-
<input
|
|
278
|
-
type="checkbox"
|
|
279
|
-
checked={forceError}
|
|
280
|
-
onChange={(e) => setForceError(e.target.checked)}
|
|
281
|
-
style="margin: 0;"
|
|
282
|
-
/>
|
|
283
|
-
🔧 Force submission error (for testing)
|
|
284
|
-
</label>
|
|
285
|
-
</div>
|
|
286
|
-
|
|
287
|
-
{/* Submission feedback messages */}
|
|
288
|
-
{(isSubmitting || submitMessage || submitError) && (
|
|
289
|
-
<div style="margin: 10px 0; padding: 10px; border-radius: 4px; font-size: 14px;">
|
|
290
|
-
{isSubmitting && (
|
|
291
|
-
<div style="color: #1976d2; background: #e3f2fd; padding: 8px; border-radius: 3px; border-left: 3px solid #1976d2;">
|
|
292
|
-
🔄 {submitMessage}
|
|
293
|
-
</div>
|
|
294
|
-
)}
|
|
295
|
-
{!isSubmitting && submitMessage && (
|
|
296
|
-
<div style="color: #388e3c; background: #e8f5e8; padding: 8px; border-radius: 3px; border-left: 3px solid #388e3c;">
|
|
297
|
-
{submitMessage}
|
|
298
|
-
</div>
|
|
299
|
-
)}
|
|
300
|
-
{submitError && (
|
|
301
|
-
<div style="color: #d32f2f; background: #ffebee; padding: 8px; border-radius: 3px; border-left: 3px solid #d32f2f;">
|
|
302
|
-
❌ {submitError}
|
|
303
|
-
</div>
|
|
304
|
-
)}
|
|
305
|
-
</div>
|
|
306
|
-
)}
|
|
307
|
-
|
|
308
|
-
<div style="margin-top: 15px; display: flex; align-items: flex-start; flex-direction: column; gap: 8px;">
|
|
309
|
-
<Button type="submit" disabled={isSubmitting}>
|
|
310
|
-
{isSubmitting ? "⏳ Submitting..." : "📤 Submit Form"}{" "}
|
|
311
|
-
{!isSubmitting && uiSelectedColor && (
|
|
312
|
-
<span style="font-size: 11px; opacity: 0.7;">
|
|
313
|
-
({uiSelectedColor})
|
|
314
|
-
</span>
|
|
315
|
-
)}
|
|
316
|
-
</Button>
|
|
317
|
-
<Button type="reset">
|
|
318
|
-
🔄 Reset to State{" "}
|
|
319
|
-
{getResetColor() && (
|
|
320
|
-
<span style="font-size: 11px; opacity: 0.7;">
|
|
321
|
-
({getResetColor()})
|
|
322
|
-
</span>
|
|
323
|
-
)}
|
|
324
|
-
</Button>
|
|
325
|
-
</div>
|
|
326
|
-
</Form>
|
|
327
|
-
</div>
|
|
328
|
-
</div>
|
|
329
|
-
|
|
330
|
-
<div style="background: #f0f8ff; padding: 15px; border-radius: 6px; margin: 20px 0; border-left: 4px solid #2196F3;">
|
|
331
|
-
<h4 style="margin: 0 0 10px 0;">How it works:</h4>
|
|
332
|
-
<ul style="margin: 0; padding-left: 20px; font-size: 14px;">
|
|
333
|
-
<li>
|
|
334
|
-
<strong>Data State</strong>: The actual data with direct
|
|
335
|
-
manipulation buttons (single selection only)
|
|
336
|
-
</li>
|
|
337
|
-
<li>
|
|
338
|
-
<strong>UI Form</strong>: Radio button interface that can
|
|
339
|
-
differ from the data state
|
|
340
|
-
</li>
|
|
341
|
-
<li>
|
|
342
|
-
<strong>Submit</strong>: Updates data state to match the form
|
|
343
|
-
selection
|
|
344
|
-
</li>
|
|
345
|
-
<li>
|
|
346
|
-
<strong>Reset</strong>: Syncs form back to current data state
|
|
347
|
-
</li>
|
|
348
|
-
</ul>
|
|
349
|
-
</div>
|
|
350
|
-
</div>
|
|
351
|
-
);
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
render(<App />, document.querySelector("#root"));
|
|
355
|
-
</script>
|
|
356
|
-
</body>
|
|
357
|
-
</html>
|