@g9tm/lynxcontrols 2.8.4 → 2.9.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 (81) hide show
  1. package/README.md +1 -0
  2. package/catalog/cards/G9Avatar.md +1 -1
  3. package/catalog/cards/G9Badge.md +1 -1
  4. package/catalog/cards/G9Button.md +1 -1
  5. package/catalog/cards/G9Chip.md +1 -1
  6. package/catalog/cards/G9ChipStrip.md +1 -1
  7. package/catalog/cards/G9ContextMenu.md +4 -2
  8. package/catalog/cards/G9DragChip.md +10 -0
  9. package/catalog/cards/G9DragSource.md +17 -0
  10. package/catalog/cards/G9DropTarget.md +15 -0
  11. package/catalog/cards/G9EmptyState.md +1 -1
  12. package/catalog/cards/G9IconButton.md +2 -2
  13. package/catalog/cards/G9InlineMessage.md +1 -1
  14. package/catalog/cards/G9KeyCapture.md +10 -0
  15. package/catalog/cards/G9Kpi.md +1 -1
  16. package/catalog/cards/G9ListRow.md +1 -1
  17. package/catalog/cards/G9LiveBadge.md +1 -1
  18. package/catalog/cards/G9LiveDot.md +1 -1
  19. package/catalog/cards/G9ProgressBar.md +1 -1
  20. package/catalog/cards/G9ProgressRing.md +1 -1
  21. package/catalog/cards/G9SafeButton.md +1 -1
  22. package/catalog/cards/G9SafeIconButton.md +2 -2
  23. package/catalog/cards/G9StatusPill.md +1 -1
  24. package/catalog/cards/G9StepTracker.md +1 -1
  25. package/catalog/cards/G9SwitchRow.md +1 -1
  26. package/catalog/cards/G9Tag.md +1 -1
  27. package/catalog/catalog.json +1069 -68
  28. package/catalog/index.md +6 -2
  29. package/dist/.tsbuildinfo +1 -1
  30. package/dist/commands/index.d.ts +1 -1
  31. package/dist/commands/index.d.ts.map +1 -1
  32. package/dist/commands/index.jsx +1 -1
  33. package/dist/commands/keys.d.ts +32 -1
  34. package/dist/commands/keys.d.ts.map +1 -1
  35. package/dist/commands/keys.jsx +92 -3
  36. package/dist/desktop/index.d.ts +3 -0
  37. package/dist/desktop/index.d.ts.map +1 -0
  38. package/dist/desktop/index.jsx +2 -0
  39. package/dist/desktop/keys.d.ts +26 -0
  40. package/dist/desktop/keys.d.ts.map +1 -0
  41. package/dist/desktop/keys.jsx +30 -0
  42. package/dist/desktop/window.d.ts +18 -0
  43. package/dist/desktop/window.d.ts.map +1 -0
  44. package/dist/desktop/window.jsx +28 -0
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/pointer/drag-session.d.ts +72 -0
  48. package/dist/pointer/drag-session.d.ts.map +1 -0
  49. package/dist/pointer/drag-session.jsx +148 -0
  50. package/dist/pointer/drag.d.ts +78 -0
  51. package/dist/pointer/drag.d.ts.map +1 -0
  52. package/dist/pointer/drag.jsx +186 -0
  53. package/dist/pointer/index.d.ts +5 -0
  54. package/dist/pointer/index.d.ts.map +1 -0
  55. package/dist/pointer/index.jsx +4 -0
  56. package/dist/pointer/point.d.ts +36 -0
  57. package/dist/pointer/point.d.ts.map +1 -0
  58. package/dist/pointer/point.jsx +34 -0
  59. package/dist/pointer/pointer.css +62 -0
  60. package/dist/pointer/pointer.css.map +1 -0
  61. package/dist/pointer/secondary.d.ts +54 -0
  62. package/dist/pointer/secondary.d.ts.map +1 -0
  63. package/dist/pointer/secondary.jsx +86 -0
  64. package/dist/popover/popover.d.ts +26 -2
  65. package/dist/popover/popover.d.ts.map +1 -1
  66. package/dist/popover/popover.jsx +47 -20
  67. package/package.json +12 -2
  68. package/skills/g9-lynx-app/SKILL.md +8 -0
  69. package/skills/g9-lynx-app/references/catalog-index.md +11 -0
  70. package/skills/g9-lynx-app/references/components/button.md +6 -6
  71. package/skills/g9-lynx-app/references/components/code-editor.md +19 -0
  72. package/skills/g9-lynx-app/references/components/code-log.md +19 -0
  73. package/skills/g9-lynx-app/references/components/desktop.md +12 -0
  74. package/skills/g9-lynx-app/references/components/display-1.md +4 -4
  75. package/skills/g9-lynx-app/references/components/display-2.md +5 -5
  76. package/skills/g9-lynx-app/references/components/display-3.md +3 -3
  77. package/skills/g9-lynx-app/references/components/graph.md +19 -0
  78. package/skills/g9-lynx-app/references/components/list.md +2 -2
  79. package/skills/g9-lynx-app/references/components/pointer.md +46 -0
  80. package/skills/g9-lynx-app/references/components/popover.md +4 -2
  81. package/skills/g9-lynx-app/references/components/toggle.md +2 -2
