@cloudbase/weda-ui 3.25.1 → 3.26.1

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.
@@ -89,6 +89,7 @@ export { default as CustomerService } from "./customer-service";
89
89
  export { default as WdAd } from "./wd-ad";
90
90
  export { default as WdOfficialAccount } from "./wd-official-account";
91
91
  export { default as WdModal } from "./wd-modal";
92
+ export { default as WdDrawer } from "./wd-drawer";
92
93
  export { default as Chart } from "./echart";
93
94
  export { default as WdButton } from "./wd-button";
94
95
  export { default as WdDivider } from "./wd-divider";
@@ -138,6 +138,7 @@ export { default as CustomerService } from './customer-service';
138
138
  export { default as WdAd } from './wd-ad';
139
139
  export { default as WdOfficialAccount } from './wd-official-account';
140
140
  export { default as WdModal } from './wd-modal';
141
+ export { default as WdDrawer } from './wd-drawer';
141
142
  export { default as Chart } from './echart';
142
143
  export { default as WdButton } from './wd-button';
143
144
  export { default as WdDivider } from './wd-divider';
@@ -0,0 +1,3 @@
1
+ import { WdDrawer } from './wd-drawer';
2
+ export { WdDrawer, type WdDrawerProps } from './wd-drawer';
3
+ export default WdDrawer;
@@ -0,0 +1,3 @@
1
+ import { WdDrawer } from './wd-drawer';
2
+ export { WdDrawer } from './wd-drawer';
3
+ export default WdDrawer;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { DataType } from '../../../configs/components/wd-drawer';
3
+ import type { CommonPropsType } from '../../types';
4
+ export interface WdDrawerProps extends CommonPropsType, DataType {
5
+ /** 动画持续时间 */
6
+ duration?: number;
7
+ /** 层级 */
8
+ zIndex?: number;
9
+ }
10
+ declare const WdDrawer: React.ForwardRefExoticComponent<WdDrawerProps & React.RefAttributes<unknown>>;
11
+ export { WdDrawer };
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import { useEffect, useRef, useState, useCallback, useImperativeHandle, forwardRef } from 'react';
4
+ import { CSSTransition } from 'react-transition-group';
5
+ import classNames from '../../utils/classnames';
6
+ import { useConfig } from '../../utils/config-context';
7
+ import { useSyncValue } from '../../utils/hooks/useSyncValue';
8
+ import { usePlatform } from '../../utils/platform';
9
+ import { convertLegacyEnum } from '../../utils/tool';
10
+ import { WD_DRAWER_PLACEMENT } from '../../../enum';
11
+ // 常量定义
12
+ const DEFAULT_DURATION = 300;
13
+ const DEFAULT_Z_INDEX = 1000;
14
+ const MASK_Z_INDEX_OFFSET = 1;
15
+ // 默认样式对象
16
+ const DEFAULT_STYLE = {};
17
+ const WdDrawer = forwardRef(function WdDrawer(props, ref) {
18
+ const { id, visible: _visible, placement: _placement, mask = true, className = '', style = DEFAULT_STYLE, duration = DEFAULT_DURATION, zIndex = DEFAULT_Z_INDEX, closeType = ['outerClick'], events, headerSlot, contentSlot, footerSlot, enableHeaderSlot = true, enableContentSlot = true, enableFooterSlot = false, } = props;
19
+ const [openInfo, setOpenInfo] = useState(null);
20
+ const [closeInfo, setCloseInfo] = useState(null);
21
+ const platform = usePlatform();
22
+ const [visible, setVisible] = useSyncValue(_visible);
23
+ const drawerRef = useRef(null);
24
+ const maskRef = useRef(null);
25
+ const { classPrefix: _classPrefix } = useConfig();
26
+ const classPrefix = _classPrefix + '-';
27
+ const placement = convertLegacyEnum(_placement, WD_DRAWER_PLACEMENT, 'right');
28
+ /**
29
+ * 关闭弹窗
30
+ */
31
+ const close = useCallback((params) => {
32
+ setVisible(false);
33
+ setCloseInfo((params === null || params === void 0 ? void 0 : params.info) || params);
34
+ events === null || events === void 0 ? void 0 : events.close(params);
35
+ }, [events, setVisible]);
36
+ /**
37
+ * 开启弹窗
38
+ */
39
+ const open = useCallback((params) => {
40
+ setOpenInfo((params === null || params === void 0 ? void 0 : params.info) || params);
41
+ setVisible(true);
42
+ events === null || events === void 0 ? void 0 : events.open(params);
43
+ }, [events, setVisible]);
44
+ /** 点击遮罩层是否关闭抽屉 */
45
+ const maskClosable = closeType.includes('outerClick');
46
+ /** 点击 ESC 键是否关闭 */
47
+ const escClosable = closeType.includes('esc');
48
+ // ESC 键关闭
49
+ useEffect(() => {
50
+ const handleKeyDown = (e) => {
51
+ if (e.key === 'Escape' && visible) {
52
+ close();
53
+ }
54
+ };
55
+ if (visible && platform === 'pc' && escClosable) {
56
+ document.addEventListener('keydown', handleKeyDown);
57
+ }
58
+ return () => {
59
+ document.removeEventListener('keydown', handleKeyDown);
60
+ };
61
+ }, [close, escClosable, platform, visible]);
62
+ // 遮罩层点击关闭
63
+ const handleMaskClick = (e) => {
64
+ if (maskClosable && e.target === maskRef.current) {
65
+ close();
66
+ }
67
+ };
68
+ // 阻止抽屉内容区域的点击事件冒泡
69
+ const handleDrawerClick = (e) => {
70
+ e.stopPropagation();
71
+ };
72
+ // 获取抽屉样式
73
+ const getDrawerStyle = () => {
74
+ const baseStyle = {
75
+ zIndex,
76
+ ...style,
77
+ };
78
+ if (placement === 'left' || placement === 'right') {
79
+ baseStyle.height = '100%';
80
+ }
81
+ else {
82
+ baseStyle.width = '100%';
83
+ }
84
+ return baseStyle;
85
+ };
86
+ // Widget API,挂载组件只读属性和组件方法
87
+ useImperativeHandle(ref, () => {
88
+ return {
89
+ close,
90
+ open,
91
+ modalState: visible ? 'open' : 'close',
92
+ openInfo,
93
+ closeInfo,
94
+ };
95
+ }, [close, open, visible, openInfo, closeInfo]);
96
+ return (_jsxs("div", { id: id, className: classNames(`${classPrefix}drawer`, `${classPrefix}${platform}-drawer`, className), style: { display: (style === null || style === void 0 ? void 0 : style.display) || 'block' }, "data-testid": "wd-drawer-test", children: [mask && (_jsx(CSSTransition, { in: visible, timeout: duration, classNames: `${classPrefix}drawer-mask`, unmountOnExit: true, nodeRef: maskRef, children: _jsx("div", { ref: maskRef, className: `${classPrefix}drawer-mask`, style: { zIndex: zIndex - MASK_Z_INDEX_OFFSET }, onClick: handleMaskClick }) })), _jsx(CSSTransition, { in: visible, timeout: duration, classNames: `${classPrefix}drawer-${placement}`, unmountOnExit: true, nodeRef: drawerRef, children: _jsxs("div", { ref: drawerRef, className: classNames(`${classPrefix}drawer-content-wrapper`, `${classPrefix}drawer-${placement}`), style: getDrawerStyle(), onClick: handleDrawerClick, children: [enableHeaderSlot && _jsx("div", { className: `${classPrefix}drawer-header`, children: headerSlot }), enableContentSlot && _jsx("div", { className: `${classPrefix}drawer-body`, children: contentSlot }), enableFooterSlot && _jsx("div", { className: `${classPrefix}drawer-footer`, children: footerSlot })] }) })] }));
97
+ });
98
+ export { WdDrawer };
@@ -138,9 +138,11 @@ export const WdModal = forwardRef(function WdModal(props, ref) {
138
138
  }
139
139
  }, children: _jsxs("div", { style: { ...styleList, ...style }, className: classNames(modalBdClasses), onClick: (e) => {
140
140
  e.stopPropagation();
141
- }, children: [_jsx("div", { className: `${classPrefix}-modal-bd__hd`, style: headerFooterStlye, children: props.headerSlot }), _jsx("div", { className: `${classPrefix}-modal-bd__main`, children: props.contentSlot }), _jsx("div", { className: `${classPrefix}-modal-bd__ft ${['confirm', 'notice'].includes(props.template) && platform === 'h5'
141
+ }, children: [props.headerSlot && (_jsx("div", { className: `${classPrefix}-modal-bd__hd`, style: headerFooterStlye, children: props.headerSlot })), props.contentSlot && _jsx("div", { className: `${classPrefix}-modal-bd__main`, children: props.contentSlot }), props.footerSlot && (_jsx("div", { className: `${classPrefix}-modal-bd__ft ${['confirm', 'notice'].includes(props.template) && platform === 'h5'
142
142
  ? `${classPrefix}-modal-bd__ft-text-btn`
143
- : ''} ${props.template === 'notice' && platform === 'h5' ? `${classPrefix}-modal-bd__ft-text-btn--vertical` : ''}`, style: headerFooterStlye, children: props.footerSlot })] }) })] }));
143
+ : ''} ${props.template === 'notice' && platform === 'h5'
144
+ ? `${classPrefix}-modal-bd__ft-text-btn--vertical`
145
+ : ''}`, style: headerFooterStlye, children: props.footerSlot }))] }) })] }));
144
146
  };
