@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,434 +0,0 @@
|
|
|
1
|
-
import { pickLightOrDark } from "@jsenv/dom";
|
|
2
|
-
import { forwardRef } from "preact/compat";
|
|
3
|
-
import {
|
|
4
|
-
useContext,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
useLayoutEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
} from "preact/hooks";
|
|
9
|
-
|
|
10
|
-
import { useActionStatus } from "../../use_action_status.js";
|
|
11
|
-
import { requestAction } from "../../validation/custom_constraint_validation.js";
|
|
12
|
-
import { useConstraints } from "../../validation/hooks/use_constraints.js";
|
|
13
|
-
import { renderActionableComponent } from "../action_execution/render_actionable_component.jsx";
|
|
14
|
-
import { useActionBoundToOneParam } from "../action_execution/use_action.js";
|
|
15
|
-
import { useExecuteAction } from "../action_execution/use_execute_action.js";
|
|
16
|
-
import { useLayoutStyle } from "../layout/use_layout_style.js";
|
|
17
|
-
import {
|
|
18
|
-
LoadableInlineElement,
|
|
19
|
-
LoaderBackground,
|
|
20
|
-
} from "../loader/loader_background.jsx";
|
|
21
|
-
import { withPropsStyle } from "../props_composition/with_props_style.js";
|
|
22
|
-
import { useAutoFocus } from "../use_auto_focus.js";
|
|
23
|
-
import { initCustomField } from "./custom_field.js";
|
|
24
|
-
import {
|
|
25
|
-
ReportDisabledOnLabelContext,
|
|
26
|
-
ReportReadOnlyOnLabelContext,
|
|
27
|
-
} from "./label.jsx";
|
|
28
|
-
import { useActionEvents } from "./use_action_events.js";
|
|
29
|
-
import {
|
|
30
|
-
DisabledContext,
|
|
31
|
-
FieldNameContext,
|
|
32
|
-
LoadingContext,
|
|
33
|
-
LoadingElementContext,
|
|
34
|
-
ReadOnlyContext,
|
|
35
|
-
RequiredContext,
|
|
36
|
-
UIStateContext,
|
|
37
|
-
UIStateControllerContext,
|
|
38
|
-
useUIState,
|
|
39
|
-
useUIStateController,
|
|
40
|
-
} from "./use_ui_state_controller.js";
|
|
41
|
-
|
|
42
|
-
import.meta.css = /* css */ `
|
|
43
|
-
@layer navi {
|
|
44
|
-
:root {
|
|
45
|
-
--navi-checkmark-color-light: white;
|
|
46
|
-
--navi-checkmark-color-dark: rgb(55, 55, 55);
|
|
47
|
-
--navi-checkmark-color: var(--navi-checkmark-light-color);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.navi_checkbox {
|
|
51
|
-
position: relative;
|
|
52
|
-
display: inline-flex;
|
|
53
|
-
box-sizing: content-box;
|
|
54
|
-
|
|
55
|
-
--outline-offset: 1px;
|
|
56
|
-
--outline-width: 2px;
|
|
57
|
-
--border-width: 1px;
|
|
58
|
-
--border-radius: 2px;
|
|
59
|
-
--width: 13px;
|
|
60
|
-
--height: 13px;
|
|
61
|
-
|
|
62
|
-
--outline-color: light-dark(#4476ff, #3b82f6);
|
|
63
|
-
--border-color: light-dark(#767676, #8e8e93);
|
|
64
|
-
--background-color: white;
|
|
65
|
-
--accent-color: light-dark(#4476ff, #3b82f6);
|
|
66
|
-
/* --color: currentColor; */
|
|
67
|
-
--checkmark-color: var(--navi-checkmark-color);
|
|
68
|
-
|
|
69
|
-
--border-color-readonly: color-mix(
|
|
70
|
-
in srgb,
|
|
71
|
-
var(--border-color) 30%,
|
|
72
|
-
white
|
|
73
|
-
);
|
|
74
|
-
--border-color-disabled: var(--border-color-readonly);
|
|
75
|
-
--border-color-hover: color-mix(in srgb, var(--border-color) 70%, black);
|
|
76
|
-
--border-color-checked-readonly: #d3d3d3;
|
|
77
|
-
--border-color-checked-disabled: #d3d3d3;
|
|
78
|
-
--background-color-checked-readonly: var(
|
|
79
|
-
--navi-background-color-readonly
|
|
80
|
-
);
|
|
81
|
-
--background-color-checked-disabled: var(
|
|
82
|
-
--navi-background-color-disabled
|
|
83
|
-
);
|
|
84
|
-
--checkmark-color-readonly: var(--navi-color-readonly);
|
|
85
|
-
--checkmark-color-disabled: var(--navi-color-disabled);
|
|
86
|
-
}
|
|
87
|
-
.navi_checkbox input {
|
|
88
|
-
position: absolute;
|
|
89
|
-
inset: 0;
|
|
90
|
-
margin: 0;
|
|
91
|
-
padding: 0;
|
|
92
|
-
border: none;
|
|
93
|
-
opacity: 0;
|
|
94
|
-
cursor: inherit;
|
|
95
|
-
}
|
|
96
|
-
.navi_checkbox_field {
|
|
97
|
-
display: inline-flex;
|
|
98
|
-
box-sizing: border-box;
|
|
99
|
-
width: var(--width);
|
|
100
|
-
height: var(--height);
|
|
101
|
-
margin: 3px 3px 3px 4px;
|
|
102
|
-
background-color: var(--background-color);
|
|
103
|
-
border-width: var(--border-width);
|
|
104
|
-
border-style: solid;
|
|
105
|
-
border-color: var(--border-color);
|
|
106
|
-
border-radius: var(--border-radius);
|
|
107
|
-
outline-width: var(--outline-width);
|
|
108
|
-
|
|
109
|
-
outline-style: none;
|
|
110
|
-
|
|
111
|
-
outline-color: var(--outline-color);
|
|
112
|
-
outline-offset: var(--outline-offset);
|
|
113
|
-
/* color: var(--color); */
|
|
114
|
-
}
|
|
115
|
-
.navi_checkbox_marker {
|
|
116
|
-
width: 100%;
|
|
117
|
-
height: 100%;
|
|
118
|
-
opacity: 0;
|
|
119
|
-
transform: scale(0.5);
|
|
120
|
-
transition: all 0.15s ease;
|
|
121
|
-
pointer-events: none;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/* Focus */
|
|
125
|
-
.navi_checkbox[data-focus-visible] .navi_checkbox_field {
|
|
126
|
-
outline-style: solid;
|
|
127
|
-
}
|
|
128
|
-
/* Hover */
|
|
129
|
-
.navi_checkbox[data-hover] .navi_checkbox_field {
|
|
130
|
-
--border-color: var(--border-color-hover);
|
|
131
|
-
}
|
|
132
|
-
/* Checked */
|
|
133
|
-
.navi_checkbox[data-checked] .navi_checkbox_field {
|
|
134
|
-
--background-color: var(--accent-color);
|
|
135
|
-
--border-color: var(--accent-color);
|
|
136
|
-
}
|
|
137
|
-
.navi_checkbox[data-checked] .navi_checkbox_marker {
|
|
138
|
-
opacity: 1;
|
|
139
|
-
stroke: var(--checkmark-color);
|
|
140
|
-
transform: scale(1);
|
|
141
|
-
}
|
|
142
|
-
/* Readonly */
|
|
143
|
-
.navi_checkbox[data-readonly] .navi_checkbox_field,
|
|
144
|
-
.navi_checkbox[data-readonly][data-hover] .navi_checkbox_field {
|
|
145
|
-
--border-color: var(--border-color-readonly);
|
|
146
|
-
--background-color: var(--background-color-readonly);
|
|
147
|
-
}
|
|
148
|
-
.navi_checkbox[data-checked][data-readonly] .navi_checkbox_field {
|
|
149
|
-
--background-color: var(--background-color-checked-readonly);
|
|
150
|
-
--border-color: var(--border-color-checked-readonly);
|
|
151
|
-
}
|
|
152
|
-
.navi_checkbox[data-checked][data-readonly] .navi_checkbox_marker {
|
|
153
|
-
stroke: var(--checkmark-color-readonly);
|
|
154
|
-
}
|
|
155
|
-
/* Disabled */
|
|
156
|
-
.navi_checkbox[data-disabled] .navi_checkbox_field {
|
|
157
|
-
--background-color: var(--background-color-disabled);
|
|
158
|
-
--border-color: var(--border-color-disabled);
|
|
159
|
-
}
|
|
160
|
-
.navi_checkbox[data-checked][data-disabled] .navi_checkbox_field {
|
|
161
|
-
--border-color: var(--border-color-checked-disabled);
|
|
162
|
-
--background-color: var(--background-color-checked-disabled);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.navi_checkbox[data-checked][data-disabled] .navi_checkbox_marker {
|
|
166
|
-
stroke: var(--checkmark-color-disabled);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
`;
|
|
170
|
-
|
|
171
|
-
export const InputCheckbox = forwardRef((props, ref) => {
|
|
172
|
-
const { value = "on" } = props;
|
|
173
|
-
const uiStateController = useUIStateController(props, "checkbox", {
|
|
174
|
-
statePropName: "checked",
|
|
175
|
-
defaultStatePropName: "defaultChecked",
|
|
176
|
-
fallbackState: false,
|
|
177
|
-
getStateFromProp: (checked) => (checked ? value : undefined),
|
|
178
|
-
getPropFromState: Boolean,
|
|
179
|
-
});
|
|
180
|
-
const uiState = useUIState(uiStateController);
|
|
181
|
-
|
|
182
|
-
const checkbox = renderActionableComponent(props, ref, {
|
|
183
|
-
Basic: InputCheckboxBasic,
|
|
184
|
-
WithAction: InputCheckboxWithAction,
|
|
185
|
-
InsideForm: InputCheckboxInsideForm,
|
|
186
|
-
});
|
|
187
|
-
return (
|
|
188
|
-
<UIStateControllerContext.Provider value={uiStateController}>
|
|
189
|
-
<UIStateContext.Provider value={uiState}>
|
|
190
|
-
{checkbox}
|
|
191
|
-
</UIStateContext.Provider>
|
|
192
|
-
</UIStateControllerContext.Provider>
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
const InputCheckboxBasic = forwardRef((props, ref) => {
|
|
197
|
-
const contextFieldName = useContext(FieldNameContext);
|
|
198
|
-
const contextReadOnly = useContext(ReadOnlyContext);
|
|
199
|
-
const contextDisabled = useContext(DisabledContext);
|
|
200
|
-
const contextRequired = useContext(RequiredContext);
|
|
201
|
-
const contextLoading = useContext(LoadingContext);
|
|
202
|
-
const loadingElement = useContext(LoadingElementContext);
|
|
203
|
-
const uiStateController = useContext(UIStateControllerContext);
|
|
204
|
-
const uiState = useContext(UIStateContext);
|
|
205
|
-
const reportReadOnlyOnLabel = useContext(ReportReadOnlyOnLabelContext);
|
|
206
|
-
const reportDisabledOnLabel = useContext(ReportDisabledOnLabelContext);
|
|
207
|
-
const {
|
|
208
|
-
name,
|
|
209
|
-
readOnly,
|
|
210
|
-
disabled,
|
|
211
|
-
required,
|
|
212
|
-
loading,
|
|
213
|
-
|
|
214
|
-
autoFocus,
|
|
215
|
-
constraints = [],
|
|
216
|
-
appeareance = "navi", // "navi" or "default"
|
|
217
|
-
accentColor,
|
|
218
|
-
onClick,
|
|
219
|
-
onInput,
|
|
220
|
-
style,
|
|
221
|
-
...rest
|
|
222
|
-
} = props;
|
|
223
|
-
const innerRef = useRef(null);
|
|
224
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
225
|
-
|
|
226
|
-
const innerName = name || contextFieldName;
|
|
227
|
-
const innerDisabled = disabled || contextDisabled;
|
|
228
|
-
const innerRequired = required || contextRequired;
|
|
229
|
-
const innerLoading =
|
|
230
|
-
loading || (contextLoading && loadingElement === innerRef.current);
|
|
231
|
-
const innerReadOnly =
|
|
232
|
-
readOnly || contextReadOnly || innerLoading || uiStateController.readOnly;
|
|
233
|
-
reportReadOnlyOnLabel?.(innerReadOnly);
|
|
234
|
-
reportDisabledOnLabel?.(innerDisabled);
|
|
235
|
-
useAutoFocus(innerRef, autoFocus);
|
|
236
|
-
useConstraints(innerRef, constraints);
|
|
237
|
-
|
|
238
|
-
const checked = Boolean(uiState);
|
|
239
|
-
const actionName = rest["data-action"];
|
|
240
|
-
if (actionName) {
|
|
241
|
-
delete rest["data-action"];
|
|
242
|
-
}
|
|
243
|
-
const inputCheckbox = (
|
|
244
|
-
<input
|
|
245
|
-
{...rest}
|
|
246
|
-
ref={innerRef}
|
|
247
|
-
type="checkbox"
|
|
248
|
-
style={appeareance === "default" ? style : undefined}
|
|
249
|
-
name={innerName}
|
|
250
|
-
checked={checked}
|
|
251
|
-
readOnly={innerReadOnly}
|
|
252
|
-
disabled={innerDisabled}
|
|
253
|
-
required={innerRequired}
|
|
254
|
-
data-callout-arrow-x="center"
|
|
255
|
-
onClick={(e) => {
|
|
256
|
-
if (innerReadOnly) {
|
|
257
|
-
e.preventDefault();
|
|
258
|
-
}
|
|
259
|
-
onClick?.(e);
|
|
260
|
-
}}
|
|
261
|
-
onInput={(e) => {
|
|
262
|
-
const checkbox = e.target;
|
|
263
|
-
const checkboxIsChecked = checkbox.checked;
|
|
264
|
-
uiStateController.setUIState(checkboxIsChecked, e);
|
|
265
|
-
onInput?.(e);
|
|
266
|
-
}}
|
|
267
|
-
// eslint-disable-next-line react/no-unknown-property
|
|
268
|
-
onresetuistate={(e) => {
|
|
269
|
-
uiStateController.resetUIState(e);
|
|
270
|
-
}}
|
|
271
|
-
// eslint-disable-next-line react/no-unknown-property
|
|
272
|
-
onsetuistate={(e) => {
|
|
273
|
-
uiStateController.setUIState(e.detail.value, e);
|
|
274
|
-
}}
|
|
275
|
-
/>
|
|
276
|
-
);
|
|
277
|
-
const loaderProps = {
|
|
278
|
-
loading: innerLoading,
|
|
279
|
-
inset: -1,
|
|
280
|
-
style: {
|
|
281
|
-
"--accent-color": accentColor || "light-dark(#355fcc, #4476ff)",
|
|
282
|
-
},
|
|
283
|
-
color: "var(--accent-color)",
|
|
284
|
-
};
|
|
285
|
-
if (appeareance === "navi") {
|
|
286
|
-
return (
|
|
287
|
-
<NaviCheckbox
|
|
288
|
-
data-action={actionName}
|
|
289
|
-
inputRef={innerRef}
|
|
290
|
-
accentColor={accentColor}
|
|
291
|
-
readOnly={readOnly}
|
|
292
|
-
disabled={innerDisabled}
|
|
293
|
-
style={style}
|
|
294
|
-
>
|
|
295
|
-
<LoaderBackground
|
|
296
|
-
{...loaderProps}
|
|
297
|
-
targetSelector=".navi_checkbox_field"
|
|
298
|
-
>
|
|
299
|
-
{inputCheckbox}
|
|
300
|
-
</LoaderBackground>
|
|
301
|
-
</NaviCheckbox>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return (
|
|
306
|
-
<LoadableInlineElement {...loaderProps} data-action={actionName}>
|
|
307
|
-
{inputCheckbox}
|
|
308
|
-
</LoadableInlineElement>
|
|
309
|
-
);
|
|
310
|
-
});
|
|
311
|
-
const NaviCheckbox = ({
|
|
312
|
-
accentColor,
|
|
313
|
-
readOnly,
|
|
314
|
-
disabled,
|
|
315
|
-
inputRef,
|
|
316
|
-
style,
|
|
317
|
-
children,
|
|
318
|
-
...rest
|
|
319
|
-
}) => {
|
|
320
|
-
const ref = useRef();
|
|
321
|
-
useLayoutEffect(() => {
|
|
322
|
-
const naviCheckbox = ref.current;
|
|
323
|
-
const colorPicked = pickLightOrDark(
|
|
324
|
-
naviCheckbox,
|
|
325
|
-
"var(--accent-color)",
|
|
326
|
-
"var(--navi-checkmark-color-light)",
|
|
327
|
-
"var(--navi-checkmark-color-dark)",
|
|
328
|
-
);
|
|
329
|
-
naviCheckbox.style.setProperty("--checkmark-color", colorPicked);
|
|
330
|
-
}, [accentColor]);
|
|
331
|
-
|
|
332
|
-
useLayoutEffect(() => {
|
|
333
|
-
return initCustomField(ref.current, inputRef.current);
|
|
334
|
-
}, []);
|
|
335
|
-
|
|
336
|
-
const { all } = useLayoutStyle(rest);
|
|
337
|
-
const innerStyle = withPropsStyle(
|
|
338
|
-
{
|
|
339
|
-
...all,
|
|
340
|
-
...(accentColor ? { "--accent-color": accentColor } : {}),
|
|
341
|
-
},
|
|
342
|
-
style,
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
return (
|
|
346
|
-
<div
|
|
347
|
-
{...rest}
|
|
348
|
-
ref={ref}
|
|
349
|
-
className="navi_checkbox"
|
|
350
|
-
style={innerStyle}
|
|
351
|
-
data-readonly={readOnly ? "" : undefined}
|
|
352
|
-
data-disabled={disabled ? "" : undefined}
|
|
353
|
-
>
|
|
354
|
-
{children}
|
|
355
|
-
<div className="navi_checkbox_field">
|
|
356
|
-
<svg
|
|
357
|
-
viewBox="0 0 12 12"
|
|
358
|
-
aria-hidden="true"
|
|
359
|
-
className="navi_checkbox_marker"
|
|
360
|
-
>
|
|
361
|
-
<path d="M10.5 2L4.5 9L1.5 5.5" fill="none" strokeWidth="2" />
|
|
362
|
-
</svg>
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
);
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const InputCheckboxWithAction = forwardRef((props, ref) => {
|
|
369
|
-
const uiStateController = useContext(UIStateControllerContext);
|
|
370
|
-
const uiState = useContext(UIStateContext);
|
|
371
|
-
const {
|
|
372
|
-
action,
|
|
373
|
-
onCancel,
|
|
374
|
-
onChange,
|
|
375
|
-
actionErrorEffect,
|
|
376
|
-
onActionPrevented,
|
|
377
|
-
onActionStart,
|
|
378
|
-
onActionAbort,
|
|
379
|
-
onActionError,
|
|
380
|
-
onActionEnd,
|
|
381
|
-
loading,
|
|
382
|
-
...rest
|
|
383
|
-
} = props;
|
|
384
|
-
const innerRef = useRef(null);
|
|
385
|
-
useImperativeHandle(ref, () => innerRef.current);
|
|
386
|
-
const [actionBoundToUIState] = useActionBoundToOneParam(action, uiState);
|
|
387
|
-
const { loading: actionLoading } = useActionStatus(actionBoundToUIState);
|
|
388
|
-
const executeAction = useExecuteAction(innerRef, {
|
|
389
|
-
errorEffect: actionErrorEffect,
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
// In this situation updating the ui state === calling associated action
|
|
393
|
-
// so cance/abort/error have to revert the ui state to the one before user interaction
|
|
394
|
-
// to show back the real state of the checkbox (not the one user tried to set)
|
|
395
|
-
useActionEvents(innerRef, {
|
|
396
|
-
onCancel: (e, reason) => {
|
|
397
|
-
if (reason === "blur_invalid") {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
uiStateController.resetUIState(e);
|
|
401
|
-
onCancel?.(e, reason);
|
|
402
|
-
},
|
|
403
|
-
onPrevented: onActionPrevented,
|
|
404
|
-
onAction: executeAction,
|
|
405
|
-
onStart: onActionStart,
|
|
406
|
-
onAbort: (e) => {
|
|
407
|
-
uiStateController.resetUIState(e);
|
|
408
|
-
onActionAbort?.(e);
|
|
409
|
-
},
|
|
410
|
-
onError: (e) => {
|
|
411
|
-
uiStateController.resetUIState(e);
|
|
412
|
-
onActionError?.(e);
|
|
413
|
-
},
|
|
414
|
-
onEnd: (e) => {
|
|
415
|
-
onActionEnd?.(e);
|
|
416
|
-
},
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
return (
|
|
420
|
-
<InputCheckboxBasic
|
|
421
|
-
data-action={actionBoundToUIState.name}
|
|
422
|
-
{...rest}
|
|
423
|
-
ref={innerRef}
|
|
424
|
-
loading={loading || actionLoading}
|
|
425
|
-
onChange={(e) => {
|
|
426
|
-
requestAction(e.target, actionBoundToUIState, {
|
|
427
|
-
event: e,
|
|
428
|
-
});
|
|
429
|
-
onChange?.(e);
|
|
430
|
-
}}
|
|
431
|
-
/>
|
|
432
|
-
);
|
|
433
|
-
});
|
|
434
|
-
const InputCheckboxInsideForm = InputCheckboxBasic;
|