@cloudbase/weda-ui 3.17.7 → 3.18.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.
Files changed (36) hide show
  1. package/dist/configs/components/wd-select-multiple.d.ts +2 -0
  2. package/dist/configs/components/wd-select-multiple.js +4 -2
  3. package/dist/configs/components/wd-select.d.ts +2 -0
  4. package/dist/configs/components/wd-select.js +4 -2
  5. package/dist/configs/components/wd-table.js +1 -1
  6. package/dist/configs/index.d.ts +4 -0
  7. package/dist/configs/type-utils/type-form.d.ts +2 -0
  8. package/dist/configs/type-utils/type-form.js +32 -4
  9. package/dist/style/index.css +7 -3
  10. package/dist/style/index.scss +1 -1
  11. package/dist/style/weda-ui.min.css +3 -3
  12. package/dist/web/components/wd-input/wd-input.js +2 -2
  13. package/dist/web/components/wd-select/hooks/useChooseList.js +16 -19
  14. package/dist/web/components/wd-select/relationSelect/index.js +2 -7
  15. package/dist/web/components/wd-select/relationSelect/relationSelect.js +6 -4
  16. package/dist/web/components/wd-select/select/index.js +9 -3
  17. package/dist/web/components/wd-select/select/selectUI.js +1 -1
  18. package/dist/web/components/wd-select/style.d.ts +0 -2
  19. package/dist/web/components/wd-select/style.js +2 -2
  20. package/dist/web/components/wd-select/wd-select.js +4 -7
  21. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +4 -4
  22. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -3
  23. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +51 -50
  24. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.d.ts +2 -1
  25. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +18 -8
  26. package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.d.ts +5 -3
  27. package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.js +20 -41
  28. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +7 -0
  29. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +44 -14
  30. package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +13 -8
  31. package/dist/web/components/wd-table/utils/index.d.ts +18 -0
  32. package/dist/web/components/wd-table/utils/index.js +64 -56
  33. package/dist/web/components/wd-table/wd-table.js +4 -2
  34. package/package.json +1 -1
  35. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +0 -16
  36. package/dist/web/components/wd-table/hooks/useChooseList.js +0 -126
@@ -111,11 +111,11 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
111
111
  }
112
112
  };
113
113
  const onFocus = (e) => {
114
- events.focus({ value: converValueFixWrap(e.target.value) }, { originEvent: e });
114
+ (events === null || events === void 0 ? void 0 : events.focus) && events.focus({ value: converValueFixWrap(e.target.value) }, { originEvent: e });
115
115
  setFocus(true);
116
116
  };
117
117
  const onBlur = (e) => {
118
- events.blur({ value: converValueFixWrap(e.target.value) }, { originEvent: e });
118
+ (events === null || events === void 0 ? void 0 : events.blur) && events.blur({ value: converValueFixWrap(e.target.value) }, { originEvent: e });
119
119
  setFocus(false);
120
120
  };
