@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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import "./dock.css";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "@lynx-js/react";
|
|
3
|
+
import { g9IdProps, g9RowStyle, mergeStyle } from "../base/control.jsx";
|
|
4
|
+
import { G9Icon } from "../icon/icon.jsx";
|
|
5
|
+
import { g9ViewPoint } from "../pointer/pad.jsx";
|
|
6
|
+
import { useG9Core, useG9Direction } from "../provider/hooks.jsx";
|
|
7
|
+
const DEFAULT_MIN = 48;
|
|
8
|
+
function normalizeDockSizes(weights) {
|
|
9
|
+
const w = weights.map((v)=>Number.isFinite(v) && v > 0 ? v : 1);
|
|
10
|
+
const sum = w.reduce((a, b)=>a + b, 0);
|
|
11
|
+
return w.map((v)=>v / sum);
|
|
12
|
+
}
|
|
13
|
+
function dragDockSizes(fractions, open, index, delta, free, mins) {
|
|
14
|
+
var _mins_index, _mins_;
|
|
15
|
+
const next = [
|
|
16
|
+
...fractions
|
|
17
|
+
];
|
|
18
|
+
const shareOpen = fractions.reduce((sum, f, i)=>open[i] ? sum + f : sum, 0);
|
|
19
|
+
if (shareOpen <= 0 || free <= 0 || !open[index] || !open[index + 1]) return next;
|
|
20
|
+
const px = (i)=>fractions[i] / shareOpen * free;
|
|
21
|
+
const a = px(index);
|
|
22
|
+
const b = px(index + 1);
|
|
23
|
+
const minA = null != (_mins_index = mins[index]) ? _mins_index : DEFAULT_MIN;
|
|
24
|
+
const minB = null != (_mins_ = mins[index + 1]) ? _mins_ : DEFAULT_MIN;
|
|
25
|
+
const pair = a + b;
|
|
26
|
+
const newA = Math.max(Math.min(a + delta, pair - minB), Math.min(minA, pair));
|
|
27
|
+
const newB = pair - newA;
|
|
28
|
+
next[index] = newA / free * shareOpen;
|
|
29
|
+
next[index + 1] = newB / free * shareOpen;
|
|
30
|
+
return next;
|
|
31
|
+
}
|
|
32
|
+
function initialDockSizes(node, into = {}) {
|
|
33
|
+
if ('pane' === node.kind) return into;
|
|
34
|
+
into[node.id] = normalizeDockSizes(node.children.map((c)=>{
|
|
35
|
+
var _c_size;
|
|
36
|
+
return null != (_c_size = c.size) ? _c_size : 1;
|
|
37
|
+
}));
|
|
38
|
+
for (const child of node.children)initialDockSizes(child, into);
|
|
39
|
+
return into;
|
|
40
|
+
}
|
|
41
|
+
const firstPane = (node)=>'pane' === node.kind ? node : node.children.length ? firstPane(node.children[0]) : null;
|
|
42
|
+
function readStore(raw) {
|
|
43
|
+
if (!raw) return {};
|
|
44
|
+
try {
|
|
45
|
+
const v = JSON.parse(raw);
|
|
46
|
+
return v && 'object' == typeof v ? v : {};
|
|
47
|
+
} catch {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function G9DockLayout(props) {
|
|
52
|
+
var _props_collapsed, _props_railSize, _props_splitterSize;
|
|
53
|
+
const core = useG9Core();
|
|
54
|
+
const dir = useG9Direction();
|
|
55
|
+
const rtl = 'rtl' === dir;
|
|
56
|
+
const base = useMemo(()=>initialDockSizes(props.layout), [
|
|
57
|
+
props.layout
|
|
58
|
+
]);
|
|
59
|
+
const withStored = (from, st)=>{
|
|
60
|
+
var _st_sizes;
|
|
61
|
+
const out = {
|
|
62
|
+
...from
|
|
63
|
+
};
|
|
64
|
+
for (const [k, v] of Object.entries(null != (_st_sizes = st.sizes) ? _st_sizes : {}))if (Array.isArray(v) && out[k] && v.length === out[k].length) out[k] = normalizeDockSizes(v);
|
|
65
|
+
return out;
|
|
66
|
+
};
|
|
67
|
+
const readKey = ()=>props.storageKey ? readStore(core.preferences.getString(props.storageKey, '')) : {};
|
|
68
|
+
const [sizes, setSizes] = useState(()=>withStored(base, readKey()));
|
|
69
|
+
const [ownCollapsed, setOwnCollapsed] = useState(()=>{
|
|
70
|
+
var _ref, _readKey_collapsed;
|
|
71
|
+
return null != (_ref = null != (_readKey_collapsed = readKey().collapsed) ? _readKey_collapsed : props.defaultCollapsed) ? _ref : [];
|
|
72
|
+
});
|
|
73
|
+
const touched = useRef(false);
|
|
74
|
+
useEffect(()=>{
|
|
75
|
+
if (!props.storageKey || core.preferences.getSnapshot().hydrated) return;
|
|
76
|
+
return core.preferences.subscribe((snap)=>{
|
|
77
|
+
if (!snap.hydrated || touched.current) return;
|
|
78
|
+
const st = readKey();
|
|
79
|
+
setSizes((prev)=>withStored(prev, st));
|
|
80
|
+
if (st.collapsed && void 0 === props.collapsed) setOwnCollapsed(st.collapsed);
|
|
81
|
+
});
|
|
82
|
+
}, [
|
|
83
|
+
props.storageKey
|
|
84
|
+
]);
|
|
85
|
+
const collapsed = null != (_props_collapsed = props.collapsed) ? _props_collapsed : ownCollapsed;
|
|
86
|
+
useEffect(()=>{
|
|
87
|
+
setSizes((prev)=>{
|
|
88
|
+
const out = {};
|
|
89
|
+
for (const [k, v] of Object.entries(base)){
|
|
90
|
+
const had = prev[k];
|
|
91
|
+
out[k] = had && had.length === v.length ? had : v;
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
});
|
|
95
|
+
}, [
|
|
96
|
+
base
|
|
97
|
+
]);
|
|
98
|
+
const latest = useRef({
|
|
99
|
+
sizes,
|
|
100
|
+
collapsed
|
|
101
|
+
});
|
|
102
|
+
latest.current = {
|
|
103
|
+
sizes,
|
|
104
|
+
collapsed
|
|
105
|
+
};
|
|
106
|
+
const extents = useRef({});
|
|
107
|
+
const drag = useRef(null);
|
|
108
|
+
const railSize = null != (_props_railSize = props.railSize) ? _props_railSize : 40;
|
|
109
|
+
const splitterSize = null != (_props_splitterSize = props.splitterSize) ? _props_splitterSize : 6;
|
|
110
|
+
const persist = (next)=>{
|
|
111
|
+
touched.current = true;
|
|
112
|
+
if (props.storageKey) core.preferences.setString(props.storageKey, JSON.stringify(next));
|
|
113
|
+
};
|
|
114
|
+
const setCollapsed = (next)=>{
|
|
115
|
+
var _props_onCollapsedChange, _props_onChange;
|
|
116
|
+
if (void 0 === props.collapsed) setOwnCollapsed(next);
|
|
117
|
+
null == (_props_onCollapsedChange = props.onCollapsedChange) || _props_onCollapsedChange.call(props, next);
|
|
118
|
+
persist({
|
|
119
|
+
sizes: latest.current.sizes,
|
|
120
|
+
collapsed: next
|
|
121
|
+
});
|
|
122
|
+
null == (_props_onChange = props.onChange) || _props_onChange.call(props, latest.current.sizes);
|
|
123
|
+
};
|
|
124
|
+
const isOpen = (node)=>'pane' === node.kind ? !collapsed.includes(node.id) : node.children.some(isOpen);
|
|
125
|
+
const splitter = (split, index, open)=>{
|
|
126
|
+
var _props_splitterLabel;
|
|
127
|
+
const horizontal = 'row' === split.kind;
|
|
128
|
+
const active = !props.fixed && true === open[index] && true === open[index + 1];
|
|
129
|
+
const axis = (e)=>{
|
|
130
|
+
const p = g9ViewPoint(e);
|
|
131
|
+
return p ? horizontal ? p.x : p.y : null;
|
|
132
|
+
};
|
|
133
|
+
const start = (e)=>{
|
|
134
|
+
var _latest_current_sizes_split_id;
|
|
135
|
+
if (!active) return;
|
|
136
|
+
const at = axis(e);
|
|
137
|
+
if (null === at) return;
|
|
138
|
+
drag.current = {
|
|
139
|
+
split: split.id,
|
|
140
|
+
index,
|
|
141
|
+
start: at,
|
|
142
|
+
from: null != (_latest_current_sizes_split_id = latest.current.sizes[split.id]) ? _latest_current_sizes_split_id : []
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const move = (e)=>{
|
|
146
|
+
var _extents_current_split_id;
|
|
147
|
+
const d = drag.current;
|
|
148
|
+
if (!d || d.split !== split.id || d.index !== index) return;
|
|
149
|
+
const at = axis(e);
|
|
150
|
+
if (null === at) return;
|
|
151
|
+
let delta = at - d.start;
|
|
152
|
+
if (horizontal && rtl) delta = -delta;
|
|
153
|
+
const rails = open.filter((o)=>!o).length;
|
|
154
|
+
const free = (null != (_extents_current_split_id = extents.current[split.id]) ? _extents_current_split_id : 0) - rails * railSize - (split.children.length - 1) * splitterSize;
|
|
155
|
+
const mins = split.children.map((c)=>{
|
|
156
|
+
var _ref;
|
|
157
|
+
var _props_minSizes;
|
|
158
|
+
const pane = 'pane' === c.kind ? c : firstPane(c);
|
|
159
|
+
return pane ? null != (_ref = null == (_props_minSizes = props.minSizes) ? void 0 : _props_minSizes[pane.id]) ? _ref : DEFAULT_MIN : DEFAULT_MIN;
|
|
160
|
+
});
|
|
161
|
+
const next = dragDockSizes(d.from, open, index, delta, free, mins);
|
|
162
|
+
touched.current = true;
|
|
163
|
+
setSizes((prev)=>({
|
|
164
|
+
...prev,
|
|
165
|
+
[split.id]: next
|
|
166
|
+
}));
|
|
167
|
+
};
|
|
168
|
+
const end = ()=>{
|
|
169
|
+
var _props_onChange;
|
|
170
|
+
if (!drag.current) return;
|
|
171
|
+
drag.current = null;
|
|
172
|
+
persist({
|
|
173
|
+
sizes: latest.current.sizes,
|
|
174
|
+
collapsed: latest.current.collapsed
|
|
175
|
+
});
|
|
176
|
+
null == (_props_onChange = props.onChange) || _props_onChange.call(props, latest.current.sizes);
|
|
177
|
+
};
|
|
178
|
+
return <view key={`s${index}`} {...g9IdProps(props.id ? `${props.id}_Split_${split.id}_${index}` : void 0)} className={`g9-dock__splitter g9-dock__splitter--${horizontal ? 'v' : 'h'}${active ? '' : ' g9-dock__splitter--off'}`} style={horizontal ? {
|
|
179
|
+
width: `${splitterSize}px`
|
|
180
|
+
} : {
|
|
181
|
+
height: `${splitterSize}px`
|
|
182
|
+
}} bindtouchstart={start} bindtouchmove={move} bindtouchend={end} bindtouchcancel={end} bindmousedown={start} bindmousemove={(e)=>{
|
|
183
|
+
if ('number' == typeof e.buttons && 0 === e.buttons) return end();
|
|
184
|
+
move(e);
|
|
185
|
+
}} bindmouseup={end} accessibility-element={active} accessibility-label={null != (_props_splitterLabel = props.splitterLabel) ? _props_splitterLabel : ''}>
|
|
186
|
+
{active ? <view className={`g9-dock__grip g9-dock__grip--${horizontal ? 'v' : 'h'}`}/> : null}
|
|
187
|
+
</view>;
|
|
188
|
+
};
|
|
189
|
+
const rail = (pane, horizontal)=><view key={pane.id} {...g9IdProps(props.id ? `${props.id}_Rail_${pane.id}` : void 0)} className={`g9-dock__rail g9-dock__rail--${horizontal ? 'v' : 'h'}`} style={horizontal ? {
|
|
190
|
+
width: `${railSize}px`
|
|
191
|
+
} : {
|
|
192
|
+
height: `${railSize}px`,
|
|
193
|
+
...g9RowStyle(dir)
|
|
194
|
+
}} bindtap={()=>setCollapsed(collapsed.filter((c)=>c !== pane.id))} accessibility-element={true} accessibility-traits="button" accessibility-label={[
|
|
195
|
+
pane.title,
|
|
196
|
+
props.railLabel
|
|
197
|
+
].filter(Boolean).join(', ')}>
|
|
198
|
+
{pane.icon ? <G9Icon icon={pane.icon} size={18} color="var(--g9-text-secondary)"/> : null}
|
|
199
|
+
{!horizontal && pane.title ? <text className="g9-dock__rail-title" text-maxline="1">
|
|
200
|
+
{pane.title}
|
|
201
|
+
</text> : null}
|
|
202
|
+
</view>;
|
|
203
|
+
const render = (node, parent, weight)=>{
|
|
204
|
+
var _sizes_node_id;
|
|
205
|
+
const horizontalParent = (null == parent ? void 0 : parent.kind) === 'row';
|
|
206
|
+
const flex = {
|
|
207
|
+
flexGrow: weight,
|
|
208
|
+
flexShrink: 1,
|
|
209
|
+
flexBasis: '0px',
|
|
210
|
+
...horizontalParent ? {
|
|
211
|
+
minWidth: '0px'
|
|
212
|
+
} : {
|
|
213
|
+
minHeight: '0px'
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
if ('pane' === node.kind) {
|
|
217
|
+
var _props_minSizes;
|
|
218
|
+
if (parent && collapsed.includes(node.id)) return rail(node, horizontalParent);
|
|
219
|
+
const min = null == (_props_minSizes = props.minSizes) ? void 0 : _props_minSizes[node.id];
|
|
220
|
+
return <view key={node.id} className="g9-dock__pane" style={{
|
|
221
|
+
...parent ? flex : {
|
|
222
|
+
flexGrow: 1
|
|
223
|
+
},
|
|
224
|
+
...void 0 !== min && parent ? {
|
|
225
|
+
[horizontalParent ? 'minWidth' : 'minHeight']: `${min}px`
|
|
226
|
+
} : {}
|
|
227
|
+
}}>
|
|
228
|
+
{props.renderPane(node.id, {
|
|
229
|
+
collapsed: false,
|
|
230
|
+
collapse: ()=>{
|
|
231
|
+
if (!collapsed.includes(node.id)) setCollapsed([
|
|
232
|
+
...collapsed,
|
|
233
|
+
node.id
|
|
234
|
+
]);
|
|
235
|
+
}
|
|
236
|
+
})}
|
|
237
|
+
</view>;
|
|
238
|
+
}
|
|
239
|
+
const fractions = null != (_sizes_node_id = sizes[node.id]) ? _sizes_node_id : normalizeDockSizes(node.children.map((c)=>{
|
|
240
|
+
var _c_size;
|
|
241
|
+
return null != (_c_size = c.size) ? _c_size : 1;
|
|
242
|
+
}));
|
|
243
|
+
const open = node.children.map(isOpen);
|
|
244
|
+
const children = [];
|
|
245
|
+
node.children.forEach((child, i)=>{
|
|
246
|
+
var _fractions_i;
|
|
247
|
+
if (i > 0) children.push(splitter(node, i - 1, open));
|
|
248
|
+
if (!open[i]) {
|
|
249
|
+
const pane = 'pane' === child.kind ? child : firstPane(child);
|
|
250
|
+
if (pane) children.push(rail(pane, 'row' === node.kind));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
children.push(render(child, node, null != (_fractions_i = fractions[i]) ? _fractions_i : 1));
|
|
254
|
+
});
|
|
255
|
+
return <view key={node.id} className={`g9-dock__split g9-dock__split--${node.kind}`} style={{
|
|
256
|
+
...parent ? flex : {
|
|
257
|
+
flexGrow: 1
|
|
258
|
+
},
|
|
259
|
+
...'row' === node.kind ? g9RowStyle(dir) : {}
|
|
260
|
+
}} bindlayoutchange={(e)=>{
|
|
261
|
+
var _e_detail, _e_detail1;
|
|
262
|
+
const v = 'row' === node.kind ? null == (_e_detail = e.detail) ? void 0 : _e_detail.width : null == (_e_detail1 = e.detail) ? void 0 : _e_detail1.height;
|
|
263
|
+
if ('number' == typeof v) extents.current[node.id] = v;
|
|
264
|
+
}}>
|
|
265
|
+
{children}
|
|
266
|
+
</view>;
|
|
267
|
+
};
|
|
268
|
+
return <view {...g9IdProps(props.id)} className={`g9-dock${props.className ? ` ${props.className}` : ''}`} style={mergeStyle(void 0, props.style)}>
|
|
269
|
+
{render(props.layout, null, 1)}
|
|
270
|
+
</view>;
|
|
271
|
+
}
|
|
272
|
+
export { G9DockLayout, dragDockSizes, initialDockSizes, normalizeDockSizes };
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { G9ActionRow, type G9ActionRowProps, G9Bento, type G9BentoProps, G9Card, type G9CardProps, G9Columns, type G9ColumnsProps, G9SaveBar, G9Section, G9SectionHeader, type G9SectionHeaderProps, type G9SectionProps, G9UnsavedBar, type G9UnsavedBarProps, } from './containers.js';
|
|
2
|
+
export { dragDockSizes, G9DockLayout, type G9DockLayoutProps, type G9DockNode, type G9DockPane, type G9DockPaneApi, type G9DockSplit, type G9DockState, initialDockSizes, normalizeDockSizes, } from './dock.js';
|
|
2
3
|
export { G9ScrollSpyBar, type G9ScrollSpyBarProps } from './scroll-spy.js';
|
|
3
4
|
export { G9HScroll, type G9HScrollProps, G9Page, type G9PageProps, G9PlaceScroll, type G9PlaceScrollProps, G9SplitPane, type G9SplitPaneProps, useG9RtlScrollStart, } from './scrollers.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,WAAW,EAChB,SAAS,EACT,KAAK,cAAc,EACnB,SAAS,EACT,SAAS,EACT,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,MAAM,EACN,KAAK,WAAW,EAChB,aAAa,EACb,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,WAAW,EAChB,SAAS,EACT,KAAK,cAAc,EACnB,SAAS,EACT,SAAS,EACT,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,MAAM,EACN,KAAK,WAAW,EAChB,aAAa,EACb,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
|
package/dist/layout/index.jsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { G9ActionRow, G9Bento, G9Card, G9Columns, G9SaveBar, G9Section, G9SectionHeader, G9UnsavedBar } from "./containers.jsx";
|
|
2
|
+
export { G9DockLayout, dragDockSizes, initialDockSizes, normalizeDockSizes } from "./dock.jsx";
|
|
2
3
|
export { G9ScrollSpyBar } from "./scroll-spy.jsx";
|
|
3
4
|
export { G9HScroll, G9Page, G9PlaceScroll, G9SplitPane, useG9RtlScrollStart } from "./scrollers.jsx";
|
|
@@ -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,I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M,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7F;AAcD,oGAAoG;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 };
|
|
@@ -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,EAA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