@licklist/design 0.44.489 → 0.44.490
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/customers/components/filter/CustomerFilter.d.ts +13 -0
- package/dist/customers/components/filter/CustomerFilter.d.ts.map +1 -0
- package/dist/customers/components/filter/CustomerFilter.js +1 -0
- package/dist/customers/components/filter/index.d.ts +3 -0
- package/dist/customers/components/filter/index.d.ts.map +1 -0
- package/dist/customers/components/index.d.ts +2 -0
- package/dist/customers/components/index.d.ts.map +1 -0
- package/dist/customers/index.d.ts +2 -0
- package/dist/customers/index.d.ts.map +1 -0
- package/dist/events/event-statistic-modal/EventStatisticModal.js +1 -1
- package/dist/iframe/payment/order-items-table/OrderItemsTable.js +1 -1
- package/dist/iframe/payment/payment-form/PaymentForm.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/sales/guest-profile/previous-bookings/PreviousBookings.d.ts +3 -2
- package/dist/sales/guest-profile/previous-bookings/PreviousBookings.d.ts.map +1 -1
- package/dist/sales/guest-profile/previous-bookings/PreviousBookings.js +1 -1
- package/dist/sales/notes/NotesTableRow.js +1 -1
- package/dist/setting/dashboard/snippets/card/SnippetCard.js +1 -1
- package/dist/styles/customers/Filter.scss +53 -0
- package/dist/styles/customers/_index.scss +1 -0
- package/dist/styles/packages.scss +1 -0
- package/dist/table/ReactTableHelperComponent.d.ts +12 -0
- package/dist/table/ReactTableHelperComponent.d.ts.map +1 -0
- package/dist/table/ReactTableHelperComponent.js +1 -0
- package/dist/table/TableHelperComponent.d.ts +2 -3
- package/dist/table/TableHelperComponent.d.ts.map +1 -1
- package/dist/table/hooks/useTableQueryOptions.d.ts +20 -0
- package/dist/table/hooks/useTableQueryOptions.d.ts.map +1 -0
- package/dist/table/hooks/useTableQueryOptions.js +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/types.d.ts +41 -0
- package/dist/table/types.d.ts.map +1 -0
- package/dist/table/utils/index.d.ts +1 -0
- package/dist/table/utils/index.d.ts.map +1 -1
- package/dist/table/utils/index.js +1 -1
- package/package.json +2 -1
- package/src/customers/components/filter/CustomerFilter.stories.tsx +18 -0
- package/src/customers/components/filter/CustomerFilter.tsx +48 -0
- package/src/customers/components/filter/index.ts +2 -0
- package/src/customers/components/index.ts +1 -0
- package/src/customers/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/sales/guest-profile/previous-bookings/PreviousBookings.stories.tsx +35 -5
- package/src/sales/guest-profile/previous-bookings/PreviousBookings.tsx +11 -3
- package/src/styles/customers/Filter.scss +53 -0
- package/src/styles/customers/_index.scss +1 -0
- package/src/styles/packages.scss +1 -0
- package/src/table/ReactTableHelperComponent.tsx +321 -0
- package/src/table/Table.stories.tsx +127 -1
- package/src/table/TableHelperComponent.tsx +3 -1
- package/src/table/hooks/useTableQueryOptions.ts +49 -0
- package/src/table/index.ts +1 -0
- package/src/table/types.ts +47 -0
- package/src/table/utils/index.ts +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ILengthAwarePaginator from "@licklist/plugins/dist/types/services/Table/ILengthAwarePaginator";
|
|
2
2
|
import { Meta, Story } from "@storybook/react";
|
|
3
3
|
import { range } from "lodash";
|
|
4
|
-
import React from "react";
|
|
4
|
+
import React, { useRef } from "react";
|
|
5
5
|
import { Router } from "../auth/Router";
|
|
6
6
|
import {
|
|
7
7
|
FilterHelperComponent as FilterHelper,
|
|
@@ -19,6 +19,13 @@ import {
|
|
|
19
19
|
TableHelperComponent as TableHelper,
|
|
20
20
|
TableHelperComponentProps,
|
|
21
21
|
} from "./TableHelperComponent";
|
|
22
|
+
import {
|
|
23
|
+
ReactTableHelperComponent as ReactTableHelper,
|
|
24
|
+
ReactTableHelperComponentProps,
|
|
25
|
+
ReactTableHelperRow,
|
|
26
|
+
ReactTableHelperComponentRef,
|
|
27
|
+
} from "./ReactTableHelperComponent";
|
|
28
|
+
import { flexRender } from "./utils/index";
|
|
22
29
|
|
|
23
30
|
export default {
|
|
24
31
|
title: "Table",
|
|
@@ -45,6 +52,40 @@ export const PerPageHelperComponent: Story<PerPageHelperComponentProps> = (
|
|
|
45
52
|
args
|
|
46
53
|
) => <PerPageHelper {...args} />;
|
|
47
54
|
|
|
55
|
+
export const ReactTableHelperComponent: Story<
|
|
56
|
+
ReactTableHelperComponentProps<any>
|
|
57
|
+
> = (args) => (
|
|
58
|
+
<>
|
|
59
|
+
<Router>
|
|
60
|
+
<ReactTableHelper {...args} />
|
|
61
|
+
</Router>
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const ComponentInsideRouter = (args) => {
|
|
66
|
+
const ref = useRef<ReactTableHelperComponentRef>(null);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ReactTableHelper
|
|
70
|
+
{...args}
|
|
71
|
+
ref={ref}
|
|
72
|
+
externalFilters={{ uniqField: "uniqField" }}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const ReactTableHelperComponentWithColumns: Story<
|
|
78
|
+
ReactTableHelperComponentProps<any>
|
|
79
|
+
> = (args) => {
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<Router>
|
|
83
|
+
<ComponentInsideRouter {...args} />
|
|
84
|
+
</Router>
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
48
89
|
const getPaginator = (perPage, items = 100) =>
|
|
49
90
|
({
|
|
50
91
|
current_page: 1,
|
|
@@ -98,3 +139,88 @@ TableHelperComponent.args = {
|
|
|
98
139
|
PaginationHelperComponent.args = {
|
|
99
140
|
paginator: getPaginator(24, 100),
|
|
100
141
|
};
|
|
142
|
+
|
|
143
|
+
ReactTableHelperComponent.args = {
|
|
144
|
+
isLoading: false,
|
|
145
|
+
headers: [
|
|
146
|
+
{
|
|
147
|
+
title: "ID",
|
|
148
|
+
key: "id",
|
|
149
|
+
isSortable: true,
|
|
150
|
+
width: "600px",
|
|
151
|
+
},
|
|
152
|
+
"Title",
|
|
153
|
+
"Description",
|
|
154
|
+
"Action",
|
|
155
|
+
],
|
|
156
|
+
paginator: getPaginator(24, 10),
|
|
157
|
+
renderItemFn: (row) => {
|
|
158
|
+
return (
|
|
159
|
+
<tr key={row.id}>
|
|
160
|
+
<td>{row.id}</td>
|
|
161
|
+
<td>{row.title}</td>
|
|
162
|
+
<td>{row.description}</td>
|
|
163
|
+
<td>ADD | REMOVE</td>
|
|
164
|
+
</tr>
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
striped: false,
|
|
168
|
+
bordered: false,
|
|
169
|
+
displayShowingSection: false,
|
|
170
|
+
initialOptions: {
|
|
171
|
+
page: 1,
|
|
172
|
+
perPage: 10,
|
|
173
|
+
sortKey: "id",
|
|
174
|
+
sortDirection: "desc",
|
|
175
|
+
filter: "",
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
ReactTableHelperComponentWithColumns.args = {
|
|
180
|
+
isLoading: false,
|
|
181
|
+
columns: [
|
|
182
|
+
{
|
|
183
|
+
accessorKey: "id",
|
|
184
|
+
header: () => "CustomHeader",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
accessorKey: "title",
|
|
188
|
+
header: () => "SuperTitle",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
accessorKey: "description",
|
|
192
|
+
header: () => "AwesomeDescription",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
accessorKey: "actions",
|
|
196
|
+
header: () => "Incredible Actions",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
sortableColumns: ["id"],
|
|
200
|
+
paginator: getPaginator(24, 10),
|
|
201
|
+
renderRow: (row: ReactTableHelperRow<any>) => {
|
|
202
|
+
return (
|
|
203
|
+
<tr key={row.id}>
|
|
204
|
+
{row.getVisibleCells().map((cell) => {
|
|
205
|
+
return (
|
|
206
|
+
<td key={cell.id}>
|
|
207
|
+
{cell.column.id === "actions"
|
|
208
|
+
? "ADD | REMOVE"
|
|
209
|
+
: flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
210
|
+
</td>
|
|
211
|
+
);
|
|
212
|
+
})}
|
|
213
|
+
</tr>
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
striped: false,
|
|
217
|
+
bordered: false,
|
|
218
|
+
displayShowingSection: false,
|
|
219
|
+
initialOptions: {
|
|
220
|
+
page: 1,
|
|
221
|
+
perPage: 10,
|
|
222
|
+
sortKey: "id",
|
|
223
|
+
sortDirection: "desc",
|
|
224
|
+
filter: "",
|
|
225
|
+
},
|
|
226
|
+
};
|
|
@@ -14,6 +14,7 @@ import { FilterHelperComponent } from "./FilterHelperComponent";
|
|
|
14
14
|
import { PaginationHelperComponent } from "./PaginationHelperComponent";
|
|
15
15
|
import { PerPageHelperComponent } from "./PerPageHelperComponent";
|
|
16
16
|
import { getFilterOptionsValue } from "./utils";
|
|
17
|
+
import { ExtendedTableOptions } from "./types";
|
|
17
18
|
|
|
18
19
|
export interface TableHelperComponentProps {
|
|
19
20
|
headers: ITableHeader[];
|
|
@@ -31,7 +32,6 @@ export interface TableHelperComponentProps {
|
|
|
31
32
|
initialOptions?: Partial<ITableProps>;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
export type ExtendedTableOptions = ITableProps & { [key: string]: any };
|
|
35
35
|
// @TODO Refactor? component to get less complexity
|
|
36
36
|
// with query filter params. Now External filters use only in
|
|
37
37
|
// one place of Dashboard.
|
|
@@ -42,6 +42,8 @@ export type ExtendedTableOptions = ITableProps & { [key: string]: any };
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* TableHelperComponent
|
|
45
|
+
* @deprecated use new ReactTableHelperComponent
|
|
46
|
+
* for default tables
|
|
45
47
|
* @param props
|
|
46
48
|
* @constructor
|
|
47
49
|
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import useQuery from "@licklist/plugins/dist/hooks/Query/useQuery";
|
|
3
|
+
import { getFilterOptionsValue } from "../utils";
|
|
4
|
+
import { TableComponentProps, ExtendedTableOptions } from "../types";
|
|
5
|
+
|
|
6
|
+
export const useTableQueryOptions = <T extends object>({
|
|
7
|
+
initialOptions = {},
|
|
8
|
+
externalFilters = {},
|
|
9
|
+
}: Pick<TableComponentProps<T>, "initialOptions" | "externalFilters">) => {
|
|
10
|
+
const query = useQuery();
|
|
11
|
+
|
|
12
|
+
const page = Number(getFilterOptionsValue(query, initialOptions, "page"));
|
|
13
|
+
const perPage = Number(
|
|
14
|
+
getFilterOptionsValue(query, initialOptions, "perPage")
|
|
15
|
+
);
|
|
16
|
+
const sortKey = String(
|
|
17
|
+
getFilterOptionsValue(query, initialOptions, "sortKey")
|
|
18
|
+
);
|
|
19
|
+
const sortDirection = String(
|
|
20
|
+
getFilterOptionsValue(query, initialOptions, "sortDirection")
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const filter = String(getFilterOptionsValue(query, initialOptions, "filter"));
|
|
24
|
+
|
|
25
|
+
const [optionsCache, setOptionsCache] = useState<ExtendedTableOptions>();
|
|
26
|
+
const [options, setOptions] = useState<ExtendedTableOptions>({
|
|
27
|
+
page,
|
|
28
|
+
perPage,
|
|
29
|
+
sortKey,
|
|
30
|
+
sortDirection,
|
|
31
|
+
filter,
|
|
32
|
+
});
|
|
33
|
+
const [cachedExternalFilters, setCachedExternalFilters] =
|
|
34
|
+
useState<{ [key: string]: any }>(externalFilters);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
page,
|
|
38
|
+
perPage,
|
|
39
|
+
sortKey,
|
|
40
|
+
sortDirection,
|
|
41
|
+
filter,
|
|
42
|
+
optionsCache,
|
|
43
|
+
setOptionsCache,
|
|
44
|
+
options,
|
|
45
|
+
setOptions,
|
|
46
|
+
cachedExternalFilters,
|
|
47
|
+
setCachedExternalFilters,
|
|
48
|
+
};
|
|
49
|
+
};
|
package/src/table/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ReactNode, CSSProperties } from "react";
|
|
2
|
+
import {
|
|
3
|
+
TableOptions,
|
|
4
|
+
ColumnDef,
|
|
5
|
+
Row as TableRow,
|
|
6
|
+
} from "@tanstack/react-table";
|
|
7
|
+
import ILengthAwarePaginator from "@licklist/plugins/dist/types/services/Table/ILengthAwarePaginator";
|
|
8
|
+
import ITableHeader from "@licklist/plugins/dist/types/services/Table/ITableHeader";
|
|
9
|
+
import ITableProps from "@licklist/plugins/dist/types/services/Table/ITableProps";
|
|
10
|
+
|
|
11
|
+
export type ReactTableHelperRow<T extends object> = TableRow<T>;
|
|
12
|
+
|
|
13
|
+
export type ExtendedTableOptions = ITableProps & { [key: string]: any };
|
|
14
|
+
|
|
15
|
+
export interface TableComponentProps<T extends object>
|
|
16
|
+
extends Omit<TableOptions<T>, "columns" | "data" | "getCoreRowModel"> {
|
|
17
|
+
paginator?: ILengthAwarePaginator<T>;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
striped?: boolean;
|
|
20
|
+
bordered?: boolean;
|
|
21
|
+
displaySearchBar?: boolean;
|
|
22
|
+
displayPerPageSelect?: boolean;
|
|
23
|
+
displayShowingSection?: boolean;
|
|
24
|
+
externalFilters?: { [key: string]: any };
|
|
25
|
+
initialOptions?: Partial<ITableProps>;
|
|
26
|
+
sortableColumns?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type TableColumnMeta = {
|
|
30
|
+
onClick?: () => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type TableComponentPropsWithOldTableData<T extends object> = {
|
|
36
|
+
headers: ITableHeader[];
|
|
37
|
+
renderItemFn: (row: T, index: number) => void;
|
|
38
|
+
columns?: never;
|
|
39
|
+
renderRow?: never;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type TableComponentPropsWithReactTableData<T extends object> = {
|
|
43
|
+
headers?: never;
|
|
44
|
+
renderItemFn?: never;
|
|
45
|
+
columns: ColumnDef<T, any>[];
|
|
46
|
+
renderRow: (row: ReactTableHelperRow<T>) => ReactNode;
|
|
47
|
+
};
|
package/src/table/utils/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ITableProps from "@licklist/plugins/dist/types/services/Table/ITableProps";
|
|
2
2
|
import TableService from "@licklist/plugins/dist/services/Table/TableService";
|
|
3
3
|
|
|
4
|
+
export { flexRender } from "@tanstack/react-table";
|
|
5
|
+
|
|
4
6
|
const DEFAULT_QUERY_VALUES: { [key in keyof ITableProps]: string | number } = {
|
|
5
7
|
page: TableService.DEFAULT_PAGE,
|
|
6
8
|
perPage: TableService.DEFAULT_PER_PAGE,
|