@licklist/design 0.44.476-dev.12 → 0.44.476-dev.2
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/events/event-statistic-modal/EventStatisticModal.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +1 -1
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/SummaryTotal.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/SummaryTotal.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +1 -2
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts +4 -0
- package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/utils/index.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 +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts.map +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.js +1 -1
- package/dist/sales/notes/NotesTableRow.d.ts.map +1 -1
- package/dist/sales/notes/NotesTableRow.js +1 -1
- package/dist/sales/notes/note-form/NoteForm.d.ts.map +1 -1
- package/dist/sales/notes/note-form/NoteForm.js +1 -1
- package/dist/setting/dashboard/snippets/card/SnippetCard.js +1 -1
- package/dist/styles/iframe-events/Event.scss +2 -0
- package/dist/styles/packages.scss +0 -1
- package/dist/styles/sales/Notes.scss +4 -0
- package/dist/table/TableHelperComponent.d.ts +3 -2
- package/dist/table/TableHelperComponent.d.ts.map +1 -1
- package/dist/table/index.d.ts +0 -1
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/utils/index.d.ts +0 -1
- package/dist/table/utils/index.d.ts.map +1 -1
- package/dist/table/utils/index.js +1 -1
- package/package.json +1 -2
- package/src/iframe/order-process/OrderProcess.stories.tsx +5 -2
- package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +2 -2
- package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +13 -6
- package/src/iframe/order-process/components/BookingSummary/components/SummaryTotal/SummaryTotal.tsx +12 -4
- package/src/iframe/order-process/components/BookingSummary/types/index.ts +1 -2
- package/src/iframe/order-process/components/BookingSummary/utils/index.ts +21 -0
- package/src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.stories.tsx +1 -9
- package/src/index.ts +0 -1
- package/src/product-set/form/StepsControl.tsx +1 -1
- package/src/sales/manual-booking/select-menu/SelectMenu.tsx +1 -3
- package/src/sales/notes/NotesTableRow.tsx +6 -11
- package/src/sales/notes/note-form/NoteForm.tsx +3 -21
- package/src/styles/iframe-events/Event.scss +2 -0
- package/src/styles/packages.scss +0 -1
- package/src/styles/sales/Notes.scss +4 -0
- package/src/table/Table.stories.tsx +1 -127
- package/src/table/TableHelperComponent.tsx +1 -3
- package/src/table/index.ts +0 -1
- package/src/table/utils/index.ts +0 -2
- package/dist/customers/components/filter/CustomerFilter.d.ts +0 -14
- package/dist/customers/components/filter/CustomerFilter.d.ts.map +0 -1
- package/dist/customers/components/filter/CustomerFilter.js +0 -1
- package/dist/customers/components/filter/index.d.ts +0 -3
- package/dist/customers/components/filter/index.d.ts.map +0 -1
- package/dist/customers/components/index.d.ts +0 -2
- package/dist/customers/components/index.d.ts.map +0 -1
- package/dist/customers/index.d.ts +0 -2
- package/dist/customers/index.d.ts.map +0 -1
- package/dist/styles/customers/Filter.scss +0 -34
- package/dist/styles/customers/_index.scss +0 -1
- package/dist/table/ReactTableHelperComponent.d.ts +0 -12
- package/dist/table/ReactTableHelperComponent.d.ts.map +0 -1
- package/dist/table/ReactTableHelperComponent.js +0 -1
- package/dist/table/hooks/useTableQueryOptions.d.ts +0 -20
- package/dist/table/hooks/useTableQueryOptions.d.ts.map +0 -1
- package/dist/table/hooks/useTableQueryOptions.js +0 -1
- package/dist/table/types.d.ts +0 -41
- package/dist/table/types.d.ts.map +0 -1
- package/src/customers/components/filter/CustomerFilter.stories.tsx +0 -19
- package/src/customers/components/filter/CustomerFilter.tsx +0 -50
- package/src/customers/components/filter/index.ts +0 -2
- package/src/customers/components/index.ts +0 -1
- package/src/customers/index.ts +0 -1
- package/src/styles/customers/Filter.scss +0 -34
- package/src/styles/customers/_index.scss +0 -1
- package/src/table/ReactTableHelperComponent.tsx +0 -321
- package/src/table/hooks/useTableQueryOptions.ts +0 -49
- package/src/table/types.ts +0 -47
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useTranslation } from "react-i18next";
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { TextField } from "../../../static/TextField";
|
|
5
|
-
|
|
6
|
-
type CustomerFilterValues = {
|
|
7
|
-
first_name: string;
|
|
8
|
-
last_name: string;
|
|
9
|
-
email: string;
|
|
10
|
-
phone: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const FILTER_FIELDS = {
|
|
14
|
-
first_name: "firstName",
|
|
15
|
-
last_name: "lastName",
|
|
16
|
-
email: "email",
|
|
17
|
-
phone: "phone",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface CustomerFilterProps {
|
|
21
|
-
values: CustomerFilterValues;
|
|
22
|
-
onChange: (values: CustomerFilterValues) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const CustomerFilter = ({ values, onChange }: CustomerFilterProps) => {
|
|
26
|
-
const { t } = useTranslation(["Design"]);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div className="customers-filter d-flex">
|
|
30
|
-
<div className="d-flex customers-filter-items">
|
|
31
|
-
{Object.keys(FILTER_FIELDS).map((filterKeyName) => {
|
|
32
|
-
const label = t(FILTER_FIELDS[filterKeyName]);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<TextField
|
|
36
|
-
key={filterKeyName}
|
|
37
|
-
className={clsx("mb-0")}
|
|
38
|
-
type="text"
|
|
39
|
-
label={label}
|
|
40
|
-
value={values[filterKeyName]}
|
|
41
|
-
onChange={(event) =>
|
|
42
|
-
onChange({ ...values, [filterKeyName]: event.target.value })
|
|
43
|
-
}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
})}
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./filter";
|
package/src/customers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./components";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
.customers-filter {
|
|
2
|
-
gap: 0.5rem;
|
|
3
|
-
|
|
4
|
-
@include media-breakpoint-down(sm) {
|
|
5
|
-
label {
|
|
6
|
-
font-size: 0.8rem;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@include media-breakpoint-up(md) {
|
|
11
|
-
label {
|
|
12
|
-
font-size: 0.9rem;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@include media-breakpoint-up(lg) {
|
|
17
|
-
label {
|
|
18
|
-
font-size: 1rem;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@include media-breakpoint-down(lg) {
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.customers-filter-items {
|
|
27
|
-
gap: 0.5rem;
|
|
28
|
-
|
|
29
|
-
@include media-breakpoint-down(xs) {
|
|
30
|
-
flex-direction: column;
|
|
31
|
-
gap: 0rem;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "./Filter.scss";
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useMemo,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
Ref,
|
|
7
|
-
ReactElement,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { Col, Row, Table } from "react-bootstrap";
|
|
10
|
-
import { useLocation } from "react-router-dom";
|
|
11
|
-
import { isEqual } from "lodash";
|
|
12
|
-
import clsx from "clsx";
|
|
13
|
-
import {
|
|
14
|
-
useReactTable,
|
|
15
|
-
ColumnDefResolved,
|
|
16
|
-
getCoreRowModel,
|
|
17
|
-
} from "@tanstack/react-table";
|
|
18
|
-
import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
|
|
19
|
-
import TableService from "@licklist/plugins/dist/services/Table/TableService";
|
|
20
|
-
import { LoaderIndicator } from "../static/loader/LoaderIndicator";
|
|
21
|
-
import { FilterHelperComponent } from "./FilterHelperComponent";
|
|
22
|
-
import { PaginationHelperComponent } from "./PaginationHelperComponent";
|
|
23
|
-
import { PerPageHelperComponent } from "./PerPageHelperComponent";
|
|
24
|
-
import { flexRender } from "./utils";
|
|
25
|
-
import {
|
|
26
|
-
TableComponentProps,
|
|
27
|
-
TableComponentPropsWithOldTableData,
|
|
28
|
-
TableComponentPropsWithReactTableData,
|
|
29
|
-
TableColumnMeta,
|
|
30
|
-
ExtendedTableOptions,
|
|
31
|
-
} from "./types";
|
|
32
|
-
import { useTableQueryOptions } from "./hooks/useTableQueryOptions";
|
|
33
|
-
|
|
34
|
-
export type { ReactTableHelperRow } from "./types";
|
|
35
|
-
|
|
36
|
-
export type ReactTableHelperComponentProps<T extends object> =
|
|
37
|
-
TableComponentProps<T> &
|
|
38
|
-
(
|
|
39
|
-
| TableComponentPropsWithOldTableData<T>
|
|
40
|
-
| TableComponentPropsWithReactTableData<T>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export type ReactTableHelperComponentRef = {
|
|
44
|
-
options: ExtendedTableOptions | null;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* ReactTableHelperComponent
|
|
49
|
-
* simple table with our backend realization
|
|
50
|
-
* and pagination.
|
|
51
|
-
* @param props
|
|
52
|
-
* @constructor
|
|
53
|
-
*/
|
|
54
|
-
function WrappedReactTableHelperComponent<T extends object>(
|
|
55
|
-
props: ReactTableHelperComponentProps<T>,
|
|
56
|
-
ref: Ref<ReactTableHelperComponentRef>
|
|
57
|
-
) {
|
|
58
|
-
const {
|
|
59
|
-
paginator,
|
|
60
|
-
headers,
|
|
61
|
-
renderItemFn,
|
|
62
|
-
isLoading,
|
|
63
|
-
striped = true,
|
|
64
|
-
bordered = true,
|
|
65
|
-
displaySearchBar = true,
|
|
66
|
-
displayPerPageSelect = true,
|
|
67
|
-
displayShowingSection = true,
|
|
68
|
-
externalFilters = {},
|
|
69
|
-
initialOptions = {},
|
|
70
|
-
columns,
|
|
71
|
-
sortableColumns = [],
|
|
72
|
-
renderRow,
|
|
73
|
-
...tableProps
|
|
74
|
-
} = props;
|
|
75
|
-
|
|
76
|
-
const { pathname } = useLocation();
|
|
77
|
-
|
|
78
|
-
const {
|
|
79
|
-
sortKey,
|
|
80
|
-
sortDirection,
|
|
81
|
-
options,
|
|
82
|
-
setOptions,
|
|
83
|
-
optionsCache,
|
|
84
|
-
setOptionsCache,
|
|
85
|
-
cachedExternalFilters,
|
|
86
|
-
setCachedExternalFilters,
|
|
87
|
-
} = useTableQueryOptions({ initialOptions, externalFilters });
|
|
88
|
-
|
|
89
|
-
const tableColumns = useMemo(() => {
|
|
90
|
-
if (!columns && !headers) return [];
|
|
91
|
-
|
|
92
|
-
if (columns && !headers) {
|
|
93
|
-
return columns.map((column) => {
|
|
94
|
-
const { accessorKey } = column as ColumnDefResolved<T>;
|
|
95
|
-
const isSortable = sortableColumns.includes(accessorKey);
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
...column,
|
|
99
|
-
meta: {
|
|
100
|
-
className: TableService.getHeaderClasses(
|
|
101
|
-
{ isSortable, key: accessorKey, title: accessorKey },
|
|
102
|
-
sortKey,
|
|
103
|
-
sortDirection
|
|
104
|
-
),
|
|
105
|
-
onClick: isSortable ? () => onSort(accessorKey!) : undefined,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return headers.map((header) => {
|
|
112
|
-
if (typeof header === "string") {
|
|
113
|
-
return {
|
|
114
|
-
accessorKey: header.toLowerCase(),
|
|
115
|
-
header: () => header,
|
|
116
|
-
meta: {
|
|
117
|
-
className: TableService.getHeaderClasses(
|
|
118
|
-
header,
|
|
119
|
-
sortKey,
|
|
120
|
-
sortDirection
|
|
121
|
-
),
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
accessorKey: header?.key || header.title.toLowerCase(),
|
|
128
|
-
header: () => header.title,
|
|
129
|
-
meta: {
|
|
130
|
-
onClick: () => header.isSortable && onSort(header.key!),
|
|
131
|
-
className: TableService.getHeaderClasses(
|
|
132
|
-
header,
|
|
133
|
-
sortKey,
|
|
134
|
-
sortDirection
|
|
135
|
-
),
|
|
136
|
-
style: { width: header?.width || "auto" },
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
}, [headers, columns, sortKey, sortDirection, sortableColumns]);
|
|
142
|
-
|
|
143
|
-
const { getHeaderGroups, getRowModel } = useReactTable<T>({
|
|
144
|
-
data: paginator.data,
|
|
145
|
-
columns: tableColumns,
|
|
146
|
-
getCoreRowModel: getCoreRowModel<T>(),
|
|
147
|
-
...tableProps,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
useImperativeHandle(ref, () => {
|
|
151
|
-
return { options };
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Redirect to the URL with a new parameters
|
|
155
|
-
// ONLY: if any option or external filters has changed
|
|
156
|
-
useEffect(
|
|
157
|
-
() => {
|
|
158
|
-
if (
|
|
159
|
-
isEqual(optionsCache, options) &&
|
|
160
|
-
isEqual(cachedExternalFilters, externalFilters)
|
|
161
|
-
)
|
|
162
|
-
return;
|
|
163
|
-
|
|
164
|
-
setOptionsCache(options);
|
|
165
|
-
setCachedExternalFilters(externalFilters);
|
|
166
|
-
|
|
167
|
-
const nextUrlSearchParams = new URLSearchParams({
|
|
168
|
-
...options,
|
|
169
|
-
...externalFilters,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
RouteService.redirectTo(
|
|
173
|
-
[pathname, nextUrlSearchParams.toString()].join("?")
|
|
174
|
-
);
|
|
175
|
-
},
|
|
176
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
177
|
-
[pathname, options, externalFilters]
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
const onSort = (key: string) => {
|
|
181
|
-
let nextDirection = TableService.DEFAULT_SORT_DIRECTION;
|
|
182
|
-
|
|
183
|
-
if (sortKey === key) {
|
|
184
|
-
setOptions((prevOptions) => {
|
|
185
|
-
nextDirection = TableService.getSortDirection(
|
|
186
|
-
prevOptions.sortDirection,
|
|
187
|
-
nextDirection
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
...prevOptions,
|
|
192
|
-
sortKey: key,
|
|
193
|
-
sortDirection: nextDirection,
|
|
194
|
-
};
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
setOptions((prevOptions) => ({
|
|
198
|
-
...prevOptions,
|
|
199
|
-
sortKey: key,
|
|
200
|
-
sortDirection: nextDirection,
|
|
201
|
-
}));
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const onPerPageChange = (nextPerPage: number) => {
|
|
206
|
-
setOptions((prevOptions) => ({
|
|
207
|
-
...prevOptions,
|
|
208
|
-
perPage: nextPerPage,
|
|
209
|
-
}));
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const onPageChange = (nextPage: number) => {
|
|
213
|
-
setOptions((prevOptions) => ({
|
|
214
|
-
...prevOptions,
|
|
215
|
-
page: nextPage,
|
|
216
|
-
}));
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const onFilterChange = (nextFilter: string) => {
|
|
220
|
-
setOptions(({ page: prevPage, ...prevOptions }) => {
|
|
221
|
-
let nextPage = prevPage;
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
(!nextFilter && prevOptions.filter) ||
|
|
225
|
-
(nextFilter && !prevOptions.filter)
|
|
226
|
-
) {
|
|
227
|
-
nextPage = 1;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
...prevOptions,
|
|
232
|
-
page: nextPage,
|
|
233
|
-
filter: nextFilter,
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<div className={clsx("table-helper", isLoading ? "py-5" : "py-1")}>
|
|
240
|
-
<LoaderIndicator isLoaded={!isLoading}>
|
|
241
|
-
<Row>
|
|
242
|
-
<Col>
|
|
243
|
-
{displayPerPageSelect && (
|
|
244
|
-
<PerPageHelperComponent
|
|
245
|
-
onChangeFn={onPerPageChange}
|
|
246
|
-
defaultValue={
|
|
247
|
-
paginator?.per_page ?? TableService.DEFAULT_PER_PAGE
|
|
248
|
-
}
|
|
249
|
-
/>
|
|
250
|
-
)}
|
|
251
|
-
</Col>
|
|
252
|
-
<Col>
|
|
253
|
-
{displaySearchBar && (
|
|
254
|
-
<FilterHelperComponent
|
|
255
|
-
onClickFn={onFilterChange}
|
|
256
|
-
defaultValue={options.filter ?? ""}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
</Col>
|
|
260
|
-
</Row>
|
|
261
|
-
<Row>
|
|
262
|
-
<Col>
|
|
263
|
-
<div className="table-responsive">
|
|
264
|
-
<Table striped={striped} bordered={bordered} hover>
|
|
265
|
-
<thead>
|
|
266
|
-
{getHeaderGroups().map((headerGroup) => (
|
|
267
|
-
<tr key={headerGroup.id}>
|
|
268
|
-
{headerGroup.headers.map((header) => {
|
|
269
|
-
const headerMeta = header.column.columnDef
|
|
270
|
-
.meta as TableColumnMeta;
|
|
271
|
-
|
|
272
|
-
return (
|
|
273
|
-
<th
|
|
274
|
-
key={header.id}
|
|
275
|
-
className={headerMeta?.className}
|
|
276
|
-
onClick={headerMeta?.onClick}
|
|
277
|
-
style={headerMeta?.style}
|
|
278
|
-
>
|
|
279
|
-
{flexRender(
|
|
280
|
-
header.column.columnDef.header,
|
|
281
|
-
header.getContext()
|
|
282
|
-
)}
|
|
283
|
-
</th>
|
|
284
|
-
);
|
|
285
|
-
})}
|
|
286
|
-
</tr>
|
|
287
|
-
))}
|
|
288
|
-
</thead>
|
|
289
|
-
<tbody>
|
|
290
|
-
{getRowModel().rows.map((row, index) => {
|
|
291
|
-
if (renderItemFn) {
|
|
292
|
-
return renderItemFn(row.original, index);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return renderRow(row);
|
|
296
|
-
})}
|
|
297
|
-
</tbody>
|
|
298
|
-
</Table>
|
|
299
|
-
</div>
|
|
300
|
-
</Col>
|
|
301
|
-
</Row>
|
|
302
|
-
|
|
303
|
-
<PaginationHelperComponent
|
|
304
|
-
displayShowingSection={displayShowingSection}
|
|
305
|
-
paginator={paginator}
|
|
306
|
-
onPageChangeFn={onPageChange}
|
|
307
|
-
/>
|
|
308
|
-
</LoaderIndicator>
|
|
309
|
-
</div>
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const ReactTableHelperComponent = forwardRef(
|
|
314
|
-
WrappedReactTableHelperComponent
|
|
315
|
-
) as <T extends object>(
|
|
316
|
-
props: ReactTableHelperComponentProps<T> & {
|
|
317
|
-
ref?: Ref<ReactTableHelperComponentRef>;
|
|
318
|
-
}
|
|
319
|
-
) => ReactElement;
|
|
320
|
-
|
|
321
|
-
export { ReactTableHelperComponent };
|
|
@@ -1,49 +0,0 @@
|
|
|
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/types.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
};
|