@gjsify/adwaita-core 0.64.12-next.281 → 0.64.12
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/lib/esm/conformance/index.js +1 -1
- package/lib/esm/conformance/list.js +1 -1
- package/lib/esm/conformance/rows.js +1 -1
- package/lib/esm/gtk-platform.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/list.js +1 -1
- package/lib/esm/option-list.js +1 -0
- package/lib/esm/rows.js +1 -1
- package/lib/types/conformance/index.d.ts +4 -4
- package/lib/types/conformance/list.d.ts +46 -39
- package/lib/types/conformance/rows.d.ts +62 -2
- package/lib/types/engine.d.ts +40 -6
- package/lib/types/gtk-platform.d.ts +9 -0
- package/lib/types/index.d.ts +6 -4
- package/lib/types/list-view.d.ts +4 -4
- package/lib/types/list.d.ts +9 -23
- package/lib/types/option-list.d.ts +128 -0
- package/lib/types/option-list.spec.d.ts +2 -0
- package/lib/types/rows.d.ts +162 -56
- package/package.json +4 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AdwComboOption, AdwListItemsChanged, AdwListModel, AdwListModelInput } from '../list.js';
|
|
1
|
+
import type { AdwComboOption, AdwListItemsChanged, AdwListModel, AdwListModelInput, AdwListModelSource } from '../list.js';
|
|
2
|
+
import { GjsifyOptionList } from '../option-list.js';
|
|
2
3
|
import type { TabViewPagesChange } from '../tab-view.js';
|
|
3
4
|
/** One {@link normalizeComboOptions} expectation. */
|
|
4
5
|
export interface ListNormalizeVector {
|
|
@@ -24,6 +25,19 @@ export interface ListNormalizeVector {
|
|
|
24
25
|
* a citation, and that sentence named no table).
|
|
25
26
|
*/
|
|
26
27
|
export declare const LIST_NORMALIZE_VECTORS: ReadonlyArray<ListNormalizeVector>;
|
|
28
|
+
/**
|
|
29
|
+
* A {@link LIST_NORMALIZE_VECTORS} row as the value a `model` PROPERTY write takes.
|
|
30
|
+
*
|
|
31
|
+
* ADR 0122 § 4 took the array arm off that property, so the ARRAY rows go in as a list built
|
|
32
|
+
* out of the array: the normaliser still runs on them, one step further in, as
|
|
33
|
+
* {@link GjsifyOptionList}'s own constructor. The model-source rows go STRAIGHT through —
|
|
34
|
+
* that is the shape the door now takes, and they are what proves a surface reads items by
|
|
35
|
+
* position rather than recognising one class.
|
|
36
|
+
*
|
|
37
|
+
* Lives here rather than in each driving suite because WHICH door a row reaches through is
|
|
38
|
+
* part of what the table claims, and two copies of that answer are two claims.
|
|
39
|
+
*/
|
|
40
|
+
export declare function listModelForInput(input: AdwListModelInput): AdwListModelSource;
|
|
27
41
|
/** One {@link parseListModel} expectation — the JSON attribute door. */
|
|
28
42
|
export interface ListParseVector {
|
|
29
43
|
/** The attribute value exactly as authored. */
|
|
@@ -65,20 +79,21 @@ export interface ListItemsChangedVector {
|
|
|
65
79
|
* change, which is `g_list_store_splice`'s shape.
|
|
66
80
|
*/
|
|
67
81
|
export declare const LIST_ITEMS_CHANGED_VECTORS: ReadonlyArray<ListItemsChangedVector>;
|
|
68
|
-
/** What a caller does to the
|
|
82
|
+
/** What a caller does to the options they hold, or to the model they were handed. */
|
|
69
83
|
export type ListReadbackOp = 'append' | 'relabel-first' | 'remove-first';
|
|
70
|
-
/** One
|
|
84
|
+
/** One ownership expectation — see {@link LIST_MODEL_OWNERSHIP_VECTORS}. */
|
|
71
85
|
export interface ListModelOwnershipVector {
|
|
72
86
|
initial: AdwListModel;
|
|
73
87
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
88
|
+
* WHAT the caller mutates. `input` is the array they authored and handed to
|
|
89
|
+
* `GjsifyOptionList.new`; `options` is the array read back out of `toOptions()`; `model`
|
|
90
|
+
* is the list itself, through its own `Gio.ListModel` API. The first two must move
|
|
91
|
+
* nothing and the third must move everything, and which of the three a surface gets
|
|
92
|
+
* wrong is the difference between a leak and a dropped redraw.
|
|
76
93
|
*/
|
|
77
|
-
source: '
|
|
94
|
+
source: 'options' | 'input' | 'model';
|
|
78
95
|
op: ListReadbackOp;
|
|
79
|
-
/**
|
|
80
|
-
assign: boolean;
|
|
81
|
-
/** The model the surface holds when the row is done. */
|
|
96
|
+
/** The options the surface holds when the row is done. */
|
|
82
97
|
model: AdwListModel;
|
|
83
98
|
/** The splice the surface emits, or `null` where it emits none. */
|
|
84
99
|
itemsChanged: AdwListItemsChanged | null;
|
|
@@ -87,50 +102,42 @@ export interface ListModelOwnershipVector {
|
|
|
87
102
|
rule: string;
|
|
88
103
|
}
|
|
89
104
|
/**
|
|
90
|
-
* WHO OWNS THE
|
|
105
|
+
* WHO OWNS THE OPTIONS — the arrays a caller holds on either side of the model, and the
|
|
106
|
+
* model itself.
|
|
91
107
|
*
|
|
92
108
|
* The browser suite drives `LIST_MODEL_OWNERSHIP_VECTORS` through `<adw-combo-row>` and
|
|
93
|
-
* `<gtk-drop-down>`, and core drives it through `ComboState
|
|
94
|
-
* where BOTH doors are reachable: the element setters run `normalizeComboOptions` and so
|
|
95
|
-
* close the input door on their own, while `ComboState.setModel` takes a normalised model
|
|
96
|
-
* straight from a caller.
|
|
109
|
+
* `<gtk-drop-down>`, and core drives it through `ComboState`.
|
|
97
110
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
111
|
+
* READ, MUTATE, ASSIGN IS GONE AS A PATTERN, and that is what reshaped these rows. ADR 0122
|
|
112
|
+
* § 4 narrows `model` to a real `Gio.ListModel`, so there is no array to assign back: the
|
|
113
|
+
* only way to change a model in place is its own API, and handing over a DIFFERENT list is a
|
|
114
|
+
* replacement that resets the selection. What survives from the array era is the half that
|
|
115
|
+
* was never about assignment — an array a caller holds is THEIRS on both sides, going in
|
|
116
|
+
* (`GjsifyOptionList` copies each descriptor into an item) and coming out (`toOptions`
|
|
117
|
+
* copies each item back). `relabel-first` is why the copy is per ITEM rather than per array:
|
|
118
|
+
* a shared descriptor would let the text under a selection move with nothing emitted, which
|
|
119
|
+
* is the failure `GjsifyOptionObject`'s read-only `label` exists to prevent.
|
|
120
|
+
*
|
|
121
|
+
* The `model` rows are the other side of the same invariant: the ONE door that does move the
|
|
122
|
+
* list emits the one minimal splice for it, in each of the three directions a splice can go.
|
|
106
123
|
*/
|
|
107
124
|
export declare const LIST_MODEL_OWNERSHIP_VECTORS: ReadonlyArray<ListModelOwnershipVector>;
|
|
108
125
|
/**
|
|
109
|
-
* The caller-side half of
|
|
110
|
-
*
|
|
126
|
+
* The caller-side half of an `options`/`input` row: mutate the array, IN PLACE, and hand the
|
|
127
|
+
* same array back.
|
|
111
128
|
*
|
|
112
129
|
* In place and returning its argument is the whole point — a helper that built a new array
|
|
113
130
|
* would test the pattern that never broke.
|
|
114
131
|
*/
|
|
115
132
|
export declare function applyListReadback(model: AdwComboOption[], op: ListReadbackOp): AdwComboOption[];
|
|
116
|
-
/** One {@link clampListSelection} expectation. */
|
|
117
|
-
export interface ListSelectionClampVector {
|
|
118
|
-
selected: number;
|
|
119
|
-
length: number;
|
|
120
|
-
result: number;
|
|
121
|
-
rule: string;
|
|
122
|
-
}
|
|
123
133
|
/**
|
|
124
|
-
*
|
|
134
|
+
* The model-side half: the same three ops through the list's own `Gio.ListModel` API.
|
|
125
135
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* the starting index these rows replace cannot be put on that element in the first place.
|
|
130
|
-
* One row is narrower than the vector even on the row, and `adw-row-state.spec.ts` says
|
|
131
|
-
* so in place.
|
|
136
|
+
* `relabel-first` is a splice rather than an assignment because {@link GjsifyOptionObject}
|
|
137
|
+
* is read-only — changing what an item says means putting a different item there, which is
|
|
138
|
+
* also how `Gio.ListStore` would have to spell it.
|
|
132
139
|
*/
|
|
133
|
-
export declare
|
|
140
|
+
export declare function applyListMutation(model: GjsifyOptionList, op: ListReadbackOp): void;
|
|
134
141
|
/** One {@link tabViewItemsChanged} expectation, with the order it replays. */
|
|
135
142
|
export interface TabPagesItemsChangedVector {
|
|
136
143
|
change: TabViewPagesChange;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import type { AdwComboOption, ComboStateChange } from '../rows.js';
|
|
1
|
+
import type { AdwComboOption, ComboNotify, ComboStateChange } from '../rows.js';
|
|
2
2
|
/**
|
|
3
3
|
* One mutation in a combo scenario. DATA, not a closure: a renderer suite
|
|
4
4
|
* replays these against a real widget (set the options, pick from the chooser)
|
|
5
5
|
* and compares what the user would see.
|
|
6
|
+
*
|
|
7
|
+
* `setModel` carries the model's CONTENTS and not a model object, so the table stays
|
|
8
|
+
* portable: each renderer builds whatever model it holds — a `GjsifyOptionList` in the
|
|
9
|
+
* core and in both browser elements, the same on the NativeScript host — out of these
|
|
10
|
+
* descriptors. `setModelAgain` is the one step that is about the model's IDENTITY rather
|
|
11
|
+
* than its contents, and it is a step rather than a flag because that is the only way to
|
|
12
|
+
* spell "assign the object you are already holding" in data.
|
|
6
13
|
*/
|
|
7
14
|
export type ComboSelectionStep = {
|
|
8
15
|
op: 'setModel';
|
|
9
16
|
model: ReadonlyArray<AdwComboOption>;
|
|
17
|
+
} | {
|
|
18
|
+
op: 'setModelAgain';
|
|
10
19
|
} | {
|
|
11
20
|
op: 'setSelectedIndex';
|
|
12
21
|
index: number;
|
|
@@ -23,7 +32,7 @@ export interface ComboSelectionVector {
|
|
|
23
32
|
steps: readonly ComboSelectionStep[];
|
|
24
33
|
/** `selectedIndex` afterwards. */
|
|
25
34
|
selected: number;
|
|
26
|
-
/** `selectedValue` afterwards — `''` when
|
|
35
|
+
/** `selectedValue` afterwards — `''` when nothing is selected. */
|
|
27
36
|
value: string;
|
|
28
37
|
/** `selectedLabel` afterwards — the text the inline value / button shows. */
|
|
29
38
|
label: string;
|
|
@@ -33,6 +42,12 @@ export interface ComboSelectionVector {
|
|
|
33
42
|
* gated on `interactive`.
|
|
34
43
|
*/
|
|
35
44
|
emitted: ReadonlyArray<ComboStateChange>;
|
|
45
|
+
/**
|
|
46
|
+
* Every `notify::` the scenario owes, flattened in EMISSION ORDER — see the module
|
|
47
|
+
* header. Driven by the surfaces that have real GObject properties; a DOM renderer
|
|
48
|
+
* skips it.
|
|
49
|
+
*/
|
|
50
|
+
notified: ReadonlyArray<ComboNotify>;
|
|
36
51
|
rule: string;
|
|
37
52
|
}
|
|
38
53
|
/**
|
|
@@ -46,6 +61,51 @@ export interface ComboSelectionVector {
|
|
|
46
61
|
* replaced. That first change is in `emitted` for exactly that reason.
|
|
47
62
|
*/
|
|
48
63
|
export declare const COMBO_SELECTION_VECTORS: ReadonlyArray<ComboSelectionVector>;
|
|
64
|
+
/** One splice applied to the model a combo state is HOLDING. */
|
|
65
|
+
export interface ComboSpliceStep {
|
|
66
|
+
position: number;
|
|
67
|
+
removed: number;
|
|
68
|
+
added: ReadonlyArray<AdwComboOption>;
|
|
69
|
+
}
|
|
70
|
+
/** One `items-changed` → selection scenario. */
|
|
71
|
+
export interface ComboItemsChangedVector {
|
|
72
|
+
name: string;
|
|
73
|
+
/** The model the state holds before the splice. */
|
|
74
|
+
initial: ReadonlyArray<AdwComboOption>;
|
|
75
|
+
/** Where the selection sits before the splice — `-1` leaves the sentinel in place. */
|
|
76
|
+
selected: number;
|
|
77
|
+
splice: ComboSpliceStep;
|
|
78
|
+
/** `selectedIndex` after the splice. */
|
|
79
|
+
result: number;
|
|
80
|
+
/** `selectedValue` after the splice. */
|
|
81
|
+
value: string;
|
|
82
|
+
/** The `notify::` the splice owes, in order — EMPTY where GTK emits none. */
|
|
83
|
+
notified: ReadonlyArray<ComboNotify>;
|
|
84
|
+
rule: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* What a splice on the HELD model does to the selection — `GtkSingleSelection`'s
|
|
88
|
+
* `items-changed` handler, which `Adw.ComboRow` and `Gtk.DropDown` both sit on.
|
|
89
|
+
*
|
|
90
|
+
* NEW IN ADR 0122, and only reachable since it: while `model` was an Array the only way to
|
|
91
|
+
* change the list was to replace it, so this whole axis had no spelling. A live
|
|
92
|
+
* `Gio.ListModel` moves under the widget, and WHERE it moved decides whether the selection
|
|
93
|
+
* follows the item, shifts with it, or is clamped because the item is gone.
|
|
94
|
+
*
|
|
95
|
+
* Every row is MEASURED (`combo-probe2.js`), and the `notified` column is the point of the
|
|
96
|
+
* table: the order here is the INVERSE of a `selected` write — `selected-item` first,
|
|
97
|
+
* because what changed is the item and the index is downstream of it. The shift row
|
|
98
|
+
* notifies `selected` ALONE for the mirror-image reason (the item did not change, only its
|
|
99
|
+
* position), and the replace-in-place row notifies `selected-item` alone.
|
|
100
|
+
*
|
|
101
|
+
* `<adw-combo-row>` drives the table through its own DOM, which is where the splice has to
|
|
102
|
+
* land for a user to see it: the outcome columns, the rebuilt `<option>` list, and the
|
|
103
|
+
* SILENCE a DOM surface owes (a model moving underneath is not a user pick, so no
|
|
104
|
+
* `notify::selected` event). The `notified` column itself stays with the core suite — it is
|
|
105
|
+
* a GObject property feed, and no port publishes one for this path yet; `subscribeNotify`
|
|
106
|
+
* is the seam a host that owns real properties will re-emit from.
|
|
107
|
+
*/
|
|
108
|
+
export declare const COMBO_ITEMS_CHANGED_VECTORS: ReadonlyArray<ComboItemsChangedVector>;
|
|
49
109
|
/** One `presentsChooser` expectation. */
|
|
50
110
|
export interface ComboChooserVector {
|
|
51
111
|
count: number;
|
package/lib/types/engine.d.ts
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
import type { Binding, BindingFlag, ClassLike, GObjectInstance, ParamSpec, RegisteredClass, SignalHandler } from './gobject.js';
|
|
1
|
+
import type { Binding, BindingFlag, ClassLike, GInterface, GObjectInstance, GType, ParamSpec, RegisteredClass, SignalHandler } from './gobject.js';
|
|
2
|
+
/**
|
|
3
|
+
* The kinds that carry a VALUE a declaration can also spell as a default — the five the subset
|
|
4
|
+
* has had since ADR 0105, and the only ones a signal parameter may take.
|
|
5
|
+
*/
|
|
6
|
+
export type ForeignScalarKind = 'string' | 'boolean' | 'int' | 'uint' | 'double';
|
|
2
7
|
/** The property kinds the subset has, and the only ones a declared widget property may take. */
|
|
3
|
-
export type ForeignPropertyKind =
|
|
8
|
+
export type ForeignPropertyKind = ForeignScalarKind | 'object';
|
|
4
9
|
/** One property a widget class declares at its `extends`. `default` is the unset value. */
|
|
5
|
-
export interface
|
|
6
|
-
readonly kind:
|
|
10
|
+
export interface ForeignScalarProperty {
|
|
11
|
+
readonly kind: ForeignScalarKind;
|
|
7
12
|
readonly default?: string | boolean | number | null;
|
|
8
13
|
readonly nick?: string;
|
|
9
14
|
readonly blurb?: string;
|
|
10
15
|
}
|
|
11
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* A property holding another GObject, or `null` — `Adw.ComboRow:model` (ADR 0122 § 6).
|
|
18
|
+
*
|
|
19
|
+
* `valueType` IS REQUIRED, and that is the whole reason this is a separate arm rather than an
|
|
20
|
+
* optional field on the one above. `g_param_spec_object` takes the object type as an argument and
|
|
21
|
+
* has no default for it, so a declaration that omitted it would leave the engine to guess between
|
|
22
|
+
* "any GObject" and the interface the widget actually means — and a `model` that accepted any
|
|
23
|
+
* GObject is the refusal ADR 0122 § 6 exists to make. It is the subset's own token (`TYPE_OBJECT`
|
|
24
|
+
* or an interface of the subset), NOT node-gi's: a port that named a real GType would have to
|
|
25
|
+
* import node-gi to describe its own properties, which is the dependency this vocabulary exists
|
|
26
|
+
* to keep out. The engine that has node-gi translates.
|
|
27
|
+
*
|
|
28
|
+
* There is no `default`. `g_param_spec_object`'s default is always `NULL`, so a declaration
|
|
29
|
+
* cannot carry another one.
|
|
30
|
+
*/
|
|
31
|
+
export interface ForeignObjectProperty {
|
|
32
|
+
readonly kind: 'object';
|
|
33
|
+
readonly valueType: GType | GInterface;
|
|
34
|
+
readonly nick?: string;
|
|
35
|
+
readonly blurb?: string;
|
|
36
|
+
}
|
|
37
|
+
/** One property a widget class declares at its `extends`. */
|
|
38
|
+
export type ForeignProperty = ForeignScalarProperty | ForeignObjectProperty;
|
|
39
|
+
/**
|
|
40
|
+
* One signal a widget class declares at its `extends`, in the subset's parameter vocabulary.
|
|
41
|
+
*
|
|
42
|
+
* SCALARS ONLY. An object parameter would need its own type beside the kind, as the property arm
|
|
43
|
+
* does, and nothing declares one — `items-changed` is three `uint`s. Widening it to
|
|
44
|
+
* `ForeignPropertyKind` would make `{ kind: 'object' }` spellable with no type and no meaning.
|
|
45
|
+
*/
|
|
12
46
|
export interface ForeignSignal {
|
|
13
|
-
readonly param_types?: readonly
|
|
47
|
+
readonly param_types?: readonly ForeignScalarKind[];
|
|
14
48
|
}
|
|
15
49
|
/**
|
|
16
50
|
* What a widget class declares at its `extends` — GJS's `registerClass` meta, in the port's own
|
|
@@ -42,6 +42,8 @@ export declare const GDK_KEYS: Readonly<{
|
|
|
42
42
|
readonly KEY_Up: 65362;
|
|
43
43
|
readonly KEY_Right: 65363;
|
|
44
44
|
readonly KEY_Down: 65364;
|
|
45
|
+
/** XF86Back: the hardware / mouse back key, and what Android's back button is delivered as. */
|
|
46
|
+
readonly KEY_Back: 269025062;
|
|
45
47
|
}>;
|
|
46
48
|
/** A DOM `key` as the keysym GTK would deliver: a Latin-1 character is its own code point, lowercased. */
|
|
47
49
|
export declare function keyvalOfKey(key: string): number;
|
|
@@ -109,6 +111,13 @@ export interface GtkPlatform {
|
|
|
109
111
|
}
|
|
110
112
|
/** A port is always on a display, so `Settings.get_default()` is never null (real GTK: null before `Gtk.init`). */
|
|
111
113
|
export declare function createGtkPlatform(host: PlatformHost): GtkPlatform;
|
|
114
|
+
/**
|
|
115
|
+
* Runs `event` through the key controllers attached to `widget`, as GTK does for a key the widget's
|
|
116
|
+
* toplevel receives: the first controller whose `key-pressed` / `key-released` handler returns true
|
|
117
|
+
* takes it. For keys the platform delivers by another road than the widget's own key listener (the
|
|
118
|
+
* Android back button); the result is whether a controller handled it.
|
|
119
|
+
*/
|
|
120
|
+
export declare function deliverKeyToControllers(widget: object, event: HostKeyEvent): boolean;
|
|
112
121
|
/** `Gtk.Widget.add_controller` / `remove_controller` for the widgets of a port. */
|
|
113
122
|
export declare function widgetControllerMembers(host: PlatformHost): {
|
|
114
123
|
add_controller(this: object, controller: EventControllerKey): void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export { Toast, ToastOverlayQueue, ToastPriority } from './toast-object.js';
|
|
|
32
32
|
export type { ToastOverlayQueueOptions } from './toast-object.js';
|
|
33
33
|
export { AdwAlertResponses, BottomSheetPresentation, resolveBottomSheetChrome, resolveBottomSheetClose, resolveBottomSheetOpen, resolveBottomSheetSwipeTracker, } from './dialog.js';
|
|
34
34
|
export type { AdwAlertResponse, AdwResponseAppearance, AdwResponseOptions, BottomSheetChrome, BottomSheetChromeState, BottomSheetCloseOutcome, BottomSheetCloseSource, BottomSheetCloseState, BottomSheetLayer, BottomSheetOpenOutcome, BottomSheetOpenSource, BottomSheetOpenState, BottomSheetPresentationListener, BottomSheetPresentationOptions, BottomSheetSwipeTrackerConfig, BottomSheetSwipeTrackerState, BottomSheetTeardownCallback, OrderedConfirmResponses, } from './dialog.js';
|
|
35
|
-
export { ADW_COMBO_NO_SELECTION,
|
|
35
|
+
export { ADW_COMBO_NO_SELECTION, listItemsChanged, normalizeComboOptions, parseListModel } from './list.js';
|
|
36
36
|
export type { AdwComboOption, AdwComboOptionInput, AdwListItemsChanged, AdwListModel, AdwListModelInput, } from './list.js';
|
|
37
37
|
export { ADW_COLUMN_VIEW_NO_FIXED_WIDTH, ADW_GRID_VIEW_MAX_COLUMNS, ADW_GRID_VIEW_MIN_COLUMNS, columnViewSort, columnViewTracks, gridViewColumns, listItemField, listViewSelect, listViewSelectAll, ListViewState, normalizeColumnViewColumns, normalizeListSelectionMode, parseColumnViewColumns, } from './list-view.js';
|
|
38
38
|
export type { AdwColumnViewColumn, AdwColumnViewSort, AdwListItemContext, AdwListItemFactory, AdwListItemField, AdwListSelectStep, AdwListSelection, AdwListSelectionMode, AdwListSelectResult, ListViewItemsListener, ListViewSelectionChange, ListViewSelectionListener, } from './list-view.js';
|
|
@@ -48,15 +48,17 @@ export { GtkAdjustment } from './gtk-adjustment.js';
|
|
|
48
48
|
export type { GtkAdjustmentProps } from './gtk-adjustment.js';
|
|
49
49
|
export { GtkStringList, GtkStringObject, INVALID_LIST_POSITION } from './gtk-string-list.js';
|
|
50
50
|
export type { GtkStringListProps } from './gtk-string-list.js';
|
|
51
|
+
export { GjsifyOptionList, GjsifyOptionObject, readModelWrite } from './option-list.js';
|
|
52
|
+
export type { GjsifyOptionListProps } from './option-list.js';
|
|
51
53
|
export { ComboState, ExpanderState, ToggleGroupState, keptToggles, toggleIndexOfName } from './rows.js';
|
|
52
|
-
export type { ComboItemsListener, ComboStateChange, ComboStateListener, ExpanderStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
54
|
+
export type { ComboItemsListener, ComboNotify, ComboNotifyListener, ComboStateChange, ComboStateListener, ComboWatchableModel, ExpanderStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
53
55
|
export { DEFAULT_BOX_SPACING, normalizeBoxOrientation, normalizeBoxSpacing } from './box.js';
|
|
54
56
|
export type { BoxOrientation } from './box.js';
|
|
55
57
|
export { DEFAULT_LABEL_ELLIPSIZE, DEFAULT_LABEL_LINES, DEFAULT_LABEL_MAX_WIDTH_CHARS, DEFAULT_LABEL_WIDTH_CHARS, DEFAULT_LABEL_WRAP_MODE, DEFAULT_LABEL_XALIGN, DEFAULT_LABEL_YALIGN, LABEL_ELLIPSIZE_MODES, LABEL_JUSTIFICATIONS, LABEL_WRAP_MODES, labelDisplayText, labelEffectiveLines, labelEllipsizeOverflowValue, labelMarkupIsUnparseable, labelWidthCharsExtent, labelYalignAlignItems, normalizeLabelEllipsize, normalizeLabelJustify, normalizeLabelLines, normalizeLabelMaxWidthChars, normalizeLabelWidthChars, normalizeLabelWrapMode, normalizeLabelXalign, normalizeLabelYalign, } from './label.js';
|
|
56
58
|
export type { LabelAlignItems, LabelEllipsizeMode, LabelJustification, LabelWidthCharsExtent, LabelWrapMode, } from './label.js';
|
|
57
59
|
export { glibClamp, gStrStrip, stringIsNotEmpty } from './glib.js';
|
|
58
60
|
export { AppLaunchContext as GdkAppLaunchContext, ContentFormats, ContentProvider, Clipboard, Display, createGdk, widgetDisplayMembers, } from './gdk.js';
|
|
59
|
-
export { CURRENT_TIME, CssProvider, EventControllerKey, GDK_KEYS, GtkSettings, IconTheme, STYLE_PROVIDER_PRIORITY_APPLICATION, STYLE_PROVIDER_PRIORITY_FALLBACK, STYLE_PROVIDER_PRIORITY_SETTINGS, STYLE_PROVIDER_PRIORITY_THEME, STYLE_PROVIDER_PRIORITY_USER, createGtkPlatform, keyvalOfKey, widgetControllerMembers, } from './gtk-platform.js';
|
|
61
|
+
export { CURRENT_TIME, CssProvider, EventControllerKey, GDK_KEYS, GtkSettings, IconTheme, STYLE_PROVIDER_PRIORITY_APPLICATION, STYLE_PROVIDER_PRIORITY_FALLBACK, STYLE_PROVIDER_PRIORITY_SETTINGS, STYLE_PROVIDER_PRIORITY_THEME, STYLE_PROVIDER_PRIORITY_USER, createGtkPlatform, deliverKeyToControllers, keyvalOfKey, widgetControllerMembers, } from './gtk-platform.js';
|
|
60
62
|
export type { GtkPlatform, HostKeyEvent, PlatformHost } from './gtk-platform.js';
|
|
61
63
|
export { iconLookupNames, lookupResourceIcon } from './icon-theme-resources.js';
|
|
62
64
|
export type { IconDirection, ResourceIconMatch, ResourceIconRequest } from './icon-theme-resources.js';
|
|
@@ -141,7 +143,7 @@ export { ActionRegistry, SimpleAction, actionRegistryOf, activateWidgetAction, a
|
|
|
141
143
|
export type { ActionActivateHandler, ActionGroupLike, ActionLike, SimpleActionProps } from './gio-actions.js';
|
|
142
144
|
export type { Binding, BindingFlag, BlueprintTemplate, BuiltTemplate, ClassLike, ClassMeta, GInterface, GObjectConstructor, GObjectDoor, GObjectInstance, GObjectNamespace, GType, ParamKind, RegisterClass, RegisteredClass, SignalHandler, SignalMeta, TemplateScope, } from './gobject.js';
|
|
143
145
|
export { engineForTarget, registerGObjectEngine, registeredEngine, resetRegisteredEngine } from './engine.js';
|
|
144
|
-
export type { EngineTarget, ForeignClassMeta, ForeignProperty, ForeignPropertyKind, ForeignSignal, GObjectEngine, } from './engine.js';
|
|
146
|
+
export type { EngineTarget, ForeignClassMeta, ForeignObjectProperty, ForeignProperty, ForeignPropertyKind, ForeignScalarKind, ForeignScalarProperty, ForeignSignal, GObjectEngine, } from './engine.js';
|
|
145
147
|
export { MAXUINT32, buildFilenamev, getCurrentDir, getSystemDataDirs } from './glib-paths.js';
|
|
146
148
|
export { uriEscapeString } from './glib-uri.js';
|
|
147
149
|
export { computeLanguageNames, languageNamesFromTags, localeFromLanguageTag } from './glib-language.js';
|
package/lib/types/list-view.d.ts
CHANGED
|
@@ -138,10 +138,10 @@ export declare class ListViewState {
|
|
|
138
138
|
* any selected position the new model does not have.
|
|
139
139
|
*
|
|
140
140
|
* A VIEW DOES NOT AUTOSELECT, and that is the one place this class deliberately
|
|
141
|
-
* differs from `ComboState
|
|
142
|
-
* `autoselect
|
|
143
|
-
* has no inline value and GTK's own `GtkMultiSelection` keeps nothing
|
|
144
|
-
* a model it cannot map. So positions are filtered, not
|
|
141
|
+
* differs from `ComboState`, whose model write resets the selection to 0:
|
|
142
|
+
* `GtkSingleSelection:autoselect` exists so a combo row always has a value to SHOW; a
|
|
143
|
+
* list view has no inline value and GTK's own `GtkMultiSelection` keeps nothing
|
|
144
|
+
* selected after a model it cannot map. So positions are filtered, not reset.
|
|
145
145
|
*/
|
|
146
146
|
setModel(model: readonly AdwComboOption[] | null | undefined): void;
|
|
147
147
|
/** `Gtk.SelectionModel` choice. Narrowing it drops what the new mode cannot hold. */
|
package/lib/types/list.d.ts
CHANGED
|
@@ -32,13 +32,16 @@ export interface AdwListModelSource {
|
|
|
32
32
|
get_item(position: number): unknown;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* What
|
|
36
|
-
* {@link AdwListModelSource}.
|
|
35
|
+
* What {@link normalizeComboOptions} ACCEPTS: the widened form of {@link AdwListModel}, plus a
|
|
36
|
+
* real {@link AdwListModelSource}.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* the
|
|
38
|
+
* IT IS THE NORMALISER'S INPUT TYPE AND NOT A PROPERTY TYPE, which is the whole of what ADR
|
|
39
|
+
* 0122 § 6 changed about it. `Adw.ComboRow:model` and `Gtk.DropDown:model` are a
|
|
40
|
+
* `Gio.ListModel` and nothing else now — an array assigned to either is a `TypeError` naming
|
|
41
|
+
* the type. The union stays because the AUTHORED vocabulary is still both: a JSON markup
|
|
42
|
+
* attribute parses to an array, a `Gtk.StringList` handed to `GjsifyOptionList` is a model,
|
|
43
|
+
* and both arrive here on their way to becoming descriptors. The arms are the two forms a
|
|
44
|
+
* caller can WRITE DOWN, not the two values a property will take.
|
|
42
45
|
*/
|
|
43
46
|
export type AdwListModelInput = ReadonlyArray<AdwComboOptionInput> | AdwListModelSource;
|
|
44
47
|
/**
|
|
@@ -83,23 +86,6 @@ export declare function parseListModel(raw: string | null | undefined): AdwCombo
|
|
|
83
86
|
* draw a placeholder has nothing to test.
|
|
84
87
|
*/
|
|
85
88
|
export declare const ADW_COMBO_NO_SELECTION = -1;
|
|
86
|
-
/**
|
|
87
|
-
* Where a selection lands after the model under it was REPLACED.
|
|
88
|
-
*
|
|
89
|
-
* `GtkSingleSelection` autoselects, so a position the new model does not have falls back
|
|
90
|
-
* to 0 — including the sentinel, which is how a widget recovers a selection when its model
|
|
91
|
-
* grows. An EMPTY model has no 0 to fall back to and lands on
|
|
92
|
-
* {@link ADW_COMBO_NO_SELECTION}.
|
|
93
|
-
*
|
|
94
|
-
* The test is membership and not `selected >= length`: the sentinel is BELOW the range, so
|
|
95
|
-
* a one-sided comparison leaves a `-1` in place and a model that was emptied and refilled
|
|
96
|
-
* comes back with nothing selected.
|
|
97
|
-
*
|
|
98
|
-
* Lifted out of `ComboState.setModel` so a second list widget cannot re-derive it. The
|
|
99
|
-
* cross-renderer rule it encodes was already conformance data — `conformance/rows.ts`
|
|
100
|
-
* carries it as "the ports' shared answer" — it just had no name of its own.
|
|
101
|
-
*/
|
|
102
|
-
export declare function clampListSelection(selected: number, length: number): number;
|
|
103
89
|
/**
|
|
104
90
|
* One positional change — `Gio.ListModel::items-changed`'s own three parameters.
|
|
105
91
|
*
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { GObjectObject, type GType } from './gobject.js';
|
|
2
|
+
import { type AdwComboOption, type AdwComboOptionInput } from './list.js';
|
|
3
|
+
import type { ComboWatchableModel } from './rows.js';
|
|
4
|
+
/**
|
|
5
|
+
* One selectable item, as the `GObject` a `GListModel` is allowed to hand out.
|
|
6
|
+
*
|
|
7
|
+
* Both properties are READ-ONLY, and that is not caution: an item is what a model contains, and
|
|
8
|
+
* a model reports a content change through `items-changed`. A writable `label` would let the
|
|
9
|
+
* text under a selection move with nothing emitted, which is the failure
|
|
10
|
+
* `GtkStringObject`'s read-only `string` exists to prevent.
|
|
11
|
+
*
|
|
12
|
+
* It deliberately has NO `string` property. `readListModel` unwraps an item that has one as a
|
|
13
|
+
* bare string — that is `Gtk.StringObject`'s shape — and an option that answered to it would
|
|
14
|
+
* lose its `value` on the way out, which is the whole reason this type exists.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GjsifyOptionObject extends GObjectObject {
|
|
17
|
+
constructor(props?: Record<string, unknown> | null);
|
|
18
|
+
/** An item holding `value` and `label` — the only way to put either in one. */
|
|
19
|
+
static new(value: string, label: string): GjsifyOptionObject;
|
|
20
|
+
/** An item for one authored entry, through the normaliser every surface already shares. */
|
|
21
|
+
static fromInput(entry: AdwComboOptionInput): GjsifyOptionObject;
|
|
22
|
+
/** The value this item is addressed by. */
|
|
23
|
+
get value(): string;
|
|
24
|
+
set value(_value: string);
|
|
25
|
+
/** The text this item draws as. */
|
|
26
|
+
get label(): string;
|
|
27
|
+
set label(_value: string);
|
|
28
|
+
/** The descriptor this item holds, as a COPY — nothing hands out the stored record. */
|
|
29
|
+
toOption(): AdwComboOption;
|
|
30
|
+
}
|
|
31
|
+
/** What `new GjsifyOptionList({ … })` takes. */
|
|
32
|
+
export interface GjsifyOptionListProps {
|
|
33
|
+
/** The options the list starts with, in any form {@link normalizeComboOptions} accepts. */
|
|
34
|
+
options?: readonly AdwComboOptionInput[] | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A `Gio.ListModel` of {@link GjsifyOptionObject}s — what a `model` property holds once the
|
|
38
|
+
* array door is closed.
|
|
39
|
+
*
|
|
40
|
+
* `new GjsifyOptionList()` is empty. The instance is a GObject with a real identity, so a
|
|
41
|
+
* `model` write that assigns the SAME list again is the no-op GTK makes it, and
|
|
42
|
+
* `row.model === list` answers true.
|
|
43
|
+
*/
|
|
44
|
+
export declare class GjsifyOptionList extends GObjectObject {
|
|
45
|
+
/** Installed by the core from {@link ListModel}; declared here for the type alone. */
|
|
46
|
+
readonly get_item: (position: number) => GjsifyOptionObject | null;
|
|
47
|
+
readonly get_item_type: () => GType;
|
|
48
|
+
readonly get_n_items: () => number;
|
|
49
|
+
readonly items_changed: (position: number, removed: number, added: number) => void;
|
|
50
|
+
constructor(props?: GjsifyOptionListProps | null);
|
|
51
|
+
/** A list holding `options`, or an empty one for `null` — the markup door's constructor. */
|
|
52
|
+
static new(options: readonly AdwComboOptionInput[] | null): GjsifyOptionList;
|
|
53
|
+
/** The item type, which here is the specific one: this list holds nothing else. */
|
|
54
|
+
get item_type(): GType;
|
|
55
|
+
set item_type(_value: GType);
|
|
56
|
+
get itemType(): GType;
|
|
57
|
+
set itemType(_value: GType);
|
|
58
|
+
/** `n-items` — the `ParamSpec`'s reader, and `get_n_items`'s answer. */
|
|
59
|
+
get n_items(): number;
|
|
60
|
+
set n_items(_value: number);
|
|
61
|
+
/** `vfunc_get_item_type` — what the interface's `get_item_type()` calls through to. */
|
|
62
|
+
vfunc_get_item_type(): GType;
|
|
63
|
+
/** `vfunc_get_n_items`. */
|
|
64
|
+
vfunc_get_n_items(): number;
|
|
65
|
+
/** `vfunc_get_item` — `null` past the end, as `g_list_model_get_item` returns `NULL`. */
|
|
66
|
+
vfunc_get_item(position: number): GjsifyOptionObject | null;
|
|
67
|
+
/** The descriptors this list holds, as copies — the form every renderer draws from. */
|
|
68
|
+
toOptions(): AdwComboOption[];
|
|
69
|
+
/** One more option at the end. */
|
|
70
|
+
append(option: AdwComboOptionInput): void;
|
|
71
|
+
/** The option at `position`, which must be in range. */
|
|
72
|
+
remove(position: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* `g_list_store_splice(position, n_removals, additions)` — the C signature, all three
|
|
75
|
+
* arguments, additions as ONE array, so a hundred-item replacement is one emission.
|
|
76
|
+
*
|
|
77
|
+
* Out of range is a CRITICAL and a no-op rather than an exception, which is the shape
|
|
78
|
+
* `Gtk.StringList` measured for the same call: this door is reachable from a markup
|
|
79
|
+
* attribute, and an author's slip must not take the widget down.
|
|
80
|
+
*/
|
|
81
|
+
splice(position: number, nRemovals: number, additions: readonly AdwComboOptionInput[] | null): void;
|
|
82
|
+
/**
|
|
83
|
+
* The POSITION of the first option with this value, {@link INVALID_LIST_POSITION} when there
|
|
84
|
+
* is none — `gtk_string_list_find`'s meaning of the name, over the half a descriptor is
|
|
85
|
+
* addressed by.
|
|
86
|
+
*/
|
|
87
|
+
find(value: string): number;
|
|
88
|
+
/**
|
|
89
|
+
* Replace the contents with `next` IN PLACE, as the ONE splice that turns one into the
|
|
90
|
+
* other — {@link listItemsChanged}'s minimal range.
|
|
91
|
+
*
|
|
92
|
+
* This is the markup door's update path and it keeps the list's IDENTITY, which is what
|
|
93
|
+
* makes it different from a `model` write. Re-parsing an attribute must not look to the
|
|
94
|
+
* widget like a new model: a model REPLACEMENT re-runs autoselect and resets the selection
|
|
95
|
+
* to 0 (ADR 0122 § 4, measured), while appending one option to the end of the list the
|
|
96
|
+
* widget already holds moves nothing. An author editing `model='[…]'` means the second.
|
|
97
|
+
*/
|
|
98
|
+
reconcile(next: readonly AdwComboOptionInput[] | null): void;
|
|
99
|
+
/** The one mutation, so the emission rule is written once. See the file header. */
|
|
100
|
+
private spliceItems;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What a write to a `model` property reads as — the ONE door, for all four surfaces.
|
|
104
|
+
*
|
|
105
|
+
* ADR 0122 § 6 makes `model` an object property over `Gio.ListModel`, and § 5 leaves the JSON
|
|
106
|
+
* markup attribute open, so every `model` setter in this repository has the same three-way
|
|
107
|
+
* answer to give. It is written here once because it was about to be written four times:
|
|
108
|
+
*
|
|
109
|
+
* - a real model — anything with `get_n_items` and `get_item`, which is what
|
|
110
|
+
* {@link AdwListModelSource}'s docblock argues is the test — is handed through by IDENTITY,
|
|
111
|
+
* so `widget.model === model` holds as it is measured to in libadwaita;
|
|
112
|
+
* - `null` / `undefined` is the "no model" write, which notifies `model` alone;
|
|
113
|
+
* - a STRING is the markup attribute, parsed and reconciled into `authored` — the surface's
|
|
114
|
+
* OWN list, whose identity survives the edit so an author appending one option to
|
|
115
|
+
* `model='[…]'` gets one splice instead of a replacement that resets the selection;
|
|
116
|
+
* - anything else, an ARRAY above all, is a `TypeError`.
|
|
117
|
+
*
|
|
118
|
+
* THE REFUSAL IS THE PROPERTY'S, not a second opinion: the message comes out of
|
|
119
|
+
* {@link checkPropertyValue} against `model`'s own ParamSpec, which is where GJS's measured
|
|
120
|
+
* wording lives. Reaching it is already the failure case, and it always throws for a value that
|
|
121
|
+
* gets that far — the one thing it accepts is a registered implementor of `Gio.ListModel`, and
|
|
122
|
+
* the interface installs the two getters the duck test above just failed to find.
|
|
123
|
+
*
|
|
124
|
+
* The duck test and not `checkPropertyValue` alone, because a REAL `Gio.ListStore` reached
|
|
125
|
+
* through node-gi (ADR 0104) is no registered class of this subset and `implementsInterface`
|
|
126
|
+
* would refuse it — and handing one to `Adw.ComboRow:model` is the whole point of having it.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readModelWrite(value: unknown, authored: GjsifyOptionList): ComboWatchableModel | null;
|