121
121
  const handleZhStart = () => {
@@ -25,8 +25,8 @@ export const mapResult = (records, primaryColumn) => {
25
25
  export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
26
26
  const [total, setTotal] = useState(0);
27
27
  const [loading, setLoading] = useState(true);
28
- const { options, setOptions } = useSelectContext();
29
- const unshiftVal = (transformedRecords, itemResult, originOption) => {
28
+ const { options = [], setOptions } = useSelectContext();
29
+ const unshiftVal = (transformedRecords, itemResult, originOption = []) => {
30
30
  if (itemResult &&
31
31
  transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
32
32
  originOption.findIndex((item) => item._id === itemResult._id) < 0) {
@@ -43,24 +43,19 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
43
43
  }),
44
44
  ];
45
45
  if (value && isInsertSelectedValue) {
46
- if (isMultiple) {
47
- value.forEach((i) => {
48
- if (i) {
49
- promiseList.push(dataSourceAPI.getRecord(i, {
50
- db: childDbName,
51
- }));
52
- }
53
- });
54
- }
55
- else {
56
- promiseList.push(dataSourceAPI.getRecord(value, {
57
- db: childDbName,
58
- }));
59
- }
46
+ const values = Array.isArray(value) ? value : [value];
47
+ const filter = {
48
+ where: {
49
+ $and: [{ $or: values.map((i) => ({ _id: { $eq: i } })) }],
50
+ },
51
+ };
52
+ promiseList.push(dataSourceAPI.getRecordListV2({ ...queryParams, filter, pageNumber: queryParams.pageNo, pageSize: 200 }, {
53
+ db: childDbName,
54
+ }));
60
55
  }
61
- const [result, ...rest] = await Promise.all(promiseList);
56
+ const [result, valueItem] = await Promise.all(promiseList);
62
57
  let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
63
- const itemResult = [...rest];
58
+ const itemResult = [...((valueItem === null || valueItem === void 0 ? void 0 : valueItem.records) || [])];
64
59
  // 若下拉列表中无选中值,则将选中值插到数组头部
65
60
  if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
66
61
  itemResult.forEach((i) => {
@@ -72,7 +67,9 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
72
67
  optionRes = [...options, ...optionRes];
73
68
  }
74
69
  optionRes = getUniqueOption(optionRes);
75
- setOptions(optionRes);
70
+ if (typeof setOptions === 'function') {
71
+ setOptions(optionRes);
72
+ }
76
73
  setTotal(result === null || result === void 0 ? void 0 : result.total);
77
74
  setLoading(false);
78
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1,17 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { LoadingTip } from 'tea-component';
4
4
  import { EnumSelect } from './enumSelect';
5
5
  import { RelationSelect } from './relationSelect';
6
- import { WdIcon } from '../../wd-icon';
7
6
  export function CustomSelect(props) {
8
- const { format, addRelationButtonText, enableAddRelationButton, events } = props;
7
+ const { format, addRelationButton } = props;
9
8
  const isEnumType = format === 'x-enum';
10
9
  const [refreshStatus, setRefreshStatus] = useState(false);
11
- const addRelationButton = enableAddRelationButton && (_jsxs("span", { className: "wd-add-relation-button-wrap", onClick: () => {
12
- var _a;
13
- (_a = events === null || events === void 0 ? void 0 : events.onAddRelationButtonClick) === null || _a === void 0 ? void 0 : _a.call(events);
14
- }, children: [_jsx(WdIcon, { size: 'xs', name: 'td:add-circle' }), addRelationButtonText] }));
15
10
  if (refreshStatus) {
16
11
  return _jsx(LoadingTip, {});
17
12
  }
@@ -52,7 +52,9 @@ const defaultSize = 50;
52
52
  const defaultPage = 1;
53
53
  export function RelationSelect(props) {
54
54
  var _a, _b;
55
- const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, ignoreCase = true, where, queryCondition, supportManyRelated, sorter, searchable, } = props;
55
+ const { placeholder, size, disabled, onChange, value, onSearch, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, ignoreCase = true, where, queryCondition, supportManyRelated, sorter, searchable, selectFieldLabel, } = props;
56
+ // 选项名称 (默认是主列字段,支持自定义指定)
57
+ const showLabel = selectFieldLabel || primaryField;
56
58
  const selectFieldsLength = selectFieldType === 'custom' ? selectFields === null || selectFields === void 0 ? void 0 : selectFields.length : 0;
57
59
  // 设置下拉列表与下拉按钮同宽
58
60
  // 以传入为准,未传入,在自定义展示字段少于2个时设置为 true,否则设置为false,宽度设置为700,
@@ -90,7 +92,7 @@ export function RelationSelect(props) {
90
92
  dataSourceAPI,
91
93
  childDbName: dataSourceName,
92
94
  queryParams: query,
93
- primaryColumn: primaryField,
95
+ primaryColumn: showLabel,
94
96
  value,
95
97
  });
96
98
  const [isLoading, setIsLoading] = useSyncValue(isValidating, isObjectEqual);
@@ -144,7 +146,7 @@ export function RelationSelect(props) {
144
146
  filter = {
145
147
  ...filter,
146
148
  where: {
147
- $and: [filter.where, { $and: [{ [primaryField]: { [`${search}`]: keyword } }] }],
149
+ $and: [filter.where, { $and: [{ [showLabel]: { [`${search}`]: keyword } }] }],
148
150
  },
149
151
  };
150
152
  }
@@ -161,5 +163,5 @@ export function RelationSelect(props) {
161
163
  }, onOpen: () => {
162
164
  setIsLoading(true);
163
165
  searchOptionListWithWhere();
164
- }, footer: addRelationButton, mode: mode }));
166
+ }, mode: mode }));
165
167
  }
@@ -1,9 +1,15 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ConfigProvider } from 'tea-component';
3
3
  import { CustomSelect } from '../relationSelect/index';
4
4
  import { SelectUI as Select } from './selectUI';
5
+ import { WdIcon } from '../../wd-icon';
5
6
  export function SelectCom(props) {
6
- const { isRelation, filterable = false } = props;
7
+ const { isRelation, filterable = false, enableAddRelationButton, events, addRelationButtonText } = props;
7
8
  const filter = filterable ? () => true : undefined;
8
- return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: isRelation ? _jsx(CustomSelect, { ...props }) : _jsx(Select, { ...props, filter: filter }) }));
9
+ const onClick = () => {
10
+ var _a;
11
+ (_a = events === null || events === void 0 ? void 0 : events.onAddRelationButtonClick) === null || _a === void 0 ? void 0 : _a.call(events);
12
+ };
13
+ const addRelationButton = enableAddRelationButton ? (_jsxs("span", { className: "wd-add-relation-button-wrap", onClick: onClick, children: [_jsx(WdIcon, { size: 'xs', name: 'td:add-circle' }), addRelationButtonText] })) : null;
14
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: isRelation ? (_jsx(CustomSelect, { ...props, footer: addRelationButton })) : (_jsx(Select, { ...props, filter: filter, footer: addRelationButton })) }));
9
15
  }