145
147
  return (_jsx("div", { id: id, className: classNames(classes, className), style: { display: (style === null || style === void 0 ? void 0 : style.display) || 'block' }, "data-testid": "wd-modal-test", children: maskPreToShow && renderNode() }));
146
148
  });
@@ -1,6 +1,5 @@
1
1
  import { useState, useEffect, useCallback } from 'react';
2
2
  import { useSelectContext } from '../contexts/selectContext';
3
- const defaultPage = 1;
4
3
  const getUniqueOption = (option) => {
5
4
  var _a;
6
5
  const optionMap = option.reduce((acc, item) => {
@@ -6,8 +6,9 @@ import { LoadingTip } from 'tea-component';
6
6
  import { SelectUI as Select } from '../select/selectUI';
7
7
  import { WdIcon } from '../../wd-icon';
8
8
  import { getTableColumns } from '../../wd-table/components/FieldRender';
9
+ import { EnumView } from '../../wd-table/components/FieldRender/Form/Enum';
9
10
  import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
10
- import { usePlatform } from '../../../utils/platform';
11
+ import { usePlatform, textToString } from '../../../utils/platform';
11
12
  import { DataSource } from '../../../utils/datasource';
12
13
  import { useSyncValue } from '../../../utils/hooks/useSyncValue';
13
14
  import isObjectEqual from '../../../utils/isObjectEqual';
@@ -15,7 +16,14 @@ import { deepClone } from '../../../utils/tool';
15
16
  import { useChooseList } from '../hooks/useChooseList';
16
17
  import { getDefaultQuery } from './queryParams';
17
18
  import { EnumHoc } from '../../../utils/hooks/EnumHoc';
18
- const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, }) => {
19
+ const OptionTextTitle = ({ field, values }) => {
20
+ if (field.format === 'x-enum') {
21
+ return _jsx(EnumView, { field: field, values: values, showRelationWithTag: false });
22
+ }
23
+ return _jsx("span", { title: textToString(values), children: textToString(values) });
24
+ };
25
+ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, showLabelField, }) => {
26
+ var _a;
19
27
  const platform = usePlatform();
20
28
  const columns = useMemo(() => {
21
29
  return getTableColumns({
@@ -44,7 +52,7 @@ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelati
44
52
  option,
45
53
  });
46
54
  }
47
- }, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", title: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value), children: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
55
+ }, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", title: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value), children: _jsx(OptionTextTitle, { field: showLabelField, values: (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : option === null || option === void 0 ? void 0 : option.value }) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
48
56
  onRelationOptionJump({ item: option });
