@adaptabletools/adaptable 23.0.5-canary.0 → 23.0.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.
Files changed (82) hide show
  1. package/index.css +0 -64
  2. package/package.json +1 -1
  3. package/src/AdaptableState/Aggregations/weightedAverage.d.ts +0 -1
  4. package/src/AdaptableState/Aggregations/weightedAverage.js +1 -1
  5. package/src/components/CodeBlock/index.d.ts +0 -1
  6. package/src/components/CodeBlock/index.js +1 -2
  7. package/src/env.js +2 -2
  8. package/tsconfig.esm.tsbuildinfo +1 -1
  9. package/src/AdaptableState/Common/NamedObject.d.ts +0 -10
  10. package/src/AdaptableState/Common/NamedObject.js +0 -1
  11. package/src/Utilities/ExpressionFunctions/groupingMap.d.ts +0 -35
  12. package/src/Utilities/ExpressionFunctions/groupingMap.js +0 -91
  13. package/src/Utilities/Interface/AdaptableToolPanelContext.d.ts +0 -4
  14. package/src/Utilities/Interface/AdaptableToolPanelContext.js +0 -1
  15. package/src/View/Components/Buttons/EntityListActionButtons.d.ts +0 -38
  16. package/src/View/Components/Buttons/EntityListActionButtons.js +0 -41
  17. package/src/View/Components/ColumnFilter/components/ColumnFilterMenu.d.ts +0 -12
  18. package/src/View/Components/ColumnFilter/components/ColumnFilterMenu.js +0 -66
  19. package/src/View/Components/EntityRowItem.d.ts +0 -7
  20. package/src/View/Components/EntityRowItem.js +0 -7
  21. package/src/View/Components/FilterForm/getDefaultColumnFilterPredicate.d.ts +0 -3
  22. package/src/View/Components/FilterForm/getDefaultColumnFilterPredicate.js +0 -5
  23. package/src/View/Components/ModuleProfile.d.ts +0 -8
  24. package/src/View/Components/ModuleProfile.js +0 -10
  25. package/src/View/Components/ModuleSummary/ModuleDetail.d.ts +0 -23
  26. package/src/View/Components/ModuleSummary/ModuleDetail.js +0 -15
  27. package/src/View/Components/ModuleSummary/ModuleHeader.d.ts +0 -15
  28. package/src/View/Components/ModuleSummary/ModuleHeader.js +0 -15
  29. package/src/View/Components/ModuleSummary/SummaryRowItem.d.ts +0 -7
  30. package/src/View/Components/ModuleSummary/SummaryRowItem.js +0 -12
  31. package/src/View/Components/SharedProps/ModuleSummaryProps.d.ts +0 -9
  32. package/src/View/Components/SharedProps/ModuleSummaryProps.js +0 -1
  33. package/src/View/Components/SharedProps/ToolPanelModuleViewPopupProps.d.ts +0 -13
  34. package/src/View/Components/SharedProps/ToolPanelModuleViewPopupProps.js +0 -1
  35. package/src/View/Components/SharedProps/ToolbarModuleViewPopupProps.d.ts +0 -14
  36. package/src/View/Components/SharedProps/ToolbarModuleViewPopupProps.js +0 -1
  37. package/src/View/Components/StyleVisualItem.d.ts +0 -9
  38. package/src/View/Components/StyleVisualItem.js +0 -40
  39. package/src/View/Components/WizardSummaryPage.d.ts +0 -7
  40. package/src/View/Components/WizardSummaryPage.js +0 -17
  41. package/src/components/Accordion.d.ts +0 -7
  42. package/src/components/Accordion.js +0 -33
  43. package/src/components/FlexWithFooter.d.ts +0 -9
  44. package/src/components/FlexWithFooter.js +0 -13
  45. package/src/components/NotifyResize/index.d.ts +0 -9
  46. package/src/components/NotifyResize/index.js +0 -35
  47. package/src/components/PopupWithFooter.d.ts +0 -14
  48. package/src/components/PopupWithFooter.js +0 -11
  49. package/src/components/SelectableList/index.d.ts +0 -15
  50. package/src/components/SelectableList/index.js +0 -88
  51. package/src/components/SizedContainer/index.d.ts +0 -17
  52. package/src/components/SizedContainer/index.js +0 -20
  53. package/src/components/Table/index.d.ts +0 -4
  54. package/src/components/Table/index.js +0 -6
  55. package/src/components/WizardPanel/index.d.ts +0 -9
  56. package/src/components/WizardPanel/index.js +0 -7
  57. package/src/components/icons/align-justify.d.ts +0 -3
  58. package/src/components/icons/align-justify.js +0 -3
  59. package/src/components/icons/column-info.d.ts +0 -3
  60. package/src/components/icons/column-info.js +0 -3
  61. package/src/components/icons/gradient-column.d.ts +0 -3
  62. package/src/components/icons/gradient-column.js +0 -3
  63. package/src/components/icons/invalid.d.ts +0 -3
  64. package/src/components/icons/invalid.js +0 -3
  65. package/src/components/icons/logout copy.d.ts +0 -3
  66. package/src/components/icons/logout copy.js +0 -3
  67. package/src/components/icons/smart-edit.d.ts +0 -3
  68. package/src/components/icons/smart-edit.js +0 -3
  69. package/src/components/icons/team-share.d.ts +0 -3
  70. package/src/components/icons/team-share.js +0 -3
  71. package/src/components/icons/unchecked.d.ts +0 -3
  72. package/src/components/icons/unchecked.js +0 -3
  73. package/src/components/icons/user-filter.d.ts +0 -3
  74. package/src/components/icons/user-filter.js +0 -3
  75. package/src/components/utils/useContainerScrollObserver/index.d.ts +0 -6
  76. package/src/components/utils/useContainerScrollObserver/index.js +0 -79
  77. package/src/components/utils/useGlobalEvent.d.ts +0 -1
  78. package/src/components/utils/useGlobalEvent.js +0 -7
  79. package/src/components/utils/useLatest.d.ts +0 -1
  80. package/src/components/utils/useLatest.js +0 -6
  81. package/src/components/utils/usePropState.d.ts +0 -2
  82. package/src/components/utils/usePropState.js +0 -8
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { FlexProps } from './Flex';
3
- import { HTMLProps } from 'react';
4
- interface TypeProps extends FlexProps {
5
- footer: React.ReactNode;
6
- footerProps?: FlexProps & HTMLProps<HTMLDivElement>;
7
- }
8
- declare const FlexWithFooter: (props: TypeProps & React.HTMLProps<HTMLDivElement>) => React.JSX.Element;
9
- export default FlexWithFooter;
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Flex } from './Flex';
3
- const defaultStyle = {
4
- height: '100%',
5
- maxHeight: '90vh',
6
- width: '70vw',
7
- maxWidth: 800,
8
- };
9
- const FlexWithFooter = (props) => {
10
- const { footer, footerProps, children, style, ...domProps } = props;
11
- return (_jsxs(Flex, { flexDirection: "column", ...domProps, style: { ...defaultStyle, ...style }, children: [_jsx(Flex, { flexDirection: "column", className: "twa:p-0 twa:flex-1", children: _jsx(Flex, { flexDirection: "column", className: "twa:flex-1", children: children }) }), footer ? (_jsx(Flex, { className: "twa:p-2 twa:bg-primary", ...footerProps, children: footer })) : null] }));
12
- };
13
- export default FlexWithFooter;
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- export interface NotifyResizeProps {
3
- onResize: (size: {
4
- width: number;
5
- height: number;
6
- }) => void;
7
- }
8
- declare const NotifyResize: (props: NotifyResizeProps) => React.JSX.Element;
9
- export default NotifyResize;
@@ -1,35 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { getResizeObserverObject } from '../ResizeObserver/getResizeObserverObject';
4
- const RO = getResizeObserverObject();
5
- const NotifyResize = (props) => {
6
- const domRef = React.useRef(null);
7
- React.useEffect(() => {
8
- if (!RO) {
9
- return;
10
- }
11
- const ro = new RO((entries) => {
12
- const entry = entries[0];
13
- if (entry) {
14
- const { width, height } = entry.contentRect;
15
- props.onResize({ width, height });
16
- }
17
- });
18
- const domNode = domRef.current;
19
- ro.observe(domNode);
20
- return () => {
21
- if (domNode) {
22
- ro.unobserve(domNode);
23
- }
24
- };
25
- }, []);
26
- return (_jsx("div", { ref: domRef, style: {
27
- visibility: 'hidden',
28
- position: 'absolute',
29
- width: '100%',
30
- height: '100%',
31
- top: 0,
32
- left: 0,
33
- } }));
34
- };
35
- export default NotifyResize;
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- import { DialogProps, DialogRefType } from './Dialog';
3
- /**
4
- * This is the main popup that we use - so all function popups will appear here.
5
- */
6
- export interface IPopupWithFooterProps extends DialogProps {
7
- showModal: boolean;
8
- onHide?: () => void;
9
- modal?: boolean;
10
- maxWidth?: number;
11
- footer: React.ReactNode;
12
- children: React.ReactNode;
13
- }
14
- export declare const PopupWithFooter: React.ForwardRefExoticComponent<IPopupWithFooterProps & React.RefAttributes<DialogRefType>>;
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import Dialog from './Dialog';
4
- import FlexWithFooter from './FlexWithFooter';
5
- import { twMerge } from '../twMerge';
6
- export const PopupWithFooter = React.forwardRef((props, ref) => {
7
- const { showModal, onHide, footer, maxWidth, style, ...dialogProps } = props;
8
- return (_jsx(Dialog, { ...dialogProps, ref: ref, isOpen: showModal, onDismiss: onHide, showCloseButton: false, className: twMerge('twa:p-0', dialogProps.className), children: _jsx(FlexWithFooter, { flexDirection: "column", style: style, footer: footer, footerProps: {
9
- className: 'ab-Popup__footer twa:p-2 twa:bg-primary',
10
- }, children: props.children }) }));
11
- });
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import { SyntheticEvent, HTMLProps } from 'react';
3
- type SelectableListValues = {
4
- [key: string]: boolean;
5
- };
6
- export declare const useSelectionEvent: () => (event: SyntheticEvent, { index }: {
7
- index: number;
8
- }) => void;
9
- interface SelectableListProps {
10
- onSelectedChange?: (selected: SelectableListValues) => void;
11
- toggleOnSimpleClick?: boolean;
12
- getItemId: (index: number) => string | number;
13
- }
14
- declare const SelectableList: (props: HTMLProps<HTMLDivElement> & SelectableListProps) => React.JSX.Element;
15
- export default SelectableList;
@@ -1,88 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { useContext, useRef } from 'react';
4
- import useProperty from '../utils/useProperty';
5
- const SelectableListContext = React.createContext({
6
- clickInfoRef: null,
7
- selected: {},
8
- getItemId: (index) => index,
9
- toggleOnSimpleClick: false,
10
- setSelected: (x) => { },
11
- });
12
- export const useSelectionEvent = () => {
13
- const { selected, setSelected, toggleOnSimpleClick, clickInfoRef, getItemId } = useContext(SelectableListContext);
14
- return (event, { index }) => {
15
- if (index === undefined) {
16
- return;
17
- }
18
- const { lastClickIndexWithoutShift, lastShiftSelectionRange } = clickInfoRef.current;
19
- let { shiftKey, metaKey, ctrlKey } = event;
20
- if (ctrlKey) {
21
- metaKey = true;
22
- }
23
- if (metaKey) {
24
- shiftKey = false;
25
- }
26
- let itemId = `${getItemId(index)}`;
27
- let newSelection;
28
- if (!shiftKey) {
29
- clickInfoRef.current.lastClickIndexWithoutShift = index;
30
- if (!metaKey && !toggleOnSimpleClick) {
31
- newSelection = { [itemId]: true };
32
- }
33
- else {
34
- const currentRowSelected = selected[itemId];
35
- newSelection = { ...selected };
36
- if (currentRowSelected) {
37
- delete newSelection[itemId];
38
- clickInfoRef.current.lastClickIndexWithoutShift = lastClickIndexWithoutShift;
39
- }
40
- else {
41
- newSelection[itemId] = true;
42
- }
43
- }
44
- clickInfoRef.current.lastShiftSelectionRange = null;
45
- setSelected(newSelection);
46
- }
47
- else {
48
- let prevClickIndex = lastClickIndexWithoutShift;
49
- let currentClickIndex = index;
50
- newSelection = { ...selected };
51
- if (lastShiftSelectionRange) {
52
- let { start, end } = lastShiftSelectionRange;
53
- for (; start <= end; start++) {
54
- delete newSelection[getItemId(start)];
55
- }
56
- }
57
- let [start, end] = [
58
- Math.min(prevClickIndex, currentClickIndex),
59
- Math.max(prevClickIndex, currentClickIndex),
60
- ];
61
- clickInfoRef.current.lastShiftSelectionRange = { start, end };
62
- for (; start <= end; start++) {
63
- newSelection[getItemId(start)] = true;
64
- }
65
- setSelected(newSelection);
66
- }
67
- };
68
- };
69
- const SelectableList = (props) => {
70
- const [selected, setSelected] = useProperty(props, 'selected', {});
71
- const clickInfoRef = useRef({
72
- lastClickIndexWithoutShift: 0,
73
- });
74
- const getItemId = (index) => {
75
- if (props.getItemId) {
76
- return props.getItemId(index);
77
- }
78
- return index;
79
- };
80
- return (_jsx(SelectableListContext.Provider, { value: {
81
- clickInfoRef,
82
- toggleOnSimpleClick: props.toggleOnSimpleClick || false,
83
- selected,
84
- setSelected,
85
- getItemId,
86
- }, children: props.children }));
87
- };
88
- export default SelectableList;
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { ReactNode } from 'react';
3
- import { BoxProps } from '../Flex';
4
- interface SizedContainerProps extends Omit<BoxProps, 'children' | 'onResize'> {
5
- style?: React.CSSProperties;
6
- className?: string;
7
- children: (size: {
8
- width: number;
9
- height: number;
10
- }) => ReactNode;
11
- onResize?: (size: {
12
- width: number;
13
- height: number;
14
- }) => void;
15
- }
16
- declare const SizedContainer: (props: SizedContainerProps) => React.JSX.Element;
17
- export default SizedContainer;
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import NotifyResize from '../NotifyResize';
4
- import { Box } from '../Flex';
5
- const SizedContainer = (props) => {
6
- const { onResize: onResizeFromProps, ...domProps } = props;
7
- const [size, onResize] = React.useState(null);
8
- const sizeFn = props.children;
9
- return (_jsx(Box, { ...domProps, style: { flex: 1, ...domProps.style, position: 'relative' }, children: _jsxs(Box, { style: {
10
- position: 'absolute',
11
- left: 0,
12
- top: 0,
13
- width: '100%',
14
- height: '100%',
15
- }, "data-width": size ? size.width : null, "data-height": size ? size.height : null, children: [_jsx(NotifyResize, { onResize: (size) => {
16
- onResize(size);
17
- onResizeFromProps?.(size);
18
- } }), size ? sizeFn(size) : null] }) }));
19
- };
20
- export default SizedContainer;
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { HTMLAttributes } from 'react';
3
- declare const Table: (props: HTMLAttributes<HTMLTableElement>) => React.JSX.Element;
4
- export default Table;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import join from '../utils/join';
3
- const Table = (props) => {
4
- return _jsx("table", { ...props, className: join(props.className, 'ab-Table') });
5
- };
6
- export default Table;
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { PanelProps } from '../Panel';
3
- declare const WizardPanel: (props: {
4
- bodyProps?: PanelProps["bodyProps"];
5
- className?: string;
6
- "data-name"?: string;
7
- children?: React.ReactNode;
8
- }) => React.JSX.Element;
9
- export default WizardPanel;
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import Panel from '../Panel';
3
- import { twMerge } from '../../twMerge';
4
- const WizardPanel = (props) => {
5
- return (_jsx(Panel, { bodyScroll: true, bodyProps: props.bodyProps, "data-name": props['data-name'], className: twMerge('ab-WizardPanel', 'twa:border-none twa:rounded-none twa:h-full', props.className), children: props.children }));
6
- };
7
- export default WizardPanel;
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M11,9H13V11H11V9M9,11H11V13H9V11M13,11H15V13H13V11M15,9H17V11H15V9M7,9H9V11H7V9M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M9,18H7V16H9V18M13,18H11V16H13V18M17,18H15V16H17V18M19,11H17V13H19V15H17V13H15V15H13V13H11V15H9V13H7V15H5V13H7V11H5V5H19V11Z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2L1 21z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsxs(DefaultIcon, { ...props, children: [_jsx("path", { d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" })] }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-5 3c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm4 8h-8v-1c0-1.33 2.67-2 4-2s4 .67 4 2v1z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" }) }));
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: (props: any) => React.JSX.Element;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import DefaultIcon from './DefaultIcon';
3
- export default (props) => (_jsx(DefaultIcon, { ...props, children: _jsx("path", { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }) }));
@@ -1,6 +0,0 @@
1
- type UseContainerScrollObserverCallback = (currentIndex: number) => void;
2
- export declare const useContainerScrollObserver: (callback: UseContainerScrollObserverCallback) => {
3
- ref: (node: HTMLElement) => void;
4
- scrollToIndex: (index: number) => void;
5
- };
6
- export {};
@@ -1,79 +0,0 @@
1
- import { useCallback, useRef } from 'react';
2
- class SectionSelector {
3
- scrollTop = 0;
4
- node;
5
- boxHeight;
6
- childrenHeights = [];
7
- maxScrollTop;
8
- constructor(node) {
9
- this.node = node;
10
- this.refreshFromDOM();
11
- }
12
- refreshFromDOM() {
13
- this.boxHeight = this.node.scrollHeight;
14
- this.childrenHeights = Array.prototype.map.call(this.node.children, (child) => child.offsetHeight);
15
- this.maxScrollTop = this.boxHeight - this.node.offsetHeight;
16
- }
17
- getVisibleRange(scrollTop = this.scrollTop) {
18
- const top = scrollTop;
19
- const height = this.node.offsetHeight;
20
- const bottom = scrollTop + this.node.offsetHeight;
21
- return {
22
- top,
23
- bottom,
24
- height,
25
- };
26
- }
27
- select = (scrollTop) => {
28
- this.refreshFromDOM();
29
- const relativeCurrentHeight = (scrollTop * this.boxHeight) / this.maxScrollTop;
30
- let heightSum = 0;
31
- for (let i = 0, len = this.childrenHeights.length; i < len; i++) {
32
- heightSum += this.childrenHeights[i];
33
- if (heightSum > relativeCurrentHeight) {
34
- return i;
35
- }
36
- }
37
- return this.childrenHeights.length - 1;
38
- };
39
- }
40
- export const useContainerScrollObserver = (callback) => {
41
- const containerNodeRef = useRef(null);
42
- const sectionSelectorRef = useRef(null);
43
- const update = useCallback((scrollTop) => {
44
- callback(sectionSelectorRef.current.select(scrollTop));
45
- }, []);
46
- const scrollRafRef = useRef(null);
47
- const onScroll = useCallback(() => {
48
- if (scrollRafRef.current) {
49
- cancelAnimationFrame(scrollRafRef.current);
50
- scrollRafRef.current = null;
51
- }
52
- requestAnimationFrame(() => {
53
- scrollRafRef.current = null;
54
- update(containerNodeRef.current.scrollTop);
55
- });
56
- }, []);
57
- const setupScroll = useCallback((node) => {
58
- if (node) {
59
- containerNodeRef.current = node;
60
- node.addEventListener('scroll', onScroll, { passive: true });
61
- sectionSelectorRef.current = new SectionSelector(node);
62
- }
63
- else {
64
- containerNodeRef.current?.removeEventListener('scroll', onScroll);
65
- sectionSelectorRef.current = null;
66
- }
67
- }, []);
68
- const ref = setupScroll;
69
- return {
70
- ref,
71
- scrollToIndex: useCallback((index) => {
72
- const container = containerNodeRef.current;
73
- const node = container.childNodes[index];
74
- node.scrollIntoView({
75
- behavior: 'smooth',
76
- });
77
- }, []),
78
- };
79
- };
@@ -1 +0,0 @@
1
- export declare const useGlobalEvent: (eventName: string, callback: (event: KeyboardEvent) => void) => void;
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- export const useGlobalEvent = (eventName, callback) => {
3
- React.useEffect(() => {
4
- window.addEventListener(eventName, callback);
5
- return () => window.removeEventListener(eventName, callback);
6
- }, [eventName, callback]);
7
- };
@@ -1 +0,0 @@
1
- export declare const useLatest: <T>(value: T) => (() => T);
@@ -1,6 +0,0 @@
1
- import { useCallback, useRef } from 'react';
2
- export const useLatest = (value) => {
3
- const ref = useRef(value);
4
- ref.current = value;
5
- return useCallback(() => ref.current, []);
6
- };
@@ -1,2 +0,0 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- export default function usePropState<S>(state: S | undefined, setState: Dispatch<SetStateAction<S>> | undefined, initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
@@ -1,8 +0,0 @@
1
- import { useState } from 'react';
2
- export default function usePropState(state, setState, initialState) {
3
- const [localState, setLocalState] = useState(initialState);
4
- return [
5
- state !== undefined ? state : localState,
6
- setState !== undefined ? setState : setLocalState,
7
- ];
8
- }