@gjsify/adwaita-core 0.31.0 → 0.32.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.
Files changed (112) hide show
  1. package/lib/esm/about-dialog.js +3 -0
  2. package/lib/esm/action-row.js +1 -0
  3. package/lib/esm/avatar.js +1 -0
  4. package/lib/esm/banner.js +1 -0
  5. package/lib/esm/button-content.js +1 -0
  6. package/lib/esm/carousel.js +1 -0
  7. package/lib/esm/checks.js +1 -0
  8. package/lib/esm/chrome.js +1 -0
  9. package/lib/esm/conformance/about-dialog.js +6 -0
  10. package/lib/esm/conformance/action-row.js +1 -0
  11. package/lib/esm/conformance/avatar.js +1 -0
  12. package/lib/esm/conformance/banner.js +1 -0
  13. package/lib/esm/conformance/button-content.js +1 -0
  14. package/lib/esm/conformance/carousel.js +1 -0
  15. package/lib/esm/conformance/checks.js +1 -0
  16. package/lib/esm/conformance/chrome.js +1 -0
  17. package/lib/esm/conformance/data-grid.js +1 -0
  18. package/lib/esm/conformance/dialog.js +1 -0
  19. package/lib/esm/conformance/entry-row.js +1 -0
  20. package/lib/esm/conformance/index.js +1 -0
  21. package/lib/esm/conformance/navigation-view.js +1 -0
  22. package/lib/esm/conformance/popover.js +1 -0
  23. package/lib/esm/conformance/preferences.js +1 -0
  24. package/lib/esm/conformance/rows.js +1 -0
  25. package/lib/esm/conformance/sidebar.js +1 -0
  26. package/lib/esm/conformance/split-button.js +1 -0
  27. package/lib/esm/conformance/split-view.js +1 -0
  28. package/lib/esm/conformance/tab-view.js +1 -0
  29. package/lib/esm/conformance/view-stack.js +1 -0
  30. package/lib/esm/conformance/view-switcher.js +1 -0
  31. package/lib/esm/conformance/wrap-box.js +1 -0
  32. package/lib/esm/data-grid.js +1 -0
  33. package/lib/esm/dialog.js +1 -1
  34. package/lib/esm/entry-row.js +1 -0
  35. package/lib/esm/glib.js +1 -0
  36. package/lib/esm/index.js +1 -1
  37. package/lib/esm/navigation-view.js +1 -0
  38. package/lib/esm/popover.js +1 -0
  39. package/lib/esm/preferences.js +1 -0
  40. package/lib/esm/rows.js +1 -1
  41. package/lib/esm/sidebar.js +1 -0
  42. package/lib/esm/split-button.js +1 -0
  43. package/lib/esm/split-view.js +1 -0
  44. package/lib/esm/tab-view.js +1 -0
  45. package/lib/esm/view-stack.js +1 -0
  46. package/lib/esm/view-switcher.js +1 -0
  47. package/lib/types/about-dialog.d.ts +391 -0
  48. package/lib/types/about-dialog.spec.d.ts +2 -0
  49. package/lib/types/action-row.d.ts +270 -0
  50. package/lib/types/action-row.spec.d.ts +2 -0
  51. package/lib/types/avatar.d.ts +112 -0
  52. package/lib/types/avatar.spec.d.ts +2 -0
  53. package/lib/types/banner.d.ts +104 -0
  54. package/lib/types/banner.spec.d.ts +2 -0
  55. package/lib/types/button-content.d.ts +141 -0
  56. package/lib/types/button-content.spec.d.ts +2 -0
  57. package/lib/types/carousel.d.ts +535 -0
  58. package/lib/types/carousel.spec.d.ts +2 -0
  59. package/lib/types/checks.d.ts +63 -0
  60. package/lib/types/checks.spec.d.ts +2 -0
  61. package/lib/types/chrome.d.ts +355 -0
  62. package/lib/types/chrome.spec.d.ts +2 -0
  63. package/lib/types/conformance/about-dialog.d.ts +300 -0
  64. package/lib/types/conformance/action-row.d.ts +186 -0
  65. package/lib/types/conformance/avatar.d.ts +61 -0
  66. package/lib/types/conformance/banner.d.ts +91 -0
  67. package/lib/types/conformance/button-content.d.ts +110 -0
  68. package/lib/types/conformance/carousel.d.ts +284 -0
  69. package/lib/types/conformance/checks.d.ts +29 -0
  70. package/lib/types/conformance/chrome.d.ts +195 -0
  71. package/lib/types/conformance/data-grid.d.ts +134 -0
  72. package/lib/types/conformance/dialog.d.ts +97 -0
  73. package/lib/types/conformance/entry-row.d.ts +185 -0
  74. package/lib/types/conformance/index.d.ts +44 -0
  75. package/lib/types/conformance/navigation-view.d.ts +235 -0
  76. package/lib/types/conformance/popover.d.ts +56 -0
  77. package/lib/types/conformance/preferences.d.ts +170 -0
  78. package/lib/types/conformance/rows.d.ts +51 -0
  79. package/lib/types/conformance/sidebar.d.ts +182 -0
  80. package/lib/types/conformance/split-button.d.ts +189 -0
  81. package/lib/types/conformance/split-view.d.ts +290 -0
  82. package/lib/types/conformance/tab-view.d.ts +441 -0
  83. package/lib/types/conformance/view-stack.d.ts +121 -0
  84. package/lib/types/conformance/view-switcher.d.ts +443 -0
  85. package/lib/types/conformance/wrap-box.d.ts +134 -0
  86. package/lib/types/data-grid.d.ts +140 -0
  87. package/lib/types/data-grid.spec.d.ts +2 -0
  88. package/lib/types/dialog.d.ts +144 -0
  89. package/lib/types/entry-row.d.ts +308 -0
  90. package/lib/types/entry-row.spec.d.ts +2 -0
  91. package/lib/types/glib.d.ts +49 -0
  92. package/lib/types/index.d.ts +43 -4
  93. package/lib/types/navigation-view.d.ts +343 -0
  94. package/lib/types/navigation-view.spec.d.ts +2 -0
  95. package/lib/types/popover.d.ts +155 -0
  96. package/lib/types/popover.spec.d.ts +2 -0
  97. package/lib/types/preferences.d.ts +349 -0
  98. package/lib/types/preferences.spec.d.ts +2 -0
  99. package/lib/types/rows.d.ts +49 -2
  100. package/lib/types/sidebar.d.ts +308 -0
  101. package/lib/types/sidebar.spec.d.ts +2 -0
  102. package/lib/types/split-button.d.ts +316 -0
  103. package/lib/types/split-button.spec.d.ts +2 -0
  104. package/lib/types/split-view.d.ts +714 -0
  105. package/lib/types/split-view.spec.d.ts +2 -0
  106. package/lib/types/tab-view.d.ts +616 -0
  107. package/lib/types/tab-view.spec.d.ts +2 -0
  108. package/lib/types/view-stack.d.ts +266 -0
  109. package/lib/types/view-stack.spec.d.ts +2 -0
  110. package/lib/types/view-switcher.d.ts +521 -0
  111. package/lib/types/view-switcher.spec.d.ts +2 -0
  112. package/package.json +8 -4
