Socket
Socket
Sign inDemoInstall

@os-design/core

Package Overview
Dependencies
Maintainers
1
Versions
478
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@os-design/core - npm Package Compare versions

Comparing version 0.0.73 to 0.0.74

lib/List/utils/bodyPointerEvents.d.ts

1

lib/Header/index.js

@@ -26,2 +26,3 @@ "use strict";

border-bottom: 1px solid ${p.theme.colorBorder};
z-index: 101;
`;

@@ -28,0 +29,0 @@ const sidebarIndent = (p) => p.sidebarIndent && core_1.css `

3

lib/index.d.ts

@@ -15,3 +15,3 @@ export { default as Alert } from './Alert';

export { default as List } from './List';
export { default as ListItem } from './List/ListItem';
export { default as ListItem } from './ListItem';
export { default as LogoContainer } from './LogoContainer';

@@ -39,2 +39,3 @@ export { default as message } from './message';

export * from './List';
export * from './ListItem';
export * from './LogoContainer';

@@ -41,0 +42,0 @@ export * from './Modal';

@@ -34,3 +34,3 @@ "use strict";

exports.List = List_1.default;
var ListItem_1 = require("./List/ListItem");
var ListItem_1 = require("./ListItem");
exports.ListItem = ListItem_1.default;

@@ -69,2 +69,3 @@ var LogoContainer_1 = require("./LogoContainer");

__export(require("./List"));
__export(require("./ListItem"));
__export(require("./LogoContainer"));

@@ -71,0 +72,0 @@ __export(require("./Modal"));

@@ -5,3 +5,7 @@ import React from 'react';

itemCount: number;
itemHeight?: number;
threshold?: number;
overscanCount?: number;
paddingTop?: number;
paddingBottom?: number;
loadNext?: () => void;

@@ -8,0 +12,0 @@ itemRenderer?: React.FC<ListChildComponentProps>;

@@ -15,51 +15,40 @@ "use strict";

const react_window_1 = require("react-window");
const styled_1 = __importDefault(require("@os-design/styled"));
const utils_1 = require("@os-design/utils");
const styled_1 = __importDefault(require("@os-design/styled"));
const ListContainer = styled_1.default.div `
height: 100%;
const WindowScroller_1 = __importDefault(require("./WindowScroller"));
const useResizedItemHeight_1 = __importDefault(require("./utils/useResizedItemHeight"));
const OuterContainer = styled_1.default.div `
// Set the bottom border between list items
& > div > div > div:not(:last-of-type) {
border-bottom: 1px solid rgba(0,0,0,0.05);
& > div > div:not(:last-of-type) {
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
`;
const List = props => {
const { threshold = 10, loadNext = () => undefined, itemRenderer = () => null, } = props;
const containerRef = react_1.useRef(null);
const [containerHeight, setContainerHeight] = react_1.useState(0);
const [itemHeight, setItemHeight] = react_1.useState(0);
react_1.useEffect(() => {
const getItemHeight = () => {
const { clientWidth } = document.body;
if (clientWidth < utils_1.minBreakpoints.md)
return 60;
if (clientWidth < utils_1.minBreakpoints.xxl)
return 80;
return 90;
};
const resizeHandler = () => {
if (!containerRef.current)
return;
const { clientHeight } = containerRef.current;
if (clientHeight !== containerHeight)
setContainerHeight(clientHeight);
const nextItemHeight = getItemHeight();
if (itemHeight !== nextItemHeight)
setItemHeight(nextItemHeight);
};
const throttledResizeHandler = utils_1.throttling(resizeHandler, 100);
throttledResizeHandler();
window.addEventListener('resize', throttledResizeHandler);
return () => window.removeEventListener('resize', throttledResizeHandler);
}, [containerHeight, itemHeight]);
const { itemHeight = 60, threshold = 10, overscanCount = 10, paddingTop = 0, paddingBottom = 0, loadNext = () => undefined, itemRenderer = () => null, } = props;
const size = utils_1.useWindowSize();
const resizedItemHeight = useResizedItemHeight_1.default(itemHeight);
const listRef = react_1.useRef(null);
const scrollHandler = (p) => {
const clientHeight = containerRef.current ? containerRef.current.clientHeight : 0;
const maxScrollTopBeforeLoad = (props.itemCount - threshold) * itemHeight - clientHeight;
if (p.scrollOffset > maxScrollTopBeforeLoad)
if (listRef.current)
listRef.current.scrollTo(p.scrollTop);
const maxItemBeforeLoad = props.itemCount - threshold;
const maxScrollTopBeforeLoad = maxItemBeforeLoad * resizedItemHeight + paddingTop - size.height;
if (p.scrollTop > maxScrollTopBeforeLoad)
loadNext();
};
return (react_1.default.createElement(ListContainer, { ref: containerRef },
react_1.default.createElement(react_window_1.FixedSizeList, { width: '100%', height: containerHeight, itemSize: itemHeight, itemCount: props.itemCount, onScroll: scrollHandler }, itemRenderer)));
const innerElementType = react_1.forwardRef(({ style, ...rest }, ref) => (react_1.default.createElement("div", Object.assign({ ref: ref, style: {
...style,
height: `${parseFloat(style.height) + paddingTop + paddingBottom}px`,
} }, rest))));
const outerElementType = react_1.forwardRef((p, ref) => (react_1.default.createElement(OuterContainer, Object.assign({ ref: ref }, p))));
return (react_1.default.createElement(WindowScroller_1.default, { onScroll: scrollHandler },
react_1.default.createElement(react_window_1.FixedSizeList, { ref: listRef, width: '100%', height: size.height, itemSize: resizedItemHeight, itemCount: props.itemCount, style: { height: '100% important!' }, overscanCount: overscanCount, innerElementType: innerElementType, outerElementType: outerElementType }, ({ style, ...rest }) => (itemRenderer({
style: {
...style,
top: `${parseFloat(style.top ? style.top.toString() : '0') + paddingTop}px`,
},
...rest,
})))));
};
exports.default = List;
//# sourceMappingURL=index.js.map
{
"name": "@os-design/core",
"version": "0.0.73",
"version": "0.0.74",
"license": "MIT",

@@ -20,7 +20,10 @@ "main": "lib/index.js",

"@emotion/core": "^10.0.22",
"@n8tb1t/use-scroll-position": "^1.0.43",
"@os-design/icons": "^0.0.18",
"@os-design/styled": "^0.0.8",
"@os-design/utils": "^0.0.10",
"@os-design/utils": "^0.0.11",
"@types/facepaint": "^1.2.1",
"facepaint": "^1.2.1",
"react-measure": "^2.3.0",
"react-virtualized": "^9.21.2",
"react-window": "^1.8.5"

@@ -34,5 +37,6 @@ },

"@os-design/theming": "^0.0.8",
"@types/react-measure": "^2.0.5",
"@types/react-window": "^1.8.1"
},
"gitHead": "4672f2c0c0919594d1339ecec7bda97fb0809076"
"gitHead": "0ca64c9b6f5c437bebf48326253c916ae4bdc679"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc