@pushwoosh/dumb-components 1.0.4 → 1.0.6
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/Drawer/components/Drawer/index.d.ts +1 -0
- package/Drawer/components/Drawer/index.js +1 -0
- package/Drawer/{styles.js → components/Drawer/styles.js} +4 -4
- package/Drawer/components/DrawerContent/index.d.ts +1 -0
- package/Drawer/components/DrawerContent/index.js +1 -0
- package/Drawer/components/DrawerContent/styles.d.ts +3 -0
- package/Drawer/components/DrawerContent/styles.js +14 -0
- package/Drawer/components/DrawerDocs/DrawerDocs.d.ts +3 -0
- package/Drawer/components/DrawerDocs/DrawerDocs.js +45 -0
- package/Drawer/components/DrawerDocs/hooks.d.ts +5 -0
- package/Drawer/components/DrawerDocs/hooks.js +15 -0
- package/Drawer/components/DrawerDocs/index.d.ts +2 -0
- package/Drawer/components/DrawerDocs/index.js +2 -0
- package/Drawer/components/DrawerDocs/styles.d.ts +5 -0
- package/Drawer/components/DrawerDocs/styles.js +16 -0
- package/Drawer/components/DrawerDocs/types.d.ts +5 -0
- package/Drawer/components/DrawerDocs/types.js +1 -0
- package/Drawer/index.d.ts +3 -1
- package/Drawer/index.js +3 -1
- package/DropdownMenu/components/DropdownMenuItem/index.d.ts +1 -0
- package/DropdownMenu/index.d.ts +1 -1
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.js +2 -2
- package/Select/Select.d.ts +6 -0
- package/Select/Select.js +39 -0
- package/Select/constants.d.ts +1 -0
- package/Select/constants.js +1 -0
- package/Select/index.d.ts +3 -0
- package/Select/index.js +2 -0
- package/Select/styles.d.ts +6 -0
- package/Select/styles.js +31 -0
- package/Select/types.d.ts +15 -0
- package/Select/types.js +1 -0
- package/Spinner/Spinner.js +3 -6
- package/Spinner/assets/spinner.medium.svg +1 -1
- package/Spinner/assets/spinner.small.svg +1 -1
- package/Table/assets/box.svg +1 -0
- package/Table/assets/error.svg +1 -0
- package/Table/assets/notfound.svg +1 -0
- package/Table/components/ClearableInput/ClearableInput.d.ts +3 -0
- package/Table/components/ClearableInput/ClearableInput.js +20 -0
- package/Table/components/ClearableInput/index.d.ts +1 -0
- package/Table/components/ClearableInput/index.js +1 -0
- package/Table/components/ClearableInput/styles.d.ts +14 -0
- package/Table/components/ClearableInput/styles.js +10 -0
- package/Table/components/ClearableInput/types.d.ts +5 -0
- package/Table/components/ClearableInput/types.js +1 -0
- package/Table/components/DataTable/DataTable.d.ts +4 -0
- package/Table/components/DataTable/DataTable.js +74 -0
- package/Table/components/DataTable/index.d.ts +1 -0
- package/Table/components/DataTable/index.js +1 -0
- package/Table/components/DataTable/types.d.ts +22 -0
- package/Table/components/DataTable/types.js +1 -0
- package/Table/components/DataTableGetContext/DataTableGetContext.d.ts +4 -0
- package/Table/components/DataTableGetContext/DataTableGetContext.js +8 -0
- package/Table/components/DataTableGetContext/index.d.ts +1 -0
- package/Table/components/DataTableGetContext/index.js +1 -0
- package/Table/components/DataTableGetContext/types.d.ts +5 -0
- package/Table/components/DataTableGetContext/types.js +1 -0
- package/Table/components/DataTableList/DataTableList.d.ts +3 -0
- package/Table/components/DataTableList/DataTableList.js +77 -0
- package/Table/components/DataTableList/index.d.ts +1 -0
- package/Table/components/DataTableList/index.js +1 -0
- package/Table/components/DataTableList/types.d.ts +4 -0
- package/Table/components/DataTableList/types.js +1 -0
- package/Table/components/DataTablePagination/DataTablePagination.d.ts +3 -0
- package/Table/components/DataTablePagination/DataTablePagination.js +33 -0
- package/Table/components/DataTablePagination/index.d.ts +1 -0
- package/Table/components/DataTablePagination/index.js +1 -0
- package/Table/components/DataTablePagination/types.d.ts +4 -0
- package/Table/components/DataTablePagination/types.js +1 -0
- package/Table/components/DataTableSearchInput/DataTableSearchInput.d.ts +3 -0
- package/Table/components/DataTableSearchInput/DataTableSearchInput.js +31 -0
- package/Table/components/DataTableSearchInput/index.d.ts +1 -0
- package/Table/components/DataTableSearchInput/index.js +1 -0
- package/Table/components/DataTableSearchInput/types.d.ts +3 -0
- package/Table/components/DataTableSearchInput/types.js +1 -0
- package/Table/components/DataTableSortableCell/DataTableSortableCell.d.ts +3 -0
- package/Table/components/DataTableSortableCell/DataTableSortableCell.js +25 -0
- package/Table/components/DataTableSortableCell/index.d.ts +1 -0
- package/Table/components/DataTableSortableCell/index.js +1 -0
- package/Table/components/DataTableSortableCell/types.d.ts +4 -0
- package/Table/components/DataTableSortableCell/types.js +1 -0
- package/Table/components/Loading/Loading.d.ts +2 -0
- package/Table/components/Loading/Loading.js +20 -0
- package/Table/components/Loading/index.d.ts +1 -0
- package/Table/components/Loading/index.js +1 -0
- package/Table/components/Loading/styles.d.ts +1 -0
- package/Table/components/Loading/styles.js +6 -0
- package/Table/components/TableList/TableList.d.ts +3 -0
- package/Table/components/TableList/TableList.js +15 -0
- package/Table/components/TableList/index.d.ts +1 -0
- package/Table/components/TableList/index.js +1 -0
- package/Table/components/TableList/types.d.ts +9 -0
- package/Table/components/TableList/types.js +1 -0
- package/Table/components/TablePagination/TablePagination.d.ts +3 -0
- package/Table/components/TablePagination/TablePagination.js +38 -0
- package/Table/components/TablePagination/index.d.ts +1 -0
- package/Table/components/TablePagination/index.js +1 -0
- package/Table/components/TablePagination/types.d.ts +9 -0
- package/Table/components/TablePagination/types.js +1 -0
- package/Table/context.d.ts +2 -0
- package/Table/context.js +2 -0
- package/Table/hooks/index.d.ts +2 -0
- package/Table/hooks/index.js +2 -0
- package/Table/hooks/useDataTableContext.d.ts +11 -0
- package/Table/hooks/useDataTableContext.js +23 -0
- package/Table/hooks/useDataTableParams.d.ts +10 -0
- package/Table/hooks/useDataTableParams.js +39 -0
- package/Table/index.d.ts +13 -0
- package/Table/index.js +12 -0
- package/Table/styles.d.ts +73 -0
- package/Table/styles.js +60 -0
- package/Table/types.d.ts +20 -0
- package/Table/types.js +1 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +4 -2
- /package/Drawer/{Drawer.d.ts → components/Drawer/Drawer.d.ts} +0 -0
- /package/Drawer/{Drawer.js → components/Drawer/Drawer.js} +0 -0
- /package/Drawer/{maps.d.ts → components/Drawer/maps.d.ts} +0 -0
- /package/Drawer/{maps.js → components/Drawer/maps.js} +0 -0
- /package/Drawer/{styles.d.ts → components/Drawer/styles.d.ts} +0 -0
- /package/Drawer/{types.d.ts → components/Drawer/types.d.ts} +0 -0
- /package/Drawer/{types.js → components/Drawer/types.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
3
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
4
|
+
$gap?: string | number | undefined;
|
|
5
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
6
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
7
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
8
|
+
$margin?: string | number | undefined;
|
|
9
|
+
$padding?: string | number | undefined;
|
|
10
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
$gridAutoFlow: string;
|
|
13
|
+
}, "$gridAutoFlow">;
|
|
14
|
+
export declare const ClearButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
export const Wrapper = styled(Horizontal).withConfig({
|
|
4
|
+
displayName: "Wrapper",
|
|
5
|
+
componentId: "sc-1c8truw-0"
|
|
6
|
+
})(["position:relative;"]);
|
|
7
|
+
export const ClearButton = styled.div.withConfig({
|
|
8
|
+
displayName: "ClearButton",
|
|
9
|
+
componentId: "sc-1c8truw-1"
|
|
10
|
+
})(["position:absolute;right:8px;top:50%;transform:translateY(-50%);cursor:pointer;"]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { WarningRoundIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
6
|
+
import { Button } from '../../../Button';
|
|
7
|
+
import { Spinner } from '../../../Spinner';
|
|
8
|
+
import { DataTableContext } from '../../context';
|
|
9
|
+
import { LockedText, Table } from '../../styles';
|
|
10
|
+
import { DataTableList } from '../DataTableList';
|
|
11
|
+
import { DataTablePagination } from '../DataTablePagination';
|
|
12
|
+
export function DataTable(props) {
|
|
13
|
+
var _data$value, _data$value2, _data$value3, _data$value4, _data$value5, _data$value6;
|
|
14
|
+
const {
|
|
15
|
+
columns,
|
|
16
|
+
width,
|
|
17
|
+
context,
|
|
18
|
+
renderTableTop,
|
|
19
|
+
renderAfter,
|
|
20
|
+
hidePagination
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
data,
|
|
24
|
+
params
|
|
25
|
+
} = context;
|
|
26
|
+
const isFiltered = ((_data$value = data.value) === null || _data$value === void 0 ? void 0 : _data$value.isFiltered) || params.search;
|
|
27
|
+
return React.createElement(DataTableContext.Provider, {
|
|
28
|
+
value: context
|
|
29
|
+
}, React.createElement(Table, {
|
|
30
|
+
columns: columns,
|
|
31
|
+
width: width
|
|
32
|
+
}, renderTableTop === null || renderTableTop === void 0 ? void 0 : renderTableTop(context), 'renderHead' in props && props.renderHead(), 'renderList' in props ? props.renderList(context) : React.createElement(DataTableList, {
|
|
33
|
+
renderItem: props.renderItem
|
|
34
|
+
}), !hidePagination && React.createElement(DataTablePagination, {
|
|
35
|
+
allLimits: [10, 20, 50, 100]
|
|
36
|
+
}, data.loading && React.createElement(Horizontal, {
|
|
37
|
+
"$gap": Spacing.S1,
|
|
38
|
+
"$alignItems": "center"
|
|
39
|
+
}, React.createElement(Spinner, {
|
|
40
|
+
size: "medium",
|
|
41
|
+
color: Color.LOCKED
|
|
42
|
+
}), React.createElement(LockedText, null, "Loading...")), !data.loading && data.error && React.createElement(Horizontal, {
|
|
43
|
+
"$gap": Spacing.S1,
|
|
44
|
+
"$alignItems": "center"
|
|
45
|
+
}, React.createElement(WarningRoundIcon, {
|
|
46
|
+
size: "medium",
|
|
47
|
+
view: "lined",
|
|
48
|
+
color: Color.WARNING
|
|
49
|
+
}), React.createElement(Text, {
|
|
50
|
+
"$color": Color.WARNING
|
|
51
|
+
}, "Request is failed")), !data.loading && !data.error && (((_data$value2 = data.value) === null || _data$value2 === void 0 ? void 0 : _data$value2.total) ?? 0) > 0 && React.createElement(Horizontal, {
|
|
52
|
+
"$placeItems": "center",
|
|
53
|
+
"$gap": Spacing.S1
|
|
54
|
+
}, "Result:", React.createElement(LockedText, null, `${(_data$value3 = data.value) === null || _data$value3 === void 0 ? void 0 : _data$value3.total} item${(((_data$value4 = data.value) === null || _data$value4 === void 0 ? void 0 : _data$value4.total) ?? 0) > 1 ? 's' : ''}`)), !data.loading && !data.error && (((_data$value5 = data.value) === null || _data$value5 === void 0 ? void 0 : _data$value5.total) ?? 0) === 0 && !isFiltered && React.createElement(Horizontal, {
|
|
55
|
+
"$placeItems": "center"
|
|
56
|
+
}, React.createElement(LockedText, null, "No items yet")), !data.loading && (((_data$value6 = data.value) === null || _data$value6 === void 0 || (_data$value6 = _data$value6.items) === null || _data$value6 === void 0 ? void 0 : _data$value6.length) ?? 0) === 0 && isFiltered && React.createElement(Horizontal, {
|
|
57
|
+
"$gap": Spacing.S5
|
|
58
|
+
}, !data.error && React.createElement(Horizontal, {
|
|
59
|
+
"$placeItems": "center",
|
|
60
|
+
"$gap": Spacing.S1
|
|
61
|
+
}, "Result:", React.createElement(LockedText, null, "No match found")), React.createElement(Button, {
|
|
62
|
+
color: "primary",
|
|
63
|
+
view: "ghost",
|
|
64
|
+
onClick: () => {
|
|
65
|
+
const keys = ['perPage', 'order', 'direction'];
|
|
66
|
+
context.onChangeParams(keys.reduce((acc, key) => ({
|
|
67
|
+
...acc,
|
|
68
|
+
[key]: context.params[key]
|
|
69
|
+
}), {
|
|
70
|
+
page: 1
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}, "Clear request")))), renderAfter === null || renderAfter === void 0 ? void 0 : renderAfter(context));
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTable } from './DataTable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTable } from './DataTable';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { DataTableParams, DataTableContextType } from '../../types';
|
|
3
|
+
export type DataTableListProps<I, P extends DataTableParams> = {
|
|
4
|
+
columns: string;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
context: DataTableContextType<I, P>;
|
|
7
|
+
hidePagination?: boolean;
|
|
8
|
+
renderTableTop?: (ctxValue: DataTableContextType<I, P>) => ReactNode;
|
|
9
|
+
renderList: (ctxValue: DataTableContextType<I, P>) => ReactNode;
|
|
10
|
+
renderAfter?: (ctxValue: DataTableContextType<I, P>) => ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export type DataTableItemProps<I, P extends DataTableParams> = {
|
|
13
|
+
columns: string;
|
|
14
|
+
width?: string | number;
|
|
15
|
+
context: DataTableContextType<I, P>;
|
|
16
|
+
hidePagination?: boolean;
|
|
17
|
+
renderTableTop?: (ctxValue: DataTableContextType<I, P>) => ReactNode;
|
|
18
|
+
renderHead: () => ReactNode;
|
|
19
|
+
renderItem: (item: I) => ReactNode;
|
|
20
|
+
renderAfter?: (ctxValue: DataTableContextType<I, P>) => ReactNode;
|
|
21
|
+
};
|
|
22
|
+
export type DataTableProps<I, P extends DataTableParams> = DataTableListProps<I, P> | DataTableItemProps<I, P>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DataGetContextProps } from './types';
|
|
3
|
+
import type { DataTableContextType } from '../../types';
|
|
4
|
+
export declare const DataTableGetContext: <C extends DataTableContextType<any, any>>({ children }: DataGetContextProps<C>) => React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { DataTableContext } from '../../context';
|
|
3
|
+
export const DataTableGetContext = ({
|
|
4
|
+
children
|
|
5
|
+
}) => {
|
|
6
|
+
const ctxValue = useContext(DataTableContext);
|
|
7
|
+
return React.createElement(React.Fragment, null, children(ctxValue));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableGetContext } from './DataTableGetContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableGetContext } from './DataTableGetContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { FontSize, FontWeight, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import Box from '../../assets/box.svg';
|
|
5
|
+
import Error from '../../assets/error.svg';
|
|
6
|
+
import NotFound from '../../assets/notfound.svg';
|
|
7
|
+
import { DataTableContext } from '../../context';
|
|
8
|
+
import { LockedText } from '../../styles';
|
|
9
|
+
import { Loading } from '../Loading';
|
|
10
|
+
export function DataTableList({
|
|
11
|
+
renderItem
|
|
12
|
+
}) {
|
|
13
|
+
var _data$value, _data$value2;
|
|
14
|
+
const {
|
|
15
|
+
data,
|
|
16
|
+
params
|
|
17
|
+
} = useContext(DataTableContext);
|
|
18
|
+
if (data.loading || (_data$value = data.value) !== null && _data$value !== void 0 && (_data$value = _data$value.items) !== null && _data$value !== void 0 && _data$value.length) {
|
|
19
|
+
return data.value ? React.createElement(React.Fragment, null, data.value.items.map(renderItem)) : React.createElement(Loading, null);
|
|
20
|
+
}
|
|
21
|
+
if (!data.loading && data.error) {
|
|
22
|
+
return React.createElement(Horizontal, {
|
|
23
|
+
"$placeItems": "center",
|
|
24
|
+
"$padding": Spacing.S14
|
|
25
|
+
}, React.createElement(Horizontal, {
|
|
26
|
+
"$gap": 16
|
|
27
|
+
}, React.createElement("img", {
|
|
28
|
+
src: Error,
|
|
29
|
+
alt: "Request failed"
|
|
30
|
+
}), React.createElement(Vertical, {
|
|
31
|
+
"$alignContent": "center",
|
|
32
|
+
"$gap": 8
|
|
33
|
+
}, React.createElement(LockedText, {
|
|
34
|
+
"$fontWeight": FontWeight.MEDIUM,
|
|
35
|
+
"$maxWidth": "250px"
|
|
36
|
+
}, "Something went wrong"), React.createElement(LockedText, {
|
|
37
|
+
"$fontSize": FontSize.SMALL,
|
|
38
|
+
"$maxWidth": "250px"
|
|
39
|
+
}, "Give it another try or refresh the page to see if we can fix this glitch!"))));
|
|
40
|
+
}
|
|
41
|
+
const isFiltered = ((_data$value2 = data.value) === null || _data$value2 === void 0 ? void 0 : _data$value2.isFiltered) || params.search;
|
|
42
|
+
return isFiltered ? React.createElement(Horizontal, {
|
|
43
|
+
"$placeItems": "center",
|
|
44
|
+
"$padding": Spacing.S14
|
|
45
|
+
}, React.createElement(Horizontal, {
|
|
46
|
+
"$gap": 16
|
|
47
|
+
}, React.createElement("img", {
|
|
48
|
+
src: NotFound,
|
|
49
|
+
alt: "Not found"
|
|
50
|
+
}), React.createElement(Vertical, {
|
|
51
|
+
"$alignContent": "center",
|
|
52
|
+
"$gap": 8
|
|
53
|
+
}, React.createElement(LockedText, {
|
|
54
|
+
"$fontWeight": FontWeight.MEDIUM,
|
|
55
|
+
"$maxWidth": "250px"
|
|
56
|
+
}, "No match found"), React.createElement(LockedText, {
|
|
57
|
+
"$fontSize": FontSize.SMALL,
|
|
58
|
+
"$maxWidth": "250px"
|
|
59
|
+
}, "Please try using different search terms with a minimum of two characters.")))) : React.createElement(Horizontal, {
|
|
60
|
+
"$placeItems": "center",
|
|
61
|
+
"$padding": Spacing.S14
|
|
62
|
+
}, React.createElement(Horizontal, {
|
|
63
|
+
"$gap": 16
|
|
64
|
+
}, React.createElement("img", {
|
|
65
|
+
src: Box,
|
|
66
|
+
alt: "Empty box"
|
|
67
|
+
}), React.createElement(Vertical, {
|
|
68
|
+
"$alignContent": "center",
|
|
69
|
+
"$gap": 8
|
|
70
|
+
}, React.createElement(LockedText, {
|
|
71
|
+
"$fontWeight": FontWeight.MEDIUM,
|
|
72
|
+
"$maxWidth": "250px"
|
|
73
|
+
}, "This list is empty"), React.createElement(LockedText, {
|
|
74
|
+
"$fontSize": FontSize.SMALL,
|
|
75
|
+
"$maxWidth": "250px"
|
|
76
|
+
}, "Looks like there's nothing here yet. Time to create \u2014 let's bring this list to life!"))));
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableList } from './DataTableList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableList } from './DataTableList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { DataTableContext } from '../../context';
|
|
3
|
+
import { TablePagination } from '../TablePagination';
|
|
4
|
+
export function DataTablePagination({
|
|
5
|
+
allLimits,
|
|
6
|
+
children
|
|
7
|
+
}) {
|
|
8
|
+
var _data$value;
|
|
9
|
+
const {
|
|
10
|
+
data,
|
|
11
|
+
params,
|
|
12
|
+
onChangeParams
|
|
13
|
+
} = useContext(DataTableContext);
|
|
14
|
+
return React.createElement(TablePagination, {
|
|
15
|
+
activePage: params.page,
|
|
16
|
+
totalPages: ((_data$value = data.value) === null || _data$value === void 0 ? void 0 : _data$value.totalPages) || 1,
|
|
17
|
+
limit: params.perPage,
|
|
18
|
+
allLimits: allLimits,
|
|
19
|
+
onChangePage: page => {
|
|
20
|
+
onChangeParams({
|
|
21
|
+
...params,
|
|
22
|
+
page
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
onChangeLimit: perPage => {
|
|
26
|
+
onChangeParams({
|
|
27
|
+
...params,
|
|
28
|
+
page: 1,
|
|
29
|
+
perPage
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, children);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTablePagination } from './DataTablePagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTablePagination } from './DataTablePagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect, useContext } from 'react';
|
|
2
|
+
import { DataTableContext } from '../../context';
|
|
3
|
+
import { ClearableInput } from '../ClearableInput';
|
|
4
|
+
export function DataTableSearchInput(props) {
|
|
5
|
+
const context = useContext(DataTableContext);
|
|
6
|
+
const [inputValue, setInputValue] = useState(context.params.search);
|
|
7
|
+
const timeoutRef = useRef();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (inputValue !== context.params.search) {
|
|
10
|
+
setInputValue(context.params.search);
|
|
11
|
+
}
|
|
12
|
+
}, [context.params.search]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
13
|
+
return React.createElement(ClearableInput, {
|
|
14
|
+
...props,
|
|
15
|
+
value: inputValue,
|
|
16
|
+
onChange: value => {
|
|
17
|
+
setInputValue(value);
|
|
18
|
+
if (timeoutRef.current) {
|
|
19
|
+
clearTimeout(timeoutRef.current);
|
|
20
|
+
}
|
|
21
|
+
timeoutRef.current = setTimeout(() => {
|
|
22
|
+
context.onChangeParams({
|
|
23
|
+
...context.params,
|
|
24
|
+
search: value,
|
|
25
|
+
page: 1
|
|
26
|
+
});
|
|
27
|
+
timeoutRef.current = undefined;
|
|
28
|
+
}, 750);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableSearchInput } from './DataTableSearchInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableSearchInput } from './DataTableSearchInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { SortButton } from '../../../SortButton';
|
|
3
|
+
import { DataTableContext } from '../../context';
|
|
4
|
+
export function DataTableSortableCell(props) {
|
|
5
|
+
const {
|
|
6
|
+
name,
|
|
7
|
+
children
|
|
8
|
+
} = props;
|
|
9
|
+
const {
|
|
10
|
+
params,
|
|
11
|
+
onChangeParams
|
|
12
|
+
} = useContext(DataTableContext);
|
|
13
|
+
return React.createElement(SortButton, {
|
|
14
|
+
name: name,
|
|
15
|
+
order: params.order === name ? params.direction : null,
|
|
16
|
+
onClick: sortParams => {
|
|
17
|
+
onChangeParams({
|
|
18
|
+
...params,
|
|
19
|
+
order: sortParams.name,
|
|
20
|
+
direction: sortParams.order || 'asc',
|
|
21
|
+
page: 1
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableSortableCell } from './DataTableSortableCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableSortableCell } from './DataTableSortableCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { Wrapper } from './styles';
|
|
4
|
+
import { TextSkeleton } from '../../../Skeleton';
|
|
5
|
+
const Row = ({
|
|
6
|
+
width
|
|
7
|
+
}) => React.createElement(Horizontal, {
|
|
8
|
+
"$alignItems": "center",
|
|
9
|
+
"$padding": "0 24px"
|
|
10
|
+
}, React.createElement(TextSkeleton, {
|
|
11
|
+
width: width
|
|
12
|
+
}));
|
|
13
|
+
export const Loading = () => React.createElement(Wrapper, null, Array.from({
|
|
14
|
+
length: 4
|
|
15
|
+
}).map((_, index) =>
|
|
16
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
17
|
+
React.createElement(Row, {
|
|
18
|
+
key: index,
|
|
19
|
+
width: `${index % 2 ? 35 : 50}%`
|
|
20
|
+
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Loading } from './Loading';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Loading } from './Loading';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontSize } from '@pushwoosh/kit-constants';
|
|
3
|
+
export const Wrapper = styled.div.withConfig({
|
|
4
|
+
displayName: "Wrapper",
|
|
5
|
+
componentId: "sc-1xpxjq7-0"
|
|
6
|
+
})(["position:relative;font-size:", ";line-height:12px;background-color:", ";& > div{height:52px;border-bottom:1px solid ", ";& > div{transition:width 200ms linear;}}&:after{content:'';position:absolute;left:0;right:0;top:0;bottom:0;background-image:linear-gradient(to bottom,rgba(255,255,255,0),rgba(255,255,255,0.9));}"], FontSize.SMALL, Color.CLEAR, Color.DIVIDER);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table } from '../../styles';
|
|
3
|
+
export function TableList(props) {
|
|
4
|
+
const {
|
|
5
|
+
columns,
|
|
6
|
+
items,
|
|
7
|
+
renderHead,
|
|
8
|
+
renderItem,
|
|
9
|
+
renderTableTop,
|
|
10
|
+
renderTableBottom
|
|
11
|
+
} = props;
|
|
12
|
+
return React.createElement(Table, {
|
|
13
|
+
columns: columns
|
|
14
|
+
}, renderTableTop === null || renderTableTop === void 0 ? void 0 : renderTableTop(), renderHead(), items.map(renderItem), renderTableBottom === null || renderTableBottom === void 0 ? void 0 : renderTableBottom());
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableList } from './TableList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableList } from './TableList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { NativeSelect } from '../../../native';
|
|
4
|
+
import { Pagination } from '../../../Pagination';
|
|
5
|
+
export function TablePagination(props) {
|
|
6
|
+
const {
|
|
7
|
+
activePage,
|
|
8
|
+
totalPages,
|
|
9
|
+
limit,
|
|
10
|
+
allLimits,
|
|
11
|
+
onChangePage,
|
|
12
|
+
onChangeLimit,
|
|
13
|
+
children
|
|
14
|
+
} = props;
|
|
15
|
+
return React.createElement(Horizontal, {
|
|
16
|
+
"$justifyContent": "space-between",
|
|
17
|
+
"$padding": 24
|
|
18
|
+
}, React.createElement(Horizontal, {
|
|
19
|
+
"$gap": 8,
|
|
20
|
+
"$alignItems": "center"
|
|
21
|
+
}, totalPages > 1 && React.createElement(Pagination, {
|
|
22
|
+
activePage: activePage,
|
|
23
|
+
totalPages: totalPages,
|
|
24
|
+
onChangePage: onChangePage
|
|
25
|
+
}), children), React.createElement(Horizontal, {
|
|
26
|
+
"$gap": 8,
|
|
27
|
+
"$alignItems": "center"
|
|
28
|
+
}, React.createElement("span", null, "Show on page:"), React.createElement(NativeSelect, {
|
|
29
|
+
name: "page",
|
|
30
|
+
value: limit,
|
|
31
|
+
onChange: event => {
|
|
32
|
+
onChangeLimit(Number(event.target.value));
|
|
33
|
+
}
|
|
34
|
+
}, allLimits.map(option => React.createElement("option", {
|
|
35
|
+
key: option,
|
|
36
|
+
value: option
|
|
37
|
+
}, option)))));
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TablePagination } from './TablePagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TablePagination } from './TablePagination';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
export type TablePaginationProps = PropsWithChildren<{
|
|
3
|
+
activePage: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
limit: number;
|
|
6
|
+
allLimits: number[];
|
|
7
|
+
onChangePage: (page: number) => void;
|
|
8
|
+
onChangeLimit: (limit: number) => void;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/Table/context.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DataTableParams, DataTableContextType } from '../types';
|
|
2
|
+
export type DataTableContextProps<I, P extends DataTableParams> = {
|
|
3
|
+
getItems: (params: P) => Promise<{
|
|
4
|
+
items: I[];
|
|
5
|
+
total: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
}>;
|
|
8
|
+
params: P;
|
|
9
|
+
onChangeParams: (params: P) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function useDataTableContext<I, P extends DataTableParams = DataTableParams>({ getItems, params, onChangeParams, }: DataTableContextProps<I, P>): DataTableContextType<I, P>;
|