grep-components 2.25.0-GREPF-2996.2 → 2.25.0
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.
|
@@ -6,6 +6,6 @@ interface Context {
|
|
|
6
6
|
classes?: Record<'nav' | 'tree' | 'node' | 'link', string>;
|
|
7
7
|
offsetTop?: number;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export {
|
|
11
|
-
export default
|
|
9
|
+
declare const Context: React.Context<Context>;
|
|
10
|
+
export { Context as GrepTableOfContentContex };
|
|
11
|
+
export default Context;
|
|
@@ -4,5 +4,5 @@ export interface IdentifyElement {
|
|
|
4
4
|
export declare const generateElementId: IdentifyElement;
|
|
5
5
|
export declare const identifyElement: (identify?: IdentifyElement) => (element: HTMLElement) => string;
|
|
6
6
|
export declare const identifyElements: (elements: Array<HTMLElement>, identify?: IdentifyElement) => void;
|
|
7
|
-
export declare const
|
|
8
|
-
export default
|
|
7
|
+
export declare const identifiedElements: (elements: Array<HTMLElement>, identify?: IdentifyElement) => Record<string, HTMLElement>;
|
|
8
|
+
export default identifiedElements;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import LocalizedFormatPlugin from 'dayjs/plugin/localizedFormat.js';
|
|
|
3
3
|
import isBetweenPlugin from 'dayjs/plugin/isBetween.js';
|
|
4
4
|
import { blueGrey, grey, brown, deepOrange, orange, amber, yellow, lime, lightGreen, green, teal, cyan, lightBlue, blue, indigo, deepPurple, purple, pink, red } from '@mui/material/colors';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import React__default, { useRef, useMemo, createContext, useContext, forwardRef, createElement, useState, useCallback, useEffect, useLayoutEffect, memo, useReducer, cloneElement } from 'react';
|
|
6
|
+
import React__default, { useRef, useMemo, createContext, useContext, forwardRef, createElement, useState, useCallback, useEffect, useLayoutEffect, memo, useReducer, cloneElement, use } from 'react';
|
|
7
7
|
import AccountCircle from '@mui/icons-material/AccountCircle';
|
|
8
8
|
import ArrowDropdown from '@mui/icons-material/ArrowDropDown';
|
|
9
9
|
import { Button, Box, Typography, Tabs, Tab, Collapse, MenuList, Tooltip, MenuItem as MenuItem$1, Menu as Menu$1, Container, List, ListItem, ListItemText, ListItemButton, CircularProgress, TextField, FormControl, InputLabel, Select, OutlinedInput, Input, Checkbox, FormHelperText, IconButton as IconButton$1, ToggleButtonGroup, ToggleButton, AppBar as AppBar$1, Toolbar as Toolbar$1, Divider as Divider$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogContentText as DialogContentText$1, DialogActions as DialogActions$1 } from '@mui/material';
|
|
@@ -1708,7 +1708,7 @@ const CollapsableMenuItem = ({ items, onClick, children, onClose: _onclose, tool
|
|
|
1708
1708
|
const handleClick = items ? onToggleClick : onClick;
|
|
1709
1709
|
useEffect(() => {
|
|
1710
1710
|
document.addEventListener('click', onScrimClick, { capture: true });
|
|
1711
|
-
return () => document.removeEventListener('click', onScrimClick);
|
|
1711
|
+
return () => document.removeEventListener('click', onScrimClick, { capture: true });
|
|
1712
1712
|
}, [listItemRef, onScrimClick]);
|
|
1713
1713
|
const { classes } = useStyles$f({ open });
|
|
1714
1714
|
const renderInner = () => (React__default.createElement(Box, { sx: { display: 'flex', flexDirection: 'column', width: '100%' } },
|
|
@@ -2158,35 +2158,35 @@ const getElementIndex = (el) => Number(el.getAttribute('data-index') || -1);
|
|
|
2158
2158
|
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
2159
2159
|
const [rowsPerPage, setRowsPerPage] = React__default.useState(props.rowsPerPage || 10);
|
|
2160
2160
|
const [menuAnchor, setMenuAnchor] = React__default.useState(null);
|
|
2161
|
-
const [currentPage,
|
|
2162
|
-
const [selectedRowIndex,
|
|
2163
|
-
const [expandedRowIndex,
|
|
2161
|
+
const [currentPage, setCurrentPage] = React__default.useState(0);
|
|
2162
|
+
const [selectedRowIndex, setSelectedRowIndex] = React__default.useState();
|
|
2163
|
+
const [expandedRowIndex, setExpandedRowIndex] = React__default.useState();
|
|
2164
2164
|
const [dropdownContext, setDropdownContext] = React__default.useState();
|
|
2165
2165
|
const selectedRow = data[selectedRowIndex] || null;
|
|
2166
|
-
const
|
|
2166
|
+
const _setCurrentPage = useCallback((index, rowIndex, shouldExpand) => {
|
|
2167
2167
|
index = pagination && index >= 0 ? index : 0;
|
|
2168
|
-
|
|
2169
|
-
|
|
2168
|
+
setCurrentPage(index);
|
|
2169
|
+
setSelectedRowIndex(rowIndex);
|
|
2170
2170
|
if (shouldExpand) {
|
|
2171
|
-
|
|
2171
|
+
setExpandedRowIndex(rowIndex);
|
|
2172
2172
|
}
|
|
2173
2173
|
}, [
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2174
|
+
setCurrentPage,
|
|
2175
|
+
setSelectedRowIndex,
|
|
2176
|
+
setExpandedRowIndex,
|
|
2177
2177
|
rowsPerPage,
|
|
2178
2178
|
pagination,
|
|
2179
2179
|
]);
|
|
2180
|
-
const
|
|
2180
|
+
const _setSelectedRowIndex = (index, shouldExpand = true) => {
|
|
2181
2181
|
const hasIndexChanged = index === selectedRowIndex;
|
|
2182
2182
|
const pageIndex = Math.floor(index / rowsPerPage);
|
|
2183
|
-
|
|
2183
|
+
_setCurrentPage(pageIndex, index, shouldExpand);
|
|
2184
2184
|
if (hasIndexChanged && onSelectedRowChange) {
|
|
2185
2185
|
onSelectedRowChange(data[index]);
|
|
2186
2186
|
}
|
|
2187
2187
|
};
|
|
2188
2188
|
const setSelectedElement = (el, shouldExpand = true) => {
|
|
2189
|
-
|
|
2189
|
+
_setSelectedRowIndex(getElementIndex(el), shouldExpand);
|
|
2190
2190
|
};
|
|
2191
2191
|
const tableRef = React__default.useRef(null);
|
|
2192
2192
|
// focus selected row first tabable item
|
|
@@ -2201,8 +2201,8 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2201
2201
|
}
|
|
2202
2202
|
}, [tableRef, selectedRowIndex]);
|
|
2203
2203
|
React__default.useEffect(() => {
|
|
2204
|
-
|
|
2205
|
-
}, [data.length,
|
|
2204
|
+
_setCurrentPage(0);
|
|
2205
|
+
}, [data.length, _setCurrentPage]);
|
|
2206
2206
|
const _openDropdown = (e, row) => {
|
|
2207
2207
|
const { onContextIdChanged } = props;
|
|
2208
2208
|
if (onContextIdChanged) {
|
|
@@ -2217,7 +2217,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2217
2217
|
}, [onRowClick]);
|
|
2218
2218
|
const _handlePageChange = (event, newPage) => {
|
|
2219
2219
|
event && event.preventDefault();
|
|
2220
|
-
|
|
2220
|
+
_setCurrentPage(newPage);
|
|
2221
2221
|
};
|
|
2222
2222
|
const _handleChangeRowsPerPage = (event) => {
|
|
2223
2223
|
setRowsPerPage(Number(event.target.value));
|
|
@@ -2297,7 +2297,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2297
2297
|
const moveSelectedRow = (steps) => {
|
|
2298
2298
|
const i = (selectedRowIndex || 0) + steps;
|
|
2299
2299
|
if (i >= 0 && i <= maxIndex) {
|
|
2300
|
-
|
|
2300
|
+
_setSelectedRowIndex(i);
|
|
2301
2301
|
}
|
|
2302
2302
|
};
|
|
2303
2303
|
switch (e.key) {
|
|
@@ -2316,15 +2316,15 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2316
2316
|
moveSelectedRow(rowsPerPage);
|
|
2317
2317
|
break;
|
|
2318
2318
|
case Key.Home:
|
|
2319
|
-
|
|
2319
|
+
_setSelectedRowIndex(0);
|
|
2320
2320
|
break;
|
|
2321
2321
|
case Key.End:
|
|
2322
|
-
|
|
2322
|
+
_setSelectedRowIndex(maxIndex);
|
|
2323
2323
|
break;
|
|
2324
2324
|
case Key.Tab:
|
|
2325
2325
|
requestAnimationFrame(() => {
|
|
2326
2326
|
// check is any children still has focus
|
|
2327
|
-
!containsFocus(tableRef.current) &&
|
|
2327
|
+
!containsFocus(tableRef.current) && _setSelectedRowIndex(-1);
|
|
2328
2328
|
});
|
|
2329
2329
|
break;
|
|
2330
2330
|
case Key.Enter:
|
|
@@ -2611,16 +2611,16 @@ const GrepInput = ({ variant = 'standard', ...props }) => {
|
|
|
2611
2611
|
};
|
|
2612
2612
|
|
|
2613
2613
|
const GrepSelect = (props) => {
|
|
2614
|
-
const
|
|
2614
|
+
const inputLabelRef = React.useRef(null);
|
|
2615
2615
|
const [labelWidth, setLabelWidth] = React.useState(0);
|
|
2616
2616
|
React.useEffect(() => {
|
|
2617
|
-
setLabelWidth(
|
|
2617
|
+
setLabelWidth(inputLabelRef.current.offsetWidth);
|
|
2618
2618
|
}, []);
|
|
2619
2619
|
const { unselectOption = true, errorMessage, selectItems, helperText, fullWidth, outlined, disabled, required, label, labelProps, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
2620
2620
|
const error = errorMessage ? errorMessage.length > 0 : false;
|
|
2621
2621
|
const selected = value;
|
|
2622
2622
|
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled },
|
|
2623
|
-
React.createElement(InputLabel, { htmlFor: id, ref:
|
|
2623
|
+
React.createElement(InputLabel, { htmlFor: id, ref: inputLabelRef, style: {
|
|
2624
2624
|
minWidth: 'max-content',
|
|
2625
2625
|
overflow: 'visible',
|
|
2626
2626
|
}, ...labelProps }, label),
|
|
@@ -2651,7 +2651,7 @@ const defaultOptions$2 = {
|
|
|
2651
2651
|
};
|
|
2652
2652
|
const useDate = (value = null, options) => {
|
|
2653
2653
|
const { utc, preserveTime } = { ...options, ...defaultOptions$2 };
|
|
2654
|
-
const [date,
|
|
2654
|
+
const [date, setDate] = useState(null);
|
|
2655
2655
|
const getDate = useCallback((value) => {
|
|
2656
2656
|
if (value) {
|
|
2657
2657
|
const date = dayjs(value);
|
|
@@ -2659,13 +2659,13 @@ const useDate = (value = null, options) => {
|
|
|
2659
2659
|
}
|
|
2660
2660
|
return null;
|
|
2661
2661
|
}, [preserveTime]);
|
|
2662
|
-
const
|
|
2662
|
+
const _setDate = (next) => {
|
|
2663
2663
|
const nextDate = getDate(next);
|
|
2664
|
-
hasDateChanged(date, nextDate) &&
|
|
2664
|
+
hasDateChanged(date, nextDate) && setDate(nextDate);
|
|
2665
2665
|
};
|
|
2666
2666
|
// eslint-disable-next-line @eslint-react/use-memo
|
|
2667
|
-
useMemo(() =>
|
|
2668
|
-
return [date,
|
|
2667
|
+
useMemo(() => _setDate(value ? parseDate(value, { utc }) : null), [value, utc]);
|
|
2668
|
+
return [date, _setDate];
|
|
2669
2669
|
};
|
|
2670
2670
|
|
|
2671
2671
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -7809,7 +7809,7 @@ function getItemGap$1(clientRects, index, activeIndex) {
|
|
|
7809
7809
|
}
|
|
7810
7810
|
|
|
7811
7811
|
const ID_PREFIX = 'Sortable';
|
|
7812
|
-
const Context = /*#__PURE__*/React__default.createContext({
|
|
7812
|
+
const Context$1 = /*#__PURE__*/React__default.createContext({
|
|
7813
7813
|
activeIndex: -1,
|
|
7814
7814
|
containerId: ID_PREFIX,
|
|
7815
7815
|
disableTransforms: false,
|
|
@@ -7868,7 +7868,7 @@ function SortableContext(_ref) {
|
|
|
7868
7868
|
strategy
|
|
7869
7869
|
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7870
7870
|
[activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]);
|
|
7871
|
-
return React__default.createElement(Context.Provider, {
|
|
7871
|
+
return React__default.createElement(Context$1.Provider, {
|
|
7872
7872
|
value: contextValue
|
|
7873
7873
|
}, children);
|
|
7874
7874
|
}
|
|
@@ -7992,7 +7992,7 @@ function useSortable(_ref) {
|
|
|
7992
7992
|
overIndex,
|
|
7993
7993
|
useDragOverlay,
|
|
7994
7994
|
strategy: globalStrategy
|
|
7995
|
-
} = useContext(Context);
|
|
7995
|
+
} = useContext(Context$1);
|
|
7996
7996
|
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
7997
7997
|
const index = items.indexOf(id);
|
|
7998
7998
|
const data = useMemo(() => ({
|
|
@@ -8554,16 +8554,16 @@ function Mt(t,e){if(null==t)return false;const n=Object.getPrototypeOf(t);retur
|
|
|
8554
8554
|
|
|
8555
8555
|
function StyleWrapperPlugin({ showCharcount, maxChars, helperText, readOnly, classes, label, children, autoFocus, toolbarAnchor, hasCustomToolbar, }) {
|
|
8556
8556
|
const [editor] = useLexicalComposerContext();
|
|
8557
|
-
const [hasFocus,
|
|
8557
|
+
const [hasFocus, setHasFocus] = useState(() => {
|
|
8558
8558
|
return editor.getRootElement() === document.activeElement;
|
|
8559
8559
|
});
|
|
8560
8560
|
const [charCount, setCharCount] = useState(0);
|
|
8561
8561
|
useEffect(() => {
|
|
8562
8562
|
return mergeRegister(editor.registerCommand(BLUR_COMMAND, () => {
|
|
8563
|
-
|
|
8563
|
+
setHasFocus(editor.getRootElement() === document.activeElement);
|
|
8564
8564
|
return false;
|
|
8565
8565
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(FOCUS_COMMAND, () => {
|
|
8566
|
-
|
|
8566
|
+
setHasFocus(editor.getRootElement() === document.activeElement);
|
|
8567
8567
|
return false;
|
|
8568
8568
|
}, COMMAND_PRIORITY_EDITOR));
|
|
8569
8569
|
}, []);
|
|
@@ -8687,6 +8687,7 @@ function ModifyPastePlugin({ blockPasting, stripPastedStyles, }) {
|
|
|
8687
8687
|
const [editor] = useLexicalComposerContext();
|
|
8688
8688
|
editor.registerCommand(PASTE_COMMAND, (e) => {
|
|
8689
8689
|
if (blockPasting) {
|
|
8690
|
+
e.preventDefault();
|
|
8690
8691
|
return true;
|
|
8691
8692
|
}
|
|
8692
8693
|
else if (stripPastedStyles && 'clipboardData' in e && e.clipboardData) {
|
|
@@ -9260,11 +9261,13 @@ const setPlaceholderOnSelection = ({ selection, editor, placeholder, }) => {
|
|
|
9260
9261
|
* 4. Get "PointType" object, that contain Nodes data
|
|
9261
9262
|
*/
|
|
9262
9263
|
const anchor = selection.anchor;
|
|
9263
|
-
placeholder = DOMPurify.sanitize(placeholder
|
|
9264
|
+
placeholder = DOMPurify.sanitize(placeholder || '');
|
|
9264
9265
|
if (placeholder) {
|
|
9265
9266
|
const selectedHtmlElement = editor.getElementByKey(anchor.key);
|
|
9266
9267
|
selectedHtmlElement?.classList.add(PLACEHOLDER_CLASS_NAME);
|
|
9267
|
-
|
|
9268
|
+
const e = document.createElement('div');
|
|
9269
|
+
e.innerHTML = placeholder;
|
|
9270
|
+
selectedHtmlElement?.setAttribute('data-placeholder', e.textContent);
|
|
9268
9271
|
}
|
|
9269
9272
|
};
|
|
9270
9273
|
const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
@@ -9280,14 +9283,9 @@ const setNodePlaceholderFromSelection = (editor, placeholder) => {
|
|
|
9280
9283
|
const AddPlaceholderPlugin = ({ placeholder, }) => {
|
|
9281
9284
|
const [editor] = useLexicalComposerContext();
|
|
9282
9285
|
useEffect(() => {
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
});
|
|
9287
|
-
}
|
|
9288
|
-
else {
|
|
9289
|
-
return;
|
|
9290
|
-
}
|
|
9286
|
+
return editor.registerUpdateListener(() => {
|
|
9287
|
+
setNodePlaceholderFromSelection(editor, placeholder ?? '');
|
|
9288
|
+
});
|
|
9291
9289
|
}, [editor, placeholder]);
|
|
9292
9290
|
return null;
|
|
9293
9291
|
};
|
|
@@ -9782,11 +9780,11 @@ const GrepDialogServiceProvider = ({ children, }) => {
|
|
|
9782
9780
|
setDialogState(options);
|
|
9783
9781
|
setDialogOpen(true);
|
|
9784
9782
|
};
|
|
9785
|
-
return (React__default.createElement(GrepDialogServiceContext
|
|
9783
|
+
return (React__default.createElement(GrepDialogServiceContext, { value: openDialog },
|
|
9786
9784
|
React__default.createElement(GrepDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), ...dialogState }),
|
|
9787
9785
|
children));
|
|
9788
9786
|
};
|
|
9789
|
-
const useGrepDialog = () =>
|
|
9787
|
+
const useGrepDialog = () => use(GrepDialogServiceContext);
|
|
9790
9788
|
|
|
9791
9789
|
/**
|
|
9792
9790
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -10261,15 +10259,15 @@ const initial = {
|
|
|
10261
10259
|
throw Error('not implemented');
|
|
10262
10260
|
},
|
|
10263
10261
|
};
|
|
10264
|
-
const
|
|
10265
|
-
|
|
10262
|
+
const Context = React__default.createContext(initial);
|
|
10263
|
+
Context.displayName = 'Grep.ToC.Context';
|
|
10266
10264
|
|
|
10267
10265
|
const defaultSelector = [...new Array(9)]
|
|
10268
10266
|
.map((_, i) => `h${i + 1}:not([role="presentation"])`)
|
|
10269
10267
|
.join(',');
|
|
10270
10268
|
const GrepTableOfContentProvider = ({ ...props }) => {
|
|
10271
10269
|
const { container, identifier, onSelected, classes, scrollTarget, children, offsetTop = -10, identifyElementFn = identifyElement, } = props;
|
|
10272
|
-
const [selected,
|
|
10270
|
+
const [selected, setSelected] = useState();
|
|
10273
10271
|
const [initialized, setInitialized] = useState();
|
|
10274
10272
|
const hash = useLocation().hash;
|
|
10275
10273
|
const scrollToElement = useCallback((element) => {
|
|
@@ -10283,10 +10281,10 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10283
10281
|
return identifyElementFn(identifier || generateElementId);
|
|
10284
10282
|
}, [identifier, identifyElementFn]);
|
|
10285
10283
|
const elements = useContentElements(container, props.selector || defaultSelector, { identify });
|
|
10286
|
-
const
|
|
10284
|
+
const _setSelected = useCallback(throttle((element, scroll) => {
|
|
10287
10285
|
element && scroll && scrollToElement(element);
|
|
10288
|
-
|
|
10289
|
-
}, 50, { trailing: false }), [
|
|
10286
|
+
setSelected(element);
|
|
10287
|
+
}, 50, { trailing: false }), [setSelected, scrollToElement]);
|
|
10290
10288
|
const getViewportElement = useCallback(() => {
|
|
10291
10289
|
const records = Object.values(elements);
|
|
10292
10290
|
if (!records.length)
|
|
@@ -10307,13 +10305,13 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10307
10305
|
return;
|
|
10308
10306
|
const onScroll = throttle(() => {
|
|
10309
10307
|
const element = getViewportElement();
|
|
10310
|
-
|
|
10308
|
+
_setSelected(element);
|
|
10311
10309
|
}, 50);
|
|
10312
10310
|
target.addEventListener('scroll', onScroll, false);
|
|
10313
10311
|
return () => {
|
|
10314
10312
|
return target.removeEventListener('scroll', onScroll);
|
|
10315
10313
|
};
|
|
10316
|
-
}, [scrollTarget,
|
|
10314
|
+
}, [scrollTarget, _setSelected, offsetTop, getViewportElement]);
|
|
10317
10315
|
// notify observer when selected change
|
|
10318
10316
|
useEffect(() => {
|
|
10319
10317
|
selected && onSelected && onSelected(selected);
|
|
@@ -10321,15 +10319,15 @@ const GrepTableOfContentProvider = ({ ...props }) => {
|
|
|
10321
10319
|
// observe changes in hash
|
|
10322
10320
|
useEffect(() => {
|
|
10323
10321
|
if (hash && elements[hash]) {
|
|
10324
|
-
|
|
10322
|
+
_setSelected(elements[hash], true);
|
|
10325
10323
|
}
|
|
10326
|
-
}, [hash,
|
|
10324
|
+
}, [hash, _setSelected]);
|
|
10327
10325
|
// set selected element on initial load
|
|
10328
10326
|
if (!initialized && elements && elements[hash]) {
|
|
10329
|
-
|
|
10327
|
+
_setSelected(elements[hash], true);
|
|
10330
10328
|
setInitialized(true);
|
|
10331
10329
|
}
|
|
10332
|
-
return (React__default.createElement(
|
|
10330
|
+
return (React__default.createElement(Context, { value: { elements, selected, classes, setSelected: _setSelected } }, children));
|
|
10333
10331
|
};
|
|
10334
10332
|
GrepTableOfContentProvider.displayName = 'Grep.ToC.Provider';
|
|
10335
10333
|
|
|
@@ -10367,7 +10365,7 @@ const GrepTableOfContentNavTreeNode = (props) => {
|
|
|
10367
10365
|
const linkRef = useRef(null);
|
|
10368
10366
|
const { node, style, renderChilds, setSelectedValue, percentageRendered } = props;
|
|
10369
10367
|
const { lvl, el, index, children } = node;
|
|
10370
|
-
const { selected, setSelected, classes, elements } =
|
|
10368
|
+
const { selected, setSelected, classes, elements } = use(Context);
|
|
10371
10369
|
const isSelected = el === selected;
|
|
10372
10370
|
const { classes: styles } = useStyles$2({ lvl });
|
|
10373
10371
|
const className = clsx('grep-toc__nav-tree-node', isSelected && 'grep-toc__nav-tree-node--selected', styles.root, classes?.node, props.className);
|
|
@@ -10423,7 +10421,7 @@ const useStyles$1 = makeStyles()(() => ({
|
|
|
10423
10421
|
|
|
10424
10422
|
const NavTree = (props) => {
|
|
10425
10423
|
const { elements, style, setSelectedValue, percentageRendered } = props;
|
|
10426
|
-
const { classes } =
|
|
10424
|
+
const { classes } = use(Context);
|
|
10427
10425
|
const { classes: styles } = useStyles$1();
|
|
10428
10426
|
const className = clsx('grep-toc__nav-tree', styles.root, classes?.tree, props.className);
|
|
10429
10427
|
return (React__default.createElement("ul", { className: className, style: style }, Object.values(elements).map((node) => (React__default.createElement(GrepTableOfContentNavTreeNode, { node: node, key: node.index, renderChilds: (children) => (React__default.createElement(NavTree, { elements: children, setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })), setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })))));
|
|
@@ -10473,7 +10471,7 @@ const buildTree = (elements, normalizer = normalize) => {
|
|
|
10473
10471
|
|
|
10474
10472
|
const GrepTableOfContentNav = (props) => {
|
|
10475
10473
|
const ref = useRef(null);
|
|
10476
|
-
const { elements, classes, selected, setSelected } =
|
|
10474
|
+
const { elements, classes, selected, setSelected } = use(Context);
|
|
10477
10475
|
const tree = useMemo(() => buildTree(Object.values(elements)), [elements]);
|
|
10478
10476
|
const focusSelected = useCallback(() => {
|
|
10479
10477
|
requestAnimationFrame(() => {
|