@elliemae/ds-shared 3.3.0-next.2 → 3.3.0-next.5
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/cjs/CheckableGroup.js +3 -19
- package/dist/cjs/CheckableGroup.js.map +1 -1
- package/dist/cjs/FocusGroup/FocusGrid.js +5 -18
- package/dist/cjs/FocusGroup/FocusGrid.js.map +1 -1
- package/dist/cjs/FocusGroup/FocusGroup.js +6 -19
- package/dist/cjs/FocusGroup/FocusGroup.js.map +1 -1
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js +14 -42
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js.map +1 -1
- package/dist/cjs/FocusGroup/useFocusGroupItem.js +2 -16
- package/dist/cjs/FocusGroup/useFocusGroupItem.js.map +1 -1
- package/dist/cjs/ScrollSync/ScrollSyncPane.js +3 -19
- package/dist/cjs/ScrollSync/ScrollSyncPane.js.map +1 -1
- package/dist/cjs/createDataInstance/createInstancePlugin.js +1 -15
- package/dist/cjs/createDataInstance/createInstancePlugin.js.map +1 -1
- package/dist/cjs/createDataInstance/createInstanceRef.js +9 -41
- package/dist/cjs/createDataInstance/createInstanceRef.js.map +1 -1
- package/dist/cjs/createDataInstance/utils.js +20 -25
- package/dist/cjs/createDataInstance/utils.js.map +1 -1
- package/dist/cjs/defer-render-hoc/index.js +3 -15
- package/dist/cjs/defer-render-hoc/index.js.map +1 -1
- package/dist/cjs/toolbar/ToolbarProvider.js +9 -24
- package/dist/cjs/toolbar/ToolbarProvider.js.map +1 -1
- package/dist/cjs/useDataGrid/initColumnDefinition.js +27 -33
- package/dist/cjs/useDataGrid/initColumnDefinition.js.map +1 -1
- package/dist/cjs/useDataGrid/useDataGrid.js +31 -53
- package/dist/cjs/useDataGrid/useDataGrid.js.map +1 -1
- package/dist/cjs/useDataList/useDataList.js +14 -47
- package/dist/cjs/useDataList/useDataList.js.map +1 -1
- package/dist/cjs/utils.js +2 -18
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/virtualization/AutoHeightList.js +14 -51
- package/dist/cjs/virtualization/AutoHeightList.js.map +1 -1
- package/dist/cjs/virtualization/FluidHeightList.js +7 -38
- package/dist/cjs/virtualization/FluidHeightList.js.map +1 -1
- package/dist/esm/CheckableGroup.js +3 -21
- package/dist/esm/CheckableGroup.js.map +1 -1
- package/dist/esm/FocusGroup/FocusGrid.js +5 -20
- package/dist/esm/FocusGroup/FocusGrid.js.map +1 -1
- package/dist/esm/FocusGroup/FocusGroup.js +6 -21
- package/dist/esm/FocusGroup/FocusGroup.js.map +1 -1
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js +14 -44
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js.map +1 -1
- package/dist/esm/FocusGroup/useFocusGroupItem.js +2 -17
- package/dist/esm/FocusGroup/useFocusGroupItem.js.map +1 -1
- package/dist/esm/ScrollSync/ScrollSyncPane.js +3 -21
- package/dist/esm/ScrollSync/ScrollSyncPane.js.map +1 -1
- package/dist/esm/createDataInstance/createInstancePlugin.js +1 -17
- package/dist/esm/createDataInstance/createInstancePlugin.js.map +1 -1
- package/dist/esm/createDataInstance/createInstanceRef.js +9 -43
- package/dist/esm/createDataInstance/createInstanceRef.js.map +1 -1
- package/dist/esm/createDataInstance/utils.js +20 -27
- package/dist/esm/createDataInstance/utils.js.map +1 -1
- package/dist/esm/defer-render-hoc/index.js +3 -17
- package/dist/esm/defer-render-hoc/index.js.map +1 -1
- package/dist/esm/toolbar/ToolbarProvider.js +9 -26
- package/dist/esm/toolbar/ToolbarProvider.js.map +1 -1
- package/dist/esm/useDataGrid/initColumnDefinition.js +27 -35
- package/dist/esm/useDataGrid/initColumnDefinition.js.map +1 -1
- package/dist/esm/useDataGrid/useDataGrid.js +31 -55
- package/dist/esm/useDataGrid/useDataGrid.js.map +1 -1
- package/dist/esm/useDataList/useDataList.js +14 -49
- package/dist/esm/useDataList/useDataList.js.map +1 -1
- package/dist/esm/utils.js +2 -20
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/virtualization/AutoHeightList.js +14 -53
- package/dist/esm/virtualization/AutoHeightList.js.map +1 -1
- package/dist/esm/virtualization/FluidHeightList.js +7 -40
- package/dist/esm/virtualization/FluidHeightList.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -59,10 +42,11 @@ function useCheckableGroup({ children, active: activeProp, multi, onCheck = () =
|
|
|
59
42
|
return import_react.default.Children.map(children, (child) => {
|
|
60
43
|
const { props } = child;
|
|
61
44
|
const checked = Array.isArray(active) ? active.indexOf(props.name) !== -1 : active === props.name;
|
|
62
|
-
return (0, import_react.cloneElement)(child,
|
|
45
|
+
return (0, import_react.cloneElement)(child, {
|
|
46
|
+
...props,
|
|
63
47
|
checked,
|
|
64
48
|
onClick: (0, import_ds_utilities.runAll)(handleCheck, props.onClick)
|
|
65
|
-
})
|
|
49
|
+
});
|
|
66
50
|
});
|
|
67
51
|
}
|
|
68
52
|
function CheckableGroup({
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/CheckableGroup.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { cloneElement } from 'react';\nimport PropTypes from 'prop-types';\nimport { addOrRemove, runAll, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nexport function useCheckableGroup({ children, active: activeProp, multi, onCheck = () => null }) {\n const [active, setActive] = useDerivedStateFromProps(activeProp);\n\n const handleCheck = ({ target: { value } }, item) => {\n setActive((prevActive) => {\n const nextActive = multi ? addOrRemove(prevActive, value) : value;\n onCheck(nextActive, item);\n return nextActive;\n });\n };\n\n return React.Children.map(children, (child) => {\n const { props } = child;\n const checked = Array.isArray(active) ? active.indexOf(props.name) !== -1 : active === props.name;\n\n return cloneElement(child, {\n ...props,\n checked,\n onClick: runAll(handleCheck, props.onClick),\n });\n });\n}\n\nexport function CheckableGroup({\n active = [],\n multi = false, // checkbox or radio\n children,\n}) {\n return useCheckableGroup({ active, multi, children });\n}\n\nCheckableGroup.propTypes = {\n /* The item (if multi false) or items (if multi true) selected */\n active: PropTypes.arrayOf(PropTypes.string),\n /* Whether is multi select or not */\n multi: PropTypes.bool,\n /* Handler when a user checks an item */\n onCheck: PropTypes.func,\n};\n\nexport default CheckableGroup;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAoC;AACpC,wBAAsB;AACtB,0BAA8D;AAEvD,2BAA2B,EAAE,UAAU,QAAQ,YAAY,OAAO,UAAU,MAAM,QAAQ;AAC/F,QAAM,CAAC,QAAQ,aAAa,kDAAyB,UAAU;AAE/D,QAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,WAAW,SAAS;AACnD,cAAU,CAAC,eAAe;AACxB,YAAM,aAAa,QAAQ,qCAAY,YAAY,KAAK,IAAI;AAC5D,cAAQ,YAAY,IAAI;AACxB,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,SAAO,qBAAM,SAAS,IAAI,UAAU,CAAC,UAAU;AAC7C,UAAM,EAAE,UAAU;AAClB,UAAM,UAAU,MAAM,QAAQ,MAAM,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,KAAK,WAAW,MAAM;AAE7F,WAAO,+BAAa,OAAO;AAAA,MACzB,GAAG;AAAA,MACH;AAAA,MACA,SAAS,gCAAO,aAAa,MAAM,OAAO;AAAA,IAC5C,CAAC;AAAA,EACH,CAAC;AACH;AAEO,wBAAwB;AAAA,EAC7B,SAAS,CAAC;AAAA,EACV,QAAQ;AAAA,EACR;AAAA,GACC;AACD,SAAO,kBAAkB,EAAE,QAAQ,OAAO,SAAS,CAAC;AACtD;AAEA,eAAe,YAAY;AAAA,EAEzB,QAAQ,0BAAU,QAAQ,0BAAU,MAAM;AAAA,EAE1C,OAAO,0BAAU;AAAA,EAEjB,SAAS,0BAAU;AACrB;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,22 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
8
|
var __export = (target, all) => {
|
|
23
9
|
for (var name in all)
|
|
24
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -132,7 +118,7 @@ const FocusGridProvider = ({
|
|
|
132
118
|
}
|
|
133
119
|
};
|
|
134
120
|
registerHotKeysHooks(hotKeys, { focusedCell, focusedRow });
|
|
135
|
-
const defaultKeyBindings =
|
|
121
|
+
const defaultKeyBindings = {
|
|
136
122
|
ArrowUp: (0, import_ds_utilities.runAll)(preventDefault, () => focusNextCell(-1, 0)),
|
|
137
123
|
ArrowRight: (0, import_ds_utilities.runAll)(preventDefault, () => focusNextCell(0, 1)),
|
|
138
124
|
ArrowDown: (0, import_ds_utilities.runAll)(preventDefault, () => focusNextCell(1, 0)),
|
|
@@ -150,13 +136,14 @@ const FocusGridProvider = ({
|
|
|
150
136
|
rowIndex = grid.current.length - 1;
|
|
151
137
|
}
|
|
152
138
|
focusNextCell(0, 0, { rowIndex, cellIndex: grid.current[0].length - 1 });
|
|
153
|
-
})
|
|
154
|
-
|
|
139
|
+
}),
|
|
140
|
+
...keyBindings
|
|
141
|
+
};
|
|
155
142
|
const nextKeyBindings = (0, import_ds_utilities.isFunction)(keyBindings) ? keyBindings({
|
|
156
143
|
defaultBindings: defaultKeyBindings,
|
|
157
144
|
rowIndex: focusedRow.current,
|
|
158
145
|
cellIndex: focusedCell.current
|
|
159
|
-
}) :
|
|
146
|
+
}) : { ...defaultKeyBindings, ...keyBindings };
|
|
160
147
|
const onKeyDown = (e) => {
|
|
161
148
|
if (e.target.tagName.toLowerCase() === "input")
|
|
162
149
|
return;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FocusGroup/FocusGrid.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { createContext, useEffect, useMemo, useRef } from 'react';\nimport { isFunction, runAll, get, useHotkeys, mergeRefs } from '@elliemae/ds-utilities';\nimport { getNextCellPosition } from './utils/getNextCellPosition';\n\nconst FocusGridContext = createContext();\nconst { Provider } = FocusGridContext;\n\nconst preventDefault = e => e.preventDefault();\n\nfunction registerHotKeysHooks(hotKeys, { focusedRow, focusedCell }) {\n Object.keys(hotKeys).forEach(key => {\n const { handler, options } = hotKeys[key];\n useHotkeys({\n keys: key,\n handler: e => {\n e.preventDefault();\n handler({\n rowIndex: focusedRow.current,\n cellIndex: focusedCell.current,\n });\n },\n options,\n });\n });\n}\n\n// eslint-disable-next-line max-statements\nconst FocusGridProvider = ({\n shouldWrapRows = false,\n shouldWrapCells = false,\n shouldRefocus = true,\n children,\n keyBindings,\n hotKeys,\n}) => {\n const focusedRow = useRef();\n const focusedCell = useRef();\n const grid = useRef([]);\n const containerRef = useRef(document);\n const child = React.Children.only(children);\n const decoratedChild = React.cloneElement(child, {\n innerRef: mergeRefs(child.props.innerRef, containerRef),\n });\n\n const getNode = ({ rowIndex, cellIndex }) =>\n get(grid.current, [rowIndex, cellIndex]);\n\n const register = (node, rowIndex, columnIndex) => {\n if (!node) return;\n if (!Array.isArray(grid.current[rowIndex])) {\n grid.current[rowIndex] = [];\n }\n\n if (rowIndex === 0 && columnIndex === 0) {\n node.setAttribute('tabindex', 0);\n } else {\n node.setAttribute('tabindex', -1);\n }\n\n node.onfocus = () => {\n const prevNode = getNode({\n rowIndex: focusedRow.current,\n cellIndex: focusedCell.current,\n });\n\n if (prevNode) prevNode.setAttribute('tabindex', -1);\n\n node.setAttribute('tabindex', 0);\n focusedRow.current = rowIndex;\n focusedCell.current = columnIndex;\n };\n grid.current[rowIndex][columnIndex] = node;\n };\n\n useEffect(() => {\n if (shouldRefocus) {\n const rowIndex = focusedRow.current;\n const cellIndex = focusedCell.current;\n\n const node = get(grid.current, [rowIndex, cellIndex]);\n if (node) node.focus();\n }\n });\n\n const focusNextCell = (directionY, directionX, position) => {\n const { rowIndex, cellIndex } =\n position ||\n getNextCellPosition({\n grid: grid.current,\n currentCell: focusedCell.current,\n currentRow: focusedRow.current,\n directionX,\n directionY,\n shouldWrapCells,\n shouldWrapRows,\n });\n\n const node = getNode({ rowIndex, cellIndex });\n\n // can focus\n if (node) {\n node.focus();\n focusedRow.current = rowIndex;\n focusedCell.current = cellIndex;\n }\n };\n\n registerHotKeysHooks(hotKeys, { focusedCell, focusedRow });\n\n const defaultKeyBindings = {\n ArrowUp: runAll(preventDefault, () => focusNextCell(-1, 0)),\n ArrowRight: runAll(preventDefault, () => focusNextCell(0, 1)),\n ArrowDown: runAll(preventDefault, () => focusNextCell(1, 0)),\n ArrowLeft: runAll(preventDefault, () => focusNextCell(0, -1)),\n Home: runAll(preventDefault, e => {\n let rowIndex = focusedRow.current;\n if (e.ctrlKey) {\n rowIndex = 0;\n }\n focusNextCell(0, 0, { rowIndex, cellIndex: 0 });\n }),\n End: runAll(preventDefault, e => {\n let rowIndex = focusedRow.current;\n if (e.ctrlKey) {\n rowIndex = grid.current.length - 1;\n }\n focusNextCell(0, 0, { rowIndex, cellIndex: grid.current[0].length - 1 });\n }),\n ...keyBindings,\n };\n const nextKeyBindings = isFunction(keyBindings)\n ? keyBindings({\n defaultBindings: defaultKeyBindings,\n rowIndex: focusedRow.current,\n cellIndex: focusedCell.current,\n })\n : { ...defaultKeyBindings, ...keyBindings };\n\n const onKeyDown = e => {\n if (e.target.tagName.toLowerCase() === 'input') return;\n const action = nextKeyBindings[e.key];\n if (isFunction(action)) action(e);\n };\n\n const activate = container => {\n container.addEventListener('keydown', onKeyDown, true);\n };\n\n const deactivate = container => {\n container.removeEventListener('keydown', onKeyDown, true);\n };\n\n useEffect(() => {\n activate(containerRef.current);\n return () => {\n deactivate(containerRef.current);\n };\n }, []);\n\n const valueProvider = useMemo(\n () => ({\n register,\n }),\n [],\n );\n\n return <Provider value={valueProvider}>{decoratedChild}</Provider>;\n};\n\nexport { FocusGridProvider, FocusGridProvider as FocusGrid, FocusGridContext };\nexport default FocusGridProvider;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAiE;AACjE,0BAA+D;AAC/D,iCAAoC;AAEpC,MAAM,mBAAmB,gCAAc;AACvC,MAAM,EAAE,aAAa;AAErB,MAAM,iBAAiB,OAAK,EAAE,eAAe;AAE7C,8BAA8B,SAAS,EAAE,YAAY,eAAe;AAClE,SAAO,KAAK,OAAO,EAAE,QAAQ,SAAO;AAClC,UAAM,EAAE,SAAS,YAAY,QAAQ;AACrC,wCAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,OAAK;AACZ,UAAE,eAAe;AACjB,gBAAQ;AAAA,UACN,UAAU,WAAW;AAAA,UACrB,WAAW,YAAY;AAAA,QACzB,CAAC;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AAGA,MAAM,oBAAoB,CAAC;AAAA,EACzB,iBAAiB;AA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ACrB,WAAW,YAAY;AAAA,EACzB,CAAC,IACD,EAAE,GAAG,oBAAoB,GAAG,YAAY;AAE5C,QAAM,YAAY,OAAK;AACrB,QAAI,EAAE,OAAO,QAAQ,YAAY,MAAM;AAAS;AAChD,UAAM,SAAS,gBAAgB,EAAE;AACjC,QAAI,oCAAW,MAAM;AAAG,aAAO,CAAC;AAAA,EAClC;AAEA,QAAM,WAAW,eAAa;AAC5B,cAAU,iBAAiB,WAAW,WAAW,IAAI;AAAA,EACvD;AAEA,QAAM,aAAa,eAAa;AAC9B,cAAU,oBAAoB,WAAW,WAAW,IAAI;AAAA,EAC1D;AAEA,8BAAU,MAAM;AACd,aAAS,aAAa,OAAO;AAC7B,WAAO,MAAM;AACX,iBAAW,aAAa,OAAO;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,0BACpB,MAAO;AAAA,IACL;AAAA,EACF,IACA,CAAC,CACH;AAEA,SAAO,mDAAC;AAAA,IAAS,OAAO;AAAA,KAAgB,cAAe;AACzD;AAGA,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,22 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
8
|
var __export = (target, all) => {
|
|
23
9
|
for (var name in all)
|
|
24
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -61,7 +47,7 @@ const registerHotkeys = (hotKeys = {}, params, getContainer = () => document) =>
|
|
|
61
47
|
e.preventDefault();
|
|
62
48
|
handler(handlerParams);
|
|
63
49
|
};
|
|
64
|
-
(0, import_hotkeys_js.default)(hotkey,
|
|
50
|
+
(0, import_hotkeys_js.default)(hotkey, { element: getContainer(), ...options }, parameterizedHandler);
|
|
65
51
|
});
|
|
66
52
|
};
|
|
67
53
|
const unregisterHotKeys = (hotKeys = {}) => {
|
|
@@ -73,9 +59,9 @@ const noop = () => null;
|
|
|
73
59
|
class FocusGroup {
|
|
74
60
|
constructor(options = {}) {
|
|
75
61
|
this.items = [];
|
|
76
|
-
this.options =
|
|
62
|
+
this.options = { ...defaultOptions, ...options };
|
|
77
63
|
const { orientation } = this.options;
|
|
78
|
-
this.keyBindings =
|
|
64
|
+
this.keyBindings = {
|
|
79
65
|
ArrowUp: orientation !== "horizontal" && "previous",
|
|
80
66
|
ArrowRight: orientation !== "vertical" && "next",
|
|
81
67
|
ArrowDown: orientation !== "horizontal" && "next",
|
|
@@ -84,8 +70,9 @@ class FocusGroup {
|
|
|
84
70
|
End: "last",
|
|
85
71
|
PageUp: "first",
|
|
86
72
|
PageDown: "last",
|
|
87
|
-
Escape: "exit"
|
|
88
|
-
|
|
73
|
+
Escape: "exit",
|
|
74
|
+
...options.keyBindings
|
|
75
|
+
};
|
|
89
76
|
this.currentFocusedItem = null;
|
|
90
77
|
this.currIndex = null;
|
|
91
78
|
this.mapActions = {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FocusGroup/FocusGroup.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable no-param-reassign */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { isFunction, get } from '@elliemae/ds-utilities';\nimport hotkeys from 'hotkeys-js';\n\nconst defaultOptions = {\n orientation: 'vertical',\n};\n\nconst safeCallAction = (e, fun, ...args) => {\n if (isFunction(fun)) {\n e.preventDefault();\n fun(...args);\n }\n};\n\nconst registerHotkeys = (hotKeys = {}, params, getContainer = () => document) => {\n Object.keys(hotKeys).forEach((hotkey) => {\n const { options, handler, allowDocumentHandler = false } = hotKeys[hotkey];\n const parameterizedHandler = (e) => {\n const handlerParams = isFunction(params) ? params() : params;\n if (!allowDocumentHandler && handlerParams.item !== document.activeElement) return;\n e.preventDefault();\n handler(handlerParams);\n };\n hotkeys(hotkey, { element: getContainer(), ...options }, parameterizedHandler);\n });\n};\n\nconst unregisterHotKeys = (hotKeys = {}) => {\n Object.keys(hotKeys).forEach((hotkey) => {\n hotkeys.unbind(hotkey);\n });\n};\n\nconst noop = () => null;\n\nclass FocusGroup {\n items = [];\n\n constructor(options = {}) {\n this.options = { ...defaultOptions, ...options };\n\n const { orientation } = this.options;\n\n this.keyBindings = {\n ArrowUp: orientation !== 'horizontal' && 'previous',\n ArrowRight: orientation !== 'vertical' && 'next',\n ArrowDown: orientation !== 'horizontal' && 'next',\n ArrowLeft: orientation !== 'vertical' && 'previous',\n Home: 'first',\n End: 'last',\n PageUp: 'first',\n PageDown: 'last',\n Escape: 'exit',\n ...options.keyBindings,\n };\n\n this.currentFocusedItem = null;\n this.currIndex = null;\n\n this.mapActions = {\n previous: this.focusPrevious.bind(this),\n next: this.focusNext.bind(this),\n first: this.focusFirst.bind(this),\n last: this.focusLast.bind(this),\n exit: this.exit.bind(this),\n enter: () => null,\n };\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.register = this.register.bind(this);\n this.focusFirst = this.focusFirst.bind(this);\n this.focusLast = this.focusLast.bind(this);\n this.isGroupActive = this.isGroupActive.bind(this);\n this.focusNext = this.focusNext.bind(this);\n this.focusPrevious = this.focusPrevious.bind(this);\n this.focusItem = this.focusItem.bind(this);\n this.focusCurrent = this.focusCurrent.bind(this);\n this.getHotKeysParams = this.getHotKeysParams.bind(this);\n this.activate = this.activate.bind(this);\n this.deactivate = this.deactivate.bind(this);\n this.executeActionByEvent = this.executeActionByEvent.bind(this);\n this.unregister = this.unregister.bind(this);\n this.exit = this.exit.bind(this);\n this.focusByNode = this.focusByNode.bind(this);\n this.focusByIndex = this.focusByIndex.bind(this);\n this.focusNextGroup = this.focusNextGroup.bind(this);\n this.focusPreviousGroup = this.focusPreviousGroup.bind(this);\n this.getNextItem = this.getNextItem.bind(this);\n this.getPreviousItem = this.getPreviousItem.bind(this);\n this.checkCanFocusNext = this.checkCanFocusNext.bind(this);\n this.getItemByIndex = this.getItemByIndex.bind(this);\n this.getItemIndexByNode = this.getItemIndexByNode.bind(this);\n this.getFocusedIndex = this.getFocusedIndex.bind(this);\n this.getFocusedItem = this.getFocusedItem.bind(this);\n this.getFirstItem = this.getFirstItem.bind(this);\n this.getLastItem = this.getLastItem.bind(this);\n }\n\n getHotKeysParams() {\n const item = this.currentFocusedItem;\n const { index } = get(item, ['dataset'], {});\n return {\n item,\n index,\n };\n }\n\n activate() {\n const { getContainer } = this.options;\n document.addEventListener('keydown', this.handleKeyDown, true);\n registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);\n }\n\n deactivate() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n unregisterHotKeys(this.options.hotKeys);\n }\n\n handleKeyDown(e) {\n if (!this.isGroupActive()) return;\n this.executeActionByEvent(e);\n }\n\n executeActionByEvent(e) {\n const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];\n return actions.map((action) =>\n typeof action === 'string' ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action),\n );\n }\n\n register(node, props = {}) {\n const afterIndex = this.items.findIndex(\n (item) => item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING,\n );\n node.specialOnFocus = props.onFocus || noop;\n node.specialOnBlur = props.onBlur || noop;\n node.onclick = () => this.focusItem(node);\n node.onfocus = () => {\n this.focusItem(node);\n };\n if (afterIndex === -1) {\n this.items.push(node);\n } else {\n this.items.splice(afterIndex, 0, node);\n }\n }\n\n unregister(node) {\n const index = this.getItemIndexByNode(node);\n if (index > -1) this.items.splice(index, 1);\n }\n\n exit() {\n const { onExitFocusGroup } = this.options;\n onExitFocusGroup();\n }\n\n focusItem(node) {\n if (this.currentFocusedItem && this.currentFocusedItem !== node) {\n this.currentFocusedItem.specialOnBlur();\n this.currentFocusedItem.setAttribute('tabindex', -1);\n }\n if (!node) return;\n this.currentFocusedItem = node;\n node.setAttribute('tabindex', 0);\n node.focus();\n node.specialOnFocus();\n }\n\n focusNext() {\n const item = this.getNextItem();\n this.focusItem(item);\n }\n\n focusByNode(node) {\n const index = this.getItemIndexByNode(node);\n this.focusByIndex(index);\n }\n\n focusByIndex(index) {\n const item = this.getItemByIndex(index);\n this.focusItem(item);\n }\n\n focusPrevious() {\n const prevItem = this.getPreviousItem();\n this.focusItem(prevItem);\n }\n\n focusFirst() {\n const item = this.getFirstItem();\n this.focusItem(item);\n }\n\n focusLast() {\n const item = this.getLastItem();\n this.focusItem(item);\n }\n\n focusCurrent() {\n this.focusItem(this.currentFocusedItem);\n }\n\n focusNextGroup() {\n const { onFocusNextGroup } = this.options;\n this.exit();\n onFocusNextGroup();\n }\n\n focusPreviousGroup() {\n const { onFocusPreviousGroup } = this.options;\n this.exit();\n onFocusPreviousGroup();\n }\n\n getNextItem() {\n const { loop } = this.options;\n const currentIndex = this.getFocusedIndex();\n const supposedNextIndex = currentIndex + 1;\n if (!this.checkCanFocusNext(supposedNextIndex)) {\n return loop ? this.getFirstItem() : this.focusNextGroup();\n }\n return this.getItemByIndex(supposedNextIndex);\n }\n\n getPreviousItem() {\n const { loop } = this.options;\n const currentIndex = this.getFocusedIndex();\n const supposedPrevIndex = currentIndex - 1;\n if (!this.checkCanFocusPrev(supposedPrevIndex)) {\n return loop ? this.getLastItem() : this.focusPreviousGroup();\n }\n return this.getItemByIndex(supposedPrevIndex);\n }\n\n checkCanFocusNext(index) {\n return this.items.length > index;\n }\n\n checkCanFocusPrev(index) {\n return index >= 0;\n }\n\n getItemByIndex(index) {\n return this.items[index];\n }\n\n getItemIndexByNode(node) {\n return this.items.findIndex((item) => item === node);\n }\n\n getFocusedIndex() {\n return this.getItemIndexByNode(document.activeElement);\n }\n\n getFocusedItem() {\n const index = this.getFocusedIndex();\n return index > -1 && this.items[index];\n }\n\n isGroupActive() {\n return this.getFocusedIndex() !== -1;\n }\n\n getFirstItem() {\n return !!this.items.length && this.items[0];\n }\n\n getLastItem() {\n return !!this.items.length && this.items[this.items.length - 1];\n }\n}\n\nexport { FocusGroup };\nexport default FocusGroup;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,0BAAgC;AAChC,wBAAoB;AAEpB,MAAM,iBAAiB;AAAA,EACrB,aAAa;AACf;AAEA,MAAM,iBAAiB,CAAC,GAAG,QAAQ,SAAS;AAC1C,MAAI,oCAAW,GAAG,GAAG;AACnB,MAAE,eAAe;AACjB,QAAI,GAAG,IAAI;AAAA,EACb;AACF;AAEA,MAAM,kBAAkB,CAAC,UAAU,CAAC,GAAG,QAAQ,eAAe,MAAM,aAAa;AAC/E,SAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,WAAW;AACvC,UAAM,EAAE,SAAS,SAAS,uBAAuB,UAAU,QAAQ;AACnE,UAAM,uBAAuB,CAAC,MAAM;AA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;AACF;AAGA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,34 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
8
|
var __export = (target, all) => {
|
|
35
9
|
for (var name in all)
|
|
36
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -55,22 +29,20 @@ var React = __toESM(require("react"));
|
|
|
55
29
|
var import_react = __toESM(require("react"));
|
|
56
30
|
var import_FocusGroupManager = require("./FocusGroupManager");
|
|
57
31
|
function FocusGroupHoc(WrappedComponent, options = {}) {
|
|
58
|
-
return (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, options), /* @__PURE__ */ import_react.default.createElement(WrappedComponent, __spreadValues(__spreadValues({}, props), options)));
|
|
73
|
-
};
|
|
32
|
+
return ({
|
|
33
|
+
onExitFocusGroup,
|
|
34
|
+
onFocusPrevGroup,
|
|
35
|
+
focusKeyBindings,
|
|
36
|
+
...props
|
|
37
|
+
}) => /* @__PURE__ */ import_react.default.createElement(import_FocusGroupManager.FocusGroupProvider, {
|
|
38
|
+
keyBindings: focusKeyBindings,
|
|
39
|
+
onExitFocusGroup,
|
|
40
|
+
onFocusPrevGroup,
|
|
41
|
+
...options
|
|
42
|
+
}, /* @__PURE__ */ import_react.default.createElement(WrappedComponent, {
|
|
43
|
+
...props,
|
|
44
|
+
...options
|
|
45
|
+
}));
|
|
74
46
|
}
|
|
75
47
|
var focusGroupManagerHoc_default = FocusGroupHoc;
|
|
76
48
|
//# sourceMappingURL=focusGroupManagerHoc.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FocusGroup/focusGroupManagerHoc.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react/display-name */\nimport React from 'react';\nimport { FocusGroupProvider } from './FocusGroupManager';\n\nfunction FocusGroupHoc(WrappedComponent, options = {}) {\n return ({\n onExitFocusGroup,\n onFocusPrevGroup,\n focusKeyBindings,\n ...props\n }) => (\n <FocusGroupProvider\n keyBindings={focusKeyBindings}\n onExitFocusGroup={onExitFocusGroup}\n onFocusPrevGroup={onFocusPrevGroup}\n {...options}\n >\n <WrappedComponent {...props} {...options} />\n </FocusGroupProvider>\n );\n}\n\nexport { FocusGroupHoc };\nexport default FocusGroupHoc;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,+BAAmC;AAEnC,uBAAuB,kBAAkB,UAAU,CAAC,GAAG;AACrD,SAAO,CAAC;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,QAEH,mDAAC;AAAA,IACC,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACC,GAAG;AAAA,KAEJ,mDAAC;AAAA,IAAkB,GAAG;AAAA,IAAQ,GAAG;AAAA,GAAS,CAC5C;AAEJ;AAGA,IAAO,+BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,22 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __objRest = (source, exclude) => {
|
|
11
|
-
var target = {};
|
|
12
|
-
for (var prop in source)
|
|
13
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
14
|
-
target[prop] = source[prop];
|
|
15
|
-
if (source != null && __getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
17
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
18
|
-
target[prop] = source[prop];
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
};
|
|
22
8
|
var __export = (target, all) => {
|
|
23
9
|
for (var name in all)
|
|
24
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -44,7 +30,7 @@ var React = __toESM(require("react"));
|
|
|
44
30
|
var import_react = require("react");
|
|
45
31
|
var import_FocusGroupContext = require("./FocusGroupContext");
|
|
46
32
|
function useFocusGroupItem(ref = {}, props) {
|
|
47
|
-
const
|
|
33
|
+
const { register, unregister, ...otherActions } = (0, import_react.useContext)(import_FocusGroupContext.FocusGroupContext) || {};
|
|
48
34
|
(0, import_react.useEffect)(() => {
|
|
49
35
|
if (ref.current && register)
|
|
50
36
|
register(ref.current, props);
|
|
@@ -58,7 +44,7 @@ function useFocusGroupItem(ref = {}, props) {
|
|
|
58
44
|
return otherActions;
|
|
59
45
|
}
|
|
60
46
|
const useFocusGroupWithState = (ref = {}, props) => {
|
|
61
|
-
const
|
|
47
|
+
const { register, unregister, ...otherActions } = (0, import_react.useContext)(import_FocusGroupContext.FocusGroupContext) || {};
|
|
62
48
|
(0, import_react.useEffect)(() => {
|
|
63
49
|
if (ref && register)
|
|
64
50
|
register(ref, props);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FocusGroup/useFocusGroupItem.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { useContext, useEffect } from 'react';\nimport { FocusGroupContext } from './FocusGroupContext';\n\nfunction useFocusGroupItem(ref = {}, props) {\n const { register, unregister, ...otherActions } =\n useContext(FocusGroupContext) || {};\n\n useEffect(() => {\n if (ref.current && register) register(ref.current, props);\n return () => {\n if (ref.current && unregister) unregister(ref.current);\n };\n });\n\n // if the focus item is not wrapped with the focus provider then return null\n if (!register) return {};\n return otherActions;\n}\n\nexport const useFocusGroupWithState = (ref = {}, props) => {\n const { register, unregister, ...otherActions } =\n useContext(FocusGroupContext) || {};\n\n useEffect(() => {\n if (ref && register) register(ref, props);\n return () => {\n if (ref && unregister) unregister(ref);\n };\n }, [ref]);\n\n // if the focus item is not wrapped with the focus provider then return null\n if (!register) return {};\n return otherActions;\n};\n\nexport { useFocusGroupItem };\nexport default useFocusGroupItem;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAsC;AACtC,+BAAkC;AAElC,2BAA2B,MAAM,CAAC,GAAG,OAAO;AAC1C,QAAM,EAAE,UAAU,eAAe,iBAC/B,6BAAW,0CAAiB,KAAK,CAAC;AAEpC,8BAAU,MAAM;AACd,QAAI,IAAI,WAAW;AAAU,eAAS,IAAI,SAAS,KAAK;AACxD,WAAO,MAAM;AACX,UAAI,IAAI,WAAW;AAAY,mBAAW,IAAI,OAAO;AAAA,IACvD;AAAA,EACF,CAAC;AAGD,MAAI,CAAC;AAAU,WAAO,CAAC;AACvB,SAAO;AACT;AAEO,MAAM,yBAAyB,CAAC,MAAM,CAAC,GAAG,UAAU;AACzD,QAAM,EAAE,UAAU,eAAe,iBAC/B,6BAAW,0CAAiB,KAAK,CAAC;AAEpC,8BAAU,MAAM;AACd,QAAI,OAAO;AAAU,eAAS,KAAK,KAAK;AACxC,WAAO,MAAM;AACX,UAAI,OAAO;AAAY,mBAAW,GAAG;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,GAAG,CAAC;AAGR,MAAI,CAAC;AAAU,WAAO,CAAC;AACvB,SAAO;AACT;AAGA,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -76,8 +59,9 @@ ScrollSyncPane.defaultProps = {
|
|
|
76
59
|
group: "default",
|
|
77
60
|
enabled: true
|
|
78
61
|
};
|
|
79
|
-
const ScrollSyncPaneHOC = (props) => /* @__PURE__ */ import_react.default.createElement(import_ScrollSync.ScrollSyncContext.Consumer, null, (context) => /* @__PURE__ */ import_react.default.createElement(ScrollSyncPane,
|
|
62
|
+
const ScrollSyncPaneHOC = (props) => /* @__PURE__ */ import_react.default.createElement(import_ScrollSync.ScrollSyncContext.Consumer, null, (context) => /* @__PURE__ */ import_react.default.createElement(ScrollSyncPane, {
|
|
63
|
+
...props,
|
|
80
64
|
syncContext: context
|
|
81
|
-
}))
|
|
65
|
+
}));
|
|
82
66
|
var ScrollSyncPane_default = ScrollSyncPaneHOC;
|
|
83
67
|
//# sourceMappingURL=ScrollSyncPane.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ScrollSync/ScrollSyncPane.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react/display-name */\nimport React, { Component } from 'react';\nimport { ScrollSyncContext } from './ScrollSync';\n\n/**\n * MODIFIED FROM react-scroll-sync\n *\n * ScrollSyncPane Component\n *\n * Wrap your content in it to keep its scroll position in sync with other panes\n *\n * @param groups\n * @example ./example.md\n */\nclass ScrollSyncPane extends Component {\n static defaultProps = {\n group: 'default',\n enabled: true,\n };\n\n componentWillUnmount() {\n const { enabled, group, syncContext } = this.props;\n const { unregisterPane } = syncContext;\n\n if (enabled) unregisterPane(this.node, this.toArray(group));\n }\n\n toArray = groups => [].concat(groups);\n\n render() {\n const { children, group, syncContext, notPaginated } = this.props;\n const { registerPane } = syncContext;\n\n return children({\n registerPane: node => {\n if (notPaginated) {\n const virtualizedBody = node.querySelector(\n '.virtualized-body-wrapper',\n );\n if (virtualizedBody) {\n registerPane(virtualizedBody, this.toArray(group));\n }\n }\n return registerPane(node, this.toArray(group));\n },\n });\n }\n}\n\nexport const ScrollSyncPaneHOC = props => (\n <ScrollSyncContext.Consumer>\n {context => <ScrollSyncPane {...props} syncContext={context} />}\n </ScrollSyncContext.Consumer>\n);\n\nexport default ScrollSyncPaneHOC;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAiC;AACjC,wBAAkC;AAYlC,MAAM,uBAAuB,uBAAU;AAAA,EAAvC;AAAA;AAaE,mBAAU,YAAU,CAAC,EAAE,OAAO,MAAM;AAAA;AAAA,EAPpC,uBAAuB;AACrB,UAAM,EAAE,SAAS,OAAO,gBAAgB,KAAK;AAC7C,UAAM,EAAE,mBAAmB;AAE3B,QAAI;AAAS,qBAAe,KAAK,MAAM,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC5D;AAAA,EAIA,SAAS;AACP,UAAM,EAAE,UAAU,OAAO,aAAa,iBAAiB,KAAK;AAC5D,UAAM,EAAE,iBAAiB;AAEzB,WAAO,SAAS;AAAA,MACd,cAAc,UAAQ;AACpB,YAAI,cAAc;AAChB,gBAAM,kBAAkB,KAAK,cAC3B,2BACF;AACA,cAAI,iBAAiB;AACnB,yBAAa,iBAAiB,KAAK,QAAQ,KAAK,CAAC;AAAA,UACnD;AAAA,QACF;AACA,eAAO,aAAa,MAAM,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC/C;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAhCE,AADI,eACG,eAAe;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AACX;AA+BK,MAAM,oBAAoB,WAC/B,mDAAC,oCAAkB,UAAlB,MACE,aAAW,mDAAC;AAAA,EAAgB,GAAG;AAAA,EAAO,aAAa;AAAA,CAAS,CAC/D;AAGF,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,22 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
8
|
var __export = (target, all) => {
|
|
23
9
|
for (var name in all)
|
|
24
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -42,7 +28,7 @@ __export(createInstancePlugin_exports, {
|
|
|
42
28
|
module.exports = __toCommonJS(createInstancePlugin_exports);
|
|
43
29
|
var React = __toESM(require("react"));
|
|
44
30
|
const getDecoratorsFromHooks = (hooks, decorators) => {
|
|
45
|
-
const nextDecorators =
|
|
31
|
+
const nextDecorators = { ...decorators };
|
|
46
32
|
Object.keys(hooks).forEach((decorator) => {
|
|
47
33
|
if (Array.isArray(decorators[decorator])) {
|
|
48
34
|
nextDecorators[decorator] = [...decorators[decorator], hooks[decorator]];
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/createDataInstance/createInstancePlugin.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["const getDecoratorsFromHooks = (hooks, decorators) => {\n const nextDecorators = { ...decorators };\n\n Object.keys(hooks).forEach((decorator) => {\n if (Array.isArray(decorators[decorator])) {\n nextDecorators[decorator] = [...decorators[decorator], hooks[decorator]];\n } else {\n nextDecorators[decorator] = hooks[decorator];\n }\n });\n\n return nextDecorators;\n};\n\nexport const createInstancePlugin = (name, hooks) => (decorators) => getDecoratorsFromHooks(hooks, decorators);\n\nexport default createInstancePlugin;\n\nexport { getDecoratorsFromHooks };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,yBAAyB,CAAC,OAAO,eAAe;AACpD,QAAM,iBAAiB,EAAE,GAAG,WAAW;AAEvC,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,cAAc;AACxC,QAAI,MAAM,QAAQ,WAAW,UAAU,GAAG;AACxC,qBAAe,aAAa,CAAC,GAAG,WAAW,YAAY,MAAM,UAAU;AAAA,IACzE,OAAO;AACL,qBAAe,aAAa,MAAM;AAAA,IACpC;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,MAAM,UAAU,CAAC,eAAe,uBAAuB,OAAO,UAAU;AAE7G,IAAO,+BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,34 +3,8 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
8
|
var __export = (target, all) => {
|
|
35
9
|
for (var name in all)
|
|
36
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -63,20 +37,14 @@ const defaultDecorators = {
|
|
|
63
37
|
renderers: [],
|
|
64
38
|
composeData: []
|
|
65
39
|
};
|
|
66
|
-
function createDataInstanceRef(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"uuid",
|
|
75
|
-
"data",
|
|
76
|
-
"renderers",
|
|
77
|
-
"plugins",
|
|
78
|
-
"customDecorators"
|
|
79
|
-
]);
|
|
40
|
+
function createDataInstanceRef({
|
|
41
|
+
uuid: uuidProp,
|
|
42
|
+
data,
|
|
43
|
+
renderers,
|
|
44
|
+
plugins,
|
|
45
|
+
customDecorators,
|
|
46
|
+
...props
|
|
47
|
+
}) {
|
|
80
48
|
const instance = (0, import_react.useRef)();
|
|
81
49
|
const [uuid] = (0, import_react.useState)(uuidProp || (() => (0, import_uuid.v4)()));
|
|
82
50
|
instance.current = {
|
|
@@ -96,7 +64,7 @@ function createDataInstanceRef(_a) {
|
|
|
96
64
|
props
|
|
97
65
|
};
|
|
98
66
|
const decorators = (0, import_react.useMemo)(() => {
|
|
99
|
-
let nextDecorators =
|
|
67
|
+
let nextDecorators = { ...defaultDecorators, ...customDecorators };
|
|
100
68
|
plugins.forEach((plugin) => {
|
|
101
69
|
if (!plugin)
|
|
102
70
|
return;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/createDataInstance/createInstanceRef.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { v4 as uuidv4 } from 'uuid';\nimport { useMemo, useRef, useState } from 'react';\nimport { orderBy } from 'lodash';\nimport {\n mergeInstance,\n registerHotKeysHookToInstance,\n registerStateHookToInstance,\n} from './utils';\n\nconst defaultDecorators = {\n instance: [],\n state: [],\n hotKeys: [],\n renderers: [],\n composeData: [],\n};\n\nfunction createDataInstanceRef({\n uuid: uuidProp,\n data,\n renderers,\n plugins,\n customDecorators,\n ...props\n}) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const instance = useRef();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [uuid] = useState(uuidProp || (() => uuidv4()));\n\n instance.current = {\n uuid,\n state: {},\n actions: {},\n hotKeys: {}, // keyboard hotkeys to run specific actions\n originalData: data,\n records: [], // item abstraction with meta data for originalData\n renderers,\n ref(key) {\n // eslint-disable-next-line no-return-assign\n return (node) => (instance.current.refs[key] = node);\n },\n getInstance() {\n return instance.current;\n },\n props,\n };\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const decorators = useMemo(() => {\n let nextDecorators = { ...defaultDecorators, ...customDecorators };\n\n plugins.forEach((plugin) => {\n if (!plugin) return;\n nextDecorators = plugin(nextDecorators);\n });\n\n Object.keys(nextDecorators).forEach((key) => {\n if (Array.isArray(nextDecorators[key]))\n nextDecorators[key] = orderBy(\n nextDecorators[key],\n (item) => item.order,\n );\n });\n\n return nextDecorators;\n }, []); // the plugins are defined on creation, but not changed at runtime\n\n // todo: test if getting the hooks without registering them\n // here would be beneficial to memoize instance and squeeze performance\n instance.current = decorators.instance.reduce(\n mergeInstance,\n instance.current,\n );\n instance.current = decorators.state.reduce(\n registerStateHookToInstance,\n instance.current,\n );\n instance.current = decorators.hotKeys.reduce(\n registerHotKeysHookToInstance,\n instance.current,\n );\n instance.current.renderers = decorators.renderers.reduce(\n (result, decorator) => decorator(result, instance.current),\n renderers,\n );\n\n return { instance, decorators };\n}\n\nexport { createDataInstanceRef };\nexport default createDataInstanceRef;", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,kBAA6B;AAC7B,mBAA0C;AAC1C,oBAAwB;AACxB,mBAIO;AAEP,MAAM,oBAAoB;AAAA,EACxB,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,WAAW,CAAC;AAAA,EACZ,aAAa,CAAC;AAChB;AAEA,+BAA+B;AAAA,EAC7B,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,GACF;AAED,QAAM,WAAW,yBAAO;AAExB,QAAM,CAAC,QAAQ,2BAAS,YAAa,OAAM,oBAAO,EAAE;AAEpD,WAAS,UAAU;AAAA,IACjB;AAAA,IACA,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,SAAS,CAAC;AAAA,IACV,cAAc;AAAA,IACd,SAAS,CAAC;AAAA,IACV;AAAA,IACA,IAAI,KAAK;AAEP,aAAO,CAAC,SAAU,SAAS,QAAQ,KAAK,OAAO;AAAA,IACjD;AAAA,IACA,cAAc;AACZ,aAAO,SAAS;AAAA,IAClB;AAAA,IACA;AAAA,EACF;AAGA,QAAM,aAAa,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