@ndlib/component-library 0.0.60 → 0.0.62
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/DropdownLinks.stories.d.ts +1 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +5 -1
- package/dist/components/composites/DropdownLinks/index.js +6 -1
- package/dist/components/composites/StructuredData/StructuredData.test.js +1 -1
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.js +1 -1
- package/dist/components/composites/StructuredData/index.d.ts +1 -1
- package/dist/components/composites/StructuredData/index.js +1 -1
- package/dist/components/elements/Table/Table.stories.d.ts +2 -0
- package/dist/components/elements/Table/Table.stories.js +22 -0
- package/dist/components/elements/Table/index.d.ts +2 -1
- package/dist/components/elements/Table/index.js +26 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
|
|
3
3
|
import { DropdownLinks } from '.';
|
|
4
4
|
import { Button } from '../../elements/Button';
|
|
5
5
|
import { Box } from '../../elements/layout/Box';
|
|
6
|
+
import { Row } from '../../elements/layout/Row';
|
|
6
7
|
const meta = {
|
|
7
8
|
title: 'Composites/DropdownLinks',
|
|
8
9
|
component: DropdownLinks,
|
|
@@ -11,11 +12,14 @@ const meta = {
|
|
|
11
12
|
export default meta;
|
|
12
13
|
const options = [
|
|
13
14
|
{ value: 'https://google.com', label: 'Google' },
|
|
14
|
-
{ value: 'https://facebook.com', label: '
|
|
15
|
+
{ value: 'https://facebook.com', label: 'This is intentionally long' },
|
|
15
16
|
];
|
|
16
17
|
export const Default = {
|
|
17
18
|
render: () => (_jsx(Box, Object.assign({ sx: { width: '200px', height: '200px' } }, { children: _jsx(DropdownLinks, Object.assign({ options: options }, { children: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon }, { children: "Links" }))) })) }))),
|
|
18
19
|
};
|
|
20
|
+
export const Right = {
|
|
21
|
+
render: () => (_jsx(Row, Object.assign({ sx: { width: '90vw', height: '200px' }, justify: "flex-end" }, { children: _jsx(DropdownLinks, Object.assign({ options: options }, { children: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon }, { children: "Links" }))) })) }))),
|
|
22
|
+
};
|
|
19
23
|
export const OpenInNewTab = {
|
|
20
24
|
render: () => (_jsx(Box, Object.assign({ sx: { width: '200px', height: '200px' } }, { children: _jsx(DropdownLinks, Object.assign({ options: options, openNewTab: true }, { children: ({ anchorProps }) => _jsx(Button, Object.assign({}, anchorProps, { children: "Links" })) })) }))),
|
|
21
25
|
};
|
|
@@ -12,7 +12,7 @@ describe('getStructuredDataSchemas', () => {
|
|
|
12
12
|
description: 'Custom Description',
|
|
13
13
|
events: [
|
|
14
14
|
{
|
|
15
|
-
|
|
15
|
+
title: 'Archival Research Lab II: Inside the Archive',
|
|
16
16
|
startDate: '2021-10-13T14:00:00.000Z',
|
|
17
17
|
endDate: '2021-10-13T15:15:00.000Z',
|
|
18
18
|
slug: 'archival-research-lab-2-inside-the-archive-2021-10-13',
|
|
@@ -3,7 +3,7 @@ import { getStructuredDataSchemas } from '../index';
|
|
|
3
3
|
export const StructuredDataDisplay = () => {
|
|
4
4
|
const events = [
|
|
5
5
|
{
|
|
6
|
-
|
|
6
|
+
title: 'Archival Research Lab II: Inside the Archive',
|
|
7
7
|
startDate: '2021-10-13T14:00:00.000Z',
|
|
8
8
|
endDate: '2021-10-13T15:15:00.000Z',
|
|
9
9
|
slug: 'archival-research-lab-2-inside-the-archive-2021-10-13',
|
|
@@ -26,7 +26,7 @@ export const getStructuredDataSchemas = ({ title, description, nofollow, noindex
|
|
|
26
26
|
}));
|
|
27
27
|
events === null || events === void 0 ? void 0 : events.map((event) => {
|
|
28
28
|
schemas.push(stringifyEventSchema({
|
|
29
|
-
title: event.
|
|
29
|
+
title: event.title,
|
|
30
30
|
description: event.shortDescription,
|
|
31
31
|
image: event.representationalImage.url,
|
|
32
32
|
url: event.slug,
|
|
@@ -40,3 +40,25 @@ export const Default = {
|
|
|
40
40
|
width: '100px',
|
|
41
41
|
} }, { children: (row) => row.age })), _jsx(TableColumn, Object.assign({ header: "Occupation" }, { children: (row) => row.position }))] }))),
|
|
42
42
|
};
|
|
43
|
+
export const OmitColumn = {
|
|
44
|
+
render: () => {
|
|
45
|
+
const someCondition = false;
|
|
46
|
+
return (_jsxs(Table, Object.assign({ data: data, alternateRowColor: true }, { children: [_jsx(TableColumn, { header: "Name", dataKey: "name", sx: {
|
|
47
|
+
width: '160px',
|
|
48
|
+
} }), someCondition ? (_jsx(TableColumn, Object.assign({ header: "Age", sx: {
|
|
49
|
+
width: '100px',
|
|
50
|
+
} }, { children: (row) => row.age }))) : null, _jsx(TableColumn, Object.assign({ header: "Occupation" }, { children: (row) => row.position }))] })));
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const ColumnGroup = {
|
|
54
|
+
render: () => {
|
|
55
|
+
return (_jsxs(Table, Object.assign({ data: data, alternateRowColor: true }, { children: [_jsx(TableColumn, { header: "Name", dataKey: "name", sx: {
|
|
56
|
+
width: '160px',
|
|
57
|
+
} }), [
|
|
58
|
+
_jsx(TableColumn, Object.assign({ header: "Age", sx: {
|
|
59
|
+
width: '100px',
|
|
60
|
+
} }, { children: (row) => row.age })),
|
|
61
|
+
_jsx(TableColumn, Object.assign({ header: "Occupation" }, { children: (row) => row.position })),
|
|
62
|
+
]] })));
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -10,9 +10,10 @@ type ColumnProps<RowData extends object> = {
|
|
|
10
10
|
children?: ColumnRenderFn<RowData>;
|
|
11
11
|
sx?: StylesProp;
|
|
12
12
|
};
|
|
13
|
+
type ChildList = ChildList[] | JSX.Element | null | undefined;
|
|
13
14
|
type TableProps<RowData> = StyledElementProps<HTMLTableElement, {
|
|
14
15
|
data: RowData[];
|
|
15
|
-
children:
|
|
16
|
+
children: ChildList[];
|
|
16
17
|
cellStyles?: StylesProp;
|
|
17
18
|
alternateRowColor?: boolean;
|
|
18
19
|
showRowDividers?: boolean;
|
|
@@ -4,9 +4,33 @@ import { COLOR } from '../../../theme/colors';
|
|
|
4
4
|
import { useEnvironment } from '../../providers/env';
|
|
5
5
|
import { TYPOGRAPHY_TYPE, typographyStyleMap } from '../../../theme/typography';
|
|
6
6
|
const useColumnSpec = (children) => {
|
|
7
|
-
const
|
|
7
|
+
const headerList = [];
|
|
8
|
+
const parseHeaders = (children) => {
|
|
9
|
+
children.forEach((child) => {
|
|
10
|
+
if (Array.isArray(child)) {
|
|
11
|
+
parseHeaders(child);
|
|
12
|
+
}
|
|
13
|
+
else if (child) {
|
|
14
|
+
headerList.push(child.props.header);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
parseHeaders(children);
|
|
19
|
+
const columnList = JSON.stringify(headerList);
|
|
8
20
|
return useMemo(() => {
|
|
9
|
-
|
|
21
|
+
const columnProps = [];
|
|
22
|
+
const parseColumnProps = (children) => {
|
|
23
|
+
children.forEach((child) => {
|
|
24
|
+
if (Array.isArray(child)) {
|
|
25
|
+
parseColumnProps(child);
|
|
26
|
+
}
|
|
27
|
+
else if (child) {
|
|
28
|
+
columnProps.push(child.props);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
parseColumnProps(children);
|
|
33
|
+
return columnProps;
|
|
10
34
|
}, [columnList]);
|
|
11
35
|
};
|
|
12
36
|
export function TableColumn(props) {
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { StructuredData } from './components/composites/StructuredData';
|
|
|
43
43
|
export { UiProvider } from './components/providers/ui';
|
|
44
44
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
|
45
45
|
export { SnackBarProvider, useSnackBar } from './components/providers/snackBar';
|
|
46
|
-
export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
|
|
46
|
+
export { useAlerts, AlertsProvider, ALERT_TYPE, ALERT_DOMAIN, } from './components/providers/alerts';
|
|
47
47
|
export { MediaSizeProvider, useMediaQuery } from './components/providers/media';
|
|
48
48
|
export { DialogsProvider, useDialog } from './components/providers/dialogs';
|
|
49
49
|
export { useUniqueId } from './components/providers/uniqueIds';
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export { StructuredData } from './components/composites/StructuredData';
|
|
|
42
42
|
export { UiProvider } from './components/providers/ui';
|
|
43
43
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
|
44
44
|
export { SnackBarProvider, useSnackBar } from './components/providers/snackBar';
|
|
45
|
-
export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
|
|
45
|
+
export { useAlerts, AlertsProvider, ALERT_TYPE, ALERT_DOMAIN, } from './components/providers/alerts';
|
|
46
46
|
export { MediaSizeProvider, useMediaQuery } from './components/providers/media';
|
|
47
47
|
export { DialogsProvider, useDialog } from './components/providers/dialogs';
|
|
48
48
|
export { useUniqueId } from './components/providers/uniqueIds';
|