@g9tm/lynxcontrols 2.8.3 → 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 (98) 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 +1129 -69
  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/fields/editor.d.ts +7 -0
  46. package/dist/fields/editor.d.ts.map +1 -1
  47. package/dist/fields/editor.jsx +3 -1
  48. package/dist/fields/index.d.ts +1 -0
  49. package/dist/fields/index.d.ts.map +1 -1
  50. package/dist/fields/index.jsx +1 -0
  51. package/dist/fields/line-direction.d.ts +13 -0
  52. package/dist/fields/line-direction.d.ts.map +1 -0
  53. package/dist/fields/line-direction.jsx +15 -0
  54. package/dist/host/host.d.ts.map +1 -1
  55. package/dist/host/host.jsx +3 -1
  56. package/dist/index.d.ts +2 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/pointer/drag-session.d.ts +72 -0
  59. package/dist/pointer/drag-session.d.ts.map +1 -0
  60. package/dist/pointer/drag-session.jsx +148 -0
  61. package/dist/pointer/drag.d.ts +78 -0
  62. package/dist/pointer/drag.d.ts.map +1 -0
  63. package/dist/pointer/drag.jsx +186 -0
  64. package/dist/pointer/index.d.ts +5 -0
  65. package/dist/pointer/index.d.ts.map +1 -0
  66. package/dist/pointer/index.jsx +4 -0
  67. package/dist/pointer/point.d.ts +36 -0
  68. package/dist/pointer/point.d.ts.map +1 -0
  69. package/dist/pointer/point.jsx +34 -0
  70. package/dist/pointer/pointer.css +62 -0
  71. package/dist/pointer/pointer.css.map +1 -0
  72. package/dist/pointer/secondary.d.ts +54 -0
  73. package/dist/pointer/secondary.d.ts.map +1 -0
  74. package/dist/pointer/secondary.jsx +86 -0
  75. package/dist/popover/popover.d.ts +26 -2
  76. package/dist/popover/popover.d.ts.map +1 -1
  77. package/dist/popover/popover.jsx +47 -20
  78. package/dist/provider/index.d.ts +1 -1
  79. package/dist/provider/index.d.ts.map +1 -1
  80. package/dist/provider/settings.d.ts +11 -0
  81. package/dist/provider/settings.d.ts.map +1 -1
  82. package/dist/provider/settings.jsx +3 -2
  83. package/package.json +12 -2
  84. package/skills/g9-lynx-app/SKILL.md +8 -0
  85. package/skills/g9-lynx-app/references/catalog-index.md +11 -0
  86. package/skills/g9-lynx-app/references/components/button.md +6 -6
  87. package/skills/g9-lynx-app/references/components/code-editor.md +19 -0
  88. package/skills/g9-lynx-app/references/components/code-log.md +19 -0
  89. package/skills/g9-lynx-app/references/components/desktop.md +12 -0
  90. package/skills/g9-lynx-app/references/components/display-1.md +4 -4
  91. package/skills/g9-lynx-app/references/components/display-2.md +5 -5
  92. package/skills/g9-lynx-app/references/components/display-3.md +3 -3
  93. package/skills/g9-lynx-app/references/components/graph.md +19 -0
  94. package/skills/g9-lynx-app/references/components/list.md +2 -2
  95. package/skills/g9-lynx-app/references/components/media-photo-editor.md +3 -3
  96. package/skills/g9-lynx-app/references/components/pointer.md +46 -0
  97. package/skills/g9-lynx-app/references/components/popover.md +4 -2
  98. package/skills/g9-lynx-app/references/components/toggle.md +2 -2
