@g9tm/lynxcontrols 2.9.0 → 2.10.1
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/catalog/cards/G9DockLayout.md +17 -0
- package/catalog/cards/G9KeyDiamond.md +15 -0
- package/catalog/cards/G9KeySlider.md +17 -0
- package/catalog/catalog.json +1249 -7
- package/catalog/index.md +4 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchor/hooks.d.ts.map +1 -1
- package/dist/anchor/hooks.jsx +1 -1
- package/dist/base/control.d.ts +9 -0
- package/dist/base/control.d.ts.map +1 -1
- package/dist/base/control.jsx +14 -1
- package/dist/base/index.d.ts +1 -1
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.jsx +1 -1
- package/dist/base/press.d.ts +16 -1
- package/dist/base/press.d.ts.map +1 -1
- package/dist/base/press.jsx +29 -3
- package/dist/base/text-of.d.ts +10 -0
- package/dist/base/text-of.d.ts.map +1 -0
- package/dist/base/text-of.jsx +26 -0
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.jsx +6 -2
- package/dist/display/figures.d.ts +1 -1
- package/dist/display/figures.d.ts.map +1 -1
- package/dist/display/figures.jsx +2 -2
- package/dist/display/motion-figures.d.ts +5 -2
- package/dist/display/motion-figures.d.ts.map +1 -1
- package/dist/display/motion-figures.jsx +4 -4
- package/dist/layout/containers.d.ts +6 -1
- package/dist/layout/containers.d.ts.map +1 -1
- package/dist/layout/containers.jsx +7 -2
- 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/list/virtual-list.d.ts +11 -1
- package/dist/list/virtual-list.d.ts.map +1 -1
- package/dist/list/virtual-list.jsx +36 -7
- package/dist/pointer/index.d.ts +1 -0
- package/dist/pointer/index.d.ts.map +1 -1
- package/dist/pointer/index.jsx +1 -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/popover/popover.d.ts +3 -1
- package/dist/popover/popover.d.ts.map +1 -1
- package/dist/popover/popover.jsx +4 -2
- 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/dist/sheet/sizing.d.ts +3 -3
- package/dist/shell/shell.css +6 -1
- package/dist/shell/shell.css.map +1 -1
- package/dist/shell/shell.d.ts.map +1 -1
- package/dist/shell/shell.jsx +13 -7
- package/dist/tab-bar/tab-bar.d.ts +2 -0
- package/dist/tab-bar/tab-bar.d.ts.map +1 -1
- package/dist/tab-bar/tab-bar.jsx +7 -3
- package/package.json +2 -2
- package/skills/g9-lynx-app/references/catalog-index.md +11 -2
- package/skills/g9-lynx-app/references/components/datagrid.md +3 -3
- 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/media-1.md +7 -7
- 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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import './dock.css';
|
|
2
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
3
|
+
import { type G9StyleProp } from '../base/control.js';
|
|
4
|
+
import { type G9IconInput } from '../icon/icon.js';
|
|
5
|
+
/** A pane of a {@link G9DockLayout}: a leaf of the tree. */
|
|
6
|
+
export interface G9DockPane {
|
|
7
|
+
readonly kind: 'pane';
|
|
8
|
+
/** Unique in the tree: `renderPane`'s key, the minimum size's key, the rail's id. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** Its name on the rail and to a screen reader. */
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
/** Its icon on the rail. */
|
|
13
|
+
readonly icon?: G9IconInput;
|
|
14
|
+
/** Its starting weight among its siblings. Default 1. */
|
|
15
|
+
readonly size?: number;
|
|
16
|
+
}
|
|
17
|
+
/** A row (children side by side, in the reading direction) or a column (stacked) of a {@link G9DockLayout}. */
|
|
18
|
+
export interface G9DockSplit {
|
|
19
|
+
readonly kind: 'row' | 'column';
|
|
20
|
+
/** Unique in the tree: the key of its sizes in `onChange` and the store. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly children: readonly G9DockNode[];
|
|
23
|
+
/** Its starting weight in its own parent. Default 1. */
|
|
24
|
+
readonly size?: number;
|
|
25
|
+
}
|
|
26
|
+
/** A node of a {@link G9DockLayout}'s tree. */
|
|
27
|
+
export type G9DockNode = G9DockPane | G9DockSplit;
|
|
28
|
+
/** What a dock remembers: each split's children as fractions (summing to 1), and the collapsed panes. */
|
|
29
|
+
export interface G9DockState {
|
|
30
|
+
readonly sizes: Readonly<Record<string, readonly number[]>>;
|
|
31
|
+
readonly collapsed: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/** What `renderPane` may do. */
|
|
34
|
+
export interface G9DockPaneApi {
|
|
35
|
+
/** Folds the pane to its rail. */
|
|
36
|
+
readonly collapse: () => void;
|
|
37
|
+
readonly collapsed: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Props of {@link G9DockLayout}. */
|
|
40
|
+
export interface G9DockLayoutProps {
|
|
41
|
+
readonly id?: string;
|
|
42
|
+
readonly className?: string;
|
|
43
|
+
readonly style?: G9StyleProp;
|
|
44
|
+
/** The tree: rows and columns of panes. */
|
|
45
|
+
readonly layout: G9DockNode;
|
|
46
|
+
/** A pane's content. */
|
|
47
|
+
readonly renderPane: (id: string, api: G9DockPaneApi) => ReactNode;
|
|
48
|
+
/** The smallest size (dp) of a pane, by pane id, along its split's axis. Default 48. */
|
|
49
|
+
readonly minSizes?: Readonly<Record<string, number>>;
|
|
50
|
+
/** Where the sizes and the collapsed panes are remembered (the preference store). None: not remembered. */
|
|
51
|
+
readonly storageKey?: string;
|
|
52
|
+
/** The sizes (by split id, as fractions) once a drag ends, and after a pane collapses or opens. */
|
|
53
|
+
readonly onChange?: (sizes: Readonly<Record<string, readonly number[]>>) => void;
|
|
54
|
+
/** The collapsed panes (controlled); with `onCollapsedChange`. */
|
|
55
|
+
readonly collapsed?: readonly string[];
|
|
56
|
+
readonly defaultCollapsed?: readonly string[];
|
|
57
|
+
readonly onCollapsedChange?: (collapsed: readonly string[]) => void;
|
|
58
|
+
/** The rail's thickness (dp). Default 40. */
|
|
59
|
+
readonly railSize?: number;
|
|
60
|
+
/** The splitter's thickness (dp; its touch target is wider). Default 6. */
|
|
61
|
+
readonly splitterSize?: number;
|
|
62
|
+
/** No dragging (the sizes still come from the store and the tree). */
|
|
63
|
+
readonly fixed?: boolean;
|
|
64
|
+
/** The spoken name of a splitter («Resize»). */
|
|
65
|
+
readonly splitterLabel?: string;
|
|
66
|
+
/** The spoken hint of a rail («Open»), after the pane's title. */
|
|
67
|
+
readonly railLabel?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Fractions that sum to 1 (a list of weights; non-positive weights count as 1). */
|
|
70
|
+
export declare function normalizeDockSizes(weights: readonly number[]): number[];
|
|
71
|
+
/**
|
|
72
|
+
* Moves the boundary between children `index` and `index + 1` by `delta` dp, inside `free` dp of room shared by the
|
|
73
|
+
* open children (`open[i]` false = a rail, which takes no fraction), keeping each at least its minimum. Returns new
|
|
74
|
+
* fractions (the open children's share; rails keep theirs).
|
|
75
|
+
*/
|
|
76
|
+
export declare function dragDockSizes(fractions: readonly number[], open: readonly boolean[], index: number, delta: number, free: number, mins: readonly number[]): number[];
|
|
77
|
+
/** The starting state of a tree: each split's children by their `size` weights, nothing collapsed. */
|
|
78
|
+
export declare function initialDockSizes(node: G9DockNode, into?: Record<string, number[]>): Record<string, number[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Panes in nested rows and columns (an editor's frame). Drag a splitter to share the room between its neighbours
|
|
81
|
+
* (each keeps its `minSizes`); `renderPane(id, { collapse })` folds a pane to a rail with its icon, and a tap on the
|
|
82
|
+
* rail opens it. With `storageKey` the sizes and the folded panes come back next time. Rows follow the reading
|
|
83
|
+
* direction. Ids: `<id>`, `<id>_Split_<splitId>_<n>` (the splitter after child n), `<id>_Rail_<paneId>`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function G9DockLayout(props: G9DockLayoutProps): ReactNode;
|
|
86
|
+
//# sourceMappingURL=dock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.d.ts","sourceRoot":"","sources":["../../src/layout/dock.tsx"],"names":[],"mappings":"AAGA,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,cAAc,C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AAS,EAAE,SAAS,MAAM,EAAE,EAC5B,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,EAAE,CAeV;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAKhH;AAeD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA8MhE"}
|
|
@@ -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";
|
|
@@ -116,7 +116,10 @@ export interface G9VirtualListProps<T> {
|
|
|
116
116
|
* there. Every row still costs a little on the background thread even deferred (~1 ms each on a Galaxy A21s: 10 000
|
|
117
117
|
* rows were 10 s of script before the first touch), so a long list should never describe all its rows at once.
|
|
118
118
|
* Default: on for more than {@link g9ListProgressiveFrom} items in a vertical list that does not start at the end.
|
|
119
|
-
*
|
|
119
|
+
* On the web host (its list keeps every described cell in the page) the default is on above one screen: two rows at
|
|
120
|
+
* first, then one row per frame up to two screens ({@link g9WebListScreenItems}), and a screen more, row by row, when
|
|
121
|
+
* the scroll nears the end. Give `estimatedSize` near the real row height: the screen is counted with it. `onEndReached` fires once every item is
|
|
122
|
+
* shown.
|
|
120
123
|
*/
|
|
121
124
|
readonly progressive?: boolean;
|
|
122
125
|
/**
|
|
@@ -221,6 +224,13 @@ export declare const g9ListProgressiveFrom = 300;
|
|
|
221
224
|
export declare const g9ListFirstBatch = 24;
|
|
222
225
|
/** Rows added each time the scroll nears the end of the described part (40 rows ahead of it). */
|
|
223
226
|
export declare const g9ListNextBatch = 96;
|
|
227
|
+
/**
|
|
228
|
+
* How many items fill one screen of a list on the web host: the window's height over the estimated item size, in whole
|
|
229
|
+
* rows of `columns`. Lynx for Web's list does not recycle its cells (every described row is in the page), so there a
|
|
230
|
+
* list grows a screen at a time, one row per frame (G9Studio 2.8.4: 60 tiles were 3.8 s of script before Projects
|
|
231
|
+
* opened).
|
|
232
|
+
*/
|
|
233
|
+
export declare function g9WebListScreenItems(estimatedSize: number, columns: number): number;
|
|
224
234
|
/**
|
|
225
235
|
* A virtualised list on Lynx's native `<list>` (G9Hub VirtualList, SAC DataGrid rows, every long list): elements are
|
|
226
236
|
* recycled and laid out lazily by the engine, so 10 000 rows cost what one screen costs. Each row is memoised by its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../src/list/virtual-list.tsx"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,EAAQ,KAAK,SAAS,EAAoD,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,iBAAiB,CAAC;AAK1E,sCAAsC;AACtC,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,wGAAwG;IACxG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;IACrF;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,I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AE,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAIjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE;IAClC,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CAqB5G;AAED,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,iJAAiJ;AACjJ,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,iGAAiG;AACjG,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOnF;AA4BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,CAugBxE"}
|
|
@@ -53,6 +53,14 @@ function g9LastRowWatcher(o) {
|
|
|
53
53
|
const g9ListProgressiveFrom = 300;
|
|
54
54
|
const g9ListFirstBatch = 24;
|
|
55
55
|
const g9ListNextBatch = 96;
|
|
56
|
+
function g9WebListScreenItems(estimatedSize, columns) {
|
|
57
|
+
const info = globalThis.SystemInfo;
|
|
58
|
+
const ratio = (null == info ? void 0 : info.pixelRatio) && info.pixelRatio > 0 ? info.pixelRatio : 1;
|
|
59
|
+
const height = (null == info ? void 0 : info.pixelHeight) && info.pixelHeight > 0 ? info.pixelHeight / ratio : 800;
|
|
60
|
+
const size = Number.isFinite(estimatedSize) && estimatedSize > 0 ? estimatedSize : 56;
|
|
61
|
+
const cols = Math.max(1, Math.floor(columns));
|
|
62
|
+
return Math.max(cols, Math.ceil(height / size) * cols);
|
|
63
|
+
}
|
|
56
64
|
const Cell = memo(function(props) {
|
|
57
65
|
return props.render();
|
|
58
66
|
});
|
|
@@ -118,16 +126,27 @@ function G9VirtualList(props) {
|
|
|
118
126
|
const columns = Math.max(1, null != (_props_columns = props.columns) ? _props_columns : 1);
|
|
119
127
|
const listType = 'waterfall' === props.kind ? 'waterfall' : columns > 1 ? 'flow' : 'single';
|
|
120
128
|
const total = props.items.length;
|
|
121
|
-
const
|
|
122
|
-
const
|
|
129
|
+
const web = onWebHost();
|
|
130
|
+
const screen = web ? g9WebListScreenItems('function' == typeof est ? total ? est(props.items[0], 0) : 56 : est, 'waterfall' === props.kind || columns > 1 ? columns : 1) : 0;
|
|
131
|
+
const lazyWeb = web && !props.startAtEnd && !props.horizontal;
|
|
132
|
+
const progressive = null != (_props_progressive = props.progressive) ? _props_progressive : lazyWeb ? total > screen : total > g9ListProgressiveFrom && !props.startAtEnd && !props.horizontal;
|
|
133
|
+
const step = columns > 1 || 'waterfall' === props.kind ? columns : Math.max(1, Math.ceil(screen / 6));
|
|
134
|
+
const firstBatch = web ? Math.min(screen, 2 * step) : g9ListFirstBatch;
|
|
135
|
+
const nextBatch = web ? screen : g9ListNextBatch;
|
|
136
|
+
const firstLimit = Math.max(firstBatch, (null != initialItem ? initialItem : 0) + Math.ceil(firstBatch / 2));
|
|
137
|
+
const firstTarget = Math.max(firstLimit, 2 * screen);
|
|
123
138
|
const [limit, setLimit] = useState(firstLimit);
|
|
139
|
+
const [target, setTarget] = useState(firstTarget);
|
|
124
140
|
const firstKey = total ? props.getKey(props.items[0], 0) : '';
|
|
125
141
|
const lastFirstKey = useRef(firstKey);
|
|
126
142
|
let effectiveLimit = limit;
|
|
143
|
+
let effectiveTarget = target;
|
|
127
144
|
if (lastFirstKey.current !== firstKey) {
|
|
128
145
|
lastFirstKey.current = firstKey;
|
|
129
146
|
effectiveLimit = firstLimit;
|
|
147
|
+
effectiveTarget = firstTarget;
|
|
130
148
|
if (limit !== firstLimit) setLimit(firstLimit);
|
|
149
|
+
if (target !== effectiveTarget) setTarget(effectiveTarget);
|
|
131
150
|
}
|
|
132
151
|
const shown = progressive ? Math.min(total, effectiveLimit) : total;
|
|
133
152
|
const more = progressive && shown < total;
|
|
@@ -137,14 +156,23 @@ function G9VirtualList(props) {
|
|
|
137
156
|
total
|
|
138
157
|
]);
|
|
139
158
|
useEffect(()=>{
|
|
140
|
-
if (!progressive || shown >= total
|
|
159
|
+
if (!progressive || shown >= total) return;
|
|
160
|
+
if (web) {
|
|
161
|
+
if (shown >= effectiveTarget) return;
|
|
162
|
+
const t = setTimeout(()=>setLimit((l)=>Math.min(Math.max(l, shown) + step, effectiveTarget)), 16);
|
|
163
|
+
return ()=>clearTimeout(t);
|
|
164
|
+
}
|
|
165
|
+
if (shown > firstLimit) return;
|
|
141
166
|
const t = setTimeout(()=>setLimit((l)=>Math.max(l, firstLimit) + g9ListNextBatch), 0);
|
|
142
167
|
return ()=>clearTimeout(t);
|
|
143
168
|
}, [
|
|
144
169
|
progressive,
|
|
145
170
|
shown,
|
|
146
171
|
total,
|
|
147
|
-
firstLimit
|
|
172
|
+
firstLimit,
|
|
173
|
+
web,
|
|
174
|
+
effectiveTarget,
|
|
175
|
+
step
|
|
148
176
|
]);
|
|
149
177
|
const follow = (null != (_props_followEnd = props.followEnd) ? _props_followEnd : true === props.startAtEnd) !== false;
|
|
150
178
|
const inSheet = null !== useContext(G9SheetNestedScrollContext) && true !== props.horizontal;
|
|
@@ -438,13 +466,14 @@ function G9VirtualList(props) {
|
|
|
438
466
|
</view>;
|
|
439
467
|
return <list className={`g9-vlist${props.className ? ` ${props.className}` : ''}`} {...g9IdProps(props.id)} style={revealed ? mergeStyle(settle ? SHOWN : void 0, props.style) : mergeStyle(props.style, HIDDEN)} {...defer ? {
|
|
440
468
|
'custom-list-name': 'list-container'
|
|
441
|
-
} : {}} scroll-orientation={props.horizontal ? 'horizontal' : 'vertical'} list-type={listType} span-count={columns} preload-buffer-count={null != (_props_preload = props.preload) ? _props_preload : 3} lower-threshold-item-count={more ? Math.max(null != (_props_threshold = props.threshold) ? _props_threshold : 5, 40) : null != (_props_threshold1 = props.threshold) ? _props_threshold1 : 5} upper-threshold-item-count={null != (_props_threshold2 = props.threshold) ? _props_threshold2 : 5} scroll-event-throttle={null != (_props_scrollThrottle = props.scrollThrottle) ? _props_scrollThrottle : 100} bounces={null != (_props_bounces = props.bounces) ? _props_bounces : true} scroll-bar-enable={null != (_props_showScrollBar = props.showScrollBar) ? _props_showScrollBar : false} {...void 0 !== initial ? {
|
|
469
|
+
} : {}} scroll-orientation={props.horizontal ? 'horizontal' : 'vertical'} list-type={listType} span-count={columns} preload-buffer-count={null != (_props_preload = props.preload) ? _props_preload : 3} lower-threshold-item-count={more ? Math.max(null != (_props_threshold = props.threshold) ? _props_threshold : 5, web ? Math.ceil(screen / 2) : 40) : null != (_props_threshold1 = props.threshold) ? _props_threshold1 : 5} upper-threshold-item-count={null != (_props_threshold2 = props.threshold) ? _props_threshold2 : 5} scroll-event-throttle={null != (_props_scrollThrottle = props.scrollThrottle) ? _props_scrollThrottle : 100} bounces={null != (_props_bounces = props.bounces) ? _props_bounces : true} scroll-bar-enable={null != (_props_showScrollBar = props.showScrollBar) ? _props_showScrollBar : false} {...void 0 !== initial ? {
|
|
442
470
|
'initial-scroll-index': initial
|
|
443
471
|
} : {}} ref={attach} {...more || props.onEndReached || follow ? {
|
|
444
472
|
bindscrolltolower: ()=>{
|
|
445
473
|
var _props_onEndReached;
|
|
446
474
|
atEnd.current = true;
|
|
447
|
-
if (more)
|
|
475
|
+
if (more && web) setTarget((t)=>Math.max(t, shown + nextBatch));
|
|
476
|
+
else if (more) setLimit((l)=>Math.max(l, shown) + nextBatch);
|
|
448
477
|
else if (shownRef.current) null == (_props_onEndReached = props.onEndReached) || _props_onEndReached.call(props);
|
|
449
478
|
}
|
|
450
479
|
} : {}} {...props.onStartReached ? {
|
|
@@ -508,4 +537,4 @@ function G9VirtualList(props) {
|
|
|
508
537
|
</list-item> : null}
|
|
509
538
|
</list>;
|
|
510
539
|
}
|
|
511
|
-
export { G9VirtualList, g9LastRowWatcher, g9ListFirstBatch, g9ListNextBatch, g9ListOwnScrollMs, g9ListProgressiveFrom, g9ListRevealMs, g9ListStickDistance, g9ReadableLanding, g9WebListOffset };
|
|
540
|
+
export { G9VirtualList, g9LastRowWatcher, g9ListFirstBatch, g9ListNextBatch, g9ListOwnScrollMs, g9ListProgressiveFrom, g9ListRevealMs, g9ListStickDistance, g9ReadableLanding, g9WebListOffset, g9WebListScreenItems };
|
package/dist/pointer/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { G9DragChip, G9DragSource, type G9DragSourceComponentProps, type G9DragSourceOptions, type G9DragSourceProps, G9DropTarget, type G9DropTargetOptions, type G9DropTargetProps, type G9DropTargetState, useG9DragSource, useG9DragState, useG9DropTarget, } from './drag.js';
|
|
2
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 G9PadDragOptions, type G9PadDragProps, type G9PadPhase, type G9PadPoint, g9PadPoint, g9ViewPoint, useG9PadDrag, } from './pad.js';
|
|
3
4
|
export { type G9Point, type G9PointerEventLike, g9MouseButton, g9PointerPoint, isSecondaryPress } from './point.js';
|
|
4
5
|
export { type G9LynxKeyEventLike, type G9SecondaryAction, type G9SecondaryActionOptions, type G9SecondaryActionProps, type G9SecondarySource, keyEventOf, useG9SecondaryAction, } from './secondary.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,OAAO,CAAC;AACf,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"}
|
package/dist/pointer/index.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { G9DragChip, G9DragSource, G9DropTarget, useG9DragSource, useG9DragState, useG9DropTarget } from "./drag.jsx";
|
|
2
2
|
export { cancelG9Drag, currentG9Drag, endG9Drag, hitDropTarget, moveG9Drag, registerG9DropTarget, startG9Drag, subscribeG9Drag } from "./drag-session.jsx";
|
|
3
|
+
export { g9PadPoint, g9ViewPoint, useG9PadDrag } from "./pad.jsx";
|
|
3
4
|
export { g9MouseButton, g9PointerPoint, isSecondaryPress } from "./point.jsx";
|
|
4
5
|
export { keyEventOf, useG9SecondaryAction } from "./secondary.jsx";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { NodesRef } from '@lynx-js/types';
|
|
2
|
+
import type { G9AnchorRect } from '../anchor/registry.js';
|
|
3
|
+
import { type G9Point, type G9PointerEventLike } from './point.js';
|
|
4
|
+
/** Where a drag is, in the element's own space. */
|
|
5
|
+
export interface G9PadPoint {
|
|
6
|
+
/** dp from the element's left edge (may be outside 0 … width while a mouse is outside). */
|
|
7
|
+
readonly x: number;
|
|
8
|
+
/** dp from the element's top edge. */
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
/** `x / width`, clamped to 0 … 1. */
|
|
13
|
+
readonly fx: number;
|
|
14
|
+
/** `y / height`, clamped to 0 … 1. */
|
|
15
|
+
readonly fy: number;
|
|
16
|
+
}
|
|
17
|
+
/** `start` (the press), `move`, `end` (released or cancelled). */
|
|
18
|
+
export type G9PadPhase = 'start' | 'move' | 'end';
|
|
19
|
+
/** Options of {@link useG9PadDrag}. */
|
|
20
|
+
export interface G9PadDragOptions {
|
|
21
|
+
/** Every step of a drag. */
|
|
22
|
+
readonly onDrag: (point: G9PadPoint, phase: G9PadPhase) => void;
|
|
23
|
+
/** Default true. */
|
|
24
|
+
readonly enabled?: boolean;
|
|
25
|
+
/** The element's size changed (its layout). */
|
|
26
|
+
readonly onSize?: (width: number, height: number) => void;
|
|
27
|
+
}
|
|
28
|
+
/** The props {@link useG9PadDrag} puts on the element. */
|
|
29
|
+
export interface G9PadDragProps {
|
|
30
|
+
readonly ref: (node: NodesRef | null) => void;
|
|
31
|
+
readonly bindlayoutchange: (e: {
|
|
32
|
+
readonly detail?: {
|
|
33
|
+
readonly width?: number;
|
|
34
|
+
readonly height?: number;
|
|
35
|
+
};
|
|
36
|
+
}) => void;
|
|
37
|
+
readonly bindtouchstart: (e: G9PointerEventLike) => void;
|
|
38
|
+
readonly bindtouchmove: (e: G9PointerEventLike) => void;
|
|
39
|
+
readonly bindtouchend: (e: G9PointerEventLike) => void;
|
|
40
|
+
readonly bindtouchcancel: (e: G9PointerEventLike) => void;
|
|
41
|
+
readonly bindmousedown: (e: G9PointerEventLike) => void;
|
|
42
|
+
readonly bindmousemove: (e: G9PointerEventLike) => void;
|
|
43
|
+
readonly bindmouseup: (e: G9PointerEventLike) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A pointer event's point in the LynxView's space. A touch's `detail.x/y` and a mouse event's own `x/y` are in that
|
|
47
|
+
* space on every host (Lynx for Web keeps `pageX` document-relative), so they win; `pageX/pageY` are the fallback.
|
|
48
|
+
*/
|
|
49
|
+
export declare function g9ViewPoint(e: G9PointerEventLike | null | undefined): G9Point | null;
|
|
50
|
+
/** A point of the LynxView's space in a box's own space. */
|
|
51
|
+
export declare function g9PadPoint(point: G9Point, rect: G9AnchorRect): G9PadPoint;
|
|
52
|
+
/**
|
|
53
|
+
* A drag area: spread the returned props on the element. The element's box is measured when it lays out and again
|
|
54
|
+
* at each press (a scroll may have moved it); a press before the first measure is reported once the box is known.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useG9PadDrag(options: G9PadDragOptions): G9PadDragProps;
|
|
57
|
+
//# sourceMappingURL=pad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../../src/pointer/pad.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAEhF,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,2FAA2F;IAC3F,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,Q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