@cloudbase/weda-ui 3.23.1 → 3.24.0

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.
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { WdMenuLayoutProps } from '../wd-menu-layout';
3
- export declare const HorizontalMenu: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<unknown>>;
3
+ export declare const HorizontalMenu: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<HTMLElement>>;
@@ -5,5 +5,5 @@ import { slotDiv } from '../utils';
5
5
  import { WdMenuList } from '../../index';
6
6
  export const HorizontalMenu = forwardRef(function HorizontalMenu(props, ref) {
7
7
  const { classPrefix } = useConfig();
8
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${classPrefix}-menulayout-header`, children: [_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap`, children: slotDiv(props.headSlot) }), _jsx("div", { className: `${classPrefix}-menulayout-header__slot`, children: _jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }) }), _jsx("div", { className: `${classPrefix}-menulayout-header__right-wrap`, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) })] }), _jsx("div", { className: `${classPrefix}-menulayout-body`, children: _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot }) })] }));
8
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${classPrefix}-menulayout-header`, children: [props.headSlot && (_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap`, children: slotDiv(props.headSlot) })), _jsx("div", { className: `${classPrefix}-menulayout-header__slot`, children: _jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }) }), props.headRightSlot && (_jsx("div", { className: `${classPrefix}-menulayout-header__right-wrap`, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) }))] }), _jsx("div", { className: `${classPrefix}-menulayout-body`, children: _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot }) })] }));
9
9
  });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { WdMenuLayoutProps } from '../wd-menu-layout';