@@ -72,7 +72,7 @@ function SelectH5(props) {
72
72
  setInputFocus(true);
73
73
  }, children: [inputFocus ? (_jsx("input", { className: `${classPrefix}-input`, ref: focusRef, value: searchValue, autoFocus: true, onChange: handleSearch, onCompositionStart: handleZhStart, onCompositionEnd: handleZhEnd, placeholder: searchPlaceholder })) : (
74
74
  // 此处主要为了兼容 iOS
75
- _jsx("div", { className: `${classPrefix}-input` })), _jsxs("div", { className: `${classPrefix}-custom-search-box__label`, children: [_jsx("span", { className: `${classPrefix}-custom-search-box__search-icon` }), _jsx("span", { className: `${classPrefix}-custom-search-box__search-placeholder`, children: searchPlaceholder })] }), inputFocus && searchValue !== '' && (_jsx("span", { className: `${classPrefix}-custom-search-box__dismiss-icon`, onClick: () => {
75
+ _jsx("div", { className: `${classPrefix}-input` })), _jsxs("div", { className: `${classPrefix}-custom-search-box__label`, children: [_jsx("span", { className: `${classPrefix}-custom-search-box__search-icon` }), _jsx("span", { className: `${classPrefix}-custom-search-box__search-placeholder`, children: searchValue || searchPlaceholder })] }), inputFocus && searchValue !== '' && (_jsx("span", { className: `${classPrefix}-custom-search-box__dismiss-icon`, onClick: () => {
76
76
  getInitOptions();
77
77
  } }))] }), _jsx("button", { className: `${classPrefix}-custom-search__btn-cancle`, onClick: () => {
78
78
  setInputFocus(false);
@@ -1,4 +1,2 @@
1
- import '../form/select/dropdown-select/index.css';
2
- import '../form/select/allTimePicker/index.css';
3
1
  import '../style';
4
2
  import './wd-select.css';
@@ -1,4 +1,4 @@
1
- import '../form/select/dropdown-select/index.css';
2
- import '../form/select/allTimePicker/index.css';
1
+ // import '../form/select/dropdown-select/index.css';
2
+ // import '../form/select/allTimePicker/index.css';
3
3
  import '../style';
4
4
  import './wd-select.css';
@@ -20,7 +20,7 @@ import { SelectProvider } from './contexts/selectContext';
20
20
  */
21
21
  export const WdSelect = forwardRef(function WsSelect(props, ref) {
22
22
  const { classRoot = 'select', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, format, tipBlock = X_RUNTIME_DEFAULT.tipBlock, where = X_RUNTIME_DEFAULT.where, enumName, primaryField, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
23
- selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, } = props;
23
+ selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, selectFieldLabel, } = props;
24
24
  const childRef = useRef(null);
25
25
  const [options, setOptions] = useSyncValue(range, isObjectEqual);
26
26
  const [innerHandle, setInnerHandle] = useState({});
@@ -85,11 +85,8 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
85
85
  ...clearProps,
86
86
  };
87
87
  const selectFields = React.useMemo(() => {
88
- if (['father-son', 'related'].includes(format)) {
89
- return [];
90
- }
91
- return [primaryField];
92
- }, [format, primaryField]);
88
+ return [selectFieldLabel || primaryField];
89
+ }, [primaryField, selectFieldLabel]);
93
90
  useSetWidgetApi(() => ({
94
91
  ...innerHandle,
95
92
  selectedLabel,
@@ -117,5 +114,5 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
117
114
  }, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
118
115
  var _a;
119
116
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
120
- }, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, where: where, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: searchable, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
117
+ }, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, selectFieldLabel: selectFieldLabel, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, where: where, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: searchable, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
121
118
  });
@@ -21,7 +21,7 @@ import { SelectProvider } from '../wd-select/contexts/selectContext';
21
21
  */
22
22
  export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref) {
23
23
  const { classRoot = 'select-multiple', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, enumName, format, primaryField, tipBlock = X_RUNTIME_DEFAULT.tipBlock, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, where = X_RUNTIME_DEFAULT.where, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
24
- selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, } = props;
24
+ selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, selectFieldLabel, } = props;
25
25
  const childRef = useRef(null);
26
26
  const [options, setOptions] = useSyncValue(range, isObjectEqual);
27
27
  const [innerHandle, setInnerHandle] = useState({});
@@ -89,10 +89,10 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
89
89
  useSetWidgetApi(() => ({
90
90
  ...innerHandle,
91
91
  selectedLabel,
92
- selectFields: [primaryField],
92
+ selectFields: [selectFieldLabel || primaryField],
93
93
  item: selectedItem,
94
94
  value,
95
- }), [innerHandle, selectedLabel, primaryField, selectedItem, value], ref);
95
+ }), [innerHandle, selectedLabel, selectFieldLabel, primaryField, selectedItem, value], ref);
96
96
  const eventsRef = useSyncedRef(events);