@@ -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 };
@@ -0,0 +1,78 @@
1
+ import { type ReactNode } from '@lynx-js/react';
2
+ import type { NodesRef } from '@lynx-js/types';
3
+ import { type G9DragPayload, type G9DragState, type G9DropEvent } from './drag-session.js';
4
+ import { type G9PointerEventLike } from './point.js';
5
+ import './pointer.css';
6
+ /** The page's drag as React state: re-renders on its start, a change of the target under it, and its end. */
7
+ export declare function useG9DragState(): G9DragState | null;
8
+ /** Options of {@link useG9DragSource}. */
9
+ export interface G9DragSourceOptions<T = unknown> {
10
+ /** What is dragged (a function is asked when the drag starts). */
11
+ readonly payload: G9DragPayload<T> | (() => G9DragPayload<T>);
12
+ /** Default true. */
13
+ readonly enabled?: boolean;
14
+ /** How far (dp) the mouse moves before a drag starts. Default 4. */
15
+ readonly threshold?: number;
16
+ /** A long press starts a drag on touch. Default true. */
17
+ readonly longPress?: boolean;
18
+ /** The preview under the pointer; default a chip with the payload's `label`. */
19
+ readonly renderPreview?: (payload: G9DragPayload<T>) => ReactNode;
20
+ readonly onDragStart?: (payload: G9DragPayload<T>) => void;
21
+ /** The drag ended: the drop, or null (no target, or cancelled). */
22
+ readonly onDragEnd?: (drop: G9DropEvent<T> | null) => void;
23
+ }
24
+ /** The props {@link useG9DragSource} puts on the source element. */
25
+ export interface G9DragSourceProps {
26
+ readonly bindmousedown?: (e: G9PointerEventLike) => void;
27
+ readonly bindmousemove?: (e: G9PointerEventLike) => void;
28
+ readonly bindmouseup?: (e: G9PointerEventLike) => void;
29
+ readonly bindlongpress?: (e: G9PointerEventLike) => void;
30
+ readonly bindtouchmove?: (e: G9PointerEventLike) => void;
31
+ readonly bindtouchend?: (e: G9PointerEventLike) => void;
32
+ readonly bindtouchcancel?: () => void;
33
+ }
34
+ /** Makes an element a drag source: spread `props` on it; `dragging` is true while its drag runs. */
35
+ export declare function useG9DragSource<T>(options: G9DragSourceOptions<T>): {
36
+ readonly props: G9DragSourceProps;
37
+ readonly dragging: boolean;
38
+ };
39
+ /** The default preview: the payload's label in a chip. */
40
+ export declare function G9DragChip(props: {
41
+ readonly payload: G9DragPayload;
42
+ }): ReactNode;
43
+ /** How a drop target is drawn now. */
44
+ export type G9DropTargetState = 'idle' | 'candidate' | 'over';
45
+ /** Options of {@link useG9DropTarget}. */
46
+ export interface G9DropTargetOptions<T = unknown> {
47
+ /** Unique on the page; default a generated one. */
48
+ readonly id?: string;
49
+ /** Whether it takes a payload (default: every payload). */
50
+ readonly accepts?: (payload: G9DragPayload<T>) => boolean;
51
+ readonly onDrop: (event: G9DropEvent<T>) => void;
52
+ readonly onEnter?: (payload: G9DragPayload<T>) => void;
53
+ readonly onLeave?: (payload: G9DragPayload<T>) => void;
54
+ /** Default true. */
55
+ readonly enabled?: boolean;
56
+ }
57
+ /** Makes an element a drop target: put `ref` on it; `state` lights it while a drag that it accepts runs. */
58
+ export declare function useG9DropTarget<T>(options: G9DropTargetOptions<T>): {
59
+ readonly ref: (node: NodesRef | null) => void;
60
+ readonly state: G9DropTargetState;
61
+ };
62
+ /** Props of {@link G9DragSource}. */
63
+ export interface G9DragSourceComponentProps<T = unknown> extends G9DragSourceOptions<T> {
64
+ readonly id?: string;
65
+ readonly className?: string;
66
+ readonly children?: ReactNode;
67
+ }
68
+ /** A drag source around its children (a list row, a card): drawn faded while it is dragged. */
69
+ export declare function G9DragSource<T>(props: G9DragSourceComponentProps<T>): ReactNode;
70
+ /** Props of {@link G9DropTarget}. */
71
+ export interface G9DropTargetProps<T = unknown> extends G9DropTargetOptions<T> {
72
+ readonly className?: string;
73
+ /** Children, or a function of the state (to draw the light its own way). */
74
+ readonly children?: ReactNode | ((state: G9DropTargetState) => ReactNode);
75
+ }
76
+ /** A drop target around its children: outlined while a drag it accepts runs, filled while the drag is over it. */
77
+ export declare function G9DropTarget<T>(props: G9DropTargetProps<T>): ReactNode;
78
+ //# sourceMappingURL=drag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.d.ts","sourceRoot":"","sources":["../../src/pointer/drag.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,gBAAgB,CAAC;AACtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OA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base/control.jsx";
4
+ import { useStableCallback } from "../base/use-stable-callback.jsx";
5
+ import { useG9Keys } from "../commands/keys.jsx";
6
+ import { useG9LayerItem } from "../host/hooks.jsx";
7
+ import { cancelG9Drag, currentG9Drag, endG9Drag, moveG9Drag, registerG9DropTarget, startG9Drag, subscribeG9Drag } from "./drag-session.jsx";
8
+ import { g9MouseButton, g9PointerPoint } from "./point.jsx";
9
+ import "./pointer.css";
10
+ let seq = 0;
11
+ function useG9DragState() {
12
+ const [state, setState] = useState(currentG9Drag);
13
+ useEffect(()=>subscribeG9Drag(setState), []);
14
+ return state;
15
+ }
16
+ function useG9DragSource(options) {
17
+ var _options_threshold, _ref;
18
+ var _latest_current_renderPreview, _latest_current;
19
+ const key = useMemo(()=>`g9-drag-${++seq}`, []);
20
+ const previewId = `${key}-preview`;
21
+ const [active, setActive] = useState(null);
22
+ const press = useRef(null);
23
+ const running = useRef(false);
24
+ const lastPoint = useRef({
25
+ x: 0,
26
+ y: 0
27
+ });
28
+ const latest = useRef(options);
29
+ latest.current = options;
30
+ const threshold = null != (_options_threshold = options.threshold) ? _options_threshold : 4;
31
+ const place = (x, y)=>{
32
+ try {
33
+ lynx.createSelectorQuery().select(`#${previewId}`).setNativeProps({
34
+ transform: `translate(${Math.round(x + 12)}px, ${Math.round(y + 12)}px)`
35
+ }).exec();
36
+ } catch {}
37
+ };
38
+ const start = (x, y)=>{
39
+ var _o_onDragStart;
40
+ const o = latest.current;
41
+ const payload = 'function' == typeof o.payload ? o.payload() : o.payload;
42
+ running.current = true;
43
+ press.current = null;
44
+ lastPoint.current = {
45
+ x,
46
+ y
47
+ };
48
+ setActive(payload);
49
+ null == (_o_onDragStart = o.onDragStart) || _o_onDragStart.call(o, payload);
50
+ startG9Drag(payload, x, y);
51
+ };
52
+ const move = (e)=>{
53
+ const p = g9PointerPoint(e);
54
+ if (!p) return;
55
+ if (!running.current) {
56
+ const from = press.current;
57
+ if (from && Math.abs(p.x - from.x) + Math.abs(p.y - from.y) >= threshold) start(p.x, p.y);
58
+ return;
59
+ }
60
+ lastPoint.current = p;
61
+ moveG9Drag(p.x, p.y);
62
+ place(p.x, p.y);
63
+ };
64
+ const finish = (e, cancelled)=>{
65
+ var _ref;
66
+ var _latest_current_onDragEnd, _latest_current;
67
+ press.current = null;
68
+ if (!running.current) return;
69
+ running.current = false;
70
+ const p = null != (_ref = e && g9PointerPoint(e)) ? _ref : lastPoint.current;
71
+ const drop = cancelled ? (cancelG9Drag(), null) : endG9Drag(p.x, p.y);
72
+ setActive(null);
73
+ null == (_latest_current_onDragEnd = (_latest_current = latest.current).onDragEnd) || _latest_current_onDragEnd.call(_latest_current, drop);
74
+ };
75
+ useG9Keys((e)=>'Escape' === e.key ? (finish(null, true), true) : false, {
76
+ enabled: null !== active,
77
+ field: true
78
+ });
79
+ useEffect(()=>()=>{
80
+ if (running.current) cancelG9Drag();
81
+ }, []);
82
+ const preview = active ? null != (_ref = null == (_latest_current_renderPreview = (_latest_current = latest.current).renderPreview) ? void 0 : _latest_current_renderPreview.call(_latest_current, active)) ? _ref : <G9DragChip payload={active}/> : null;
83
+ const at = lastPoint.current;
84
+ const layer = active ? <view key={key} className="g9-drag-layer" bindmousemove={move} bindmouseup={(e)=>finish(e, false)} bindtouchmove={move} bindtouchend={(e)=>finish(e, false)} bindtouchcancel={()=>finish(null, true)}>
85
+ <view id={previewId} className="g9-drag-preview" style={{
86
+ transform: `translate(${Math.round(at.x + 12)}px, ${Math.round(at.y + 12)}px)`
87
+ }}>
88
+ {preview}
89
+ </view>
90
+ </view> : null;
91
+ useG9LayerItem('floating', key, layer, {
92
+ enabled: null !== active
93
+ });
94
+ if (false === options.enabled) return {
95
+ props: {},
96
+ dragging: false
97
+ };
98
+ return {
99
+ dragging: null !== active,
100
+ props: {
101
+ bindmousedown: (e)=>{
102
+ if (0 !== g9MouseButton(e)) return;
103
+ press.current = g9PointerPoint(e);
104
+ },
105
+ bindmousemove: move,
106
+ bindmouseup: (e)=>finish(e, false),
107
+ ...false === options.longPress ? {} : {
108
+ bindlongpress: (e)=>{
109
+ const p = g9PointerPoint(e);
110
+ if (p) start(p.x, p.y);
111
+ }
112
+ },
113
+ bindtouchmove: move,
114
+ bindtouchend: (e)=>finish(e, false),
115
+ bindtouchcancel: ()=>finish(null, true)
116
+ }
117
+ };
118
+ }
119
+ function G9DragChip(props) {
120
+ var _props_payload_label;
121
+ return <view className="g9-drag-chip">
122
+ <text className="g9-drag-chip__text" text-maxline="1">
123
+ {null != (_props_payload_label = props.payload.label) ? _props_payload_label : props.payload.kind}
124
+ </text>
125
+ </view>;
126
+ }
127
+ function useG9DropTarget(options) {
128
+ const id = useMemo(()=>{
129
+ var _options_id;
130
+ return null != (_options_id = options.id) ? _options_id : `g9-drop-${++seq}`;
131
+ }, [
132
+ options.id
133
+ ]);
134
+ const node = useRef(null);
135
+ const drop = useStableCallback(options.onDrop);
136
+ const enter = useStableCallback(options.onEnter);
137
+ const leave = useStableCallback(options.onLeave);
138
+ const latest = useRef(options);
139
+ latest.current = options;
140
+ const enabled = false !== options.enabled;
141
+ const [state, setState] = useState('idle');
142
+ useEffect(()=>{
143
+ if (!enabled) return;
144
+ const off = registerG9DropTarget({
145
+ id,
146
+ accepts: (p)=>latest.current.accepts ? latest.current.accepts(p) : true,
147
+ measure: ()=>measureNode(node.current),
148
+ onEnter: (_o, p)=>enter(p),
149
+ onLeave: (p)=>leave(p),
150
+ onDrop: (e)=>drop(e)
151
+ });
152
+ const offState = subscribeG9Drag((s)=>{
153
+ var _s_over;
154
+ return setState(s ? (null == (_s_over = s.over) ? void 0 : _s_over.target) === id ? 'over' : s.candidates.includes(id) ? 'candidate' : 'idle' : 'idle');
155
+ });
156
+ return ()=>{
157
+ off();
158
+ offState();
159
+ setState('idle');
160
+ };
161
+ }, [
162
+ id,
163
+ enabled
164
+ ]);
165
+ return {
166
+ ref: (n)=>{
167
+ node.current = n;
168
+ },
169
+ state
170
+ };
171
+ }
172
+ function G9DragSource(props) {
173
+ const { props: bind, dragging } = useG9DragSource(props);
174
+ return <view {...g9IdProps(props.id)} className={`g9-drag-source${dragging ? ' g9-drag-source--dragging' : ''}${props.className ? ` ${props.className}` : ''}`} {...bind}>
175
+ {props.children}
176
+ </view>;
177
+ }
178
+ function G9DropTarget(props) {
179
+ const { ref, state } = useG9DropTarget(props);
180
+ return <view {...props.id ? {
181
+ id: g9SafeId(props.id)
182
+ } : {}} ref={ref} className={`g9-drop-target g9-drop-target--${state}${props.className ? ` ${props.className}` : ''}`}>
183
+ {'function' == typeof props.children ? props.children(state) : props.children}
184
+ </view>;
185
+ }
186
+ export { G9DragChip, G9DragSource, G9DropTarget, useG9DragSource, useG9DragState, useG9DropTarget };
@@ -0,0 +1,5 @@
1
+ export { G9DragChip, G9DragSource, type G9DragSourceComponentProps, type G9DragSourceOptions, type G9DragSourceProps, G9DropTarget, type G9DropTargetOptions, type G9DropTargetProps, type G9DropTargetState, useG9DragSource, useG9DragState, useG9DropTarget, } from './drag.js';
2
+ export { cancelG9Drag, currentG9Drag, endG9Drag, type G9DragPayload, type G9DragState, type G9DropEvent, type G9DropOver, type G9DropTargetSpec, hitDropTarget, moveG9Drag, registerG9DropTarget, startG9Drag, subscribeG9Drag, } from './drag-session.js';
3
+ export { type G9Point, type G9PointerEventLike, g9MouseButton, g9PointerPoint, isSecondaryPress } from './point.js';
4
+ export { type G9LynxKeyEventLike, type G9SecondaryAction, type G9SecondaryActionOptions, type G9SecondaryActionProps, type G9SecondarySource, keyEventOf, useG9SecondaryAction, } from './secondary.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pointer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACjH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { G9DragChip, G9DragSource, G9DropTarget, useG9DragSource, useG9DragState, useG9DropTarget } from "./drag.jsx";
2
+ export { cancelG9Drag, currentG9Drag, endG9Drag, hitDropTarget, moveG9Drag, registerG9DropTarget, startG9Drag, subscribeG9Drag } from "./drag-session.jsx";
3
+ export { g9MouseButton, g9PointerPoint, isSecondaryPress } from "./point.jsx";
4
+ export { keyEventOf, useG9SecondaryAction } from "./secondary.jsx";
@@ -0,0 +1,36 @@
1
+ /** A point in the LynxView's space (dp). */
2
+ export interface G9Point {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ }
6
+ /** The fields of a Lynx pointer event this module reads. */
7
+ export interface G9PointerEventLike {
8
+ readonly detail?: {
9
+ readonly x?: number;
10
+ readonly y?: number;
11
+ readonly button?: number;
12
+ } | null;
13
+ readonly touches?: ReadonlyArray<{
14
+ readonly pageX?: number;
15
+ readonly pageY?: number;
16
+ readonly clientX?: number;
17
+ readonly clientY?: number;
18
+ }>;
19
+ readonly changedTouches?: ReadonlyArray<{
20
+ readonly pageX?: number;
21
+ readonly pageY?: number;
22
+ }>;
23
+ readonly x?: number;
24
+ readonly y?: number;
25
+ readonly pageX?: number;
26
+ readonly pageY?: number;
27
+ readonly button?: number;
28
+ readonly buttons?: number;
29
+ }
30
+ /** The event's point in the LynxView's space; `null` when the event carries none. */
31
+ export declare function g9PointerPoint(e: G9PointerEventLike | null | undefined): G9Point | null;
32
+ /** The mouse button of a press: 0 primary, 1 middle, 2 secondary (the right button). A touch is 0. */
33
+ export declare function g9MouseButton(e: G9PointerEventLike | null | undefined): number;
34
+ /** True for a secondary press (the right mouse button; Ctrl+click on a Mac arrives as one from the host). */
35
+ export declare function isSecondaryPress(e: G9PointerEventLike | null | undefined): boolean;
36
+ //# sourceMappingURL=point.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../src/pointer/point.ts"],"names":[],"mappings":"AAKA,4CAA4C;AAC5C,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChG,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC,CAAC;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9F,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAQvF;AAED,sGAAsG;AACtG,wBAAgB,aAAa,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAG9E;AAED,6GAA6G;AAC7G,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAElF"}
@@ -0,0 +1,34 @@
1
+ const finite = (v)=>'number' == typeof v && Number.isFinite(v);
2
+ function g9PointerPoint(e) {
3
+ var _ref;
4
+ var _e_touches, _e_changedTouches;
5
+ if (!e) return null;
6
+ const t = null != (_ref = null == (_e_touches = e.touches) ? void 0 : _e_touches[0]) ? _ref : null == (_e_changedTouches = e.changedTouches) ? void 0 : _e_changedTouches[0];
7
+ if (t && finite(t.pageX) && finite(t.pageY)) return {
8
+ x: t.pageX,
9
+ y: t.pageY
10
+ };
11
+ if (finite(e.pageX) && finite(e.pageY)) return {
12
+ x: e.pageX,
13
+ y: e.pageY
14
+ };
15
+ if (finite(e.x) && finite(e.y)) return {
16
+ x: e.x,
17
+ y: e.y
18
+ };
19
+ if (e.detail && finite(e.detail.x) && finite(e.detail.y)) return {
20
+ x: e.detail.x,
21
+ y: e.detail.y
22
+ };
23
+ return null;
24
+ }
25
+ function g9MouseButton(e) {
26
+ var _ref;
27
+ var _e_detail;
28
+ const b = null != (_ref = null == e ? void 0 : e.button) ? _ref : null == e ? void 0 : null == (_e_detail = e.detail) ? void 0 : _e_detail.button;
29
+ return finite(b) ? b : 0;
30
+ }
31
+ function isSecondaryPress(e) {
32
+ return 2 === g9MouseButton(e);
33
+ }
34
+ export { g9MouseButton, g9PointerPoint, isSecondaryPress };
@@ -0,0 +1,62 @@
1
+ .g9-drag-layer {
2
+ display: flex;
3
+ position: fixed;
4
+ top: 0;
5
+ bottom: 0;
6
+ left: 0;
7
+ right: 0;
8
+ }
9
+
10
+ .g9-drag-preview {
11
+ pointer-events: none;
12
+ opacity: .92;
13
+ display: flex;
14
+ position: absolute;
15
+ top: 0;
16
+ left: 0;
17
+ }
18
+
19
+ .g9-drag-chip {
20
+ background-color: var(--g9-inverse-surface);
21
+ border-radius: 999px;
22
+ flex-direction: row;
23
+ align-items: center;
24
+ max-width: 280px;
25
+ padding: 6px 12px;
26
+ display: flex;
27
+ }
28
+
29
+ .g9-drag-chip__text {
30
+ font-size: 13px;
31
+ font-family: var(--g9-font-text);
32
+ color: var(--g9-inverse-on-surface);
33
+ }
34
+
35
+ .g9-drag-source {
36
+ flex-direction: column;
37
+ display: flex;
38
+ }
39
+
40
+ .g9-drag-source--dragging {
41
+ opacity: .45;
42
+ }
43
+
44
+ .g9-drop-target {
45
+ border-radius: var(--g9-radius-card);
46
+ border: 2px solid #0000;
47
+ flex-direction: column;
48
+ display: flex;
49
+ }
50
+
51
+ .g9-drop-target--candidate {
52
+ border-style: dashed;
53
+ border-color: var(--g9-primary);
54
+ }
55
+
56
+ .g9-drop-target--over {
57
+ border-color: var(--g9-primary);
58
+ background-color: var(--g9-primary-container);
59
+ }
60
+
61
+
62
+ /*# sourceMappingURL=pointer.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack://./src/pointer/pointer.css"],"names":[],"mappings":"AAEA;EADE,aAAa;EACb,eAAe;EACf,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AAIA;EADE,oBAAoB;EACpB,YAAY;EACZ,aAAa;EACb,kBAAkB;EAClB,MAAM;EACN,OAAO;AACT;;AAIA;EADE,2CAA2C;EAC3C,oBAAoB;EACpB,mBAAmB;EACnB,mBAAmB;EACnB,gBAAgB;EAChB,iBAAiB;EACjB,aAAa;AACf;;AAIA;EADE,eAAe;EACf,gCAAgC;EAChC,mCAAmC;AACrC;;AAIA;EADE,sBAAsB;EACtB,aAAa;AACf;;AAIA;EADE,YAAY;AACd;;AAIA;EADE,oCAAoC;EACpC,uBAAuB;EACvB,sBAAsB;EACtB,aAAa;AACf;;AAMA;EAHE,oBAAoB;EACpB,+BAA+B;AACjC;;AAMA;EAHE,+BAA+B;EAC/B,6CAA6C;AAC/C","sourcesContent":["/* Drag and drop between regions (2.9.0): the layer that takes the pointer during a drag, the preview, the default chip,\n a source while it is dragged and a target's light. */\n.g9-drag-layer {\n position: fixed;\n left: 0px;\n top: 0px;\n right: 0px;\n bottom: 0px;\n display: flex;\n}\n\n.g9-drag-preview {\n position: absolute;\n left: 0px;\n top: 0px;\n display: flex;\n pointer-events: none;\n opacity: 0.92;\n}\n\n.g9-drag-chip {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 6px 12px;\n border-radius: 999px;\n background-color: var(--g9-inverse-surface);\n max-width: 280px;\n}\n\n.g9-drag-chip__text {\n font-size: 13px;\n font-family: var(--g9-font-text);\n color: var(--g9-inverse-on-surface);\n}\n\n.g9-drag-source {\n display: flex;\n flex-direction: column;\n}\n\n.g9-drag-source--dragging {\n opacity: 0.45;\n}\n\n.g9-drop-target {\n display: flex;\n flex-direction: column;\n border-width: 2px;\n border-style: solid;\n border-color: transparent;\n border-radius: var(--g9-radius-card);\n}\n\n.g9-drop-target--candidate {\n border-style: dashed;\n border-color: var(--g9-primary);\n}\n\n.g9-drop-target--over {\n border-color: var(--g9-primary);\n background-color: var(--g9-primary-container);\n}\n"],"sourceRoot":""}
@@ -0,0 +1,54 @@
1
+ import { type G9KeyEvent } from '@g9tm/lynxcontrols-foundation';
2
+ import type { NodesRef } from '@lynx-js/types';
3
+ import type { G9AnchorRect } from '../anchor/registry.js';
4
+ import { type G9PointerEventLike } from './point.js';
5
+ /** How a secondary action was asked for. */
6
+ export type G9SecondarySource = 'mouse' | 'touch' | 'keyboard';
7
+ /** What a secondary action hands its handler. */
8
+ export interface G9SecondaryAction {
9
+ readonly source: G9SecondarySource;
10
+ /** Where to open: the pointer (a 0×0 rect) for a mouse or a long press with a point, else the element's rect. */
11
+ readonly anchor: G9AnchorRect;
12
+ }
13
+ /** Options of {@link useG9SecondaryAction}. */
14
+ export interface G9SecondaryActionOptions {
15
+ /** Default true. */
16
+ readonly enabled?: boolean;
17
+ /** A long press on touch opens it too. Default true. */
18
+ readonly longPress?: boolean;
19
+ /**
20
+ * The context-menu key and Shift+F10 open it: `'focus'` (default) when the element has the keyboard focus (its own
21
+ * `keydown`), `'global'` whenever the hook is enabled (an app's selected item: one element at a time), `'off'`.
22
+ */
23
+ readonly keyboard?: 'focus' | 'global' | 'off';
24
+ /** A light haptic when it opens from a long press. Default true. */
25
+ readonly haptic?: boolean;
26
+ }
27
+ /** The props {@link useG9SecondaryAction} puts on the element. */
28
+ export interface G9SecondaryActionProps {
29
+ readonly ref: (node: NodesRef | null) => void;
30
+ readonly bindmousedown?: (e: G9PointerEventLike) => void;
31
+ readonly bindlongpress?: (e: G9PointerEventLike) => void;
32
+ readonly bindkeydown?: (e: G9LynxKeyEventLike) => void;
33
+ }
34
+ /** A Lynx `keydown` event as the desktop engine sends it. */
35
+ export interface G9LynxKeyEventLike {
36
+ readonly key?: string;
37
+ readonly shiftKey?: boolean;
38
+ readonly ctrlKey?: boolean;
39
+ readonly altKey?: boolean;
40
+ readonly metaKey?: boolean;
41
+ readonly detail?: {
42
+ readonly key?: string;
43
+ readonly shiftKey?: boolean;
44
+ } | null;
45
+ }
46
+ /** A Lynx `keydown` event as a `G9KeyEvent` (null without a key). */
47
+ export declare function keyEventOf(e: G9LynxKeyEventLike | null | undefined): G9KeyEvent | null;
48
+ /**
49
+ * Gives an element its secondary action: spread the returned props on it (`<view {...props}>`). `onAction` hears the
50
+ * source and where to open (`G9Menu`'s `anchorRect`). The right button opens on press, as on every desktop; the primary
51
+ * button and a tap are left to the element.
52
+ */
53
+ export declare function useG9SecondaryAction(onAction: (action: G9SecondaryAction) => void, options?: G9SecondaryActionOptions): G9SecondaryActionProps;
54
+ //# sourceMappingURL=secondary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondary.d.ts","sourceRoot":"","sources":["../../src/pointer/secondary.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAA8B,MAAM,+BAA+B,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAE,KAAK,kBAAkB,EAAoC,MAAM,SAAS,CAAC;AAEpF,4CAA4C;AAC5C,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/D,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,iHAAiH;IACjH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED,+CAA+C;AAC/C,MAAM,WAAW,wBAAwB;IACvC,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC/C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