@ndlib/component-library 0.0.61 → 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.
@@ -4,4 +4,5 @@ declare const meta: Meta<typeof DropdownLinks>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof DropdownLinks>;
6
6
  export declare const Default: Story;
7
+ export declare const Right: Story;
7
8
  export declare const OpenInNewTab: Story;
@@ -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: 'Facebook' },
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
  };
@@ -51,7 +51,12 @@ export const DropdownLinks = (_a) => {
51
51
  },
52
52
  }),
53
53
  autoPlacement({
54
- allowedPlacements: ['top-start', 'bottom-start'],
54
+ allowedPlacements: [
55
+ 'top-start',
56
+ 'bottom-start',
57
+ 'top-end',
58
+ 'bottom-end',
59
+ ],
55
60
  }),
56
61
  ],
57
62
  });
@@ -4,3 +4,5 @@ declare const meta: Meta<typeof Table>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof Table>;
6
6
  export declare const Default: Story;
7
+ export declare const OmitColumn: Story;
8
+ export declare const ColumnGroup: Story;
@@ -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: JSX.Element[];
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 columnList = JSON.stringify(children.map((child) => child.props.header));
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
- return children.map((child) => child.props);
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [