@g9tm/lynxcontrols 2.8.4 → 2.10.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 +1 -0
- package/catalog/cards/G9Avatar.md +1 -1
- package/catalog/cards/G9Badge.md +1 -1
- package/catalog/cards/G9Button.md +1 -1
- package/catalog/cards/G9Chip.md +1 -1
- package/catalog/cards/G9ChipStrip.md +1 -1
- package/catalog/cards/G9ContextMenu.md +4 -2
- package/catalog/cards/G9DockLayout.md +17 -0
- package/catalog/cards/G9DragChip.md +10 -0
- package/catalog/cards/G9DragSource.md +17 -0
- package/catalog/cards/G9DropTarget.md +15 -0
- package/catalog/cards/G9EmptyState.md +1 -1
- package/catalog/cards/G9IconButton.md +2 -2
- package/catalog/cards/G9InlineMessage.md +1 -1
- package/catalog/cards/G9KeyCapture.md +10 -0
- package/catalog/cards/G9KeyDiamond.md +15 -0
- package/catalog/cards/G9KeySlider.md +17 -0
- package/catalog/cards/G9Kpi.md +1 -1
- package/catalog/cards/G9ListRow.md +1 -1
- package/catalog/cards/G9LiveBadge.md +1 -1
- package/catalog/cards/G9LiveDot.md +1 -1
- package/catalog/cards/G9ProgressBar.md +1 -1
- package/catalog/cards/G9ProgressRing.md +1 -1
- package/catalog/cards/G9SafeButton.md +1 -1
- package/catalog/cards/G9SafeIconButton.md +2 -2
- package/catalog/cards/G9StatusPill.md +1 -1
- package/catalog/cards/G9StepTracker.md +1 -1
- package/catalog/cards/G9SwitchRow.md +1 -1
- package/catalog/cards/G9Tag.md +1 -1
- package/catalog/catalog.json +2391 -192
- package/catalog/index.md +9 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.jsx +1 -1
- package/dist/commands/keys.d.ts +32 -1
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.jsx +92 -3
- package/dist/desktop/index.d.ts +3 -0
- package/dist/desktop/index.d.ts.map +1 -0
- package/dist/desktop/index.jsx +2 -0
- package/dist/desktop/keys.d.ts +26 -0
- package/dist/desktop/keys.d.ts.map +1 -0
- package/dist/desktop/keys.jsx +30 -0
- package/dist/desktop/window.d.ts +18 -0
- package/dist/desktop/window.d.ts.map +1 -0
- package/dist/desktop/window.jsx +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/layout/dock.css +90 -0
- package/dist/layout/dock.css.map +1 -0
- package/dist/layout/dock.d.ts +86 -0
- package/dist/layout/dock.d.ts.map +1 -0
- package/dist/layout/dock.jsx +272 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.jsx +1 -0
- package/dist/pointer/drag-session.d.ts +72 -0
- package/dist/pointer/drag-session.d.ts.map +1 -0
- package/dist/pointer/drag-session.jsx +148 -0
- package/dist/pointer/drag.d.ts +78 -0
- package/dist/pointer/drag.d.ts.map +1 -0
- package/dist/pointer/drag.jsx +186 -0
- package/dist/pointer/index.d.ts +6 -0
- package/dist/pointer/index.d.ts.map +1 -0
- package/dist/pointer/index.jsx +5 -0
- package/dist/pointer/pad.d.ts +57 -0
- package/dist/pointer/pad.d.ts.map +1 -0
- package/dist/pointer/pad.jsx +111 -0
- package/dist/pointer/point.d.ts +36 -0
- package/dist/pointer/point.d.ts.map +1 -0
- package/dist/pointer/point.jsx +34 -0
- package/dist/pointer/pointer.css +62 -0
- package/dist/pointer/pointer.css.map +1 -0
- package/dist/pointer/secondary.d.ts +54 -0
- package/dist/pointer/secondary.d.ts.map +1 -0
- package/dist/pointer/secondary.jsx +86 -0
- package/dist/popover/popover.d.ts +26 -2
- package/dist/popover/popover.d.ts.map +1 -1
- package/dist/popover/popover.jsx +47 -20
- package/dist/range-slider/index.d.ts +1 -0
- package/dist/range-slider/index.d.ts.map +1 -1
- package/dist/range-slider/index.jsx +1 -0
- package/dist/range-slider/key-slider.d.ts +50 -0
- package/dist/range-slider/key-slider.d.ts.map +1 -0
- package/dist/range-slider/key-slider.jsx +51 -0
- package/dist/range-slider/range-slider.css +48 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.d.ts +16 -0
- package/dist/range-slider/range-slider.d.ts.map +1 -1
- package/dist/range-slider/range-slider.jsx +26 -10
- package/package.json +12 -2
- package/skills/g9-lynx-app/SKILL.md +8 -0
- package/skills/g9-lynx-app/references/catalog-index.md +22 -2
- package/skills/g9-lynx-app/references/components/button.md +6 -6
- package/skills/g9-lynx-app/references/components/code-editor.md +19 -0
- package/skills/g9-lynx-app/references/components/code-log.md +19 -0
- package/skills/g9-lynx-app/references/components/datagrid.md +3 -3
- package/skills/g9-lynx-app/references/components/desktop.md +12 -0
- package/skills/g9-lynx-app/references/components/display-1.md +4 -4
- package/skills/g9-lynx-app/references/components/display-2.md +5 -5
- package/skills/g9-lynx-app/references/components/display-3.md +3 -3
- package/skills/g9-lynx-app/references/components/graph.md +19 -0
- package/skills/g9-lynx-app/references/components/layout-1.md +18 -18
- package/skills/g9-lynx-app/references/components/layout-2.md +18 -0
- package/skills/g9-lynx-app/references/components/list.md +2 -2
- package/skills/g9-lynx-app/references/components/media-1.md +7 -7
- package/skills/g9-lynx-app/references/components/pointer.md +46 -0
- package/skills/g9-lynx-app/references/components/popover.md +4 -2
- package/skills/g9-lynx-app/references/components/projects.md +1 -1
- package/skills/g9-lynx-app/references/components/range-slider.md +34 -0
- package/skills/g9-lynx-app/references/components/studio-color-picker.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-ease-editor.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-filmstrip.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-font-picker.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-gradient-editor.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-history-list.md +34 -0
- package/skills/g9-lynx-app/references/components/studio-media-slot.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-option-form.md +19 -0
- package/skills/g9-lynx-app/references/components/studio-waveform.md +19 -0
- package/skills/g9-lynx-app/references/components/toggle.md +2 -2
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { dispatchG9Key, type G9KeyDeliver, registerG9KeySource, useG9KeySequence, useG9Keys, useG9Shortcut, } from './keys.js';
|
|
1
|
+
export { dispatchG9Key, type G9KeyDeliver, type G9ShortcutsOptions, g9HeldModifiers, g9KeyPlatform, noteG9ModifierKey, registerG9KeySource, setG9HeldModifiers, useG9KeySequence, useG9Keys, useG9Shortcut, useG9Shortcuts, } from './keys.js';
|
|
2
2
|
export { type G9Command, type G9CommandAbortSignal, type G9CommandGroup, G9CommandPalette, type G9CommandPaletteProps, type G9CommandProvider, type G9ShortcutGroup, type G9ShortcutItem, G9ShortcutList, type G9ShortcutListProps, G9ShortcutsSheet, type G9ShortcutsSheetProps, paletteResults, rankCommands, } from './palette.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,cAAc,GACf,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC"}
|
package/dist/commands/index.jsx
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { dispatchG9Key, registerG9KeySource, useG9KeySequence, useG9Keys, useG9Shortcut } from "./keys.jsx";
|
|
1
|
+
export { dispatchG9Key, g9HeldModifiers, g9KeyPlatform, noteG9ModifierKey, registerG9KeySource, setG9HeldModifiers, useG9KeySequence, useG9Keys, useG9Shortcut, useG9Shortcuts } from "./keys.jsx";
|
|
2
2
|
export { G9CommandPalette, G9ShortcutList, G9ShortcutsSheet, paletteResults, rankCommands } from "./palette.jsx";
|
package/dist/commands/keys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type G9KeyEvent } from '@g9tm/lynxcontrols-foundation';
|
|
1
|
+
import { type G9HeldModifiers, type G9KeyEvent } from '@g9tm/lynxcontrols-foundation';
|
|
2
2
|
/**
|
|
3
3
|
* What a key source hands the library: the raw key (a `G9KeyEvent`-shaped object or a key name) and whether it came
|
|
4
4
|
* from inside a text field. Answers whether a handler took it (the host then stops the native default).
|
|
@@ -10,6 +10,15 @@ export type G9KeyDeliver = (raw: unknown, field?: boolean) => boolean;
|
|
|
10
10
|
* `useG9Keys` / `useG9Shortcut` hears them. `connect(deliver)` returns its disconnect; the returned function removes it.
|
|
11
11
|
*/
|
|
12
12
|
export declare function registerG9KeySource(connect: (deliver: G9KeyDeliver) => (() => void) | void): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* The modifier keys held now (2.9.0): what the host last said (`g9modifiers`, or a key capture's keydown / keyup) and the
|
|
15
|
+
* flags of the last key. Lynx pointer events carry no modifier flags; Shift+click and Ctrl+click read this.
|
|
16
|
+
*/
|
|
17
|
+
export declare function g9HeldModifiers(): G9HeldModifiers;
|
|
18
|
+
/** Sets the held modifiers (a host bridge, `G9KeyCapture`, tests); a partial update keeps the others, null clears all. */
|
|
19
|
+
export declare function setG9HeldModifiers(next: Partial<G9HeldModifiers> | null): void;
|
|
20
|
+
/** A modifier key itself went down or up (`'Shift'`, `'Control'`, `'Alt'`, `'Meta'`); false for any other key. */
|
|
21
|
+
export declare function noteG9ModifierKey(key: string, down: boolean): boolean;
|
|
13
22
|
/**
|
|
14
23
|
* Delivers a key to the handler stack (exported for hosts that call it directly, and for tests). Answers whether a
|
|
15
24
|
* handler took it.
|
|
@@ -33,4 +42,26 @@ export declare function useG9Shortcut(combo: string | readonly string[], action:
|
|
|
33
42
|
export declare function useG9KeySequence(sequences: readonly string[], onMatch: (sequence: string) => void, options?: {
|
|
34
43
|
readonly enabled?: boolean;
|
|
35
44
|
}): void;
|
|
45
|
+
/** Options of {@link useG9Shortcuts}. */
|
|
46
|
+
export interface G9ShortcutsOptions {
|
|
47
|
+
/** Default true. */
|
|
48
|
+
readonly enabled?: boolean;
|
|
49
|
+
/** `'mac'` maps Mod to ⌘; default: the platform the app runs on (`SystemInfo.platform`). */
|
|
50
|
+
readonly platform?: 'mac' | 'other';
|
|
51
|
+
/**
|
|
52
|
+
* The combos that also fire while a text field has the focus (`['Esc', 'Mod+K']`). Default none: a focused field keeps
|
|
53
|
+
* its own keys (Delete, Ctrl+Z, the arrows), as a desktop app does.
|
|
54
|
+
*/
|
|
55
|
+
readonly inFields?: readonly string[];
|
|
56
|
+
/** Fire while the key repeats (held down). Default false. */
|
|
57
|
+
readonly repeat?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** The platform for Mod (⌘ on macOS, Ctrl elsewhere), from `SystemInfo.platform`. */
|
|
60
|
+
export declare function g9KeyPlatform(): 'mac' | 'other';
|
|
61
|
+
/**
|
|
62
|
+
* A desktop app's shortcuts in one map (2.9.0, G9ProxyManager): `{ 'Mod+K': openPalette, 'Mod+1': goHome, 'Delete':
|
|
63
|
+
* removeSelected, 'Esc': clear, 'Mod+Alt+F': find }`. The first combo that matches runs and the key stops there. A key
|
|
64
|
+
* typed in a text field reaches only the combos listed in `inFields`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function useG9Shortcuts(map: Readonly<Record<string, (e: G9KeyEvent) => void>>, options?: G9ShortcutsOptions): void;
|
|
36
67
|
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/commands/keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/commands/keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,UAAU,EAMhB,MAAM,+BAA+B,CAAC;AA6BvC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,IAAI,CAYvG;AAKD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,eAAe,CAEjD;AAED,0HAA0H;AAC1H,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,GAAG,IAAI,CAE9E;AASD,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAKrE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAiBxD;AA2BD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,GAAG,IAAI,EAC1C,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CA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AAI,CAyBN"}
|
package/dist/commands/keys.jsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { createSequenceMatcher, g9FieldKeyEventName, g9KeyEventName, matchesCombo } from "@g9tm/lynxcontrols-foundation";
|
|
1
|
+
import { createSequenceMatcher, g9FieldKeyEventName, g9KeyEventName, g9ModifiersEventName, matchesCombo, parseCombo } from "@g9tm/lynxcontrols-foundation";
|
|
2
2
|
import { useEffect, useMemo, useRef } from "@lynx-js/react";
|
|
3
3
|
import { useStableCallback } from "../base/use-stable-callback.jsx";
|
|
4
4
|
import { addGlobalListener } from "../provider/global-events.jsx";
|
|
5
5
|
const stack = [];
|
|
6
6
|
let uninstall = null;
|
|
7
|
-
function normalize(
|
|
7
|
+
function normalize(input, field) {
|
|
8
|
+
const raw = Array.isArray(input) && 1 === input.length ? input[0] : input;
|
|
8
9
|
if (!raw || 'object' != typeof raw) return 'string' == typeof raw ? {
|
|
9
10
|
key: raw,
|
|
10
11
|
field
|
|
@@ -52,7 +53,43 @@ function registerG9KeySource(connect) {
|
|
|
52
53
|
if ('function' == typeof off) off();
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
const NONE = Object.freeze({
|
|
57
|
+
shift: false,
|
|
58
|
+
ctrl: false,
|
|
59
|
+
alt: false,
|
|
60
|
+
meta: false
|
|
61
|
+
});
|
|
62
|
+
let held = NONE;
|
|
63
|
+
function g9HeldModifiers() {
|
|
64
|
+
return held;
|
|
65
|
+
}
|
|
66
|
+
function setG9HeldModifiers(next) {
|
|
67
|
+
held = next ? {
|
|
68
|
+
...held,
|
|
69
|
+
...next
|
|
70
|
+
} : NONE;
|
|
71
|
+
}
|
|
72
|
+
const MODIFIER_KEYS = {
|
|
73
|
+
Shift: 'shift',
|
|
74
|
+
Control: 'ctrl',
|
|
75
|
+
Alt: 'alt',
|
|
76
|
+
Meta: 'meta'
|
|
77
|
+
};
|
|
78
|
+
function noteG9ModifierKey(key, down) {
|
|
79
|
+
const name = MODIFIER_KEYS[key];
|
|
80
|
+
if (!name) return false;
|
|
81
|
+
setG9HeldModifiers({
|
|
82
|
+
[name]: down
|
|
83
|
+
});
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
55
86
|
function dispatchG9Key(event) {
|
|
87
|
+
held = {
|
|
88
|
+
shift: true === event.shift,
|
|
89
|
+
ctrl: true === event.ctrl,
|
|
90
|
+
alt: true === event.alt,
|
|
91
|
+
meta: true === event.meta
|
|
92
|
+
};
|
|
56
93
|
for(let i = stack.length - 1; i >= 0; i--){
|
|
57
94
|
const h = stack[i];
|
|
58
95
|
if (!event.field || h.field) try {
|
|
@@ -71,9 +108,19 @@ function install() {
|
|
|
71
108
|
const e = normalize(raw, true);
|
|
72
109
|
if (e) dispatchG9Key(e);
|
|
73
110
|
});
|
|
111
|
+
const offModifiers = addGlobalListener(g9ModifiersEventName, (raw)=>{
|
|
112
|
+
const m = Array.isArray(raw) && 1 === raw.length ? raw[0] : raw;
|
|
113
|
+
setG9HeldModifiers(m && 'object' == typeof m ? {
|
|
114
|
+
shift: true === m.shift,
|
|
115
|
+
ctrl: true === m.ctrl,
|
|
116
|
+
alt: true === m.alt,
|
|
117
|
+
meta: true === m.meta
|
|
118
|
+
} : null);
|
|
119
|
+
});
|
|
74
120
|
uninstall = ()=>{
|
|
75
121
|
offKey();
|
|
76
122
|
offField();
|
|
123
|
+
offModifiers();
|
|
77
124
|
};
|
|
78
125
|
}
|
|
79
126
|
function useG9Keys(handler, options = {}) {
|
|
@@ -135,4 +182,46 @@ function useG9KeySequence(sequences, onMatch, options = {}) {
|
|
|
135
182
|
enabled: options.enabled
|
|
136
183
|
} : {});
|
|
137
184
|
}
|
|
138
|
-
|
|
185
|
+
function g9KeyPlatform() {
|
|
186
|
+
var _ref;
|
|
187
|
+
var _globalThis_SystemInfo;
|
|
188
|
+
const p = (null != (_ref = null == (_globalThis_SystemInfo = globalThis.SystemInfo) ? void 0 : _globalThis_SystemInfo.platform) ? _ref : '').toLowerCase();
|
|
189
|
+
return 'macos' === p || 'mac' === p || 'osx' === p || 'ios' === p ? 'mac' : 'other';
|
|
190
|
+
}
|
|
191
|
+
function useG9Shortcuts(map, options = {}) {
|
|
192
|
+
var _options_inFields, _options_platform;
|
|
193
|
+
const latest = useRef(map);
|
|
194
|
+
latest.current = map;
|
|
195
|
+
const parsed = useMemo(()=>Object.keys(map).map((combo)=>({
|
|
196
|
+
combo,
|
|
197
|
+
parsed: parseCombo(combo)
|
|
198
|
+
})), [
|
|
199
|
+
Object.keys(map).join('\n')
|
|
200
|
+
]);
|
|
201
|
+
const inFields = useMemo(()=>{
|
|
202
|
+
var _options_inFields;
|
|
203
|
+
return (null != (_options_inFields = options.inFields) ? _options_inFields : []).map((c)=>parseCombo(c));
|
|
204
|
+
}, [
|
|
205
|
+
(null != (_options_inFields = options.inFields) ? _options_inFields : []).join('\n')
|
|
206
|
+
]);
|
|
207
|
+
const platform = null != (_options_platform = options.platform) ? _options_platform : g9KeyPlatform();
|
|
208
|
+
useG9Keys((e)=>{
|
|
209
|
+
if (e.repeat && !options.repeat) return false;
|
|
210
|
+
for (const { combo, parsed: c } of parsed){
|
|
211
|
+
var _latest_current_combo, _latest_current;
|
|
212
|
+
if (matchesCombo(e, c, platform)) {
|
|
213
|
+
if (!e.field || inFields.some((f)=>matchesCombo(e, f, platform))) {
|
|
214
|
+
null == (_latest_current_combo = (_latest_current = latest.current)[combo]) || _latest_current_combo.call(_latest_current, e);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
}, {
|
|
221
|
+
...void 0 !== options.enabled ? {
|
|
222
|
+
enabled: options.enabled
|
|
223
|
+
} : {},
|
|
224
|
+
field: inFields.length > 0
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export { dispatchG9Key, g9HeldModifiers, g9KeyPlatform, noteG9ModifierKey, registerG9KeySource, setG9HeldModifiers, useG9KeySequence, useG9Keys, useG9Shortcut, useG9Shortcuts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/desktop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
2
|
+
import { type G9LynxKeyEventLike } from '../pointer/secondary.js';
|
|
3
|
+
/** The fields of a key event's target the capture reads to tell a text field. */
|
|
4
|
+
interface TargetLike {
|
|
5
|
+
readonly dataset?: Readonly<Record<string, unknown>>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* True when the key came from inside a text field: the target carries the library's keyboard-target mark
|
|
9
|
+
* (`g9KeyboardTargetProps`, on every G9 field's input), the mark the host's keyboard dismiss already reads.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isFieldKeyEvent(e: {
|
|
12
|
+
readonly target?: TargetLike | null;
|
|
13
|
+
} | null | undefined): boolean;
|
|
14
|
+
/** Delivers one Lynx `keydown` to the page's key handlers; answers whether one took it. */
|
|
15
|
+
export declare function deliverLynxKey(e: (G9LynxKeyEventLike & {
|
|
16
|
+
readonly target?: TargetLike | null;
|
|
17
|
+
}) | null | undefined): boolean;
|
|
18
|
+
/** Props of {@link G9KeyCapture}. */
|
|
19
|
+
export interface G9KeyCaptureProps {
|
|
20
|
+
readonly className?: string;
|
|
21
|
+
readonly children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/** Hears the keys pressed anywhere inside (desktop: Lynxtron) and hands them to the page's key handlers. */
|
|
24
|
+
export declare function G9KeyCapture(props: G9KeyCaptureProps): ReactNode;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/desktop/keys.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,KAAK,kBAAkB,EAAc,MAAM,sBAAsB,CAAC;AAE3E,iFAAiF;AACjF,UAAU,UAAU;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEtG;AAED,2FAA2F;AAC3F,wBAAgB,cAAc,CAC5B,CAAC,EAAE,CAAC,kBAAkB,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;CAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GACnF,OAAO,CAKT;AAED,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED,4GAA4G;AAC5G,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAchE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dispatchG9Key, noteG9ModifierKey } from "../commands/keys.jsx";
|
|
2
|
+
import { isKeyboardTarget } from "../host/keyboard.jsx";
|
|
3
|
+
import { keyEventOf } from "../pointer/secondary.jsx";
|
|
4
|
+
function isFieldKeyEvent(e) {
|
|
5
|
+
return isKeyboardTarget(null == e ? void 0 : e.target);
|
|
6
|
+
}
|
|
7
|
+
function deliverLynxKey(e) {
|
|
8
|
+
const k = keyEventOf(e);
|
|
9
|
+
if (!k) return false;
|
|
10
|
+
if (noteG9ModifierKey(k.key, true)) return false;
|
|
11
|
+
return dispatchG9Key(isFieldKeyEvent(e) ? {
|
|
12
|
+
...k,
|
|
13
|
+
field: true
|
|
14
|
+
} : k);
|
|
15
|
+
}
|
|
16
|
+
function G9KeyCapture(props) {
|
|
17
|
+
return <view className={`g9-key-capture${props.className ? ` ${props.className}` : ''}`} style={{
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
flexGrow: 1,
|
|
21
|
+
flexShrink: 1,
|
|
22
|
+
flexBasis: '0px'
|
|
23
|
+
}} bindkeydown={(e)=>void deliverLynxKey(e)} bindkeyup={(e)=>{
|
|
24
|
+
const k = keyEventOf(e);
|
|
25
|
+
if (k) noteG9ModifierKey(k.key, false);
|
|
26
|
+
}}>
|
|
27
|
+
{props.children}
|
|
28
|
+
</view>;
|
|
29
|
+
}
|
|
30
|
+
export { G9KeyCapture, deliverLynxKey, isFieldKeyEvent };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type G9CloseRequestHandler, type G9WindowControl, type G9WindowEvent } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
/** The app's window: the provider's `window` service, or an unavailable control (`available: false`). */
|
|
3
|
+
export declare function useG9WindowControl(): G9WindowControl;
|
|
4
|
+
/**
|
|
5
|
+
* Hears the window's events (`'focus'`, `'minimize'`, the main process's messages such as the tray's «show») while
|
|
6
|
+
* mounted. Nothing is subscribed on a host without a window (`available: false`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function useG9WindowEvent(listener: (event: G9WindowEvent) => void, options?: {
|
|
9
|
+
readonly enabled?: boolean;
|
|
10
|
+
}): void;
|
|
11
|
+
/**
|
|
12
|
+
* Takes part in the window's close requests while mounted (close to the tray, an unsaved-work question): answer
|
|
13
|
+
* `'cancel'` to keep the window. Nothing is registered on a host without a window.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useG9CloseRequest(handler: G9CloseRequestHandler, options?: {
|
|
16
|
+
readonly enabled?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/desktop/window.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AASvC,yGAAyG;AACzG,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3C,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,IAAI,CAKpH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createUnavailableWindowControl } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
import { useEffect } from "@lynx-js/react";
|
|
3
|
+
import { useStableCallback } from "../base/use-stable-callback.jsx";
|
|
4
|
+
import { useG9OptionalService } from "../provider/hooks.jsx";
|
|
5
|
+
const unavailable = createUnavailableWindowControl('No window service: hand G9Provider services.window (createLynxtronWindowControl on Lynxtron).');
|
|
6
|
+
function useG9WindowControl() {
|
|
7
|
+
var _useG9OptionalService;
|
|
8
|
+
return null != (_useG9OptionalService = useG9OptionalService('window')) ? _useG9OptionalService : unavailable;
|
|
9
|
+
}
|
|
10
|
+
function useG9WindowEvent(listener, options = {}) {
|
|
11
|
+
const control = useG9WindowControl();
|
|
12
|
+
const run = useStableCallback(listener);
|
|
13
|
+
const enabled = false !== options.enabled;
|
|
14
|
+
useEffect(()=>enabled && control.available ? control.subscribe((e)=>run(e)) : void 0, [
|
|
15
|
+
control,
|
|
16
|
+
enabled
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
function useG9CloseRequest(handler, options = {}) {
|
|
20
|
+
const control = useG9WindowControl();
|
|
21
|
+
const run = useStableCallback(handler);
|
|
22
|
+
const enabled = false !== options.enabled;
|
|
23
|
+
useEffect(()=>enabled && control.available ? control.onCloseRequest(()=>run()) : void 0, [
|
|
24
|
+
control,
|
|
25
|
+
enabled
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
export { useG9CloseRequest, useG9WindowControl, useG9WindowEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type * from './commands/index.js';
|
|
|
7
7
|
export type * from './dashboard/index.js';
|
|
8
8
|
export type * from './deferred/index.js';
|
|
9
9
|
export type * from './design/index.js';
|
|
10
|
+
export type * from './desktop/index.js';
|
|
10
11
|
export type * from './display/index.js';
|
|
11
12
|
export type * from './edge-panel/index.js';
|
|
12
13
|
export type * from './effects/index.js';
|
|
@@ -22,6 +23,7 @@ export type * from './notifications/index.js';
|
|
|
22
23
|
export type * from './orb/index.js';
|
|
23
24
|
export type * from './pickers/index.js';
|
|
24
25
|
export type * from './plus-button/index.js';
|
|
26
|
+
export type * from './pointer/index.js';
|
|
25
27
|
export type * from './popover/index.js';
|
|
26
28
|
export type * from './popup/index.js';
|
|
27
29
|
export type * from './provider/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,kBAAkB,CAAC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ACtC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.g9-dock {
|
|
2
|
+
flex-direction: column;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.g9-dock__split {
|
|
10
|
+
display: flex;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.g9-dock__split--row {
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.g9-dock__split--column {
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.g9-dock__pane {
|
|
23
|
+
background-color: var(--g9-surface);
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
display: flex;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.g9-dock__splitter {
|
|
30
|
+
background-color: var(--g9-surface-container);
|
|
31
|
+
flex-shrink: 0;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
display: flex;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.g9-dock__splitter--v, .g9-dock__splitter--h {
|
|
38
|
+
align-self: stretch;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.g9-dock__grip {
|
|
42
|
+
background-color: var(--g9-outline-variant);
|
|
43
|
+
border-radius: 2px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.g9-dock__grip--v {
|
|
47
|
+
width: 2px;
|
|
48
|
+
height: 24px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.g9-dock__grip--h {
|
|
52
|
+
width: 24px;
|
|
53
|
+
height: 2px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.g9-dock__splitter:active {
|
|
57
|
+
background-color: var(--g9-primary-a12);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.g9-dock__rail {
|
|
61
|
+
background-color: var(--g9-surface-container-low);
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
align-items: center;
|
|
64
|
+
display: flex;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.g9-dock__rail--v {
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
align-self: stretch;
|
|
70
|
+
padding-top: 10px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.g9-dock__rail--h {
|
|
74
|
+
align-self: stretch;
|
|
75
|
+
column-gap: 8px;
|
|
76
|
+
padding: 0 10px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.g9-dock__rail:active {
|
|
80
|
+
background-color: var(--g9-surface-container-high);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.g9-dock__rail-title {
|
|
84
|
+
font-size: 13px;
|
|
85
|
+
font-family: var(--g9-font-text);
|
|
86
|
+
color: var(--g9-text-secondary);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/*# sourceMappingURL=dock.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack://./src/layout/dock.css"],"names":[],"mappings":"AACA;EAAE,sBAAsB;EACtB,WAAW;EACX,YAAY;EACZ,aAAa;EACb,gBAAgB;AAClB;;AAGA;EAAE,aAAa;EACb,gBAAgB;AAClB;;AAGA;EAAE,mBAAmB;AACrB;;AAGA;EAAE,sBAAsB;AACxB;;AAGA;EAAE,mCAAmC;EACnC,sBAAsB;EACtB,aAAa;EACb,gBAAgB;AAClB;;AAGA;EAAE,6CAA6C;EAC7C,cAAc;EACd,uBAAuB;EACvB,mBAAmB;EACnB,aAAa;AACf;;AAGA;EAAE,mBAAmB;AACrB;;AAOA;EAJE,2CAA2C;EAC3C,kBAAkB;AACpB;;AAOA;EAJE,UAAU;EACV,YAAY;AACd;;AAOA;EAJE,WAAW;EACX,WAAW;AACb;;AAOA;EAJE,uCAAuC;AACzC;;AAOA;EAJE,iDAAiD;EACjD,cAAc;EACd,mBAAmB;EACnB,aAAa;AACf;;AAOA;EAJE,sBAAsB;EACtB,mBAAmB;EACnB,iBAAiB;AACnB;;AAOA;EAJE,mBAAmB;EACnB,eAAe;EACf,eAAe;AACjB;;AAOA;EAJE,kDAAkD;AACpD;;AAOA;EAJE,eAAe;EACf,gCAAgC;EAChC,+BAA+B;AACjC","sourcesContent":["/* G9DockLayout (2.10.0) */\n.g9-dock {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.g9-dock__split {\n display: flex;\n overflow: hidden;\n}\n\n.g9-dock__split--row {\n flex-direction: row;\n}\n\n.g9-dock__split--column {\n flex-direction: column;\n}\n\n.g9-dock__pane {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background-color: var(--g9-surface);\n}\n\n.g9-dock__splitter {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n background-color: var(--g9-surface-container);\n}\n\n.g9-dock__splitter--v {\n align-self: stretch;\n}\n\n.g9-dock__splitter--h {\n align-self: stretch;\n}\n\n.g9-dock__grip {\n border-radius: 2px;\n background-color: var(--g9-outline-variant);\n}\n\n.g9-dock__grip--v {\n width: 2px;\n height: 24px;\n}\n\n.g9-dock__grip--h {\n width: 24px;\n height: 2px;\n}\n\n.g9-dock__splitter:active {\n background-color: var(--g9-primary-a12);\n}\n\n.g9-dock__rail {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n background-color: var(--g9-surface-container-low);\n}\n\n.g9-dock__rail--v {\n flex-direction: column;\n padding-top: 10px;\n align-self: stretch;\n}\n\n.g9-dock__rail--h {\n padding: 0px 10px;\n column-gap: 8px;\n align-self: stretch;\n}\n\n.g9-dock__rail:active {\n background-color: var(--g9-surface-container-high);\n}\n\n.g9-dock__rail-title {\n font-size: 13px;\n font-family: var(--g9-font-text);\n color: var(--g9-text-secondary);\n}\n"],"sourceRoot":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import './dock.css';
|
|
2
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
3
|
+
import { type G9StyleProp } from '../base/control.js';
|
|
4
|
+
import { type G9IconInput } from '../icon/icon.js';
|
|
5
|
+
/** A pane of a {@link G9DockLayout}: a leaf of the tree. */
|
|
6
|
+
export interface G9DockPane {
|
|
7
|
+
readonly kind: 'pane';
|
|
8
|
+
/** Unique in the tree: `renderPane`'s key, the minimum size's key, the rail's id. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** Its name on the rail and to a screen reader. */
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
/** Its icon on the rail. */
|
|
13
|
+
readonly icon?: G9IconInput;
|
|
14
|
+
/** Its starting weight among its siblings. Default 1. */
|
|
15
|
+
readonly size?: number;
|
|
16
|
+
}
|
|
17
|
+
/** A row (children side by side, in the reading direction) or a column (stacked) of a {@link G9DockLayout}. */
|
|
18
|
+
export interface G9DockSplit {
|
|
19
|
+
readonly kind: 'row' | 'column';
|
|
20
|
+
/** Unique in the tree: the key of its sizes in `onChange` and the store. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly children: readonly G9DockNode[];
|
|
23
|
+
/** Its starting weight in its own parent. Default 1. */
|
|
24
|
+
readonly size?: number;
|
|
25
|
+
}
|
|
26
|
+
/** A node of a {@link G9DockLayout}'s tree. */
|
|
27
|
+
export type G9DockNode = G9DockPane | G9DockSplit;
|
|
28
|
+
/** What a dock remembers: each split's children as fractions (summing to 1), and the collapsed panes. */
|
|
29
|
+
export interface G9DockState {
|
|
30
|
+
readonly sizes: Readonly<Record<string, readonly number[]>>;
|
|
31
|
+
readonly collapsed: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/** What `renderPane` may do. */
|
|
34
|
+
export interface G9DockPaneApi {
|
|
35
|
+
/** Folds the pane to its rail. */
|
|
36
|
+
readonly collapse: () => void;
|
|
37
|
+
readonly collapsed: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Props of {@link G9DockLayout}. */
|
|
40
|
+
export interface G9DockLayoutProps {
|
|
41
|
+
readonly id?: string;
|
|
42
|
+
readonly className?: string;
|
|
43
|
+
readonly style?: G9StyleProp;
|
|
44
|
+
/** The tree: rows and columns of panes. */
|
|
45
|
+
readonly layout: G9DockNode;
|
|
46
|
+
/** A pane's content. */
|
|
47
|
+
readonly renderPane: (id: string, api: G9DockPaneApi) => ReactNode;
|
|
48
|
+
/** The smallest size (dp) of a pane, by pane id, along its split's axis. Default 48. */
|
|
49
|
+
readonly minSizes?: Readonly<Record<string, number>>;
|
|
50
|
+
/** Where the sizes and the collapsed panes are remembered (the preference store). None: not remembered. */
|
|
51
|
+
readonly storageKey?: string;
|
|
52
|
+
/** The sizes (by split id, as fractions) once a drag ends, and after a pane collapses or opens. */
|
|
53
|
+
readonly onChange?: (sizes: Readonly<Record<string, readonly number[]>>) => void;
|
|
54
|
+
/** The collapsed panes (controlled); with `onCollapsedChange`. */
|
|
55
|
+
readonly collapsed?: readonly string[];
|
|
56
|
+
readonly defaultCollapsed?: readonly string[];
|
|
57
|
+
readonly onCollapsedChange?: (collapsed: readonly string[]) => void;
|
|
58
|
+
/** The rail's thickness (dp). Default 40. */
|
|
59
|
+
readonly railSize?: number;
|
|
60
|
+
/** The splitter's thickness (dp; its touch target is wider). Default 6. */
|
|
61
|
+
readonly splitterSize?: number;
|
|
62
|
+
/** No dragging (the sizes still come from the store and the tree). */
|
|
63
|
+
readonly fixed?: boolean;
|
|
64
|
+
/** The spoken name of a splitter («Resize»). */
|
|
65
|
+
readonly splitterLabel?: string;
|
|
66
|
+
/** The spoken hint of a rail («Open»), after the pane's title. */
|
|
67
|
+
readonly railLabel?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Fractions that sum to 1 (a list of weights; non-positive weights count as 1). */
|
|
70
|
+
export declare function normalizeDockSizes(weights: readonly number[]): number[];
|
|
71
|
+
/**
|
|
72
|
+
* Moves the boundary between children `index` and `index + 1` by `delta` dp, inside `free` dp of room shared by the
|
|
73
|
+
* open children (`open[i]` false = a rail, which takes no fraction), keeping each at least its minimum. Returns new
|
|
74
|
+
* fractions (the open children's share; rails keep theirs).
|
|
75
|
+
*/
|
|
76
|
+
export declare function dragDockSizes(fractions: readonly number[], open: readonly boolean[], index: number, delta: number, free: number, mins: readonly number[]): number[];
|
|
77
|
+
/** The starting state of a tree: each split's children by their `size` weights, nothing collapsed. */
|
|
78
|
+
export declare function initialDockSizes(node: G9DockNode, into?: Record<string, number[]>): Record<string, number[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Panes in nested rows and columns (an editor's frame). Drag a splitter to share the room between its neighbours
|
|
81
|
+
* (each keeps its `minSizes`); `renderPane(id, { collapse })` folds a pane to a rail with its icon, and a tap on the
|
|
82
|
+
* rail opens it. With `storageKey` the sizes and the folded panes come back next time. Rows follow the reading
|
|
83
|
+
* direction. Ids: `<id>`, `<id>_Split_<splitId>_<n>` (the splitter after child n), `<id>_Rail_<paneId>`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function G9DockLayout(props: G9DockLayoutProps): ReactNode;
|
|
86
|
+
//# sourceMappingURL=dock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.d.ts","sourceRoot":"","sources":["../../src/layout/dock.tsx"],"names":[],"mappings":"AAGA,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAKxD,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+GAA+G;AAC/G,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CA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