49
57
  }, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
50
58
  };
@@ -99,12 +107,23 @@ export function RelationSelect(props) {
99
107
  const [isLoading, setIsLoading] = useSyncValue(isValidating, isObjectEqual);
100
108
  // 下拉选项数据
101
109
  const customOptions = useMemo(() => {
102
- return isRelationSelectOption
103
- ? options === null || options === void 0 ? void 0 : options.map((i) => ({
110
+ const showLabelField = authFields.find((i) => i.name === showLabel);
111
+ if (isRelationSelectOption) {
112
+ return options === null || options === void 0 ? void 0 : options.map((i) => ({
104
113
  ...i,
105
- text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump })),
106
- }))
107
- : options;
114
+ text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump, showLabelField: showLabelField })),
115
+ }));
116
+ }
117
+ else if ((showLabelField === null || showLabelField === void 0 ? void 0 : showLabelField.format) === 'x-enum') {
118
+ return options === null || options === void 0 ? void 0 : options.map((i) => {
119
+ var _a;
120
+ return ({
121
+ ...i,
122
+ text: _jsx(OptionTextTitle, { field: showLabelField, values: (_a = i.label) !== null && _a !== void 0 ? _a : i.value }),
123
+ });
124
+ });
125
+ }
126
+ return options;
108
127
  }, [
109
128
  authFields,
110
129
  enableRelationOptionJump,
@@ -114,6 +133,7 @@ export function RelationSelect(props) {
114
133
  onRelationOptionJump,
115
134
  options,
116
135
  selectFields,
136
+ showLabel,
117
137
  ]);
