@deephaven/grid 1.27.5-alpha-nodehttp2-config3.276eddc.0 → 1.29.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/dist/Grid.d.ts +102 -43
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +442 -390
- package/dist/Grid.js.map +1 -1
- package/dist/GridA11yFallback.d.ts +26 -0
- package/dist/GridA11yFallback.d.ts.map +1 -0
- package/dist/GridA11yFallback.js +115 -0
- package/dist/GridA11yFallback.js.map +1 -0
- package/dist/GridA11yUtils.d.ts +89 -0
- package/dist/GridA11yUtils.d.ts.map +1 -0
- package/dist/GridA11yUtils.js +321 -0
- package/dist/GridA11yUtils.js.map +1 -0
- package/dist/GridRenderer.d.ts +9 -0
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +187 -39
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridRendererTypes.d.ts +3 -4
- package/dist/GridRendererTypes.d.ts.map +1 -1
- package/dist/GridRendererTypes.js.map +1 -1
- package/dist/GridSelectionUtils.d.ts +98 -0
- package/dist/GridSelectionUtils.d.ts.map +1 -0
- package/dist/GridSelectionUtils.js +180 -0
- package/dist/GridSelectionUtils.js.map +1 -0
- package/dist/RangedSelection.d.ts +120 -0
- package/dist/RangedSelection.d.ts.map +1 -0
- package/dist/RangedSelection.js +375 -0
- package/dist/RangedSelection.js.map +1 -0
- package/dist/Selection.d.ts +221 -0
- package/dist/Selection.d.ts.map +1 -0
- package/dist/Selection.js +71 -0
- package/dist/Selection.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +3 -3
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.d.ts +1 -0
- package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +144 -138
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +6 -3
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts +1 -0
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +7 -0
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts +0 -9
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +41 -39
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridTokenMouseHandler.js +4 -1
- package/dist/mouse-handlers/GridTokenMouseHandler.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type GridRenderState } from './GridRendererTypes';
|
|
2
|
+
/** Called with the state the grid just drew */
|
|
3
|
+
export type GridDrawListener = (renderState: GridRenderState) => void;
|
|
4
|
+
export type GridA11yFallbackProps = {
|
|
5
|
+
/** Listen for the grid drawing its canvas. Returns a function to stop listening */
|
|
6
|
+
registerDrawListener: (listener: GridDrawListener) => () => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The fallback content of the grid canvas. Never painted, but assistive
|
|
10
|
+
* technology and browser automation read it in place of the pixels.
|
|
11
|
+
*
|
|
12
|
+
* Everything here describes the most recent draw, so it only updates when the
|
|
13
|
+
* grid draws. Describing the contents walks every visible cell, which is far
|
|
14
|
+
* too expensive to do on every frame for a grid nobody is inspecting, so the
|
|
15
|
+
* snapshot is toggled on and off by a button and only tracks the viewport while
|
|
16
|
+
* it is on.
|
|
17
|
+
*
|
|
18
|
+
* The snapshot is a plain table rather than divs with ARIA roles, as fallback
|
|
19
|
+
* content is never laid out and native table semantics come with the column
|
|
20
|
+
* associations for free. It is a `table` and not a `grid` because `grid`
|
|
21
|
+
* promises the cell by cell keyboard navigation that only the canvas
|
|
22
|
+
* implements.
|
|
23
|
+
*/
|
|
24
|
+
export declare function GridA11yFallback({ registerDrawListener, }: GridA11yFallbackProps): JSX.Element;
|
|
25
|
+
export default GridA11yFallback;
|
|
26
|
+
//# sourceMappingURL=GridA11yFallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridA11yFallback.d.ts","sourceRoot":"","sources":["../src/GridA11yFallback.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,eAAe,KAAK,IAAI,CAAC;AAEtE,MAAM,MAAM,qBAAqB,GAAG;IAClC,mFAAmF;IACnF,oBAAoB,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,MAAM,IAAI,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,oBAAoB,GACrB,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAoFrC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { createGridA11ySnapshot, formatGridA11yRect, GRID_A11Y_ATTRIBUTES } from "./GridA11yUtils.js";
|
|
9
|
+
/** Called with the state the grid just drew */
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* The fallback content of the grid canvas. Never painted, but assistive
|
|
13
|
+
* technology and browser automation read it in place of the pixels.
|
|
14
|
+
*
|
|
15
|
+
* Everything here describes the most recent draw, so it only updates when the
|
|
16
|
+
* grid draws. Describing the contents walks every visible cell, which is far
|
|
17
|
+
* too expensive to do on every frame for a grid nobody is inspecting, so the
|
|
18
|
+
* snapshot is toggled on and off by a button and only tracks the viewport while
|
|
19
|
+
* it is on.
|
|
20
|
+
*
|
|
21
|
+
* The snapshot is a plain table rather than divs with ARIA roles, as fallback
|
|
22
|
+
* content is never laid out and native table semantics come with the column
|
|
23
|
+
* associations for free. It is a `table` and not a `grid` because `grid`
|
|
24
|
+
* promises the cell by cell keyboard navigation that only the canvas
|
|
25
|
+
* implements.
|
|
26
|
+
*/
|
|
27
|
+
export function GridA11yFallback(_ref) {
|
|
28
|
+
var registerDrawListener = _ref.registerDrawListener;
|
|
29
|
+
var _useState = useState(false),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
showSnapshot = _useState2[0],
|
|
32
|
+
setShowSnapshot = _useState2[1];
|
|
33
|
+
var _useState3 = useState(null),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
renderState = _useState4[0],
|
|
36
|
+
setRenderState = _useState4[1];
|
|
37
|
+
|
|
38
|
+
// Only follow the grid while the snapshot is shown, so a grid nobody is
|
|
39
|
+
// inspecting does no extra work per draw
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!showSnapshot) {
|
|
42
|
+
setRenderState(null);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return registerDrawListener(setRenderState);
|
|
46
|
+
}, [registerDrawListener, showSnapshot]);
|
|
47
|
+
var snapshot = useMemo(() => {
|
|
48
|
+
if (renderState == null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
var model = renderState.model,
|
|
52
|
+
metrics = renderState.metrics,
|
|
53
|
+
selection = renderState.selection;
|
|
54
|
+
return createGridA11ySnapshot(model, metrics, selection);
|
|
55
|
+
}, [renderState]);
|
|
56
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
57
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
58
|
+
type: "button",
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
"aria-pressed": showSnapshot,
|
|
61
|
+
onClick: () => setShowSnapshot(prevShowSnapshot => !prevShowSnapshot),
|
|
62
|
+
[GRID_A11Y_ATTRIBUTES.describe]: '',
|
|
63
|
+
children: showSnapshot ? 'Hide the grid contents' : 'Describe the grid contents'
|
|
64
|
+
}), snapshot != null && /*#__PURE__*/_jsxs("div", {
|
|
65
|
+
[GRID_A11Y_ATTRIBUTES.snapshot]: '',
|
|
66
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
67
|
+
role: "status",
|
|
68
|
+
children: snapshot.description
|
|
69
|
+
}), /*#__PURE__*/_jsxs("table", {
|
|
70
|
+
"aria-rowcount": snapshot.rowCount + 1,
|
|
71
|
+
"aria-colcount": snapshot.columnCount,
|
|
72
|
+
children: [/*#__PURE__*/_jsx("thead", {
|
|
73
|
+
children: /*#__PURE__*/_jsx("tr", {
|
|
74
|
+
"aria-rowindex": 1,
|
|
75
|
+
children: snapshot.columns.map(_ref2 => {
|
|
76
|
+
var column = _ref2.column,
|
|
77
|
+
text = _ref2.text,
|
|
78
|
+
rect = _ref2.rect;
|
|
79
|
+
return /*#__PURE__*/_jsx("th", {
|
|
80
|
+
scope: "col",
|
|
81
|
+
"aria-colindex": column + 1,
|
|
82
|
+
[GRID_A11Y_ATTRIBUTES.column]: column,
|
|
83
|
+
[GRID_A11Y_ATTRIBUTES.header]: text,
|
|
84
|
+
[GRID_A11Y_ATTRIBUTES.rect]: formatGridA11yRect(rect),
|
|
85
|
+
children: text
|
|
86
|
+
}, column);
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
90
|
+
children: snapshot.rows.map(_ref3 => {
|
|
91
|
+
var row = _ref3.row,
|
|
92
|
+
cells = _ref3.cells;
|
|
93
|
+
return /*#__PURE__*/_jsx("tr", {
|
|
94
|
+
"aria-rowindex": row + 2,
|
|
95
|
+
children: cells.map(_ref4 => {
|
|
96
|
+
var column = _ref4.column,
|
|
97
|
+
text = _ref4.text,
|
|
98
|
+
rect = _ref4.rect;
|
|
99
|
+
return /*#__PURE__*/_jsx("td", {
|
|
100
|
+
"aria-colindex": column + 1,
|
|
101
|
+
[GRID_A11Y_ATTRIBUTES.column]: column,
|
|
102
|
+
[GRID_A11Y_ATTRIBUTES.row]: row,
|
|
103
|
+
[GRID_A11Y_ATTRIBUTES.rect]: formatGridA11yRect(rect),
|
|
104
|
+
children: text
|
|
105
|
+
}, column);
|
|
106
|
+
})
|
|
107
|
+
}, row);
|
|
108
|
+
})
|
|
109
|
+
})]
|
|
110
|
+
})]
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export default GridA11yFallback;
|
|
115
|
+
//# sourceMappingURL=GridA11yFallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridA11yFallback.js","names":["React","useEffect","useMemo","useState","createGridA11ySnapshot","formatGridA11yRect","GRID_A11Y_ATTRIBUTES","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","GridA11yFallback","_ref","registerDrawListener","_useState","_useState2","_slicedToArray","showSnapshot","setShowSnapshot","_useState3","_useState4","renderState","setRenderState","undefined","snapshot","model","metrics","selection","children","type","tabIndex","onClick","prevShowSnapshot","describe","role","description","rowCount","columnCount","columns","map","_ref2","column","text","rect","scope","header","rows","_ref3","row","cells","_ref4"],"sources":["../src/GridA11yFallback.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { type GridRenderState } from './GridRendererTypes';\nimport {\n createGridA11ySnapshot,\n formatGridA11yRect,\n GRID_A11Y_ATTRIBUTES,\n} from './GridA11yUtils';\n\n/** Called with the state the grid just drew */\nexport type GridDrawListener = (renderState: GridRenderState) => void;\n\nexport type GridA11yFallbackProps = {\n /** Listen for the grid drawing its canvas. Returns a function to stop listening */\n registerDrawListener: (listener: GridDrawListener) => () => void;\n};\n\n/**\n * The fallback content of the grid canvas. Never painted, but assistive\n * technology and browser automation read it in place of the pixels.\n *\n * Everything here describes the most recent draw, so it only updates when the\n * grid draws. Describing the contents walks every visible cell, which is far\n * too expensive to do on every frame for a grid nobody is inspecting, so the\n * snapshot is toggled on and off by a button and only tracks the viewport while\n * it is on.\n *\n * The snapshot is a plain table rather than divs with ARIA roles, as fallback\n * content is never laid out and native table semantics come with the column\n * associations for free. It is a `table` and not a `grid` because `grid`\n * promises the cell by cell keyboard navigation that only the canvas\n * implements.\n */\nexport function GridA11yFallback({\n registerDrawListener,\n}: GridA11yFallbackProps): JSX.Element {\n const [showSnapshot, setShowSnapshot] = useState(false);\n const [renderState, setRenderState] = useState<GridRenderState | null>(null);\n\n // Only follow the grid while the snapshot is shown, so a grid nobody is\n // inspecting does no extra work per draw\n useEffect(() => {\n if (!showSnapshot) {\n setRenderState(null);\n return undefined;\n }\n return registerDrawListener(setRenderState);\n }, [registerDrawListener, showSnapshot]);\n\n const snapshot = useMemo(() => {\n if (renderState == null) {\n return null;\n }\n const { model, metrics, selection } = renderState;\n return createGridA11ySnapshot(model, metrics, selection);\n }, [renderState]);\n\n return (\n <>\n {/* Kept out of the tab order so sighted keyboard users are not sent to an element they cannot see */}\n <button\n type=\"button\"\n tabIndex={-1}\n aria-pressed={showSnapshot}\n onClick={() => setShowSnapshot(prevShowSnapshot => !prevShowSnapshot)}\n {...{ [GRID_A11Y_ATTRIBUTES.describe]: '' }}\n >\n {showSnapshot ? 'Hide the grid contents' : 'Describe the grid contents'}\n </button>\n {snapshot != null && (\n <div {...{ [GRID_A11Y_ATTRIBUTES.snapshot]: '' }}>\n <p role=\"status\">{snapshot.description}</p>\n <table\n aria-rowcount={snapshot.rowCount + 1}\n aria-colcount={snapshot.columnCount}\n >\n <thead>\n <tr aria-rowindex={1}>\n {snapshot.columns.map(({ column, text, rect }) => (\n <th\n key={column}\n scope=\"col\"\n aria-colindex={column + 1}\n {...{\n [GRID_A11Y_ATTRIBUTES.column]: column,\n [GRID_A11Y_ATTRIBUTES.header]: text,\n [GRID_A11Y_ATTRIBUTES.rect]: formatGridA11yRect(rect),\n }}\n >\n {text}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {/* ARIA indexes are one based and count the header row */}\n {snapshot.rows.map(({ row, cells }) => (\n <tr key={row} aria-rowindex={row + 2}>\n {cells.map(({ column, text, rect }) => (\n <td\n key={column}\n aria-colindex={column + 1}\n {...{\n [GRID_A11Y_ATTRIBUTES.column]: column,\n [GRID_A11Y_ATTRIBUTES.row]: row,\n [GRID_A11Y_ATTRIBUTES.rect]: formatGridA11yRect(rect),\n }}\n >\n {text}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </>\n );\n}\n\nexport default GridA11yFallback;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAG1DC,sBAAsB,EACtBC,kBAAkB,EAClBC,oBAAoB;AAGtB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAEO;EAAA,IADrCC,oBAAoB,GAAAD,IAAA,CAApBC,oBAAoB;EAEpB,IAAAC,SAAA,GAAwCb,QAAQ,CAAC,KAAK,CAAC;IAAAc,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAAhDG,YAAY,GAAAF,UAAA;IAAEG,eAAe,GAAAH,UAAA;EACpC,IAAAI,UAAA,GAAsClB,QAAQ,CAAyB,IAAI,CAAC;IAAAmB,UAAA,GAAAJ,cAAA,CAAAG,UAAA;IAArEE,WAAW,GAAAD,UAAA;IAAEE,cAAc,GAAAF,UAAA;;EAElC;EACA;EACArB,SAAS,CAAC,MAAM;IACd,IAAI,CAACkB,YAAY,EAAE;MACjBK,cAAc,CAAC,IAAI,CAAC;MACpB,OAAOC,SAAS;IAClB;IACA,OAAOV,oBAAoB,CAACS,cAAc,CAAC;EAC7C,CAAC,EAAE,CAACT,oBAAoB,EAAEI,YAAY,CAAC,CAAC;EAExC,IAAMO,QAAQ,GAAGxB,OAAO,CAAC,MAAM;IAC7B,IAAIqB,WAAW,IAAI,IAAI,EAAE;MACvB,OAAO,IAAI;IAC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gBAExB,CAACrC,oBAAoB,CAACqC,MAAM,GAAGA,MAAM;gBACrC,CAACrC,oBAAoB,CAACyC,MAAM,GAAGH,IAAI;gBACnC,CAACtC,oBAAoB,CAACuC,IAAI,GAAGxC,kBAAkB,CAACwC,IAAI,CAAC;gBAAAf,QAAA,EAGtDc;cAAI,GATAD,MAUH,CAAC;YAAA,CACN;UAAC,CACA;QAAC,CACA,CAAC,eACRnC,IAAA;UAAAsB,QAAA,EAEGJ,QAAQ,CAACsB,IAAI,CAACP,GAAG,CAACQ,KAAA;YAAA,IAAGC,GAAG,GAAAD,KAAA,CAAHC,GAAG;cAAEC,KAAK,GAAAF,KAAA,CAALE,KAAK;YAAA,oBAC9B3C,IAAA;cAAc,iBAAe0C,GAAG,GAAG,CAAE;cAAApB,QAAA,EAClCqB,KAAK,CAACV,GAAG,CAACW,KAAA;gBAAA,IAAGT,MAAM,GAAAS,KAAA,CAANT,MAAM;kBAAEC,IAAI,GAAAQ,KAAA,CAAJR,IAAI;kBAAEC,IAAI,GAAAO,KAAA,CAAJP,IAAI;gBAAA,oBAC9BrC,IAAA;kBAEE,iBAAemC,MAAM,GAAG,CAAE;kBAExB,CAACrC,oBAAoB,CAACqC,MAAM,GAAGA,MAAM;kBACrC,CAACrC,oBAAoB,CAAC4C,GAAG,GAAGA,GAAG;kBAC/B,CAAC5C,oBAAoB,CAACuC,IAAI,GAAGxC,kBAAkB,CAACwC,IAAI,CAAC;kBAAAf,QAAA,EAGtDc;gBAAI,GARAD,MASH,CAAC;cAAA,CACN;YAAC,GAbKO,GAcL,CAAC;UAAA,CACN;QAAC,CACG,CAAC;MAAA,CACH,CAAC;IAAA,CACL,CACN;EAAA,CACD,CAAC;AAEP;AAEA,eAAerC,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type GridMetrics from './GridMetrics';
|
|
2
|
+
import { type VisibleIndex } from './GridMetrics';
|
|
3
|
+
import type GridModel from './GridModel';
|
|
4
|
+
import type { Selection } from './Selection';
|
|
5
|
+
/**
|
|
6
|
+
* Attributes on the accessibility snapshot that Grid renders into its canvas
|
|
7
|
+
* fallback content. External tooling locates grid contents through these, so
|
|
8
|
+
* treat them as a public contract.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GRID_A11Y_ATTRIBUTES: {
|
|
11
|
+
/** On the button that generates a snapshot */
|
|
12
|
+
readonly describe: "data-grid-a11y-describe";
|
|
13
|
+
/** On the root of a generated snapshot */
|
|
14
|
+
readonly snapshot: "data-grid-a11y-snapshot";
|
|
15
|
+
/** Visible column index. On column headers and cells */
|
|
16
|
+
readonly column: "data-grid-column";
|
|
17
|
+
/** Visible row index. On cells */
|
|
18
|
+
readonly row: "data-grid-row";
|
|
19
|
+
/** Header text. On column headers */
|
|
20
|
+
readonly header: "data-grid-header";
|
|
21
|
+
/** Bounds as `x,y,width,height`, relative to the top left of the canvas, in CSS pixels */
|
|
22
|
+
readonly rect: "data-grid-rect";
|
|
23
|
+
};
|
|
24
|
+
/** The attribute names used by the accessibility snapshot */
|
|
25
|
+
export type GridA11yAttributes = typeof GRID_A11Y_ATTRIBUTES;
|
|
26
|
+
/** A rectangle relative to the top left of the grid canvas, in CSS pixels */
|
|
27
|
+
export type GridA11yRect = {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
/** A column header in an accessibility snapshot */
|
|
34
|
+
export type GridA11yColumnSnapshot = {
|
|
35
|
+
column: VisibleIndex;
|
|
36
|
+
text: string;
|
|
37
|
+
rect: GridA11yRect;
|
|
38
|
+
};
|
|
39
|
+
/** A cell in an accessibility snapshot */
|
|
40
|
+
export type GridA11yCellSnapshot = {
|
|
41
|
+
column: VisibleIndex;
|
|
42
|
+
text: string;
|
|
43
|
+
rect: GridA11yRect;
|
|
44
|
+
};
|
|
45
|
+
/** A row of cells in an accessibility snapshot */
|
|
46
|
+
export type GridA11yRowSnapshot = {
|
|
47
|
+
row: VisibleIndex;
|
|
48
|
+
cells: readonly GridA11yCellSnapshot[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The grid viewport at a point in time. Generated on demand rather than on
|
|
52
|
+
* every frame, as walking the viewport is far too expensive to do while
|
|
53
|
+
* scrolling.
|
|
54
|
+
*/
|
|
55
|
+
export type GridA11ySnapshot = {
|
|
56
|
+
/** A sentence describing the grid size, selection, and viewport */
|
|
57
|
+
description: string;
|
|
58
|
+
/** The number of rows in the whole grid, not just the viewport */
|
|
59
|
+
rowCount: number;
|
|
60
|
+
/** The number of columns in the whole grid, not just the viewport */
|
|
61
|
+
columnCount: number;
|
|
62
|
+
columns: readonly GridA11yColumnSnapshot[];
|
|
63
|
+
rows: readonly GridA11yRowSnapshot[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Format a rect for the `data-grid-rect` attribute.
|
|
67
|
+
* @param rect The rect to format
|
|
68
|
+
* @returns The rect as `x,y,width,height`
|
|
69
|
+
*/
|
|
70
|
+
export declare function formatGridA11yRect({ x, y, width, height, }: GridA11yRect): string;
|
|
71
|
+
/**
|
|
72
|
+
* Get a brief description of the grid size and selection.
|
|
73
|
+
* Only reads values the grid already has on hand, so it is cheap enough to
|
|
74
|
+
* regenerate on every render.
|
|
75
|
+
* @param model The model being displayed
|
|
76
|
+
* @param selection The current selection, or `null` when none
|
|
77
|
+
* @returns A sentence describing the grid
|
|
78
|
+
*/
|
|
79
|
+
export declare function getGridA11ySummary(model: GridModel, selection?: Selection | null): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get the text and bounds of everything currently in the viewport.
|
|
82
|
+
* Iterates every visible cell, so only generate it on demand.
|
|
83
|
+
* @param model The model being displayed
|
|
84
|
+
* @param metrics Metrics of the last render
|
|
85
|
+
* @param selection The current selection, or `null` when none
|
|
86
|
+
* @returns The snapshot to render into the canvas fallback content
|
|
87
|
+
*/
|
|
88
|
+
export declare function createGridA11ySnapshot(model: GridModel, metrics: GridMetrics, selection?: Selection | null): GridA11ySnapshot;
|
|
89
|
+
//# sourceMappingURL=GridA11yUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridA11yUtils.d.ts","sourceRoot":"","sources":["../src/GridA11yUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;IAC/B,8CAA8C;;IAG9C,0CAA0C;;IAG1C,wDAAwD;;IAGxD,kCAAkC;;IAGlC,qCAAqC;;IAGrC,0FAA0F;;CAElF,CAAC;AAEX,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,oBAAoB,CAAC;AAE7D,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,YAAY,CAAC;IAClB,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACxC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IAEpB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IAEjB,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IAEpB,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC3C,IAAI,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,CAAC,EACD,CAAC,EACD,KAAK,EACL,MAAM,GACP,EAAE,YAAY,GAAG,MAAM,CAEvB;AAiID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,SAAS,GAAE,SAAS,GAAG,IAAW,GACjC,MAAM,CAMR;AA0CD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,WAAW,EACpB,SAAS,GAAE,SAAS,GAAG,IAAW,GACjC,gBAAgB,CAkGlB"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
/**
|
|
8
|
+
* Attributes on the accessibility snapshot that Grid renders into its canvas
|
|
9
|
+
* fallback content. External tooling locates grid contents through these, so
|
|
10
|
+
* treat them as a public contract.
|
|
11
|
+
*/
|
|
12
|
+
export var GRID_A11Y_ATTRIBUTES = {
|
|
13
|
+
/** On the button that generates a snapshot */
|
|
14
|
+
describe: 'data-grid-a11y-describe',
|
|
15
|
+
/** On the root of a generated snapshot */
|
|
16
|
+
snapshot: 'data-grid-a11y-snapshot',
|
|
17
|
+
/** Visible column index. On column headers and cells */
|
|
18
|
+
column: 'data-grid-column',
|
|
19
|
+
/** Visible row index. On cells */
|
|
20
|
+
row: 'data-grid-row',
|
|
21
|
+
/** Header text. On column headers */
|
|
22
|
+
header: 'data-grid-header',
|
|
23
|
+
/** Bounds as `x,y,width,height`, relative to the top left of the canvas, in CSS pixels */
|
|
24
|
+
rect: 'data-grid-rect'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** The attribute names used by the accessibility snapshot */
|
|
28
|
+
|
|
29
|
+
/** A rectangle relative to the top left of the grid canvas, in CSS pixels */
|
|
30
|
+
|
|
31
|
+
/** A column header in an accessibility snapshot */
|
|
32
|
+
|
|
33
|
+
/** A cell in an accessibility snapshot */
|
|
34
|
+
|
|
35
|
+
/** A row of cells in an accessibility snapshot */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The grid viewport at a point in time. Generated on demand rather than on
|
|
39
|
+
* every frame, as walking the viewport is far too expensive to do while
|
|
40
|
+
* scrolling.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Format a rect for the `data-grid-rect` attribute.
|
|
45
|
+
* @param rect The rect to format
|
|
46
|
+
* @returns The rect as `x,y,width,height`
|
|
47
|
+
*/
|
|
48
|
+
export function formatGridA11yRect(_ref) {
|
|
49
|
+
var x = _ref.x,
|
|
50
|
+
y = _ref.y,
|
|
51
|
+
width = _ref.width,
|
|
52
|
+
height = _ref.height;
|
|
53
|
+
return "".concat(x, ",").concat(y, ",").concat(width, ",").concat(height);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The area an item may be painted in, relative to the top left of the grid
|
|
58
|
+
* content area.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Clip a rect to the bounds it is painted in and move it onto the canvas.
|
|
63
|
+
* @param rect The rect, relative to the top left of the grid content area
|
|
64
|
+
* @param bounds The bounds the rect is painted in
|
|
65
|
+
* @param metrics Metrics of the last render
|
|
66
|
+
* @returns The visible part of the rect relative to the top left of the
|
|
67
|
+
* canvas, or null if none of it can be interacted with
|
|
68
|
+
*/
|
|
69
|
+
function clipGridA11yRect(_ref2, _ref3, metrics) {
|
|
70
|
+
var x = _ref2.x,
|
|
71
|
+
y = _ref2.y,
|
|
72
|
+
width = _ref2.width,
|
|
73
|
+
height = _ref2.height;
|
|
74
|
+
var left = _ref3.left,
|
|
75
|
+
top = _ref3.top,
|
|
76
|
+
right = _ref3.right,
|
|
77
|
+
bottom = _ref3.bottom;
|
|
78
|
+
var clippedX = Math.max(x, left);
|
|
79
|
+
var clippedY = Math.max(y, top);
|
|
80
|
+
var clippedWidth = Math.min(x + width, right) - clippedX;
|
|
81
|
+
var clippedHeight = Math.min(y + height, bottom) - clippedY;
|
|
82
|
+
if (clippedWidth <= 0 || clippedHeight <= 0) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
x: metrics.gridX + clippedX,
|
|
87
|
+
y: metrics.gridY + clippedY,
|
|
88
|
+
width: clippedWidth,
|
|
89
|
+
height: clippedHeight
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the bounds of a cell, relative to the top left of the canvas.
|
|
95
|
+
* @param metrics Metrics of the last render
|
|
96
|
+
* @param column Visible column index of the cell
|
|
97
|
+
* @param row Visible row index of the cell
|
|
98
|
+
* @param isFloatingColumn Whether the column is frozen to the left or right
|
|
99
|
+
* @param isFloatingRow Whether the row is frozen to the top or bottom
|
|
100
|
+
* @returns The bounds of the cell, or null if none of it is interactable
|
|
101
|
+
*/
|
|
102
|
+
function getCellRect(metrics, column, row, isFloatingColumn, isFloatingRow) {
|
|
103
|
+
var x = metrics.allColumnXs.get(column);
|
|
104
|
+
var y = metrics.allRowYs.get(row);
|
|
105
|
+
var width = metrics.allColumnWidths.get(column);
|
|
106
|
+
var height = metrics.allRowHeights.get(row);
|
|
107
|
+
if (x == null || y == null || width == null || height == null) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
var gridX = metrics.gridX,
|
|
111
|
+
gridY = metrics.gridY,
|
|
112
|
+
verticalBarWidth = metrics.verticalBarWidth,
|
|
113
|
+
horizontalBarHeight = metrics.horizontalBarHeight,
|
|
114
|
+
floatingLeftWidth = metrics.floatingLeftWidth,
|
|
115
|
+
floatingRightWidth = metrics.floatingRightWidth,
|
|
116
|
+
floatingTopHeight = metrics.floatingTopHeight,
|
|
117
|
+
floatingBottomHeight = metrics.floatingBottomHeight;
|
|
118
|
+
|
|
119
|
+
// Scrollable cells run under the headers, the frozen panes, and the scroll
|
|
120
|
+
// bars, all of which are painted over them and take the click instead
|
|
121
|
+
var right = metrics.width - gridX - verticalBarWidth;
|
|
122
|
+
var bottom = metrics.height - gridY - horizontalBarHeight;
|
|
123
|
+
return clipGridA11yRect({
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
width,
|
|
127
|
+
height
|
|
128
|
+
}, {
|
|
129
|
+
left: isFloatingColumn ? 0 : floatingLeftWidth,
|
|
130
|
+
top: isFloatingRow ? 0 : floatingTopHeight,
|
|
131
|
+
right: isFloatingColumn ? right : right - floatingRightWidth,
|
|
132
|
+
bottom: isFloatingRow ? bottom : bottom - floatingBottomHeight
|
|
133
|
+
}, metrics);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get the bounds of a bottom level column header, relative to the top left of the canvas.
|
|
138
|
+
* @param metrics Metrics of the last render
|
|
139
|
+
* @param column Visible column index of the header
|
|
140
|
+
* @param isFloatingColumn Whether the column is frozen to the left or right
|
|
141
|
+
* @returns The bounds of the header, or null if none of it is interactable
|
|
142
|
+
*/
|
|
143
|
+
function getColumnHeaderRect(metrics, column, isFloatingColumn) {
|
|
144
|
+
var x = metrics.allColumnXs.get(column);
|
|
145
|
+
var width = metrics.allColumnWidths.get(column);
|
|
146
|
+
if (x == null || width == null) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
var gridX = metrics.gridX,
|
|
150
|
+
columnHeaderHeight = metrics.columnHeaderHeight,
|
|
151
|
+
floatingLeftWidth = metrics.floatingLeftWidth,
|
|
152
|
+
floatingRightWidth = metrics.floatingRightWidth;
|
|
153
|
+
|
|
154
|
+
// Headers sit above the grid content, so the scroll bars never cover them
|
|
155
|
+
var right = metrics.width - gridX;
|
|
156
|
+
return clipGridA11yRect(
|
|
157
|
+
// The bottom level header sits directly above the grid content
|
|
158
|
+
{
|
|
159
|
+
x,
|
|
160
|
+
y: -columnHeaderHeight,
|
|
161
|
+
width,
|
|
162
|
+
height: columnHeaderHeight
|
|
163
|
+
}, {
|
|
164
|
+
left: isFloatingColumn ? 0 : floatingLeftWidth,
|
|
165
|
+
top: -columnHeaderHeight,
|
|
166
|
+
right: isFloatingColumn ? right : right - floatingRightWidth,
|
|
167
|
+
bottom: 0
|
|
168
|
+
}, metrics);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get a brief description of the grid size and selection.
|
|
173
|
+
* Only reads values the grid already has on hand, so it is cheap enough to
|
|
174
|
+
* regenerate on every render.
|
|
175
|
+
* @param model The model being displayed
|
|
176
|
+
* @param selection The current selection, or `null` when none
|
|
177
|
+
* @returns A sentence describing the grid
|
|
178
|
+
*/
|
|
179
|
+
export function getGridA11ySummary(model) {
|
|
180
|
+
var selection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
181
|
+
var rowCount = model.rowCount,
|
|
182
|
+
columnCount = model.columnCount;
|
|
183
|
+
var size = "Grid with ".concat(rowCount, " rows and ").concat(columnCount, " columns.");
|
|
184
|
+
return selection != null && !selection.isEmpty() ? "".concat(size, " ").concat(selection.describe()) : size;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Describe which rows are on screen. Consecutive rows are collapsed into a
|
|
189
|
+
* range, so floating rows read as separate groups instead of being lumped in
|
|
190
|
+
* with the scrolled rows between them.
|
|
191
|
+
* @param rows The visible rows, in any order
|
|
192
|
+
* @returns A sentence fragment such as `Showing rows 1 to 20 and 100`
|
|
193
|
+
*/
|
|
194
|
+
function getVisibleRowsDescription(rows) {
|
|
195
|
+
var ranges = [];
|
|
196
|
+
[...rows].sort((a, b) => a - b).forEach(row => {
|
|
197
|
+
var lastRange = ranges.at(-1);
|
|
198
|
+
if (lastRange != null && row === lastRange[1] + 1) {
|
|
199
|
+
lastRange[1] = row;
|
|
200
|
+
} else {
|
|
201
|
+
ranges.push([row, row]);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
if (ranges.length === 0) {
|
|
205
|
+
return 'Showing no rows';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Row indexes are zero based, but the row numbers the user sees are not
|
|
209
|
+
var descriptions = ranges.map(_ref4 => {
|
|
210
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
211
|
+
start = _ref5[0],
|
|
212
|
+
end = _ref5[1];
|
|
213
|
+
return start === end ? "".concat(start + 1) : "".concat(start + 1, " to ").concat(end + 1);
|
|
214
|
+
});
|
|
215
|
+
var label = rows.length === 1 ? 'row' : 'rows';
|
|
216
|
+
if (descriptions.length === 1) {
|
|
217
|
+
return "Showing ".concat(label, " ").concat(descriptions[0]);
|
|
218
|
+
}
|
|
219
|
+
if (descriptions.length === 2) {
|
|
220
|
+
return "Showing ".concat(label, " ").concat(descriptions[0], " and ").concat(descriptions[1]);
|
|
221
|
+
}
|
|
222
|
+
return "Showing ".concat(label, " ").concat(descriptions.slice(0, -1).join(', '), ", and ").concat(descriptions.at(-1));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the text and bounds of everything currently in the viewport.
|
|
227
|
+
* Iterates every visible cell, so only generate it on demand.
|
|
228
|
+
* @param model The model being displayed
|
|
229
|
+
* @param metrics Metrics of the last render
|
|
230
|
+
* @param selection The current selection, or `null` when none
|
|
231
|
+
* @returns The snapshot to render into the canvas fallback content
|
|
232
|
+
*/
|
|
233
|
+
export function createGridA11ySnapshot(model, metrics) {
|
|
234
|
+
var selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
235
|
+
var rowCount = model.rowCount,
|
|
236
|
+
columnCount = model.columnCount;
|
|
237
|
+
var columns = [];
|
|
238
|
+
var rows = [];
|
|
239
|
+
var isHiddenColumn = column => {
|
|
240
|
+
var _metrics$allColumnWid;
|
|
241
|
+
return ((_metrics$allColumnWid = metrics.allColumnWidths.get(column)) !== null && _metrics$allColumnWid !== void 0 ? _metrics$allColumnWid : 0) <= 0;
|
|
242
|
+
};
|
|
243
|
+
var isHiddenRow = row => {
|
|
244
|
+
var _metrics$allRowHeight;
|
|
245
|
+
return ((_metrics$allRowHeight = metrics.allRowHeights.get(row)) !== null && _metrics$allRowHeight !== void 0 ? _metrics$allRowHeight : 0) <= 0;
|
|
246
|
+
};
|
|
247
|
+
var floatingColumns = new Set(metrics.floatingColumns);
|
|
248
|
+
var floatingRows = new Set(metrics.floatingRows);
|
|
249
|
+
|
|
250
|
+
// Hidden columns and rows are collapsed to nothing on screen, so leave them
|
|
251
|
+
// out rather than describing something the user cannot see
|
|
252
|
+
// Floating columns/rows are pinned to the edges of the grid and can also
|
|
253
|
+
// appear in the visible ranges, so dedupe them and describe everything in
|
|
254
|
+
// the order it appears on screen
|
|
255
|
+
var snapshotColumns = [...new Set([...metrics.floatingColumns, ...metrics.visibleColumns])].filter(column => !isHiddenColumn(column)).sort((a, b) => {
|
|
256
|
+
var _metrics$allColumnXs$, _metrics$allColumnXs$2;
|
|
257
|
+
return ((_metrics$allColumnXs$ = metrics.allColumnXs.get(a)) !== null && _metrics$allColumnXs$ !== void 0 ? _metrics$allColumnXs$ : 0) - ((_metrics$allColumnXs$2 = metrics.allColumnXs.get(b)) !== null && _metrics$allColumnXs$2 !== void 0 ? _metrics$allColumnXs$2 : 0);
|
|
258
|
+
});
|
|
259
|
+
var snapshotRows = [...new Set([...metrics.floatingRows, ...metrics.visibleRows])].filter(row => !isHiddenRow(row)).sort((a, b) => {
|
|
260
|
+
var _metrics$allRowYs$get, _metrics$allRowYs$get2;
|
|
261
|
+
return ((_metrics$allRowYs$get = metrics.allRowYs.get(a)) !== null && _metrics$allRowYs$get !== void 0 ? _metrics$allRowYs$get : 0) - ((_metrics$allRowYs$get2 = metrics.allRowYs.get(b)) !== null && _metrics$allRowYs$get2 !== void 0 ? _metrics$allRowYs$get2 : 0);
|
|
262
|
+
});
|
|
263
|
+
snapshotColumns.forEach(column => {
|
|
264
|
+
var _model$textForColumnH;
|
|
265
|
+
var modelColumn = metrics.modelColumns.get(column);
|
|
266
|
+
var rect = getColumnHeaderRect(metrics, column, floatingColumns.has(column));
|
|
267
|
+
if (modelColumn == null || rect == null) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
columns.push({
|
|
271
|
+
column,
|
|
272
|
+
text: (_model$textForColumnH = model.textForColumnHeader(modelColumn, 0)) !== null && _model$textForColumnH !== void 0 ? _model$textForColumnH : '',
|
|
273
|
+
rect
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
snapshotRows.forEach(row => {
|
|
277
|
+
var modelRow = metrics.modelRows.get(row);
|
|
278
|
+
if (modelRow == null) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
var isFloatingRow = floatingRows.has(row);
|
|
282
|
+
var cells = [];
|
|
283
|
+
snapshotColumns.forEach(column => {
|
|
284
|
+
var modelColumn = metrics.modelColumns.get(column);
|
|
285
|
+
var rect = getCellRect(metrics, column, row, floatingColumns.has(column), isFloatingRow);
|
|
286
|
+
if (modelColumn == null || rect == null) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
cells.push({
|
|
290
|
+
column,
|
|
291
|
+
text: model.textForCell(modelColumn, modelRow),
|
|
292
|
+
rect
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
// A row with nothing left after clipping is entirely covered by the frozen
|
|
296
|
+
// panes or the scroll bars
|
|
297
|
+
if (cells.length > 0) {
|
|
298
|
+
rows.push({
|
|
299
|
+
row,
|
|
300
|
+
cells
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
var headers = columns.map(_ref6 => {
|
|
305
|
+
var text = _ref6.text;
|
|
306
|
+
return text;
|
|
307
|
+
}).filter(text => text !== '');
|
|
308
|
+
var visibleRows = getVisibleRowsDescription(rows.map(_ref7 => {
|
|
309
|
+
var row = _ref7.row;
|
|
310
|
+
return row;
|
|
311
|
+
}));
|
|
312
|
+
var viewport = headers.length > 0 ? "".concat(visibleRows, ", columns ").concat(headers.join(', '), ".") : "".concat(visibleRows, ".");
|
|
313
|
+
return {
|
|
314
|
+
description: "".concat(getGridA11ySummary(model, selection), " ").concat(viewport),
|
|
315
|
+
rowCount,
|
|
316
|
+
columnCount,
|
|
317
|
+
columns,
|
|
318
|
+
rows
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=GridA11yUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridA11yUtils.js","names":["GRID_A11Y_ATTRIBUTES","describe","snapshot","column","row","header","rect","formatGridA11yRect","_ref","x","y","width","height","concat","clipGridA11yRect","_ref2","_ref3","metrics","left","top","right","bottom","clippedX","Math","max","clippedY","clippedWidth","min","clippedHeight","gridX","gridY","getCellRect","isFloatingColumn","isFloatingRow","allColumnXs","get","allRowYs","allColumnWidths","allRowHeights","verticalBarWidth","horizontalBarHeight","floatingLeftWidth","floatingRightWidth","floatingTopHeight","floatingBottomHeight","getColumnHeaderRect","columnHeaderHeight","getGridA11ySummary","model","selection","arguments","length","undefined","rowCount","columnCount","size","isEmpty","getVisibleRowsDescription","rows","ranges","sort","a","b","forEach","lastRange","at","push","descriptions","map","_ref4","_ref5","_slicedToArray","start","end","label","slice","join","createGridA11ySnapshot","columns","isHiddenColumn","_metrics$allColumnWid","isHiddenRow","_metrics$allRowHeight","floatingColumns","Set","floatingRows","snapshotColumns","visibleColumns","filter","_metrics$allColumnXs$","_metrics$allColumnXs$2","snapshotRows","visibleRows","_metrics$allRowYs$get","_metrics$allRowYs$get2","_model$textForColumnH","modelColumn","modelColumns","has","text","textForColumnHeader","modelRow","modelRows","cells","textForCell","headers","_ref6","_ref7","viewport","description"],"sources":["../src/GridA11yUtils.ts"],"sourcesContent":["import type GridMetrics from './GridMetrics';\nimport { type VisibleIndex } from './GridMetrics';\nimport type GridModel from './GridModel';\nimport type { Selection } from './Selection';\n\n/**\n * Attributes on the accessibility snapshot that Grid renders into its canvas\n * fallback content. External tooling locates grid contents through these, so\n * treat them as a public contract.\n */\nexport const GRID_A11Y_ATTRIBUTES = {\n /** On the button that generates a snapshot */\n describe: 'data-grid-a11y-describe',\n\n /** On the root of a generated snapshot */\n snapshot: 'data-grid-a11y-snapshot',\n\n /** Visible column index. On column headers and cells */\n column: 'data-grid-column',\n\n /** Visible row index. On cells */\n row: 'data-grid-row',\n\n /** Header text. On column headers */\n header: 'data-grid-header',\n\n /** Bounds as `x,y,width,height`, relative to the top left of the canvas, in CSS pixels */\n rect: 'data-grid-rect',\n} as const;\n\n/** The attribute names used by the accessibility snapshot */\nexport type GridA11yAttributes = typeof GRID_A11Y_ATTRIBUTES;\n\n/** A rectangle relative to the top left of the grid canvas, in CSS pixels */\nexport type GridA11yRect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\n/** A column header in an accessibility snapshot */\nexport type GridA11yColumnSnapshot = {\n column: VisibleIndex;\n text: string;\n rect: GridA11yRect;\n};\n\n/** A cell in an accessibility snapshot */\nexport type GridA11yCellSnapshot = {\n column: VisibleIndex;\n text: string;\n rect: GridA11yRect;\n};\n\n/** A row of cells in an accessibility snapshot */\nexport type GridA11yRowSnapshot = {\n row: VisibleIndex;\n cells: readonly GridA11yCellSnapshot[];\n};\n\n/**\n * The grid viewport at a point in time. Generated on demand rather than on\n * every frame, as walking the viewport is far too expensive to do while\n * scrolling.\n */\nexport type GridA11ySnapshot = {\n /** A sentence describing the grid size, selection, and viewport */\n description: string;\n\n /** The number of rows in the whole grid, not just the viewport */\n rowCount: number;\n\n /** The number of columns in the whole grid, not just the viewport */\n columnCount: number;\n\n columns: readonly GridA11yColumnSnapshot[];\n rows: readonly GridA11yRowSnapshot[];\n};\n\n/**\n * Format a rect for the `data-grid-rect` attribute.\n * @param rect The rect to format\n * @returns The rect as `x,y,width,height`\n */\nexport function formatGridA11yRect({\n x,\n y,\n width,\n height,\n}: GridA11yRect): string {\n return `${x},${y},${width},${height}`;\n}\n\n/**\n * The area an item may be painted in, relative to the top left of the grid\n * content area.\n */\ntype GridA11yBounds = {\n left: number;\n top: number;\n right: number;\n bottom: number;\n};\n\n/**\n * Clip a rect to the bounds it is painted in and move it onto the canvas.\n * @param rect The rect, relative to the top left of the grid content area\n * @param bounds The bounds the rect is painted in\n * @param metrics Metrics of the last render\n * @returns The visible part of the rect relative to the top left of the\n * canvas, or null if none of it can be interacted with\n */\nfunction clipGridA11yRect(\n { x, y, width, height }: GridA11yRect,\n { left, top, right, bottom }: GridA11yBounds,\n metrics: GridMetrics\n): GridA11yRect | null {\n const clippedX = Math.max(x, left);\n const clippedY = Math.max(y, top);\n const clippedWidth = Math.min(x + width, right) - clippedX;\n const clippedHeight = Math.min(y + height, bottom) - clippedY;\n if (clippedWidth <= 0 || clippedHeight <= 0) {\n return null;\n }\n\n return {\n x: metrics.gridX + clippedX,\n y: metrics.gridY + clippedY,\n width: clippedWidth,\n height: clippedHeight,\n };\n}\n\n/**\n * Get the bounds of a cell, relative to the top left of the canvas.\n * @param metrics Metrics of the last render\n * @param column Visible column index of the cell\n * @param row Visible row index of the cell\n * @param isFloatingColumn Whether the column is frozen to the left or right\n * @param isFloatingRow Whether the row is frozen to the top or bottom\n * @returns The bounds of the cell, or null if none of it is interactable\n */\nfunction getCellRect(\n metrics: GridMetrics,\n column: VisibleIndex,\n row: VisibleIndex,\n isFloatingColumn: boolean,\n isFloatingRow: boolean\n): GridA11yRect | null {\n const x = metrics.allColumnXs.get(column);\n const y = metrics.allRowYs.get(row);\n const width = metrics.allColumnWidths.get(column);\n const height = metrics.allRowHeights.get(row);\n if (x == null || y == null || width == null || height == null) {\n return null;\n }\n\n const {\n gridX,\n gridY,\n verticalBarWidth,\n horizontalBarHeight,\n floatingLeftWidth,\n floatingRightWidth,\n floatingTopHeight,\n floatingBottomHeight,\n } = metrics;\n\n // Scrollable cells run under the headers, the frozen panes, and the scroll\n // bars, all of which are painted over them and take the click instead\n const right = metrics.width - gridX - verticalBarWidth;\n const bottom = metrics.height - gridY - horizontalBarHeight;\n return clipGridA11yRect(\n { x, y, width, height },\n {\n left: isFloatingColumn ? 0 : floatingLeftWidth,\n top: isFloatingRow ? 0 : floatingTopHeight,\n right: isFloatingColumn ? right : right - floatingRightWidth,\n bottom: isFloatingRow ? bottom : bottom - floatingBottomHeight,\n },\n metrics\n );\n}\n\n/**\n * Get the bounds of a bottom level column header, relative to the top left of the canvas.\n * @param metrics Metrics of the last render\n * @param column Visible column index of the header\n * @param isFloatingColumn Whether the column is frozen to the left or right\n * @returns The bounds of the header, or null if none of it is interactable\n */\nfunction getColumnHeaderRect(\n metrics: GridMetrics,\n column: VisibleIndex,\n isFloatingColumn: boolean\n): GridA11yRect | null {\n const x = metrics.allColumnXs.get(column);\n const width = metrics.allColumnWidths.get(column);\n if (x == null || width == null) {\n return null;\n }\n\n const { gridX, columnHeaderHeight, floatingLeftWidth, floatingRightWidth } =\n metrics;\n\n // Headers sit above the grid content, so the scroll bars never cover them\n const right = metrics.width - gridX;\n return clipGridA11yRect(\n // The bottom level header sits directly above the grid content\n { x, y: -columnHeaderHeight, width, height: columnHeaderHeight },\n {\n left: isFloatingColumn ? 0 : floatingLeftWidth,\n top: -columnHeaderHeight,\n right: isFloatingColumn ? right : right - floatingRightWidth,\n bottom: 0,\n },\n metrics\n );\n}\n\n/**\n * Get a brief description of the grid size and selection.\n * Only reads values the grid already has on hand, so it is cheap enough to\n * regenerate on every render.\n * @param model The model being displayed\n * @param selection The current selection, or `null` when none\n * @returns A sentence describing the grid\n */\nexport function getGridA11ySummary(\n model: GridModel,\n selection: Selection | null = null\n): string {\n const { rowCount, columnCount } = model;\n const size = `Grid with ${rowCount} rows and ${columnCount} columns.`;\n return selection != null && !selection.isEmpty()\n ? `${size} ${selection.describe()}`\n : size;\n}\n\n/**\n * Describe which rows are on screen. Consecutive rows are collapsed into a\n * range, so floating rows read as separate groups instead of being lumped in\n * with the scrolled rows between them.\n * @param rows The visible rows, in any order\n * @returns A sentence fragment such as `Showing rows 1 to 20 and 100`\n */\nfunction getVisibleRowsDescription(rows: readonly VisibleIndex[]): string {\n const ranges: Array<[number, number]> = [];\n [...rows]\n .sort((a, b) => a - b)\n .forEach(row => {\n const lastRange = ranges.at(-1);\n if (lastRange != null && row === lastRange[1] + 1) {\n lastRange[1] = row;\n } else {\n ranges.push([row, row]);\n }\n });\n\n if (ranges.length === 0) {\n return 'Showing no rows';\n }\n\n // Row indexes are zero based, but the row numbers the user sees are not\n const descriptions = ranges.map(([start, end]) =>\n start === end ? `${start + 1}` : `${start + 1} to ${end + 1}`\n );\n const label = rows.length === 1 ? 'row' : 'rows';\n if (descriptions.length === 1) {\n return `Showing ${label} ${descriptions[0]}`;\n }\n if (descriptions.length === 2) {\n return `Showing ${label} ${descriptions[0]} and ${descriptions[1]}`;\n }\n return `Showing ${label} ${descriptions\n .slice(0, -1)\n .join(', ')}, and ${descriptions.at(-1)}`;\n}\n\n/**\n * Get the text and bounds of everything currently in the viewport.\n * Iterates every visible cell, so only generate it on demand.\n * @param model The model being displayed\n * @param metrics Metrics of the last render\n * @param selection The current selection, or `null` when none\n * @returns The snapshot to render into the canvas fallback content\n */\nexport function createGridA11ySnapshot(\n model: GridModel,\n metrics: GridMetrics,\n selection: Selection | null = null\n): GridA11ySnapshot {\n const { rowCount, columnCount } = model;\n const columns: GridA11yColumnSnapshot[] = [];\n const rows: GridA11yRowSnapshot[] = [];\n\n const isHiddenColumn = (column: VisibleIndex): boolean =>\n (metrics.allColumnWidths.get(column) ?? 0) <= 0;\n const isHiddenRow = (row: VisibleIndex): boolean =>\n (metrics.allRowHeights.get(row) ?? 0) <= 0;\n\n const floatingColumns = new Set(metrics.floatingColumns);\n const floatingRows = new Set(metrics.floatingRows);\n\n // Hidden columns and rows are collapsed to nothing on screen, so leave them\n // out rather than describing something the user cannot see\n // Floating columns/rows are pinned to the edges of the grid and can also\n // appear in the visible ranges, so dedupe them and describe everything in\n // the order it appears on screen\n const snapshotColumns = [\n ...new Set([...metrics.floatingColumns, ...metrics.visibleColumns]),\n ]\n .filter(column => !isHiddenColumn(column))\n .sort(\n (a, b) =>\n (metrics.allColumnXs.get(a) ?? 0) - (metrics.allColumnXs.get(b) ?? 0)\n );\n\n const snapshotRows = [\n ...new Set([...metrics.floatingRows, ...metrics.visibleRows]),\n ]\n .filter(row => !isHiddenRow(row))\n .sort(\n (a, b) => (metrics.allRowYs.get(a) ?? 0) - (metrics.allRowYs.get(b) ?? 0)\n );\n\n snapshotColumns.forEach(column => {\n const modelColumn = metrics.modelColumns.get(column);\n const rect = getColumnHeaderRect(\n metrics,\n column,\n floatingColumns.has(column)\n );\n if (modelColumn == null || rect == null) {\n return;\n }\n columns.push({\n column,\n text: model.textForColumnHeader(modelColumn, 0) ?? '',\n rect,\n });\n });\n\n snapshotRows.forEach(row => {\n const modelRow = metrics.modelRows.get(row);\n if (modelRow == null) {\n return;\n }\n const isFloatingRow = floatingRows.has(row);\n const cells: GridA11yCellSnapshot[] = [];\n snapshotColumns.forEach(column => {\n const modelColumn = metrics.modelColumns.get(column);\n const rect = getCellRect(\n metrics,\n column,\n row,\n floatingColumns.has(column),\n isFloatingRow\n );\n if (modelColumn == null || rect == null) {\n return;\n }\n cells.push({\n column,\n text: model.textForCell(modelColumn, modelRow),\n rect,\n });\n });\n // A row with nothing left after clipping is entirely covered by the frozen\n // panes or the scroll bars\n if (cells.length > 0) {\n rows.push({ row, cells });\n }\n });\n\n const headers = columns.map(({ text }) => text).filter(text => text !== '');\n const visibleRows = getVisibleRowsDescription(rows.map(({ row }) => row));\n const viewport =\n headers.length > 0\n ? `${visibleRows}, columns ${headers.join(', ')}.`\n : `${visibleRows}.`;\n\n return {\n description: `${getGridA11ySummary(model, selection)} ${viewport}`,\n rowCount,\n columnCount,\n columns,\n rows,\n };\n}\n"],"mappings":";;;;;;AAKA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMA,oBAAoB,GAAG;EAClC;EACAC,QAAQ,EAAE,yBAAyB;EAEnC;EACAC,QAAQ,EAAE,yBAAyB;EAEnC;EACAC,MAAM,EAAE,kBAAkB;EAE1B;EACAC,GAAG,EAAE,eAAe;EAEpB;EACAC,MAAM,EAAE,kBAAkB;EAE1B;EACAC,IAAI,EAAE;AACR,CAAU;;AAEV;;AAG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AAC,CAACX,MAAM,CAACW,IAAI,IAAIA,IAAI,KAAK,EAAE,CAAC;EAC3E,IAAMP,WAAW,GAAGnC,yBAAyB,CAACC,IAAI,CAACU,GAAG,CAACuC,KAAA;IAAA,IAAGvG,GAAG,GAAAuG,KAAA,CAAHvG,GAAG;IAAA,OAAOA,GAAG;EAAA,EAAC,CAAC;EACzE,IAAMwG,QAAQ,GACZH,OAAO,CAACtD,MAAM,GAAG,CAAC,MAAAtC,MAAA,CACX+E,WAAW,gBAAA/E,MAAA,CAAa4F,OAAO,CAAC7B,IAAI,CAAC,IAAI,CAAC,YAAA/D,MAAA,CAC1C+E,WAAW,MAAG;EAEvB,OAAO;IACLiB,WAAW,KAAAhG,MAAA,CAAKkC,kBAAkB,CAACC,KAAK,EAAEC,SAAS,CAAC,OAAApC,MAAA,CAAI+F,QAAQ,CAAE;IAClEvD,QAAQ;IACRC,WAAW;IACXwB,OAAO;IACPpB;EACF,CAAC;AACH","ignoreList":[]}
|
package/dist/GridRenderer.d.ts
CHANGED
|
@@ -133,6 +133,15 @@ export declare class GridRenderer {
|
|
|
133
133
|
maxY?: Coordinate;
|
|
134
134
|
}): void;
|
|
135
135
|
drawActiveCell(context: CanvasRenderingContext2D, state: GridRenderState, column: VisibleIndex, row: VisibleIndex): void;
|
|
136
|
+
/**
|
|
137
|
+
* Draws an outline around the in-flight ctrl+click / ctrl+shift+click drag
|
|
138
|
+
* rectangle. Uses `selection.cursor` (mouse-down anchor) and
|
|
139
|
+
* `selection.selectionEnd` (current drag position) for the bounds. For row
|
|
140
|
+
* selection themes only the top and bottom horizontal strokes are drawn
|
|
141
|
+
* (row-boundary preview); for column selection only left/right; for cell
|
|
142
|
+
* selection all four sides.
|
|
143
|
+
*/
|
|
144
|
+
drawGestureDragOutline(context: CanvasRenderingContext2D, state: GridRenderState): void;
|
|
136
145
|
/**
|
|
137
146
|
* Draws a rounded rectangle using the current state of the canvas.
|
|
138
147
|
*
|