@gjsify/adwaita-app 0.38.1 → 0.40.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 +5 -1
- package/lib/esm/dialog-model.js +1 -0
- package/lib/esm/dialogs.js +1 -1
- package/lib/types/dialog-model.d.ts +16 -0
- package/lib/types/dialog-model.spec.d.ts +2 -0
- package/lib/types/dialogs.d.ts +9 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/types.d.ts +2 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -87,7 +87,11 @@ promise-job queue under `run()`).
|
|
|
87
87
|
|
|
88
88
|
### Interaction helpers
|
|
89
89
|
|
|
90
|
-
- `confirmDialog(parent, { heading, body?, confirmLabel?, cancelLabel?, destructive? }): Promise<boolean>`
|
|
90
|
+
- `confirmDialog(parent, { heading, body?, confirmLabel?, cancelLabel?, destructive?, defaultResponse? }): Promise<boolean>`
|
|
91
|
+
— `defaultResponse` (`'confirm' | 'cancel'`, default `'confirm'`) picks the
|
|
92
|
+
response Enter activates. A destructive question wants both: `destructive: true`
|
|
93
|
+
for the red button and `defaultResponse: 'cancel'` so the reflex keystroke
|
|
94
|
+
escapes instead of deleting. An id that is neither throws a `TypeError`.
|
|
91
95
|
- `errorDialog(parent, heading, body?): Promise<void>`
|
|
92
96
|
- `registerToastOverlay(overlay)` + `showToast(title, timeout?)`
|
|
93
97
|
- `pickFile(parent, { title?, filters? }): Promise<string | null>` /
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";function isConfirmResponse(e){return e===`confirm`||e===`cancel`}function resolveDefaultResponse(e){if(e===void 0)return`confirm`;if(!isConfirmResponse(e))throw TypeError(`@gjsify/adwaita-app: confirmDialog defaultResponse must be 'confirm' or 'cancel', got ${JSON.stringify(e)}`);return e}export{resolveDefaultResponse};
|
package/lib/esm/dialogs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import e from"@girs/adw-1";function confirmDialog(
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{resolveDefaultResponse as e}from"./dialog-model.js";import t from"@girs/adw-1";function confirmDialog(n,r){let i=e(r.defaultResponse);return new Promise(e=>{let a=new t.AlertDialog({heading:r.heading,body:r.body??``});a.add_response(`cancel`,r.cancelLabel??`Cancel`),a.add_response(`confirm`,r.confirmLabel??`OK`),a.set_response_appearance(`confirm`,r.destructive?t.ResponseAppearance.DESTRUCTIVE:t.ResponseAppearance.SUGGESTED),a.set_default_response(i),a.set_close_response(`cancel`),a.connect(`response`,(t,n)=>e(n===`confirm`)),a.present(n)})}function errorDialog(e,n,r){return new Promise(i=>{let a=new t.AlertDialog({heading:n,body:r??``});a.add_response(`ok`,`OK`),a.set_default_response(`ok`),a.set_close_response(`ok`),a.connect(`response`,()=>i()),a.present(e)})}export{confirmDialog,errorDialog};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConfirmResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve which response a confirm dialog opens focused on — the one Enter picks.
|
|
4
|
+
*
|
|
5
|
+
* Falls back to `confirm`, which is what every caller of the option-less API
|
|
6
|
+
* already gets; changing that default would change published behaviour under
|
|
7
|
+
* consumers who never asked for it.
|
|
8
|
+
*
|
|
9
|
+
* The id is checked at RUNTIME, not just by the union: the type is erased, and
|
|
10
|
+
* `adw_alert_dialog_set_default_response()` takes any string — an id matching no
|
|
11
|
+
* response stores the quark and never touches the default widget, so a typo
|
|
12
|
+
* ships as a dialog where Enter quietly does nothing.
|
|
13
|
+
*
|
|
14
|
+
* @throws TypeError for an id the dialog has no response for.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveDefaultResponse(requested?: string): ConfirmResponse;
|
package/lib/types/dialogs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type Gtk from '@girs/gtk-4.0';
|
|
2
|
+
import type { ConfirmResponse } from './types.js';
|
|
2
3
|
/** Options for {@link confirmDialog}. */
|
|
3
4
|
export interface ConfirmOptions {
|
|
4
5
|
/** Dialog heading. */
|
|
@@ -11,6 +12,14 @@ export interface ConfirmOptions {
|
|
|
11
12
|
cancelLabel?: string;
|
|
12
13
|
/** Style the confirm button as destructive (red) instead of suggested. */
|
|
13
14
|
destructive?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Response the dialog opens focused on, so Enter activates it. Default `confirm`.
|
|
17
|
+
*
|
|
18
|
+
* Pair `cancel` with `destructive`: what makes a "really delete this?" dialog
|
|
19
|
+
* worth showing is the accidental gesture, and a `confirm` default hands the
|
|
20
|
+
* reflex of dismissing a dialog with Enter the deletion instead of the escape.
|
|
21
|
+
*/
|
|
22
|
+
defaultResponse?: ConfirmResponse;
|
|
14
23
|
}
|
|
15
24
|
/**
|
|
16
25
|
* Present a confirm/cancel `Adw.AlertDialog`; resolves `true` on confirm, `false`
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export type { FileFilterSpec, PickFileOptions } from './file-dialog.js';
|
|
|
13
13
|
export { readAppDevHooks } from './dev-hooks.js';
|
|
14
14
|
export type { AppDevHooks, ReadAppDevHooksOptions } from './dev-hooks.js';
|
|
15
15
|
export { findNavItem, resolveInitialNavIndex } from './nav-model.js';
|
|
16
|
-
export type { AboutInfo, NavItem } from './types.js';
|
|
16
|
+
export type { AboutInfo, ConfirmResponse, NavItem } from './types.js';
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The two response ids a `confirmDialog` adds to its `Adw.AlertDialog`. */
|
|
2
|
+
export type ConfirmResponse = 'confirm' | 'cancel';
|
|
1
3
|
/** A single entry in the navigation sidebar / view stack. */
|
|
2
4
|
export interface NavItem {
|
|
3
5
|
/** Stable id used as the `Gtk.Stack` child name and for `selectById`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/adwaita-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Native Adwaita application shell for GJS/GTK apps — Adw.Application lifecycle (runAsync + devtools + CSS), a data-driven NavigationSplitView nav shell, an async-view mounter, and promise dialog/toast/file helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@girs/glib-2.0": "^4.1.0",
|
|
47
47
|
"@girs/gobject-2.0": "^4.1.0",
|
|
48
48
|
"@girs/gtk-4.0": "^4.1.0",
|
|
49
|
-
"@gjsify/devtools": "^0.
|
|
49
|
+
"@gjsify/devtools": "^0.40.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@gjsify/cli": "^0.
|
|
53
|
-
"@gjsify/storybook": "^0.
|
|
54
|
-
"@gjsify/unit": "^0.
|
|
52
|
+
"@gjsify/cli": "^0.40.0",
|
|
53
|
+
"@gjsify/storybook": "^0.40.0",
|
|
54
|
+
"@gjsify/unit": "^0.40.0",
|
|
55
55
|
"@types/node": "^25.9.2",
|
|
56
56
|
"typescript": "^6.0.3"
|
|
57
57
|
},
|