118
138
  const searchOptionListWithWhere = useDebouncedCallback((filter = defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter) => {
119
139
  empty();
@@ -37,8 +37,9 @@ export const formatEnum = (value, field, enumOptions, showRelationWithTag = true
37
37
  const optionName = field['x-option-name'];
38
38
  const isMulti = field['x-multi-select'];
39
39
  const options = (enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[optionName]) || [];
40
+ const optionsMap = new Map(options.map((item) => [item.value, item.text]));
40
41
  let val = '-';
41
- const getTextByValue = (value) => { var _a; return ((_a = options === null || options === void 0 ? void 0 : options.find((item) => (item === null || item === void 0 ? void 0 : item.value) === value)) === null || _a === void 0 ? void 0 : _a.text) || value; };
42
+ const getTextByValue = (value) => optionsMap.get(value) || value;
42
43
  if (isMulti) {
43
44
  val = (_a = []
44
45
  .concat(value)
@@ -48,7 +49,7 @@ export const formatEnum = (value, field, enumOptions, showRelationWithTag = true
48
49
  val = getTextByValue(value);
49
50
  }
50
51
  if (!showRelationWithTag) {
51
- return _jsx("span", { title: val, children: val });
52
+ return (_jsx("span", { style: { display: 'inline-block' }, title: val, children: val }));
52
53
  }
53
54
  return (_jsx(WdTag, { range: val === null || val === void 0 ? void 0 : val.split(',').map((i) => ({
54
55
  label: i,
@@ -10,6 +10,7 @@ import StatusContent from '../../../statusContent';
10
10
  import classNames from '../../../../utils/classnames';
11
11
  import { setTableHeaderStyle } from './util';
12
12
  import { orderByFieldKey } from '../../utils/index';
13
+ import { FormFieldProvider } from '../../../wd-form/contexts/form-field-context';
13
14
  const { LoadingTip } = StatusTip;
14
15
  const defaultTotal = 0;
15
16
  const pageIndexSpan = 1;
@@ -179,7 +180,8 @@ export const BaseTableCom = ({ events, recordKey, className, columns, setColumns
179
180
  }
180
181
  }
181
182
  if (shouldShowBottomTip) {
182
- return _jsx(_Fragment, { children: bottomTip });
183
+ // 表格底部插槽内的表单组件,非标准数组字段,不受表格控制
184
+ return (_jsx(FormFieldProvider, { setFieldValue: () => { }, getFieldValue: () => { }, children: bottomTip }));
183
185
  }
184
186
  return null;
185
187
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable max-lines */
3
- import { useRef, useEffect, useState, useMemo, forwardRef, memo } from 'react';
3
+ import { useRef, useEffect, useState, useMemo, forwardRef, memo, useCallback } from 'react';
4
4
  import { ConfigProvider } from 'tea-component';
5
5
  import { ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
6
6
  import { TableWithForm } from './table-with-form';
@@ -63,7 +63,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
63
63
  // 以下为非标准属性,config中没有
64
64
  // isOrderBy, // API是否支持排序(旧的表格有该属性)
65
65
  isMock = false, //是否mock数据
66
- enableRefreshBtn = true, enableTableHeightSizeBtn = true, emptyText = '暂无数据', dataSourceData, //绑定表达式时的表格数据
66
+ enableRefreshBtn = true, enableTableHeightSizeBtn = true, emptyText = '暂无数据', dataSourceData = [], //绑定表达式时的表格数据
67
67
  recordKey: _recordKey = '_id', // 数据主键
68
68
  total: _total, // 表格总条数
69
69
  enableTotal = false, //是否开启动态分页
@@ -123,10 +123,6 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
123
123
  // 移动端操作按钮弹窗
124
124
  const [isMobileOptionVisible, setIsMobileOptionVisible] = useState(false);
125
125
  const modalRef = useRef(null);
126
- const dataRef = useRef({
127
- dataSourceData: [],
128
- tableRecords: [],
129
- });
130
126
  const { enumOptions } = useEnumContext();
131
127
  const dataSourceAPI = useMemo(() => new DataSource(dbName), [dbName]); // datasource 方法-模型
132
128
  // 插槽属性
@@ -332,7 +328,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
332
328
  };
333
329
  const isTableLoading = getLoadingStatus();
334
330
  // 表格数据
335
- const mapTableData = () => {
331
+ const mapTableData = useCallback(() => {
336
332
  if (isMock) {
337
333
  return Mock.records;
338
334
  }
@@ -354,8 +350,21 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
354
350
  mapTableDataWithView(viewFieldsData, tableData);
355
351
  }
356
352
  return tableData;
357
- };
358
- const tableRecords = mapTableData();
353
+ // eslint-disable-next-line react-hooks/exhaustive-deps
354
+ }, [
355
+ dataSourceData,
356
+ exprLoading,
357
+ isExpression,
358
+ isH5,
359
+ isMock,
360
+ isNoDataSourceBind,
361
+ isTableLoading,
362
+ queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageIndex,
363
+ tableData,
364
+ ]);
365
+ const tableRecords = useMemo(() => {
366
+ return mapTableData();
367
+ }, [mapTableData]);
359
368
  // 总数
360
369
  let total = isExpression ? tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length : tableTotal;
361
370
  if (enableTotal && isExpression && !isNaN(parseInt(`${_total}`))) {
@@ -365,17 +374,6 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
365
374
  setSelectedKeys([]);
366
375
  setSelectedRecords([]);
367
376
  }, [_recordKey]);
368
- useEffect(() => {
369
- var _a, _b;
370
- if (isExpression &&
371
- Array.isArray(dataSourceData) &&
372
- !isObjectEqual((_a = dataRef === null || dataRef === void 0 ? void 0 : dataRef.current) === null || _a === void 0 ? void 0 : _a.dataSourceData, dataSourceData)) {
373
- dataRef.current.dataSourceData = [...dataSourceData];
374
- }
375
- if (!isObjectEqual((_b = dataRef === null || dataRef === void 0 ? void 0 : dataRef.current) === null || _b === void 0 ? void 0 : _b.tableRecords, tableRecords)) {
376
- dataRef.current.tableRecords = [...tableRecords];
377
- }
378
- }, [dataSourceData, tableRecords, isExpression]);
379
377
  const beforeModalDestroy = () => {
380
378
  // 重新加载数据
381
379
  refreshTable();
@@ -557,7 +555,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
557
555
  onSelectChange([], {}, true);
558
556
  return;
559
557
  }
560
- const recordsMap = new Map(dataRef.current.tableRecords.map((item) => [item[recordKey], item]));
558
+ const recordsMap = new Map(tableRecords.map((item) => [item[recordKey], item]));
561
559
  const records = (_b = (_a = params === null || params === void 0 ? void 0 : params.selectedKeys) === null || _a === void 0 ? void 0 : _a.map((key) => recordsMap.get(key))) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
562
560
  const context = { record: records, selectedRecords: records };
563
561
  const validSelectedKeys = (records === null || records === void 0 ? void 0 : records.map((record) => record[recordKey])) || [];
@@ -565,8 +563,8 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
565
563
  },
566
564
  // 当前页数据
567
565
  records: isExpression && !enableTotal && enablePagination
568
- ? getCurrentPageData(dataRef.current.tableRecords, query.pageNo, query.pageSize)
569
- : dataRef.current.tableRecords,
566
+ ? getCurrentPageData(tableRecords, query.pageNo, query.pageSize)
567
+ : tableRecords,
570
568
  // 当前总数
571
569
  total: total,
572
570
  pageNo: query.pageNo,
@@ -578,7 +576,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
578
576
  columnSets,
579
577
  defaultPageSize,
580
578
  defaultPageIndex,
581
- dataSourceData: dataRef.current.dataSourceData,
579
+ dataSourceData,
582
580
  sort: supportManyRelated ? query.orderBy : [{ orderBy: query.orderBy, orderType: query.orderType }],
583
581
  filter: supportManyRelated ? query.filter : query === null || query === void 0 ? void 0 : query.where,
584
582
  dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
@@ -592,7 +590,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
592
590
  isH5,
593
591
  isModel,
594
592
  selectedKeys,
595
- dataRef.current.tableRecords,
593
+ tableRecords,
596
594
  total,
597
595
  query.pageNo,
598
596
  query.pageSize,
@@ -601,7 +599,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
601
599
  bindMetadata,
602
600
  defaultPageSize,
603
601
  defaultPageIndex,
604
- dataRef.current.dataSourceData,
602
+ dataSourceData,
605
603
  selectedRecords,
606
604
  query === null || query === void 0 ? void 0 : query.orderBy,
607
605
  query === null || query === void 0 ? void 0 : query.orderType,
@@ -64,8 +64,8 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
64
64
  300);
65
65
  // 渲染菜单
66
66
  const RenderTabItem = (index, item) => {
67
- return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: () => {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
67
+ return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: (e) => {
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
69
69
  if (!(item === null || item === void 0 ? void 0 : item.isDisabled) && !(item === null || item === void 0 ? void 0 : item.selected)) {
70
70
  if (restProps.direction !== 'vertical') {
71
71
  const parentWidths = (_b = (_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth;
@@ -93,6 +93,7 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
93
93
  $node.current._getInstanceRef().current.selectedValue = currentSelectedValue;
94
94
  }
95
95
  }
96
+ (_q = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _q === void 0 ? void 0 : _q.tap({}, { originEvent: e });
96
97
  debouncedChangeEvent({ value: item === null || item === void 0 ? void 0 : item.value });
97
98
  }
98
99
  }, children: [(item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'prefix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null, _jsx("div", { className: `${classPrefix}-tabs__item-text`, children: item === null || item === void 0 ? void 0 : item.label }), (item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'suffix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null] }));
@@ -108,5 +109,7 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
108
109
  const showRightMask = Math.round(scrollLeft + parentWidth) < scrollWidth;
109
110
  setShowRightMask(showRightMask);
110
111
  }
111
- }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }), showMask && restProps.direction !== 'vertical' && (_jsx("div", { className: `${classPrefix}-tabs__header-item-mask`, style: { opacity: `${showRightMask ? '1' : '0'}` } }))] }) }), _jsx("div", { className: `${classPrefix}-tabs__body`, children: _jsx("div", { className: `${classPrefix}-tabs__body-content`, children: renderSlot({ ...restProps, selectedTab, tabsDatas, isMultipleSlot }) }) })] }));
112
+ }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }), showMask && restProps.direction !== 'vertical' && (_jsx("div", { className: `${classPrefix}-tabs__header-item-mask`, style: { opacity: `${showRightMask ? '1' : '0'}` } }))] }) }), _jsx("div", { className: `${classPrefix}-tabs__body`, onClick: (e) => {
113
+ e.stopPropagation();
114
+ }, children: _jsx("div", { className: `${classPrefix}-tabs__body-content`, children: renderSlot({ ...restProps, selectedTab, tabsDatas, isMultipleSlot }) }) })] }));
112
115
  };
