@ndlib/component-library 0.0.62 → 0.0.65
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/composites/DropdownLinks/index.d.ts +1 -0
- package/dist/components/composites/DropdownLinks/index.js +11 -2
- package/dist/components/elements/Table/Table.stories.d.ts +1 -0
- package/dist/components/elements/Table/Table.stories.js +9 -0
- package/dist/components/elements/Table/index.d.ts +1 -0
- package/dist/components/elements/Table/index.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -11,5 +11,6 @@ type DropdownLinksProps = StyledElementProps<HTMLDivElement, {
|
|
|
11
11
|
renderOption?: RenderOption<string, LinkOption>;
|
|
12
12
|
openNewTab?: boolean;
|
|
13
13
|
}, DropdownChildrenFn>;
|
|
14
|
+
export declare const Overlay: React.FC<StyledElementProps<HTMLDivElement>>;
|
|
14
15
|
export declare const DropdownLinks: React.FC<DropdownLinksProps>;
|
|
15
16
|
export {};
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useCallback, useMemo, useState } from 'react';
|
|
14
14
|
import { autoPlacement, offset, size, useFloating } from '@floating-ui/react';
|
|
15
15
|
import { ListBox } from '../../elements/ListBox';
|
|
@@ -17,6 +17,15 @@ import { Link } from '../../elements/Link';
|
|
|
17
17
|
import { Box } from '../../elements/layout/Box';
|
|
18
18
|
import { useComponentConfig } from '../../providers/componentConfig';
|
|
19
19
|
import { useUniqueId } from '../../providers/uniqueIds';
|
|
20
|
+
import { Z_INDEX } from '../../../theme/custom';
|
|
21
|
+
export const Overlay = (props) => (_jsx(Box, Object.assign({}, props, { sx: {
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
width: '100vw',
|
|
26
|
+
height: '100vh',
|
|
27
|
+
zIndex: Z_INDEX.ELEVATED,
|
|
28
|
+
} })));
|
|
20
29
|
export const DropdownLinks = (_a) => {
|
|
21
30
|
var { children, options: optionsParam, renderOption: renderOptionParam, openNewTab, role = 'navigation' } = _a, rest = __rest(_a, ["children", "options", "renderOption", "openNewTab", "role"]);
|
|
22
31
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -74,5 +83,5 @@ export const DropdownLinks = (_a) => {
|
|
|
74
83
|
return (_jsxs(Box, Object.assign({}, rest, { children: [children &&
|
|
75
84
|
children({
|
|
76
85
|
anchorProps: dropdownAnchorProps,
|
|
77
|
-
}), isOpen && (_jsx(ListBox, { role: role, id: listboxId, options: options, ref: refs.setFloating, renderOption: renderOption, style: Object.assign(Object.assign({ minWidth: dropdownMinWidth }, floatingStyles), { zIndex:
|
|
86
|
+
}), isOpen && (_jsxs(_Fragment, { children: [_jsx(ListBox, { role: role, id: listboxId, options: options, ref: refs.setFloating, renderOption: renderOption, style: Object.assign(Object.assign({ minWidth: dropdownMinWidth }, floatingStyles), { zIndex: Z_INDEX.DIALOG }) }), _jsx(Overlay, { onClick: () => setIsOpen(false) })] }))] })));
|
|
78
87
|
};
|
|
@@ -50,6 +50,15 @@ export const OmitColumn = {
|
|
|
50
50
|
} }, { children: (row) => row.age }))) : null, _jsx(TableColumn, Object.assign({ header: "Occupation" }, { children: (row) => row.position }))] })));
|
|
51
51
|
},
|
|
52
52
|
};
|
|
53
|
+
export const ResponsiveColumn = {
|
|
54
|
+
render: () => {
|
|
55
|
+
return (_jsxs(Table, Object.assign({ data: data, alternateRowColor: true }, { children: [_jsx(TableColumn, { header: "Name", dataKey: "name", sx: {
|
|
56
|
+
width: '160px',
|
|
57
|
+
} }), _jsx(TableColumn, Object.assign({ breakpoint: 2, header: "Age", sx: {
|
|
58
|
+
width: '100px',
|
|
59
|
+
} }, { children: (row) => row.age })), _jsx(TableColumn, Object.assign({ header: "Occupation" }, { children: (row) => row.position }))] })));
|
|
60
|
+
},
|
|
61
|
+
};
|
|
53
62
|
export const ColumnGroup = {
|
|
54
63
|
render: () => {
|
|
55
64
|
return (_jsxs(Table, Object.assign({ data: data, alternateRowColor: true }, { children: [_jsx(TableColumn, { header: "Name", dataKey: "name", sx: {
|
|
@@ -8,6 +8,7 @@ type ColumnProps<RowData extends object> = {
|
|
|
8
8
|
align?: 'left' | 'center' | 'right';
|
|
9
9
|
alignHeader?: 'left' | 'center' | 'right';
|
|
10
10
|
children?: ColumnRenderFn<RowData>;
|
|
11
|
+
breakpoint?: number;
|
|
11
12
|
sx?: StylesProp;
|
|
12
13
|
};
|
|
13
14
|
type ChildList = ChildList[] | JSX.Element | null | undefined;
|
|
@@ -3,6 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { COLOR } from '../../../theme/colors';
|
|
4
4
|
import { useEnvironment } from '../../providers/env';
|
|
5
5
|
import { TYPOGRAPHY_TYPE, typographyStyleMap } from '../../../theme/typography';
|
|
6
|
+
import { useMediaQuery } from '../../providers/media';
|
|
6
7
|
const useColumnSpec = (children) => {
|
|
7
8
|
const headerList = [];
|
|
8
9
|
const parseHeaders = (children) => {
|
|
@@ -43,6 +44,7 @@ export function Table(props) {
|
|
|
43
44
|
const { role, data, alternateRowColor = true, cellStyles, sx, children, showRowDividers = true, showColumnDividers = false, } = props;
|
|
44
45
|
const cellTypographyStyles = typographyStyleMap[TYPOGRAPHY_TYPE.CONDENSED_TEXT_MEDIUM];
|
|
45
46
|
const headerTypographyStyles = typographyStyleMap[TYPOGRAPHY_TYPE.CONTROL_MEDIUM];
|
|
47
|
+
const { breakpoint } = useMediaQuery();
|
|
46
48
|
const columnSpec = useColumnSpec(children);
|
|
47
49
|
const getCellStyles = (params) => {
|
|
48
50
|
const { columnProps, rowIndex, columnIndex } = params;
|
|
@@ -56,9 +58,15 @@ export function Table(props) {
|
|
|
56
58
|
};
|
|
57
59
|
return (_jsxs("table", Object.assign({ role: role, sx: sx }, { children: [_jsx("thead", Object.assign({ role: "rowgroup" }, { children: _jsx("tr", { children: columnSpec.map((column, i) => {
|
|
58
60
|
const isLastColumn = i === columnSpec.length - 1;
|
|
61
|
+
if (column.breakpoint && breakpoint < column.breakpoint) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
59
64
|
return (_jsx("th", Object.assign({ role: "columnheader", sx: Object.assign(Object.assign({ textAlign: column.alignHeader || column.align || 'left', borderBottom: '1px solid', borderRight: showColumnDividers && !isLastColumn ? '1px solid' : 'none', borderColor: COLOR.LIGHT_GRAY, px: 3, pb: 1 }, headerTypographyStyles), column.headerStyles) }, { children: column.header }), i));
|
|
60
65
|
}) }) })), _jsx("tbody", Object.assign({ role: "rowgroup" }, { children: data.map((rowData, rowIndex) => {
|
|
61
66
|
return (_jsx("tr", Object.assign({ role: "row" }, { children: columnSpec.map((column, columnIndex) => {
|
|
67
|
+
if (column.breakpoint && breakpoint < column.breakpoint) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
62
70
|
const { children, dataKey } = column;
|
|
63
71
|
const cellStyles = getCellStyles({
|
|
64
72
|
columnProps: column,
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { TabList, Tab } from './components/elements/TabList';
|
|
|
34
34
|
export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
|
|
35
35
|
export { SnackBar } from './components/composites/SnackBar';
|
|
36
36
|
export { NavMenu } from './components/composites/NavMenu';
|
|
37
|
+
export { MENU_ACTION_TYPE, MENU_ORIENTATION } from './components/providers/menu';
|
|
37
38
|
export { EmptyState, EMPTY_STATE_SIZE, } from './components/composites/EmptyState';
|
|
38
39
|
export { DropdownLinks } from './components/composites/DropdownLinks';
|
|
39
40
|
export { Modal } from './components/composites/Modal';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export { TabList, Tab } from './components/elements/TabList';
|
|
|
33
33
|
export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
|
|
34
34
|
export { SnackBar } from './components/composites/SnackBar';
|
|
35
35
|
export { NavMenu } from './components/composites/NavMenu';
|
|
36
|
+
export { MENU_ACTION_TYPE, MENU_ORIENTATION } from './components/providers/menu';
|
|
36
37
|
export { EmptyState, EMPTY_STATE_SIZE, } from './components/composites/EmptyState';
|
|
37
38
|
export { DropdownLinks } from './components/composites/DropdownLinks';
|
|
38
39
|
export { Modal } from './components/composites/Modal';
|