@dreamcommerce/aurora 2.9.0-12 → 2.9.0-13
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/build/cjs/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js +20 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js +16 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js +101 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js +12 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js +20 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_hook.js +21 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_hook.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/index.js +18 -0
- package/build/cjs/packages/aurora/src/components/scroll_sync/index.js.map +1 -0
- package/build/cjs/packages/aurora/src/index.js +4 -0
- package/build/cjs/packages/aurora/src/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.d.ts +7 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js +12 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.d.ts +12 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js +11 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.d.ts +21 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js +92 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.d.ts +4 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js +8 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.d.ts +2 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js +16 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_hook.d.ts +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_hook.js +13 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_hook.js.map +1 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/index.d.ts +3 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/index.js +10 -0
- package/build/esm/packages/aurora/src/components/scroll_sync/index.js.map +1 -0
- package/build/esm/packages/aurora/src/index.d.ts +3 -1
- package/build/esm/packages/aurora/src/index.js +2 -0
- package/build/esm/packages/aurora/src/index.js.map +1 -1
- package/package.json +1 -1
package/build/cjs/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var scroll_sync_container_hook = require('../hooks/scroll_sync_container_hook.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
const ScrollSyncContainer = ({ children, id }) => {
|
|
13
|
+
const elementRef = React__default['default'].useRef(null);
|
|
14
|
+
scroll_sync_container_hook.useScrollSyncContainer(id, elementRef);
|
|
15
|
+
return React__default['default'].createElement(React__default['default'].Fragment, null, children(elementRef));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.ScrollSyncContainer = ScrollSyncContainer;
|
|
19
|
+
exports.default = ScrollSyncContainer;
|
|
20
|
+
//# sourceMappingURL=scroll_sync_container.js.map
|
package/build/cjs/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const ScrollSyncContext = React.createContext({
|
|
8
|
+
registerContainer: () => { },
|
|
9
|
+
unregisterContainer: () => { },
|
|
10
|
+
hasContainer: () => false
|
|
11
|
+
});
|
|
12
|
+
const ScrollSyncContextProvider = ScrollSyncContext.Provider;
|
|
13
|
+
|
|
14
|
+
exports.ScrollSyncContext = ScrollSyncContext;
|
|
15
|
+
exports.ScrollSyncContextProvider = ScrollSyncContextProvider;
|
|
16
|
+
//# sourceMappingURL=scroll_sync_context.js.map
|
package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var use_lazy_ref = require('../../../hooks/use_lazy_ref.js');
|
|
7
|
+
var scroll_sync_context = require('./scroll_sync_context.js');
|
|
8
|
+
var setup_scroll_syncer = require('./setup_scroll_syncer.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
|
|
14
|
+
const SCROLL_CONTAINER_ID_ATTRIBUTE = 'data-scroll-sync-id';
|
|
15
|
+
class ScrollSyncer {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.scrollContainers = [];
|
|
18
|
+
this.proportional = true;
|
|
19
|
+
this.vertical = true;
|
|
20
|
+
this.horizontal = true;
|
|
21
|
+
this.enabled = true;
|
|
22
|
+
this._addScrollEvent = (container) => {
|
|
23
|
+
container.$el.addEventListener('scroll', this._handleScrollEvent);
|
|
24
|
+
};
|
|
25
|
+
this._handleScrollEvent = (ev) => {
|
|
26
|
+
const $container = ev.target;
|
|
27
|
+
const containerId = $container.getAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE);
|
|
28
|
+
if (!containerId)
|
|
29
|
+
return;
|
|
30
|
+
const container = this._getContentContainer(containerId);
|
|
31
|
+
if (!container)
|
|
32
|
+
return;
|
|
33
|
+
window.requestAnimationFrame(() => this._syncScrollPositions(container));
|
|
34
|
+
};
|
|
35
|
+
this._removeScrollEvent = (container) => {
|
|
36
|
+
container.$el.removeEventListener('scroll', this._handleScrollEvent);
|
|
37
|
+
};
|
|
38
|
+
this._syncScrollPosition = (containerToSync, scrolledContainer) => {
|
|
39
|
+
const $scrolledContainerEl = scrolledContainer.$el;
|
|
40
|
+
const { scrollTop, scrollHeight, clientHeight, scrollLeft, scrollWidth, clientWidth } = $scrolledContainerEl;
|
|
41
|
+
const scrollTopOffset = scrollHeight - clientHeight;
|
|
42
|
+
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
43
|
+
const paneHeight = containerToSync.$el.scrollHeight - clientHeight;
|
|
44
|
+
const paneWidth = containerToSync.$el.scrollWidth - clientWidth;
|
|
45
|
+
if (this.vertical && scrollTopOffset > 0) {
|
|
46
|
+
containerToSync.$el.scrollTop = this.proportional ? (paneHeight * scrollTop) / scrollTopOffset : scrollTop;
|
|
47
|
+
}
|
|
48
|
+
if (this.horizontal && scrollLeftOffset > 0) {
|
|
49
|
+
containerToSync.$el.scrollLeft = this.proportional ? (paneWidth * scrollLeft) / scrollLeftOffset : scrollLeft;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this._syncScrollPositions = (scrolledContainer) => {
|
|
53
|
+
this.scrollContainers.forEach((containerToSync) => {
|
|
54
|
+
if (containerToSync.id !== scrolledContainer.id) {
|
|
55
|
+
this._syncScrollPosition(containerToSync, scrolledContainer);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
this._getContentContainer = (id) => {
|
|
60
|
+
return this.scrollContainers.find((currContainer) => currContainer.id === id);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
registerContainer(container) {
|
|
64
|
+
container.$el.setAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE, container.id);
|
|
65
|
+
this.scrollContainers.push(container);
|
|
66
|
+
this._addScrollEvent(container);
|
|
67
|
+
}
|
|
68
|
+
unregisterContainer(id) {
|
|
69
|
+
const container = this._getContentContainer(id);
|
|
70
|
+
if (!container)
|
|
71
|
+
return;
|
|
72
|
+
this.scrollContainers = this.scrollContainers.filter((currContainer) => container.id !== currContainer.id);
|
|
73
|
+
container.$el.removeAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE);
|
|
74
|
+
this._removeScrollEvent(container);
|
|
75
|
+
}
|
|
76
|
+
hasContainer(id) {
|
|
77
|
+
return !!this.scrollContainers.find((container) => container.id === id);
|
|
78
|
+
}
|
|
79
|
+
dispose() {
|
|
80
|
+
// unregister all events
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const ScrollSyncProvider = ({ children }) => {
|
|
84
|
+
const scrollSyncerSetup = use_lazy_ref.useLazyRef(() => setup_scroll_syncer.setupScrollSyncer());
|
|
85
|
+
const value = {
|
|
86
|
+
registerContainer(container) {
|
|
87
|
+
scrollSyncerSetup.current.scrollSyncerApi.registerContainer(container);
|
|
88
|
+
},
|
|
89
|
+
unregisterContainer(id) {
|
|
90
|
+
scrollSyncerSetup.current.scrollSyncerApi.unregisterContainer(id);
|
|
91
|
+
},
|
|
92
|
+
hasContainer(id) {
|
|
93
|
+
return scrollSyncerSetup.current.scrollSyncerApi.hasContainer(id);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return React__default['default'].createElement(scroll_sync_context.ScrollSyncContextProvider, { value: value }, children);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.ScrollSyncProvider = ScrollSyncProvider;
|
|
100
|
+
exports.ScrollSyncer = ScrollSyncer;
|
|
101
|
+
//# sourceMappingURL=scroll_sync_provider.js.map
|
package/build/cjs/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var scroll_sync_provider = require('./scroll_sync_provider.js');
|
|
6
|
+
|
|
7
|
+
const setupScrollSyncer = () => {
|
|
8
|
+
return { scrollSyncerApi: new scroll_sync_provider.ScrollSyncer() };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.setupScrollSyncer = setupScrollSyncer;
|
|
12
|
+
//# sourceMappingURL=setup_scroll_syncer.js.map
|
package/build/cjs/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var scroll_sync_hook = require('./scroll_sync_hook.js');
|
|
7
|
+
|
|
8
|
+
const useScrollSyncContainer = (id, ref) => {
|
|
9
|
+
const scrollSyncApi = scroll_sync_hook.useScrollSync();
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (!ref.current)
|
|
12
|
+
return;
|
|
13
|
+
if (!scrollSyncApi.hasContainer(id))
|
|
14
|
+
scrollSyncApi.registerContainer({ id, $el: ref.current });
|
|
15
|
+
return () => scrollSyncApi.unregisterContainer(id);
|
|
16
|
+
}, []);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.useScrollSyncContainer = useScrollSyncContainer;
|
|
20
|
+
//# sourceMappingURL=scroll_sync_container_hook.js.map
|
package/build/cjs/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var scroll_sync_context = require('../context/scroll_sync_context.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
const useScrollSync = () => {
|
|
13
|
+
const context = React__default['default'].useContext(scroll_sync_context.ScrollSyncContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('useScrollSync must be used within a ScrollSyncContextProvider');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useScrollSync = useScrollSync;
|
|
21
|
+
//# sourceMappingURL=scroll_sync_hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var scroll_sync_provider = require('./context/scroll_sync_provider.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
const ScrollSync = ({ children }) => {
|
|
13
|
+
return React__default['default'].createElement(scroll_sync_provider.ScrollSyncProvider, null, children);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.ScrollSync = ScrollSync;
|
|
17
|
+
exports.default = ScrollSync;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -83,6 +83,8 @@ var index$J = require('./components/with_loader/index.js');
|
|
|
83
83
|
var values_syncer = require('./components/controls/components/values_syncer.js');
|
|
84
84
|
var index$N = require('./components/tree/index.js');
|
|
85
85
|
var tree_node = require('./components/tree/components/tree_node.js');
|
|
86
|
+
var scroll_sync_container = require('./components/scroll_sync/components/scroll_sync_container.js');
|
|
87
|
+
var index$O = require('./components/scroll_sync/index.js');
|
|
86
88
|
|
|
87
89
|
|
|
88
90
|
|
|
@@ -169,4 +171,6 @@ exports.WithLoader = index$J['default'];
|
|
|
169
171
|
exports.ValuesSyncer = values_syncer['default'];
|
|
170
172
|
exports.Tree = index$N.Tree;
|
|
171
173
|
exports.TreeNode = tree_node.TreeNode;
|
|
174
|
+
exports.ScrollSyncContainer = scroll_sync_container.ScrollSyncContainer;
|
|
175
|
+
exports.ScrollSync = index$O.ScrollSync;
|
|
172
176
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type TScrollSyncContainerProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
children: (elementRef: React.Ref<HTMLElement>) => React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare const ScrollSyncContainer: ({ children, id }: TScrollSyncContainerProps) => JSX.Element;
|
|
7
|
+
export default ScrollSyncContainer;
|
package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useScrollSyncContainer } from '../hooks/scroll_sync_container_hook.js';
|
|
3
|
+
|
|
4
|
+
const ScrollSyncContainer = ({ children, id }) => {
|
|
5
|
+
const elementRef = React.useRef(null);
|
|
6
|
+
useScrollSyncContainer(id, elementRef);
|
|
7
|
+
return React.createElement(React.Fragment, null, children(elementRef));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default ScrollSyncContainer;
|
|
11
|
+
export { ScrollSyncContainer };
|
|
12
|
+
//# sourceMappingURL=scroll_sync_container.js.map
|
package/build/esm/packages/aurora/src/components/scroll_sync/components/scroll_sync_container.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type TScrollSyncContainer = {
|
|
3
|
+
id: string;
|
|
4
|
+
$el: HTMLElement;
|
|
5
|
+
};
|
|
6
|
+
export interface IScrollSyncContext {
|
|
7
|
+
registerContainer: (container: TScrollSyncContainer) => void;
|
|
8
|
+
unregisterContainer: (id: string) => void;
|
|
9
|
+
hasContainer: (id: string) => boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ScrollSyncContext: import("react").Context<IScrollSyncContext>;
|
|
12
|
+
export declare const ScrollSyncContextProvider: import("react").Provider<IScrollSyncContext>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const ScrollSyncContext = createContext({
|
|
4
|
+
registerContainer: () => { },
|
|
5
|
+
unregisterContainer: () => { },
|
|
6
|
+
hasContainer: () => false
|
|
7
|
+
});
|
|
8
|
+
const ScrollSyncContextProvider = ScrollSyncContext.Provider;
|
|
9
|
+
|
|
10
|
+
export { ScrollSyncContext, ScrollSyncContextProvider };
|
|
11
|
+
//# sourceMappingURL=scroll_sync_context.js.map
|
package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { TScrollSyncContainer } from "./scroll_sync_context";
|
|
3
|
+
export declare class ScrollSyncer {
|
|
4
|
+
private scrollContainers;
|
|
5
|
+
proportional: boolean;
|
|
6
|
+
vertical: boolean;
|
|
7
|
+
horizontal: boolean;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
constructor();
|
|
10
|
+
registerContainer(container: TScrollSyncContainer): void;
|
|
11
|
+
unregisterContainer(id: string): void;
|
|
12
|
+
private _addScrollEvent;
|
|
13
|
+
private _handleScrollEvent;
|
|
14
|
+
private _removeScrollEvent;
|
|
15
|
+
private _syncScrollPosition;
|
|
16
|
+
private _syncScrollPositions;
|
|
17
|
+
private _getContentContainer;
|
|
18
|
+
hasContainer(id: string): boolean;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const ScrollSyncProvider: ({ children }: PropsWithChildren<{}>) => JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLazyRef } from '../../../hooks/use_lazy_ref.js';
|
|
3
|
+
import { ScrollSyncContextProvider } from './scroll_sync_context.js';
|
|
4
|
+
import { setupScrollSyncer } from './setup_scroll_syncer.js';
|
|
5
|
+
|
|
6
|
+
const SCROLL_CONTAINER_ID_ATTRIBUTE = 'data-scroll-sync-id';
|
|
7
|
+
class ScrollSyncer {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.scrollContainers = [];
|
|
10
|
+
this.proportional = true;
|
|
11
|
+
this.vertical = true;
|
|
12
|
+
this.horizontal = true;
|
|
13
|
+
this.enabled = true;
|
|
14
|
+
this._addScrollEvent = (container) => {
|
|
15
|
+
container.$el.addEventListener('scroll', this._handleScrollEvent);
|
|
16
|
+
};
|
|
17
|
+
this._handleScrollEvent = (ev) => {
|
|
18
|
+
const $container = ev.target;
|
|
19
|
+
const containerId = $container.getAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE);
|
|
20
|
+
if (!containerId)
|
|
21
|
+
return;
|
|
22
|
+
const container = this._getContentContainer(containerId);
|
|
23
|
+
if (!container)
|
|
24
|
+
return;
|
|
25
|
+
window.requestAnimationFrame(() => this._syncScrollPositions(container));
|
|
26
|
+
};
|
|
27
|
+
this._removeScrollEvent = (container) => {
|
|
28
|
+
container.$el.removeEventListener('scroll', this._handleScrollEvent);
|
|
29
|
+
};
|
|
30
|
+
this._syncScrollPosition = (containerToSync, scrolledContainer) => {
|
|
31
|
+
const $scrolledContainerEl = scrolledContainer.$el;
|
|
32
|
+
const { scrollTop, scrollHeight, clientHeight, scrollLeft, scrollWidth, clientWidth } = $scrolledContainerEl;
|
|
33
|
+
const scrollTopOffset = scrollHeight - clientHeight;
|
|
34
|
+
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
35
|
+
const paneHeight = containerToSync.$el.scrollHeight - clientHeight;
|
|
36
|
+
const paneWidth = containerToSync.$el.scrollWidth - clientWidth;
|
|
37
|
+
if (this.vertical && scrollTopOffset > 0) {
|
|
38
|
+
containerToSync.$el.scrollTop = this.proportional ? (paneHeight * scrollTop) / scrollTopOffset : scrollTop;
|
|
39
|
+
}
|
|
40
|
+
if (this.horizontal && scrollLeftOffset > 0) {
|
|
41
|
+
containerToSync.$el.scrollLeft = this.proportional ? (paneWidth * scrollLeft) / scrollLeftOffset : scrollLeft;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this._syncScrollPositions = (scrolledContainer) => {
|
|
45
|
+
this.scrollContainers.forEach((containerToSync) => {
|
|
46
|
+
if (containerToSync.id !== scrolledContainer.id) {
|
|
47
|
+
this._syncScrollPosition(containerToSync, scrolledContainer);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
this._getContentContainer = (id) => {
|
|
52
|
+
return this.scrollContainers.find((currContainer) => currContainer.id === id);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
registerContainer(container) {
|
|
56
|
+
container.$el.setAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE, container.id);
|
|
57
|
+
this.scrollContainers.push(container);
|
|
58
|
+
this._addScrollEvent(container);
|
|
59
|
+
}
|
|
60
|
+
unregisterContainer(id) {
|
|
61
|
+
const container = this._getContentContainer(id);
|
|
62
|
+
if (!container)
|
|
63
|
+
return;
|
|
64
|
+
this.scrollContainers = this.scrollContainers.filter((currContainer) => container.id !== currContainer.id);
|
|
65
|
+
container.$el.removeAttribute(SCROLL_CONTAINER_ID_ATTRIBUTE);
|
|
66
|
+
this._removeScrollEvent(container);
|
|
67
|
+
}
|
|
68
|
+
hasContainer(id) {
|
|
69
|
+
return !!this.scrollContainers.find((container) => container.id === id);
|
|
70
|
+
}
|
|
71
|
+
dispose() {
|
|
72
|
+
// unregister all events
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const ScrollSyncProvider = ({ children }) => {
|
|
76
|
+
const scrollSyncerSetup = useLazyRef(() => setupScrollSyncer());
|
|
77
|
+
const value = {
|
|
78
|
+
registerContainer(container) {
|
|
79
|
+
scrollSyncerSetup.current.scrollSyncerApi.registerContainer(container);
|
|
80
|
+
},
|
|
81
|
+
unregisterContainer(id) {
|
|
82
|
+
scrollSyncerSetup.current.scrollSyncerApi.unregisterContainer(id);
|
|
83
|
+
},
|
|
84
|
+
hasContainer(id) {
|
|
85
|
+
return scrollSyncerSetup.current.scrollSyncerApi.hasContainer(id);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return React.createElement(ScrollSyncContextProvider, { value: value }, children);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export { ScrollSyncProvider, ScrollSyncer };
|
|
92
|
+
//# sourceMappingURL=scroll_sync_provider.js.map
|
package/build/esm/packages/aurora/src/components/scroll_sync/context/scroll_sync_provider.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/scroll_sync/context/setup_scroll_syncer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useScrollSync } from './scroll_sync_hook.js';
|
|
3
|
+
|
|
4
|
+
const useScrollSyncContainer = (id, ref) => {
|
|
5
|
+
const scrollSyncApi = useScrollSync();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!ref.current)
|
|
8
|
+
return;
|
|
9
|
+
if (!scrollSyncApi.hasContainer(id))
|
|
10
|
+
scrollSyncApi.registerContainer({ id, $el: ref.current });
|
|
11
|
+
return () => scrollSyncApi.unregisterContainer(id);
|
|
12
|
+
}, []);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useScrollSyncContainer };
|
|
16
|
+
//# sourceMappingURL=scroll_sync_container_hook.js.map
|
package/build/esm/packages/aurora/src/components/scroll_sync/hooks/scroll_sync_container_hook.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useScrollSync: () => import("../context/scroll_sync_context").IScrollSyncContext;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollSyncContext } from '../context/scroll_sync_context.js';
|
|
3
|
+
|
|
4
|
+
const useScrollSync = () => {
|
|
5
|
+
const context = React.useContext(ScrollSyncContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useScrollSync must be used within a ScrollSyncContextProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useScrollSync };
|
|
13
|
+
//# sourceMappingURL=scroll_sync_hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollSyncProvider } from './context/scroll_sync_provider.js';
|
|
3
|
+
|
|
4
|
+
const ScrollSync = ({ children }) => {
|
|
5
|
+
return React.createElement(ScrollSyncProvider, null, children);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default ScrollSync;
|
|
9
|
+
export { ScrollSync };
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -107,13 +107,15 @@ import XhrImagePicker from "./components/xhr_image_picker";
|
|
|
107
107
|
import ValuesSyncer from "./components/controls/components/values_syncer";
|
|
108
108
|
import { Tree } from "./components/tree";
|
|
109
109
|
import { TreeNode } from "./components/tree/components/tree_node";
|
|
110
|
+
import { ScrollSyncContainer } from "./components/scroll_sync/components/scroll_sync_container";
|
|
111
|
+
import { ScrollSync } from "./components/scroll_sync";
|
|
110
112
|
/**
|
|
111
113
|
* export hooks
|
|
112
114
|
*/
|
|
113
115
|
/**
|
|
114
116
|
* export components
|
|
115
117
|
*/
|
|
116
|
-
export { Accordion, Button, Tooltip, ButtonsGroup, Dropdown, Select, MultiSelect, Label, Stack, Control, ControlInput, ControlCheckbox, ControlCheckboxSwitch, ControlRadio, ControlSelect, ControlRange, ControlMultiSelect, ControlTextarea, Gallery, Datepicker, ColorPicker, ControlColorPicker, ControlDatepicker, ControlFilePicker, ControlXhrImagePicker, Heading, Typography, Modal, ModalProvider, AbsoluteModal, RelativeModal, TabsWrapper, Tabs, TabsItem, TabsItemList, TabsPanel, TabsPanelList, SearchList, SearchListInput, SearchListResults, Tag, TagsSelector, ControlTagsSelector, Table, DataTable, Grid, DropdownContext, ModalContext, IconCalendar, Spacing, IconArrow, IconTick, FilePicker, ImagePicker, ControlCellSelector, Hint, ControlRadioGroup, MessageBox, FlashMessenger, useFlashMessenger, Loader, WithLoader, useDropdownContext, FlashMessengerContext, FlashMessagesList, Link, IconTablet, IconMobile, IconLaptop, IconDesktop, IconWarning, useToggle, useSearchList, Slide, SlideWrapper, SlideHeader, SlideSubHeader, SlideContent, SlideFooter, XhrImagePicker, ValuesSyncer, Tree, TreeNode };
|
|
118
|
+
export { Accordion, Button, Tooltip, ButtonsGroup, Dropdown, Select, MultiSelect, Label, Stack, Control, ControlInput, ControlCheckbox, ControlCheckboxSwitch, ControlRadio, ControlSelect, ControlRange, ControlMultiSelect, ControlTextarea, Gallery, Datepicker, ColorPicker, ControlColorPicker, ControlDatepicker, ControlFilePicker, ControlXhrImagePicker, Heading, Typography, Modal, ModalProvider, AbsoluteModal, RelativeModal, TabsWrapper, Tabs, TabsItem, TabsItemList, TabsPanel, TabsPanelList, SearchList, SearchListInput, SearchListResults, Tag, TagsSelector, ControlTagsSelector, Table, DataTable, Grid, DropdownContext, ModalContext, IconCalendar, Spacing, IconArrow, IconTick, FilePicker, ImagePicker, ControlCellSelector, Hint, ControlRadioGroup, MessageBox, FlashMessenger, useFlashMessenger, Loader, WithLoader, useDropdownContext, FlashMessengerContext, FlashMessagesList, Link, IconTablet, IconMobile, IconLaptop, IconDesktop, IconWarning, useToggle, useSearchList, Slide, SlideWrapper, SlideHeader, SlideSubHeader, SlideContent, SlideFooter, XhrImagePicker, ValuesSyncer, Tree, TreeNode, ScrollSyncContainer, ScrollSync };
|
|
117
119
|
/**
|
|
118
120
|
* export types
|
|
119
121
|
*/
|
|
@@ -79,4 +79,6 @@ export { default as WithLoader } from './components/with_loader/index.js';
|
|
|
79
79
|
export { default as ValuesSyncer } from './components/controls/components/values_syncer.js';
|
|
80
80
|
export { Tree } from './components/tree/index.js';
|
|
81
81
|
export { TreeNode } from './components/tree/components/tree_node.js';
|
|
82
|
+
export { ScrollSyncContainer } from './components/scroll_sync/components/scroll_sync_container.js';
|
|
83
|
+
export { ScrollSync } from './components/scroll_sync/index.js';
|
|
82
84
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|