@pie-lib/plot 5.0.1-next.20261006030823 → 5.0.1-next.20261006032932
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/dist/__tests__/keyboard.test.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/keyboard.d.ts +21 -0
- package/dist/keyboard.js +32 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ import * as utils from './utils.js';
|
|
|
5
5
|
import * as trig from './trig.js';
|
|
6
6
|
import * as types from './types.js';
|
|
7
7
|
import { create as createGraphProps } from './graph-props.js';
|
|
8
|
-
|
|
8
|
+
import * as keyboard from './keyboard.js';
|
|
9
|
+
export { Root, Draggable, gridDraggable, utils, trig, types, createGraphProps, keyboard };
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,5 @@ import r from "./draggable.js";
|
|
|
5
5
|
import { gridDraggable as i } from "./grid-draggable.js";
|
|
6
6
|
import { trig_exports as a } from "./trig.js";
|
|
7
7
|
import { create as o } from "./graph-props.js";
|
|
8
|
-
|
|
8
|
+
import { keyboard_exports as s } from "./keyboard.js";
|
|
9
|
+
export { r as Draggable, n as Root, o as createGraphProps, i as gridDraggable, s as keyboard, a as trig, e as types, t as utils };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard stepping for a mark that moves along one axis of the grid, as an APG slider moves.
|
|
3
|
+
* The pointer drag in grid-draggable snaps with `graphProps.snap`; passing that same function as
|
|
4
|
+
* `snap` makes a key land where a drag would.
|
|
5
|
+
*/
|
|
6
|
+
export type SliderRange = {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
step: number;
|
|
10
|
+
/** The Page Up and Page Down step. Without it the slider leaves those keys to the page. */
|
|
11
|
+
largeStep?: number;
|
|
12
|
+
snap?: (value: number) => number;
|
|
13
|
+
};
|
|
14
|
+
/** `value` clamped to the range, snapped as a drag snaps, and clamped again. */
|
|
15
|
+
export declare const fitToRange: (value: number, range: SliderRange) => number;
|
|
16
|
+
/**
|
|
17
|
+
* The value a key moves a slider to: ArrowUp and ArrowRight go one step up, ArrowDown and
|
|
18
|
+
* ArrowLeft one step down, PageUp and PageDown one large step, and Home and End to the ends of the
|
|
19
|
+
* range. Undefined for a key the slider does not handle.
|
|
20
|
+
*/
|
|
21
|
+
export declare const sliderKeyValue: (key: string, value: number, range: SliderRange) => number | undefined;
|
package/dist/keyboard.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/keyboard.ts
|
|
3
|
+
var t = /* @__PURE__ */ e({
|
|
4
|
+
fitToRange: () => a,
|
|
5
|
+
sliderKeyValue: () => c
|
|
6
|
+
}), n = 1e-9, r = (e) => Number(e.toFixed(4)), i = (e, { min: t, max: n }) => Math.min(n, Math.max(t, e)), a = (e, t) => {
|
|
7
|
+
let n = i(e, t);
|
|
8
|
+
return r(i(t.snap ? t.snap(n) : n, t));
|
|
9
|
+
}, o = (e, t, r, i) => {
|
|
10
|
+
let a = (e - t) / r;
|
|
11
|
+
return t + (i > 0 ? Math.floor(a + n) + 1 : Math.ceil(a - n) - 1) * r;
|
|
12
|
+
}, s = (e, t, r, i) => {
|
|
13
|
+
if (!(t > 0)) return a(e, i);
|
|
14
|
+
let s = (e) => r > 0 ? e >= i.max : e <= i.min, c = o(e, i.min, t, r), l = a(c, i);
|
|
15
|
+
for (; r * (l - e) <= n && !s(c);) c += r * t, l = a(c, i);
|
|
16
|
+
return l;
|
|
17
|
+
}, c = (e, t, n) => {
|
|
18
|
+
let { min: r, max: i, step: o, largeStep: c } = n, l = Number.isFinite(t) ? t : r;
|
|
19
|
+
switch (e) {
|
|
20
|
+
case "ArrowUp":
|
|
21
|
+
case "ArrowRight": return s(l, o, 1, n);
|
|
22
|
+
case "ArrowDown":
|
|
23
|
+
case "ArrowLeft": return s(l, o, -1, n);
|
|
24
|
+
case "PageUp": return c ? s(l, c, 1, n) : void 0;
|
|
25
|
+
case "PageDown": return c ? s(l, c, -1, n) : void 0;
|
|
26
|
+
case "Home": return a(r, n);
|
|
27
|
+
case "End": return a(i, n);
|
|
28
|
+
default: return;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { a as fitToRange, t as keyboard_exports, c as sliderKeyValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/plot",
|
|
3
|
-
"version": "5.0.1-next.
|
|
3
|
+
"version": "5.0.1-next.20261006032932",
|
|
4
4
|
"description": "Some underlying components for building charts/graphs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@mapbox/point-geometry": "^1.1.0",
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
|
-
"@pie-lib/editable-html-tip-tap": "3.0.1-next.
|
|
17
|
-
"@pie-lib/render-ui": "8.0.1-next.
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "3.0.1-next.20261006032932",
|
|
17
|
+
"@pie-lib/render-ui": "8.0.1-next.20261006032932",
|
|
18
18
|
"assert": "^2.1.0",
|
|
19
19
|
"d3-scale": "^4.0.2",
|
|
20
20
|
"d3-selection": "^3.0.0",
|