3
+ export declare const LeftMenu: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<unknown>>;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState } from 'react';
3
+ import { useConfig } from '../../../utils/config-context';
4
+ import { slotDiv } from '../utils';
5
+ import { WdMenuList } from '../../index';
6
+ import WdIcon from '../../wd-icon';
7
+ import classNames from '../../../utils/classnames';
8
+ export const LeftMenu = forwardRef(function LeftMenu(props, ref) {
9
+ const { classPrefix } = useConfig();
10
+ const { collapsed, onToggleCollapse, enableHeadSlot = false } = props;
11
+ const [isHovering, setIsHovering] = useState(false);
12
+ const [tempExpanded, setTempExpanded] = useState(false);
13
+ // 计算实际的展开状态
14
+ const effectiveCollapsed = collapsed && !tempExpanded;
15
+ const classes = classNames({
16
+ [`${classPrefix}-menulayout-body__left`]: true,
17
+ [`${classPrefix}-menulayout-body--hover`]: isHovering,
18
+ [`${classPrefix}-menulayout-body__left--collapsed`]: effectiveCollapsed,
19
+ });
20
+ // 处理鼠标进入事件
21
+ const handleMouseEnter = () => {
22
+ setIsHovering(true);
23
+ if (collapsed) {
24
+ setTempExpanded(true);
25
+ }
26
+ };
27
+ // 处理鼠标离开事件
28
+ const handleMouseLeave = () => {
29
+ setIsHovering(false);
30
+ if (collapsed) {
31
+ setTempExpanded(false);
32
+ }
33
+ };
34
+ // 点击展开收起按钮
35
+ const handleCollapse = () => {
36
+ onToggleCollapse();
37
+ setTempExpanded(false);
38
+ setIsHovering(false);
39
+ };
40
+ return (_jsxs("div", { className: classes, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [enableHeadSlot && props.headSlot && (_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap is-not-content`, children: slotDiv(props.headSlot) })), _jsx("div", { className: `${classPrefix}-menulayout-body__left-menu ${classPrefix}-menulayout__menu ${effectiveCollapsed ? `${classPrefix}-menulayout__menu--collapsed` : ''}`, children: _jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }) }), props.footerSlot && (_jsx("div", { className: `${classPrefix}-menulayout-body__left-slot is-not-content ${classPrefix}-menulayout-body__footer`, children: slotDiv(props.footerSlot) })), _jsx("div", { className: `${classPrefix}-menulayout-body__footer ${classPrefix}-menulayout-body__footer--collapse`, onClick: handleCollapse, children: _jsx("div", { className: `${classPrefix}-event-tap ${classPrefix}-menulayout-body__footer--collapse-icon`, children: _jsx(WdIcon, { type: "inner", size: "xs", name: collapsed ? 'td:menu-fold' : 'td:menu-unfold' }) }) })] }));
41
+ });
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { WdMenuLayoutProps } from '../wd-menu-layout';
3
- export declare const PlantMenu: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<unknown>>;
3
+ export declare const PlantMenu: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<HTMLElement>>;
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { forwardRef } from 'react';
3
3
  import { useConfig } from '../../../utils/config-context';
4
4
  import { slotDiv } from '../utils';
5
- import { WdMenuList } from '../../index';
5
+ import { LeftMenu } from './LeftMenu';
6
6
  export const PlantMenu = forwardRef(function PlantMenu(props, ref) {
7
7
  const { classPrefix } = useConfig();
8
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${classPrefix}-menulayout-header ${classPrefix}-menulayout-header--plant`, children: [_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap`, children: slotDiv(props.headSlot) }), _jsx("div", { className: `${classPrefix}-menulayout-header__right-wrap `, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) })] }), _jsxs("div", { className: `${classPrefix}-menulayout-body ${classPrefix}-menulayout-body--plant`, children: [_jsxs("div", { className: `${classPrefix}-menulayout-body__left`, children: [_jsx("div", { className: `${classPrefix}-menulayout-body__left-menu ${classPrefix}-menulayout__menu`, children: _jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }) }), _jsx("div", { className: `${classPrefix}-menulayout-body__left-slot is-not-content ${classPrefix}-menulayout-body__footer`, children: slotDiv(props.footerSlot) })] }), _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot })] })] }));
8
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${classPrefix}-menulayout-header ${classPrefix}-menulayout-header--plant`, children: [props.headSlot && (_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap`, children: slotDiv(props.headSlot) })), props.headRightSlot && (_jsx("div", { className: `${classPrefix}-menulayout-header__right-wrap `, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) }))] }), _jsxs("div", { className: `${classPrefix}-menulayout-body ${classPrefix}-menulayout-body--plant`, children: [_jsx(LeftMenu, { ref: ref, ...props }), _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot })] })] }));
9
9
  });
@@ -1,9 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { useConfig } from '../../../utils/config-context';
4
- import { slotDiv } from '../utils';
5
- import { WdMenuList } from '../../index';
4
+ import classNames from '../../../utils/classnames';
5
+ import { LeftMenu } from './LeftMenu';
6
6
  export const VerticalMenu = forwardRef(function VerticalMenu(props, ref) {
7
7
  const { classPrefix } = useConfig();
8
- return (_jsx(_Fragment, { children: _jsxs("div", { className: `${classPrefix}-menulayout-body ${classPrefix}-menulayout-body--vertical`, children: [_jsxs("div", { className: `${classPrefix}-menulayout-body__left`, children: [_jsx("div", { className: `${classPrefix}-menulayout-header__logo-wrap is-not-content`, children: slotDiv(props.headSlot) }), _jsx("div", { className: `${classPrefix}-menulayout-body__left-menu ${classPrefix}-menulayout__menu`, children: _jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }) }), _jsx("div", { className: `${classPrefix}-menulayout-body__left-slot is-not-content ${classPrefix}-menulayout-body__footer`, children: slotDiv(props.footerSlot) })] }), _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot })] }) }));
8
+ // 计算实际的展开状态
9
+ const classes = classNames({
10
+ [`${classPrefix}-menulayout-body`]: true,
11
+ [`${classPrefix}-menulayout-body--vertical`]: true,
12
+ });
13
+ return (_jsx(_Fragment, { children: _jsxs("div", { className: classes, children: [_jsx(LeftMenu, { ref: ref, ...props, enableHeadSlot: true }), _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot })] }) }));
9
14
  });
@@ -2,7 +2,10 @@ import React from 'react';
2
2
  import type { CommonPropsType } from '../../types';
3
3
  import type { DataType } from '../../../configs/components/wd-menu-layout';
4
4
  import { WdMenuListProps } from '../wd-menu-list';
5
- export declare const WdMenuLayout: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<unknown>>;
5
+ export declare const WdMenuLayout: React.ForwardRefExoticComponent<WdMenuLayoutProps & React.RefAttributes<HTMLElement>>;
6
6
  export interface WdMenuLayoutProps extends CommonPropsType, DataType {
7
7
  setSelectedInfo: (item: WdMenuListProps['menu']['menuData']['0'], isNavigate: boolean) => void;
8
+ collapsed?: boolean;
9
+ onToggleCollapse?: () => void;
10
+ enableHeadSlot?: boolean;
8
11
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useState } from 'react';
3
3
  import { HorizontalMenu } from './components/HorizontalMenu';
4
4
  import { PlantMenu } from './components/PlantMenu';
5
5
  import { VerticalMenu } from './components/VerticalMenu';
@@ -12,13 +12,12 @@ import classNames from '../../utils/classnames';
12
12
  import { usePlatform } from '../../utils/platform';
13
13
  // const type = 'horizontal'; // 顶导航: horizontal 侧导航: vertical 厂子形状:plant h5
14
14
  export const WdMenuLayout = forwardRef(function WdMenuLayout(props, ref) {
15
+ const [collapsed, setCollapsed] = useState(false);
15
16
  const { classPrefix } = useConfig();
16
17
  const platform = usePlatform();
17
18
  const _type = props.type || props.template;
18
- const type = platform === 'h5' && !['tab', 'nav', 'navTab'].includes(_type)
19
- ? 'h5'
20
- : _type;
19
+ const type = platform === 'h5' && !['tab', 'nav', 'navTab'].includes(_type) ? 'h5' : _type;
21
20
  return (
22
21
  // 1024px 800px为方便测试 开发时去掉
23
- _jsxs("div", { id: props.id, style: props.style, className: classNames(props.className, `${classPrefix}-menulayout`, `${classPrefix}-menulayout-root`, ['h5'].includes(type) ? `${classPrefix}-menulayout-h5-root` : '', `${classPrefix}-menulayout--${type}`), children: [['horizontal'].includes(type) && (_jsx(HorizontalMenu, { ...props, ref: ref })), ['vertical'].includes(type) && (_jsx(VerticalMenu, { ...props, ref: ref })), ['plant'].includes(type) && _jsx(PlantMenu, { ...props, ref: ref }), ['h5'].includes(type) && _jsx(H5Menu, { ...props, ref: ref }), ['tab'].includes(type) && _jsx(TabMenu, { ...props, ref: ref }), ['nav'].includes(type) && _jsx(NavMenu, { ...props, ref: ref }), ['navTab'].includes(type) && (_jsx(NavTabMenu, { ...props, ref: ref }))] }));
22
+ _jsxs("div", { id: props.id, style: props.style, className: classNames(props.className, `${classPrefix}-menulayout`, `${classPrefix}-menulayout-root`, ['h5'].includes(type) ? `${classPrefix}-menulayout-h5-root` : '', `${classPrefix}-menulayout--${type}`, collapsed ? `${classPrefix}-menulayout--collapsed` : ''), children: [['horizontal'].includes(type) && _jsx(HorizontalMenu, { ...props, ref: ref }), ['vertical'].includes(type) && (_jsx(VerticalMenu, { ...props, ref: ref, collapsed: collapsed, onToggleCollapse: () => setCollapsed(!collapsed) })), ['plant'].includes(type) && (_jsx(PlantMenu, { ...props, ref: ref, collapsed: collapsed, onToggleCollapse: () => setCollapsed(!collapsed) })), ['h5'].includes(type) && _jsx(H5Menu, { ...props, ref: ref }), ['tab'].includes(type) && _jsx(TabMenu, { ...props, ref: ref }), ['nav'].includes(type) && _jsx(NavMenu, { ...props, ref: ref }), ['navTab'].includes(type) && _jsx(NavTabMenu, { ...props, ref: ref })] }));
24
23
  });
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useImperativeHandle, useState, useContext, useCallback, useMemo, } from 'react';
2
+ import { forwardRef, useEffect, useImperativeHandle, useState, useContext, useCallback, useMemo } from 'react';
3
3
  import destr from 'destr';
4
4
  import classNames from '../../utils/classnames';
5
5
  import { useConfig } from '../../utils/config-context';
@@ -7,7 +7,7 @@ import { usePlatform } from '../../utils/platform';
7
7
  import { Menu, ConfigProvider } from 'tea-component';
8
8
  import WdIcon from '../wd-icon';
9
9
  import WdLink from '../wd-link';
10
- import { findSelectItem, navigateTo, getMenuList, hasChildSelected, } from './utils';
10
+ import { findSelectItem, navigateTo, getMenuList, hasChildSelected } from './utils';
11
11
  import { MenuLayoutContext } from '../wd-menu-layout/utils';
12
12
  export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
13
13
  const { className = '', style, id } = props;
@@ -85,9 +85,7 @@ export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
85
85
  const renderMenuTitle = (item, useLink = false) => {
86
86
  var _a;
87
87
  const show = (_jsxs("div", { className: `${classPrefix}-menulayout-menu__item`, children: [getIconShow(item, selected), _jsx("div", { className: `${classPrefix}-menulayout-menu__item-text`, children: item.title })] }));
88
- const url = (item === null || item === void 0 ? void 0 : item.type) === 'link' && item.linkUrl
89
- ? item.linkUrl
90
- : (_a = item === null || item === void 0 ? void 0 : item.path) === null || _a === void 0 ? void 0 : _a.replace('/', '');
88
+ const url = (item === null || item === void 0 ? void 0 : item.type) === 'link' && item.linkUrl ? item.linkUrl : (_a = item === null || item === void 0 ? void 0 : item.path) === null || _a === void 0 ? void 0 : _a.replace('/', '');
91
89
  return useLink && url ? (_jsx(WdLink, { style: { width: '100%', color: 'unset', fontSize: 'unset' }, packageName: item === null || item === void 0 ? void 0 : item.subPackageName, url: url, params: [], disabled: true, contentSlot: show, content: '' })) : (show);
92
90
  };
93
91
  // 渲染MenuItem
@@ -112,15 +110,12 @@ export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
112
110
  // 渲染subMenu
113
111
  const renderSubMenu = (item, hasThereNode = false, level = '1') => {
114
112
  const { key, children, disabled } = item;
115
- // 缓存key带上默认菜单展开状态,以区分不同的默认🚉开情况
113
+ // 缓存key带上默认菜单展开状态,以区分不同的默认展开情况
116
114
  const itemKey = `${key}_${props.defaultOpened}`;
117
115
  let isOpened = openStatus[itemKey];
118
116
  // 默认不展开菜单时进行判断
119
117
  if (!props.defaultOpened) {
120
- isOpened =
121
- openStatus[itemKey] === undefined
122
- ? hasChildSelected(item, selected)
123
- : openStatus[itemKey];
118
+ isOpened = openStatus[itemKey] === undefined ? hasChildSelected(item, selected) : openStatus[itemKey];
124
119
  if (openStatus[itemKey] === undefined && isOpened) {
125
120
  setOpenStatus((prev) => ({ ...prev, [itemKey]: isOpened }));
126
121
  }
@@ -130,6 +125,7 @@ export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
130
125
  [`${classPrefix}-menulayout__submenu-stair`]: ['1'].includes(level),
131
126
  [`${classPrefix}-menulayout__submenu-second`]: ['2'].includes(level),
132
127
  'is-disabled': !!disabled,
128
+ 'has-selected-child': hasChildSelected(item, selected),
133
129
  }), title: renderMenuTitle(item), defaultOpened: props.defaultOpened, opened: isOpened, onOpenedChange: (isOpened) => {
134
130
  setOpenStatus((prev) => ({ ...prev, [itemKey]: isOpened }));
135
131
  const result = { ...openStatus, [itemKey]: isOpened };
@@ -138,8 +134,6 @@ export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
138
134
  };
139
135
  return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("div", { id: id, className: classNames(classes, className), style: style, children: _jsx(Menu, { children: menuData === null || menuData === void 0 ? void 0 : menuData.map((item) => {
140
136
  var _a;
141
- return ((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length) > 0
142
- ? renderSubMenu(item)
143
- : renderMenuItem(item, '1');
137
+ return ((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? renderSubMenu(item) : renderMenuItem(item, '1');
144
138
  }) }) }) }));
145
139
  });
@@ -1,65 +1,43 @@
1
- import React from 'react';
2
- export declare const BaseTableCom: ({ events, recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, errorObj, isLoading, queryParams, total, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot, bottomTip, enableBottomTipSlot, }: {
3
- events: any;
4
- recordKey: any;
5
- className: any;
6
- columns: any;
7
- setColumns: any;
8
- records: any;
9
- sortColumns: any;
10
- sort: any;
11
- onSelectChange: any;
12
- selectedKeys: any;
13
- rowColor: any;
14
- isError: any;
15
- errorObj: any;
16
- isLoading: any;
17
- queryParams: any;
1
+ import React, { ReactNode } from 'react';
2
+ interface BaseTableComProps {
3
+ events?: any;
4
+ recordKey?: string;
5
+ className?: any;
6
+ columns?: any[];
7
+ setColumns?: (columns: any[]) => void;
8
+ records?: any[];
9
+ sortColumns?: any[];
10
+ sort?: any[];
11
+ onSelectChange?: (selectedKeys?: any, selectedRows?: any, clearAll?: boolean) => void;
12
+ selectedKeys?: string[];
13
+ rowColor?: string | ((params: {
14
+ event: {
15
+ detail: any;
16
+ };
17
+ data: any;
18
+ }) => string);
19
+ isError?: boolean;
20
+ errorObj?: any;
21
+ isLoading?: boolean;
22
+ queryParams?: any;
18
23
  total?: number;
19
- onQueryChange: any;
20
- enablePagination: any;
21
- columnSelectType: any;
22
- defaultPageSize: any;
23
- defaultPageIndex: any;
24
- rowClick: any;
25
- cellClick: any;
26
- currentSize: any;
27
- isNoDataSourceBind: any;
28
- isH5: any;
29
- emptyText: any;
30
- __innerSlot?: React.ReactNode;
31
- bottomTip: any;
24
+ onQueryChange?: (query: any) => void;
25
+ enablePagination?: boolean;
26
+ columnSelectType?: 'select' | 'radio' | string;
27
+ defaultPageSize?: number;
28
+ defaultPageIndex?: number;
29
+ rowClick?: (e: React.MouseEvent, context: any) => void;
30
+ cellClick?: (e: React.MouseEvent, context: any) => void;
31
+ currentSize?: string;
32
+ isNoDataSourceBind?: boolean;
33
+ isH5?: boolean;
34
+ emptyText?: string;
35
+ __innerSlot?: ReactNode;
36
+ bottomTip?: ReactNode;
32
37
  enableBottomTipSlot?: boolean;
33
- }) => JSX.Element;
34
- export declare const BaseTable: React.MemoExoticComponent<({ events, recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, errorObj, isLoading, queryParams, total, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot, bottomTip, enableBottomTipSlot, }: {
35
- events: any;
36
- recordKey: any;
37
- className: any;
38
- columns: any;
39
- setColumns: any;
40
- records: any;
41
- sortColumns: any;
42
- sort: any;
43
- onSelectChange: any;
44
- selectedKeys: any;
45
- rowColor: any;
46
- isError: any;
47
- errorObj: any;
48
- isLoading: any;
49
- queryParams: any;
50
- total?: number;
51
- onQueryChange: any;
52
- enablePagination: any;
53
- columnSelectType: any;
54
- defaultPageSize: any;
55
- defaultPageIndex: any;
56
- rowClick: any;
57
- cellClick: any;
58
- currentSize: any;
59
- isNoDataSourceBind: any;
60
- isH5: any;
61
- emptyText: any;
62
- __innerSlot?: React.ReactNode;
63
- bottomTip: any;
64
- enableBottomTipSlot?: boolean;
65
- }) => JSX.Element>;
38
+ rowDisabled?: boolean | ((record: any) => boolean);
39
+ componentId?: string;
40
+ }
41
+ export declare const BaseTableCom: ({ events, recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, errorObj, isLoading, queryParams, total, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot, bottomTip, enableBottomTipSlot, rowDisabled, componentId, }: BaseTableComProps) => JSX.Element;
42
+ export declare const BaseTable: React.MemoExoticComponent<({ events, recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, errorObj, isLoading, queryParams, total, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot, bottomTip, enableBottomTipSlot, rowDisabled, componentId, }: BaseTableComProps) => JSX.Element>;
43
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint max-lines: [error, 350] */
3
3
  import React, { useRef, useEffect } from 'react';
4
- import { Icon, Table, StatusTip, ConfigProvider } from 'tea-component';
4
+ import { Table, StatusTip, ConfigProvider } from 'tea-component';
5
5
  import { useResizeObserver } from '@react-hookz/web';
6
+ import { errorHandler } from '../../../../utils/error';
6
7
  import { useConfig } from '../../../../utils/config-context';
7
- import { isInIde } from '../../../../utils/platform';
8
8
  const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, columnsResizable } = Table.addons;
9
9
  import StatusContent from '../../../statusContent';
10
10
  import classNames from '../../../../utils/classnames';
@@ -34,9 +34,8 @@ const renderStatus = ({ isH5, status, isNoDataSourceBind, _emptyText, errorObj,
34
34
  // eslint-disable-next-line complexity
35
35
  export const BaseTableCom = ({ events, recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, errorObj, isLoading, queryParams, total = defaultTotal,
36
36
  // refreshTable,
37
- onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot = (_jsx(_Fragment, {})), bottomTip, enableBottomTipSlot = false, }) => {
37
+ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, cellClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, __innerSlot = (_jsx(_Fragment, {})), bottomTip, enableBottomTipSlot = false, rowDisabled, componentId, }) => {
38
38
  var _a;
39
- const inEditor = isInIde();
40
39
  const tableRef = useRef(null);
41
40
  const { classPrefix } = useConfig();
42
41
  // 是否展示全局loading
@@ -100,17 +99,14 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
100
99
  },
101
100
  }),
102
101
  }),
103
- ];
104
- // 仅运行态可编辑
105
- if (!inEditor) {
106
- tableAddons.push(columnsResizable({
102
+ columnsResizable({
107
103
  onResizeEnd: (columns) => {
108
104
  setColumns(columns);
109
105
  },
110
106
  minWidth: 92,
111
107
  maxWidth: 1000,
112
- }));
113
- }
108
+ }),
109
+ ];
114
110
  // 支撑分页的最大高度
115
111
  const tableDomHeight = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight;
116
112
  // 支持表格滚动,高度超过 500 开始显示滚动条
@@ -147,7 +143,6 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
147
143
  tableAddons.push(selectable({
148
144
  value: selectedKeys,
149
145
  onChange: onSelectChange,
150
- render: (element, { disabled }) => (disabled ? _jsx(Icon, { type: "loading" }) : element),
151
146
  targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'select' ? 'weda_select' : undefined,
152
147
  }));
153
148
  }
@@ -155,7 +150,6 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
155
150
  tableAddons.push(radioable({
156
151
  value: selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0],
157
152
  onChange: onSelectChange,
158
- render: (element, { disabled }) => (disabled ? _jsx(Icon, { type: "loading" }) : element),
159
153
  targetColumnKey: (columns === null || columns === void 0 ? void 0 : columns.length) && columnSelectType === 'radio' ? 'weda_radio' : undefined,
160
154
  }));
161
155
  }
@@ -207,14 +201,32 @@ onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageI
207
201
  tableDomHeight > minPageSizeHeight &&
208
202
  !isLoading &&
209
203
  isH5 &&
210
- total > miniPageSize &&
211
- !inEditor) {
204
+ total > miniPageSize) {
212
205
  onQueryChange({ pageIndex: queryParams.pageIndex + pageIndexSpan });
213
206
  }
214
207
  // eslint-disable-next-line react-hooks/exhaustive-deps
215
208
  }, [queryParams.pageIndex, currentSize, isLoading, isH5, total]);
216
209
  const status = isShowLoading ? 'loading' : isError ? 'error' : 'empty';
217
- return (_jsxs("div", { className: classNames(className, classes), children: [_jsx(Table, { ref: tableRef, className: className, bordered: true, recordKey: recordKey, columns: columns, records: records, addons: tableAddons, bottomTip: bottomTipCompRender() }), showStatus &&
210
+ const handleRowDisable = (record) => {
211
+ if (typeof rowDisabled === 'function') {
212
+ try {
213
+ return rowDisabled(record);
214
+ }
215
+ catch (error) {
216
+ errorHandler({
217
+ code: 'rowDisabledFailed',
218
+ error: error,
219
+ id: componentId,
220
+ });
221
+ return false;
222
+ }
223
+ }
224
+ else if (typeof rowDisabled === 'boolean') {
225
+ return rowDisabled;
226
+ }
227
+ return false;
228
+ };
229
+ return (_jsxs("div", { className: classNames(className, classes), children: [_jsx(Table, { rowDisabled: handleRowDisable, ref: tableRef, className: className, bordered: true, recordKey: recordKey, columns: columns, records: records, addons: tableAddons, bottomTip: bottomTipCompRender() }), showStatus &&
218
230
  renderStatus({
219
231
  isH5,
220
232
  status,
@@ -80,7 +80,7 @@ forwardRef(function TableComp(tableProps, ref) {
80
80
  isSupportMultipleSort = false, // 是否支持多字段排序
81
81
  sorter, // 排序规则
82
82
  __innerSlot, enableRelationTag = true, // 关联关系字段是否开启关联标签
83
- enableBottomTipSlot = false, row__bottom__slot, ...props } = tableProps;
83
+ enableBottomTipSlot = false, row__bottom__slot, rowDisabled, ...props } = tableProps;
84
84
  const formField = useFormField();
85
85
  const { formFieldsValue = [], setFieldValue, setFormFieldsValue } = formField || {};
86
86
  const formFieldObjsContext = useFormFieldObj();
@@ -747,7 +747,7 @@ forwardRef(function TableComp(tableProps, ref) {
747
747
  pageIndex: 1,
748
748
  }));
749
749
  }
750
- events === null || events === void 0 ? void 0 : events.onFilterChange({ searchValues });
750
+ events === null || events === void 0 ? void 0 : events.onFilterChange({ searchValues, filterConfig });
751
751
  };
752
752
  const errorStatus = isError || fieldsError;
753
753
  const errorMsg = isError ? errorObj : fieldsError;
@@ -756,7 +756,7 @@ forwardRef(function TableComp(tableProps, ref) {
756
756
  setOpenMobileFilter(true);
757
757
  }, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination }) }))] })), isH5 && (enablePagination || enableRefreshBtn || enableTableHeightSizeBtn || hasFilterButton) && (_jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
758
758
  setOpenMobileFilter(true);
759
- }, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination })), _jsx(Table, { events: events, emptyText: emptyText, isH5: isH5, isNoDataSourceBind: isNoDataSourceBind, className: tableClassList, recordKey: recordKey, currentSize: tableHightSize, defaultPageIndex: defaultPageIndex, defaultPageSize: defaultPageSize, sortColumns: sortColumns, enablePagination: !isH5 && enablePagination, columnSelectType: columnSelectType, columns: visibleColumns, setColumns: setColumns, records: tableRecords, sort: queryParams.sort, selectedKeys: selectedKeys, onSelectChange: onSelectChange, isLoading: isTableLoading, rowColor: rowColor, queryParams: queryParams, total: total, onQueryChange: onQueryChange, rowClick: rowClick, cellClick: cellClick, isError: errorStatus, errorObj: errorMsg, __innerSlot: __innerSlot, bottomTip: row__bottom__slot, enableBottomTipSlot: enableBottomTipSlot }), isH5 && enableGlobalButton && !isNoDataSourceBind && (_jsx("div", { className: `${classPrefix}-h5-table-wrap-footer`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) }))] }), _jsx(ImportFileModal, { columnSets: columnSets, dbName: dbName, datasourceTitle: datasourceTitle, fields: fields, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, isImportFileModalByApiVisible: isImportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, refresh: refreshTable, supportManyRelated: supportManyRelated }), _jsx(ExportFileModal, { whereList: wList, fields: fields, columns: mapColumKey(columns), isExportFileModalByApiVisible: isExportFileModalByApiVisible, selectedKeys: selectedKeys, dbName: dbName, query: query, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, supportManyRelated: supportManyRelated }), _jsx(InOrOutRecordModal, { dbName: dbName, isInOrOutRecordModalVisible: isInOrOutRecordModalVisible, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible }), isH5 && (_jsx(Modal, { overlayClassName: `${classPrefix}-h5-table-overlay`, className: `${classPrefix}-h5-table-option-modal-wrap`, disableCloseIcon: true, title: "\u64CD\u4F5C", visible: isMobileOptionVisible, outerRef: modalRef, events: {
759
+ }, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination })), _jsx(Table, { componentId: id, events: events, emptyText: emptyText, isH5: isH5, isNoDataSourceBind: isNoDataSourceBind, className: tableClassList, recordKey: recordKey, currentSize: tableHightSize, defaultPageIndex: defaultPageIndex, defaultPageSize: defaultPageSize, sortColumns: sortColumns, enablePagination: !isH5 && enablePagination, columnSelectType: columnSelectType, columns: visibleColumns, setColumns: setColumns, records: tableRecords, sort: queryParams.sort, selectedKeys: selectedKeys, onSelectChange: onSelectChange, isLoading: isTableLoading, rowColor: rowColor, queryParams: queryParams, total: total, onQueryChange: onQueryChange, rowClick: rowClick, cellClick: cellClick, isError: errorStatus, errorObj: errorMsg, __innerSlot: __innerSlot, bottomTip: row__bottom__slot, enableBottomTipSlot: enableBottomTipSlot, rowDisabled: rowDisabled }), isH5 && enableGlobalButton && !isNoDataSourceBind && (_jsx("div", { className: `${classPrefix}-h5-table-wrap-footer`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) }))] }), _jsx(ImportFileModal, { columnSets: columnSets, dbName: dbName, datasourceTitle: datasourceTitle, fields: fields, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, isImportFileModalByApiVisible: isImportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, refresh: refreshTable, supportManyRelated: supportManyRelated }), _jsx(ExportFileModal, { whereList: wList, fields: fields, columns: mapColumKey(columns), isExportFileModalByApiVisible: isExportFileModalByApiVisible, selectedKeys: selectedKeys, dbName: dbName, query: query, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, supportManyRelated: supportManyRelated }), _jsx(InOrOutRecordModal, { dbName: dbName, isInOrOutRecordModalVisible: isInOrOutRecordModalVisible, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible }), isH5 && (_jsx(Modal, { overlayClassName: `${classPrefix}-h5-table-overlay`, className: `${classPrefix}-h5-table-option-modal-wrap`, disableCloseIcon: true, title: "\u64CD\u4F5C", visible: isMobileOptionVisible, outerRef: modalRef, events: {
760
760
  close: () => {
761
761
  setIsMobileOptionVisible(false);
762
762
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.23.1",
3
+ "version": "3.24.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",