grep-components 2.18.0-GREPF-2830.1 → 2.19.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.
- package/dist/components/ContainedLinkList/index.d.ts +1 -1
- package/dist/components/DropdownMenu/index.d.ts +1 -1
- package/dist/components/GrepTable/index.d.ts +1 -1
- package/dist/components/LinkList/index.d.ts +1 -1
- package/dist/components/Sidebar/index.d.ts +1 -1
- package/dist/components/ToC/styles/nav.style.d.ts +1 -1
- package/dist/index.js +45 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ interface Props {
|
|
|
4
4
|
title: string;
|
|
5
5
|
pages: NavigationProps[];
|
|
6
6
|
style?: React.CSSProperties;
|
|
7
|
-
onPageClick: (page: NavigationProps) => void;
|
|
7
|
+
onPageClick: (page: NavigationProps, event: React.MouseEvent) => void;
|
|
8
8
|
}
|
|
9
9
|
declare const _default: React.ComponentType<Props>;
|
|
10
10
|
export default _default;
|
|
@@ -8,7 +8,7 @@ export type DropdownMenuItem<T> = Omit<MenuItemProps, 'disabled'> & {
|
|
|
8
8
|
tooltipPlacement?: TooltipPlacement;
|
|
9
9
|
disabled?: BooleanFunction<T> | boolean;
|
|
10
10
|
children?: Array<DropdownMenuItem<T>>;
|
|
11
|
-
handleClick?: (context?: T) => void;
|
|
11
|
+
handleClick?: (context?: T, mouseEvent?: React.MouseEvent) => void;
|
|
12
12
|
};
|
|
13
13
|
export interface DropdownMenuProps<T> extends MenuProps {
|
|
14
14
|
context?: T;
|
|
@@ -33,7 +33,7 @@ export interface GrepTableProps<T> extends Pick<TableProps, 'size' | 'stickyHead
|
|
|
33
33
|
sortDirection?: 'desc' | 'asc';
|
|
34
34
|
isRowDisabled?: (row: T) => boolean;
|
|
35
35
|
onSelectedRowChange?: (row: T | null) => void;
|
|
36
|
-
onRowClick?: (row: T) => void;
|
|
36
|
+
onRowClick?: (row: T, mouseEvent?: React.MouseEvent) => void;
|
|
37
37
|
menuTooltip?: (row: T) => string;
|
|
38
38
|
menuDisabled?: (row: T) => boolean;
|
|
39
39
|
onContextIdChanged?: (row: T) => void;
|
|
@@ -3,7 +3,7 @@ import { NavigationProps } from '../AppBarNavList';
|
|
|
3
3
|
interface Props {
|
|
4
4
|
title: string;
|
|
5
5
|
pages: NavigationProps[];
|
|
6
|
-
onPageClick: (page: NavigationProps) => unknown;
|
|
6
|
+
onPageClick: (page: NavigationProps, mouseEvent: React.MouseEvent) => unknown;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: React.ComponentType<Props>;
|
|
9
9
|
export default _default;
|
|
@@ -3,7 +3,7 @@ import { NavigationProps } from '..';
|
|
|
3
3
|
export interface SidebarProps {
|
|
4
4
|
currentPageId?: number;
|
|
5
5
|
pages: NavigationProps[];
|
|
6
|
-
onPageClick: (page: NavigationProps) => void;
|
|
6
|
+
onPageClick: (page: NavigationProps, mouseEvent?: React.MouseEvent) => void;
|
|
7
7
|
expandOnIcon?: boolean;
|
|
8
8
|
}
|
|
9
9
|
declare const Sidebar: ({ pages, onPageClick, currentPageId, expandOnIcon, }: SidebarProps) => React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ export declare const useStyles: (params: void, muiStyleOverridesParams?: {
|
|
|
2
2
|
props: Record<string, unknown>;
|
|
3
3
|
ownerState?: Record<string, unknown> | undefined;
|
|
4
4
|
} | undefined) => {
|
|
5
|
-
classes: Record<"root"
|
|
5
|
+
classes: Record<"root", string>;
|
|
6
6
|
theme: import("@mui/material").Theme;
|
|
7
7
|
css: import("tss-react").Css;
|
|
8
8
|
cx: import("tss-react").Cx;
|
package/dist/index.js
CHANGED
|
@@ -1745,7 +1745,17 @@ const DropdownMenu = ({ context, menuItems, ...menuProps }) => {
|
|
|
1745
1745
|
return;
|
|
1746
1746
|
}
|
|
1747
1747
|
menuProps.onClose && menuProps.onClose(e, 'backdropClick');
|
|
1748
|
-
|
|
1748
|
+
handleClick && handleClick(context, e);
|
|
1749
|
+
};
|
|
1750
|
+
props.onMouseDown = (e) => {
|
|
1751
|
+
// 1 = middle mouse button / wheel
|
|
1752
|
+
if (isDisabled || e.button !== 1) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
e.preventDefault();
|
|
1756
|
+
e.stopPropagation();
|
|
1757
|
+
menuProps.onClose && menuProps.onClose(e, 'backdropClick');
|
|
1758
|
+
handleClick && handleClick(context, e);
|
|
1749
1759
|
};
|
|
1750
1760
|
return (React__default.createElement(CollapsableMenuItem, { sx: isDisabled && !children ? { cursor: 'not-allowed' } : {}, level: level, id: label, disabled: isDisabled, items: children?.map(renderChild(level + 1, isDisabled)), ...props },
|
|
1751
1761
|
React__default.createElement("span", { style: style }, label)));
|
|
@@ -1884,12 +1894,18 @@ const Footer = ({ items, serviceNameText, udirLink, udirLogo, }) => {
|
|
|
1884
1894
|
const LinkList = (props) => (React__default.createElement(Box$1, { width: "100%", flexDirection: "column" },
|
|
1885
1895
|
React__default.createElement(Typography$1, { style: { fontSize: 24, color: Colors.black, marginBottom: 20 } }, props.title),
|
|
1886
1896
|
React__default.createElement(List$1, null, props.pages.map((page) => (React__default.createElement(Box$1, { key: page.id },
|
|
1887
|
-
React__default.createElement(ListItemButton, {
|
|
1897
|
+
React__default.createElement(ListItemButton, { onMouseDown: (e) => {
|
|
1898
|
+
if (e.button === 1) {
|
|
1899
|
+
e.stopPropagation();
|
|
1900
|
+
e.preventDefault();
|
|
1901
|
+
}
|
|
1902
|
+
props.onPageClick(page, e);
|
|
1903
|
+
}, style: { padding: '12px 4px' } },
|
|
1888
1904
|
React__default.createElement(ListItemText$1, { primary: page.label, slotProps: {
|
|
1889
1905
|
primary: {
|
|
1890
1906
|
color: 'primary',
|
|
1891
1907
|
style: { fontSize: 18 },
|
|
1892
|
-
}
|
|
1908
|
+
},
|
|
1893
1909
|
} }),
|
|
1894
1910
|
React__default.createElement(ListItemIcon, { style: { justifyContent: 'flex-end' } },
|
|
1895
1911
|
React__default.createElement(ArrowForward, { color: "primary" }))),
|
|
@@ -1914,7 +1930,13 @@ const ContainedLinkList = (props) => {
|
|
|
1914
1930
|
return (React.createElement(Box, { className: classes.container, style: props.style },
|
|
1915
1931
|
React.createElement(Typography, { className: classes.title }, props.title),
|
|
1916
1932
|
React.createElement(List, { style: { padding: 0 } }, props.pages.map((page) => (React.createElement(ListItem, { divider: true, key: page.id, disablePadding: true },
|
|
1917
|
-
React.createElement(ListItemButton, {
|
|
1933
|
+
React.createElement(ListItemButton, { onMouseDown: (e) => {
|
|
1934
|
+
if (e.button === 1) {
|
|
1935
|
+
e.preventDefault();
|
|
1936
|
+
e.stopPropagation();
|
|
1937
|
+
}
|
|
1938
|
+
props.onPageClick(page, e);
|
|
1939
|
+
} },
|
|
1918
1940
|
page.linkIcon && React.createElement(ListItemIcon, null, page.linkIcon),
|
|
1919
1941
|
React.createElement(ListItemText, { primary: page.label }))))))));
|
|
1920
1942
|
};
|
|
@@ -2172,9 +2194,9 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2172
2194
|
setDropdownContext(row);
|
|
2173
2195
|
setMenuAnchor(e.currentTarget);
|
|
2174
2196
|
};
|
|
2175
|
-
const _handleRowClick = useCallback((row) => {
|
|
2176
|
-
const disabled = isRowDisabled && isRowDisabled(row);
|
|
2177
|
-
!disabled && onRowClick && onRowClick(row);
|
|
2197
|
+
const _handleRowClick = useCallback((row, event) => {
|
|
2198
|
+
const disabled = (isRowDisabled && isRowDisabled(row)) ?? false;
|
|
2199
|
+
!disabled && onRowClick && onRowClick(row, event);
|
|
2178
2200
|
}, [onRowClick]);
|
|
2179
2201
|
const _handlePageChange = (event, newPage) => {
|
|
2180
2202
|
event && event.preventDefault();
|
|
@@ -2239,7 +2261,12 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2239
2261
|
else {
|
|
2240
2262
|
setSelectedElement(e.currentTarget);
|
|
2241
2263
|
if (!disableSelectOnClick) {
|
|
2242
|
-
|
|
2264
|
+
const me = e;
|
|
2265
|
+
if (me.button === 1) {
|
|
2266
|
+
e.preventDefault();
|
|
2267
|
+
e.stopPropagation();
|
|
2268
|
+
}
|
|
2269
|
+
_handleRowClick(row, me);
|
|
2243
2270
|
}
|
|
2244
2271
|
}
|
|
2245
2272
|
}, columns: rowColumns, row: row, style: getRowStyle(row, index, clickableRows, disabled), onFocus: (e) => {
|
|
@@ -3196,12 +3223,12 @@ const Sidebar = ({ pages, onPageClick, currentPageId, expandOnIcon, }) => {
|
|
|
3196
3223
|
setExpanded([...expanded, id]);
|
|
3197
3224
|
}
|
|
3198
3225
|
};
|
|
3199
|
-
const handleClick = (page) => {
|
|
3226
|
+
const handleClick = (page, mouseEvent) => {
|
|
3200
3227
|
if (expandOnIcon) {
|
|
3201
|
-
onPageClick(page);
|
|
3228
|
+
onPageClick(page, mouseEvent);
|
|
3202
3229
|
}
|
|
3203
3230
|
else {
|
|
3204
|
-
page.children ? toggleExpand(page.id) : onPageClick(page);
|
|
3231
|
+
page.children ? toggleExpand(page.id) : onPageClick(page, mouseEvent);
|
|
3205
3232
|
}
|
|
3206
3233
|
};
|
|
3207
3234
|
const renderItem = (page) => (React__default.createElement(React__default.Fragment, null,
|
|
@@ -3212,7 +3239,8 @@ const Sidebar = ({ pages, onPageClick, currentPageId, expandOnIcon, }) => {
|
|
|
3212
3239
|
if (expanded.includes(page.id)) {
|
|
3213
3240
|
if (expandOnIcon) {
|
|
3214
3241
|
return (React__default.createElement(ExpandLess, { onClick: (e) => {
|
|
3215
|
-
e.stopPropagation()
|
|
3242
|
+
e.stopPropagation();
|
|
3243
|
+
toggleExpand(page.id);
|
|
3216
3244
|
} }));
|
|
3217
3245
|
}
|
|
3218
3246
|
else {
|
|
@@ -3222,7 +3250,8 @@ const Sidebar = ({ pages, onPageClick, currentPageId, expandOnIcon, }) => {
|
|
|
3222
3250
|
else {
|
|
3223
3251
|
if (expandOnIcon) {
|
|
3224
3252
|
return (React__default.createElement(ExpandMore, { onClick: (e) => {
|
|
3225
|
-
e.stopPropagation()
|
|
3253
|
+
e.stopPropagation();
|
|
3254
|
+
toggleExpand(page.id);
|
|
3226
3255
|
} }));
|
|
3227
3256
|
}
|
|
3228
3257
|
else {
|
|
@@ -3234,11 +3263,11 @@ const Sidebar = ({ pages, onPageClick, currentPageId, expandOnIcon, }) => {
|
|
|
3234
3263
|
};
|
|
3235
3264
|
return (React__default.createElement(Box$1, { className: classes.container },
|
|
3236
3265
|
React__default.createElement(List$1, null, pages.map((page) => (React__default.createElement("div", { key: page.id },
|
|
3237
|
-
React__default.createElement(ListItem$1, { key: page.id, tabIndex: 0, className: classes.item,
|
|
3266
|
+
React__default.createElement(ListItem$1, { key: page.id, tabIndex: 0, className: classes.item, onMouseDown: (e) => handleClick(page, e), onKeyPress: keyboard.onActivation(() => handleClick(page)) },
|
|
3238
3267
|
renderItem(page),
|
|
3239
3268
|
renderExpandIcon(page)),
|
|
3240
3269
|
React__default.createElement(Collapse$1, { in: expanded.includes(page.id), timeout: "auto", unmountOnExit: true },
|
|
3241
|
-
React__default.createElement(List$1, { disablePadding: true }, page.children?.map((child) => (React__default.createElement(ListItem$1, { key: child.id, style: { paddingLeft: '30px' }, tabIndex: 0, className: classes.item,
|
|
3270
|
+
React__default.createElement(List$1, { disablePadding: true }, page.children?.map((child) => (React__default.createElement(ListItem$1, { key: child.id, style: { paddingLeft: '30px' }, tabIndex: 0, className: classes.item, onMouseDown: (e) => handleClick(child, e), onKeyPress: keyboard.onActivation(() => handleClick(child)) }, renderItem(child))))))))))));
|
|
3242
3271
|
};
|
|
3243
3272
|
|
|
3244
3273
|
var useStyles$4 = makeStyles()(() => ({
|
|
@@ -10292,19 +10321,6 @@ const useStyles = makeStyles()(() => ({
|
|
|
10292
10321
|
background: 'transparent' /* Optional: just make scrollbar invisible */,
|
|
10293
10322
|
},
|
|
10294
10323
|
},
|
|
10295
|
-
keyboardHint: {
|
|
10296
|
-
position: 'relative',
|
|
10297
|
-
'&::after': {
|
|
10298
|
-
content: '"innholdsfortegnelse: [ alt + i ]"',
|
|
10299
|
-
fontSize: 12,
|
|
10300
|
-
position: 'absolute',
|
|
10301
|
-
display: 'block',
|
|
10302
|
-
top: 5,
|
|
10303
|
-
right: 5,
|
|
10304
|
-
background: convertToRgba('#000', 0.1),
|
|
10305
|
-
padding: '2px 5px',
|
|
10306
|
-
},
|
|
10307
|
-
},
|
|
10308
10324
|
}));
|
|
10309
10325
|
|
|
10310
10326
|
const getElementLevel = (el) => {
|
|
@@ -10337,7 +10353,6 @@ const buildTree = (elements, normalizer = normalize) => {
|
|
|
10337
10353
|
};
|
|
10338
10354
|
|
|
10339
10355
|
const GrepTableOfContentNav = (props) => {
|
|
10340
|
-
const [showKeyboardHint, setShowKeyboardHint] = useState(false);
|
|
10341
10356
|
const ref = useRef(null);
|
|
10342
10357
|
const { elements, classes, selected, setSelected } = useContext(context);
|
|
10343
10358
|
const tree = useMemo(() => buildTree(Object.values(elements)), [elements]);
|
|
@@ -10355,16 +10370,6 @@ const GrepTableOfContentNav = (props) => {
|
|
|
10355
10370
|
});
|
|
10356
10371
|
}, [ref]);
|
|
10357
10372
|
const onKeyDown = (e) => {
|
|
10358
|
-
if (selected && e.key === Key.Tab && e.shiftKey === false) {
|
|
10359
|
-
const tabindex = selected.getAttribute('tabindex');
|
|
10360
|
-
selected.setAttribute('tabindex', '0');
|
|
10361
|
-
selected.focus();
|
|
10362
|
-
requestAnimationFrame(() => {
|
|
10363
|
-
tabindex === null
|
|
10364
|
-
? selected.removeAttribute('tabindex')
|
|
10365
|
-
: selected.setAttribute('tabindex', tabindex);
|
|
10366
|
-
});
|
|
10367
|
-
}
|
|
10368
10373
|
if (e.key === Key.ArrowUp || e.key === Key.ArrowDown) {
|
|
10369
10374
|
e.preventDefault();
|
|
10370
10375
|
e.stopPropagation();
|
|
@@ -10376,25 +10381,8 @@ const GrepTableOfContentNav = (props) => {
|
|
|
10376
10381
|
focusSelected();
|
|
10377
10382
|
}
|
|
10378
10383
|
};
|
|
10379
|
-
useEffect(() => {
|
|
10380
|
-
const onKeyDown = (e) => {
|
|
10381
|
-
e.key === Key.Alt && setShowKeyboardHint(true);
|
|
10382
|
-
if (e.altKey) {
|
|
10383
|
-
e.key === Key.I && focusSelected();
|
|
10384
|
-
}
|
|
10385
|
-
};
|
|
10386
|
-
const onKeyUp = (e) => {
|
|
10387
|
-
e.key === Key.Alt && setShowKeyboardHint(false);
|
|
10388
|
-
};
|
|
10389
|
-
window.addEventListener('keydown', onKeyDown);
|
|
10390
|
-
window.addEventListener('keyup', onKeyUp);
|
|
10391
|
-
return () => {
|
|
10392
|
-
window.removeEventListener('keydown', onKeyDown);
|
|
10393
|
-
window.removeEventListener('keyup', onKeyUp);
|
|
10394
|
-
};
|
|
10395
|
-
}, [focusSelected]);
|
|
10396
10384
|
const { classes: style } = useStyles();
|
|
10397
|
-
const className = clsx('grep-toc__nav', style.root, classes?.nav, props.className
|
|
10385
|
+
const className = clsx('grep-toc__nav', style.root, classes?.nav, props.className);
|
|
10398
10386
|
return (React__default.createElement("nav", { className: className, style: props.style, tabIndex: selected ? -1 : 0, onKeyDown: onKeyDown, ref: ref },
|
|
10399
10387
|
React__default.createElement(NavTree, { elements: tree, setSelectedValue: props.setSelectedValue, percentageRendered: props.percentageRendered })));
|
|
10400
10388
|
};
|