@mezzanine-ui/react 0.14.7 → 0.14.9
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/Accordion/Accordion.d.ts +0 -1
- package/Accordion/AccordionControlContext.d.ts +0 -1
- package/Accordion/AccordionDetails.d.ts +0 -1
- package/AppBar/AppBarBrand.d.ts +0 -1
- package/AppBar/AppBarMain.d.ts +0 -1
- package/AppBar/AppBarSupport.d.ts +0 -1
- package/Badge/Badge.d.ts +0 -1
- package/Badge/BadgeContainer.d.ts +0 -1
- package/Button/Button.d.ts +0 -1
- package/Button/Button.js +1 -2
- package/Button/IconButton.d.ts +1 -1
- package/Button/IconButton.js +1 -2
- package/Button/index.js +2 -2
- package/Calendar/Calendar.d.ts +0 -1
- package/Calendar/CalendarCell.d.ts +1 -2
- package/Calendar/CalendarContext.d.ts +1 -1
- package/Calendar/CalendarControls.d.ts +1 -2
- package/Calendar/CalendarDayOfWeek.d.ts +1 -2
- package/Calendar/CalendarDays.d.ts +1 -2
- package/Calendar/CalendarMonths.d.ts +1 -2
- package/Calendar/CalendarWeeks.d.ts +1 -2
- package/Calendar/CalendarYears.d.ts +1 -2
- package/Calendar/useCalendarControls.d.ts +0 -1
- package/Checkbox/CheckboxGroupContext.d.ts +0 -1
- package/DatePicker/DatePicker.d.ts +0 -1
- package/DateRangePicker/DateRangePicker.d.ts +0 -1
- package/DateRangePicker/useDateRangePickerValue.d.ts +3 -3
- package/DateTimePicker/DateTimePicker.d.ts +0 -1
- package/DateTimePicker/DateTimePickerPanel.d.ts +0 -1
- package/Drawer/Drawer.d.ts +0 -1
- package/Form/FormControlContext.d.ts +0 -1
- package/Form/FormField.d.ts +0 -1
- package/Form/FormMessage.d.ts +0 -1
- package/Form/useCheckboxControlValue.d.ts +1 -1
- package/Form/useControlValueState.d.ts +0 -1
- package/Form/useCustomControlValue.d.ts +1 -1
- package/Form/useInputControlValue.d.ts +1 -1
- package/Form/useInputWithClearControlValue.d.ts +1 -1
- package/Form/useRadioControlValue.d.ts +1 -1
- package/Form/useSwitchControlValue.d.ts +1 -1
- package/Icon/Icon.d.ts +0 -1
- package/Loading/Loading.d.ts +0 -1
- package/Menu/Menu.d.ts +0 -1
- package/Menu/MenuDivider.d.ts +0 -1
- package/Menu/MenuItem.d.ts +0 -1
- package/Message/Message.js +2 -2
- package/Modal/Modal.d.ts +0 -1
- package/Modal/ModalActions.d.ts +0 -1
- package/Modal/ModalBody.d.ts +0 -1
- package/Modal/ModalControl.d.ts +0 -1
- package/Modal/ModalFooter.d.ts +0 -1
- package/Modal/ModalHeader.d.ts +0 -1
- package/Modal/useModalContainer.d.ts +1 -2
- package/Navigation/NavigationContext.d.ts +0 -1
- package/Notifier/NotifierManager.d.ts +1 -1
- package/Pagination/Pagination.d.ts +1 -1
- package/Pagination/PaginationJumper.d.ts +1 -1
- package/Pagination/PaginationPageSize.d.ts +1 -1
- package/Progress/Progress.d.ts +0 -1
- package/Provider/context.d.ts +0 -1
- package/Radio/RadioGroupContext.d.ts +0 -1
- package/Select/AutoComplete.d.ts +0 -1
- package/Select/Option.d.ts +0 -1
- package/Select/Select.d.ts +0 -1
- package/Select/SelectControlContext.d.ts +0 -1
- package/Select/TreeSelect.d.ts +0 -1
- package/Skeleton/Skeleton.d.ts +0 -1
- package/Slider/useSlider.js +1 -1
- package/Stepper/Step.d.ts +0 -1
- package/Table/Table.d.ts +1 -1
- package/Table/Table.js +3 -1
- package/Table/TableBody.d.ts +0 -1
- package/Table/TableBody.js +1 -2
- package/Table/TableBodyRow.d.ts +0 -1
- package/Table/TableBodyRow.js +5 -5
- package/Table/TableCell.d.ts +0 -1
- package/Table/TableContext.d.ts +1 -0
- package/Table/TableExpandedTable.d.ts +0 -1
- package/Table/TableExpandedTable.js +1 -2
- package/Table/TableHeader.d.ts +0 -1
- package/Table/TableHeader.js +1 -2
- package/Table/draggable/useTableDraggable.d.ts +1 -1
- package/Table/editable/TableEditRenderWrapper.d.ts +1 -2
- package/Table/expandable/TableExpandable.d.ts +0 -1
- package/Table/expandable/TableExpandable.js +1 -2
- package/Table/index.d.ts +1 -0
- package/Table/index.js +1 -0
- package/Table/pagination/TablePagination.js +1 -2
- package/Table/pagination/useTablePagination.d.ts +1 -1
- package/Table/rowSelection/TableRowSelection.d.ts +0 -1
- package/Table/rowSelection/TableRowSelection.js +11 -8
- package/Table/rowSelection/useTableRowSelection.d.ts +1 -1
- package/Table/rowSelection/useTableRowSelection.js +5 -3
- package/Table/sorting/TableSortingIcon.d.ts +0 -1
- package/Table/sorting/TableSortingIcon.js +1 -2
- package/Table/sorting/useTableSorting.d.ts +1 -2
- package/Table/useTableFetchMore.d.ts +1 -1
- package/Table/useTableLoading.d.ts +1 -1
- package/Table/useTableScroll.d.ts +126 -114
- package/Tabs/Tab.d.ts +0 -1
- package/TimePicker/TimePicker.d.ts +0 -1
- package/TimePicker/TimePickerPanel.d.ts +0 -1
- package/Tooltip/useDelayMouseEnterLeave.d.ts +0 -1
- package/Transition/Collapse.d.ts +0 -1
- package/Transition/Fade.d.ts +0 -1
- package/Transition/Grow.d.ts +0 -1
- package/Transition/SlideFade.d.ts +0 -1
- package/Transition/Transition.d.ts +1 -1
- package/Transition/Zoom.d.ts +0 -1
- package/Transition/useAutoTransitionDuration.d.ts +0 -1
- package/Tree/TreeNode.d.ts +0 -1
- package/Tree/TreeNodeList.d.ts +0 -1
- package/Tree/useTreeExpandedValue.d.ts +0 -1
- package/Typography/Typography.js +1 -2
- package/Upload/UploadButton.d.ts +0 -1
- package/Upload/UploadInput.d.ts +0 -1
- package/Upload/UploadInput.js +1 -2
- package/Upload/UploadPictureWallItem.d.ts +1 -1
- package/Upload/UploadPictureWallItem.js +1 -2
- package/_internal/InputTriggerPopper/InputTriggerPopper.d.ts +0 -1
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +0 -1
- package/index.d.ts +1 -1
- package/index.js +1 -0
- package/package.json +13 -14
package/Table/Table.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface TableBaseProps<T> extends Omit<NativeElementPropsWithoutKeyAndR
|
|
|
10
10
|
/**
|
|
11
11
|
* customized body row className
|
|
12
12
|
*/
|
|
13
|
-
bodyRowClassName?: string | ((source:
|
|
13
|
+
bodyRowClassName?: string | ((source: T) => string);
|
|
14
14
|
/**
|
|
15
15
|
* Columns of table <br />
|
|
16
16
|
* `column.render` allowed customizing the column body cell rendering. <br />
|
package/Table/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef, useRef, useMemo, Fragment } from 'react';
|
|
3
|
-
import { DragDropContext, Droppable } from '
|
|
3
|
+
import { DragDropContext, Droppable } from '@hello-pangea/dnd';
|
|
4
4
|
import { tableClasses } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { TableContext, TableDataContext, TableComponentContext } from './TableContext.js';
|
|
6
6
|
import TableHeader from './TableHeader.js';
|
|
@@ -27,11 +27,13 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
27
27
|
selectedRowKey: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.selectedRowKey,
|
|
28
28
|
onChange: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.onChange,
|
|
29
29
|
dataSource: dataSourceProp,
|
|
30
|
+
disabledRowKeys: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.disabledRowKeys,
|
|
30
31
|
});
|
|
31
32
|
const rowSelection = useMemo(() => (rowSelectionProp ? {
|
|
32
33
|
selectedRowKeys,
|
|
33
34
|
onChange: setSelectedRowKey,
|
|
34
35
|
actions: rowSelectionProp.actions,
|
|
36
|
+
disabledRowKeys: rowSelectionProp.disabledRowKeys,
|
|
35
37
|
} : undefined), [
|
|
36
38
|
rowSelectionProp,
|
|
37
39
|
selectedRowKeys,
|
package/Table/TableBody.d.ts
CHANGED
package/Table/TableBody.js
CHANGED
|
@@ -20,6 +20,5 @@ const TableBody = forwardRef(function TableBody(props, ref) {
|
|
|
20
20
|
const currentDataSource = pagination && !disableAutoSlicing ? (dataSource.slice(currentStartCount, currentEndCount)) : dataSource;
|
|
21
21
|
return (jsxs("tbody", { ...rest, ref: ref, className: cx(tableClasses.body, className), children: [currentDataSource.length ? currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowData), rowData: rowData, rowIndex: index }, (rowData.key || rowData.id)))) : (jsx("tr", { children: jsx("td", { children: jsx(Empty, { ...restEmptyProps, className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight, children: emptyComponentChildren }) }) })), (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("tr", { className: tableClasses.bodyFetchMore, children: jsx("td", { "aria-label": "Loading", children: jsx(Loading, { loading: true }) }) })) : null] }));
|
|
22
22
|
});
|
|
23
|
-
var TableBody$1 = TableBody;
|
|
24
23
|
|
|
25
|
-
export { TableBody
|
|
24
|
+
export { TableBody as default };
|
package/Table/TableBodyRow.d.ts
CHANGED
package/Table/TableBodyRow.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { forwardRef, useContext, useState, useMemo, Fragment, createElement } from 'react';
|
|
1
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useContext, useState, useMemo, Fragment } from 'react';
|
|
3
3
|
import { tableClasses, getColumnStyle, getCellStyle } from '@mezzanine-ui/core/table';
|
|
4
|
-
import { Draggable } from '
|
|
4
|
+
import { Draggable } from '@hello-pangea/dnd';
|
|
5
5
|
import get from 'lodash/get';
|
|
6
6
|
import { TableContext, TableDataContext } from './TableContext.js';
|
|
7
7
|
import TableCell from './TableCell.js';
|
|
@@ -56,9 +56,9 @@ const TableBodyRow = forwardRef(function TableBodyRow(props, ref) {
|
|
|
56
56
|
const autoGrabData = column.dataIndex ? get(rowData, column.dataIndex) : '';
|
|
57
57
|
const ellipsis = ((_a = column.ellipsis) !== null && _a !== void 0 ? _a : true);
|
|
58
58
|
const tooltipTitle = ((_c = (_b = column.renderTooltipTitle) === null || _b === void 0 ? void 0 : _b.call(column, rowData)) !== null && _c !== void 0 ? _c : autoGrabData);
|
|
59
|
-
return (jsx("td", { className: cx(tableClasses.bodyRowCellWrapper, isFirstColumnShouldSticky && idx === 0 && tableClasses.bodyRowCellWrapperFixed, isFirstColumnShouldSticky && idx === 0 && isHorizontalScrolling && tableClasses.bodyRowCellWrapperFixedStuck, column.bodyClassName), style: getColumnStyle(column), children:
|
|
59
|
+
return (jsx("td", { className: cx(tableClasses.bodyRowCellWrapper, isFirstColumnShouldSticky && idx === 0 && tableClasses.bodyRowCellWrapperFixed, isFirstColumnShouldSticky && idx === 0 && isHorizontalScrolling && tableClasses.bodyRowCellWrapperFixedStuck, column.bodyClassName), style: getColumnStyle(column), children: createElement(TableEditRenderWrapper, { ...column, key: rowData.key || rowData.id, rowData: rowData },
|
|
60
|
+
jsx(TableCell, { ellipsis: ellipsis, forceShownTooltipWhenHovered: column.forceShownTooltipWhenHovered, style: getCellStyle(column), tooltipTitle: tooltipTitle, children: ((_d = column.render) === null || _d === void 0 ? void 0 : _d.call(column, rowData, rowIndex, column)) || autoGrabData })) }, `${idx + 1}-${(rowData.key || rowData.id)}`));
|
|
60
61
|
})] })) }, rowData.key || rowData.id), renderedExpandedContent ? (jsx("tr", { children: jsx("td", { style: { padding: 0 }, children: jsx(AccordionDetails, { className: cx(expanding.className, tableClasses.bodyRowExpandedTableWrapper), expanded: expanded, children: (renderedExpandedContent === null || renderedExpandedContent === void 0 ? void 0 : renderedExpandedContent.dataSource) ? (jsx(TableExpandedTable, { renderedExpandedContent: renderedExpandedContent })) : renderedExpandedContent }) }) })) : null] }));
|
|
61
62
|
});
|
|
62
|
-
var TableBodyRow$1 = TableBodyRow;
|
|
63
63
|
|
|
64
|
-
export { TableBodyRow
|
|
64
|
+
export { TableBodyRow as default };
|
package/Table/TableCell.d.ts
CHANGED
package/Table/TableContext.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { EmptyProps } from '../Empty';
|
|
|
5
5
|
export interface RowSelectionContext extends Pick<TableRowSelection, 'actions'> {
|
|
6
6
|
selectedRowKeys: string[];
|
|
7
7
|
onChange(v: string): void;
|
|
8
|
+
disabledRowKeys?: string[];
|
|
8
9
|
}
|
|
9
10
|
/** typeof sorting */
|
|
10
11
|
export interface SortingContext {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TableDataSource, ExpandedTableColumn } from '@mezzanine-ui/core/table';
|
|
3
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
3
|
export interface TableExpandedTableProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
|
|
@@ -22,6 +22,5 @@ const TableExpandedTable = forwardRef(function TableExpandedTable(props, ref) {
|
|
|
22
22
|
})] }, (source.key || source.id)));
|
|
23
23
|
}) }));
|
|
24
24
|
});
|
|
25
|
-
var TableExpandedTable$1 = TableExpandedTable;
|
|
26
25
|
|
|
27
|
-
export { TableExpandedTable
|
|
26
|
+
export { TableExpandedTable as default };
|
package/Table/TableHeader.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
2
|
declare const TableHeader: import("react").ForwardRefExoticComponent<NativeElementPropsWithoutKeyAndRef<"div"> & import("react").RefAttributes<HTMLTableRowElement>>;
|
|
4
3
|
export default TableHeader;
|
package/Table/TableHeader.js
CHANGED
|
@@ -29,6 +29,5 @@ const TableHeader = forwardRef(function TableHeader(props, ref) {
|
|
|
29
29
|
return (jsx("th", { className: cx(tableClasses.headerCellWrapper, isFirstColumnShouldSticky && idx === 0 && tableClasses.headerCellWrapperFixed, isFirstColumnShouldSticky && idx === 0 && isHorizontalScrolling && tableClasses.headerCellWrapperFixedStuck, column.headerClassName), style: getColumnStyle(column), children: jsxs(TableCell, { ellipsis: false, style: getCellStyle(column), children: [((_a = column.renderTitle) === null || _a === void 0 ? void 0 : _a.call(column, tableClasses)) || column.title, typeof column.sorter === 'function' || typeof column.onSorted === 'function' ? (jsx(TableSortingIcon, { column: column })) : null] }) }, `${idx + 1}`));
|
|
30
30
|
})] }) }));
|
|
31
31
|
});
|
|
32
|
-
var TableHeader$1 = TableHeader;
|
|
33
32
|
|
|
34
|
-
export { TableHeader
|
|
33
|
+
export { TableHeader as default };
|
|
@@ -10,5 +10,5 @@ export declare function useTableDraggable(props: UseTableDraggable): {
|
|
|
10
10
|
onBeforeDragStart: (e: {
|
|
11
11
|
draggableId: SetStateAction<string>;
|
|
12
12
|
}) => void;
|
|
13
|
-
onDragEnd: import("
|
|
13
|
+
onDragEnd: import("@hello-pangea/dnd").OnDragEndResponder;
|
|
14
14
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TableColumnBase, TableDataSource, TableRecord } from '@mezzanine-ui/core/table';
|
|
3
2
|
import { NativeElementPropsWithoutKeyAndRef } from '../../utils/jsx-types';
|
|
4
3
|
export interface EditableBodyCellProps extends NativeElementPropsWithoutKeyAndRef<'div'>, TableColumnBase<TableRecord<unknown>> {
|
|
5
4
|
rowData: TableDataSource;
|
|
6
5
|
}
|
|
7
|
-
declare function TableEditRenderWrapper({ children, dataIndex, editable, rowData, setCellProps, ...rest }: EditableBodyCellProps): JSX.Element;
|
|
6
|
+
declare function TableEditRenderWrapper({ children, dataIndex, editable, rowData, setCellProps, ...rest }: EditableBodyCellProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export default TableEditRenderWrapper;
|
|
@@ -20,6 +20,5 @@ const TableExpandable = forwardRef(function TableExpandable(props, ref) {
|
|
|
20
20
|
[tableClasses.iconClickable]: expandable,
|
|
21
21
|
}), color: expandable ? 'primary' : 'disabled', icon: ChevronDownIcon, onClick: onClick, style: { transform: `rotate(${expanded ? '180deg' : '0'})` } })) : null }) }));
|
|
22
22
|
});
|
|
23
|
-
var TableExpandable$1 = TableExpandable;
|
|
24
23
|
|
|
25
|
-
export { TableExpandable
|
|
24
|
+
export { TableExpandable as default };
|
package/Table/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { TableRefreshProps, default as TableRefresh, } from './refresh/TableRefr
|
|
|
3
3
|
export { TableCellProps, default as TableCell, } from './TableCell';
|
|
4
4
|
export { EditableBodyCellProps, } from './editable/TableEditRenderWrapper';
|
|
5
5
|
export { useTableDraggable, } from './draggable/useTableDraggable';
|
|
6
|
+
export { useTableRowSelection, SELECTED_ALL_KEY, } from './rowSelection/useTableRowSelection';
|
|
6
7
|
export { default as useTableScroll, } from './useTableScroll';
|
package/Table/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { default } from './Table.js';
|
|
|
2
2
|
export { default as TableRefresh } from './refresh/TableRefresh.js';
|
|
3
3
|
export { default as TableCell } from './TableCell.js';
|
|
4
4
|
export { useTableDraggable } from './draggable/useTableDraggable.js';
|
|
5
|
+
export { SELECTED_ALL_KEY, useTableRowSelection } from './rowSelection/useTableRowSelection.js';
|
|
5
6
|
export { default as useTableScroll } from './useTableScroll.js';
|
|
@@ -21,6 +21,5 @@ const TablePagination = forwardRef(function TablePagination(props, ref) {
|
|
|
21
21
|
const currentEndCount = Math.min(pageSizeProp * currentPage, total);
|
|
22
22
|
return (jsxs("div", { ...rest, ref: ref, className: cx(tableClasses.pagination, className), children: [jsx("span", { className: tableClasses.paginationIndicator, children: (_a = renderPaginationSummary === null || renderPaginationSummary === void 0 ? void 0 : renderPaginationSummary(currentStartCount, currentEndCount)) !== null && _a !== void 0 ? _a : `目前顯示 ${currentStartCount} - ${currentEndCount} 筆,共 ${total} 筆資料` }), jsx("div", { className: tableClasses.paginationActions, children: jsx(Pagination, { boundaryCount: boundaryCount, buttonText: jumperButtonText, className: paginationClassName, current: currentPage, disabled: disabled, hideNextButton: hideNextButton, hidePreviousButton: hidePreviousButton, hintText: jumperHintText, inputPlaceholder: jumperInputPlaceholder, onChange: setCurrentPage, onChangePageSize: onChangePageSize, pageSize: pageSizeProp, pageSizeLabel: pageSizeLabel, pageSizeOptions: pageSizeOptions, pageSizeUnit: pageSizeUnit, renderPageSizeOptionName: renderPageSizeOptionName, showJumper: showJumper, showPageSizeOptions: showPageSizeOptions, siblingCount: siblingCount, total: total }) })] }));
|
|
23
23
|
});
|
|
24
|
-
var TablePagination$1 = TablePagination;
|
|
25
24
|
|
|
26
|
-
export { TablePagination
|
|
25
|
+
export { TablePagination as default };
|
|
@@ -5,4 +5,4 @@ export interface UseTablePagination {
|
|
|
5
5
|
current?: TablePagination['current'];
|
|
6
6
|
onChange?: TablePagination['onChange'];
|
|
7
7
|
}
|
|
8
|
-
export declare function useTablePagination(props: UseTablePagination): readonly [number, (c: number) => void];
|
|
8
|
+
export declare function useTablePagination(props: UseTablePagination): readonly [number, (c: number) => ReturnType<(c: number) => void>];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef, useContext, useCallback, useMemo, useEffect, useState } from 'react';
|
|
3
3
|
import { tableClasses } from '@mezzanine-ui/core/table';
|
|
4
|
+
import xor from 'lodash/xor';
|
|
4
5
|
import { MoreVerticalIcon } from '@mezzanine-ui/icons';
|
|
5
6
|
import { TableContext, TableDataContext } from '../TableContext.js';
|
|
6
7
|
import { SELECTED_ALL_KEY } from './useTableRowSelection.js';
|
|
@@ -12,7 +13,7 @@ import Icon from '../../Icon/Icon.js';
|
|
|
12
13
|
import cx from 'clsx';
|
|
13
14
|
|
|
14
15
|
const TableRowSelection = forwardRef(function TableRowSelection(props, ref) {
|
|
15
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
16
17
|
const { rowKey, setChecked, showDropdownIcon, ...rest } = props;
|
|
17
18
|
const { rowSelection, expanding, } = useContext(TableContext) || {};
|
|
18
19
|
const { dataSource = [], } = useContext(TableDataContext) || {};
|
|
@@ -21,14 +22,15 @@ const TableRowSelection = forwardRef(function TableRowSelection(props, ref) {
|
|
|
21
22
|
rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(rowKey);
|
|
22
23
|
}, [rowSelection, rowKey]);
|
|
23
24
|
const checkboxStatus = useMemo(() => {
|
|
24
|
-
var _a;
|
|
25
|
+
var _a, _b;
|
|
25
26
|
const selectedRowKeys = (_a = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) !== null && _a !== void 0 ? _a : [];
|
|
26
27
|
if (!selectedRowKeys.length)
|
|
27
28
|
return 'none';
|
|
28
|
-
|
|
29
|
+
const validDataSource = xor((_b = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.disabledRowKeys) !== null && _b !== void 0 ? _b : [], dataSource.map((d) => (d.id || d.key)));
|
|
30
|
+
if (selectedRowKeys.length === validDataSource.length)
|
|
29
31
|
return 'all';
|
|
30
32
|
return 'indeterminate';
|
|
31
|
-
}, [rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys, dataSource
|
|
33
|
+
}, [rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys, rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.disabledRowKeys, dataSource]);
|
|
32
34
|
const selfChecked = useMemo(() => {
|
|
33
35
|
var _a;
|
|
34
36
|
return (((_a = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) !== null && _a !== void 0 ? _a : []).some((key) => key === rowKey));
|
|
@@ -70,9 +72,11 @@ const TableRowSelection = forwardRef(function TableRowSelection(props, ref) {
|
|
|
70
72
|
toggleOpen(false);
|
|
71
73
|
};
|
|
72
74
|
const actionMenu = (jsx(Menu, { size: "medium", children: ((_a = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.actions) !== null && _a !== void 0 ? _a : []).map(((action) => (jsx(MenuItem, { className: action.className, onClick: (evt) => onMenuItemClicked(evt, action), children: action.text }, action.key)))) }));
|
|
73
|
-
return (jsxs("div", { ref: ref, ...rest, className: tableClasses.selections, style: hiddenIconWithExpandableStyle.host, children: [jsx(Checkbox, { checked: checked, disabled:
|
|
75
|
+
return (jsxs("div", { ref: ref, ...rest, className: tableClasses.selections, style: hiddenIconWithExpandableStyle.host, children: [jsx(Checkbox, { checked: checked, disabled: ((_b = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.disabledRowKeys) === null || _b === void 0 ? void 0 : _b.length)
|
|
76
|
+
? rowSelection.disabledRowKeys.includes(rowKey)
|
|
77
|
+
: false, indeterminate: indeterminate, inputProps: {
|
|
74
78
|
name,
|
|
75
|
-
}, onChange: onSelected, size: "medium" }), ((
|
|
79
|
+
}, onChange: onSelected, size: "medium" }), ((_c = rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.actions) === null || _c === void 0 ? void 0 : _c.length) ? (jsx("div", { className: tableClasses.icon, style: hiddenIconWithExpandableStyle.icon, children: showDropdownIcon ? (jsx(Dropdown, { menu: actionMenu, onClose: () => toggleOpen(false), popperProps: {
|
|
76
80
|
open,
|
|
77
81
|
options: {
|
|
78
82
|
placement: 'bottom-start',
|
|
@@ -81,6 +85,5 @@ const TableRowSelection = forwardRef(function TableRowSelection(props, ref) {
|
|
|
81
85
|
[tableClasses.iconClickable]: isMenuAllowOpen,
|
|
82
86
|
}), color: isMenuAllowOpen ? 'primary' : 'disabled', icon: MoreVerticalIcon, onClick: onIconClicked })) })) : null })) : null] }));
|
|
83
87
|
});
|
|
84
|
-
var TableRowSelection$1 = TableRowSelection;
|
|
85
88
|
|
|
86
|
-
export { TableRowSelection
|
|
89
|
+
export { TableRowSelection as default };
|
|
@@ -3,4 +3,4 @@ export declare const SELECTED_ALL_KEY = "MZN-TABLE-ROW-SELECTION-ALL";
|
|
|
3
3
|
export interface UseTableRowSelection extends Omit<TableRowSelection, 'actions'> {
|
|
4
4
|
dataSource: TableDataSource[];
|
|
5
5
|
}
|
|
6
|
-
export declare function useTableRowSelection(props: UseTableRowSelection): readonly [string[], (v: string) => void];
|
|
6
|
+
export declare function useTableRowSelection(props: UseTableRowSelection): readonly [string[], (v: string) => ReturnType<(v: string) => void>];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import xor from 'lodash/xor';
|
|
1
2
|
import { useControlValueState } from '../../Form/useControlValueState.js';
|
|
2
3
|
import { useLastCallback } from '../../hooks/useLastCallback.js';
|
|
3
4
|
|
|
@@ -8,7 +9,7 @@ const equalityFn = (a, b) => {
|
|
|
8
9
|
};
|
|
9
10
|
const SELECTED_ALL_KEY = 'MZN-TABLE-ROW-SELECTION-ALL';
|
|
10
11
|
function useTableRowSelection(props) {
|
|
11
|
-
const { selectedRowKey: selectedRowKeyProp, onChange: onChangeProp, dataSource, } = props;
|
|
12
|
+
const { selectedRowKey: selectedRowKeyProp, onChange: onChangeProp, disabledRowKeys = [], dataSource, } = props;
|
|
12
13
|
const [selectedRowKey, setSelectedRowKey] = useControlValueState({
|
|
13
14
|
defaultValue: [],
|
|
14
15
|
equalityFn,
|
|
@@ -18,13 +19,14 @@ function useTableRowSelection(props) {
|
|
|
18
19
|
if (!dataSource.length)
|
|
19
20
|
return;
|
|
20
21
|
const allSourceKeys = dataSource.map((source) => (source.key || source.id));
|
|
22
|
+
const validSourceKeys = xor(disabledRowKeys, allSourceKeys);
|
|
21
23
|
let nextSelectedRowKey = selectedRowKey;
|
|
22
24
|
if (rowKey === SELECTED_ALL_KEY) {
|
|
23
|
-
if (equalityFn(selectedRowKey,
|
|
25
|
+
if (equalityFn(selectedRowKey, validSourceKeys)) {
|
|
24
26
|
nextSelectedRowKey = [];
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
|
-
nextSelectedRowKey =
|
|
29
|
+
nextSelectedRowKey = validSourceKeys;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
else {
|
|
@@ -28,6 +28,5 @@ const TableSortingIcon = forwardRef(function TableSortingIcon(props, ref) {
|
|
|
28
28
|
});
|
|
29
29
|
}, style: currentIconStyle.style }));
|
|
30
30
|
});
|
|
31
|
-
var TableSortingIcon$1 = TableSortingIcon;
|
|
32
31
|
|
|
33
|
-
export { TableSortingIcon
|
|
32
|
+
export { TableSortingIcon as default };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TableDataSource, TableColumn, TableRecord } from '@mezzanine-ui/core/table';
|
|
3
2
|
export interface UseTableSorting {
|
|
4
3
|
dataSource: TableDataSource[];
|
|
5
4
|
}
|
|
6
5
|
export type SortedType = 'desc' | 'asc' | 'none';
|
|
7
|
-
export declare function useTableSorting(props: UseTableSorting): readonly [TableDataSource[], (v: Pick<TableColumn<TableRecord<unknown>>, "key" | "dataIndex" | "sorter" | "onSorted">) => void
|
|
6
|
+
export declare function useTableSorting(props: UseTableSorting): readonly [TableDataSource[], (v: Pick<TableColumn<TableRecord<unknown>>, "key" | "dataIndex" | "sorter" | "onSorted">) => ReturnType<(v: Pick<TableColumn<TableRecord<unknown>>, "key" | "dataIndex" | "sorter" | "onSorted">) => void>, {
|
|
8
7
|
readonly sortedOn: string;
|
|
9
8
|
readonly sortedType: SortedType;
|
|
10
9
|
readonly onResetAll: () => void;
|
|
@@ -4,7 +4,7 @@ export interface UseTableFetchMore extends TableFetchMore {
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare function useTableFetchMore(props: UseTableFetchMore): {
|
|
7
|
-
readonly fetchMore: (() => void) | undefined;
|
|
7
|
+
readonly fetchMore: (() => ReturnType<() => void>) | undefined;
|
|
8
8
|
readonly isFetching: boolean;
|
|
9
9
|
readonly isReachEnd: boolean;
|
|
10
10
|
};
|
|
@@ -2,4 +2,4 @@ export declare const SELECTED_ALL_KEY = "MZN-TABLE-ROW-SELECTION-ALL";
|
|
|
2
2
|
export interface UseTableLoading {
|
|
3
3
|
loading?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare function useTableLoading(props: UseTableLoading): readonly [boolean, (l: boolean) => void];
|
|
5
|
+
export declare function useTableLoading(props: UseTableLoading): readonly [boolean, (l: boolean) => ReturnType<(l: boolean) => void>];
|