@vuu-ui/vuu-utils 0.8.95 → 0.8.96
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/cjs/index.js +1 -1
- package/cjs/keyboard-utils.js +2 -0
- package/cjs/keyboard-utils.js.map +1 -1
- package/cjs/row-utils.js +0 -18
- package/cjs/row-utils.js.map +1 -1
- package/esm/index.js +2 -2
- package/esm/keyboard-utils.js +2 -1
- package/esm/keyboard-utils.js.map +1 -1
- package/esm/row-utils.js +1 -18
- package/esm/row-utils.js.map +1 -1
- package/package.json +6 -6
- package/types/keyboard-utils.d.ts +3 -0
- package/types/row-utils.d.ts +0 -1
package/cjs/index.js
CHANGED
|
@@ -278,6 +278,7 @@ exports.PageDown = keyboardUtils.PageDown;
|
|
|
278
278
|
exports.PageUp = keyboardUtils.PageUp;
|
|
279
279
|
exports.Space = keyboardUtils.Space;
|
|
280
280
|
exports.Tab = keyboardUtils.Tab;
|
|
281
|
+
exports.isArrowKey = keyboardUtils.isArrowKey;
|
|
281
282
|
exports.KeySet = keyset.KeySet;
|
|
282
283
|
exports.getSelectedOption = listUtils.getSelectedOption;
|
|
283
284
|
exports.getAllLocalEntity = localStorageUtils.getAllLocalEntity;
|
|
@@ -325,7 +326,6 @@ exports.resetRange = rangeUtils.resetRange;
|
|
|
325
326
|
exports.withinRange = rangeUtils.withinRange;
|
|
326
327
|
exports.actualRowPositioning = rowUtils.actualRowPositioning;
|
|
327
328
|
exports.asDataSourceRowObject = rowUtils.asDataSourceRowObject;
|
|
328
|
-
exports.getIndexFromRowElement = rowUtils.getIndexFromRowElement;
|
|
329
329
|
exports.getRowElementAtIndex = rowUtils.getRowElementAtIndex;
|
|
330
330
|
exports.virtualRowPositioning = rowUtils.virtualRowPositioning;
|
|
331
331
|
exports.RowSelected = selectionUtils.RowSelected;
|
package/cjs/keyboard-utils.js
CHANGED
|
@@ -12,6 +12,7 @@ const PageUp = "PageUp";
|
|
|
12
12
|
const PageDown = "PageDown";
|
|
13
13
|
const Space = " ";
|
|
14
14
|
const Tab = "Tab";
|
|
15
|
+
const isArrowKey = (key) => key === "ArrowUp" || key === "ArrowDown" || key === "ArrowLeft" || key === "ArrowRight";
|
|
15
16
|
|
|
16
17
|
exports.ArrowDown = ArrowDown;
|
|
17
18
|
exports.ArrowLeft = ArrowLeft;
|
|
@@ -25,4 +26,5 @@ exports.PageDown = PageDown;
|
|
|
25
26
|
exports.PageUp = PageUp;
|
|
26
27
|
exports.Space = Space;
|
|
27
28
|
exports.Tab = Tab;
|
|
29
|
+
exports.isArrowKey = isArrowKey;
|
|
28
30
|
//# sourceMappingURL=keyboard-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-utils.js","sources":["../src/keyboard-utils.ts"],"sourcesContent":["export const ArrowUp = \"ArrowUp\";\nexport const ArrowDown = \"ArrowDown\";\nexport const ArrowLeft = \"ArrowLeft\";\nexport const ArrowRight = \"ArrowRight\";\nexport const Enter = \"Enter\";\nexport const Escape = \"Escape\";\nexport const Home = \"Home\";\nexport const End = \"End\";\nexport const PageUp = \"PageUp\";\nexport const PageDown = \"PageDown\";\nexport const Space = \" \";\nexport const Tab = \"Tab\";\n"],"names":[],"mappings":";;AAAO,MAAM,OAAU,GAAA,UAAA;AAChB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,UAAa,GAAA,aAAA;AACnB,MAAM,KAAQ,GAAA,QAAA;AACd,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,IAAO,GAAA,OAAA;AACb,MAAM,GAAM,GAAA,MAAA;AACZ,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,QAAW,GAAA,WAAA;AACjB,MAAM,KAAQ,GAAA,IAAA;AACd,MAAM,GAAM,GAAA
|
|
1
|
+
{"version":3,"file":"keyboard-utils.js","sources":["../src/keyboard-utils.ts"],"sourcesContent":["export const ArrowUp = \"ArrowUp\";\nexport const ArrowDown = \"ArrowDown\";\nexport const ArrowLeft = \"ArrowLeft\";\nexport const ArrowRight = \"ArrowRight\";\nexport const Enter = \"Enter\";\nexport const Escape = \"Escape\";\nexport const Home = \"Home\";\nexport const End = \"End\";\nexport const PageUp = \"PageUp\";\nexport const PageDown = \"PageDown\";\nexport const Space = \" \";\nexport const Tab = \"Tab\";\n\nexport type ArrowKey = \"ArrowUp\" | \"ArrowDown\" | \"ArrowLeft\" | \"ArrowRight\";\nexport type PageKey = \"Home\" | \"End\" | \"PageUp\" | \"PageDown\";\n\nexport const isArrowKey = (key: string): key is ArrowKey =>\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\";\n"],"names":[],"mappings":";;AAAO,MAAM,OAAU,GAAA,UAAA;AAChB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,UAAa,GAAA,aAAA;AACnB,MAAM,KAAQ,GAAA,QAAA;AACd,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,IAAO,GAAA,OAAA;AACb,MAAM,GAAM,GAAA,MAAA;AACZ,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,QAAW,GAAA,WAAA;AACjB,MAAM,KAAQ,GAAA,IAAA;AACd,MAAM,GAAM,GAAA,MAAA;AAKN,MAAA,UAAA,GAAa,CAAC,GACzB,KAAA,GAAA,KAAQ,aACR,GAAQ,KAAA,WAAA,IACR,GAAQ,KAAA,WAAA,IACR,GAAQ,KAAA;;;;;;;;;;;;;;;;"}
|
package/cjs/row-utils.js
CHANGED
|
@@ -39,23 +39,6 @@ const getRowElementAtIndex = (container, rowIndex) => {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
const getIndexFromRowElement = (rowElement) => {
|
|
43
|
-
const rowIndex = rowElement.ariaRowIndex;
|
|
44
|
-
if (rowIndex != null) {
|
|
45
|
-
const index = parseInt(rowIndex) - 1;
|
|
46
|
-
if (!isNaN(index)) {
|
|
47
|
-
return index;
|
|
48
|
-
} else {
|
|
49
|
-
throw Error(
|
|
50
|
-
`getIndexFromRowElement row element aria rowindex invalid ${rowIndex}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
throw Error(
|
|
55
|
-
"getIndexFromRowElement row element does not have aria rowindex"
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
42
|
const asDataSourceRowObject = (row, columnMap) => {
|
|
60
43
|
const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;
|
|
61
44
|
const rowObject = {
|
|
@@ -73,7 +56,6 @@ const asDataSourceRowObject = (row, columnMap) => {
|
|
|
73
56
|
|
|
74
57
|
exports.actualRowPositioning = actualRowPositioning;
|
|
75
58
|
exports.asDataSourceRowObject = asDataSourceRowObject;
|
|
76
|
-
exports.getIndexFromRowElement = getIndexFromRowElement;
|
|
77
59
|
exports.getRowElementAtIndex = getRowElementAtIndex;
|
|
78
60
|
exports.virtualRowPositioning = virtualRowPositioning;
|
|
79
61
|
//# sourceMappingURL=row-utils.js.map
|
package/cjs/row-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-utils.js","sources":["../src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { isRowSelected } from \"./selection-utils\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport const getRowElementAtIndex = (\n container: HTMLDivElement | EventTarget,\n rowIndex: number,\n) => {\n if (rowIndex === -1) {\n return null;\n } else {\n const activeRow = (container as HTMLElement).querySelector(\n `[aria-rowindex=\"${rowIndex + 1}\"]`,\n ) as HTMLElement;\n\n if (activeRow) {\n return activeRow;\n } else {\n throw Error(\n `getRowElementAtIndex no row found for index index ${rowIndex}`,\n );\n }\n }\n};\n\nexport const
|
|
1
|
+
{"version":3,"file":"row-utils.js","sources":["../src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { isRowSelected } from \"./selection-utils\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport const getRowElementAtIndex = (\n container: HTMLDivElement | EventTarget,\n rowIndex: number,\n) => {\n if (rowIndex === -1) {\n return null;\n } else {\n const activeRow = (container as HTMLElement).querySelector(\n `[aria-rowindex=\"${rowIndex + 1}\"]`,\n ) as HTMLElement;\n\n if (activeRow) {\n return activeRow;\n } else {\n throw Error(\n `getRowElementAtIndex no row found for index index ${rowIndex}`,\n );\n }\n }\n};\n\nexport const asDataSourceRowObject = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: isRowSelected(row),\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n"],"names":["metadataKeys","isRowSelected"],"mappings":";;;;;AASA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAQ,GAAAA,wBAAA,CAAA;AAajB,MAAA,oBAAA,GAAuB,CAAC,SAAsC,KAAA;AAAA,EACzE,CAAC,GAAA,KAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,SAAA;AAAA,EACpB,CAAC,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,EAC7C,KAAA;AACF,EAAA;AAaO,MAAM,qBAAwB,GAAA,CACnC,SACA,EAAA,iBAAA,EACA,YACmB,KAAA;AAAA,EACnB,CAAC,GAAK,EAAA,MAAA,GAAS,CAAM,KAAA;AACnB,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA,CAAA;AACzC,IAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,MAAA,IAAU,SAAY,GAAA,SAAA,CAAA;AAAA,GAC3C;AAAA;AAAA;AAAA;AAAA,EAIA,CAAC,QAAa,KAAA;AACZ,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA,CAAA;AACzC,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA,CAAO,QAAW,GAAA,SAAA,IAAa,SAAS,CAAA,CAAA;AAAA,GACtD;AAAA,EACA,IAAA;AACF,EAAA;AAEa,MAAA,oBAAA,GAAuB,CAClC,SAAA,EACA,QACG,KAAA;AACH,EAAA,IAAI,aAAa,CAAI,CAAA,EAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACF,MAAA;AACL,IAAA,MAAM,YAAa,SAA0B,CAAA,aAAA;AAAA,MAC3C,CAAA,gBAAA,EAAmB,WAAW,CAAC,CAAA,EAAA,CAAA;AAAA,KACjC,CAAA;AAEA,IAAA,IAAI,SAAW,EAAA;AACb,MAAO,OAAA,SAAA,CAAA;AAAA,KACF,MAAA;AACL,MAAM,MAAA,KAAA;AAAA,QACJ,qDAAqD,QAAQ,CAAA,CAAA;AAAA,OAC/D,CAAA;AAAA,KACF;AAAA,GACF;AACF,EAAA;AAEa,MAAA,qBAAA,GAAwB,CACnC,GAAA,EACA,SACwB,KAAA;AACxB,EAAA,MAAM,EAAE,CAAC,OAAO,GAAG,MAAQ,EAAA,CAAC,GAAG,GAAG,GAAK,EAAA,CAAC,GAAG,GAAG,OAAU,GAAA,GAAA,CAAA;AAExD,EAAA,MAAM,SAAiC,GAAA;AAAA,IACrC,GAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAY,CAAC,MAAA;AAAA,IACb,UAAA,EAAYC,6BAAc,GAAG,CAAA;AAAA,IAC7B,MAAM,EAAC;AAAA,GACT,CAAA;AAEA,EAAA,KAAA,MAAW,CAAC,OAAS,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACzD,IAAA,SAAA,CAAU,IAAK,CAAA,OAAO,CAAI,GAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,SAAA,CAAA;AACT;;;;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export { isCharacterKey, isQuoteKey } from './input-utils.js';
|
|
|
28
28
|
export { invariant } from './invariant.js';
|
|
29
29
|
export { itemToString } from './itemToString.js';
|
|
30
30
|
export { jsonToDataSourceRows } from './json-utils.js';
|
|
31
|
-
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab } from './keyboard-utils.js';
|
|
31
|
+
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab, isArrowKey } from './keyboard-utils.js';
|
|
32
32
|
export { KeySet } from './keyset.js';
|
|
33
33
|
export { getSelectedOption } from './list-utils.js';
|
|
34
34
|
export { getAllLocalEntity, getLocalEntity, saveLocalEntity } from './local-storage-utils.js';
|
|
@@ -42,7 +42,7 @@ export { debounce, throttle } from './perf-utils.js';
|
|
|
42
42
|
export { DeferredPromise } from './promise-utils.js';
|
|
43
43
|
export { isActionMessage, isEditCellRequest, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isSessionTable, isSessionTableActionMessage, isViewportRpcRequest, isVuuMenuRpcRequest, viewportRpcRequest, vuuAddRowRequest, vuuDeleteRowRequest, vuuEditCellRequest } from './protocol-message-utils.js';
|
|
44
44
|
export { NULL_RANGE, WindowRange, getFullRange, rangeNewItems, rangesAreSame, resetRange, withinRange } from './range-utils.js';
|
|
45
|
-
export { actualRowPositioning, asDataSourceRowObject,
|
|
45
|
+
export { actualRowPositioning, asDataSourceRowObject, getRowElementAtIndex, virtualRowPositioning } from './row-utils.js';
|
|
46
46
|
export { RowSelected, deselectItem, expandSelection, getSelectionStatus, isRowSelected, isRowSelectedLast, isSelected, selectItem, selectionCount } from './selection-utils.js';
|
|
47
47
|
export { VuuShellLocation } from './shell-layout-types.js';
|
|
48
48
|
export { addSortColumn, setSortColumn, toggleOrApplySort } from './sort-utils.js';
|
package/esm/keyboard-utils.js
CHANGED
|
@@ -10,6 +10,7 @@ const PageUp = "PageUp";
|
|
|
10
10
|
const PageDown = "PageDown";
|
|
11
11
|
const Space = " ";
|
|
12
12
|
const Tab = "Tab";
|
|
13
|
+
const isArrowKey = (key) => key === "ArrowUp" || key === "ArrowDown" || key === "ArrowLeft" || key === "ArrowRight";
|
|
13
14
|
|
|
14
|
-
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab };
|
|
15
|
+
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab, isArrowKey };
|
|
15
16
|
//# sourceMappingURL=keyboard-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-utils.js","sources":["../src/keyboard-utils.ts"],"sourcesContent":["export const ArrowUp = \"ArrowUp\";\nexport const ArrowDown = \"ArrowDown\";\nexport const ArrowLeft = \"ArrowLeft\";\nexport const ArrowRight = \"ArrowRight\";\nexport const Enter = \"Enter\";\nexport const Escape = \"Escape\";\nexport const Home = \"Home\";\nexport const End = \"End\";\nexport const PageUp = \"PageUp\";\nexport const PageDown = \"PageDown\";\nexport const Space = \" \";\nexport const Tab = \"Tab\";\n"],"names":[],"mappings":"AAAO,MAAM,OAAU,GAAA,UAAA;AAChB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,UAAa,GAAA,aAAA;AACnB,MAAM,KAAQ,GAAA,QAAA;AACd,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,IAAO,GAAA,OAAA;AACb,MAAM,GAAM,GAAA,MAAA;AACZ,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,QAAW,GAAA,WAAA;AACjB,MAAM,KAAQ,GAAA,IAAA;AACd,MAAM,GAAM,GAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"keyboard-utils.js","sources":["../src/keyboard-utils.ts"],"sourcesContent":["export const ArrowUp = \"ArrowUp\";\nexport const ArrowDown = \"ArrowDown\";\nexport const ArrowLeft = \"ArrowLeft\";\nexport const ArrowRight = \"ArrowRight\";\nexport const Enter = \"Enter\";\nexport const Escape = \"Escape\";\nexport const Home = \"Home\";\nexport const End = \"End\";\nexport const PageUp = \"PageUp\";\nexport const PageDown = \"PageDown\";\nexport const Space = \" \";\nexport const Tab = \"Tab\";\n\nexport type ArrowKey = \"ArrowUp\" | \"ArrowDown\" | \"ArrowLeft\" | \"ArrowRight\";\nexport type PageKey = \"Home\" | \"End\" | \"PageUp\" | \"PageDown\";\n\nexport const isArrowKey = (key: string): key is ArrowKey =>\n key === \"ArrowUp\" ||\n key === \"ArrowDown\" ||\n key === \"ArrowLeft\" ||\n key === \"ArrowRight\";\n"],"names":[],"mappings":"AAAO,MAAM,OAAU,GAAA,UAAA;AAChB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,SAAY,GAAA,YAAA;AAClB,MAAM,UAAa,GAAA,aAAA;AACnB,MAAM,KAAQ,GAAA,QAAA;AACd,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,IAAO,GAAA,OAAA;AACb,MAAM,GAAM,GAAA,MAAA;AACZ,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,QAAW,GAAA,WAAA;AACjB,MAAM,KAAQ,GAAA,IAAA;AACd,MAAM,GAAM,GAAA,MAAA;AAKN,MAAA,UAAA,GAAa,CAAC,GACzB,KAAA,GAAA,KAAQ,aACR,GAAQ,KAAA,WAAA,IACR,GAAQ,KAAA,WAAA,IACR,GAAQ,KAAA;;;;"}
|
package/esm/row-utils.js
CHANGED
|
@@ -37,23 +37,6 @@ const getRowElementAtIndex = (container, rowIndex) => {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
const getIndexFromRowElement = (rowElement) => {
|
|
41
|
-
const rowIndex = rowElement.ariaRowIndex;
|
|
42
|
-
if (rowIndex != null) {
|
|
43
|
-
const index = parseInt(rowIndex) - 1;
|
|
44
|
-
if (!isNaN(index)) {
|
|
45
|
-
return index;
|
|
46
|
-
} else {
|
|
47
|
-
throw Error(
|
|
48
|
-
`getIndexFromRowElement row element aria rowindex invalid ${rowIndex}`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
throw Error(
|
|
53
|
-
"getIndexFromRowElement row element does not have aria rowindex"
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
40
|
const asDataSourceRowObject = (row, columnMap) => {
|
|
58
41
|
const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;
|
|
59
42
|
const rowObject = {
|
|
@@ -69,5 +52,5 @@ const asDataSourceRowObject = (row, columnMap) => {
|
|
|
69
52
|
return rowObject;
|
|
70
53
|
};
|
|
71
54
|
|
|
72
|
-
export { actualRowPositioning, asDataSourceRowObject,
|
|
55
|
+
export { actualRowPositioning, asDataSourceRowObject, getRowElementAtIndex, virtualRowPositioning };
|
|
73
56
|
//# sourceMappingURL=row-utils.js.map
|
package/esm/row-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-utils.js","sources":["../src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { isRowSelected } from \"./selection-utils\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport const getRowElementAtIndex = (\n container: HTMLDivElement | EventTarget,\n rowIndex: number,\n) => {\n if (rowIndex === -1) {\n return null;\n } else {\n const activeRow = (container as HTMLElement).querySelector(\n `[aria-rowindex=\"${rowIndex + 1}\"]`,\n ) as HTMLElement;\n\n if (activeRow) {\n return activeRow;\n } else {\n throw Error(\n `getRowElementAtIndex no row found for index index ${rowIndex}`,\n );\n }\n }\n};\n\nexport const
|
|
1
|
+
{"version":3,"file":"row-utils.js","sources":["../src/row-utils.ts"],"sourcesContent":["//TODO this all probably belongs in vuu-table\nimport type {\n DataSourceRow,\n DataSourceRowObject,\n} from \"@vuu-ui/vuu-data-types\";\nimport type { MutableRefObject } from \"react\";\nimport { ColumnMap, metadataKeys } from \"./column-utils\";\nimport { isRowSelected } from \"./selection-utils\";\n\nconst { IS_LEAF, KEY, IDX } = metadataKeys;\n\nexport type RowOffsetFunc = (\n row: DataSourceRow,\n pctScrollTop?: number,\n) => number;\nexport type RowAtPositionFunc = (position: number) => number;\n\n/**\n * RowOffset function, RowAtPosition function, isVirtualScroll\n */\nexport type RowPositioning = [RowOffsetFunc, RowAtPositionFunc, boolean];\n\nexport const actualRowPositioning = (rowHeight: number): RowPositioning => [\n (row) => row[IDX] * rowHeight,\n (position) => Math.floor(position / rowHeight),\n false,\n];\n\n/**\n * return functions for determining a) the pixel offset to apply to a row, given the\n * row index and b) the index of the row at a given scroll offset. This implementation\n * is used when we are forced to 'virtualise' scrolling - because the number of rows\n * is high enough that we cannot create a large enough HTML content container.\n *\n * @param rowHeight\n * @param virtualisedExtent\n * @param pctScrollTop\n * @returns\n */\nexport const virtualRowPositioning = (\n rowHeight: number,\n virtualisedExtent: number,\n pctScrollTop: MutableRefObject<number>,\n): RowPositioning => [\n (row, offset = 0) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return (row[IDX] - offset) * rowHeight - rowOffset;\n },\n /*\n Return index position of closest row \n */\n (position) => {\n const rowOffset = pctScrollTop.current * virtualisedExtent;\n return Math.round((position + rowOffset) / rowHeight);\n },\n true,\n];\n\nexport const getRowElementAtIndex = (\n container: HTMLDivElement | EventTarget,\n rowIndex: number,\n) => {\n if (rowIndex === -1) {\n return null;\n } else {\n const activeRow = (container as HTMLElement).querySelector(\n `[aria-rowindex=\"${rowIndex + 1}\"]`,\n ) as HTMLElement;\n\n if (activeRow) {\n return activeRow;\n } else {\n throw Error(\n `getRowElementAtIndex no row found for index index ${rowIndex}`,\n );\n }\n }\n};\n\nexport const asDataSourceRowObject = (\n row: DataSourceRow,\n columnMap: ColumnMap,\n): DataSourceRowObject => {\n const { [IS_LEAF]: isLeaf, [KEY]: key, [IDX]: index } = row;\n\n const rowObject: DataSourceRowObject = {\n key,\n index,\n isGroupRow: !isLeaf,\n isSelected: isRowSelected(row),\n data: {},\n };\n\n for (const [colName, colIdx] of Object.entries(columnMap)) {\n rowObject.data[colName] = row[colIdx];\n }\n\n return rowObject;\n};\n"],"names":[],"mappings":";;;AASA,MAAM,EAAE,OAAA,EAAS,GAAK,EAAA,GAAA,EAAQ,GAAA,YAAA,CAAA;AAajB,MAAA,oBAAA,GAAuB,CAAC,SAAsC,KAAA;AAAA,EACzE,CAAC,GAAA,KAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,SAAA;AAAA,EACpB,CAAC,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,EAC7C,KAAA;AACF,EAAA;AAaO,MAAM,qBAAwB,GAAA,CACnC,SACA,EAAA,iBAAA,EACA,YACmB,KAAA;AAAA,EACnB,CAAC,GAAK,EAAA,MAAA,GAAS,CAAM,KAAA;AACnB,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA,CAAA;AACzC,IAAA,OAAA,CAAQ,GAAI,CAAA,GAAG,CAAI,GAAA,MAAA,IAAU,SAAY,GAAA,SAAA,CAAA;AAAA,GAC3C;AAAA;AAAA;AAAA;AAAA,EAIA,CAAC,QAAa,KAAA;AACZ,IAAM,MAAA,SAAA,GAAY,aAAa,OAAU,GAAA,iBAAA,CAAA;AACzC,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA,CAAO,QAAW,GAAA,SAAA,IAAa,SAAS,CAAA,CAAA;AAAA,GACtD;AAAA,EACA,IAAA;AACF,EAAA;AAEa,MAAA,oBAAA,GAAuB,CAClC,SAAA,EACA,QACG,KAAA;AACH,EAAA,IAAI,aAAa,CAAI,CAAA,EAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACF,MAAA;AACL,IAAA,MAAM,YAAa,SAA0B,CAAA,aAAA;AAAA,MAC3C,CAAA,gBAAA,EAAmB,WAAW,CAAC,CAAA,EAAA,CAAA;AAAA,KACjC,CAAA;AAEA,IAAA,IAAI,SAAW,EAAA;AACb,MAAO,OAAA,SAAA,CAAA;AAAA,KACF,MAAA;AACL,MAAM,MAAA,KAAA;AAAA,QACJ,qDAAqD,QAAQ,CAAA,CAAA;AAAA,OAC/D,CAAA;AAAA,KACF;AAAA,GACF;AACF,EAAA;AAEa,MAAA,qBAAA,GAAwB,CACnC,GAAA,EACA,SACwB,KAAA;AACxB,EAAA,MAAM,EAAE,CAAC,OAAO,GAAG,MAAQ,EAAA,CAAC,GAAG,GAAG,GAAK,EAAA,CAAC,GAAG,GAAG,OAAU,GAAA,GAAA,CAAA;AAExD,EAAA,MAAM,SAAiC,GAAA;AAAA,IACrC,GAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAY,CAAC,MAAA;AAAA,IACb,UAAA,EAAY,cAAc,GAAG,CAAA;AAAA,IAC7B,MAAM,EAAC;AAAA,GACT,CAAA;AAEA,EAAA,KAAA,MAAW,CAAC,OAAS,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACzD,IAAA,SAAA,CAAU,IAAK,CAAA,OAAO,CAAI,GAAA,GAAA,CAAI,MAAM,CAAA,CAAA;AAAA,GACtC;AAEA,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.
|
|
2
|
+
"version": "0.8.96",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@vuu-ui/vuu-data-types": "0.8.
|
|
8
|
-
"@vuu-ui/vuu-table-types": "0.8.
|
|
9
|
-
"@vuu-ui/vuu-filter-types": "0.8.
|
|
10
|
-
"@vuu-ui/vuu-protocol-types": "0.8.
|
|
7
|
+
"@vuu-ui/vuu-data-types": "0.8.96",
|
|
8
|
+
"@vuu-ui/vuu-table-types": "0.8.96",
|
|
9
|
+
"@vuu-ui/vuu-filter-types": "0.8.96",
|
|
10
|
+
"@vuu-ui/vuu-protocol-types": "0.8.96"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@internationalized/date": "^3.0.0",
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "0.8.
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "0.8.96",
|
|
15
15
|
"clsx": "^2.0.0",
|
|
16
16
|
"react": ">=17.0.2",
|
|
17
17
|
"react-dom": ">=17.0.2"
|
|
@@ -10,3 +10,6 @@ export declare const PageUp = "PageUp";
|
|
|
10
10
|
export declare const PageDown = "PageDown";
|
|
11
11
|
export declare const Space = " ";
|
|
12
12
|
export declare const Tab = "Tab";
|
|
13
|
+
export type ArrowKey = "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight";
|
|
14
|
+
export type PageKey = "Home" | "End" | "PageUp" | "PageDown";
|
|
15
|
+
export declare const isArrowKey: (key: string) => key is ArrowKey;
|
package/types/row-utils.d.ts
CHANGED
|
@@ -21,5 +21,4 @@ export declare const actualRowPositioning: (rowHeight: number) => RowPositioning
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const virtualRowPositioning: (rowHeight: number, virtualisedExtent: number, pctScrollTop: MutableRefObject<number>) => RowPositioning;
|
|
23
23
|
export declare const getRowElementAtIndex: (container: HTMLDivElement | EventTarget, rowIndex: number) => HTMLElement | null;
|
|
24
|
-
export declare const getIndexFromRowElement: (rowElement: HTMLElement) => number;
|
|
25
24
|
export declare const asDataSourceRowObject: (row: DataSourceRow, columnMap: ColumnMap) => DataSourceRowObject;
|