@carto/ps-react-ui 1.1.1 → 1.2.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/ps-react-ui.js +10151 -9091
- package/dist/types/components/button-warning/button-warning.component.d.ts +31 -0
- package/dist/types/components/button-warning/icon-button-warning.d.ts +31 -0
- package/dist/types/components/button-warning/styles.d.ts +29 -0
- package/dist/types/components/button-warning/types.d.ts +16 -0
- package/dist/types/components/grouped-chips/grouped-chips.component.d.ts +30 -0
- package/dist/types/components/grouped-chips/types.d.ts +13 -0
- package/dist/types/components/index.d.ts +21 -1
- package/dist/types/components/input-file/{InputFile.d.ts → input-file.component.d.ts} +16 -0
- package/dist/types/components/list/list.component.d.ts +36 -0
- package/dist/types/components/list/types.d.ts +20 -0
- package/dist/types/components/section-container/section-container.component.d.ts +27 -0
- package/dist/types/components/section-container/types.d.ts +9 -0
- package/dist/types/components/selects/autocomplete-select/autocomplete-select-option.component.d.ts +2 -0
- package/dist/types/components/selects/autocomplete-select/autocomplete-select.component.d.ts +43 -0
- package/dist/types/components/selects/autocomplete-select/listbox-select.component.d.ts +19 -0
- package/dist/types/components/selects/simple-select/create-options-from-array.utils.d.ts +2 -0
- package/dist/types/components/selects/simple-select/simple-select.component.d.ts +25 -0
- package/dist/types/components/selects/types.d.ts +23 -0
- package/dist/types/components/table/components/table-body.component.d.ts +32 -0
- package/dist/types/components/table/components/table-cell.component.d.ts +31 -0
- package/dist/types/components/table/components/table-header.component.d.ts +27 -0
- package/dist/types/components/table/table.component.d.ts +39 -0
- package/dist/types/components/table/types.d.ts +90 -0
- package/dist/types/components/table/utils.d.ts +4 -0
- package/dist/types/components/tabs-to-anchor/tabs-to-anchor.component.d.ts +25 -0
- package/dist/types/components/tabs-to-anchor/types.d.ts +8 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +12 -9
@@ -0,0 +1,31 @@
|
|
1
|
+
import { ButtonWarningProps } from './types';
|
2
|
+
export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"buttonWarning">;
|
3
|
+
/**
|
4
|
+
* ButtonWarning component is used to display a warning button with a custom style.
|
5
|
+
*
|
6
|
+
* @param {ButtonWarningProps} props - Material UI Button props
|
7
|
+
*
|
8
|
+
* @defaultValues
|
9
|
+
*
|
10
|
+
* | Prop | Value |
|
11
|
+
* | --- | --- |
|
12
|
+
* | `variant` | `'contained'` |
|
13
|
+
* | `size` | `'medium'` |
|
14
|
+
*
|
15
|
+
* @remarks
|
16
|
+
* The ButtonWarning component is a wrapper around the Material UI Button component. More information about the props can be found here: https://v4.mui.com/api/button/
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
*
|
20
|
+
* ```jsx
|
21
|
+
* <ButtonWarning
|
22
|
+
* variant="contained"
|
23
|
+
* size="medium"
|
24
|
+
* startIcon={<Icon />}
|
25
|
+
* endIcon={<Icon />}
|
26
|
+
* disabled={false}
|
27
|
+
* onClick={(): void => {}}
|
28
|
+
* >
|
29
|
+
* ```
|
30
|
+
*/
|
31
|
+
export declare function ButtonWarning({ children, variant, size, startIcon, endIcon, disabled, onClick, ...props }: ButtonWarningProps): JSX.Element;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { IconButtonWarningProps } from './types';
|
2
|
+
export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"buttonWarning" | "iconButtonWarning">;
|
3
|
+
/**
|
4
|
+
* IconButtonWarning component is used to display a warning button with a custom style.
|
5
|
+
*
|
6
|
+
* @param {IconButtonWarningProps} props
|
7
|
+
*
|
8
|
+
* @defaultValues
|
9
|
+
*
|
10
|
+
* | Prop | Value |
|
11
|
+
* | --- | --- |
|
12
|
+
* | `variant` | `'text'` |
|
13
|
+
* | `size` | `'medium'` |
|
14
|
+
*
|
15
|
+
* @remarks
|
16
|
+
* The ButtonWarning component is a wrapper around the Material UI Button component. More information about the props can be found here: https://v4.mui.com/api/icon-button/
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
*
|
20
|
+
* ```jsx
|
21
|
+
* <ButtonWarning
|
22
|
+
* variant="contained"
|
23
|
+
* size="medium"
|
24
|
+
* startIcon={<Icon />}
|
25
|
+
* endIcon={<Icon />}
|
26
|
+
* disabled={false}
|
27
|
+
* onClick={(): void => {}}
|
28
|
+
* >
|
29
|
+
* ```
|
30
|
+
*/
|
31
|
+
export declare function IconButtonWarning({ children, variant, size, disabled, onClick, ...props }: IconButtonWarningProps): JSX.Element;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Theme } from '@material-ui/core';
|
2
|
+
export declare const styles: ({ palette }: Theme) => {
|
3
|
+
buttonWarning: {
|
4
|
+
backgroundColor: string;
|
5
|
+
color: string;
|
6
|
+
'&:hover': {
|
7
|
+
backgroundColor: string;
|
8
|
+
};
|
9
|
+
'&.text': {
|
10
|
+
backgroundColor: string;
|
11
|
+
color: string;
|
12
|
+
'&:hover': {
|
13
|
+
backgroundColor: string;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
'&.outlined': {
|
17
|
+
backgroundColor: string;
|
18
|
+
borderColor: string;
|
19
|
+
color: string;
|
20
|
+
'&:hover': {
|
21
|
+
borderColor: string;
|
22
|
+
color: string;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
'&.Mui-disabled': {
|
26
|
+
opacity: number;
|
27
|
+
};
|
28
|
+
};
|
29
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { ButtonProps } from '@material-ui/core';
|
2
|
+
interface ButtonWarningBase extends ButtonProps {
|
3
|
+
variant?: 'text' | 'outlined' | 'contained';
|
4
|
+
children: JSX.Element;
|
5
|
+
disabled?: boolean;
|
6
|
+
onClick?: () => void;
|
7
|
+
}
|
8
|
+
export interface IconButtonWarningProps extends ButtonWarningBase {
|
9
|
+
size?: 'medium' | 'small';
|
10
|
+
}
|
11
|
+
export interface ButtonWarningProps extends ButtonWarningBase {
|
12
|
+
size?: 'medium' | 'small' | 'large';
|
13
|
+
startIcon?: JSX.Element;
|
14
|
+
endIcon?: JSX.Element;
|
15
|
+
}
|
16
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { GroupedChipsProps } from './types';
|
2
|
+
/**
|
3
|
+
* GroupedChips component is used to group chips in a single component.
|
4
|
+
*
|
5
|
+
* @param {GroupedChipsProps} props - Material UI Chip props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `size` | `'medium'` |
|
12
|
+
*
|
13
|
+
* @remarks
|
14
|
+
* The Chip component is a wrapper around the Material UI Chip component. More information about the props can be found here: https://v4.mui.com/api/chip/
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
*
|
18
|
+
* ```jsx
|
19
|
+
* <GroupedChips
|
20
|
+
* items={[
|
21
|
+
* { id: '1', label: 'Option 1' },
|
22
|
+
* { id: '2', label: 'Option 2' },
|
23
|
+
* ]}
|
24
|
+
* label='Select'
|
25
|
+
* size='small'
|
26
|
+
* onDelete={onDelete}
|
27
|
+
* />;
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
export declare function GroupedChips({ label, items, size, onDelete, ChipProps, BoxProps, }: GroupedChipsProps): JSX.Element;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { BoxProps, ChipProps } from '@material-ui/core';
|
2
|
+
export interface GroupedChipsOption {
|
3
|
+
id: string | number;
|
4
|
+
label: string;
|
5
|
+
}
|
6
|
+
export interface GroupedChipsProps {
|
7
|
+
label?: string;
|
8
|
+
items: GroupedChipsOption[];
|
9
|
+
size?: 'small' | 'medium';
|
10
|
+
onDelete: (item: GroupedChipsOption) => void;
|
11
|
+
ChipProps?: ChipProps;
|
12
|
+
BoxProps?: BoxProps;
|
13
|
+
}
|
@@ -1,2 +1,22 @@
|
|
1
|
-
export {
|
1
|
+
export { ButtonWarning } from './button-warning/button-warning.component';
|
2
|
+
export { IconButtonWarning } from './button-warning/icon-button-warning';
|
3
|
+
export * from './button-warning/types';
|
4
|
+
export { GroupedChips } from './grouped-chips/grouped-chips.component';
|
5
|
+
export * from './grouped-chips/types';
|
6
|
+
export { InputFile } from './input-file/input-file.component';
|
2
7
|
export * from './input-file/types';
|
8
|
+
export { List } from './list/list.component';
|
9
|
+
export * from './list/types';
|
10
|
+
export { SectionContainer } from './section-container/section-container.component';
|
11
|
+
export * from './section-container/types';
|
12
|
+
export { SimpleSelect } from './selects/simple-select/simple-select.component';
|
13
|
+
export { AutocompleteSelect } from './selects/autocomplete-select/autocomplete-select.component';
|
14
|
+
export { createOptionsFromArray } from './selects/simple-select/create-options-from-array.utils';
|
15
|
+
export * from './selects/types';
|
16
|
+
export { Table } from './table/table.component';
|
17
|
+
export { TableHeader } from './table/components/table-header.component';
|
18
|
+
export { TableBody } from './table/components/table-body.component';
|
19
|
+
export { TableCell } from './table/components/table-cell.component';
|
20
|
+
export * from './table/types';
|
21
|
+
export { TabsToAnchor } from './tabs-to-anchor/tabs-to-anchor.component';
|
22
|
+
export * from './tabs-to-anchor/types';
|
@@ -4,6 +4,22 @@ import { InputFileProps } from './types';
|
|
4
4
|
*
|
5
5
|
* @param {InputFileProps} props - InputFile props
|
6
6
|
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `id` | `'fileupload'` |
|
12
|
+
* | `placeholder` | `'Upload file'` |
|
13
|
+
* | `buttonText` | `'Browse'` |
|
14
|
+
* | `multipleSummaryText` | `'files selected'` |
|
15
|
+
* | `accept` | `'application/JSON'` |
|
16
|
+
* | `multiple` | `false` |
|
17
|
+
* | `required` | `false` |
|
18
|
+
* | `disabled` | `false` |
|
19
|
+
* | `error` | `false` |
|
20
|
+
* | `variant` | `'outlined'` |
|
21
|
+
* | `defaultValue` | `[]` |
|
22
|
+
*
|
7
23
|
* @example
|
8
24
|
*
|
9
25
|
* ```ts
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ListProps } from './types';
|
2
|
+
/**
|
3
|
+
* List component with two columns and collapse mode.
|
4
|
+
*
|
5
|
+
* @param {ListProps} props - Material UI List props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | :--- | :--- |
|
11
|
+
* | itemsToShow | `10` |
|
12
|
+
* | texts | `{ showMore: 'View all', showLess: 'Collapse list' }` |
|
13
|
+
* | dense | `false` |
|
14
|
+
*
|
15
|
+
* @remarks
|
16
|
+
* The List component is a wrapper around the Material UI List component. More information about the props can be found here: https://v4.mui.com/api/list/
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
*
|
20
|
+
* ```jsx
|
21
|
+
* <List
|
22
|
+
* items={[
|
23
|
+
* { id: '1', label: 'Option 1', value: 1 },
|
24
|
+
* { id: '2', label: 'Option 2', value: 2 },
|
25
|
+
* ]}
|
26
|
+
* label='List Widget'
|
27
|
+
* unit='$'
|
28
|
+
* itemsToShow={2}
|
29
|
+
* texts={{ showMore: 'View all', showLess: 'Collapse list' }}
|
30
|
+
* dense={false}
|
31
|
+
* formatter={(value) => value.toFixed(2)}
|
32
|
+
* onRowClick={(event, item) => console.log(item)}
|
33
|
+
* />;
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
export declare function List({ items, label, unit, itemsToShow, texts: { showMore, showLess }, formatter, onRowClick, ListProps, }: ListProps): JSX.Element;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { MouseEvent } from 'react';
|
2
|
+
import type { ListProps as MateriaListProps } from '@material-ui/core';
|
3
|
+
export interface ListItem {
|
4
|
+
id: string | number;
|
5
|
+
name: string;
|
6
|
+
value: string | number;
|
7
|
+
}
|
8
|
+
export interface ListProps {
|
9
|
+
items: ListItem[];
|
10
|
+
label?: string;
|
11
|
+
itemsToShow?: number;
|
12
|
+
texts?: {
|
13
|
+
showMore?: string;
|
14
|
+
showLess?: string;
|
15
|
+
};
|
16
|
+
unit?: string;
|
17
|
+
formatter?: (value: string | number) => string;
|
18
|
+
onRowClick?: (event: MouseEvent<HTMLDivElement>, item: ListItem) => void;
|
19
|
+
ListProps?: MateriaListProps;
|
20
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { SectionContainerProps } from './types';
|
2
|
+
/**
|
3
|
+
* `SectionContainer` component is used to group content in a section with a sticky title with an optional anchor.
|
4
|
+
*
|
5
|
+
* @param {SectionContainerProps} props - SectionContainer props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `anchor` | `false` |
|
12
|
+
* | `scrollMarginTop` | `0` |
|
13
|
+
*
|
14
|
+
* @example
|
15
|
+
*
|
16
|
+
* ```ts
|
17
|
+
* <SectionContainer
|
18
|
+
* title='Section title'
|
19
|
+
* id='section-id'
|
20
|
+
* anchor={true}
|
21
|
+
* scrollMarginTop={0}
|
22
|
+
* >
|
23
|
+
* <Box>Content</Box>
|
24
|
+
* </SectionContainer>
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
export declare function SectionContainer({ title, id, anchor, scrollMarginTop, children, BoxProps, }: SectionContainerProps): JSX.Element;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { AutocompleteSelectProps } from '../types';
|
2
|
+
/**
|
3
|
+
* AutocompleteSelect component
|
4
|
+
*
|
5
|
+
* @param {AutocompleteSelectProps} props - Material UI Autocomplete props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `grouped` | `false` |
|
12
|
+
* | `hasAll` | `false` |
|
13
|
+
* | `placeholder` | `'Select'` |
|
14
|
+
* | `selectAllLabel` | `'Select all'` |
|
15
|
+
* | `size` | `'small'` |
|
16
|
+
*
|
17
|
+
* @remarks
|
18
|
+
* The AutocompleteSelect component is a wrapper around the Material UI Autocomplete component. More information about the props can be found here: https://v4.mui.com/api/autocomplete
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
*
|
22
|
+
* ```jsx
|
23
|
+
* <AutocompleteSelect
|
24
|
+
* options={[
|
25
|
+
* { value: '1', label: 'Option 1' },
|
26
|
+
* { value: '2', label: 'Option 2' },
|
27
|
+
* ]}
|
28
|
+
* hasAll={true}
|
29
|
+
* grouped={true}
|
30
|
+
* label='Select'
|
31
|
+
* divisionType={{
|
32
|
+
* singular: 'option',
|
33
|
+
* plural: 'options',
|
34
|
+
* }}
|
35
|
+
* placeholder='Select'
|
36
|
+
* selectAllLabel='Select all'
|
37
|
+
* size='small'
|
38
|
+
* value={value}
|
39
|
+
* onChange={onChange}
|
40
|
+
* />;
|
41
|
+
* ```
|
42
|
+
*/
|
43
|
+
export declare function AutocompleteSelect({ options, grouped, hasAll, label, placeholder, selectAllLabel, size, value, onChange, ...props }: AutocompleteSelectProps): JSX.Element;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
2
|
+
export declare type Props = PropsWithChildren<unknown> & {
|
3
|
+
hasAll: boolean;
|
4
|
+
grouped: boolean;
|
5
|
+
some: number;
|
6
|
+
selectAll: boolean;
|
7
|
+
selectAllLabel: string;
|
8
|
+
onChange: (state: boolean) => void;
|
9
|
+
};
|
10
|
+
export declare const ListboxSelect: React.ForwardRefExoticComponent<{
|
11
|
+
children?: React.ReactNode;
|
12
|
+
} & {
|
13
|
+
hasAll: boolean;
|
14
|
+
grouped: boolean;
|
15
|
+
some: number;
|
16
|
+
selectAll: boolean;
|
17
|
+
selectAllLabel: string;
|
18
|
+
onChange: (state: boolean) => void;
|
19
|
+
} & React.RefAttributes<HTMLUListElement>>;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { SimpleSelectProps } from '../types';
|
2
|
+
/**
|
3
|
+
* SimpleSelect component
|
4
|
+
*
|
5
|
+
* @param {SimpleSelectProps} props - Material UI Select props
|
6
|
+
*
|
7
|
+
* @remarks
|
8
|
+
* The SimpleSelect component is a wrapper around the Material UI Select component. More information about the props can be found here: https://v4.mui.com/api/select/
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
*
|
12
|
+
* ```jsx
|
13
|
+
* <SimpleSelect
|
14
|
+
* options={[
|
15
|
+
* { label: 'Option 1', value: '1' },
|
16
|
+
* { label: 'Option 2', value: '2' },
|
17
|
+
* ]}
|
18
|
+
* label='Select'
|
19
|
+
* placeholder='Select an option'
|
20
|
+
* value={value}
|
21
|
+
* onChange={onChange}
|
22
|
+
* >
|
23
|
+
* ```
|
24
|
+
*/
|
25
|
+
export declare function SimpleSelect({ options, label, placeholder, value, onChange, ...props }: SimpleSelectProps): JSX.Element;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { ChangeEvent, ReactNode } from 'react';
|
2
|
+
import type { SelectProps } from '@material-ui/core/Select';
|
3
|
+
import { AutocompleteChangeDetails, AutocompleteChangeReason, AutocompleteProps, AutocompleteRenderOptionState, Value } from '@material-ui/lab';
|
4
|
+
export interface SelectOption {
|
5
|
+
label: string;
|
6
|
+
value: string | number;
|
7
|
+
group?: string;
|
8
|
+
}
|
9
|
+
export interface SimpleSelectProps extends SelectProps {
|
10
|
+
options: SelectOption[];
|
11
|
+
placeholder?: string;
|
12
|
+
}
|
13
|
+
export interface OptionProps<T = SelectOption> {
|
14
|
+
option: T;
|
15
|
+
state: AutocompleteRenderOptionState;
|
16
|
+
}
|
17
|
+
export interface AutocompleteSelectProps<T = SelectOption, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined> extends Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, 'onChange'> {
|
18
|
+
grouped?: boolean;
|
19
|
+
hasAll?: boolean;
|
20
|
+
label?: ReactNode;
|
21
|
+
selectAllLabel?: string;
|
22
|
+
onChange: (event: ChangeEvent<unknown>, options: Value<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, detail?: AutocompleteChangeDetails<T>) => void;
|
23
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { TableBodyProps, TData } from '../types';
|
2
|
+
/**
|
3
|
+
* `TableBody` component is a wrapper for Material-UI TableBody component.
|
4
|
+
*
|
5
|
+
* @param {TableBodyProps} props - TableBody props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `orderBy` | `'id'` |
|
12
|
+
*
|
13
|
+
* @remarks
|
14
|
+
* The TableBody component is a wrapper around the Material UI TableBody component. More information about the props can be found here: https://v4.mui.com/api/table-body/
|
15
|
+
*
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
*
|
19
|
+
* ```ts
|
20
|
+
* <TableBody
|
21
|
+
* columns={COLUMNS}
|
22
|
+
* order='asc'
|
23
|
+
* page={0}
|
24
|
+
* rows={ROWS}
|
25
|
+
* rowPerPage={10}
|
26
|
+
* selected={[]}
|
27
|
+
* remote={false}
|
28
|
+
* dense={false}
|
29
|
+
* />
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
export declare function TableBody<T extends TData>({ columns, order, page, rows, rowsPerPage, selected, clickable, coloredRow, dense, orderBy, pagination, remote, selectable, sortable, onRowClick, onSelect, }: TableBodyProps<T>): JSX.Element;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { TableCellProps, TData } from '../types';
|
2
|
+
/**
|
3
|
+
* `TableCell` component is a wrapper for Material-UI TableCell component.
|
4
|
+
*
|
5
|
+
* @param {TableCellProps} props - TableCell props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `disabled` | `false` |
|
12
|
+
* | `noBorder` | `false` |
|
13
|
+
* | `clickable` | `false` |
|
14
|
+
*
|
15
|
+
* @remarks
|
16
|
+
* The TableCell component is a wrapper around the Material UI TableCell component. More information about the props can be found here: https://v4.mui.com/api/table-cell/
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
*
|
20
|
+
* ```ts
|
21
|
+
* <TableCell
|
22
|
+
* columns={COLUMNS}
|
23
|
+
* row={ROW}
|
24
|
+
* disabled={false}
|
25
|
+
* noBorder={false}
|
26
|
+
* clickable={true}
|
27
|
+
* onClick={handleClick}
|
28
|
+
* />
|
29
|
+
* ```
|
30
|
+
*/
|
31
|
+
export declare function TableCell<T extends TData>({ column, row, disabled, noBorder, clickable, onClick, }: TableCellProps<T>): JSX.Element;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { TableHeaderProps } from '../types';
|
2
|
+
/**
|
3
|
+
* `TableHeader` component is a wrapper for Material-UI TableHead component.
|
4
|
+
*
|
5
|
+
* @param {TableHeaderProps} props - TableHeader props
|
6
|
+
*
|
7
|
+
* @remarks
|
8
|
+
* The TableHeader component is a wrapper around the Material UI TableHead component. More information about the props can be found here: https://v4.mui.com/api/table-head/
|
9
|
+
*
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* <TableHeader
|
15
|
+
* columns={COLUMNS}
|
16
|
+
* selectable={true}
|
17
|
+
* sortable={true}
|
18
|
+
* order='asc'
|
19
|
+
* orderBy='id'
|
20
|
+
* numSelected={1}
|
21
|
+
* rowCount={2}
|
22
|
+
* onSelectAll={() => {}}
|
23
|
+
* onSort={() => {}}
|
24
|
+
* />
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
export declare function TableHeader({ columns, selectable, sortable, order, orderBy, numSelected, rowCount, dense, onSelectAll, onSort, }: TableHeaderProps): JSX.Element;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { TableProps, TData } from './types';
|
2
|
+
/**
|
3
|
+
* `Table` component is a wrapper for Material-UI Table component.
|
4
|
+
*
|
5
|
+
* @param {TableProps} props - Table props
|
6
|
+
*
|
7
|
+
* @defaultValues
|
8
|
+
*
|
9
|
+
* | Prop | Value |
|
10
|
+
* | --- | --- |
|
11
|
+
* | `clickable` | `false` |
|
12
|
+
* | `fixedLayout` | `false` |
|
13
|
+
* | `order` | `'asc'` |
|
14
|
+
* | `orderBy` | `'id'` |
|
15
|
+
* | `pagination` | `false` |
|
16
|
+
* | `remote` | `false` |
|
17
|
+
* | `rowsPerPage` | `10` |
|
18
|
+
* | `rowsPerPageOptions` | `[10, 20, 30]` |
|
19
|
+
* | `selectable` | `false` |
|
20
|
+
* | `sort` | `false` |
|
21
|
+
*
|
22
|
+
* @remarks
|
23
|
+
* The Table component is a wrapper around the Material UI Table component. More information about the props can be found here: https://v4.mui.com/api/table/
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
*
|
27
|
+
* ```ts
|
28
|
+
* <Table
|
29
|
+
* title='Section title'
|
30
|
+
* columns={COLUMNS}
|
31
|
+
* rows={ROWS}
|
32
|
+
* sort={false}
|
33
|
+
* selectable={false}
|
34
|
+
* clickable={true}
|
35
|
+
* onRowClick={(row) => console.log(row)}
|
36
|
+
* />
|
37
|
+
* ```
|
38
|
+
*/
|
39
|
+
export declare function Table<T extends TData>({ columns, rows, clickable, colorRows, dense, fixedLayout, order, orderBy, page, pagination, remote, rowsPerPage, rowsPerPageOptions, selectable, sort, TableProps, onSelect, onOrderChange, onChangePage, onChangeRowsPerPage, onRowClick, }: TableProps<T>): JSX.Element;
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import { ChangeEvent } from 'react';
|
2
|
+
import type { TableProps as MaterialTableProps } from '@material-ui/core';
|
3
|
+
export declare type Alignment = 'left' | 'right' | 'center';
|
4
|
+
export declare type Order = 'desc' | 'asc';
|
5
|
+
export interface TableCellInterface {
|
6
|
+
id: string | number;
|
7
|
+
field: string;
|
8
|
+
headerName: string;
|
9
|
+
sort?: boolean;
|
10
|
+
width?: number | string;
|
11
|
+
maxWidth?: number | string;
|
12
|
+
minWidth?: number | string;
|
13
|
+
align?: Alignment;
|
14
|
+
colSpan?: number;
|
15
|
+
disabled?: boolean;
|
16
|
+
component?: JSX.Element;
|
17
|
+
disablePadding?: boolean;
|
18
|
+
}
|
19
|
+
export interface TableProps<T extends TData = TData> {
|
20
|
+
columns: TableCellInterface[];
|
21
|
+
rows: T[];
|
22
|
+
clickable?: boolean;
|
23
|
+
colorRows?: boolean;
|
24
|
+
dense?: boolean;
|
25
|
+
fixedLayout?: boolean;
|
26
|
+
order?: Order;
|
27
|
+
orderBy?: string;
|
28
|
+
page?: number;
|
29
|
+
pagination?: boolean;
|
30
|
+
remote?: boolean;
|
31
|
+
rowsPerPage?: number;
|
32
|
+
rowsPerPageOptions?: number[];
|
33
|
+
selectable?: boolean;
|
34
|
+
sort?: boolean;
|
35
|
+
TableProps?: MaterialTableProps;
|
36
|
+
onChangePage?: (data: number) => void;
|
37
|
+
onChangeRowsPerPage?: (data: number) => void;
|
38
|
+
onOrderChange?: (orderBy: string, order: Order) => void;
|
39
|
+
onRowClick?: (row: T) => void;
|
40
|
+
onSelect?: (id: TData['id'][]) => void;
|
41
|
+
}
|
42
|
+
export interface TableHeaderProps {
|
43
|
+
columns: TableCellInterface[];
|
44
|
+
numSelected: number;
|
45
|
+
rowCount: number;
|
46
|
+
dense?: boolean;
|
47
|
+
order: Order;
|
48
|
+
orderBy?: string;
|
49
|
+
selectable?: boolean;
|
50
|
+
sortable?: boolean;
|
51
|
+
onSelectAll?: (event: ChangeEvent<HTMLInputElement>, checked: boolean) => void;
|
52
|
+
onSort?: (data: TableCellInterface['field']) => void;
|
53
|
+
}
|
54
|
+
export interface TableBodyProps<T extends TData> {
|
55
|
+
columns: TableCellInterface[];
|
56
|
+
order: Order;
|
57
|
+
page: number;
|
58
|
+
rows: T[];
|
59
|
+
rowsPerPage: number;
|
60
|
+
selected: (string | number)[];
|
61
|
+
clickable?: boolean;
|
62
|
+
coloredRow?: boolean;
|
63
|
+
dense?: boolean;
|
64
|
+
orderBy?: string;
|
65
|
+
pagination?: boolean;
|
66
|
+
remote?: boolean;
|
67
|
+
selectable?: boolean;
|
68
|
+
sortable?: boolean;
|
69
|
+
onRowClick?: (row: T) => void;
|
70
|
+
onSelect?: (id: TData['id']) => void;
|
71
|
+
}
|
72
|
+
export interface TableBodyCellProps<T extends TData> {
|
73
|
+
columns: TableCellInterface[];
|
74
|
+
index: number;
|
75
|
+
row: T;
|
76
|
+
clickable?: boolean;
|
77
|
+
onClick?: (row: T) => void;
|
78
|
+
}
|
79
|
+
export interface TableCellProps<T extends TData> {
|
80
|
+
column: TableCellInterface;
|
81
|
+
row: T;
|
82
|
+
clickable?: boolean;
|
83
|
+
disabled?: boolean;
|
84
|
+
noBorder?: boolean;
|
85
|
+
onClick?: (row: T) => void;
|
86
|
+
}
|
87
|
+
export declare type TData = {
|
88
|
+
id: string | number;
|
89
|
+
style?: React.CSSProperties;
|
90
|
+
} & Record<string, unknown>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { TData } from './types';
|
2
|
+
export declare function getComparator<T extends TData>(order: string, orderBy: string): (a: T, b: T) => number;
|
3
|
+
export declare function stableSort<T>(data: T[], comparator: (a: T, b: T) => number): T[];
|
4
|
+
export declare function ascendingComparator<T extends TData>(a: T, b: T, orderBy: string): number;
|