@@ -65,8 +65,8 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
65
65
  300);
66
66
  // 渲染菜单
67
67
  const RenderTabItem = (index, item) => {
68
- return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: () => {
69
- var _a, _b, _c, _d, _e, _f;
68
+ return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: (e) => {
69
+ var _a, _b, _c, _d, _e, _f, _g;
70
70
  if (!(item === null || item === void 0 ? void 0 : item.isDisabled) && !(item === null || item === void 0 ? void 0 : item.selected)) {
71
71
  if (restProps.direction !== 'vertical') {
72
72
  const parentWidths = (_b = (_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth;
@@ -95,6 +95,7 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
95
95
  $node.current._getInstanceRef().current.selectedValue = currentSelectedValue;
96
96
  }
97
97
  }
98
+ (_g = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _g === void 0 ? void 0 : _g.tap({}, { originEvent: e });
98
99
  debouncedChangeEvent({ value: item === null || item === void 0 ? void 0 : item.value });
99
100
  }
100
101
  }, children: [(item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'prefix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null, _jsx("div", { className: `${classPrefix}-tabs__item-text`, children: item === null || item === void 0 ? void 0 : item.label }), (item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'suffix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null] }));
@@ -115,5 +116,7 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
115
116
  index: position.index + Number('1'),
116
117
  offset: result,
117
118
  });