97
97
  const debouncedTriggerSearchEvent = useDebouncedCallback((value) => {
98
98
  var _a, _b;
@@ -113,5 +113,5 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
113
113
  }, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
114
114
  var _a;
115
115
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
116
- }, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: searchable, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
116
+ }, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, selectFieldLabel: selectFieldLabel, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: searchable, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
117
117
  });
@@ -1,13 +1,13 @@
1
1
  import { SelectSearch } from './SelectSearch';
2
2
  export { SelectSearch };
3
- export declare const DatePickerField: ({ disabled, showTime, isRange, updateValue, value, }: {
3
+ export declare const DatePickerField: ({ disabled, showTime, isRange, updateValue, value }: {
4
4
  disabled?: boolean;
5
5
  showTime?: boolean;
6
6
  isRange: any;
7
7
  updateValue: any;
8
8
  value: any;
9
9
  }) => JSX.Element;
10
- export declare const TimePickerField: ({ disabled, isRange, updateValue, value, }: {
10
+ export declare const TimePickerField: ({ disabled, isRange, updateValue, value }: {
11
11
  disabled?: boolean;
12
12
  isRange: any;
13
13
  updateValue: any;
@@ -23,7 +23,7 @@ export declare const MultipleNumber: ({ disabled, value, updateValue }: {
23
23
  value: any;
24
24
  updateValue: any;
25
25
  }) => JSX.Element;
26
- export declare const NumberField: ({ disabled, value, updateValue, isRange, }: {
26
+ export declare const NumberField: ({ disabled, value, updateValue, isRange }: {
27
27
  disabled?: boolean;
28
28
  value: any;
29
29
  updateValue: any;
@@ -1,59 +1,61 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DatePicker, TimePicker, Input, Tooltip, Select, SelectMultiple, } from 'tea-component';
2
+ import { TimePicker, Tooltip } from 'tea-component';
3
3
  import moment from 'moment';
4
4
  import { useEnumContext } from '../../../../utils/hooks/context';
5
- const { RangePicker } = DatePicker;
6
5
  import { SelectSearch } from './SelectSearch';
6
+ import { WdDate, WdDateRange, WdTime, WdInput, WdSelectMultiple, WdSelect } from '../../../../components';
7
7
  export { SelectSearch };
8
8
  // 时间日期
9
- export const DatePickerField = ({ disabled = false, showTime = false, isRange, updateValue, value, }) => isRange ? (_jsx(Tooltip, { title: value && `${value[0]}~${value[1]}`, children: _jsx(RangePicker, { disabled: disabled, clearable: true, value: value ? [moment(value[0]), moment(value[1])] : null, showTime: showTime, onChange: (value) => {
10
- var _a, _b;
11
- updateValue({
12
- value: value[0]
13
- ? [
14
- (_a = value[0]) === null || _a === void 0 ? void 0 : _a.format('YYYY-MM-DD HH:mm:ss'),
15
- (_b = value[1]) === null || _b === void 0 ? void 0 : _b.format('YYYY-MM-DD HH:mm:ss'),
16
- ]
17
- : null,
18
- });
19
- } }) })) : (_jsx(Tooltip, { title: value, children: _jsx(DatePicker, { disabled: disabled, clearable: true, value: value ? moment(value) : null, showTime: showTime, onChange: (value) => updateValue({ value: value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD HH:mm:ss') }) }) }));
9
+ export const DatePickerField = ({ disabled = false, showTime = false, isRange, updateValue, value }) => isRange ? (_jsx(Tooltip, { title: value && `${value[0]}~${value[1]}`, children: _jsx(WdDateRange, { status: disabled ? 'disabled' : 'edit', value: value ? [moment(value[0]), moment(value[1])] : null, mode: showTime ? 'datetime' : 'date', "$widget": { closest: () => { } }, events: {
10
+ change: ({ value }) => {
11
+ updateValue({ value });
12
+ },
13
+ }, labelVisible: false, startPlaceholder: "\u5F00\u59CB\u65F6\u95F4", endPlaceholder: "\u7ED3\u675F\u65F6\u95F4", suffixIcon: "td:calendar", suffixType: "inner" }) })) : (_jsx(Tooltip, { title: value, children: _jsx(WdDate, { status: disabled ? 'disabled' : 'edit', clearable: true, value: value ? moment(value) : null, mode: showTime ? 'datetime' : 'date', events: {
14
+ change: ({ value }) => {
15
+ updateValue({ value });
16
+ },
17
+ }, labelVisible: false, "$widget": { closest: () => { } }, suffixIcon: "td:calendar", suffixType: "inner" }) }));
20
18
  // 时间
21
- export const TimePickerField = ({ disabled = false, isRange, updateValue, value, }) => isRange ? (_jsx(TimePicker.RangePicker, { disabled: disabled, clearable: true, value: value
22
- ? [moment(value[0], 'HH:mm:ss'), moment(value[1], 'HH:mm:ss')]
23
- : [null, null], onChange: (value) => {
19
+ export const TimePickerField = ({ disabled = false, isRange, updateValue, value }) => isRange ? (_jsx(TimePicker.RangePicker, { disabled: disabled, clearable: true, value: value ? [moment(value[0], 'HH:mm:ss'), moment(value[1], 'HH:mm:ss')] : [null, null], onChange: (value) => {
24
20
  var _a, _b;
25
21
  updateValue({
26
- value: value[0]
27
- ? [(_a = value[0]) === null || _a === void 0 ? void 0 : _a.format('HH:mm:ss'), (_b = value[1]) === null || _b === void 0 ? void 0 : _b.format('HH:mm:ss')]
28
- : null,
22
+ value: value[0] ? [(_a = value[0]) === null || _a === void 0 ? void 0 : _a.format('HH:mm:ss'), (_b = value[1]) === null || _b === void 0 ? void 0 : _b.format('HH:mm:ss')] : null,
29
23
  });
30
- } })) : (_jsx(TimePicker, { disabled: disabled, clearable: true, value: value ? moment(value, 'HH:mm:ss') : null, onChange: (value) => updateValue({ value: value === null || value === void 0 ? void 0 : value.format('HH:mm:ss') }) }));
24
+ } })) : (_jsx(WdTime, { status: disabled ? 'disabled' : 'edit', labelVisible: false, clearable: true, value: value ? moment(value, 'HH:mm:ss') : null, events: {
25
+ change: ({ value }) => {
26
+ updateValue({ value });
27
+ },
28
+ }, "$widget": { closest: () => { } }, suffixIcon: "pending", suffixType: "inner" }));
31
29
  // 文本输入框
32
- export const InputField = ({ disabled = false, value, updateValue }) => (_jsx(Input, { disabled: disabled, size: "full", value: value, onChange: (value) => {
33
- updateValue({ value });
34
- } }));
30
+ export const InputField = ({ disabled = false, value, updateValue }) => (_jsx(WdInput, { status: disabled ? 'disabled' : 'edit', size: "full", inputValue: value, "$widget": { closest: () => { } }, events: { change: updateValue }, labelVisible: false, placeholder: "\u8BF7\u8F93\u5165" }));
35
31
  // 数字范围输入
36
32
  export const MultipleNumber = ({ disabled = false, value, updateValue }) => {
37
33
  const val1 = value ? value[0] : '';
38
34
  const val2 = value ? value[1] : '';
39
- return (_jsxs("div", { className: "_wedamodal-fn-input-range", children: [_jsx(Input, { disabled: disabled, size: "s", placeholder: "\u8BF7\u8F93\u5165", value: val1, onChange: (value) => {
40
- if (isNaN(Number(value))) {
41
- return;
42
- }
43
- updateValue({ value: [value, val2] });
44
- } }), _jsx("span", { className: "_wedamodal-fn-input-range__split", children: "~" }), _jsx(Input, { disabled: disabled, value: val2, onChange: (value) => {
45
- if (isNaN(Number(value))) {
46
- return;
47
- }
48
- updateValue({ value: [val1, value] });
49
- }, size: "s", placeholder: "\u8BF7\u8F93\u5165" })] }));
35
+ return (_jsxs("div", { className: "_wedamodal-fn-input-range", children: [_jsx(WdInput, { status: disabled ? 'disabled' : 'edit', placeholder: "\u8BF7\u8F93\u5165", inputValue: val1, events: {
36
+ change: ({ value }) => {
37
+ if (isNaN(Number(value))) {
38
+ return;
39
+ }
40
+ updateValue({ value: [value, val2] });
41
+ },
42
+ }, labelVisible: false, "$widget": { closest: () => { } } }), _jsx("span", { className: "_wedamodal-fn-input-range__split", children: "~" }), _jsx(WdInput, { status: disabled ? 'disabled' : 'edit', inputValue: val2, events: {
43
+ change: ({ value }) => {
44
+ if (isNaN(Number(value))) {
45
+ return;
46
+ }
47
+ updateValue({ value: [val1, value] });
48
+ },
49
+ }, labelVisible: false, "$widget": { closest: () => { } }, placeholder: "\u8BF7\u8F93\u5165" })] }));
50
50
  };
51
51
  // 数字输入框
52
- export const NumberField = ({ disabled = false, value, updateValue, isRange, }) => isRange ? (_jsx(MultipleNumber, { disabled: disabled, value: value, updateValue: updateValue })) : (_jsx(Input, { disabled: disabled, size: "full", value: value, onChange: (value) => {
53
- if (isNaN(Number(value))) {
54
- return;
55
- }
56
- updateValue({ value });
52
+ export const NumberField = ({ disabled = false, value, updateValue, isRange }) => isRange ? (_jsx(MultipleNumber, { disabled: disabled, value: value, updateValue: updateValue })) : (_jsx(WdInput, { status: disabled ? 'disabled' : 'edit', size: "full", labelVisible: false, "$widget": { closest: () => { } }, inputValue: value, placeholder: "\u8BF7\u8F93\u5165", events: {
53
+ change: ({ value }) => {
54
+ if (isNaN(Number(value))) {
55
+ return;
56
+ }
57
+ updateValue({ value });
58
+ },
57
59
  } }));
58
60
  // 多选下拉框
59
61
  export const SelectMultipleField = (props) => {
@@ -63,20 +65,19 @@ export const SelectMultipleField = (props) => {
63
65
  if (!optionName && options) {
64
66
  option = options;
65
67
  }
66
- return (_jsx(SelectMultiple, { disabled: disabled, size: "full", searchable: true, staging: false, matchButtonWidth: true, value: value, appearance: "button", options: option, onChange: (value) => {
67
- updateValue({ value });
68
- } }));
68
+ return (_jsx(WdSelectMultiple, { status: disabled ? 'disabled' : 'edit', size: "full", searchable: true, value: value, range: option === null || option === void 0 ? void 0 : option.map((i) => ({ ...i, label: i.text })), "$widget": { closest: () => { } }, events: {
69
+ change: ({ value }) => {
70
+ updateValue({ value });
71
+ },
72
+ }, labelVisible: false, placeholder: "\u8BF7\u9009\u62E9" }));
69
73
  };
70
74
  // 下拉单选
71
75
  export const SelectField = ({ optionName, value, updateValue, disabled }) => {
72
76
  const { enumOptions } = useEnumContext();
73
77
  const option = (enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions[optionName]) || [];
74
- return (_jsx(Select, { disabled: disabled, size: "full", clearable: true, searchable: true,
75
- // @ts-ignore 不存在的属性
76
- staging: false, matchButtonWidth: true, value: value, appearance: "button", options: option, onChange: (value) => {
77
- updateValue({ value });
78
- }, button: () => {
79
- var _a, _b;
80
- return value ? (_jsx(Tooltip, { title: (_a = option === null || option === void 0 ? void 0 : option.find((i) => i.value === value)) === null || _a === void 0 ? void 0 : _a.text, children: _jsx("span", { children: ((_b = option === null || option === void 0 ? void 0 : option.find((i) => i.value === value)) === null || _b === void 0 ? void 0 : _b.text) || value }) })) : (_jsx("span", { className: "wedatea2td-text-weak", children: "\u8BF7\u9009\u62E9" }));
81
- } }));
78
+ return (_jsx(WdSelect, { status: disabled ? 'disabled' : 'edit', size: "full", clearable: true, searchable: true, value: value, range: option === null || option === void 0 ? void 0 : option.map((i) => ({ ...i, label: i.text })), "$widget": { closest: () => { } }, events: {
79
+ change: ({ value }) => {
80
+ updateValue({ value });
81
+ },
82
+ }, labelVisible: false, placeholder: "\u8BF7\u9009\u62E9" }));
82
83
  };
@@ -1,4 +1,5 @@
1
- export declare const FilterFieldItem: ({ updateFilterData, ...filterFieldItemConfig }: {
1
+ export declare const FilterFieldItem: ({ supportManyRelated, updateFilterData, ...filterFieldItemConfig }: {
2
2
  [x: string]: any;
3
+ supportManyRelated: any;
3
4
  updateFilterData: any;
4
5
  }) => JSX.Element;
@@ -5,8 +5,9 @@ import { DatePickerField, TimePickerField, InputField, NumberField, SelectMultip
5
5
  import { InputAdornment } from './InputAdornment';
6
6
  import { usePlatform } from '../../../../utils/platform';
7
7
  import { useConfig } from '../../../../utils/config-context';
8
+ import { NEW_RELATION_FORMATS } from './filterFieldsGenerate';
8
9
  // 计算方式下拉选框
9
- const CalculationSelect = ({ arg, cb, isDate = false, fieldCalculationOption, }) => {
10
+ const CalculationSelect = ({ arg, cb, isDate = false, fieldCalculationOption }) => {
10
11
  const { classPrefix } = useConfig();
11
12
  const isH5 = usePlatform() === 'h5'; // 响应式判定
12
13
  const [value, setValue] = useState(arg.value);
@@ -26,9 +27,7 @@ const CalculationSelect = ({ arg, cb, isDate = false, fieldCalculationOption, })
26
27
  useEffect(() => {
27
28
  setValue(arg.value);
28
29
  }, [arg]);
29
- const options = isDate
30
- ? fieldCalculationOption.filter((i) => i.value !== 'neq')
31
- : fieldCalculationOption;
30
+ const options = isDate ? fieldCalculationOption.filter((i) => i.value !== 'neq') : fieldCalculationOption;
32
31
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
33
32
  const visible = (fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.length) === 1;
34
33
  return isH5 ? (_jsx("div", { className: `${classPrefix}-space ${visible ? 'hidden' : ''}`, children: options.map((i) => (_jsx("div", { className: `${classPrefix}-space-item`, children: _jsx("div", { className: `${classPrefix}-table-wrap-filter__tag ${i.value === value ? 'is-selected ' : ''}`, onClick: () => {
@@ -36,9 +35,9 @@ const CalculationSelect = ({ arg, cb, isDate = false, fieldCalculationOption, })
36
35
  }, children: i.text }) }, i.value))) })) : (_jsx(Select, { className: `${visible ? 'hidden' : ''}`, size: "auto", options: options, value: value, onChange: (value) => calculation(value) }));
37
36
  };
38
37
  // 筛选项
39
- export const FilterFieldItem = ({ updateFilterData, ...filterFieldItemConfig }) => {
38
+ export const FilterFieldItem = ({ supportManyRelated, updateFilterData, ...filterFieldItemConfig }) => {
40
39
  const [disabled, setDisabled] = useState(false);
41
- const { filterType, isRange, label, options, fieldCalculation, value, fieldCalculationOption, } = filterFieldItemConfig;
40
+ const { filterType, isRange, label, options, fieldCalculation, value, fieldCalculationOption } = filterFieldItemConfig;
42
41
  const updateFilterConfig = (value) => {
43
42
  const lastFilterConfig = { ...filterFieldItemConfig, ...value };
44
43
  // 选择为空不为空,则清空数据
@@ -55,6 +54,9 @@ export const FilterFieldItem = ({ updateFilterData, ...filterFieldItemConfig })
55
54
  setDisabled(false);
56
55
  }
57
56
  }, [fieldCalculation.value]);
57
+ if (!supportManyRelated && NEW_RELATION_FORMATS.includes(filterType)) {
58
+ return (_jsx(InputAdornment, { label: label, before: null, children: _jsx(Input, { size: "full", disabled: true, defaultValue: '该类型暂不支持表格筛选器' }) }));
59
+ }
58
60
  const renderFieldItem = () => {
59
61
  switch (filterType) {
60
62
  case 'datetime':
@@ -82,9 +84,17 @@ export const FilterFieldItem = ({ updateFilterData, ...filterFieldItemConfig })
82
84
  return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectField, { optionName: filterFieldItemConfig.xOptionName, updateValue: updateFilterConfig, value: value, disabled: disabled }) }));
83
85
  case 'father-son':
84
86
  case 'related':
85
- return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { fields: filterFieldItemConfig.fields, format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, dbName: filterFieldItemConfig.dbName, disabled: disabled }) }));
87
+ case 'many-one':
88
+ case 'one-one':
89
+ case 'one-one-r':
90
+ return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { multiple: false, format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, disabled: disabled, primaryColumn: filterFieldItemConfig.primaryColumn, name: filterFieldItemConfig.name }) }));
91
+ case 'many-many':
92
+ case 'one-many':
93
+ return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, disabled: disabled, primaryColumn: filterFieldItemConfig.primaryColumn, name: filterFieldItemConfig.name, multiple: true }) }));
94
+ case 'x-area-code':
95
+ return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, disabled: disabled, primaryColumn: filterFieldItemConfig.primaryColumn, name: filterFieldItemConfig.name, regionType: filterFieldItemConfig.regionType }) }));
86
96
  default:
87
- return (_jsx(Input, { size: "full", disabled: true, defaultValue: '该类型暂不支持表单筛选器' }));
97
+ return (_jsx(InputAdornment, { label: label, before: null, children: _jsx(Input, { size: "full", disabled: true, defaultValue: '该类型暂不支持表格筛选器' }) }));
88
98
  }
89
99
  };
90
100
  return renderFieldItem();
@@ -1,9 +1,11 @@
1
- export declare const SelectSearch: ({ value, updateValue, format, childDbName, dbName, fields, disabled, }: {
1
+ export declare const SelectSearch: ({ value, updateValue, format, childDbName, disabled, name, primaryColumn, multiple, regionType, }: {
2
2
  value: any;
3
3
  updateValue: any;
4
4
  format: any;
5
5
  childDbName: any;
6
- dbName: any;
7
- fields: any;
8
6
  disabled?: boolean;
7
+ name: any;
8
+ primaryColumn: any;
9
+ multiple?: boolean;
10
+ regionType?: string;
9
11
  }) => JSX.Element;
@@ -1,45 +1,24 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState, useMemo } from 'react';
3
- import { Select, LoadingTip } from 'tea-component';
4
- import { useChooseList, getDataBaseInfo } from '../../hooks/useChooseList';
5
- import { DataSource } from '../../../../utils/datasource';
2
+ import { WdSelect } from '../../../wd-select';
3
+ import { WdSelectMultiple } from '../../../wd-select-multiple';
4
+ import { WdRegion } from '../../../wd-region';
5
+ const regionTypeMap = { 0: 'levelOne', 1: 'levelTwo', 2: 'levelThree' };
6
6
  // 搜索下拉
7
- export const SelectSearch = ({ value, updateValue, format, childDbName, dbName, fields, disabled = false, }) => {
8
- // 每次请求数据个数
9
- const defaultSize = 50;
10
- const defaultPage = 1;
11
- const dataSourceAPI = useMemo(() => new DataSource(dbName), [dbName]); // datasource 方法-模型
12
- const dataBase = useMemo(() => getDataBaseInfo(fields, format, childDbName), [childDbName, fields, format]);
13
- const primaryColumn = dataBase === null || dataBase === void 0 ? void 0 : dataBase.primaryColumn;
14
- const [query, setQuery] = useState({
15
- pageNo: defaultPage,
16
- pageSize: defaultSize,
17
- where: [],
18
- });
19
- const { result, total, isValidating, empty } = useChooseList({
20
- dataSourceAPI,
21
- childDbName,
22
- queryParams: query,
23
- primaryColumn: primaryColumn,
24
- value,
25
- });
26
- return (_jsx(Select, { disabled: disabled, size: "full", clearable: true, searchable: true, matchButtonWidth: true, appearance: "button", autoClearSearchValue: true, options: result, value: value, bottomTips: isValidating ? _jsx(LoadingTip, {}) : '', onChange: (value) => {
27
- updateValue({ value });
28
- }, onOpen: () => {
29
- empty();
30
- setQuery({ ...query, pageNo: defaultPage, where: [] });
31
- }, onScrollBottom: () => {
32
- if (!isValidating && result.length < total) {
33
- setQuery((query) => ({
34
- ...query,
35
- pageNo: query.pageNo + defaultPage,
36
- }));
37
- }
38
- }, onSearchValueChange: (value) => {
39
- const where = (value === null || value === void 0 ? void 0 : value.length)
40
- ? [{ key: primaryColumn, val: `${value}`, rel: 'search' }]
41
- : [];
42
- empty();
43
- setQuery({ ...query, pageNo: defaultPage, where });
7
+ export const SelectSearch = ({ value, updateValue, format, childDbName, disabled = false, name, primaryColumn, multiple = false, regionType = regionTypeMap[0], }) => {
8
+ if (format === 'x-area-code') {
9
+ return (_jsx(WdRegion, { placeholder: "\u8BF7\u9009\u62E9", status: disabled ? 'disabled' : 'edit', value: value, regionType: regionTypeMap[regionType] || regionTypeMap[0], labelVisible: false, name: name, "$widget": { closest: () => { } }, events: {
10
+ change: ({ value }) => {
11
+ updateValue({ value });
12
+ },
13
+ } }));
14
+ }
15
+ return multiple ? (_jsx(WdSelectMultiple, { placeholder: "\u8BF7\u9009\u62E9", status: disabled ? 'disabled' : 'edit', value: value, format: format, labelVisible: false, dataSourceName: childDbName, name: name, primaryField: primaryColumn, "$widget": { closest: () => { } }, events: {
16
+ change: ({ value }) => {
17
+ updateValue({ value });
18
+ },
19
+ } })) : (_jsx(WdSelect, { placeholder: "\u8BF7\u9009\u62E9", status: disabled ? 'disabled' : 'edit', value: value, format: format, labelVisible: false, dataSourceName: childDbName, name: name, primaryField: primaryColumn, "$widget": { closest: () => { } }, events: {
20
+ change: ({ value }) => {
21
+ updateValue({ value });
22
+ },
44
23
  } }));
45
24
  };
@@ -1,3 +1,4 @@
1
+ export declare const NEW_RELATION_FORMATS: string[];
1
2
  export declare const fieldCalculations: {
2
3
  number: {
3
4
  text: string;
@@ -22,5 +23,11 @@ export declare const fieldCalculations: {
22
23
  * 2、生成配置
23
24
  * 3、枚举/数字需要特殊处理(即format,用于处理查询数据转换)
24
25
  * { filterType: 'datetime' | 'date' | 'time' | 'string' |'number' | 'x-enumObj' , isRange: boolean }
26
+ *
27
+ *
28
+ * field?.type === 'array' && field?.format === '' 非关联关系 数组类型 不支持搜索
29
+ * field?.type === 'object' && field?.format === '' 非关联关系 对象类型 不支持搜索
30
+ * field?.name === '_departmentList' && field?.format === '' 所属部门 系统字段 不支持搜索
31
+ * ['x-markdown', 'x-location', 'x-music', 'x-json', 'x-video', 'x-file', 'x-image', 'x-rtf', 'function'] 不支持搜索
25
32
  */
26
33
  export declare const filterFieldsGenerate: (fields: any) => any;