@cloudbase/weda-ui 3.22.3 → 3.23.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 (40) hide show
  1. package/dist/configs/components/wd-tabbar.d.ts +16 -0
  2. package/dist/configs/components/wd-tabbar.js +6 -0
  3. package/dist/configs/components/wd-table.d.ts +1 -0
  4. package/dist/configs/components/wd-table.js +14 -1
  5. package/dist/configs/components/wd-upload-image.js +1 -1
  6. package/dist/configs/index.d.ts +34 -0
  7. package/dist/style/index.css +27 -0
  8. package/dist/style/index.scss +1 -1
  9. package/dist/style/weda-ui.min.css +2 -2
  10. package/dist/web/components/form-input-hooks/index.d.ts +0 -1
  11. package/dist/web/components/form-input-hooks/index.js +8 -14
  12. package/dist/web/components/wd-form/contexts/form-field-context.d.ts +6 -2
  13. package/dist/web/components/wd-form/contexts/form-field-context.js +18 -2
  14. package/dist/web/components/wd-form/contexts/form-field-obj-context.d.ts +2 -2
  15. package/dist/web/components/wd-form/contexts/form-field-obj-context.js +2 -2
  16. package/dist/web/components/wd-form/hoc/form-container-decorator.d.ts +11 -0
  17. package/dist/web/components/wd-form/hoc/form-container-decorator.js +61 -0
  18. package/dist/web/components/wd-form/index.d.ts +4 -49
  19. package/dist/web/components/wd-form/index.js +53 -70
  20. package/dist/web/components/wd-form-obj/base-form-obj.d.ts +5 -1
  21. package/dist/web/components/wd-form-obj/base-form-obj.js +19 -38
  22. package/dist/web/components/wd-input/wd-input.d.ts +2 -0
  23. package/dist/web/components/wd-input/wd-input.js +70 -18
  24. package/dist/web/components/wd-input-number/wd-input-number.js +15 -15
  25. package/dist/web/components/wd-tabbar/wd-tabbar.js +4 -6
  26. package/dist/web/components/wd-table/components/FieldRender/index.d.ts +9 -1
  27. package/dist/web/components/wd-table/components/FieldRender/index.js +33 -4
  28. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -1
  29. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +7 -3
  30. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -1
  31. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +6 -15
  32. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +47 -16
  33. package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +15 -5
  34. package/dist/web/components/wd-table/utils/index.d.ts +5 -2
  35. package/dist/web/components/wd-table/utils/index.js +12 -1
  36. package/dist/web/components/wd-table/wd-table.d.ts +5 -19
  37. package/dist/web/components/wd-table/wd-table.js +22 -2
  38. package/dist/web/components/wd-tree/utils.js +1 -1
  39. package/dist/web/utils/hooks/useFormLegacy.js +5 -12
  40. package/package.json +5 -5
@@ -5,6 +5,7 @@ import { dateCalculation } from '../../../../utils/date';
5
5
  import isObjectEqual from '../../../../utils/isObjectEqual';
6
6
  import { useConfig } from '../../../../utils/config-context';
7
7
  import { FilterFieldItem } from './FilterFieldItem';
8
+ import { arrayInputType } from './Fields';
8
9
  import { filterFieldsGenerate } from './filterFieldsGenerate';
9
10
  import { WdButton } from '../../../wd-button';
10
11
  import { usePlatform } from '../../../../utils/platform';
@@ -89,7 +90,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
89
90
  });
90
91
  // 值筛选条件