118
- } }))] }), _jsx("div", { className: `${classPrefix}-tabs__body`, children: _jsx("div", { className: `${classPrefix}-tabs__body-content`, children: renderSlot({ ...restProps, selectedTab, tabsDatas, isMultipleSlot }) }) })] }));
119
+ } }))] }), _jsx("div", { className: `${classPrefix}-tabs__body`, onClick: (e) => {
120
+ e.stopPropagation();
121
+ }, children: _jsx("div", { className: `${classPrefix}-tabs__body-content`, children: renderSlot({ ...restProps, selectedTab, tabsDatas, isMultipleSlot }) }) })] }));
119
122
  };
@@ -14,10 +14,6 @@ export const WdTabs = (props) => {
14
14
  setIndex(val);
15
15
  };
16
16
  return (_jsx("div", { "data-testid": "wd-tabs", className: `${classPrefix}-tabs-root ${props.direction === 'vertical'
17
- ? `${classPrefix}-tabs--vertical ${classPrefix}-side-tab-root ${isH5
18
- ? `${classPrefix}-h5-side-tab-root`
19
- : `${classPrefix}-pc-side-tab-root`}`
20
- : `${classPrefix}-top-tab-root ${isH5
21
- ? `${classPrefix}-h5-top-tab-root`
22
- : `${classPrefix}-pc-top-tab-root`}`} ${isH5 ? `${classPrefix}-tabs-h5-root` : ''} ${props === null || props === void 0 ? void 0 : props.className}`, style: props === null || props === void 0 ? void 0 : props.style, onClick: (e) => { var _a; return (_a = props === null || props === void 0 ? void 0 : props.events) === null || _a === void 0 ? void 0 : _a.tap({}, { originEvent: e }); }, children: !isH5 ? (_jsx(WdTabsPc, { getIndex: getIndex, ...props })) : (_jsx(WdTabsH5, { getIndex: getIndex, ...props })) }));
17
+ ? `${classPrefix}-tabs--vertical ${classPrefix}-side-tab-root ${isH5 ? `${classPrefix}-h5-side-tab-root` : `${classPrefix}-pc-side-tab-root`}`
18
+ : `${classPrefix}-top-tab-root ${isH5 ? `${classPrefix}-h5-top-tab-root` : `${classPrefix}-pc-top-tab-root`}`} ${isH5 ? `${classPrefix}-tabs-h5-root` : ''} ${props === null || props === void 0 ? void 0 : props.className}`, style: props === null || props === void 0 ? void 0 : props.style, children: !isH5 ? _jsx(WdTabsPc, { getIndex: getIndex, ...props }) : _jsx(WdTabsH5, { getIndex: getIndex, ...props }) }));
23
19
  };
@@ -2,7 +2,7 @@
2
2
  import { alertErrorMessage } from '../../utils/platform';
3
3
  // ! reference in src/web/components/richTextView/index.tsx
4
4
  export const getOnClick = (props) => {
5
- const { url, options, events } = props;
5
+ const { url, options, events, simulatingAnchorScrolling = true } = props;
6
6
  const isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i);
7
7
  return async (e) => {
8
8
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -16,7 +16,7 @@ export const getOnClick = (props) => {
16
16
  const targetId = url.split('#')[1];
17
17
  const target = document.getElementById(targetId) || ((_g = document.getElementsByName(targetId)) === null || _g === void 0 ? void 0 : _g[0]);
18
18
  // hash路由下模拟锚点滚动
19
- if (isHashRouter && target && (props === null || props === void 0 ? void 0 : props.simulatingAnchorScrolling)) {
19
+ if (isHashRouter && target && simulatingAnchorScrolling) {
20
20
  if ((isOrigin && isHashLink) || url.startsWith('#')) {
21
21
  if (!e.defaultPrevented) {
22
22
  e.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.25.1",
3
+ "version": "3.26.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",