@@ -0,0 +1,140 @@
1
+ /** Horizontal alignment of a column's header + cells. */
2
+ export type AdwDataGridAlign = 'start' | 'end' | 'center';
3
+ /** Accounting row emphasis. `normal` is the default plain data row. */
4
+ export type AdwDataGridRowVariant = 'normal' | 'section' | 'subtotal' | 'total';
5
+ /** The four row variants, in the order a statement uses them. */
6
+ export declare const ADW_DATA_GRID_ROW_VARIANTS: ReadonlyArray<AdwDataGridRowVariant>;
7
+ /** A column descriptor — what to read (`key`), how to label + align it. */
8
+ export interface AdwDataGridColumn {
9
+ /** The row-object key this column renders. */
10
+ key: string;
11
+ /** Header text (defaults to `key`). */
12
+ label?: string;
13
+ /** 'start' | 'end' | 'center'. Defaults to 'start' (or 'end' when numeric). */
14
+ align?: AdwDataGridAlign;
15
+ /** Fixed CSS track size (e.g. '80px', '6rem') — pins the column width. */
16
+ width?: string;
17
+ /** Fractional track weight (→ `<flex>fr`) — lets the column grow. */
18
+ flex?: number;
19
+ /** Render cells in a monospace family (tabular figures apply regardless). */
20
+ monospace?: boolean;
21
+ /** Convenience: right-align + tabular-nums (numeric columns of figures). */
22
+ numeric?: boolean;
23
+ }
24
+ /** What a cell may hold — pre-formatted strings, or anything stringifiable. */
25
+ export type AdwDataGridCellValue = string | number | boolean | AdwDataGridRowVariant | undefined;
26
+ /** A row: cell values keyed by column key + optional accounting metadata. */
27
+ export interface AdwDataGridRow {
28
+ /** Accounting emphasis. Default 'normal'. */
29
+ variant?: AdwDataGridRowVariant;
30
+ /** Make just this row clickable (overrides the element-level flag). */
31
+ interactive?: boolean;
32
+ /** Cell values keyed by column key (pre-formatted strings, or numbers). */
33
+ [key: string]: AdwDataGridCellValue;
34
+ }
35
+ /**
36
+ * One column track, in renderer-neutral terms.
37
+ *
38
+ * `fixed` carries the author's CSS length UNPARSED, because the browser can
39
+ * resolve every unit CSS has and no other renderer can: it is the one track kind
40
+ * whose meaning is the stylesheet's. A renderer without a CSS engine parses what
41
+ * it understands and falls back — see the NativeScript sibling for that call.
42
+ */
43
+ export type DataGridTrack =
44
+ /** A pinned track: the `width` string exactly as the column declared it. */
45
+ {
46
+ kind: 'fixed';
47
+ css: string;
48
+ }
49
+ /** A weighted track: `flex` fractions of the leftover space. */
50
+ | {
51
+ kind: 'flex';
52
+ weight: number;
53
+ }
54
+ /** The single slack-absorbing track — see {@link dataGridTracks}. */
55
+ | {
56
+ kind: 'slack';
57
+ }
58
+ /** A content-sized track. */
59
+ | {
60
+ kind: 'auto';
61
+ };
62
+ /** The class every data-grid cell carries, header cells included. */
63
+ export declare const DATA_GRID_CELL_CLASS = "adw-data-grid-cell";
64
+ /** The class every data-grid row carries, the header row included. */
65
+ export declare const DATA_GRID_ROW_CLASS = "adw-data-grid-row";
66
+ /**
67
+ * The column tracks derived from the column descriptors.
68
+ *
69
+ * `width` pins a track and `flex` weights one, each on its own column. The
70
+ * interesting rule is the third one and it is GLOBAL, not per column: when
71
+ * NOTHING declares a size anywhere, the FIRST column absorbs the slack and every
72
+ * other column sizes to its content. That is the statement shape — one label
73
+ * column taking whatever is left, trailing figures hugging the right edge — and
74
+ * it is why the emptiest possible column list still produces a usable grid.
75
+ *
76
+ * One declared size anywhere turns the rule off for every column, so a caller
77
+ * pinning a single column does not silently keep an implicit flexible one.
78
+ */
79
+ export declare function dataGridTracks(columns: ReadonlyArray<AdwDataGridColumn>): DataGridTrack[];
80
+ /**
81
+ * The CSS `grid-template-columns` value for a track list — the browser mapping.
82
+ *
83
+ * The slack track is `minmax(0px, 1fr)` rather than `1fr` so a long cell cannot
84
+ * push the column past its share (`1fr` floors at the content's min-content
85
+ * size); `0px` is spelled with its unit because that is the CSSOM-canonical
86
+ * form, and a bare `0` does not round-trip through `style.gridTemplateColumns`.
87
+ */
88
+ export declare function dataGridTrackTemplate(tracks: ReadonlyArray<DataGridTrack>): string;
89
+ /**
90
+ * A column's effective alignment: its own `align`, or `end` when it is numeric.
91
+ *
92
+ * The numeric default is the widget's reason to exist — a column of figures that
93
+ * does not end on a common right edge is a boxed list with extra steps.
94
+ */
95
+ export declare function dataGridColumnAlign(column: AdwDataGridColumn): AdwDataGridAlign;
96
+ /**
97
+ * The classes a column's cells carry: the base cell class, the alignment, and
98
+ * the two typographic opt-ins.
99
+ *
100
+ * `numeric` and `mono` are the libadwaita label classes (_labels.scss:81-88):
101
+ * both set `font-variant-numeric: tabular-nums`, `mono` additionally switching
102
+ * to the monospace family. A renderer whose stylesheet cannot express that
103
+ * feature still gets the alignment, which is the half that survives.
104
+ *
105
+ * `align` is NOT clamped to {@link AdwDataGridAlign} here, so a value outside
106
+ * the union produces a class no stylesheet claims and the cell falls back to the
107
+ * base rule. That is deliberate asymmetry with {@link normalizeDataGridVariant}:
108
+ * a bogus variant would pick an EMPHASIS (a bold total rule where none belongs),
109
+ * a bogus alignment only fails to move text.
110
+ */
111
+ export declare function dataGridColumnClasses(column: AdwDataGridColumn): string[];
112
+ /**
113
+ * Coerce a cell value to display text — pre-formatted strings pass through.
114
+ *
115
+ * The grid FORMATS NOTHING: locale currency, thousands separators and decimals
116
+ * are the app's, because only the app knows the locale and the rounding. A
117
+ * number reaching here is a convenience, not a formatting request, so it is
118
+ * stringified as-is. A missing key is empty rather than `undefined`.
119
+ */
120
+ export declare function dataGridCellText(value: AdwDataGridCellValue | null): string;
121
+ /** Clamp an arbitrary variant to the known set (unknown → 'normal'). */
122
+ export declare function normalizeDataGridVariant(variant: unknown): AdwDataGridRowVariant;
123
+ /** Normalise raw column descriptors to a stable list (drops malformed entries). */
124
+ export declare function normalizeDataGridColumns(raw: unknown): AdwDataGridColumn[];
125
+ /**
126
+ * Whether a row activates on click/tap.
127
+ *
128
+ * Three conditions, and the order matters. Only a `normal` row can activate at
129
+ * all — a section header, a subtotal and a total are STRUCTURE, and making them
130
+ * tappable would offer a detail view for a computed line that has none. Then the
131
+ * per-row flag wins over the grid-level one in BOTH directions: `false` opts a
132
+ * single row out of a fully interactive grid, `true` opts a single row into an
133
+ * otherwise inert one.
134
+ *
135
+ * `rowFlag` is `unknown` on purpose: it arrives from a JSON attribute, where
136
+ * anything can be under the key, and only the two booleans decide. Any other
137
+ * value defers to the grid, which is what a value the widget cannot read should
138
+ * do.
139
+ */
140
+ export declare function dataGridRowInteractive(variant: AdwDataGridRowVariant, rowFlag: unknown, gridInteractive: boolean): boolean;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -98,3 +98,147 @@ export declare class AdwAlertResponses {
98
98
  */
99
99
  resolveLabel(label: string | null | undefined): string;
100
100
  }
