@cloudbase/weda-ui 3.24.0 → 3.25.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.
Files changed (34) hide show
  1. package/dist/configs/components/dataView.js +1 -0
  2. package/dist/configs/components/listView.js +1 -0
  3. package/dist/configs/components/wd-button.js +2 -1
  4. package/dist/configs/components/wd-form-arr.js +4 -1
  5. package/dist/configs/components/wd-select-multiple.js +1 -0
  6. package/dist/configs/components/wd-select.js +1 -0
  7. package/dist/configs/components/wd-table.js +1 -0
  8. package/dist/configs/components/wd-text.js +2 -2
  9. package/dist/configs/type-utils/type-form.js +6 -4
  10. package/dist/configs/utils/field.d.ts +1 -0
  11. package/dist/configs/utils/field.js +151 -0
  12. package/dist/style/index.css +6 -0
  13. package/dist/style/index.scss +1 -1
  14. package/dist/style/weda-ui.min.css +2 -2
  15. package/dist/web/components/form-input-hooks/index.js +12 -4
  16. package/dist/web/components/formdetail/index.js +1 -0
  17. package/dist/web/components/table/ExportFileModalByApi/index.js +24 -13
  18. package/dist/web/components/wd-button/wd-button.js +5 -5
  19. package/dist/web/components/wd-form/hoc/form-container-decorator.js +7 -2
  20. package/dist/web/components/wd-form/hooks/use-remote-value.js +0 -1
  21. package/dist/web/components/wd-form-item/wd-form-item.js +9 -11
  22. package/dist/web/components/wd-table/components/FieldRender/index.js +1 -0
  23. package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +2 -2
  24. package/dist/web/components/wd-table/components/Table/index.d.ts +1 -2
  25. package/dist/web/components/wd-table/components/Table/index.js +26 -13
  26. package/dist/web/components/wd-table/components/index.d.ts +2 -1
  27. package/dist/web/components/wd-table/components/index.js +1 -1
  28. package/dist/web/components/wd-table/hooks/useTableData.js +15 -6
  29. package/dist/web/components/wd-table/table-with-form.d.ts +9 -0
  30. package/dist/web/components/wd-table/table-with-form.js +46 -0
  31. package/dist/web/components/wd-table/wd-table.d.ts +19 -4
  32. package/dist/web/components/wd-table/wd-table.js +21 -30
  33. package/dist/web/utils/hooks/useCanPreview.js +1 -1
  34. package/package.json +4 -3
@@ -2,25 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable max-lines */
3
3
  import { useRef, useEffect, useState, useMemo, forwardRef, memo } from 'react';
4
4
  import { ConfigProvider } from 'tea-component';