91
92
  filterValues.forEach((i) => {
92
- var _a, _b;
93
+ var _a, _b, _c;
93
94
  switch (i.fieldCalculation.value) {
94
95
  case 'scope':
95
96
  if (i.filterType === 'number') {
@@ -142,10 +143,19 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
142
143
  default: {
143
144
  const searchItem = {
144
145
  key: i.name,
145
- val: i.filterType === 'string' ? (_b = i.value) === null || _b === void 0 ? void 0 : _b.trim() : i.value,
146
+ val: i.value,
146
147
  rel: i.fieldCalculation.value,
147
148
  };
148
- if (i.filterType === 'number') {
149
+ if (i.filterType === 'string') {
150
+ if (arrayInputType.includes(i.fieldCalculation.value) && ((_b = searchItem === null || searchItem === void 0 ? void 0 : searchItem.val) === null || _b === void 0 ? void 0 : _b.length)) {
151
+ searchValues.push(searchItem);
152
+ }
153
+ else {
154
+ searchItem.val = (_c = i.value) === null || _c === void 0 ? void 0 : _c.trim();
155
+ searchValues.push(searchItem);
156
+ }
157
+ }
158
+ else if (i.filterType === 'number') {
149
159
  searchItem.val = Number(i.value);
150
160
  searchValues.push(searchItem);
151
161
  }
@@ -183,7 +193,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
183
193
  };
184
194
  // eslint-disable-next-line react-hooks/exhaustive-deps
185
195
  useSetWidgetApi(() => ({ resetFilter }), [initFilterData], ref);
186
- return (_jsxs(ConfigProvider, { classPrefix: "wedatea2td", children: [_jsx(Drawer, { className: `${classPrefix}-table-mobile-filter-drawer ${classPrefix}-table-wrap-filter ${classPrefix}-h5-table-wrap-filter`, title: "\u7B5B\u9009\u5668", visible: isH5 && openMobileFilter, onClose: () => {
196
+ return (_jsxs(ConfigProvider, { classPrefix: "wedatea2td", children: [isH5 && (_jsx(Drawer, { className: `${classPrefix}-table-mobile-filter-drawer ${classPrefix}-table-wrap-filter ${classPrefix}-h5-table-wrap-filter`, title: "\u7B5B\u9009\u5668", visible: isH5 && openMobileFilter, onClose: () => {
187
197
  setOpenMobileFilter(false);
188
198
  }, children: _jsxs("div", { children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__body`, children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i) => (_jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }, i.id))) }), _jsx("div", { className: `${classPrefix}-table-wrap-filter__footer`, children: _jsxs("div", { className: `${classPrefix}-table-wrap-filter__btn`, children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__btn-item`, children: _jsx(WdButton, { theme: "primary", variant: "outline", size: "lg", text: "\u91CD\u7F6E", events: {
189
199
  tap: resetFilter,
@@ -192,7 +202,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
192
202
  searchHandle();
193
203
  setOpenMobileFilter(false);
194
204
  },
195
- } }) })] }) })] }) }), !isH5 && !!filterData.length && (_jsx("form", { className: `${classPrefix}-table-wrap-filter`, onSubmit: onFormSubmit, children: _jsxs(Row, { gap: 20, verticalAlign: 'bottom', style: { justifyContent: 'space-between' }, children: [_jsx(_Fragment, { children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i, index) => (_jsx(Col, { span: 6, style: {
205
+ } }) })] }) })] }) })), !isH5 && !!filterData.length && (_jsx("form", { className: `${classPrefix}-table-wrap-filter`, onSubmit: onFormSubmit, "data-testid": "filter-form", children: _jsxs(Row, { gap: 20, verticalAlign: 'top', style: { justifyContent: 'space-between' }, children: [_jsx(_Fragment, { children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i, index) => (_jsx(Col, { span: 6, style: {
196
206
  display: `${index > num && collapse ? 'none' : 'block'}`,
197
207
  }, children: _jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }) }, i.id))) }), _jsx(Col, { span: 24, style: { flex: '1', textAlign: 'right' }, children: _jsxs("div", { className: `${classPrefix}-space`, children: [_jsx("div", { className: `${classPrefix}-space-item`, children: _jsx(WdButton, { size: "md", theme: "secondary", text: "\u91CD\u7F6E", events: {
198
208
  tap: resetFilter,
@@ -13,11 +13,14 @@ export declare const getFilter: ({ wList, searchValues, searchConfig, conditionC
13
13
  relateWhere: {};
14
14
  };
15
15
  export declare const getSearchValues: (searchValues?: any[]) => {
16
- commonSearchValue: {
16
+ commonSearchValue: ({
17
+ $or: any;
18
+ } | {
17
19
  [x: number]: {
18
20
  [x: string]: any;
19
21
  };
20
- }[];
22
+ $or?: undefined;
23
+ })[];
21
24
  relatedSearchValues: any;
22
25
  };
23
26
  export declare const orderByFieldKey: (key: any, columns: any) => any;
@@ -182,7 +182,18 @@ export const getSearchValues = (searchValues = []) => {
182
182
  // 普通字段的直接条件
183
183
  const commonSearchValue = searchValuesList
184
184
  .filter((i) => !NEW_RELATION_FORMATS.includes(i.format))
185
- .map((item) => ({ [item.key]: { [`$${item.rel}`]: item.val } }));
185
+ .map((item) => {
186
+ if (item.format === 'string' && ['search_ci', 'nsearch_ci'].includes(item.rel)) {
187
+ const itemVal = Array.isArray(item.val) ? item.val : [item.val];
188
+ if (!itemVal.length) {
189
+ return null;
190
+ }
191
+ const searchCondition = itemVal === null || itemVal === void 0 ? void 0 : itemVal.map((n) => ({ [item.key]: { [`$${item.rel}`]: n } }));
192
+ return { $or: searchCondition };
193
+ }
194
+ return { [item.key]: { [`$${item.rel}`]: item.val } };
195
+ })
196
+ .filter(Boolean);
186
197
  return {
187
198
  commonSearchValue,
188
199
  relatedSearchValues,
@@ -10,29 +10,15 @@ export declare const GlobalButton: React.NamedExoticComponent<{
10
10
  classPrefix: string;
11
11
  slots: any;
12
12
  }>;
13
- export declare const WdTable: React.ForwardRefExoticComponent<WdTableProps & React.RefAttributes<TCompRef>>;
13
+ export declare const WdTable: React.ForwardRefExoticComponent<Pick<{
14
+ [key: string]: any;
15
+ initialValues?: any;
16
+ }, string | number> & React.RefAttributes<unknown>>;
14
17
  export interface WdTableProps extends CommonPropsType, DataType {
15
18
  isMock?: boolean;
16
19
  multipleSelect: boolean;
17
20
  mockEmpty?: boolean;
18
21
  row__bottom__slot?: React.ReactNode;
19
22
  __innerSlot?: React.ReactNode;
23
+ initialValues?: [];
20
24
  }
21
- type TCompRef = {
22
- import: () => void;
23
- exportOptionalMode: () => void;
24
- export: () => void;
25
- deleteSelected: () => void;
26
- refresh: () => void;
27
- refreshKeepPage: () => void;
28
- deleteOne: (params: {
29
- id: string;
30
- }) => void;
31
- openOperationDialog: () => void;
32
- records?: any[];
33
- total: number;
34
- pageNo: number;
35
- pageSize: number;
36
- selectedRecords: any[];
37
- };
38
- export {};
@@ -2,6 +2,7 @@ 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';
5
6
  import { Table, ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
6
7
  import classNames from '../../utils/classnames';
7
8
  import { useConfig } from '../../utils/config-context';
@@ -16,6 +17,10 @@ import { useAuthFields } from './hooks/useAuthFields';
16
17
  import { useTableData } from './hooks/useTableData';
17
18
  import { useViewFields } from './hooks/useViewFields';
18
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';
19
24
  import { WdCompError } from '../../utils/error';
20
25
  import { getSlots, getFilterFields, getSelectedView, getSortColumns, mapTableDataWithView, checkSupport, DataSourceType, getRecordKey, getCurrentPageData, } from './utils';
21
26
  import { Mock } from './mock';
@@ -33,8 +38,9 @@ export const TableOption = function TableOption({ slots, ...props }) {
33
38
  export const GlobalButton = memo(function GlobalButtonDom({ classPrefix, slots }) {
34
39
  return _jsx("div", { className: `${classPrefix}-global-btn`, children: slotRender(slots) });
35
40
  });
41
+ export const WdTable = withFormContainer(
36
42
  // eslint-disable-next-line complexity
37
- export const WdTable = forwardRef(function TableComp(tableProps, ref) {
43
+ forwardRef(function TableComp(tableProps, ref) {
38
44
  const { className, style, dataSourceType = 'data-model', bindConnectMetadata = {
39
45
  datasource: { id: '', name: '', title: '' },
40
46
  }, // APImock数据
@@ -75,6 +81,9 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
75
81
  sorter, // 排序规则
76
82
  __innerSlot, enableRelationTag = true, // 关联关系字段是否开启关联标签
77
83
  enableBottomTipSlot = false, row__bottom__slot, ...props } = tableProps;
84
+ const formField = useFormField();
85
+ const { formFieldsValue = [], setFieldValue, setFormFieldsValue } = formField || {};
86
+ const formFieldObjsContext = useFormFieldObj();
78
87
  const wList = convertWhere(props, supportManyRelated); // 查询参数
79
88
  const { classPrefix } = useConfig();
80
89
  const platform = usePlatform();
@@ -355,6 +364,15 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
355
364
  return tableData;
356
365
  };
357
366
  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]);
358
376
  // 总数
359
377
  let total = isExpression ? tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length : tableTotal;
360
378
  if (enableTotal && isExpression && !isNaN(parseInt(`${_total}`))) {
@@ -573,6 +591,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
573
591
  filter: supportManyRelated ? query.filter : query === null || query === void 0 ? void 0 : query.where,
574
592
  dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
575
593
  filterConfig,
594
+ value: formFieldsValue,
576
595
  }),
577
596
  // eslint-disable-next-line react-hooks/exhaustive-deps
578
597
  [
@@ -599,6 +618,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
599
618
  query === null || query === void 0 ? void 0 : query.filter,
600
619
  supportManyRelated,
601
620
  filterConfig,
621
+ formFieldsValue,
602
622
  ], ref);
603
623
  // 表格更改上下文数据
604
624
  // 移动端和自定义APIs场景不支持导入功能,监听变化存到表格上下文中
@@ -745,4 +765,4 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
745
765
  setIsMobileOptionVisible(false);
746
766
  },
747
767
  } }) }))] }) }) }));
748
- });
768
+ }));
@@ -226,7 +226,7 @@ const dealCheck = (_treeNode, showData) => {
226
226
  };
