@effindomv2/fui-as 0.1.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/LICENSE.md +7 -0
- package/browser/src/common-harness/host-imports.ts +430 -0
- package/browser/src/common-harness/interop.ts +39 -0
- package/browser/src/common-harness/managed-harness-bitmap-host.ts +92 -0
- package/browser/src/common-harness/managed-harness-fetch-host.ts +201 -0
- package/browser/src/common-harness/managed-harness-file-host.ts +1101 -0
- package/browser/src/common-harness/managed-harness-file-payloads.ts +143 -0
- package/browser/src/common-harness/managed-harness-file-types.ts +106 -0
- package/browser/src/common-harness/managed-harness-session.ts +15 -0
- package/browser/src/common-harness/managed-harness.ts +1323 -0
- package/browser/src/common-harness/managed-history.ts +168 -0
- package/browser/src/common-harness/persisted-restore-policy.ts +50 -0
- package/browser/src/common-harness/persisted-ui-state-controller.ts +309 -0
- package/browser/src/common-harness/text-session-bridge.ts +452 -0
- package/browser/src/common-harness/types.ts +205 -0
- package/browser/src/common-harness/ui-chrome.ts +191 -0
- package/browser/src/common-harness/ui-imports.ts +529 -0
- package/browser/src/common-harness/wasm-module-cache.ts +47 -0
- package/browser/src/common-harness.ts +27 -0
- package/browser/src/file-processing-worker.ts +89 -0
- package/browser/src/host-events.ts +97 -0
- package/browser/src/host-services.ts +203 -0
- package/browser/src/index.ts +62 -0
- package/browser/src/persisted-ui-state.ts +206 -0
- package/browser/src/routed-harness.ts +198 -0
- package/browser/src/worker-bootstrap.ts +483 -0
- package/browser/src/worker-manager.ts +230 -0
- package/browser/src/worker-types.ts +50 -0
- package/package.json +89 -0
- package/scripts/build-demo-as.sh +91 -0
- package/scripts/build.sh +325 -0
- package/scripts/generate-host-events.ts +175 -0
- package/scripts/generate-host-services.ts +157 -0
- package/src/Fui.ts +205 -0
- package/src/FuiExports.ts +55 -0
- package/src/FuiPrimitives.ts +15 -0
- package/src/FuiWorker.ts +3 -0
- package/src/FuiWorkerExports.ts +6 -0
- package/src/bindings/ui.ts +531 -0
- package/src/color.ts +86 -0
- package/src/controls/AntiSelectionArea.ts +23 -0
- package/src/controls/Button.ts +750 -0
- package/src/controls/Checkbox.ts +181 -0
- package/src/controls/ContextMenu.ts +885 -0
- package/src/controls/ControlTemplateSet.ts +37 -0
- package/src/controls/Dialog.ts +355 -0
- package/src/controls/Dropdown.ts +856 -0
- package/src/controls/Form.ts +110 -0
- package/src/controls/NavLink.ts +211 -0
- package/src/controls/Popup.ts +129 -0
- package/src/controls/ProgressBar.ts +180 -0
- package/src/controls/RadioButton.ts +135 -0
- package/src/controls/RadioGroup.ts +244 -0
- package/src/controls/SelectionArea.ts +75 -0
- package/src/controls/Slider.ts +471 -0
- package/src/controls/Switch.ts +132 -0
- package/src/controls/TextArea.ts +20 -0
- package/src/controls/TextInput.ts +7 -0
- package/src/controls/index.ts +18 -0
- package/src/controls/internal/ButtonPresenter.ts +95 -0
- package/src/controls/internal/CheckboxIndicatorPresenter.ts +93 -0
- package/src/controls/internal/DropdownChevronPresenter.ts +67 -0
- package/src/controls/internal/DropdownFieldPresenter.ts +110 -0
- package/src/controls/internal/DropdownOptionRowPresenter.ts +82 -0
- package/src/controls/internal/PopupPresenter.ts +198 -0
- package/src/controls/internal/PressableIndicatorPresenter.ts +32 -0
- package/src/controls/internal/PressableLabeledControl.ts +221 -0
- package/src/controls/internal/RadioIndicatorPresenter.ts +73 -0
- package/src/controls/internal/SliderPresenter.ts +157 -0
- package/src/controls/internal/SwitchIndicatorPresenter.ts +72 -0
- package/src/controls/internal/TextInputCore.ts +695 -0
- package/src/controls/internal/TextInputPresenter.ts +72 -0
- package/src/controls/templating.ts +54 -0
- package/src/core/Action.ts +94 -0
- package/src/core/Actions.ts +37 -0
- package/src/core/Animation.ts +412 -0
- package/src/core/Application.ts +328 -0
- package/src/core/Assets.ts +264 -0
- package/src/core/AttachedProperties.ts +32 -0
- package/src/core/Bitmap.ts +70 -0
- package/src/core/BoundCallback.ts +104 -0
- package/src/core/Callbacks.ts +17 -0
- package/src/core/ContextMenuManager.ts +466 -0
- package/src/core/DebugApi.ts +30 -0
- package/src/core/Disposable.ts +10 -0
- package/src/core/DragDropManager.ts +179 -0
- package/src/core/DragGesture.ts +184 -0
- package/src/core/DynamicAssetIds.ts +24 -0
- package/src/core/Errors.ts +48 -0
- package/src/core/EventRouter.ts +408 -0
- package/src/core/ExternalDropManager.ts +122 -0
- package/src/core/Fetch.ts +264 -0
- package/src/core/FetchFfi.ts +15 -0
- package/src/core/File.ts +1002 -0
- package/src/core/FocusAdornerManager.ts +263 -0
- package/src/core/FocusVisibility.ts +36 -0
- package/src/core/FrameScheduler.ts +28 -0
- package/src/core/KeyboardScroll.ts +161 -0
- package/src/core/KeyboardScrollTracker.ts +386 -0
- package/src/core/Logger.ts +80 -0
- package/src/core/Navigation.ts +13 -0
- package/src/core/Node.ts +1708 -0
- package/src/core/PersistedState.ts +102 -0
- package/src/core/PersistedUiState.ts +142 -0
- package/src/core/Platform.ts +219 -0
- package/src/core/Signal.ts +89 -0
- package/src/core/Theme.ts +365 -0
- package/src/core/Timers.ts +129 -0
- package/src/core/ToolTip.ts +122 -0
- package/src/core/ToolTipManager.ts +459 -0
- package/src/core/Transitions.ts +34 -0
- package/src/core/Typography.ts +204 -0
- package/src/core/Worker.ts +196 -0
- package/src/core/bind.ts +37 -0
- package/src/core/event_exports.ts +596 -0
- package/src/core/ffi.ts +728 -0
- package/src/host-services/runtime.ts +25 -0
- package/src/nodes/FlexBox.ts +789 -0
- package/src/nodes/GradientStop.ts +9 -0
- package/src/nodes/Grid.ts +183 -0
- package/src/nodes/Image.ts +189 -0
- package/src/nodes/Portal.ts +14 -0
- package/src/nodes/RichText.ts +312 -0
- package/src/nodes/ScrollBar.ts +570 -0
- package/src/nodes/ScrollBox.ts +415 -0
- package/src/nodes/ScrollState.ts +10 -0
- package/src/nodes/ScrollView.ts +511 -0
- package/src/nodes/Svg.ts +142 -0
- package/src/nodes/Text.ts +145 -0
- package/src/nodes/TextCore.ts +558 -0
- package/src/nodes/VirtualList.ts +431 -0
- package/src/nodes/helpers.ts +25 -0
- package/src/nodes/index.ts +14 -0
- package/src/tsconfig.json +7 -0
- package/src/worker/Worker.ts +169 -0
- package/src/worker/WorkerJob.ts +65 -0
- package/src/worker/ffi.ts +23 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Callback1, Handler1 } from "../core/BoundCallback";
|
|
2
|
+
import { SemanticCheckedState, SemanticRole } from "../core/ffi";
|
|
3
|
+
import { PersistedInt32Codec, PersistedValueState } from "../core/PersistedState";
|
|
4
|
+
import { bind1 } from "../core/bind";
|
|
5
|
+
import { getControlTemplates } from "./ControlTemplateSet";
|
|
6
|
+
import { activeTheme } from "../core/Theme";
|
|
7
|
+
import { PressableLabeledControl } from "./internal/PressableLabeledControl";
|
|
8
|
+
import {
|
|
9
|
+
CheckboxIndicatorPresenter,
|
|
10
|
+
CheckboxIndicatorTemplate,
|
|
11
|
+
CheckboxIndicatorVisualState,
|
|
12
|
+
defaultCheckboxIndicatorTemplate,
|
|
13
|
+
} from "./internal/CheckboxIndicatorPresenter";
|
|
14
|
+
const CHECKBOX_PERSISTED_CODEC = new PersistedInt32Codec();
|
|
15
|
+
|
|
16
|
+
function clampPersistedCheckedState(value: i32): SemanticCheckedState {
|
|
17
|
+
if (value == <i32>SemanticCheckedState.True) {
|
|
18
|
+
return SemanticCheckedState.True;
|
|
19
|
+
}
|
|
20
|
+
if (value == <i32>SemanticCheckedState.Mixed) {
|
|
21
|
+
return SemanticCheckedState.Mixed;
|
|
22
|
+
}
|
|
23
|
+
return SemanticCheckedState.False;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class PersistedCheckboxState extends PersistedValueState<Checkbox, i32> {
|
|
27
|
+
constructor() {
|
|
28
|
+
super("checkbox-checked-state", CHECKBOX_PERSISTED_CODEC, 1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected captureValue(node: Checkbox): i32 {
|
|
32
|
+
return <i32>node.checkedState;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected restoreValue(node: Checkbox, value: i32): void {
|
|
36
|
+
node._applyPersistedCheckedState(clampPersistedCheckedState(value));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const CHECKBOX_PERSISTED_STATE = new PersistedCheckboxState();
|
|
41
|
+
|
|
42
|
+
function createIndicatorPresenter(template: CheckboxIndicatorTemplate | null): CheckboxIndicatorPresenter {
|
|
43
|
+
if (template !== null) {
|
|
44
|
+
return template.create();
|
|
45
|
+
}
|
|
46
|
+
const templateSet = getControlTemplates();
|
|
47
|
+
const appTemplate = templateSet !== null ? templateSet.checkboxIndicator : null;
|
|
48
|
+
return (appTemplate === null ? defaultCheckboxIndicatorTemplate : appTemplate).create();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class Checkbox extends PressableLabeledControl {
|
|
52
|
+
private indicatorPresenter: CheckboxIndicatorPresenter;
|
|
53
|
+
private templateOverride: CheckboxIndicatorTemplate | null = null;
|
|
54
|
+
private checkedStateValue: SemanticCheckedState = SemanticCheckedState.False;
|
|
55
|
+
private triStateEnabled: bool = false;
|
|
56
|
+
private changedCallback: ((state: SemanticCheckedState) => void) | null = null;
|
|
57
|
+
private changedBinding: Callback1<SemanticCheckedState> | null = null;
|
|
58
|
+
|
|
59
|
+
constructor(label: string) {
|
|
60
|
+
const indicatorPresenter = createIndicatorPresenter(null);
|
|
61
|
+
super(SemanticRole.Checkbox, label, indicatorPresenter.root);
|
|
62
|
+
this.indicatorPresenter = indicatorPresenter;
|
|
63
|
+
this.semanticChecked(this.checkedStateValue);
|
|
64
|
+
this.syncVisualState();
|
|
65
|
+
this.persistState(CHECKBOX_PERSISTED_STATE);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get checkedState(): SemanticCheckedState {
|
|
69
|
+
return this.checkedStateValue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get checked(): bool {
|
|
73
|
+
return this.checkedStateValue == SemanticCheckedState.True;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
triState(flag: bool = true): this {
|
|
77
|
+
this.triStateEnabled = flag;
|
|
78
|
+
if (!flag && this.checkedStateValue == SemanticCheckedState.Mixed) {
|
|
79
|
+
this.setCheckedState(SemanticCheckedState.False, false);
|
|
80
|
+
}
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
check(flag: bool): this {
|
|
85
|
+
this.setCheckedState(flag ? SemanticCheckedState.True : SemanticCheckedState.False, false);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
mixed(flag: bool): this {
|
|
90
|
+
if (!this.triStateEnabled) {
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
this.setCheckedState(flag ? SemanticCheckedState.Mixed : SemanticCheckedState.False, false);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
template(template: CheckboxIndicatorTemplate | null): this {
|
|
98
|
+
this.templateOverride = template;
|
|
99
|
+
this.indicatorPresenter = createIndicatorPresenter(this.templateOverride);
|
|
100
|
+
this.replaceIndicatorRoot(this.indicatorPresenter.root);
|
|
101
|
+
this.syncVisualState();
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
onChanged(callback: ((state: SemanticCheckedState) => void) | null): this {
|
|
106
|
+
this.changedCallback = callback;
|
|
107
|
+
this.changedBinding = null;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
bindChanged<Owner>(owner: Owner, handler: Handler1<Owner, SemanticCheckedState>): this {
|
|
112
|
+
this.changedCallback = null;
|
|
113
|
+
this.changedBinding = bind1<Owner, SemanticCheckedState>(owner, handler);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
onChangedWith<Owner>(owner: Owner, handler: Handler1<Owner, SemanticCheckedState>): this {
|
|
118
|
+
this.bindChanged(owner, handler);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected handleActivated(): void {
|
|
123
|
+
if (this.triStateEnabled) {
|
|
124
|
+
if (this.checkedStateValue == SemanticCheckedState.False) {
|
|
125
|
+
this.setCheckedState(SemanticCheckedState.True, true);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this.checkedStateValue == SemanticCheckedState.True) {
|
|
129
|
+
this.setCheckedState(SemanticCheckedState.Mixed, true);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.setCheckedState(SemanticCheckedState.False, true);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.setCheckedState(
|
|
136
|
+
this.checkedStateValue == SemanticCheckedState.True ? SemanticCheckedState.False : SemanticCheckedState.True,
|
|
137
|
+
true,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
protected syncVisualState(): void {
|
|
142
|
+
this.indicatorPresenter.apply(
|
|
143
|
+
activeTheme.value,
|
|
144
|
+
new CheckboxIndicatorVisualState(
|
|
145
|
+
this.checkedStateValue,
|
|
146
|
+
this.hoveredState,
|
|
147
|
+
this.pressedState,
|
|
148
|
+
this.focusedState,
|
|
149
|
+
this.isEnabled,
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_applyPersistedCheckedState(next: SemanticCheckedState): void {
|
|
155
|
+
this.setCheckedState(next, true);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private setCheckedState(next: SemanticCheckedState, emit: bool): void {
|
|
159
|
+
if (!this.triStateEnabled && next == SemanticCheckedState.Mixed) {
|
|
160
|
+
next = SemanticCheckedState.False;
|
|
161
|
+
}
|
|
162
|
+
if (this.checkedStateValue == next) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.checkedStateValue = next;
|
|
166
|
+
this.semanticChecked(next);
|
|
167
|
+
this.syncVisualState();
|
|
168
|
+
if (emit) {
|
|
169
|
+
this.requestSemanticAnnouncement();
|
|
170
|
+
const callback = this.changedCallback;
|
|
171
|
+
if (callback !== null) {
|
|
172
|
+
callback(next);
|
|
173
|
+
}
|
|
174
|
+
const binding = this.changedBinding;
|
|
175
|
+
if (binding !== null) {
|
|
176
|
+
binding.invoke(next);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|