5
- import { useDeepCompareEffect } from '@react-hookz/web';
6
- import { Table, ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
5
+ import { ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
6
+ import { TableWithForm } from './table-with-form';
7
7
  import classNames from '../../utils/classnames';
8
8
  import { useConfig } from '../../utils/config-context';
9
9
  import { DataSource } from '../../utils/datasource';
10
10
  import { CELL_CUSTOM_OPTION, emptyArray } from '../../utils/constant';
11
11
  import { useEnumContext } from '../../utils/hooks/context';
12
12
  import { EnumHoc } from '../../utils/hooks/EnumHoc';
13
- import { usePlatform, isInIde } from '../../utils/platform';
13
+ import { usePlatform } from '../../utils/platform';
14
14
  import { convertWhere } from '../../utils/getModelParams';
15
15
  import isObjectEqual from '../../utils/isObjectEqual';
16
16
  import { useAuthFields } from './hooks/useAuthFields';
17
17
  import { useTableData } from './hooks/useTableData';
18
18
  import { useViewFields } from './hooks/useViewFields';
19
19
  import { useQueryParams } from './hooks/useQueryParams';
20
- // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
21
- import { withFormContainer } from '../wd-form/hoc/form-container-decorator';
22
- import { useFormField } from '../wd-form/contexts/form-field-context';
23
- import { useFormFieldObj } from '../wd-form/contexts/form-field-obj-context';
24
20
  import { WdCompError } from '../../utils/error';
25
21
  import { getSlots, getFilterFields, getSelectedView, getSortColumns, mapTableDataWithView, checkSupport, DataSourceType, getRecordKey, getCurrentPageData, } from './utils';
26
22
  import { Mock } from './mock';
@@ -38,9 +34,8 @@ export const TableOption = function TableOption({ slots, ...props }) {
38
34
  export const GlobalButton = memo(function GlobalButtonDom({ classPrefix, slots }) {
39
35
  return _jsx("div", { className: `${classPrefix}-global-btn`, children: slotRender(slots) });
40
36
  });
41
- export const WdTable = withFormContainer(
42
37
  // eslint-disable-next-line complexity
43
- forwardRef(function TableComp(tableProps, ref) {
38
+ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
44
39
  const { className, style, dataSourceType = 'data-model', bindConnectMetadata = {
45
40
  datasource: { id: '', name: '', title: '' },
46
41
  }, // APImock数据
@@ -80,10 +75,7 @@ forwardRef(function TableComp(tableProps, ref) {
80
75
  isSupportMultipleSort = false, // 是否支持多字段排序
81
76
  sorter, // 排序规则
82
77
  __innerSlot, enableRelationTag = true, // 关联关系字段是否开启关联标签
83
- enableBottomTipSlot = false, row__bottom__slot, rowDisabled, ...props } = tableProps;
84
- const formField = useFormField();
85
- const { formFieldsValue = [], setFieldValue, setFormFieldsValue } = formField || {};
86
- const formFieldObjsContext = useFormFieldObj();
78
+ enableBottomTipSlot = false, row__bottom__slot, ...props } = tableProps;
87
79
  const wList = convertWhere(props, supportManyRelated); // 查询参数
88
80
  const { classPrefix } = useConfig();
89
81
  const platform = usePlatform();
@@ -209,7 +201,7 @@ forwardRef(function TableComp(tableProps, ref) {
209
201
  setColumns([]);
210
202
  }, [columnSets]);
211
203
  const columns = useMemo(() => {
212
- if (isMock || (isInIde() && isNoDataSourceBind)) {
204
+ if (isMock) {
213
205
  return Mock.columns;
214
206
  }
215
207
  if (isNoDataSourceBind || (!isExpression && fieldsLoading)) {
@@ -341,7 +333,7 @@ forwardRef(function TableComp(tableProps, ref) {
341
333
  const isTableLoading = getLoadingStatus();
342
334
  // 表格数据
343
335
  const mapTableData = () => {
344
- if (isMock || (isInIde() && isNoDataSourceBind)) {
336
+ if (isMock) {
345
337
  return Mock.records;
346
338
  }
347
339
  // 绑定表达式则直接返回表达式的值
@@ -364,15 +356,6 @@ forwardRef(function TableComp(tableProps, ref) {
364
356
  return tableData;
365
357
  };
366
358
  const tableRecords = mapTableData();
367
- useDeepCompareEffect(() => {
368
- const value = [...tableRecords];
369
- if (setFieldValue && (formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath)) {
370
- setFieldValue({ namePath: formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath, value });
371
- }
372
- else if (setFormFieldsValue) {
373
- setFormFieldsValue(value);
374
- }
375
- }, [formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath, tableRecords]);
376
359
  // 总数
377
360
  let total = isExpression ? tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length : tableTotal;
378
361
  if (enableTotal && isExpression && !isNaN(parseInt(`${_total}`))) {
@@ -569,7 +552,16 @@ forwardRef(function TableComp(tableProps, ref) {
569
552
  },
570
553
  // 设置选中项
571
554
  setSelectedKeys: (params) => {
572
- setSelectedKeys(params.selectedKeys);
555
+ var _a, _b;
556
+ if (!(params === null || params === void 0 ? void 0 : params.selectedKeys) || params.selectedKeys.length === 0) {
557
+ onSelectChange([], {}, true);
558
+ return;
559
+ }
560
+ const recordsMap = new Map(dataRef.current.tableRecords.map((item) => [item[recordKey], item]));
561
+ 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
+ const context = { record: records, selectedRecords: records };
563
+ const validSelectedKeys = (records === null || records === void 0 ? void 0 : records.map((record) => record[recordKey])) || [];
564
+ onSelectChange(validSelectedKeys, context, false);
573
565
  },
574
566
  // 当前页数据
575
567
  records: isExpression && !enableTotal && enablePagination
@@ -591,7 +583,6 @@ forwardRef(function TableComp(tableProps, ref) {
591
583
  filter: supportManyRelated ? query.filter : query === null || query === void 0 ? void 0 : query.where,
592
584
  dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
593
585
  filterConfig,
594
- value: formFieldsValue,
595
586
  }),
596
587
  // eslint-disable-next-line react-hooks/exhaustive-deps
597
588
  [
@@ -618,7 +609,6 @@ forwardRef(function TableComp(tableProps, ref) {
618
609
  query === null || query === void 0 ? void 0 : query.filter,
619
610
  supportManyRelated,
620
611
  filterConfig,
621
- formFieldsValue,
622
612
  ], ref);
623
613
  // 表格更改上下文数据
624
614
  // 移动端和自定义APIs场景不支持导入功能,监听变化存到表格上下文中
@@ -701,6 +691,7 @@ forwardRef(function TableComp(tableProps, ref) {
701
691
  const onSelectChange = (keys, context, empty = false) => {
702
692
  if (empty) {
703
693
  setSelectedKeys([]);
694
+ setSelectedRecords([]);
704
695
  return;
705
696
  }
706
697
  setSelectedKeys([].concat(keys));
@@ -747,7 +738,7 @@ forwardRef(function TableComp(tableProps, ref) {
747
738
  pageIndex: 1,
748
739
  }));
749
740
  }
750
- events === null || events === void 0 ? void 0 : events.onFilterChange({ searchValues, filterConfig });
741
+ events === null || events === void 0 ? void 0 : events.onFilterChange({ searchValues });
751
742
  };
752
743
  const errorStatus = isError || fieldsError;
753
744
  const errorMsg = isError ? errorObj : fieldsError;
@@ -756,7 +747,7 @@ forwardRef(function TableComp(tableProps, ref) {
756
747
  setOpenMobileFilter(true);
757
748
  }, 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
749
  setOpenMobileFilter(true);
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: {
750
+ }, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination })), _jsx(TableWithForm, { ref: ref, 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, componentType: "table" }), 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
751
  close: () => {
761
752
  setIsMobileOptionVisible(false);
762
753
  },
@@ -765,4 +756,4 @@ forwardRef(function TableComp(tableProps, ref) {
765
756
  setIsMobileOptionVisible(false);
766
757
  },
767
758
  } }) }))] }) }) }));
768
- }));
759
+ });
@@ -15,5 +15,5 @@ export function useCanPreview() {
15
15
  dispose();
16
16
  };
17
17
  }, [dispose]);
18
- return (((_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.isEditorMode) || (editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP')));
18
+ return ((_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.isEditorMode) || (editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP'));
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.24.0",
3
+ "version": "3.25.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -72,8 +72,9 @@
72
72
  "postpack": "pinst --enable",
73
73
  "test:icon": "node tools/publish-icon/test.mjs",
74
74
  "sync-icon": "node tools/publish-icon/sync-icon.mjs",
75
- "deploy": "node scripts/deploy.mjs && npm run release",
76
- "release": "node scripts/release.mjs"
75
+ "deploy": "npm run use-node18 && node scripts/deploy.mjs && npm run release",
76
+ "release": "node scripts/release.mjs",
77
+ "use-node18": "node scripts/use-node18.mjs && hash -r && node -v"
77
78
  },
78
79
  "keywords": [
79
80
  "weda",