@@ -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,GACd,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"}
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"}
@@ -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";
@@ -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,EAIhB,MAAM,+BAA+B,CAAC;AA0BvC;;;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;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAWxD;AAkBD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,GAAG,IAAI,EAC1C,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACrE,IAAI,CAkBN;AAED,yGAAyG;AACzG,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACjC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,EAC/B,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7G,IAAI,CAWN;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAC9B,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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(raw, field) {
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
- export { dispatchG9Key, registerG9KeySource, useG9KeySequence, useG9Keys, useG9Shortcut };
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,3 @@
1
+ export { deliverLynxKey, G9KeyCapture, type G9KeyCaptureProps, isFieldKeyEvent } from './keys.js';
2
+ export { useG9CloseRequest, useG9WindowControl, useG9WindowEvent } from './window.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export { G9KeyCapture, deliverLynxKey, isFieldKeyEvent } from "./keys.jsx";
2
+ export { useG9CloseRequest, useG9WindowControl, useG9WindowEvent } from "./window.jsx";
@@ -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';
@@ -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;AACtC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,gBAAgB,CAAC;AACpC,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,mBA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a,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,72 @@
1
+ import type { G9AnchorRect } from '../anchor/registry.js';
2
+ /** What is dragged: a kind the targets filter on, the app's data, and the preview's words. */
3
+ export interface G9DragPayload<T = unknown> {
4
+ readonly kind: string;
5
+ readonly data: T;
6
+ /** The default preview's text. */
7
+ readonly label?: string;
8
+ }
9
+ /** Where a drag is over: a target, and inside a composite target (a canvas) the part it named. */
10
+ export interface G9DropOver {
11
+ readonly target: string;
12
+ /** The part of a composite target (`hit` answered it); absent for a plain target. */
13
+ readonly part?: string;
14
+ }
15
+ /** What a drop hands the target. */
16
+ export interface G9DropEvent<T = unknown> extends G9DropOver {
17
+ readonly payload: G9DragPayload<T>;
18
+ /** The pointer, in the LynxView's space. */
19
+ readonly x: number;
20
+ readonly y: number;
21
+ }
22
+ /** A drop target as registered. */
23
+ export interface G9DropTargetSpec {
24
+ /** Unique on the page. */
25
+ readonly id: string;
26
+ /** Whether it takes this payload (default: every payload). Only accepting targets are measured and lit. */
27
+ accepts?(payload: G9DragPayload): boolean;
28
+ /** Its rect in the LynxView's space, asked once when a drag starts. */
29
+ measure(): Promise<G9AnchorRect | null>;
30
+ /**
31
+ * A composite target (a canvas of nodes): which part is under the point (`rect` is the measured one). `null` = no
32
+ * part takes it here (the drop falls through to targets below); a string = that part.
33
+ */
34
+ hit?(x: number, y: number, rect: G9AnchorRect, payload: G9DragPayload): string | null;
35
+ /** The drag came over it (or onto another of its parts). */
36
+ onEnter?(over: G9DropOver, payload: G9DragPayload): void;
37
+ /** The drag left it. */
38
+ onLeave?(payload: G9DragPayload): void;
39
+ onDrop(event: G9DropEvent): void;
40
+ }
41
+ /** The drag of the page, as listeners see it. */
42
+ export interface G9DragState {
43
+ readonly payload: G9DragPayload;
44
+ /** The targets that take the payload (lit as candidates). */
45
+ readonly candidates: readonly string[];
46
+ readonly over: G9DropOver | null;
47
+ readonly x: number;
48
+ readonly y: number;
49
+ }
50
+ /** Registers a drop target for as long as it lives; returns the unregister. A newer target wins where two overlap. */
51
+ export declare function registerG9DropTarget(spec: G9DropTargetSpec): () => void;
52
+ /** Hears the page's drag: its start, every change of the target under it, and its end (`null`). */
53
+ export declare function subscribeG9Drag(listener: (state: G9DragState | null) => void): () => void;
54
+ /** The drag now, or null. */
55
+ export declare function currentG9Drag(): G9DragState | null;
56
+ /** The target (and part) under the point among `measured`, newest first; null when none. */
57
+ export declare function hitDropTarget(measured: readonly {
58
+ readonly spec: G9DropTargetSpec;
59
+ readonly rect: G9AnchorRect;
60
+ }[], x: number, y: number, payload: G9DragPayload): G9DropOver | null;
61
+ /**
62
+ * Starts the page's drag at the point: every accepting target is measured once (a failed measure leaves that one
63
+ * out). A drag already running is cancelled first. Resolves when the targets are measured.
64
+ */
65
+ export declare function startG9Drag(payload: G9DragPayload, x: number, y: number): Promise<void>;
66
+ /** Moves the page's drag; the targets hear a change of the one under it. Nothing without a drag. */
67
+ export declare function moveG9Drag(x: number, y: number): void;
68
+ /** Drops at the point: the target under it hears `onDrop`. Answers the drop, or null when it fell on no target. */
69
+ export declare function endG9Drag(x: number, y: number): G9DropEvent | null;
70
+ /** Ends the page's drag without a drop (Escape, the source went away). */
71
+ export declare function cancelG9Drag(): void;
72
+ //# sourceMappingURL=drag-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-session.d.ts","sourceRoot":"","sources":["../../src/pointer/drag-session.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,8FAA8F;AAC9F,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,kGAAkG;AAClG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oCAAoC;AACpC,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,UAAU;IAC1D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACnC,4CAA4C;IAC5C,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,mCAAmC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,2GAA2G;IAC3G,OAAO,CAAC,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAC1C,uEAAuE;IACvE,OAAO,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACxC;;;OAGG;IACH,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;IACtF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G;AACpG,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAmBlE;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,IAAI,IAAI,CAOnC"}
@@ -0,0 +1,148 @@
1
+ const targets = [];
2
+ const listeners = new Set();
3
+ let session = null;
4
+ let tokens = 0;
5
+ function emit() {
6
+ const s = session ? session.state : null;
7
+ for (const l of Array.from(listeners))try {
8
+ l(s);
9
+ } catch {}
10
+ }
11
+ function registerG9DropTarget(spec) {
12
+ targets.push(spec);
13
+ return ()=>{
14
+ const i = targets.indexOf(spec);
15
+ if (i >= 0) targets.splice(i, 1);
16
+ if (session) session.measured = session.measured.filter((m)=>m.spec !== spec);
17
+ };
18
+ }
19
+ function subscribeG9Drag(listener) {
20
+ listeners.add(listener);
21
+ return ()=>{
22
+ listeners.delete(listener);
23
+ };
24
+ }
25
+ function currentG9Drag() {
26
+ return session ? session.state : null;
27
+ }
28
+ const inside = (r, x, y)=>x >= r.x && y >= r.y && x <= r.x + r.width && y <= r.y + r.height;
29
+ function hitDropTarget(measured, x, y, payload) {
30
+ for(let i = measured.length - 1; i >= 0; i--){
31
+ const m = measured[i];
32
+ if (!inside(m.rect, x, y)) continue;
33
+ if (!m.spec.hit) return {
34
+ target: m.spec.id
35
+ };
36
+ let part = null;
37
+ try {
38
+ part = m.spec.hit(x, y, m.rect, payload);
39
+ } catch {
40
+ part = null;
41
+ }
42
+ if (null !== part) return {
43
+ target: m.spec.id,
44
+ part
45
+ };
46
+ }
47
+ return null;
48
+ }
49
+ const sameOver = (a, b)=>a === b || null !== a && null !== b && a.target === b.target && a.part === b.part;
50
+ function accepting(payload) {
51
+ return targets.filter((t)=>{
52
+ try {
53
+ return t.accepts ? t.accepts(payload) : true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ });
58
+ }
59
+ async function startG9Drag(payload, x, y) {
60
+ if (session) cancelG9Drag();
61
+ const token = ++tokens;
62
+ const specs = accepting(payload);
63
+ session = {
64
+ state: {
65
+ payload,
66
+ candidates: specs.map((s)=>s.id),
67
+ over: null,
68
+ x,
69
+ y
70
+ },
71
+ measured: [],
72
+ token
73
+ };
74
+ emit();
75
+ const rects = await Promise.all(specs.map((s)=>s.measure().catch(()=>null)));
76
+ if (!session || session.token !== token) return;
77
+ const measured = [];
78
+ specs.forEach((spec, i)=>{
79
+ const rect = rects[i];
80
+ if (rect && targets.includes(spec)) measured.push({
81
+ spec,
82
+ rect
83
+ });
84
+ });
85
+ session.measured = measured;
86
+ moveG9Drag(session.state.x, session.state.y);
87
+ }
88
+ function setOver(next) {
89
+ var _find_onLeave, _find, _find_onEnter, _find1;
90
+ if (!session) return;
91
+ const before = session.state.over;
92
+ if (sameOver(before, next)) return;
93
+ const payload = session.state.payload;
94
+ const find = (id)=>{
95
+ var _session_measured_find;
96
+ return null == session ? void 0 : null == (_session_measured_find = session.measured.find((m)=>m.spec.id === id)) ? void 0 : _session_measured_find.spec;
97
+ };
98
+ if (before && (!next || next.target !== before.target)) null == (_find = find(before.target)) || null == (_find_onLeave = _find.onLeave) || _find_onLeave.call(_find, payload);
99
+ session.state = {
100
+ ...session.state,
101
+ over: next
102
+ };
103
+ if (next) null == (_find1 = find(next.target)) || null == (_find_onEnter = _find1.onEnter) || _find_onEnter.call(_find1, next, payload);
104
+ emit();
105
+ }
106
+ function moveG9Drag(x, y) {
107
+ if (!session) return;
108
+ session.state = {
109
+ ...session.state,
110
+ x,
111
+ y
112
+ };
113
+ setOver(hitDropTarget(session.measured, x, y, session.state.payload));
114
+ }
115
+ function endG9Drag(x, y) {
116
+ if (!session) return null;
117
+ moveG9Drag(x, y);
118
+ const s = session;
119
+ session = null;
120
+ const over = s.state.over;
121
+ let drop = null;
122
+ if (over) {
123
+ var _s_measured_find, _spec_onLeave;
124
+ drop = {
125
+ ...over,
126
+ payload: s.state.payload,
127
+ x,
128
+ y
129
+ };
130
+ const spec = null == (_s_measured_find = s.measured.find((m)=>m.spec.id === over.target)) ? void 0 : _s_measured_find.spec;
131
+ null == spec || null == (_spec_onLeave = spec.onLeave) || _spec_onLeave.call(spec, s.state.payload);
132
+ try {
133
+ null == spec || spec.onDrop(drop);
134
+ } catch {}
135
+ }
136
+ emit();
137
+ return drop;
138
+ }
139
+ function cancelG9Drag() {
140
+ var _s_measured_find_spec_onLeave, _s_measured_find, _s_measured_find_spec;
141
+ if (!session) return;
142
+ const s = session;
143
+ session = null;
144
+ const over = s.state.over;
145
+ if (over) null == (_s_measured_find = s.measured.find((m)=>m.spec.id === over.target)) || null == (_s_measured_find_spec_onLeave = (_s_measured_find_spec = _s_measured_find.spec).onLeave) || _s_measured_find_spec_onLeave.call(_s_measured_find_spec, s.state.payload);
146
+ emit();
147
+ }
148
+ export { cancelG9Drag, currentG9Drag, endG9Drag, hitDropTarget, moveG9Drag, registerG9DropTarget, startG9Drag, subscribeG9Drag };