227
227
  while (parent) {
228
228
  parent.checked = getChecked(parent);
229
- parent = parent.parent;
229
+ parent = parent.parent && getTreeNode(showData, parent.parent);
230
230
  }
231
231
  if ((_a = treeNode.children) === null || _a === void 0 ? void 0 : _a.length) {
232
232
  adjust(treeNode.children, treeNode.checked);
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useRef, useState, useCallback } from 'react';
2
2
  import { convertLegacyProps, convertLegacyEnum } from '../tool';
3
- import { WD_INPUT_SIZE, WD_INPUT_LAYOUT, WD_INPUT_LABEL_ALIGN, WD_DATE_FORMAT, } from '../../../enum';
3
+ import { WD_INPUT_SIZE, WD_INPUT_LAYOUT, WD_INPUT_LABEL_ALIGN, WD_DATE_FORMAT } from '../../../enum';
4
4
  import isEqual from '../isObjectEqual';
5
5
  import lodashGet from 'lodash.get';
6
6
  import { usePlatform, textToString } from '../platform';
@@ -138,7 +138,7 @@ export const convertPx = (val, unit = 'px') => {
138
138
  /** 日期时间组件相关方法 start */
139
139
  // 兼容 format
140
140
  export const useDateFormat = (props) => {
141
- const { mode = X_RUNTIME_DEFAULT.mode, dateFormat = X_RUNTIME_DEFAULT.dateFormat, } = props || {};
141
+ const { mode = X_RUNTIME_DEFAULT.mode, dateFormat = X_RUNTIME_DEFAULT.dateFormat } = props || {};
142
142
  const format = useMemo(() => {
143
143
  const formatValue = WD_DATE_FORMAT.find((item) => item.value === dateFormat);
144
144
  switch (mode) {
@@ -353,10 +353,7 @@ export const convertTimeValue = (value) => {
353
353
  const match = value.match(/(\d{2}):(\d{2}):?(\d{2})?/);
354
354
  if (match) {
355
355
  const [yes, hour = 0, minute = 0, second = 0] = match;
356
- if (yes &&
357
- Number(hour) < 24 &&
358
- Number(minute) < 60 &&
359
- Number(second) < 60) {
356
+ if (yes && Number(hour) < 24 && Number(minute) < 60 && Number(second) < 60) {
360
357
  time = moment.duration(`${hour}:${minute}:${second}`).asMilliseconds();
361
358
  }
362
359
  }
@@ -397,9 +394,7 @@ export const useHandleClear = (props) => {
397
394
  const onMouseEnter = useCallback(() => setHover(true), []);
398
395
  const onMouseLeave = useCallback(() => setHover(false), []);
399
396
  const onClear = useCallback(() => onChange === null || onChange === void 0 ? void 0 : onChange(null), [onChange]);
400
- const truth = !isNil(value) &&
401
- value !== '' &&
402
- (!Array.isArray(value) || value.length !== 0);
397
+ const truth = !isNil(value) && value !== '' && (!Array.isArray(value) || value.length !== 0);
403
398
  const hasClearIcon = clearable && !disabled && !readOnly && truth && (hover || isH5);
404
399
  return { onMouseEnter, onMouseLeave, onClear, hasClearIcon };
405
400
  };
@@ -413,9 +408,7 @@ export const convertAcceptTypes = (_acceptTypes = X_RUNTIME_DEFAULT._acceptTypes
413
408
  else if (Array.isArray(_acceptTypes)) {
414
409
  types = _acceptTypes;
415
410
  }
416
- return types
417
- .filter((d) => !!d)
418
- .map((d) => (/(\*)|(\/)|(^\..+)/.test(d) ? d : `.${d}`));
411
+ return types.filter((d) => !!d).map((d) => (/(\*)|(\/)|(^\..+)/.test(d) ? d : `.${d}`));
419
412
  };
420
413
  // 区分不同端的前后缀图标,比如下拉选择
421
414
  export const useFixedIcon = (props) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.22.3",
3
+ "version": "3.23.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -85,7 +85,7 @@
85
85
  "description": "腾讯云微搭低代码组件库模板",
86
86
  "dependencies": {
87
87
  "@antv/g6": "^4.8.5",
88
- "@cloudbase/weda-client": "^1.1.33",
88
+ "@cloudbase/weda-client": "^1.1.35",
89
89
  "@codemirror/autocomplete": "^6.16.0",
90
90
  "@codemirror/lang-javascript": "^6.2.2",
91
91
  "@codemirror/lang-json": "^6.0.1",
@@ -147,9 +147,9 @@
147
147
  "@babel/preset-env": "^7.22.15",
148
148
  "@babel/preset-react": "^7.22.15",
149
149
  "@babel/preset-typescript": "^7.22.15",
150
- "@cloudbase/cals": "^1.2.15",
151
- "@cloudbase/lowcode-cli": "^0.22.3",
152
- "@cloudbase/weda-cloud-sdk": "^1.0.106",
150
+ "@cloudbase/cals": "^1.2.17",
151
+ "@cloudbase/lowcode-cli": "^0.22.4",
152
+ "@cloudbase/weda-cloud-sdk": "^1.0.107",
153
153
  "@commitlint/cli": "^16.0.2",
154
154
  "@commitlint/config-conventional": "^17.7.0",
155
155
  "@craco/craco": "^7.1.0",