@antscorp/antsomi-ui 1.3.5-beta.526 → 1.3.5-beta.528
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/es/components/icons/DataIcon.js +3 -13
- package/es/components/icons/GridViewIcon.d.ts +3 -0
- package/es/components/icons/GridViewIcon.js +10 -0
- package/es/components/icons/SearchIcon.d.ts +3 -0
- package/es/components/icons/SearchIcon.js +9 -0
- package/es/components/icons/ViewColumnIcon.d.ts +3 -0
- package/es/components/icons/ViewColumnIcon.js +10 -0
- package/es/components/icons/hooks/useIcon.d.ts +2 -2
- package/es/components/icons/hooks/useIcon.js +1 -1
- package/es/components/icons/index.d.ts +3 -0
- package/es/components/icons/index.js +3 -0
- package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +1 -1
- package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.js +1 -1
- package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.js +2 -0
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +6 -6
- package/es/components/molecules/ThumbnailCard/types.d.ts +1 -0
- package/es/components/organism/DataTable/DataTable.js +25 -4
- package/es/components/organism/DataTable/components/GridView/index.d.ts +5 -0
- package/es/components/organism/DataTable/components/GridView/index.js +13 -0
- package/es/components/organism/DataTable/components/Table/ResizableCell.js +2 -2
- package/es/components/organism/DataTable/components/Table/index.js +1 -1
- package/es/components/organism/DataTable/components/Toolbar/ToolbarActionButtons.js +21 -8
- package/es/components/organism/DataTable/components/index.d.ts +1 -0
- package/es/components/organism/DataTable/components/index.js +1 -0
- package/es/components/organism/DataTable/constants/toolbar.d.ts +4 -0
- package/es/components/organism/DataTable/constants/toolbar.js +15 -3
- package/es/components/organism/DataTable/hooks/useDataTableListing/types.d.ts +14 -1
- package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.d.ts +4 -1
- package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.js +40 -2
- package/es/components/organism/DataTable/styled/index.d.ts +1 -0
- package/es/components/organism/DataTable/styled/index.js +23 -2
- package/es/components/organism/DataTable/types/index.d.ts +2 -0
- package/es/components/organism/DataTable/types/toolbar.d.ts +11 -2
- package/es/components/template/TemplateListing/index.js +2 -3
- package/es/types/actionsButton.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
// Libraries
|
|
13
2
|
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
14
4
|
export const DataIcon = forwardRef((props, ref) => {
|
|
15
|
-
const
|
|
16
|
-
return (React.createElement("svg", Object.assign({
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (React.createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" }, props, { ref: ref, width: width, height: height }),
|
|
17
7
|
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.002 6.5C19.002 7.88071 15.6499 9 11.515 9C7.38 9 4.02795 7.88071 4.02795 6.5C4.02795 5.11929 7.38 4 11.515 4C15.6499 4 19.002 5.11929 19.002 6.5ZM18.974 12.131C18.974 13.42 15.622 14.465 11.487 14.465C7.352 14.465 4 13.419 4 12.131V8.46204C4 9.75104 7.352 10.795 11.487 10.795C15.622 10.795 18.974 9.74904 18.974 8.46204V12.131ZM18.974 17.8423C18.974 19.1313 15.622 20.1763 11.487 20.1763C7.352 20.1763 4 19.1303 4 17.8423V14.1733C4 15.4623 7.352 16.5063 11.487 16.5063C15.622 16.5063 18.974 15.4603 18.974 14.1733V17.8423Z", fill: "currentColor" })));
|
|
18
8
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
4
|
+
export const GridViewIcon = forwardRef((props, ref) => {
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor" }, props, { ref: ref, height: height, width: width }),
|
|
7
|
+
React.createElement("g", { fillRule: "evenodd" },
|
|
8
|
+
React.createElement("path", { d: "M0 0h24v24H0z", fill: "none" }),
|
|
9
|
+
React.createElement("path", { d: "M3 3v8h8V3H3zm6 6H5V5h4v4zm-6 4v8h8v-8H3zm6 6H5v-4h4v4zm4-16v8h8V3h-8zm6 6h-4V5h4v4zm-6 4v8h8v-8h-8zm6 6h-4v-4h4v4z" }))));
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
4
|
+
export const SearchIcon = forwardRef((props, ref) => {
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, props, { ref: ref, height: height, width: width, fill: "currentColor" }),
|
|
7
|
+
React.createElement("path", { d: "M0 0h24v24H0V0z", fill: "none" }),
|
|
8
|
+
React.createElement("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" })));
|
|
9
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
4
|
+
export const ViewColumnIcon = forwardRef((props, ref) => {
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", enableBackground: "new 0 0 24 24" }, props, { viewBox: "0 0 24 24", ref: ref, height: height, width: width, fill: "currentColor" }),
|
|
7
|
+
React.createElement("rect", { fill: "none", height: "24", width: "24" }),
|
|
8
|
+
React.createElement("g", null,
|
|
9
|
+
React.createElement("path", { d: "M14.67,5v14H9.33V5H14.67z M15.67,19H21V5h-5.33V19z M8.33,19V5H3v14H8.33z" }))));
|
|
10
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
export const useIcon = (props) => {
|
|
3
3
|
const { size = 24 } = props;
|
|
4
|
-
const [width, height] = useMemo(() => [
|
|
4
|
+
const [width, height] = useMemo(() => [(props === null || props === void 0 ? void 0 : props.width) || size, (props === null || props === void 0 ? void 0 : props.height) || size], [size, props.width, props.height]);
|
|
5
5
|
return {
|
|
6
6
|
width,
|
|
7
7
|
height,
|
|
@@ -57,3 +57,6 @@ export { LoadingIcon } from './LoadingIcon';
|
|
|
57
57
|
export { DataIcon } from './DataIcon';
|
|
58
58
|
export { TableIcon } from './TableIcon';
|
|
59
59
|
export { ExpandLessIcon } from './ExpandLessIcon';
|
|
60
|
+
export { SearchIcon } from './SearchIcon';
|
|
61
|
+
export { ViewColumnIcon } from './ViewColumnIcon';
|
|
62
|
+
export { GridViewIcon } from './GridViewIcon';
|
|
@@ -57,3 +57,6 @@ export { LoadingIcon } from './LoadingIcon';
|
|
|
57
57
|
export { DataIcon } from './DataIcon';
|
|
58
58
|
export { TableIcon } from './TableIcon';
|
|
59
59
|
export { ExpandLessIcon } from './ExpandLessIcon';
|
|
60
|
+
export { SearchIcon } from './SearchIcon';
|
|
61
|
+
export { ViewColumnIcon } from './ViewColumnIcon';
|
|
62
|
+
export { GridViewIcon } from './GridViewIcon';
|
|
@@ -229,7 +229,7 @@ export const MatchesAny = props => {
|
|
|
229
229
|
React.createElement(Text, { strong: true }, `${t(translations.global.selected)} (${(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) || 0})`),
|
|
230
230
|
React.createElement(TextButton, { disabled: isDisableRemoveAll, onClick: onRemoveAll }, t(translations.global.removeAll).toString())),
|
|
231
231
|
React.createElement("div", { className: "matches-any__body" },
|
|
232
|
-
React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5,
|
|
232
|
+
React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, size: 48 }), description: t(translations.global.selectItemsFromList).toString() })) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
|
|
233
233
|
transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
|
|
234
234
|
transition: 'transform 0.3s ease',
|
|
235
235
|
}, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) }))))));
|
|
@@ -59,7 +59,7 @@ export const GeneralAccess = ({ generalAccessSettings }) => {
|
|
|
59
59
|
React.createElement("div", { className: "accessable-title" }, isPublic ? 'Public' : 'Restricted'),
|
|
60
60
|
allowEdit && (React.createElement(Icon, { className: "icon-angle", type: "icon-ants-expand-more", style: { fontSize: 20 } })))),
|
|
61
61
|
React.createElement("div", { className: "description" }, renderDescription())),
|
|
62
|
-
!!isPublic && publicRole && (React.createElement(Dropdown, { placement: "
|
|
62
|
+
!!isPublic && publicRole && (React.createElement(Dropdown, { placement: "bottomRight", trigger: ['click'], destroyPopupOnHide: true, disabled: !allowEdit || isShowOnlyText, overlayStyle: { zIndex: 3002 }, menu: {
|
|
63
63
|
items: [
|
|
64
64
|
publicRole === PUBLIC_ROLE.ONLY_VIEWER
|
|
65
65
|
? {
|
|
@@ -11,6 +11,7 @@ export const StyledGeneralAccessRoot = styled.div `
|
|
|
11
11
|
|
|
12
12
|
.setting {
|
|
13
13
|
display: flex;
|
|
14
|
+
align-items: center;
|
|
14
15
|
justify-content: space-between;
|
|
15
16
|
border: 1px solid #e6e6e6;
|
|
16
17
|
border-radius: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadius}px;
|
|
@@ -53,6 +54,7 @@ export const StyledGeneralAccessRoot = styled.div `
|
|
|
53
54
|
display: flex;
|
|
54
55
|
align-items: center;
|
|
55
56
|
gap: 4px;
|
|
57
|
+
cursor: pointer;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
`;
|
|
@@ -221,8 +221,8 @@ export const ThumbnailCard = (props) => {
|
|
|
221
221
|
const [modal, contextHolder] = Modal.useModal();
|
|
222
222
|
const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, thumbnailFit, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, thumbnailCacheValue, actionButtons, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "thumbnailFit", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "thumbnailCacheValue", "actionButtons", "onClickWrapper"]);
|
|
223
223
|
const _a = removeModalProps || {}, { onOk } = _a, restOfRemoveTemplateModalProps = __rest(_a, ["onOk"]);
|
|
224
|
-
const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick"]);
|
|
225
|
-
const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick"]);
|
|
224
|
+
const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit, show: showEditBtn = true } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick", "show"]);
|
|
225
|
+
const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview, show: showPreviewBtn = true } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick", "show"]);
|
|
226
226
|
// Memo
|
|
227
227
|
const showSkeletonMemo =
|
|
228
228
|
// NOTES: Hot fix for showSkeleton base url if showSkeleton is not defined
|
|
@@ -286,16 +286,16 @@ export const ThumbnailCard = (props) => {
|
|
|
286
286
|
} }))),
|
|
287
287
|
actionAvailable && !loading && (React.createElement(React.Fragment, null,
|
|
288
288
|
React.createElement(Flex, { className: "center-action", align: "center", gap: 10, vertical: true },
|
|
289
|
-
React.createElement(Button, Object.assign({ type: "primary", className: "animate__animated animate__fadeIn" }, restOfEditBtnProps, { onClick: e => {
|
|
289
|
+
showEditBtn && (React.createElement(Button, Object.assign({ type: "primary", className: "animate__animated animate__fadeIn" }, restOfEditBtnProps, { onClick: e => {
|
|
290
290
|
e.stopPropagation();
|
|
291
291
|
onClickEdit === null || onClickEdit === void 0 ? void 0 : onClickEdit(id);
|
|
292
292
|
} }),
|
|
293
|
-
React.createElement(Typography.Text, { ellipsis: { tooltip: editText }, style: { maxWidth: '100%', color: 'inherit' } }, editText)),
|
|
294
|
-
React.createElement(Button, Object.assign({ className: "animate__animated animate__fadeIn", onClick: e => {
|
|
293
|
+
React.createElement(Typography.Text, { ellipsis: { tooltip: editText }, style: { maxWidth: '100%', color: 'inherit' } }, editText))),
|
|
294
|
+
showPreviewBtn && (React.createElement(Button, Object.assign({ className: "animate__animated animate__fadeIn", onClick: e => {
|
|
295
295
|
e.stopPropagation();
|
|
296
296
|
onClickPreview === null || onClickPreview === void 0 ? void 0 : onClickPreview(id);
|
|
297
297
|
} }, restOfPreviewBtnProps),
|
|
298
|
-
React.createElement(Typography.Text, { ellipsis: { tooltip: previewText }, style: { maxWidth: '100%', color: 'inherit' } }, previewText))),
|
|
298
|
+
React.createElement(Typography.Text, { ellipsis: { tooltip: previewText }, style: { maxWidth: '100%', color: 'inherit' } }, previewText)))),
|
|
299
299
|
React.createElement("div", { className: "top-right-corner-action animate__animated animate__fadeIn" },
|
|
300
300
|
renderActionButtons(),
|
|
301
301
|
removable && (React.createElement(Tooltip, { title: i18nInstance.t(translations.remove).toString() },
|
|
@@ -14,22 +14,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
14
14
|
import React from 'react';
|
|
15
15
|
// Hooks
|
|
16
16
|
import { useDataTable } from './hooks';
|
|
17
|
+
import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
17
18
|
// Styled
|
|
18
|
-
import { DataTableWrapper } from './styled';
|
|
19
|
+
import { DataTableContent, DataTableWrapper } from './styled';
|
|
20
|
+
// Constants
|
|
21
|
+
import { GRID_VIEW_KEYS } from './constants';
|
|
19
22
|
// Components
|
|
20
|
-
import { Table, Pagination, Toolbar } from './components';
|
|
23
|
+
import { Table, Pagination, Toolbar, GridView } from './components';
|
|
21
24
|
// Providers
|
|
22
25
|
import { DataTableProvider } from './providers/DataTableProvider';
|
|
23
26
|
import { AntdTableConfigProvider } from './providers';
|
|
24
27
|
// Store
|
|
25
28
|
import { useDataTableStore } from './hooks/useDataTableStore';
|
|
29
|
+
const { GRID, TABLE } = GRID_VIEW_KEYS;
|
|
30
|
+
const RENDER_VIEW_COMPONENTS = {
|
|
31
|
+
[GRID]: React.createElement(GridView, null),
|
|
32
|
+
[TABLE]: React.createElement(Table, null),
|
|
33
|
+
};
|
|
26
34
|
function DataTableComponent(props) {
|
|
35
|
+
const { contentRender } = props || {};
|
|
27
36
|
// Hooks
|
|
28
37
|
const { pagination, toolbar, setPagination } = useDataTable(props);
|
|
29
|
-
const { show: showToolbar = true } = toolbar || {};
|
|
38
|
+
const { show: showToolbar = true, actionButtons } = toolbar || {};
|
|
39
|
+
const { GRID_VIEW } = actionButtons || {};
|
|
40
|
+
const renderModeView = useDeepCompareMemo(() => {
|
|
41
|
+
// Check if has content render then return this content
|
|
42
|
+
if (contentRender) {
|
|
43
|
+
return contentRender();
|
|
44
|
+
}
|
|
45
|
+
const modeView = (GRID_VIEW === null || GRID_VIEW === void 0 ? void 0 : GRID_VIEW.mode) || 'TABLE';
|
|
46
|
+
const renderContentWrapper = (key = 'TABLE', children) => (React.createElement(DataTableContent, { style: {
|
|
47
|
+
display: key === modeView ? 'flex' : 'none',
|
|
48
|
+
} }, children));
|
|
49
|
+
return Object.keys(RENDER_VIEW_COMPONENTS).map(key => (React.createElement(React.Fragment, { key: key }, renderContentWrapper(key, RENDER_VIEW_COMPONENTS[key]))));
|
|
50
|
+
}, [GRID_VIEW === null || GRID_VIEW === void 0 ? void 0 : GRID_VIEW.mode, contentRender]);
|
|
30
51
|
return (React.createElement(DataTableWrapper, null,
|
|
31
52
|
!!showToolbar && React.createElement(Toolbar, null),
|
|
32
|
-
|
|
53
|
+
renderModeView,
|
|
33
54
|
React.createElement(Pagination, Object.assign({ id: "data-table-pagination" }, pagination, { onChange: payload => {
|
|
34
55
|
var _a;
|
|
35
56
|
setPagination(payload);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { memo } from 'react';
|
|
3
|
+
// Components
|
|
4
|
+
import { TemplateListing } from '@antscorp/antsomi-ui/es/components/template';
|
|
5
|
+
import { useDataTableContext } from '../../contexts/DataTableContext';
|
|
6
|
+
export const GridView = memo(() => {
|
|
7
|
+
const gridView = useDataTableContext(store => { var _a; return (_a = store.toolbar.actionButtons) === null || _a === void 0 ? void 0 : _a.GRID_VIEW; });
|
|
8
|
+
if (gridView) {
|
|
9
|
+
const { templateListingProps } = gridView;
|
|
10
|
+
return React.createElement(TemplateListing, Object.assign({}, templateListingProps));
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
});
|
|
@@ -34,8 +34,8 @@ export const ResizableCell = props => {
|
|
|
34
34
|
return (React.createElement("th", Object.assign({}, restProps, { style: columnStyle, onClick: onClick }), CellHeaderContent));
|
|
35
35
|
}
|
|
36
36
|
const handleStyleResizable = (type) => {
|
|
37
|
-
var _a
|
|
38
|
-
(
|
|
37
|
+
var _a;
|
|
38
|
+
(_a = tableRef === null || tableRef === void 0 ? void 0 : tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.antsomi-table-body > table > tbody.antsomi-table-tbody > .antsomi-table-row').forEach(rowEl => {
|
|
39
39
|
var _a;
|
|
40
40
|
const cell = (_a = rowEl.querySelectorAll(`.antsomi-table-cell:not(.antsomi-table-selection-column):not(.antsomi-table-row-expand-icon-cell)`)) === null || _a === void 0 ? void 0 : _a[index !== null && index !== void 0 ? index : 0];
|
|
41
41
|
if (cell) {
|
|
@@ -65,7 +65,7 @@ export const Table = memo(() => {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
}, [tableProps.columns, columnWidths]);
|
|
68
|
-
return (React.createElement(ConfigProvider, { theme: { token: { motion: false } }, renderEmpty: () => (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5,
|
|
68
|
+
return (React.createElement(ConfigProvider, { theme: { token: { motion: false } }, renderEmpty: () => (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, size: 48 }), description: t(translations.noData).toString() })) },
|
|
69
69
|
React.createElement(StyledTable, Object.assign({}, restOfTable, { ref: ref => {
|
|
70
70
|
tableRef.current = ref === null || ref === void 0 ? void 0 : ref.nativeElement;
|
|
71
71
|
}, scroll: Object.assign(Object.assign({}, scroll), { y: (scroll === null || scroll === void 0 ? void 0 : scroll.y) || '100%', x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%' }), components: {
|
|
@@ -27,6 +27,7 @@ import { Icon } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
|
27
27
|
// Utils
|
|
28
28
|
import { renderActionButtons } from '@antscorp/antsomi-ui/es/utils';
|
|
29
29
|
import { flatFilterMetrics } from '../../utils';
|
|
30
|
+
import { GridViewIcon, TableIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
30
31
|
export const ToolbarActionButtons = memo(() => {
|
|
31
32
|
// Store
|
|
32
33
|
const actionButtons = useDataTableContext(useShallow(store => store.toolbar.actionButtons));
|
|
@@ -54,13 +55,16 @@ export const ToolbarActionButtons = memo(() => {
|
|
|
54
55
|
};
|
|
55
56
|
// Renders
|
|
56
57
|
const renderComponent = (action) => {
|
|
57
|
-
const { key, label, buttonProps, icon, customRender } = action;
|
|
58
|
-
const actionButton = (
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const { key, label: actionLabel, buttonProps, icon: actionIcon, customRender } = action;
|
|
59
|
+
const actionButton = (payload) => {
|
|
60
|
+
const { icon = actionIcon, label = actionLabel } = payload || {};
|
|
61
|
+
return (React.createElement(ActionButton, Object.assign({ key: key, type: "text" }, buttonProps),
|
|
62
|
+
React.createElement("div", { className: "action-icon" }, typeof icon === 'string' ? React.createElement(Icon, { type: icon }) : icon),
|
|
63
|
+
`${label}`.toUpperCase()));
|
|
64
|
+
};
|
|
61
65
|
// If customRender is exist then return custom render instead of render internal component
|
|
62
66
|
if (customRender)
|
|
63
|
-
return actionButton;
|
|
67
|
+
return actionButton();
|
|
64
68
|
switch (key) {
|
|
65
69
|
case 'SEARCH': {
|
|
66
70
|
const _a = action, { addFilterInfo, onClickSearchItem, isAddFilterFromSearchItem } = _a, restOfAction = __rest(_a, ["addFilterInfo", "onClickSearchItem", "isAddFilterFromSearchItem"]);
|
|
@@ -69,13 +73,22 @@ export const ToolbarActionButtons = memo(() => {
|
|
|
69
73
|
onAddFilterFromSearch(searchItem.label, addFilterInfo);
|
|
70
74
|
}
|
|
71
75
|
onClickSearchItem === null || onClickSearchItem === void 0 ? void 0 : onClickSearchItem(searchItem, index);
|
|
72
|
-
}, onAddFilter: value => onAddFilterFromSearch(value, addFilterInfo) }), actionButton));
|
|
76
|
+
}, onAddFilter: value => onAddFilterFromSearch(value, addFilterInfo) }), actionButton()));
|
|
73
77
|
}
|
|
74
78
|
case 'COLUMN': {
|
|
75
|
-
return React.createElement(ModifyColumn, { key: key }, actionButton);
|
|
79
|
+
return React.createElement(ModifyColumn, { key: key }, actionButton());
|
|
80
|
+
}
|
|
81
|
+
case 'GRID_VIEW': {
|
|
82
|
+
const { mode, onChangeMode = () => { } } = action;
|
|
83
|
+
return (React.createElement("div", { key: key, onClick: () => {
|
|
84
|
+
onChangeMode(mode === 'TABLE' ? 'GRID' : 'TABLE');
|
|
85
|
+
} }, actionButton({
|
|
86
|
+
icon: mode === 'TABLE' ? React.createElement(GridViewIcon, null) : React.createElement(TableIcon, null),
|
|
87
|
+
label: mode === 'TABLE' ? 'Grid view' : 'Table',
|
|
88
|
+
})));
|
|
76
89
|
}
|
|
77
90
|
default:
|
|
78
|
-
return actionButton;
|
|
91
|
+
return actionButton();
|
|
79
92
|
}
|
|
80
93
|
};
|
|
81
94
|
return (React.createElement(ToolbarActionButtonWrapper, { align: "center", gap: 2 }, renderActionButtons({
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
3
|
+
// Icons
|
|
4
|
+
import { SearchIcon, TableIcon, ViewColumnIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
2
5
|
// Types
|
|
3
6
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
4
7
|
export const TOOLBAR_ACTION_KEYS = {
|
|
@@ -13,17 +16,17 @@ export const TOOLBAR_ACTION_KEYS = {
|
|
|
13
16
|
GRID_VIEW: 'GRID_VIEW',
|
|
14
17
|
MORE: 'MORE',
|
|
15
18
|
};
|
|
16
|
-
const { SEARCH, COLUMN, EXPLORE, EXPORT, CALENDAR, TABLE, COMPARE } = TOOLBAR_ACTION_KEYS;
|
|
19
|
+
const { SEARCH, COLUMN, EXPLORE, EXPORT, CALENDAR, TABLE, COMPARE, GRID_VIEW } = TOOLBAR_ACTION_KEYS;
|
|
17
20
|
export const TOOLBAR_ACTION_OPTIONS = {
|
|
18
21
|
[SEARCH]: {
|
|
19
22
|
key: SEARCH,
|
|
20
23
|
label: i18nInstance.t(translations.dataTableToolbar.toolbarActions.search).toString(),
|
|
21
|
-
icon:
|
|
24
|
+
icon: React.createElement(SearchIcon, null),
|
|
22
25
|
},
|
|
23
26
|
[COLUMN]: {
|
|
24
27
|
key: COLUMN,
|
|
25
28
|
label: 'Column',
|
|
26
|
-
icon:
|
|
29
|
+
icon: React.createElement(ViewColumnIcon, null),
|
|
27
30
|
},
|
|
28
31
|
[EXPLORE]: {
|
|
29
32
|
key: EXPLORE,
|
|
@@ -50,4 +53,13 @@ export const TOOLBAR_ACTION_OPTIONS = {
|
|
|
50
53
|
label: 'Compare',
|
|
51
54
|
icon: 'file-download',
|
|
52
55
|
},
|
|
56
|
+
[GRID_VIEW]: {
|
|
57
|
+
key: GRID_VIEW,
|
|
58
|
+
label: 'Grid View',
|
|
59
|
+
icon: React.createElement(TableIcon, null),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const GRID_VIEW_KEYS = {
|
|
63
|
+
TABLE: 'TABLE',
|
|
64
|
+
GRID: 'GRID',
|
|
53
65
|
};
|
|
@@ -7,7 +7,8 @@ import { PaginationProps } from '../../components';
|
|
|
7
7
|
import { ColumnType } from 'antd/es/table';
|
|
8
8
|
import { SorterResult } from 'antd/es/table/interface';
|
|
9
9
|
import { TGetColumnMetrics, TGetFilterMetricList, TGetModifyColumnList, TGetSavedFilterList, TGetSearchListing, TGetTableListing } from '@antscorp/antsomi-ui/es/queries';
|
|
10
|
-
import { MatchesAnyItem } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
10
|
+
import { MatchesAnyItem, TThumbnailButton } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
11
|
+
import { TTemplateItem } from '@antscorp/antsomi-ui/es/components/template';
|
|
11
12
|
export type TApiGlobal = AxiosRequestConfig<any> & {
|
|
12
13
|
enabled?: boolean;
|
|
13
14
|
};
|
|
@@ -60,6 +61,17 @@ type TSearchProps<TSearchType> = Partial<Pick<TSearchActionButton, 'addFilterInf
|
|
|
60
61
|
onClickSearchItem?: (record?: Partial<TSearchType>) => void;
|
|
61
62
|
formatData?: (response: any) => Partial<TSearchType>[];
|
|
62
63
|
};
|
|
64
|
+
type TGridViewProps<TTableType> = {
|
|
65
|
+
itemMapKeys: Record<keyof TTemplateItem, keyof TTableType>;
|
|
66
|
+
name?: (record: TTableType) => ReactNode | ReactNode;
|
|
67
|
+
thumbnail?: (record: TTableType) => string | string;
|
|
68
|
+
itemProps?: {
|
|
69
|
+
showButton?: boolean;
|
|
70
|
+
buttonProps?: Omit<TThumbnailButton, 'onClick'> & {
|
|
71
|
+
onClick: (record: TTableType) => void;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
63
75
|
export type TFormatFilterValue = Partial<Record<TOperatorKey, (value: any) => unknown>>;
|
|
64
76
|
export interface UseDataTableListingProps<TTableType = any, TSearchType = any> {
|
|
65
77
|
name?: string;
|
|
@@ -98,6 +110,7 @@ export interface UseDataTableListingProps<TTableType = any, TSearchType = any> {
|
|
|
98
110
|
*/
|
|
99
111
|
formatFilterValue?: TFormatFilterValue;
|
|
100
112
|
};
|
|
113
|
+
gridView?: TGridViewProps<TTableType>;
|
|
101
114
|
}
|
|
102
115
|
export interface DataTableLocalStorage<TTableType = any> {
|
|
103
116
|
filter?: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useGetColumnMetrics, useGetFilterMetricList, useGetModifyColumnList, useGetSavedFilterList, useGetSearchListing, useGetTableListing } from '@antscorp/antsomi-ui/es/queries';
|
|
3
3
|
import { UseDataTableListingProps } from './types';
|
|
4
|
-
import { FilterItem, FilterProps, TColumnActionButton, TSearchActionButton, TableProps } from '../../types';
|
|
4
|
+
import { FilterItem, FilterProps, TColumnActionButton, TGridViewActionButton, TSearchActionButton, TableProps, TGridViewKeys } from '../../types';
|
|
5
5
|
import { PaginationProps } from '../../components';
|
|
6
6
|
import { SorterResult } from 'antd/es/table/interface';
|
|
7
7
|
interface TUseDataTableListing<TTableType = any> {
|
|
@@ -10,6 +10,7 @@ interface TUseDataTableListing<TTableType = any> {
|
|
|
10
10
|
pagination: PaginationProps;
|
|
11
11
|
table: TableProps<TTableType>;
|
|
12
12
|
search: TSearchActionButton;
|
|
13
|
+
gridView: TGridViewActionButton;
|
|
13
14
|
/**
|
|
14
15
|
* This selectedRowKeys is deprecated. Use selectedRow.keys instead.
|
|
15
16
|
* @deprecated
|
|
@@ -49,6 +50,8 @@ type TState<TTableType = any> = {
|
|
|
49
50
|
sorter?: SorterResult<TTableType>;
|
|
50
51
|
selectedFilterItem?: FilterItem;
|
|
51
52
|
expandedRowKeys?: React.Key[];
|
|
53
|
+
/** Mode view of data table listing */
|
|
54
|
+
modeView?: TGridViewKeys;
|
|
52
55
|
};
|
|
53
56
|
export declare function useDataTableListing<TTableType = Record<string, any>, TSearchType = any>(props: UseDataTableListingProps<TTableType, TSearchType>): TUseDataTableListing<TTableType>;
|
|
54
57
|
export {};
|
|
@@ -62,11 +62,12 @@ const initialState = {
|
|
|
62
62
|
sorter: {},
|
|
63
63
|
selectedFilterItem: undefined,
|
|
64
64
|
expandedRowKeys: [],
|
|
65
|
+
modeView: 'TABLE',
|
|
65
66
|
};
|
|
66
67
|
export function useDataTableListing(props) {
|
|
67
68
|
var _a, _b, _c;
|
|
68
69
|
// Props
|
|
69
|
-
const { config, name = 'default', table: tableProps, search: searchProps, filter: filterProps, queryOptions, } = props || {};
|
|
70
|
+
const { config, name = 'default', table: tableProps, search: searchProps, filter: filterProps, gridView: gridViewProps, queryOptions, } = props || {};
|
|
70
71
|
// Hooks
|
|
71
72
|
const queryClient = useQueryClient();
|
|
72
73
|
const { appConfig } = useAppConfigContext();
|
|
@@ -79,9 +80,10 @@ export function useDataTableListing(props) {
|
|
|
79
80
|
const _e = apiFilter || {}, { url: filterUrl = `${COLUMN_DOMAIN[env || 'development']}/api/filter`, enabled: enabledApiFilter = true } = _e, restOfApiFilterRequest = __rest(_e, ["url", "enabled"]);
|
|
80
81
|
const _f = apiListing || {}, { url: listingUrl = '', enabled: enabledApiListing = true } = _f, restOfApiListingRequest = __rest(_f, ["url", "enabled"]);
|
|
81
82
|
const _g = apiSearch || {}, { url: searchUrl = '', enabled: enabledApiSearch = true } = _g, restOfApiSearchRequest = __rest(_g, ["url", "enabled"]);
|
|
82
|
-
const { filters, selectedFilterId, pagination, selectedRowKeys, searchValue, table, sorter, selectedRow, selectedFilterItem, expandedRowKeys, } = state;
|
|
83
|
+
const { filters, selectedFilterId, pagination, selectedRowKeys, searchValue, table, sorter, selectedRow, selectedFilterItem, expandedRowKeys, modeView, } = state;
|
|
83
84
|
const { externalFilters, includeDataType = false, matchesAny, formatFilterValue, } = filterProps || {};
|
|
84
85
|
const { sortDirectionKey = 'az', mainColumnKey, expandColumnKey, expandable } = tableProps || {};
|
|
86
|
+
const { itemProps: gridViewItemProps } = gridViewProps || {};
|
|
85
87
|
const modifyColumnAuth = Object.assign(Object.assign({}, auth), { url: columnUrl });
|
|
86
88
|
const filterAuth = Object.assign(Object.assign({}, auth), { url: filterUrl });
|
|
87
89
|
const listingAuth = Object.assign(Object.assign({}, auth), { url: listingUrl });
|
|
@@ -375,6 +377,15 @@ export function useDataTableListing(props) {
|
|
|
375
377
|
}
|
|
376
378
|
return [];
|
|
377
379
|
}, [matchesAny, infiniteMatchesAnyData, selectedFilterItem === null || selectedFilterItem === void 0 ? void 0 : selectedFilterItem.column]);
|
|
380
|
+
const gridViewList = useDeepCompareMemo(() => {
|
|
381
|
+
if (gridViewProps === null || gridViewProps === void 0 ? void 0 : gridViewProps.itemMapKeys) {
|
|
382
|
+
const { name, thumbnail } = gridViewProps || {};
|
|
383
|
+
return ((tableData === null || tableData === void 0 ? void 0 : tableData.map(record => Object.entries((gridViewProps === null || gridViewProps === void 0 ? void 0 : gridViewProps.itemMapKeys) || {}).reduce((acc, [key, value]) => (Object.assign(Object.assign(Object.assign(Object.assign({}, acc), { [key]: record[value] }), (thumbnail && {
|
|
384
|
+
thumbnail: typeof thumbnail === 'function' ? thumbnail(record) : thumbnail,
|
|
385
|
+
})), (name && { name: typeof name === 'function' ? name(record) : name }))), {}))) || []);
|
|
386
|
+
}
|
|
387
|
+
return [];
|
|
388
|
+
}, [gridViewProps, tableData]);
|
|
378
389
|
// Effects
|
|
379
390
|
/**
|
|
380
391
|
* Update values from local storage to state
|
|
@@ -619,6 +630,33 @@ export function useDataTableListing(props) {
|
|
|
619
630
|
columnWidths: Object.assign(Object.assign({}, table.columnWidths), { [index]: width }),
|
|
620
631
|
});
|
|
621
632
|
} }),
|
|
633
|
+
/* Grid view */
|
|
634
|
+
gridView: {
|
|
635
|
+
mode: modeView,
|
|
636
|
+
onChangeMode(mode) {
|
|
637
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { modeView: mode })));
|
|
638
|
+
},
|
|
639
|
+
templateListingProps: {
|
|
640
|
+
templatesProps: {
|
|
641
|
+
items: gridViewList,
|
|
642
|
+
loading: isTableListingLoading || isTableListingRefetching,
|
|
643
|
+
},
|
|
644
|
+
templateItemProps: {
|
|
645
|
+
removable: false,
|
|
646
|
+
previewBtnProps: {
|
|
647
|
+
show: false,
|
|
648
|
+
},
|
|
649
|
+
actionAvailable: gridViewItemProps === null || gridViewItemProps === void 0 ? void 0 : gridViewItemProps.showButton,
|
|
650
|
+
editBtnProps: Object.assign(Object.assign({}, gridViewItemProps === null || gridViewItemProps === void 0 ? void 0 : gridViewItemProps.buttonProps), { onClick(id) {
|
|
651
|
+
var _a, _b;
|
|
652
|
+
const record = tableData === null || tableData === void 0 ? void 0 : tableData.find(item => (item === null || item === void 0 ? void 0 : item[gridViewProps === null || gridViewProps === void 0 ? void 0 : gridViewProps.itemMapKeys.id]) === id);
|
|
653
|
+
if (record && ((_a = gridViewItemProps === null || gridViewItemProps === void 0 ? void 0 : gridViewItemProps.buttonProps) === null || _a === void 0 ? void 0 : _a.onClick)) {
|
|
654
|
+
(_b = gridViewItemProps === null || gridViewItemProps === void 0 ? void 0 : gridViewItemProps.buttonProps) === null || _b === void 0 ? void 0 : _b.onClick(record);
|
|
655
|
+
}
|
|
656
|
+
} }),
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
},
|
|
622
660
|
/* Selected row */
|
|
623
661
|
selectedRowKeys,
|
|
624
662
|
selectedRow,
|
|
@@ -7,4 +7,5 @@ export declare const ActionButton: import("styled-components").StyledComponent<i
|
|
|
7
7
|
$hide?: boolean | undefined;
|
|
8
8
|
}, never>;
|
|
9
9
|
export declare const FilterMetricLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
10
|
+
export declare const DataTableContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
11
|
export declare const FilterButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -34,15 +34,26 @@ export const ActionButton = styled(Button) `
|
|
|
34
34
|
display: flex !important;
|
|
35
35
|
flex-direction: column;
|
|
36
36
|
align-items: center;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
gap: 4px 0px !important;
|
|
39
37
|
height: 43px !important;
|
|
40
38
|
width: 50px !important;
|
|
39
|
+
gap: 4px !important;
|
|
40
|
+
padding: 3px 0px !important;
|
|
41
41
|
font-size: 8px !important;
|
|
42
|
+
line-height: 1 !important;
|
|
42
43
|
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8} !important;
|
|
43
44
|
|
|
44
45
|
${props => props.$hide && `visibility: hidden !important;`}
|
|
45
46
|
|
|
47
|
+
.action-icon {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
> i {
|
|
53
|
+
font-size: 24px !important;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
/* &:hover, */
|
|
47
58
|
&:active {
|
|
48
59
|
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary} !important;
|
|
@@ -60,6 +71,16 @@ export const FilterMetricLabel = styled(Flex) `
|
|
|
60
71
|
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8};
|
|
61
72
|
}
|
|
62
73
|
`;
|
|
74
|
+
export const DataTableContent = styled.div `
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
overflow: auto;
|
|
78
|
+
|
|
79
|
+
.scrollbar-view {
|
|
80
|
+
height: 100%;
|
|
81
|
+
position: relative !important;
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
63
84
|
/* Filter */
|
|
64
85
|
export const FilterButton = styled.div `
|
|
65
86
|
width: 24px;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TableProps as AntdTableProps } from 'antd';
|
|
2
3
|
import { StoreApi } from 'zustand';
|
|
3
4
|
import { ToolbarProps } from './toolbar';
|
|
@@ -13,6 +14,7 @@ export interface TableProps<T> extends AntdTableProps<T> {
|
|
|
13
14
|
export interface ModifyColumnProps {
|
|
14
15
|
}
|
|
15
16
|
export interface DataTableProps<TTableDataType = any> extends Partial<DataTableState<TTableDataType>> {
|
|
17
|
+
contentRender?: () => React.ReactNode;
|
|
16
18
|
store?: StoreApi<DataTableStore<any>> | null;
|
|
17
19
|
}
|
|
18
20
|
export interface DataTableState<TTableDataType> {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { DropdownProps } from 'antd';
|
|
3
|
-
import { TOOLBAR_ACTION_KEYS } from '../constants';
|
|
3
|
+
import { GRID_VIEW_KEYS, TOOLBAR_ACTION_KEYS } from '../constants';
|
|
4
4
|
import { AddButtonProps } from '../components/AddButton';
|
|
5
5
|
import { TActionButton, TConfirmResponse } from '@antscorp/antsomi-ui/es/types';
|
|
6
6
|
import { TOperatorKey } from '@antscorp/antsomi-ui/es/types/condition';
|
|
7
7
|
import { ModifyColumnMetric } from '../../ModifyColumnModal';
|
|
8
8
|
import { SavedModifyColumnItem, TOnSaveModifyColumnArgs } from '../../ModifyColumnModal/types';
|
|
9
9
|
import { TextProps } from 'antd/es/typography/Text';
|
|
10
|
+
import { TemplateListingProps } from '../../../template';
|
|
10
11
|
export type TActionToolbarButtonKey<T extends string[] = []> = (typeof TOOLBAR_ACTION_KEYS)[keyof typeof TOOLBAR_ACTION_KEYS] | T[number];
|
|
12
|
+
export type TGridViewKeys = (typeof GRID_VIEW_KEYS)[keyof typeof GRID_VIEW_KEYS];
|
|
11
13
|
export type TSearchItem = {
|
|
12
14
|
id: string | number;
|
|
13
15
|
label: string;
|
|
@@ -54,7 +56,14 @@ export type TColumnActionButton = TActionButton & {
|
|
|
54
56
|
metrics?: ModifyColumnMetric[];
|
|
55
57
|
onApply?: (args: TOnSaveModifyColumnArgs) => Promise<TConfirmResponse>;
|
|
56
58
|
};
|
|
57
|
-
export type
|
|
59
|
+
export type TGridViewActionButton = TActionButton & {
|
|
60
|
+
/** The mode of the grid view. Ex: '' */
|
|
61
|
+
mode?: TGridViewKeys;
|
|
62
|
+
templateListingProps?: TemplateListingProps;
|
|
63
|
+
/** The callback function to change the mode of the grid view. */
|
|
64
|
+
onChangeMode?: (mode: TGridViewKeys) => void;
|
|
65
|
+
};
|
|
66
|
+
export type TToolbarActionButton<TActionKey extends string[] = [], ActionKey extends TActionToolbarButtonKey<TActionKey> = TActionToolbarButtonKey<TActionKey>> = ActionKey extends 'SEARCH' ? TSearchActionButton : ActionKey extends 'COLUMN' ? TColumnActionButton : ActionKey extends 'GRID_VIEW' ? TGridViewActionButton : TActionButton;
|
|
58
67
|
export type TCollapse = {
|
|
59
68
|
collapsed?: boolean;
|
|
60
69
|
onCollapse?: (collapsed: boolean) => void;
|
|
@@ -32,6 +32,7 @@ export const TemplateListing = memo(props => {
|
|
|
32
32
|
const { header, footer, items = [], gap = LISTING_GAP_DEFAULT, loading = false, wrapperClassName, wrapperStyle, onLoadMoreTemplates = () => { }, } = templatesProps || {};
|
|
33
33
|
const _a = previewModalProps || {}, { onOk, onCancel } = _a, restOfPreviewModalProps = __rest(_a, ["onOk", "onCancel"]);
|
|
34
34
|
const _b = templateItemProps || {}, { width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, previewBtnProps } = _b, restOfTemplateItemProps = __rest(_b, ["width", "height", "previewBtnProps"]);
|
|
35
|
+
console.log('🚀 ~ templateItemProps:', templateItemProps);
|
|
35
36
|
const { onClick: onClickPreview } = previewBtnProps || {};
|
|
36
37
|
const isHasData = items.length > 0;
|
|
37
38
|
// Memo
|
|
@@ -80,9 +81,7 @@ export const TemplateListing = memo(props => {
|
|
|
80
81
|
const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
|
|
81
82
|
return (React.createElement("div", { key: id },
|
|
82
83
|
index === items.length - 2 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }),
|
|
83
|
-
React.createElement(ThumbnailCard, Object.assign({ id: id || 0, name: name || 'Untitled', loading: loading, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `${templateItemProps.className}`, thumbnailCacheValue: thumbnailCacheValue, previewBtnProps: {
|
|
84
|
-
onClick: handleClickThumbnailPreview,
|
|
85
|
-
} }, restOfTemplateItemProps))));
|
|
84
|
+
React.createElement(ThumbnailCard, Object.assign({ id: id || 0, name: name || 'Untitled', loading: loading, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `${templateItemProps.className}`, thumbnailCacheValue: thumbnailCacheValue, previewBtnProps: Object.assign({ onClick: handleClickThumbnailPreview }, previewBtnProps) }, restOfTemplateItemProps))));
|
|
86
85
|
}))),
|
|
87
86
|
!loading && !blankTemplateProps.show && !isHasData && React.createElement(Empty, Object.assign({}, emptyProps)))),
|
|
88
87
|
footer),
|
|
@@ -4,13 +4,13 @@ export type TActionButton = {
|
|
|
4
4
|
buttonProps?: ButtonProps;
|
|
5
5
|
key?: string;
|
|
6
6
|
label?: React.ReactNode;
|
|
7
|
-
icon?:
|
|
7
|
+
icon?: ReactNode;
|
|
8
8
|
customRender?: (node: ReactNode) => ReactNode;
|
|
9
9
|
};
|
|
10
10
|
export type TActionOption = {
|
|
11
11
|
key: string;
|
|
12
12
|
label: string;
|
|
13
|
-
icon?:
|
|
13
|
+
icon?: ReactNode;
|
|
14
14
|
iconSize?: number;
|
|
15
15
|
};
|
|
16
16
|
export type TActionOptions = Record<string, TActionOption>;
|