@mezzanine-ui/react 0.14.6 → 0.14.7

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/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;
13
+ bodyRowClassName?: string | ((source: TableDataSource) => 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
@@ -143,6 +143,15 @@ const Table = forwardRef(function Table(props, ref) {
143
143
  });
144
144
  }, [(_a = components === null || components === void 0 ? void 0 : components.body) === null || _a === void 0 ? void 0 : _a.cell]);
145
145
  const tableRefs = useComposeRefs([ref, scrollBody.target]);
146
+ const rowClassName = useMemo(() => {
147
+ if (bodyRowClassName) {
148
+ if (typeof bodyRowClassName === 'string') {
149
+ return (() => bodyRowClassName);
150
+ }
151
+ return ((source) => bodyRowClassName === null || bodyRowClassName === void 0 ? void 0 : bodyRowClassName(source));
152
+ }
153
+ return undefined;
154
+ }, [bodyRowClassName]);
146
155
  return (jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsx(TableComponentContext.Provider, { value: tableComponentContextValue, children: jsx(DragDropContext, { onBeforeDragStart: onBeforeDragStart, onDragEnd: onDragEnd, children: jsx(Loading, { loading: loading, stretch: true, tip: loadingTip, overlayProps: {
147
156
  className: tableClasses.loading,
148
157
  }, children: jsx(Droppable, { droppableId: "mzn-table-dnd", isDropDisabled: !(draggableProp === null || draggableProp === void 0 ? void 0 : draggableProp.enabled), children: (provided) => (jsxs(Fragment, { children: [jsx("div", { ...provided.droppableProps, ref: composeRefs([scrollBody.ref, provided.innerRef]), className: cx(tableClasses.scrollContainer, scrollContainerClassName), onScroll: scrollBody.onScroll, style: tableContextValue.scroll ? {
@@ -152,7 +161,7 @@ const Table = forwardRef(function Table(props, ref) {
152
161
  '--table-scroll-y': tableContextValue.scroll.y
153
162
  ? `${tableContextValue.scroll.y}px`
154
163
  : 'unset',
155
- } : undefined, children: jsxs("table", { ref: tableRefs, ...rest, className: cx(tableClasses.host, className), children: [isRefreshShow ? (jsx("tbody", { children: jsx("tr", { children: jsx("td", { "aria-label": "Refresh", children: jsx(TableRefresh, { onClick: refreshProp.onClick }) }) }) })) : null, jsx(TableHeader, { className: headerClassName }), jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: bodyRowClassName }), jsx("tbody", { children: provided.placeholder })] }) }), paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef })) : null, jsx("div", { ref: scrollElement.trackRef, "aria-label": "Scroll Track", style: scrollElement.trackStyle, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, role: "button", tabIndex: -1, className: "mzn-table-scroll-bar-track", children: jsx("div", { style: {
164
+ } : undefined, children: jsxs("table", { ref: tableRefs, ...rest, className: cx(tableClasses.host, className), children: [isRefreshShow ? (jsx("tbody", { children: jsx("tr", { children: jsx("td", { "aria-label": "Refresh", children: jsx(TableRefresh, { onClick: refreshProp.onClick }) }) }) })) : null, jsx(TableHeader, { className: headerClassName }), jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: rowClassName }), jsx("tbody", { children: provided.placeholder })] }) }), paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef })) : null, jsx("div", { ref: scrollElement.trackRef, "aria-label": "Scroll Track", style: scrollElement.trackStyle, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, role: "button", tabIndex: -1, className: "mzn-table-scroll-bar-track", children: jsx("div", { style: {
156
165
  width: '100%',
157
166
  height: '100%',
158
167
  position: 'relative',
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
+ import { TableDataSource } from '@mezzanine-ui/core/table';
2
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
4
  export interface TableBodyProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
5
  /**
5
6
  * customize row className
6
7
  */
7
- rowClassName?: string;
8
+ rowClassName?: (source: TableDataSource) => string;
8
9
  }
9
10
  declare const TableBody: import("react").ForwardRefExoticComponent<TableBodyProps & import("react").RefAttributes<HTMLTableSectionElement>>;
10
11
  export default TableBody;
@@ -18,7 +18,7 @@ const TableBody = forwardRef(function TableBody(props, ref) {
18
18
  const currentStartCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage ? ((paginationOptions.pageSize) * (currentPage - 1)) : 0;
19
19
  const currentEndCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage && total ? (Math.min(((paginationOptions.pageSize) * currentPage), total)) : 0;
20
20
  const currentDataSource = pagination && !disableAutoSlicing ? (dataSource.slice(currentStartCount, currentEndCount)) : dataSource;
21
- return (jsxs("tbody", { ...rest, ref: ref, className: cx(tableClasses.body, className), children: [currentDataSource.length ? currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName, 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] }));
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
23
  var TableBody$1 = TableBody;
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/react",
3
- "version": "0.14.6",
3
+ "version": "0.14.7",
4
4
  "description": "React components for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -28,9 +28,9 @@
28
28
  "react-dom": "^18.2.0"
29
29
  },
30
30
  "dependencies": {
31
- "@mezzanine-ui/core": "^0.14.6",
32
- "@mezzanine-ui/icons": "^0.14.6",
33
- "@mezzanine-ui/system": "^0.14.6",
31
+ "@mezzanine-ui/core": "^0.14.7",
32
+ "@mezzanine-ui/icons": "^0.14.7",
33
+ "@mezzanine-ui/system": "^0.14.7",
34
34
  "@popperjs/core": "^2.11.6",
35
35
  "@types/react-transition-group": "^4.4.8",
36
36
  "clsx": "^2.0.0",