@elliemae/ds-shared 3.0.0-alpha.0 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CheckableGroup.js +19 -3
- package/dist/cjs/CheckableGroup.js.map +1 -1
- package/dist/cjs/FocusGroup/FocusGrid.js +18 -5
- package/dist/cjs/FocusGroup/FocusGrid.js.map +1 -1
- package/dist/cjs/FocusGroup/FocusGroup.js +19 -6
- package/dist/cjs/FocusGroup/FocusGroup.js.map +1 -1
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js +42 -14
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js.map +1 -1
- package/dist/cjs/FocusGroup/useFocusGroupItem.js +16 -2
- package/dist/cjs/FocusGroup/useFocusGroupItem.js.map +1 -1
- package/dist/cjs/ScrollSync/ScrollSyncPane.js +19 -3
- package/dist/cjs/ScrollSync/ScrollSyncPane.js.map +1 -1
- package/dist/cjs/createDataInstance/createInstancePlugin.js +15 -1
- package/dist/cjs/createDataInstance/createInstancePlugin.js.map +1 -1
- package/dist/cjs/createDataInstance/createInstanceRef.js +41 -9
- package/dist/cjs/createDataInstance/createInstanceRef.js.map +1 -1
- package/dist/cjs/createDataInstance/utils.js +25 -20
- package/dist/cjs/createDataInstance/utils.js.map +1 -1
- package/dist/cjs/defer-render-hoc/index.js +15 -3
- package/dist/cjs/defer-render-hoc/index.js.map +1 -1
- package/dist/cjs/toolbar/ToolbarProvider.js +24 -9
- package/dist/cjs/toolbar/ToolbarProvider.js.map +1 -1
- package/dist/cjs/useDataGrid/initColumnDefinition.js +33 -27
- package/dist/cjs/useDataGrid/initColumnDefinition.js.map +1 -1
- package/dist/cjs/useDataGrid/useDataGrid.js +53 -31
- package/dist/cjs/useDataGrid/useDataGrid.js.map +1 -1
- package/dist/cjs/useDataList/useDataList.js +47 -14
- package/dist/cjs/useDataList/useDataList.js.map +1 -1
- package/dist/cjs/utils.js +18 -2
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/virtualization/AutoHeightList.js +51 -14
- package/dist/cjs/virtualization/AutoHeightList.js.map +1 -1
- package/dist/cjs/virtualization/FluidHeightList.js +38 -7
- package/dist/cjs/virtualization/FluidHeightList.js.map +1 -1
- package/dist/esm/CheckableGroup.js +21 -3
- package/dist/esm/CheckableGroup.js.map +1 -1
- package/dist/esm/FocusGroup/FocusGrid.js +20 -5
- package/dist/esm/FocusGroup/FocusGrid.js.map +1 -1
- package/dist/esm/FocusGroup/FocusGroup.js +21 -6
- package/dist/esm/FocusGroup/FocusGroup.js.map +1 -1
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js +44 -14
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js.map +1 -1
- package/dist/esm/FocusGroup/useFocusGroupItem.js +17 -2
- package/dist/esm/FocusGroup/useFocusGroupItem.js.map +1 -1
- package/dist/esm/ScrollSync/ScrollSyncPane.js +21 -3
- package/dist/esm/ScrollSync/ScrollSyncPane.js.map +1 -1
- package/dist/esm/createDataInstance/createInstancePlugin.js +17 -1
- package/dist/esm/createDataInstance/createInstancePlugin.js.map +1 -1
- package/dist/esm/createDataInstance/createInstanceRef.js +43 -9
- package/dist/esm/createDataInstance/createInstanceRef.js.map +1 -1
- package/dist/esm/createDataInstance/utils.js +27 -20
- package/dist/esm/createDataInstance/utils.js.map +1 -1
- package/dist/esm/defer-render-hoc/index.js +17 -3
- package/dist/esm/defer-render-hoc/index.js.map +1 -1
- package/dist/esm/toolbar/ToolbarProvider.js +26 -9
- package/dist/esm/toolbar/ToolbarProvider.js.map +1 -1
- package/dist/esm/useDataGrid/initColumnDefinition.js +35 -27
- package/dist/esm/useDataGrid/initColumnDefinition.js.map +1 -1
- package/dist/esm/useDataGrid/useDataGrid.js +55 -31
- package/dist/esm/useDataGrid/useDataGrid.js.map +1 -1
- package/dist/esm/useDataList/useDataList.js +49 -14
- package/dist/esm/useDataList/useDataList.js.map +1 -1
- package/dist/esm/utils.js +20 -2
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/virtualization/AutoHeightList.js +53 -14
- package/dist/esm/virtualization/AutoHeightList.js.map +1 -1
- package/dist/esm/virtualization/FluidHeightList.js +40 -7
- package/dist/esm/virtualization/FluidHeightList.js.map +1 -1
- package/package.json +4 -3
- package/dist/types/Animations/BaseAnimation.d.ts +0 -13
- package/dist/types/Animations/Grow.d.ts +0 -12
- package/dist/types/Animations/GrowRight.d.ts +0 -12
- package/dist/types/Animations/GrowVertical.d.ts +0 -1
- package/dist/types/CheckableGroup.d.ts +0 -21
- package/dist/types/DeferRenderAfterComputation.d.ts +0 -7
- package/dist/types/FocusGroup/FocusGrid.d.ts +0 -12
- package/dist/types/FocusGroup/FocusGroup.d.ts +0 -38
- package/dist/types/FocusGroup/FocusGroupContext.d.ts +0 -4
- package/dist/types/FocusGroup/FocusGroupManager.d.ts +0 -26
- package/dist/types/FocusGroup/focusGroupManagerHoc.d.ts +0 -9
- package/dist/types/FocusGroup/index.d.ts +0 -6
- package/dist/types/FocusGroup/useFocusGroupItem.d.ts +0 -4
- package/dist/types/FocusGroup/utils/getNextCellPosition.d.ts +0 -14
- package/dist/types/GroupContext/Group.d.ts +0 -15
- package/dist/types/GroupContext/GroupContext.d.ts +0 -2
- package/dist/types/GroupContext/GroupItem.d.ts +0 -6
- package/dist/types/GroupContext/index.d.ts +0 -3
- package/dist/types/ScrollSync/ScrollSync.d.ts +0 -23
- package/dist/types/ScrollSync/ScrollSyncPane.d.ts +0 -3
- package/dist/types/ScrollSync/ScrollSyncProvider.d.ts +0 -12
- package/dist/types/ScrollSync/index.d.ts +0 -2
- package/dist/types/ScrollSync/useScrollSync.d.ts +0 -7
- package/dist/types/constants.d.ts +0 -30
- package/dist/types/createDataInstance/createInstancePlugin.d.ts +0 -2
- package/dist/types/createDataInstance/createInstanceRef.d.ts +0 -14
- package/dist/types/createDataInstance/tests/createInstanceRef.test.d.ts +0 -0
- package/dist/types/createDataInstance/utils.d.ts +0 -9
- package/dist/types/dimsum.config.d.ts +0 -5
- package/dist/types/index.d.ts +0 -2
- package/dist/types/prop-types.d.ts +0 -41
- package/dist/types/react-spring/index.d.ts +0 -1
- package/dist/types/react-spring/renderprops.d.ts +0 -1
- package/dist/types/toolbar/ToolbarProvider.d.ts +0 -5
- package/dist/types/useDataGrid/VolatileRowsListener.d.ts +0 -7
- package/dist/types/useDataGrid/index.d.ts +0 -1
- package/dist/types/useDataGrid/initColumnDefinition.d.ts +0 -6
- package/dist/types/useDataGrid/useDataGrid.d.ts +0 -9
- package/dist/types/useDataList/index.d.ts +0 -1
- package/dist/types/useDataList/recordIterator.d.ts +0 -1
- package/dist/types/useDataList/useDataList.d.ts +0 -14
- package/dist/types/utils.d.ts +0 -22
- package/dist/types/virtualization/AutoHeightList.d.ts +0 -2
- package/dist/types/virtualization/FluidHeightList.d.ts +0 -2
- package/dist/types/virtualization/index.d.ts +0 -9
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
8
37
|
var __export = (target, all) => {
|
|
9
38
|
for (var name in all)
|
|
10
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,25 +62,33 @@ var React = __toESM(require("react"));
|
|
|
33
62
|
var import_react = __toESM(require("react"));
|
|
34
63
|
var import_react_window = require("react-window");
|
|
35
64
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
36
|
-
const AutoHeightList = (0, import_react.forwardRef)(({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
65
|
+
const AutoHeightList = (0, import_react.forwardRef)((_a, ref) => {
|
|
66
|
+
var _b = _a, {
|
|
67
|
+
itemCount,
|
|
68
|
+
className,
|
|
69
|
+
innerRef,
|
|
70
|
+
itemData,
|
|
71
|
+
itemKey,
|
|
72
|
+
itemSize,
|
|
73
|
+
outerRef,
|
|
74
|
+
component: ListComponent = import_react_window.FixedSizeList
|
|
75
|
+
} = _b, otherProps = __objRest(_b, [
|
|
76
|
+
"itemCount",
|
|
77
|
+
"className",
|
|
78
|
+
"innerRef",
|
|
79
|
+
"itemData",
|
|
80
|
+
"itemKey",
|
|
81
|
+
"itemSize",
|
|
82
|
+
"outerRef",
|
|
83
|
+
"component"
|
|
84
|
+
]);
|
|
47
85
|
const listRef = (0, import_react.useRef)();
|
|
48
86
|
const outerListRef = (0, import_react.useRef)();
|
|
49
87
|
(0, import_ds_utilities.useWindowScrollerList)({
|
|
50
88
|
listInstance: listRef,
|
|
51
89
|
outerListRef
|
|
52
90
|
});
|
|
53
|
-
return /* @__PURE__ */ import_react.default.createElement(ListComponent, {
|
|
54
|
-
...otherProps,
|
|
91
|
+
return /* @__PURE__ */ import_react.default.createElement(ListComponent, __spreadProps(__spreadValues({}, otherProps), {
|
|
55
92
|
ref: (0, import_ds_utilities.mergeRefs)(ref, listRef),
|
|
56
93
|
className: (0, import_ds_utilities.cx)(className, "window-scroller-override"),
|
|
57
94
|
height: window.innerHeight,
|
|
@@ -63,7 +100,7 @@ const AutoHeightList = (0, import_react.forwardRef)(({
|
|
|
63
100
|
outerRef: (0, import_ds_utilities.mergeRefs)(outerListRef, outerRef),
|
|
64
101
|
overscanCount: 10,
|
|
65
102
|
useIsScrolling: true
|
|
66
|
-
});
|
|
103
|
+
}));
|
|
67
104
|
});
|
|
68
105
|
module.exports = __toCommonJS(AutoHeightList_exports);
|
|
69
106
|
//# sourceMappingURL=AutoHeightList.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/virtualization/AutoHeightList.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { forwardRef, useRef } from 'react';\nimport { FixedSizeList as List } from 'react-window';\nimport { cx, useWindowScrollerList, mergeRefs } from '@elliemae/ds-utilities';\n\nexport const AutoHeightList = forwardRef(\n (\n {\n itemCount,\n className,\n innerRef,\n itemData,\n itemKey,\n itemSize,\n outerRef,\n component: ListComponent = List,\n ...otherProps\n },\n ref,\n ) => {\n const listRef = useRef();\n const outerListRef = useRef();\n\n useWindowScrollerList({\n listInstance: listRef,\n outerListRef,\n });\n\n return (\n <ListComponent\n {...otherProps}\n ref={mergeRefs(ref, listRef)}\n className={cx(className, 'window-scroller-override')}\n height={window.innerHeight}\n innerRef={innerRef}\n itemCount={itemCount}\n itemData={itemData}\n itemKey={itemKey}\n itemSize={itemSize}\n outerRef={mergeRefs(outerListRef, outerRef)}\n overscanCount={10}\n useIsScrolling\n />\n );\n },\n);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0C;AAC1C,0BAAsC;AACtC,0BAAqD;AAE9C,MAAM,iBAAiB,6BAC5B,CACE,IAWA,QACG;AAZH,eACE;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,gBAAgB;AAAA,MAR7B,IASK,uBATL,IASK;AAAA,IARH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKF,QAAM,UAAU;AAChB,QAAM,eAAe;AAErB,iDAAsB;AAAA,IACpB,cAAc;AAAA,IACd;AAAA;AAGF,SACE,mDAAC,eAAD,iCACM,aADN;AAAA,IAEE,KAAK,mCAAU,KAAK;AAAA,IACpB,WAAW,4BAAG,WAAW;AAAA,IACzB,QAAQ,OAAO;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,mCAAU,cAAc;AAAA,IAClC,eAAe;AAAA,IACf,gBAAc;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
8
37
|
var __export = (target, all) => {
|
|
9
38
|
for (var name in all)
|
|
10
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -32,12 +61,14 @@ __export(FluidHeightList_exports, {
|
|
|
32
61
|
var React = __toESM(require("react"));
|
|
33
62
|
var import_react = __toESM(require("react"));
|
|
34
63
|
var import_react_virtualized_auto_sizer = __toESM(require("react-virtualized-auto-sizer"));
|
|
35
|
-
const FluidHeightList = (0, import_react.forwardRef)((
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
const FluidHeightList = (0, import_react.forwardRef)((_a, ref) => {
|
|
65
|
+
var _b = _a, { component: Component } = _b, props = __objRest(_b, ["component"]);
|
|
66
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_virtualized_auto_sizer.default, {
|
|
67
|
+
disableWidth: true
|
|
68
|
+
}, ({ height: fluidHeight }) => /* @__PURE__ */ import_react.default.createElement(Component, __spreadProps(__spreadValues({}, props), {
|
|
69
|
+
ref,
|
|
70
|
+
height: fluidHeight - 32
|
|
71
|
+
})));
|
|
72
|
+
});
|
|
42
73
|
module.exports = __toCommonJS(FluidHeightList_exports);
|
|
43
74
|
//# sourceMappingURL=FluidHeightList.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/virtualization/FluidHeightList.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { forwardRef } from 'react';\nimport AutoSizer from 'react-virtualized-auto-sizer';\n\nexport const FluidHeightList = forwardRef(\n ({ component: Component, ...props }, ref) => (\n <AutoSizer disableWidth>\n {({ height: fluidHeight }) => (\n <Component\n {...props}\n ref={ref}\n height={fluidHeight - 32} // taking in count the margins of the list\n />\n )}\n </AutoSizer>\n ),\n);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,0CAAsB;AAEf,MAAM,kBAAkB,6BAC7B,CAAC,IAAoC,QAAK;AAAzC,eAAE,aAAW,cAAb,IAA2B,kBAA3B,IAA2B,CAAzB;AACD,4DAAC,6CAAD;AAAA,IAAW,cAAY;AAAA,KACpB,CAAC,EAAE,QAAQ,kBACV,mDAAC,WAAD,iCACM,QADN;AAAA,IAEE;AAAA,IACA,QAAQ,cAAc;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
import * as React from "react";
|
|
2
21
|
import React2, { cloneElement } from "react";
|
|
3
22
|
import PropTypes from "prop-types";
|
|
@@ -19,11 +38,10 @@ function useCheckableGroup({
|
|
|
19
38
|
return React2.Children.map(children, (child) => {
|
|
20
39
|
const { props } = child;
|
|
21
40
|
const checked = Array.isArray(active) ? active.indexOf(props.name) !== -1 : active === props.name;
|
|
22
|
-
return cloneElement(child, {
|
|
23
|
-
...props,
|
|
41
|
+
return cloneElement(child, __spreadProps(__spreadValues({}, props), {
|
|
24
42
|
checked,
|
|
25
43
|
onClick: runAll(handleCheck, props.onClick)
|
|
26
|
-
});
|
|
44
|
+
}));
|
|
27
45
|
});
|
|
28
46
|
}
|
|
29
47
|
function CheckableGroup({
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/CheckableGroup.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { cloneElement } from 'react';\nimport PropTypes from 'prop-types';\nimport { addOrRemove, runAll, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nexport function useCheckableGroup({\n children,\n active: activeProp,\n multi,\n onCheck = () => null,\n}) {\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)\n ? active.indexOf(props.name) !== -1\n : active === props.name;\n\n return cloneElement(child, {\n ...props,\n checked,\n onClick: runAll(handleCheck, props.onClick),\n });\n });\n}\n\nfunction 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 { CheckableGroup };\nexport default CheckableGroup;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEO,2BAA2B;AAAA,EAChC;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,UAAU,MAAM;AAAA,GACf;AACD,QAAM,CAAC,QAAQ,aAAa,yBAAyB;AAErD,QAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,WAAW,SAAS;AACnD,cAAU,gBAAc;AACtB,YAAM,aAAa,QAAQ,YAAY,YAAY,SAAS;AAC5D,cAAQ,YAAY;AACpB,aAAO;AAAA;AAAA;AAIX,SAAO,OAAM,SAAS,IAAI,UAAU,WAAS;AAC3C,UAAM,EAAE,UAAU;AAClB,UAAM,UAAU,MAAM,QAAQ,UAC1B,OAAO,QAAQ,MAAM,UAAU,KAC/B,WAAW,MAAM;AAErB,WAAO,aAAa,OAAO
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAEO,2BAA2B;AAAA,EAChC;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,UAAU,MAAM;AAAA,GACf;AACD,QAAM,CAAC,QAAQ,aAAa,yBAAyB;AAErD,QAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,WAAW,SAAS;AACnD,cAAU,gBAAc;AACtB,YAAM,aAAa,QAAQ,YAAY,YAAY,SAAS;AAC5D,cAAQ,YAAY;AACpB,aAAO;AAAA;AAAA;AAIX,SAAO,OAAM,SAAS,IAAI,UAAU,WAAS;AAC3C,UAAM,EAAE,UAAU;AAClB,UAAM,UAAU,MAAM,QAAQ,UAC1B,OAAO,QAAQ,MAAM,UAAU,KAC/B,WAAW,MAAM;AAErB,WAAO,aAAa,OAAO,iCACtB,QADsB;AAAA,MAEzB;AAAA,MACA,SAAS,OAAO,aAAa,MAAM;AAAA;AAAA;AAAA;AAKzC,wBAAwB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,GACC;AACD,SAAO,kBAAkB,EAAE,QAAQ,OAAO;AAAA;AAG5C,eAAe,YAAY;AAAA,EAEzB,QAAQ,UAAU,QAAQ,UAAU;AAAA,EAEpC,OAAO,UAAU;AAAA,EAEjB,SAAS,UAAU;AAAA;AAIrB,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import * as React from "react";
|
|
2
18
|
import React2, { createContext, useEffect, useMemo, useRef } from "react";
|
|
3
19
|
import { isFunction, runAll, get, useHotkeys, mergeRefs } from "@elliemae/ds-utilities";
|
|
@@ -89,7 +105,7 @@ const FocusGridProvider = ({
|
|
|
89
105
|
}
|
|
90
106
|
};
|
|
91
107
|
registerHotKeysHooks(hotKeys, { focusedCell, focusedRow });
|
|
92
|
-
const defaultKeyBindings = {
|
|
108
|
+
const defaultKeyBindings = __spreadValues({
|
|
93
109
|
ArrowUp: runAll(preventDefault, () => focusNextCell(-1, 0)),
|
|
94
110
|
ArrowRight: runAll(preventDefault, () => focusNextCell(0, 1)),
|
|
95
111
|
ArrowDown: runAll(preventDefault, () => focusNextCell(1, 0)),
|
|
@@ -107,14 +123,13 @@ const FocusGridProvider = ({
|
|
|
107
123
|
rowIndex = grid.current.length - 1;
|
|
108
124
|
}
|
|
109
125
|
focusNextCell(0, 0, { rowIndex, cellIndex: grid.current[0].length - 1 });
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
};
|
|
126
|
+
})
|
|
127
|
+
}, keyBindings);
|
|
113
128
|
const nextKeyBindings = isFunction(keyBindings) ? keyBindings({
|
|
114
129
|
defaultBindings: defaultKeyBindings,
|
|
115
130
|
rowIndex: focusedRow.current,
|
|
116
131
|
cellIndex: focusedCell.current
|
|
117
|
-
}) : {
|
|
132
|
+
}) : __spreadValues(__spreadValues({}, defaultKeyBindings), keyBindings);
|
|
118
133
|
const onKeyDown = (e) => {
|
|
119
134
|
if (e.target.tagName.toLowerCase() === "input")
|
|
120
135
|
return;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FocusGroup/FocusGrid.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,mBAAmB;AACzB,MAAM,EAAE,aAAa;AAErB,MAAM,iBAAiB,OAAK,EAAE;AAE9B,8BAA8B,SAAS,EAAE,YAAY,eAAe;AAClE,SAAO,KAAK,SAAS,QAAQ,SAAO;AAClC,UAAM,EAAE,SAAS,YAAY,QAAQ;AACrC,eAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,OAAK;AACZ,UAAE;AACF,gBAAQ;AAAA,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AAiB,WAAW,WAAW;AAAA;AAGnD,QAAM,aAAa,eAAa;AAC9B,cAAU,oBAAoB,WAAW,WAAW;AAAA;AAGtD,YAAU,MAAM;AACd,aAAS,aAAa;AACtB,WAAO,MAAM;AACX,iBAAW,aAAa;AAAA;AAAA,KAEzB;AAEH,QAAM,gBAAgB,QACpB,MAAO;AAAA,IACL;AAAA,MAEF;AAGF,SAAO,qCAAC,UAAD;AAAA,IAAU,OAAO;AAAA,KAAgB;AAAA;AAI1C,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import * as React from "react";
|
|
2
18
|
import { isFunction, get } from "@elliemae/ds-utilities";
|
|
3
19
|
import hotkeys from "hotkeys-js";
|
|
@@ -20,7 +36,7 @@ const registerHotkeys = (hotKeys = {}, params, getContainer = () => document) =>
|
|
|
20
36
|
e.preventDefault();
|
|
21
37
|
handler(handlerParams);
|
|
22
38
|
};
|
|
23
|
-
hotkeys(hotkey, { element: getContainer(),
|
|
39
|
+
hotkeys(hotkey, __spreadValues({ element: getContainer() }, options), parameterizedHandler);
|
|
24
40
|
});
|
|
25
41
|
};
|
|
26
42
|
const unregisterHotKeys = (hotKeys = {}) => {
|
|
@@ -32,9 +48,9 @@ const noop = () => null;
|
|
|
32
48
|
class FocusGroup {
|
|
33
49
|
constructor(options = {}) {
|
|
34
50
|
this.items = [];
|
|
35
|
-
this.options = {
|
|
51
|
+
this.options = __spreadValues(__spreadValues({}, defaultOptions), options);
|
|
36
52
|
const { orientation } = this.options;
|
|
37
|
-
this.keyBindings = {
|
|
53
|
+
this.keyBindings = __spreadValues({
|
|
38
54
|
ArrowUp: orientation !== "horizontal" && "previous",
|
|
39
55
|
ArrowRight: orientation !== "vertical" && "next",
|
|
40
56
|
ArrowDown: orientation !== "horizontal" && "next",
|
|
@@ -43,9 +59,8 @@ class FocusGroup {
|
|
|
43
59
|
End: "last",
|
|
44
60
|
PageUp: "first",
|
|
45
61
|
PageDown: "last",
|
|
46
|
-
Escape: "exit"
|
|
47
|
-
|
|
48
|
-
};
|
|
62
|
+
Escape: "exit"
|
|
63
|
+
}, options.keyBindings);
|
|
49
64
|
this.currentFocusedItem = null;
|
|
50
65
|
this.currIndex = null;
|
|
51
66
|
this.mapActions = {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FocusGroup/FocusGroup.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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 = (\n hotKeys = {},\n params,\n getContainer = () => document,\n) => {\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 (\n !allowDocumentHandler &&\n handlerParams.item !== document.activeElement\n )\n return;\n e.preventDefault();\n handler(handlerParams);\n };\n hotkeys(\n hotkey,\n { element: getContainer(), ...options },\n parameterizedHandler,\n );\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 }\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])\n ? this.keyBindings[e.key]\n : [this.keyBindings[e.key]];\n return actions.map((action) =>\n typeof action === 'string'\n ? safeCallAction(e, this.mapActions[action])\n : safeCallAction(e, action),\n );\n }\n\n register(node, props = {}) {\n const afterIndex = this.items.findIndex(\n (item) =>\n 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;"],
|
|
5
|
-
"mappings": "AAAA;ACGA;AACA;AAEA,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA;AAGf,MAAM,iBAAiB,CAAC,GAAG,QAAQ,SAAS;AAC1C,MAAI,WAAW,MAAM;AACnB,MAAE;AACF,QAAI,GAAG;AAAA;AAAA;AAIX,MAAM,kBAAkB,CACtB,UAAU,IACV,QACA,eAAe,MAAM,aAClB;AACH,SAAO,KAAK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AM;AAAA;AAAA,EAGlC,gBAAgB;AACd,WAAO,KAAK,sBAAsB;AAAA;AAAA,EAGpC,eAAe;AACb,WAAO,CAAC,CAAC,KAAK,MAAM,UAAU,KAAK,MAAM;AAAA;AAAA,EAG3C,cAAc;AACZ,WAAO,CAAC,CAAC,KAAK,MAAM,UAAU,KAAK,MAAM,KAAK,MAAM,SAAS;AAAA;AAAA;AAKjE,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,21 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
1
29
|
import * as React from "react";
|
|
2
30
|
import React2 from "react";
|
|
3
31
|
import { FocusGroupProvider } from "./FocusGroupManager";
|
|
4
32
|
function FocusGroupHoc(WrappedComponent, options = {}) {
|
|
5
|
-
return ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
33
|
+
return (_a) => {
|
|
34
|
+
var _b = _a, {
|
|
35
|
+
onExitFocusGroup,
|
|
36
|
+
onFocusPrevGroup,
|
|
37
|
+
focusKeyBindings
|
|
38
|
+
} = _b, props = __objRest(_b, [
|
|
39
|
+
"onExitFocusGroup",
|
|
40
|
+
"onFocusPrevGroup",
|
|
41
|
+
"focusKeyBindings"
|
|
42
|
+
]);
|
|
43
|
+
return /* @__PURE__ */ React2.createElement(FocusGroupProvider, __spreadValues({
|
|
44
|
+
keyBindings: focusKeyBindings,
|
|
45
|
+
onExitFocusGroup,
|
|
46
|
+
onFocusPrevGroup
|
|
47
|
+
}, options), /* @__PURE__ */ React2.createElement(WrappedComponent, __spreadValues(__spreadValues({}, props), options)));
|
|
48
|
+
};
|
|
19
49
|
}
|
|
20
50
|
var focusGroupManagerHoc_default = FocusGroupHoc;
|
|
21
51
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FocusGroup/focusGroupManagerHoc.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AAEA,uBAAuB,kBAAkB,UAAU,IAAI;AACrD,SAAO,CAAC;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAEA,uBAAuB,kBAAkB,UAAU,IAAI;AACrD,SAAO,CAAC,OAKL;AALK,iBACN;AAAA;AAAA,MACA;AAAA,MACA;AAAA,QAHM,IAIH,kBAJG,IAIH;AAAA,MAHH;AAAA,MACA;AAAA,MACA;AAAA;AAGA,gDAAC,oBAAD;AAAA,MACE,aAAa;AAAA,MACb;AAAA,MACA;AAAA,OACI,UAEJ,qCAAC,kBAAD,kCAAsB,QAAW;AAAA;AAAA;AAMvC,IAAO,+BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
+
target[prop] = source[prop];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
1
16
|
import * as React from "react";
|
|
2
17
|
import { useContext, useEffect } from "react";
|
|
3
18
|
import { FocusGroupContext } from "./FocusGroupContext";
|
|
4
19
|
function useFocusGroupItem(ref = {}, props) {
|
|
5
|
-
const { register, unregister,
|
|
20
|
+
const _a = useContext(FocusGroupContext) || {}, { register, unregister } = _a, otherActions = __objRest(_a, ["register", "unregister"]);
|
|
6
21
|
useEffect(() => {
|
|
7
22
|
if (ref.current && register)
|
|
8
23
|
register(ref.current, props);
|
|
@@ -16,7 +31,7 @@ function useFocusGroupItem(ref = {}, props) {
|
|
|
16
31
|
return otherActions;
|
|
17
32
|
}
|
|
18
33
|
const useFocusGroupWithState = (ref = {}, props) => {
|
|
19
|
-
const { register, unregister,
|
|
34
|
+
const _a = useContext(FocusGroupContext) || {}, { register, unregister } = _a, otherActions = __objRest(_a, ["register", "unregister"]);
|
|
20
35
|
useEffect(() => {
|
|
21
36
|
if (ref && register)
|
|
22
37
|
register(ref, props);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FocusGroup/useFocusGroupItem.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA,2BAA2B,MAAM,IAAI,OAAO;AAC1C,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;ACAA;AACA;AAEA,2BAA2B,MAAM,IAAI,OAAO;AAC1C,QACE,gBAAW,sBAAsB,IAD3B,YAAU,eAChB,IAD+B,yBAC/B,IAD+B,CAAzB,YAAU;AAGlB,YAAU,MAAM;AACd,QAAI,IAAI,WAAW;AAAU,eAAS,IAAI,SAAS;AACnD,WAAO,MAAM;AACX,UAAI,IAAI,WAAW;AAAY,mBAAW,IAAI;AAAA;AAAA;AAKlD,MAAI,CAAC;AAAU,WAAO;AACtB,SAAO;AAAA;AAGF,MAAM,yBAAyB,CAAC,MAAM,IAAI,UAAU;AACzD,QACE,gBAAW,sBAAsB,IAD3B,YAAU,eAChB,IAD+B,yBAC/B,IAD+B,CAAzB,YAAU;AAGlB,YAAU,MAAM;AACd,QAAI,OAAO;AAAU,eAAS,KAAK;AACnC,WAAO,MAAM;AACX,UAAI,OAAO;AAAY,mBAAW;AAAA;AAAA,KAEnC,CAAC;AAGJ,MAAI,CAAC;AAAU,WAAO;AACtB,SAAO;AAAA;AAIT,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
import * as React from "react";
|
|
2
21
|
import React2, { Component } from "react";
|
|
3
22
|
import { ScrollSyncContext } from "./ScrollSync";
|
|
@@ -32,10 +51,9 @@ ScrollSyncPane.defaultProps = {
|
|
|
32
51
|
group: "default",
|
|
33
52
|
enabled: true
|
|
34
53
|
};
|
|
35
|
-
const ScrollSyncPaneHOC = (props) => /* @__PURE__ */ React2.createElement(ScrollSyncContext.Consumer, null, (context) => /* @__PURE__ */ React2.createElement(ScrollSyncPane, {
|
|
36
|
-
...props,
|
|
54
|
+
const ScrollSyncPaneHOC = (props) => /* @__PURE__ */ React2.createElement(ScrollSyncContext.Consumer, null, (context) => /* @__PURE__ */ React2.createElement(ScrollSyncPane, __spreadProps(__spreadValues({}, props), {
|
|
37
55
|
syncContext: context
|
|
38
|
-
}));
|
|
56
|
+
})));
|
|
39
57
|
var ScrollSyncPane_default = ScrollSyncPaneHOC;
|
|
40
58
|
export {
|
|
41
59
|
ScrollSyncPaneHOC,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/ScrollSync/ScrollSyncPane.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AAYA,6BAA6B,UAAU;AAAA,EAAvC,cAdA;AAcA;AAaE,mBAAU,YAAU,GAAG,OAAO;AAAA;AAAA,EAP9B,uBAAuB;AACrB,UAAM,EAAE,SAAS,OAAO,gBAAgB,KAAK;AAC7C,UAAM,EAAE,mBAAmB;AAE3B,QAAI;AAAS,qBAAe,KAAK,MAAM,KAAK,QAAQ;AAAA;AAAA,EAKtD,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;AAEF,cAAI,iBAAiB;AACnB,yBAAa,iBAAiB,KAAK,QAAQ;AAAA;AAAA;AAG/C,eAAO,aAAa,MAAM,KAAK,QAAQ;AAAA;AAAA;AAAA;AAAA;AA5BtC,AADT,eACS,eAAe;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AAAA;AAgCN,MAAM,oBAAoB,WAC/B,qCAAC,kBAAkB,UAAnB,MACG,aAAW,qCAAC,gBAAD
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAYA,6BAA6B,UAAU;AAAA,EAAvC,cAdA;AAcA;AAaE,mBAAU,YAAU,GAAG,OAAO;AAAA;AAAA,EAP9B,uBAAuB;AACrB,UAAM,EAAE,SAAS,OAAO,gBAAgB,KAAK;AAC7C,UAAM,EAAE,mBAAmB;AAE3B,QAAI;AAAS,qBAAe,KAAK,MAAM,KAAK,QAAQ;AAAA;AAAA,EAKtD,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;AAEF,cAAI,iBAAiB;AACnB,yBAAa,iBAAiB,KAAK,QAAQ;AAAA;AAAA;AAG/C,eAAO,aAAa,MAAM,KAAK,QAAQ;AAAA;AAAA;AAAA;AAAA;AA5BtC,AADT,eACS,eAAe;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AAAA;AAgCN,MAAM,oBAAoB,WAC/B,qCAAC,kBAAkB,UAAnB,MACG,aAAW,qCAAC,gBAAD,iCAAoB,QAApB;AAAA,EAA2B,aAAa;AAAA;AAIxD,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import * as React from "react";
|
|
2
18
|
const getDecoratorsFromHooks = (hooks, decorators) => {
|
|
3
|
-
const nextDecorators = {
|
|
19
|
+
const nextDecorators = __spreadValues({}, decorators);
|
|
4
20
|
Object.keys(hooks).forEach((decorator) => {
|
|
5
21
|
if (Array.isArray(decorators[decorator])) {
|
|
6
22
|
nextDecorators[decorator] = [...decorators[decorator], hooks[decorator]];
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/createDataInstance/createInstancePlugin.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA;ACAA,MAAM,yBAAyB,CAAC,OAAO,eAAe;AACpD,QAAM,iBAAiB,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA,MAAM,yBAAyB,CAAC,OAAO,eAAe;AACpD,QAAM,iBAAiB,mBAAK;AAE5B,SAAO,KAAK,OAAO,QAAQ,CAAC,cAAc;AACxC,QAAI,MAAM,QAAQ,WAAW,aAAa;AACxC,qBAAe,aAAa,CAAC,GAAG,WAAW,YAAY,MAAM;AAAA,WACxD;AACL,qBAAe,aAAa,MAAM;AAAA;AAAA;AAItC,SAAO;AAAA;AAGF,MAAM,uBAAuB,CAAC,MAAM,UAAU,CAAC,eAAe,uBAAuB,OAAO;AAEnG,IAAO,+BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|