@gtkx/react 1.0.0-rc.3 → 1.0.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/README.md +8 -9
- package/dist/adw/config.d.ts +1 -0
- package/dist/adw/config.d.ts.map +1 -1
- package/dist/adw/config.js +1 -0
- package/dist/adw/config.js.map +1 -1
- package/dist/adw/dialog.d.ts +4 -4
- package/dist/adw/dialog.d.ts.map +1 -1
- package/dist/adw/dialog.js +16 -21
- package/dist/adw/dialog.js.map +1 -1
- package/dist/adw/element-behaviors.js +104 -57
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/adw/element-config.d.ts +0 -5
- package/dist/adw/element-config.d.ts.map +1 -1
- package/dist/adw/element-config.js +25 -26
- package/dist/adw/element-config.js.map +1 -1
- package/dist/adw/index.d.ts +1 -0
- package/dist/adw/index.d.ts.map +1 -1
- package/dist/adw/index.js +1 -0
- package/dist/adw/index.js.map +1 -1
- package/dist/adw/prop-types.d.ts +35 -4
- package/dist/adw/prop-types.d.ts.map +1 -1
- package/dist/adw/prop-types.js.map +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/application-window.d.ts +5 -0
- package/dist/components/application-window.d.ts.map +1 -0
- package/dist/components/application-window.js +7 -0
- package/dist/components/application-window.js.map +1 -0
- package/dist/components/application.d.ts +3 -8
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +22 -6
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +13 -2
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +39 -15
- package/dist/components/element.js.map +1 -1
- package/dist/components/portaled.d.ts +5 -0
- package/dist/components/portaled.d.ts.map +1 -0
- package/dist/components/portaled.js +8 -0
- package/dist/components/portaled.js.map +1 -0
- package/dist/components/window.d.ts +6 -5
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +17 -16
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +7 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/element-behaviors.js +11 -2
- package/dist/element-behaviors.js.map +1 -1
- package/dist/element-config.d.ts +4 -3
- package/dist/element-config.d.ts.map +1 -1
- package/dist/element-config.js +19 -15
- package/dist/element-config.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +8 -7
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +2 -7
- package/dist/hooks/use-bind-setting.js.map +1 -1
- package/dist/hooks/use-merged-refs.d.ts +1 -4
- package/dist/hooks/use-merged-refs.d.ts.map +1 -1
- package/dist/hooks/use-merged-refs.js +1 -1
- package/dist/hooks/use-merged-refs.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -1
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -1
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-presented-instance.d.ts +12 -0
- package/dist/hooks/use-presented-instance.d.ts.map +1 -0
- package/dist/hooks/use-presented-instance.js +27 -0
- package/dist/hooks/use-presented-instance.js.map +1 -0
- package/dist/hooks/use-property.d.ts +4 -3
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +1 -2
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +2 -3
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +2 -3
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +15 -8
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +6 -8
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +8 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +7 -5
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +88 -4
- package/dist/prop-types.d.ts.map +1 -1
- package/dist/prop-types.js.map +1 -1
- package/dist/reconciler/apply-props.d.ts +4 -4
- package/dist/reconciler/apply-props.d.ts.map +1 -1
- package/dist/reconciler/apply-props.js +62 -20
- package/dist/reconciler/apply-props.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +9 -20
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +44 -41
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/devtools.d.ts +6 -0
- package/dist/reconciler/devtools.d.ts.map +1 -0
- package/dist/reconciler/devtools.js +11 -0
- package/dist/reconciler/devtools.js.map +1 -0
- package/dist/reconciler/host-config.d.ts +1 -1
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js +17 -26
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +6 -4
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts +2 -2
- package/dist/reconciler/metadata.d.ts.map +1 -1
- package/dist/reconciler/metadata.js +9 -11
- package/dist/reconciler/metadata.js.map +1 -1
- package/dist/reconciler/node.d.ts +4 -3
- package/dist/reconciler/node.d.ts.map +1 -1
- package/dist/reconciler/node.js +8 -7
- package/dist/reconciler/node.js.map +1 -1
- package/dist/reconciler/placement.js +20 -20
- package/dist/reconciler/placement.js.map +1 -1
- package/dist/reconciler/registry.d.ts +46 -32
- package/dist/reconciler/registry.d.ts.map +1 -1
- package/dist/reconciler/registry.js +10 -19
- package/dist/reconciler/registry.js.map +1 -1
- package/dist/reconciler/root-element.d.ts +1 -1
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +0 -1
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +9 -20
- package/dist/reconciler/root.d.ts.map +1 -1
- package/dist/reconciler/root.js +6 -19
- package/dist/reconciler/root.js.map +1 -1
- package/dist/reconciler/signals.d.ts +1 -2
- package/dist/reconciler/signals.d.ts.map +1 -1
- package/dist/reconciler/signals.js +3 -3
- package/dist/reconciler/signals.js.map +1 -1
- package/dist/reconciler/text.js +5 -5
- package/dist/reconciler/text.js.map +1 -1
- package/dist/utils/accessible-props.d.ts +57 -9
- package/dist/utils/accessible-props.d.ts.map +1 -1
- package/dist/utils/accessible-props.js +11 -13
- package/dist/utils/accessible-props.js.map +1 -1
- package/dist/utils/ref-prop.d.ts +0 -6
- package/dist/utils/ref-prop.d.ts.map +1 -1
- package/dist/utils/ref-prop.js +0 -6
- package/dist/utils/ref-prop.js.map +1 -1
- package/dist/utils/settings.d.ts +7 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/settings.js.map +1 -1
- package/dist/utils/variant.d.ts +33 -1
- package/dist/utils/variant.d.ts.map +1 -1
- package/dist/utils/variant.js.map +1 -1
- package/env.d.ts +11 -4
- package/package.json +5 -5
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +23 -25
- package/src/adw/element-behaviors.ts +131 -60
- package/src/adw/element-config.ts +25 -26
- package/src/adw/index.ts +1 -0
- package/src/adw/prop-types.ts +36 -3
- package/src/bootstrap.ts +1 -1
- package/src/components/application-window.tsx +10 -0
- package/src/components/application.tsx +32 -5
- package/src/components/element.tsx +52 -17
- package/src/components/portaled.tsx +14 -0
- package/src/components/window.tsx +25 -23
- package/src/config.ts +13 -8
- package/src/element-behaviors.ts +20 -1
- package/src/element-config.ts +19 -15
- package/src/hooks/use-bind-setting.ts +8 -7
- package/src/hooks/use-merged-refs.ts +1 -1
- package/src/hooks/use-parent-window.ts +3 -1
- package/src/hooks/use-presented-instance.tsx +50 -0
- package/src/hooks/use-property.ts +4 -3
- package/src/hooks/use-setting.ts +2 -3
- package/src/hooks/use-signal.ts +18 -11
- package/src/index.ts +10 -2
- package/src/internal.ts +8 -5
- package/src/prop-types.ts +119 -11
- package/src/reconciler/apply-props.ts +77 -24
- package/src/reconciler/behaviors.ts +77 -50
- package/src/reconciler/devtools.ts +18 -0
- package/src/reconciler/host-config.ts +20 -32
- package/src/reconciler/instance.ts +7 -4
- package/src/reconciler/metadata.ts +11 -14
- package/src/reconciler/node.ts +12 -9
- package/src/reconciler/placement.ts +25 -25
- package/src/reconciler/registry.ts +56 -39
- package/src/reconciler/root-element.ts +4 -2
- package/src/reconciler/root.ts +12 -20
- package/src/reconciler/signals.ts +2 -3
- package/src/reconciler/text.ts +6 -6
- package/src/utils/accessible-props.ts +70 -25
- package/src/utils/ref-prop.ts +0 -6
- package/src/utils/settings.ts +7 -0
- package/src/utils/variant.ts +33 -1
- package/dist/utils/accessible-metadata.d.ts +0 -12
- package/dist/utils/accessible-metadata.d.ts.map +0 -1
- package/dist/utils/accessible-metadata.js +0 -25
- package/dist/utils/accessible-metadata.js.map +0 -1
- package/src/utils/accessible-metadata.ts +0 -31
|
@@ -1,64 +1,111 @@
|
|
|
1
1
|
import * as GObject from "@gtkx/gi/gobject";
|
|
2
2
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
3
|
import type { Props } from "../reconciler/registry.js";
|
|
4
|
-
import { deleteAccessibleMetadata, setAccessibleMetadata } from "./accessible-metadata.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Accessibility props available on every widget. Each member maps to a GTK4 accessible attribute
|
|
8
7
|
* (a `Gtk.AccessibleProperty`, `Gtk.AccessibleState`, or `Gtk.AccessibleRelation`) and is applied
|
|
9
|
-
* to the widget's accessible interface
|
|
8
|
+
* to the widget's accessible interface. Setting a member to `null` or `undefined`, or dropping it from the
|
|
9
|
+
* props, resets that attribute to its default.
|
|
10
10
|
*/
|
|
11
11
|
type AccessibleProps = {
|
|
12
|
+
/** How the widget completes the text being typed into it. */
|
|
12
13
|
accessibleAutocomplete?: Gtk.AccessibleAutocomplete | null | undefined;
|
|
14
|
+
/** Longer description announced after the label. */
|
|
13
15
|
accessibleDescription?: string | null | undefined;
|
|
16
|
+
/** Whether activating the widget opens a popup. */
|
|
14
17
|
accessibleHasPopup?: boolean | null | undefined;
|
|
18
|
+
/** Keyboard shortcuts that activate the widget. */
|
|
15
19
|
accessibleKeyShortcuts?: string | null | undefined;
|
|
20
|
+
/** Short name announced for the widget. */
|
|
16
21
|
accessibleLabel?: string | null | undefined;
|
|
22
|
+
/** Depth of the widget within a hierarchy of headings, list items, or tree rows. */
|
|
17
23
|
accessibleLevel?: number | null | undefined;
|
|
24
|
+
/** Whether the widget blocks interaction with everything behind it. */
|
|
18
25
|
accessibleModal?: boolean | null | undefined;
|
|
26
|
+
/** Whether the text input accepts more than one line. */
|
|
19
27
|
accessibleMultiLine?: boolean | null | undefined;
|
|
28
|
+
/** Whether more than one of the widget's items can be selected at a time. */
|
|
20
29
|
accessibleMultiSelectable?: boolean | null | undefined;
|
|
30
|
+
/** Whether the widget arranges its items horizontally or vertically. */
|
|
21
31
|
accessibleOrientation?: Gtk.Orientation | null | undefined;
|
|
32
|
+
/** Hint announced while the input is empty. */
|
|
22
33
|
accessiblePlaceholder?: string | null | undefined;
|
|
34
|
+
/** Whether the value can be read but not changed. */
|
|
23
35
|
accessibleReadOnly?: boolean | null | undefined;
|
|
36
|
+
/** Whether a value has to be supplied before the form can be submitted. */
|
|
24
37
|
accessibleRequired?: boolean | null | undefined;
|
|
38
|
+
/** Wording that replaces the default announcement of the widget's role. */
|
|
25
39
|
accessibleRoleDescription?: string | null | undefined;
|
|
40
|
+
/** Direction the widget's items are sorted in. */
|
|
26
41
|
accessibleSort?: Gtk.AccessibleSort | null | undefined;
|
|
42
|
+
/** Upper bound of the widget's value range. */
|
|
27
43
|
accessibleValueMax?: number | null | undefined;
|
|
44
|
+
/** Lower bound of the widget's value range. */
|
|
28
45
|
accessibleValueMin?: number | null | undefined;
|
|
46
|
+
/** Current value within the widget's range. */
|
|
29
47
|
accessibleValueNow?: number | null | undefined;
|
|
48
|
+
/** Wording announced in place of the numeric value. */
|
|
30
49
|
accessibleValueText?: string | null | undefined;
|
|
50
|
+
/** Help text describing how to use the widget. */
|
|
31
51
|
accessibleHelpText?: string | null | undefined;
|
|
52
|
+
/** Whether the widget is still loading and its content may yet change. */
|
|
32
53
|
accessibleBusy?: boolean | null | undefined;
|
|
54
|
+
/** Checked state of a check button or menu item, which may be mixed. */
|
|
33
55
|
accessibleChecked?: Gtk.AccessibleTristate | null | undefined;
|
|
56
|
+
/** Whether the widget is visible but cannot be edited or operated. */
|
|
34
57
|
accessibleDisabled?: boolean | null | undefined;
|
|
58
|
+
/** Whether the content the widget discloses is showing. */
|
|
35
59
|
accessibleExpanded?: boolean | null | undefined;
|
|
60
|
+
/** Whether the widget is kept out of the accessibility tree. */
|
|
36
61
|
accessibleHidden?: boolean | null | undefined;
|
|
62
|
+
/** Whether the entered value fails validation, and in what way. */
|
|
37
63
|
accessibleInvalid?: Gtk.AccessibleInvalidState | null | undefined;
|
|
64
|
+
/** Pressed state of a toggle button, which may be mixed. */
|
|
38
65
|
accessiblePressed?: Gtk.AccessibleTristate | null | undefined;
|
|
66
|
+
/** Whether the widget is selected within its container. */
|
|
39
67
|
accessibleSelected?: boolean | null | undefined;
|
|
68
|
+
/** Whether the link has already been followed. */
|
|
40
69
|
accessibleVisited?: boolean | null | undefined;
|
|
41
|
-
|
|
70
|
+
/** Descendant that holds the focus while the widget itself keeps it. */
|
|
71
|
+
accessibleActiveDescendant?: Gtk.Accessible | null | undefined;
|
|
72
|
+
/** Total number of columns in the table, including any that are not rendered. */
|
|
42
73
|
accessibleColCount?: number | null | undefined;
|
|
74
|
+
/** One-based column position of the cell within its table. */
|
|
43
75
|
accessibleColIndex?: number | null | undefined;
|
|
76
|
+
/** Wording announced in place of the numeric column position. */
|
|
44
77
|
accessibleColIndexText?: string | null | undefined;
|
|
78
|
+
/** Number of columns the cell spans. */
|
|
45
79
|
accessibleColSpan?: number | null | undefined;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
/** Widgets whose content or presence this widget controls. */
|
|
81
|
+
accessibleControls?: Gtk.Accessible[] | null | undefined;
|
|
82
|
+
/** Widgets that describe this one. */
|
|
83
|
+
accessibleDescribedBy?: Gtk.Accessible[] | null | undefined;
|
|
84
|
+
/** Widgets holding extended detail about this one. */
|
|
85
|
+
accessibleDetails?: Gtk.Accessible[] | null | undefined;
|
|
86
|
+
/** Widgets holding the message that explains why the value is invalid. */
|
|
87
|
+
accessibleErrorMessage?: Gtk.Accessible[] | null | undefined;
|
|
88
|
+
/** Widgets to read next, overriding the default reading order. */
|
|
89
|
+
accessibleFlowTo?: Gtk.Accessible[] | null | undefined;
|
|
90
|
+
/** Widgets that label this one. */
|
|
91
|
+
accessibleLabelledBy?: Gtk.Accessible[] | null | undefined;
|
|
92
|
+
/** Widgets this one owns that the widget hierarchy does not already imply. */
|
|
93
|
+
accessibleOwns?: Gtk.Accessible[] | null | undefined;
|
|
94
|
+
/** One-based position of the widget within its set. */
|
|
53
95
|
accessiblePosInSet?: number | null | undefined;
|
|
96
|
+
/** Total number of rows in the table, including any that are not rendered. */
|
|
54
97
|
accessibleRowCount?: number | null | undefined;
|
|
98
|
+
/** One-based row position of the cell within its table. */
|
|
55
99
|
accessibleRowIndex?: number | null | undefined;
|
|
100
|
+
/** Wording announced in place of the numeric row position. */
|
|
56
101
|
accessibleRowIndexText?: string | null | undefined;
|
|
102
|
+
/** Number of rows the cell spans. */
|
|
57
103
|
accessibleRowSpan?: number | null | undefined;
|
|
104
|
+
/** Total number of items in the set the widget belongs to. */
|
|
58
105
|
accessibleSetSize?: number | null | undefined;
|
|
59
106
|
};
|
|
60
107
|
|
|
61
|
-
type AccessibleValueType = "string" | "boolean" | "int" | "double" | "object" | "list";
|
|
108
|
+
type AccessibleValueType = "string" | "boolean" | "optionalBoolean" | "int" | "double" | "object" | "list";
|
|
62
109
|
|
|
63
110
|
type AccessiblePropertyDescriptor = {
|
|
64
111
|
kind: "property";
|
|
@@ -104,12 +151,12 @@ const ACCESSIBLE_PROP_MAP: Record<keyof AccessibleProps, AccessibleDescriptor> =
|
|
|
104
151
|
accessibleBusy: buildState(Gtk.AccessibleState.BUSY, "boolean"),
|
|
105
152
|
accessibleChecked: buildState(Gtk.AccessibleState.CHECKED, "int"),
|
|
106
153
|
accessibleDisabled: buildState(Gtk.AccessibleState.DISABLED, "boolean"),
|
|
107
|
-
accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "
|
|
154
|
+
accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "optionalBoolean"),
|
|
108
155
|
accessibleHidden: buildState(Gtk.AccessibleState.HIDDEN, "boolean"),
|
|
109
156
|
accessibleInvalid: buildState(Gtk.AccessibleState.INVALID, "int"),
|
|
110
157
|
accessiblePressed: buildState(Gtk.AccessibleState.PRESSED, "int"),
|
|
111
|
-
accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "
|
|
112
|
-
accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "
|
|
158
|
+
accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "optionalBoolean"),
|
|
159
|
+
accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "optionalBoolean"),
|
|
113
160
|
accessibleActiveDescendant: buildRelation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, "object"),
|
|
114
161
|
accessibleColCount: buildRelation(Gtk.AccessibleRelation.COL_COUNT, "int"),
|
|
115
162
|
accessibleColIndex: buildRelation(Gtk.AccessibleRelation.COL_INDEX, "int"),
|
|
@@ -166,6 +213,11 @@ const buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject
|
|
|
166
213
|
v.setBoolean(jsValue as boolean);
|
|
167
214
|
});
|
|
168
215
|
}
|
|
216
|
+
case "optionalBoolean": {
|
|
217
|
+
return GObject.buildValue(GObject.TYPE_INT, (v) => {
|
|
218
|
+
v.setInt(jsValue === true ? 1 : 0);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
169
221
|
case "int": {
|
|
170
222
|
return GObject.buildValue(GObject.TYPE_INT, (v) => {
|
|
171
223
|
v.setInt(jsValue as number);
|
|
@@ -182,7 +234,7 @@ const buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject
|
|
|
182
234
|
});
|
|
183
235
|
}
|
|
184
236
|
case "list": {
|
|
185
|
-
const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.
|
|
237
|
+
const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.Accessible[]);
|
|
186
238
|
|
|
187
239
|
return GObject.buildValue(Gtk.AccessibleList.prototype.__type__, (v) => {
|
|
188
240
|
v.setBoxed(list);
|
|
@@ -233,24 +285,18 @@ function resetDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescripto
|
|
|
233
285
|
const applyChangedProp = (widget: Gtk.Accessible, name: keyof AccessibleProps, newValue: unknown): void => {
|
|
234
286
|
if (newValue == null) {
|
|
235
287
|
resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
|
|
236
|
-
deleteAccessibleMetadata(widget, name);
|
|
237
288
|
} else {
|
|
238
289
|
applyDescriptor(widget, ACCESSIBLE_PROP_MAP[name], newValue);
|
|
239
|
-
setAccessibleMetadata(widget, name, newValue);
|
|
240
290
|
}
|
|
241
291
|
};
|
|
242
292
|
|
|
243
|
-
const applyChangedProps = (widget: Gtk.Accessible,
|
|
293
|
+
const applyChangedProps = (widget: Gtk.Accessible, newProps: Props): void => {
|
|
244
294
|
for (const name in newProps) {
|
|
245
295
|
if (!isAccessibleProp(name)) {
|
|
246
296
|
continue;
|
|
247
297
|
}
|
|
248
298
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (oldProps?.[name] !== newValue) {
|
|
252
|
-
applyChangedProp(widget, name, newValue);
|
|
253
|
-
}
|
|
299
|
+
applyChangedProp(widget, name, newProps[name]);
|
|
254
300
|
}
|
|
255
301
|
};
|
|
256
302
|
|
|
@@ -264,12 +310,11 @@ const resetRemovedProps = (widget: Gtk.Accessible, oldProps: Props, newProps: Pr
|
|
|
264
310
|
}
|
|
265
311
|
|
|
266
312
|
resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
|
|
267
|
-
deleteAccessibleMetadata(widget, name);
|
|
268
313
|
}
|
|
269
314
|
};
|
|
270
315
|
|
|
271
316
|
const applyAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {
|
|
272
|
-
applyChangedProps(widget,
|
|
317
|
+
applyChangedProps(widget, newProps);
|
|
273
318
|
|
|
274
319
|
if (oldProps) {
|
|
275
320
|
resetRemovedProps(widget, oldProps, newProps);
|
package/src/utils/ref-prop.ts
CHANGED
|
@@ -9,12 +9,6 @@ type RefProp<T extends object> = T | RefObject<T | null> | null | undefined;
|
|
|
9
9
|
const isRefObject = <T extends object>(value: T | RefObject<T | null>): value is RefObject<T | null> =>
|
|
10
10
|
typeof value === "object" && "current" in value;
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Resolves a {@link RefProp} to the concrete object it points at, or null when it is absent or unresolved.
|
|
14
|
-
*
|
|
15
|
-
* @param prop The target object, a ref to one, or null/undefined.
|
|
16
|
-
* @returns The resolved object, or null.
|
|
17
|
-
*/
|
|
18
12
|
const resolveRefProp = <T extends object>(prop: RefProp<T>): T | null => {
|
|
19
13
|
if (prop === null || prop === undefined) {
|
|
20
14
|
return null;
|
package/src/utils/settings.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type * as Gio from "@gtkx/gi/gio";
|
|
2
2
|
import { packVariant, parseVariantType, unpackVariant, type VariantValue } from "./variant.js";
|
|
3
3
|
|
|
4
|
+
/** Maps each key of a GSettings schema to its kind: a GVariant type string, or `enum` or `flags`. */
|
|
4
5
|
type SettingsSchemaKeys = Record<string, string>;
|
|
6
|
+
/** Value type a key kind stands for: `number` for `enum` and `flags`, otherwise the unpacked GVariant. */
|
|
5
7
|
type SettingKindValue<S extends string> = S extends "enum" | "flags" ? number : VariantValue<S>;
|
|
8
|
+
/** Value type of key `P`, looked up by its kind in schema `K`, that reads and writes of that key take. */
|
|
6
9
|
type SettingValue<K extends SettingsSchemaKeys, P extends keyof K> = SettingKindValue<K[P] & string>;
|
|
7
10
|
|
|
11
|
+
/** A GSettings schema, as described by the modules GTKX generates from a project's `.gschema.xml` files. */
|
|
8
12
|
type SettingsSchema<K extends SettingsSchemaKeys = SettingsSchemaKeys> = {
|
|
13
|
+
/** Schema id it is looked up by, such as `org.gtkx.Example`. */
|
|
9
14
|
id: string;
|
|
15
|
+
/** Path a relocatable schema is instantiated at, or `null` to use the schema's own path. */
|
|
10
16
|
path: string | null;
|
|
17
|
+
/** Kind of every key the schema declares, which types reads and writes of that key. */
|
|
11
18
|
keys: K;
|
|
12
19
|
};
|
|
13
20
|
|
package/src/utils/variant.ts
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
import * as GLib from "@gtkx/gi/glib";
|
|
2
2
|
|
|
3
|
+
/** JavaScript type every GVariant basic type code unpacks to. */
|
|
3
4
|
type BasicValueMap = {
|
|
5
|
+
/** Boolean, held as a single byte reading 0 or 1. */
|
|
4
6
|
b: boolean;
|
|
7
|
+
/** Unsigned byte. */
|
|
5
8
|
y: number;
|
|
9
|
+
/** Signed 16-bit integer. */
|
|
6
10
|
n: number;
|
|
11
|
+
/** Unsigned 16-bit integer. */
|
|
7
12
|
q: number;
|
|
13
|
+
/** Signed 32-bit integer. */
|
|
8
14
|
i: number;
|
|
15
|
+
/** Unsigned 32-bit integer. */
|
|
9
16
|
u: number;
|
|
17
|
+
/** Index into the file descriptor list a message carries. */
|
|
10
18
|
h: number;
|
|
19
|
+
/** Double precision floating point number. */
|
|
11
20
|
d: number;
|
|
21
|
+
/** Signed 64-bit integer. */
|
|
12
22
|
x: bigint;
|
|
23
|
+
/** Unsigned 64-bit integer. */
|
|
13
24
|
t: bigint;
|
|
25
|
+
/** UTF-8 string, under no further constraint on what it holds. */
|
|
14
26
|
s: string;
|
|
27
|
+
/** D-Bus object path. */
|
|
15
28
|
o: string;
|
|
29
|
+
/** GVariant type signature. */
|
|
16
30
|
g: string;
|
|
31
|
+
/** Boxed variant holding a value of any type. */
|
|
17
32
|
v: GLib.Variant;
|
|
18
33
|
};
|
|
19
34
|
|
|
35
|
+
/** Single-character code of one of the GVariant basic types in {@link BasicValueMap}. */
|
|
20
36
|
type BasicCode = keyof BasicValueMap;
|
|
37
|
+
/** Parses the element type of an array, yielding the array type it produces and the rest of the string. */
|
|
21
38
|
type ParseArray<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V[], R] : never;
|
|
39
|
+
/** Parses the element type of a maybe, yielding the nullable type it produces and the rest of the string. */
|
|
22
40
|
type ParseMaybe<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V | null, R] : never;
|
|
23
41
|
|
|
42
|
+
/** Collects tuple member types into `Acc` up to the closing parenthesis, yielding them and the rest of the string. */
|
|
24
43
|
type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer Rest}`
|
|
25
44
|
? [Acc, Rest]
|
|
26
45
|
: [Parse<S>] extends [never]
|
|
@@ -29,8 +48,10 @@ type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer R
|
|
|
29
48
|
? ParseTuple<R, [...Acc, V]>
|
|
30
49
|
: never;
|
|
31
50
|
|
|
51
|
+
/** Types a dictionary entry key can hold. */
|
|
32
52
|
type DictKey = string | number | bigint | boolean;
|
|
33
53
|
|
|
54
|
+
/** Parses the key and value types of a dictionary entry, yielding them and the rest of the string after its brace. */
|
|
34
55
|
type ParsePair<S extends string> =
|
|
35
56
|
Parse<S> extends [infer K, infer R1 extends string]
|
|
36
57
|
? Parse<R1> extends [infer V, infer R2 extends string]
|
|
@@ -42,16 +63,26 @@ type ParsePair<S extends string> =
|
|
|
42
63
|
: never
|
|
43
64
|
: never;
|
|
44
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Parses a dictionary entry into the collection an array of those entries unpacks to, a record for string keys and a
|
|
68
|
+
* `Map` otherwise, plus the rest of the string.
|
|
69
|
+
*/
|
|
45
70
|
type ParseDict<S extends string> =
|
|
46
71
|
ParsePair<S> extends [infer K, infer V, infer R extends string]
|
|
47
72
|
? [[K] extends [string] ? Record<string, V> : Map<K, V>, R]
|
|
48
73
|
: never;
|
|
49
74
|
|
|
75
|
+
/** Parses a standalone dictionary entry into a key and value pair, yielding it and the rest of the string. */
|
|
50
76
|
type ParseEntry<S extends string> =
|
|
51
77
|
ParsePair<S> extends [infer K, infer V, infer R extends string] ? [[K, V], R] : never;
|
|
52
78
|
|
|
79
|
+
/** Parses what follows an `a` as a dictionary when it opens an entry, and as a plain array otherwise. */
|
|
53
80
|
type ParseArrayOrDict<S extends string> = S extends `{${infer Rest}` ? ParseDict<Rest> : ParseArray<S>;
|
|
54
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Parses the type at the head of `S`, yielding the JavaScript type it unpacks to and the rest of the string, or
|
|
84
|
+
* `never` when the string is malformed.
|
|
85
|
+
*/
|
|
55
86
|
type Parse<S extends string> = S extends `a${infer Rest}`
|
|
56
87
|
? ParseArrayOrDict<Rest>
|
|
57
88
|
: S extends `m${infer Rest}`
|
|
@@ -66,6 +97,7 @@ type Parse<S extends string> = S extends `a${infer Rest}`
|
|
|
66
97
|
: never
|
|
67
98
|
: never;
|
|
68
99
|
|
|
100
|
+
/** JavaScript type a variant of type string `S` unpacks to, or `unknown` when `S` is not one complete type. */
|
|
69
101
|
type VariantValue<S extends string> = [Parse<S>] extends [never]
|
|
70
102
|
? unknown
|
|
71
103
|
: Parse<S> extends [infer V, ""]
|
|
@@ -365,4 +397,4 @@ const packVariant = (node: VariantTypeNode, value: unknown): GLib.Variant => {
|
|
|
365
397
|
}
|
|
366
398
|
};
|
|
367
399
|
|
|
368
|
-
export { parseVariantType, unpackVariant, packVariant, type VariantValue
|
|
400
|
+
export { parseVariantType, unpackVariant, packVariant, type VariantValue };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const setAccessibleMetadata: (widget: object, name: string, value: unknown) => void;
|
|
2
|
-
declare const deleteAccessibleMetadata: (widget: object, name: string) => void;
|
|
3
|
-
/**
|
|
4
|
-
* Returns the last value applied for an accessible prop on a widget, or null when none was applied.
|
|
5
|
-
*
|
|
6
|
-
* @param widget The widget to read from.
|
|
7
|
-
* @param name The accessible prop name.
|
|
8
|
-
* @returns The last applied value, or null.
|
|
9
|
-
*/
|
|
10
|
-
declare const getAccessibleMetadata: (widget: object, name: string) => unknown;
|
|
11
|
-
export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
|
|
12
|
-
//# sourceMappingURL=accessible-metadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessible-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,IAS7E,CAAC;AAEF,QAAA,MAAM,wBAAwB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAEhE,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,OAI7D,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const metadataStore = new WeakMap();
|
|
2
|
-
const setAccessibleMetadata = (widget, name, value) => {
|
|
3
|
-
let entries = metadataStore.get(widget);
|
|
4
|
-
if (entries === undefined) {
|
|
5
|
-
entries = new Map();
|
|
6
|
-
metadataStore.set(widget, entries);
|
|
7
|
-
}
|
|
8
|
-
entries.set(name, value);
|
|
9
|
-
};
|
|
10
|
-
const deleteAccessibleMetadata = (widget, name) => {
|
|
11
|
-
metadataStore.get(widget)?.delete(name);
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Returns the last value applied for an accessible prop on a widget, or null when none was applied.
|
|
15
|
-
*
|
|
16
|
-
* @param widget The widget to read from.
|
|
17
|
-
* @param name The accessible prop name.
|
|
18
|
-
* @returns The last applied value, or null.
|
|
19
|
-
*/
|
|
20
|
-
const getAccessibleMetadata = (widget, name) => {
|
|
21
|
-
const value = metadataStore.get(widget)?.get(name);
|
|
22
|
-
return value === undefined ? null : value;
|
|
23
|
-
};
|
|
24
|
-
export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
|
|
25
|
-
//# sourceMappingURL=accessible-metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessible-metadata.js","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE3E,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,KAAc,EAAQ,EAAE;IACjF,IAAI,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAExC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAQ,EAAE;IACpE,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAW,EAAE;IACpE,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["const metadataStore: WeakMap<object, Map<string, unknown>> = new WeakMap();\n\nconst setAccessibleMetadata = (widget: object, name: string, value: unknown): void => {\n let entries = metadataStore.get(widget);\n\n if (entries === undefined) {\n entries = new Map();\n metadataStore.set(widget, entries);\n }\n\n entries.set(name, value);\n};\n\nconst deleteAccessibleMetadata = (widget: object, name: string): void => {\n metadataStore.get(widget)?.delete(name);\n};\n\n/**\n * Returns the last value applied for an accessible prop on a widget, or null when none was applied.\n *\n * @param widget The widget to read from.\n * @param name The accessible prop name.\n * @returns The last applied value, or null.\n */\nconst getAccessibleMetadata = (widget: object, name: string): unknown => {\n const value = metadataStore.get(widget)?.get(name);\n\n return value === undefined ? null : value;\n};\n\nexport { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const metadataStore: WeakMap<object, Map<string, unknown>> = new WeakMap();
|
|
2
|
-
|
|
3
|
-
const setAccessibleMetadata = (widget: object, name: string, value: unknown): void => {
|
|
4
|
-
let entries = metadataStore.get(widget);
|
|
5
|
-
|
|
6
|
-
if (entries === undefined) {
|
|
7
|
-
entries = new Map();
|
|
8
|
-
metadataStore.set(widget, entries);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
entries.set(name, value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const deleteAccessibleMetadata = (widget: object, name: string): void => {
|
|
15
|
-
metadataStore.get(widget)?.delete(name);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns the last value applied for an accessible prop on a widget, or null when none was applied.
|
|
20
|
-
*
|
|
21
|
-
* @param widget The widget to read from.
|
|
22
|
-
* @param name The accessible prop name.
|
|
23
|
-
* @returns The last applied value, or null.
|
|
24
|
-
*/
|
|
25
|
-
const getAccessibleMetadata = (widget: object, name: string): unknown => {
|
|
26
|
-
const value = metadataStore.get(widget)?.get(name);
|
|
27
|
-
|
|
28
|
-
return value === undefined ? null : value;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
|