101
+ /**
102
+ * Which affordance asked a bottom sheet to close.
103
+ *
104
+ * These are not interchangeable: the C source runs each through a DIFFERENT
105
+ * gate, and the differences are exactly what a renderer flattening them into one
106
+ * `_attemptClose()` loses.
107
+ *
108
+ * - `'dimming'` — a click on the modal scrim (`released_cb`).
109
+ * - `'escape'` — the <kbd>Escape</kbd> shortcut on the sheet (`maybe_close_cb`).
110
+ * - `'close-button'` — the `sheet.close` widget action (`sheet_close_cb`).
111
+ * - `'drag-handle'` — the pill at the top of the sheet. Decorative in libadwaita.
112
+ * - `'swipe'` — a downward swipe on the sheet (`prepare_cb` → `end_swipe_cb`).
113
+ */
114
+ export type BottomSheetCloseSource = 'dimming' | 'escape' | 'close-button' | 'drag-handle' | 'swipe';
115
+ /**
116
+ * What a renderer must do about a close request.
117
+ *
118
+ * - `'close'` — close the sheet.
119
+ * - `'close-attempt'` — emit `close-attempt`; the sheet stays as it is.
120
+ * - `'delegate'` — forward the `sheet.close` action to the PARENT (a sheet
121
+ * nested in another sheet/dialog closes the outer one).
122
+ * - `'ignored'` — do nothing, and emit nothing. Not the same as
123
+ * `'close-attempt'`: a locked sheet swallows a swipe
124
+ * silently but SIGNALS a scrim click.
125
+ */
126
+ export type BottomSheetCloseOutcome = 'close' | 'close-attempt' | 'delegate' | 'ignored';
127
+ /** The two bits {@link resolveBottomSheetClose} decides from. */
128
+ export interface BottomSheetCloseState {
129
+ /** Whether the sheet is currently revealed (`AdwBottomSheet:open`). */
130
+ open: boolean;
131
+ /** Whether the user may dismiss it (`AdwBottomSheet:can-close`). */
132
+ canClose: boolean;
133
+ }
134
+ /**
135
+ * The dismissal decision table — `Adw.BottomSheet`'s five dismissal affordances
136
+ * as one pure function, callable without owning any state.
137
+ *
138
+ * Three rows are worth reading twice, because no renderer got them right:
139
+ *
140
+ * - `('drag-handle', …)` is ALWAYS `'ignored'`. The handle is created with
141
+ * `can_focus = FALSE` + `can_target = FALSE` (adw-bottom-sheet.c:1197-1198),
142
+ * so it cannot be clicked at all; its only behavioural role is elsewhere
143
+ * (`allow_mouse_drag = show_drag_handle || bottom_bar`, adw-bottom-sheet.c:455).
144
+ * Both ports had turned it into a close BUTTON, which is the one behaviour it
145
+ * provably does not have.
146
+ * - `('escape', { open: false })` is `'close-attempt'`, not nothing. The emit in
147
+ * `maybe_close_cb` (adw-bottom-sheet.c:393-399) is the fallthrough for EVERY
148
+ * case that is not `can_close && open`, and a closed sheet is still focusable
149
+ * while it shows a bottom bar.
150
+ * - `('close-button', { open: false, canClose: true })` is `'delegate'`:
151
+ * `sheet_close_cb` (adw-bottom-sheet.c:377-385) activates the parent's
152
+ * `sheet.close` action instead of doing nothing.
153
+ *
154
+ * The `'dimming'`/`'swipe'` closed rows encode a REACHABILITY gate rather than a
155
+ * branch inside the callback: `released_cb` never tests `open`, but the scrim is
156
+ * `can_target = open` (adw-bottom-sheet.c:1148, 1692), and `prepare_cb` refuses
157
+ * to even detect a swipe unless the direction matches the state
158
+ * (adw-bottom-sheet.c:1050-1053). Neither can fire on a closed sheet, so neither
159
+ * signals anything.
160
+ */
161
+ export declare function resolveBottomSheetClose(source: BottomSheetCloseSource, state: BottomSheetCloseState): BottomSheetCloseOutcome;
162
+ /** One entry in a {@link BottomSheetPresentation}'s teardown callback pair. */
163
+ export type BottomSheetTeardownCallback = 'closing' | 'closed';
164
+ /** Subscriber for {@link BottomSheetPresentation} `open` changes. */
165
+ export type BottomSheetPresentationListener = (open: boolean) => void;
166
+ /**
167
+ * The two callbacks `AdwDialog` installs on its bottom sheet
168
+ * (`adw_bottom_sheet_set_callbacks`, adw-bottom-sheet.c:2227-2238). They are
169
+ * NOT the same event twice:
170
+ *
171
+ * - `onClosing` fires when the close STARTS — adw-dialog.c:231-240 turns it into
172
+ * the public `AdwDialog::closed` signal.
173
+ * - `onClosed` fires when the sheet has finished hiding — adw-dialog.c:243-249
174
+ * turns it into the dialog's removal from the widget tree.
175
+ */
176
+ export interface BottomSheetPresentationOptions {
177
+ /** The close started (`closing_callback`). */
178
+ onClosing?: () => void;
179
+ /** The sheet finished hiding (`closed_callback`). */
180
+ onClosed?: () => void;
181
+ }
182
+ /**
183
+ * The open/closed half of `Adw.BottomSheet` — the part with no geometry in it:
184
+ * the idempotent `open` flag, the `can-close` gate applied through
185
+ * {@link resolveBottomSheetClose}, and the `has_been_open` teardown replay.
186
+ *
187
+ * `setOpen` is the PROGRAMMATIC path and deliberately ignores `can-close`
188
+ * ("Bottom sheet can still be closed using [property@BottomSheet:open]",
189
+ * adw-bottom-sheet.c:2071); {@link requestClose} is the INTERACTIVE path that
190
+ * runs the gate. Keeping them apart is what lets a locked sheet still be closed
191
+ * by its owner — the distinction NativeScript lacked entirely (every dismissal
192
+ * went through one unconditional `close()`).
193
+ */
194
+ export declare class BottomSheetPresentation {
195
+ private _open;
196
+ private _canClose;
197
+ private _hasBeenOpen;
198
+ private readonly _listeners;
199
+ private readonly _onClosing;
200
+ private readonly _onClosed;
201
+ constructor(options?: BottomSheetPresentationOptions);
202
+ /** Subscribe to `open` changes (the `notify::open` seam). Returns an unsubscribe function. */
203
+ subscribe(listener: BottomSheetPresentationListener): () => void;
204
+ private _emit;
205
+ /** Whether the sheet is revealed (`AdwBottomSheet:open`). */
206
+ get open(): boolean;
207
+ /** Whether the user may dismiss the sheet (`AdwBottomSheet:can-close`). */
208
+ get canClose(): boolean;
209
+ /**
210
+ * Whether the sheet has ever been open. Drives the teardown replay in
211
+ * {@link setOpen}; `has_been_open` in the C source (adw-bottom-sheet.c:153).
212
+ */
213
+ get hasBeenOpen(): boolean;
214
+ /** Set `can-close`. Returns whether it changed (adw-bottom-sheet.c:2076-2091). */
215
+ setCanClose(canClose: boolean): boolean;
216
+ /**
217
+ * The programmatic open/close — `adw_bottom_sheet_set_open`
218
+ * (adw-bottom-sheet.c:1661-1778). Returns whether `open` changed, i.e.
219
+ * whether a `notify::open` was emitted.
220
+ *
221
+ * `can-close` is NOT consulted: this is the owner's path, and it is how
222
+ * `adw_dialog_force_close` closes a locked dialog (adw-dialog.c:1979-1997).
223
+ */
224
+ setOpen(open: boolean): boolean;
225
+ /**
226
+ * Route a dismissal affordance through {@link resolveBottomSheetClose} and
227
+ * APPLY the outcome — `'close'` closes the sheet, everything else leaves it
228
+ * untouched. The returned outcome tells the renderer what to emit: a
229
+ * `close-attempt` signal, a `sheet.close` forwarded to the parent, or
230
+ * nothing at all.
231
+ */
232
+ requestClose(source: BottomSheetCloseSource): BottomSheetCloseOutcome;
233
+ /**
234
+ * The sheet has finished hiding — `open_animation_done_cb`'s teardown
235
+ * (adw-bottom-sheet.c:335-349) reduced to what a renderer without a spring
236
+ * animation can observe. Fires `onClosed` and returns whether it did.
237
+ *
238
+ * The C guard is `progress < 0.5` ("settled on the closed side"); with no
239
+ * animation the settled progress IS `open`, so an open sheet fires nothing.
240
+ * Call it only after a {@link setOpen} that RETURNED TRUE — the replay branch
241
+ * has already fired both callbacks for a never-opened sheet.
242
+ */
243
+ finishClose(): boolean;
244
+ }
@@ -0,0 +1,308 @@
1
+ /** How long the empty↔filled title transition runs — adw-entry-row.c:18. */
2
+ export declare const EMPTY_ANIMATION_DURATION_MS = 150;
3
+ /**
4
+ * Gap between the shrunken title and the text baseline, in px —
5
+ * adw-entry-row.c:19 (`TITLE_SPACING`), used in the vertical measure (C:318,320)
6
+ * and in both the title offset and the baseline shift (C:384,407).
7
+ *
8
+ * Exported as DATA rather than applied here: the two renderers currently
9
+ * hardcode `1px` (web `_entry_row.scss`) and `2` (NS `theme/adwaita.css`), and
10
+ * neither knew it was meant to be the same number as the other's.
11
+ */
12
+ export declare const ENTRY_ROW_TITLE_SPACING = 3;
13
+ /**
14
+ * Upper bound of `Adw.EntryRow:max-length` / `:text-length`.
15
+ *
16
+ * `text-length` is declared `0, G_MAXUINT16, 0` (adw-entry-row.c:666-669) and
17
+ * `max-length` runs `0..GTK_ENTRY_BUFFER_MAX_SIZE` (C:678-682) — the same 16-bit
18
+ * ceiling. `0` means unlimited, so this is only the clamp for an absurd input.
19
+ */
20
+ export declare const ENTRY_ROW_MAX_LENGTH_LIMIT = 65535;
21
+ /** Icon name of the trailing pencil — adw-entry-row.ui (`edit_icon`). */
22
+ export declare const ENTRY_ROW_EDIT_ICON_NAME = "adw-entry-edit-symbolic";
23
+ /** Icon name of the apply button — adw-entry-row.ui (`apply_button`). */
24
+ export declare const ENTRY_ROW_APPLY_ICON_NAME = "adw-entry-apply-symbolic";
25
+ /** Tooltip of the apply button — adw-entry-row.ui. */
26
+ export declare const ENTRY_ROW_APPLY_TOOLTIP = "Apply";
27
+ /** Peek-button icon while the password is masked — adw-password-entry-row.c:74. */
28
+ export declare const PASSWORD_REVEAL_ICON_NAME = "view-reveal-symbolic";
29
+ /** Peek-button icon while the password is revealed — adw-password-entry-row.c:69. */
30
+ export declare const PASSWORD_CONCEAL_ICON_NAME = "view-conceal-symbolic";
31
+ /** Peek-button tooltip while the password is masked — adw-password-entry-row.c:76. */
32
+ export declare const PASSWORD_REVEAL_LABEL = "Show Password";
33
+ /** Peek-button tooltip while the password is revealed — adw-password-entry-row.c:71. */
34
+ export declare const PASSWORD_CONCEAL_LABEL = "Hide Password";
35
+ /** Caps-lock indicator icon — adw-password-entry-row.c:169. */
36
+ export declare const CAPS_LOCK_ICON_NAME = "caps-lock-symbolic";
37
+ /** Caps-lock indicator tooltip — adw-password-entry-row.c:171. */
38
+ export declare const CAPS_LOCK_TOOLTIP = "Caps Lock is on";
39
+ /**
40
+ * The number of CHARACTERS in `text`, i.e. what `adw_entry_row_get_text_length`
41
+ * reports ("The current number of characters in @self", adw-entry-row.c:1304).
42
+ *
43
+ * Code points, never UTF-16 units: a port that reaches for `.length` reports 3
44
+ * for `'🔒é'` where GTK reports 2, and then truncates a surrogate pair in half.
45
+ * This one function is why `max-length` and `text-length` cannot be left to the
46
+ * renderers.
47
+ */
48
+ export declare function entryTextLength(text: string): number;
49
+ /**
50
+ * Truncate `text` to `maxLength` CHARACTERS, with `0` meaning unlimited —
51
+ * `Adw.EntryRow:max-length` is documented as "Maximum number of characters for
52
+ * the entry" and both its default and its range floor are `0`
53
+ * (adw-entry-row.c:674 + :678-682).
54
+ *
55
+ * Split out of {@link EntryRowState} so a renderer can also apply it on an
56
+ * IME/paste path before the state sees the value.
57
+ */
58
+ export declare function clampEntryText(text: string, maxLength: number): string;
59
+ /**
60
+ * The complete render snapshot of an entry row: the five outputs of
61
+ * `update_empty` (adw-entry-row.c:149-154), the animation endpoint it drives
62
+ * (C:158-161), and the inputs a renderer echoes into CSS classes.
63
+ *
64
+ * ONE object rather than per-flag notifications so a renderer applies the whole
65
+ * derivation in a single pass and can never apply half of it.
66
+ */
67
+ export interface EntryRowRenderState {
68
+ /** The entry contents (already truncated to `maxLength`). */
69
+ text: string;
70
+ /** {@link entryTextLength} of {@link text} — `Adw.EntryRow:text-length`. */
71
+ textLength: number;
72
+ /** `empty && !(focused && editable) && !text_changed` — C:154. Drives the placeholder title. */
73
+ empty: boolean;
74
+ /** Whether the embedded entry has focus — C:181. Renderers mirror it as the `focused` state class (C:183-186). */
75
+ editing: boolean;
76
+ /** Whether the embedded entry accepts edits (`GtkEditable:editable`). */
77
+ editable: boolean;
78
+ /** The pending-apply latch — C:170-172. */
79
+ textChanged: boolean;
80
+ /** `!text_changed && (!editing || !editable)` — C:149. */
81
+ editIconVisible: boolean;
82
+ /** `editable` — C:150. The pencil stays VISIBLE but goes insensitive on a read-only row. */
83
+ editIconSensitive: boolean;
84
+ /** `editing && show_indicator` — C:151. */
85
+ indicatorVisible: boolean;
86
+ /** `text_changed` — C:152. */
87
+ applyButtonVisible: boolean;
88
+ /**
89
+ * Where the empty↔filled transition is headed: `0` while {@link empty}, `1`
90
+ * otherwise — C:160-161. The renderer animates its OWN progress toward this
91
+ * over {@link EMPTY_ANIMATION_DURATION_MS}, starting from wherever the
92
+ * progress currently is (C:158-159 sets `value_from` to the live value), so
93
+ * an interrupted transition resumes instead of restarting.
94
+ */
95
+ emptyTarget: 0 | 1;
96
+ }
97
+ /**
98
+ * Per-instance subscriber for {@link EntryRowState}. Matches the
99
+ * `ExpanderState`/`ToggleGroupState` shape in rows.ts — the change carries no
100
+ * `interactive` flag, see the module header for why.
101
+ */
102
+ export type EntryRowStateListener = (state: EntryRowRenderState) => void;
103
+ /**
104
+ * What <kbd>Enter</kbd> resolves to. A discriminated union because
105
+ * `text_activated_cb` (adw-entry-row.c:243-266) emits exactly ONE of the two
106
+ * signals, never both; `activateDefault` carries the ordering requirement that
107
+ * the default widget is activated BEFORE `entry-activated` is emitted (the
108
+ * `gtk_widget_activate_default` call is C:254, the `g_signal_emit` is C:256).
109
+ */
110
+ export type EntryRowActivation = {
111
+ signal: 'apply';
112
+ } | {
113
+ signal: 'entry-activated';
114
+ activateDefault: boolean;
115
+ };
116
+ /**
117
+ * `Adw.EntryRow`'s derivation, headless: the `update_empty` truth table, the
118
+ * `text_changed` latch with both of its reset paths, character-counted
119
+ * max-length truncation, and the two-way <kbd>Enter</kbd> dispatch.
120
+ *
121
+ * The setter guards are NOT uniform, and that is faithful rather than sloppy:
122
+ * {@link setShowApplyButton} early-outs on an unchanged value and retracts a
123
+ * pending latch when turned off (C:982-995), while {@link setShowIndicator}
124
+ * deliberately has NO equality guard and always re-derives (C:1281-1296) — it is
125
+ * the private `adw-entry-row-private.h` hook the password row drives, not a
126
+ * public property, which is why it returns `void`.
127
+ */
128
+ export declare class EntryRowState {
129
+ private _text;
130
+ private _maxLength;
131
+ private _editing;
132
+ private _editable;
133
+ private _showApplyButton;
134
+ private _showIndicator;
135
+ private _textChanged;
136
+ private _activatesDefault;
137
+ private readonly _listeners;
138
+ /** Subscribe to render-state changes. Returns an unsubscribe function. */
139
+ subscribe(listener: EntryRowStateListener): () => void;
140
+ /** Re-run `update_empty` and push the fresh snapshot to every subscriber. */
141
+ private _update;
142
+ /** The current render snapshot — `update_empty`'s outputs, freshly derived. */
143
+ get state(): EntryRowRenderState;
144
+ /** The entry contents. */
145
+ get text(): string;
146
+ /**
147
+ * Set the contents (truncated to {@link maxLength}) and run the latch +
148
+ * derivation, exactly as the buffer's `changed` signal does — C:166-174.
149
+ *
150
+ * Idempotent on an identical value. GTK routes this through GtkEntryBuffer,
151
+ * whose emission for a same-value set is a GtkText internal this checkout
152
+ * has no source for (`refs/gtk` is empty), so the headless contract is the
153
+ * house convention — and it is what a renderer's `input`/`textChange` event
154
+ * produces anyway, since neither platform fires one without a real edit.
155
+ *
156
+ * Returns whether the text changed.
157
+ */
158
+ setText(text: string): boolean;
159
+ /** `text_changed_cb` — latch iff the apply button is armed AND we are editing (C:170-171), then re-derive (C:173). */
160
+ private _latchAndUpdate;
161
+ /** {@link entryTextLength} of the contents — `Adw.EntryRow:text-length` (C:1308-1318). */
162
+ get textLength(): number;
163
+ /** Maximum number of CHARACTERS, `0` = unlimited (C:674, :678-682). */
164
+ get maxLength(): number;
165
+ /**
166
+ * Set the maximum length, clamped into `[0, ENTRY_ROW_MAX_LENGTH_LIMIT]`
167
+ * (C:678-682). Over-long contents are truncated immediately, which runs the
168
+ * same latch + derivation a buffer edit does.
169
+ *
170
+ * Returns whether the property changed. Upstream emits NO `notify` here
171
+ * (there is no `g_object_notify_by_pspec` in C:1329-1343) — pinned by a
172
+ * vector so a port does not "helpfully" add one.
173
+ */
174
+ setMaxLength(maxLength: number): boolean;
175
+ /** Whether the embedded entry has focus — `priv->editing` (C:181). */
176
+ get editing(): boolean;
177
+ /** Feed the focus state in and re-derive — `text_state_flags_changed_cb` (C:176-189). Returns whether it changed. */
178
+ setEditing(editing: boolean): boolean;
179
+ /** Whether the embedded entry accepts edits (`GtkEditable:editable`). */
180
+ get editable(): boolean;
181
+ /** Set editability and re-derive — the `notify::editable` → `update_empty` binding in adw-entry-row.ui. Returns whether it changed. */
182
+ setEditable(editable: boolean): boolean;
183
+ /** Whether typing reveals an apply button — `Adw.EntryRow:show-apply-button`. */
184
+ get showApplyButton(): boolean;
185
+ /**
186
+ * Arm/disarm the apply button (C:982-995). Turning it OFF retracts a pending
187
+ * apply (C:989-992); turning it ON changes no derived output, which is why
188
+ * the C re-derives only in the retract branch.
189
+ *
190
+ * Returns whether the property changed — the caller's cue to re-emit
191
+ * `notify::show-apply-button`.
192
+ */
193
+ setShowApplyButton(show: boolean): boolean;
194
+ /**
195
+ * The private indicator hook — `adw_entry_row_set_show_indicator`
196
+ * (adw-entry-row-private.h, C:1281-1296). `void` and UNGUARDED on purpose:
197
+ * the C assigns and calls `update_empty` unconditionally, with no equality
198
+ * check, so a redundant call still re-derives and still notifies.
199
+ *
200
+ * `Adw.PasswordEntryRow` is the only caller upstream; a renderer reaches it
201
+ * through {@link PasswordEntryRowState}.
202
+ */
203
+ setShowIndicator(show: boolean): void;
204
+ /** Whether <kbd>Enter</kbd> may activate the default widget — `Adw.EntryRow:activates-default`. */
205
+ get activatesDefault(): boolean;
206
+ /**
207
+ * Set `activates-default` (C:1238-1253). Returns whether it changed — the
208
+ * caller's cue to re-emit `notify::activates-default`.
209
+ *
210
+ * The C compares the raw `gboolean` because GValue already normalised it;
211
+ * a JS caller has no such guarantee, so coerce first.
212
+ */
213
+ setActivatesDefault(value: boolean): boolean;
214
+ /** The pending-apply latch (C:170-172) — `true` while the apply button is showing. */
215
+ get textChanged(): boolean;
216
+ /**
217
+ * Clear the latch and re-derive — `apply_button_clicked_cb` (C:237-238). The
218
+ * renderer emits `apply` right after (C:240); focus handling (C:234-235) is
219
+ * a platform concern and stays there.
220
+ */
221
+ apply(): void;
222
+ /**
223
+ * <kbd>Enter</kbd> — `text_activated_cb` (C:243-266). Dispatches to the
224
+ * apply path when the apply button is showing (C:248-249), otherwise reports
225
+ * `entry-activated` plus whether the default widget must be activated FIRST
226
+ * (C:253-256).
227
+ *
228
+ * The `GtkActionable` action fired afterwards (C:258-264) has no headless
229
+ * equivalent and stays with the renderer.
230
+ */
231
+ activate(): EntryRowActivation;
232
+ }
233
+ /**
234
+ * The render snapshot of a password entry row: `notify_visibility_cb`'s icon +
235
+ * tooltip pair (adw-password-entry-row.c:62-81) plus the caps-lock inputs, as
236
+ * data.
237
+ *
238
+ * The icon names and English strings are the literals from the C source, so the
239
+ * two renderers stop inventing their own spellings (`revealed` vs `peeking`,
240
+ * `view-reveal` vs `viewRevealSymbolic`) and a renderer can map ONE canonical
241
+ * name onto whatever asset it actually ships.
242
+ */
243
+ export interface PasswordEntryRowRenderState {
244
+ /** Whether the contents are shown in clear text (`GtkText:visibility`). */
245
+ revealed: boolean;
246
+ /** Whether the keyboard reports Caps Lock engaged (`gdk_device_get_caps_lock_state`). */
247
+ capsLockOn: boolean;
248
+ /** Icon the peek button shows — C:68,73. */
249
+ peekIconName: typeof PASSWORD_REVEAL_ICON_NAME | typeof PASSWORD_CONCEAL_ICON_NAME;
250
+ /** Tooltip/accessible label of the peek button — C:71,76. */
251
+ peekLabel: typeof PASSWORD_REVEAL_LABEL | typeof PASSWORD_CONCEAL_LABEL;
252
+ /** Icon of the caps-lock indicator — C:169. Constant, exposed so a renderer reads one object. */
253
+ indicatorIconName: typeof CAPS_LOCK_ICON_NAME;
254
+ /** Tooltip of the caps-lock indicator — C:171. */
255
+ indicatorTooltip: typeof CAPS_LOCK_TOOLTIP;
256
+ }
257
+ /** Per-instance subscriber for {@link PasswordEntryRowState}. */
258
+ export type PasswordEntryRowStateListener = (state: PasswordEntryRowRenderState) => void;
259
+ /**
260
+ * `Adw.PasswordEntryRow`'s extra behaviour, headless: the reveal/conceal pair
261
+ * and the caps-lock warning with BOTH of its suppression rules.
262
+ *
263
+ * COMPOSES an {@link EntryRowState} rather than extending it, mirroring the C:
264
+ * `AdwPasswordEntryRow` is a subclass but reaches its parent through the private
265
+ * `adw_entry_row_set_show_indicator` hook, not a protected field. Composition
266
+ * also keeps `EntryRowState` usable on its own for a plain entry row.
267
+ *
268
+ * Every reveal/caps-lock change recomputes `!revealed && capsLockOn` and pushes
269
+ * it into the entry (C:57-59) — which is why peeking makes the caps-lock warning
270
+ * disappear. The second suppression is the entry's own (`editing && show_indicator`,
271
+ * C:151): the warning only shows while the entry has focus. Focus changes
272
+ * therefore need no push from here — they re-derive on the entry side, which is
273
+ * what `notify_has_focus_cb` (C:83-88) achieves by re-running `update_caps_lock`.
274
+ */
275
+ export declare class PasswordEntryRowState {
276
+ private readonly _entry;
277
+ private _revealed;
278
+ private _capsLockOn;
279
+ private readonly _listeners;
280
+ constructor(entry: EntryRowState);
281
+ /** Subscribe to peek/caps-lock changes. Returns an unsubscribe function. */
282
+ subscribe(listener: PasswordEntryRowStateListener): () => void;
283
+ private _emit;
284
+ /** The current render snapshot — `notify_visibility_cb`'s derivation (C:62-81). */
285
+ get state(): PasswordEntryRowRenderState;
286
+ /** Whether the contents are shown in clear text. */
287
+ get revealed(): boolean;
288
+ /**
289
+ * Set the peek state. Early-outs on an unchanged value — every settable
290
+ * property in this family does (C:984, :1198, :1247), which is why the web
291
+ * port's unguarded `notify::revealed` on a redundant `setAttribute` is a
292
+ * defect and not a style choice.
293
+ *
294
+ * Returns whether it changed.
295
+ */
296
+ setRevealed(revealed: boolean): boolean;
297
+ /** Flip masked↔revealed — `show_text_clicked_cb` (C:94-96). Returns whether it changed. */
298
+ togglePeek(): boolean;
299
+ /** Whether Caps Lock is engaged. */
300
+ get capsLockOn(): boolean;
301
+ /**
302
+ * Feed the keyboard's caps-lock state in — the `notify::caps-lock-state`
303
+ * handler (C:111-115). Returns whether it changed.
304
+ */
305
+ setCapsLockOn(on: boolean): boolean;
306
+ /** `update_caps_lock` — C:57-59. */
307
+ private _pushIndicator;
308
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * GLib's `g_strstrip` — trim ASCII whitespace from both ends, and ONLY ASCII
3
+ * whitespace.
4
+ *
5
+ * NOT `String.prototype.trim()`, which also eats U+00A0 NBSP, U+FEFF and the
6
+ * Unicode space separators. Two widgets already depend on the difference:
7
+ * `Adw.Avatar` derives its initials from the stripped name, so a name that
8
+ * starts with U+00A0 keeps the NBSP as its initial in GTK, where a
9
+ * `trim()`-based port yields the first LETTER instead; and
10
+ * `Adw.AboutDialog`'s `parse_person` (adw-about-dialog.c:533) strips the credit
11
+ * name the same way, so an NBSP-padded contributor name keeps its padding.
12
+ */
13
+ export declare function gStrStrip(value: string): string;
14
+ /**
15
+ * libadwaita's `string_is_not_empty` template closure — the predicate EVERY
16
+ * Adwaita label binds its `visible` property to.
17
+ *
18
+ * `return string && string[0];` — verbatim in six widgets that each declare
19
+ * their own private copy (`adw-action-row.c:112-117`, `adw-button-row.c:92-97`,
20
+ * `adw-sidebar.c`, `adw-shortcut-row.c`, `adw-status-page.c`,
21
+ * `adw-toast-widget.c`), bound from the matching `.ui`
22
+ * (`adw-action-row.ui:49-53` for the title, `:71-75` for the subtitle).
23
+ *
24
+ * Two properties of it are load-bearing and are what a hand-rolled copy gets
25
+ * wrong: only the EXACT empty string (and NULL) is false — one space is a
26
+ * visible label, because the C never trims — and the rule applies to the TITLE
27
+ * as much as to the subtitle. Every port so far hid an empty subtitle and left
28
+ * an empty title occupying a line.
29
+ */
30
+ export declare function stringIsNotEmpty(value: string | null | undefined): boolean;
31
+ /**
32
+ * GLib's `CLAMP`, which tests the HIGH bound FIRST:
33
+ * `x > high ? high : (x < low ? low : x)`.
34
+ *
35
+ * NOT interchangeable with `Math.min(high, Math.max(low, x))` — the two disagree
36
+ * whenever the bounds are inverted, and Adwaita reaches inverted bounds for
37
+ * real: a split view's sidebar caps invert whenever the content minimum exceeds
38
+ * what is left of the width.
39
+ */
40
+ export declare function glibClamp(x: number, low: number, high: number): number;
41
+ /**
42
+ * Drop GTK mnemonic markers from a label (`gtk_label_new_with_mnemonic`).
43
+ *
44
+ * A single `_` marks the character after it and is itself removed; `__` is an
45
+ * escaped literal underscore. A renderer with no accelerator layer wants the
46
+ * plain text, which is what this returns — GTK would underline the marked
47
+ * character instead.
48
+ */
49
+ export declare function stripMnemonic(text: string): string;