@cloudbase/weda-ui 3.10.3 → 3.11.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 (101) hide show
  1. package/dist/configs/components/button.js +1 -1
  2. package/dist/configs/components/chart/bar.d.ts +146 -0
  3. package/dist/configs/components/chart/bar.js +1147 -0
  4. package/dist/configs/components/dataView.js +0 -16
  5. package/dist/configs/components/image.js +1 -1
  6. package/dist/configs/components/listView.js +0 -16
  7. package/dist/configs/components/lottery.js +1 -1
  8. package/dist/configs/components/navigationBar.json +1 -1
  9. package/dist/configs/components/wd-audio.js +1 -1
  10. package/dist/configs/components/wd-button.js +2 -2
  11. package/dist/configs/components/wd-icon.js +1 -1
  12. package/dist/configs/components/wd-image.js +1 -1
  13. package/dist/configs/components/wd-input-email.d.ts +2 -2
  14. package/dist/configs/components/wd-input-phone.d.ts +2 -2
  15. package/dist/configs/components/wd-input-url.d.ts +2 -2
  16. package/dist/configs/components/wd-link.js +1 -1
  17. package/dist/configs/components/wd-progress.d.ts +10 -0
  18. package/dist/configs/components/wd-progress.js +39 -2
  19. package/dist/configs/components/wd-rating.js +2 -2
  20. package/dist/configs/components/wd-select-multiple.d.ts +23 -0
  21. package/dist/configs/components/wd-select-multiple.js +26 -1
  22. package/dist/configs/components/wd-select.d.ts +23 -0
  23. package/dist/configs/components/wd-select.js +25 -0
  24. package/dist/configs/components/wd-side-tab.js +2 -2
  25. package/dist/configs/components/wd-table.d.ts +1 -1
  26. package/dist/configs/components/wd-table.js +1 -0
  27. package/dist/configs/components/wd-top-tab.d.ts +4 -0
  28. package/dist/configs/components/wd-top-tab.js +7 -2
  29. package/dist/configs/components/wd-upload-image.js +1 -1
  30. package/dist/configs/components/wedaVideo.js +3 -3
  31. package/dist/configs/components/wxOpenApi/share.js +1 -1
  32. package/dist/configs/index.d.ts +765 -2065
  33. package/dist/configs/index.js +1 -1
  34. package/dist/configs/type-utils/type-form.d.ts +6 -0
  35. package/dist/configs/type-utils/type-form.js +64 -22
  36. package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
  37. package/dist/configs/type-utils/x-runtime-default.js +1 -0
  38. package/dist/enum/index.js +5 -1
  39. package/dist/style/index.css +16 -4
  40. package/dist/style/index.scss +1 -1
  41. package/dist/style/weda-ui.min.css +2 -2
  42. package/dist/web/components/form/location/common/propsConfig.d.ts +1 -1
  43. package/dist/web/components/form/select/index.css +2 -2
  44. package/dist/web/components/form/select/request.d.ts +3 -3
  45. package/dist/web/components/form/select/request.js +1 -0
  46. package/dist/web/components/form/select/status/index.d.ts +3 -1
  47. package/dist/web/components/form/select/status/index.js +3 -1
  48. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +5 -5
  49. package/dist/web/components/form/uploader/uploader.h5.js +13 -4
  50. package/dist/web/components/form/uploader/util.d.ts +1 -0
  51. package/dist/web/components/form/uploader/util.js +28 -0
  52. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +14 -6
  53. package/dist/web/components/form-date/index.d.ts +1 -1
  54. package/dist/web/components/form-email/index.d.ts +1 -1
  55. package/dist/web/components/form-input/index.d.ts +1 -1
  56. package/dist/web/components/form-input-hooks/index.js +10 -1
  57. package/dist/web/components/form-input-hooks/validator.d.ts +1 -0
  58. package/dist/web/components/form-input-hooks/validator.js +6 -2
  59. package/dist/web/components/form-phone/index.d.ts +1 -1
  60. package/dist/web/components/form-time/index.d.ts +1 -1
  61. package/dist/web/components/form-url/index.d.ts +1 -1
  62. package/dist/web/components/grid/col.d.ts +2 -2
  63. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  64. package/dist/web/components/wd-date/elements/Modal.h5.js +3 -3
  65. package/dist/web/components/wd-form/index.js +1 -1
  66. package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
  67. package/dist/web/components/wd-input/wd-input.d.ts +1 -1
  68. package/dist/web/components/wd-input-email/wd-input-email.d.ts +1 -1
  69. package/dist/web/components/wd-input-phone/wd-input-phone.d.ts +1 -1
  70. package/dist/web/components/wd-input-url/wd-input-url.d.ts +1 -1
  71. package/dist/web/components/wd-progress/wd-progress.js +5 -3
  72. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +4 -0
  73. package/dist/web/components/wd-select/relationSelect/relationSelect.js +202 -0
  74. package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js} +4 -4
  75. package/dist/web/components/wd-select/select/index.d.ts +2 -0
  76. package/dist/web/components/wd-select/select/index.js +8 -0
  77. package/dist/web/components/wd-select/select/selectUI.d.ts +3 -0
  78. package/dist/web/components/wd-select/select/selectUI.js +190 -0
  79. package/dist/web/components/wd-select/style.d.ts +2 -0
  80. package/dist/web/components/wd-select/style.js +2 -0
  81. package/dist/web/components/wd-select/wd-select.css +83 -0
  82. package/dist/web/components/wd-select/wd-select.d.ts +0 -1
  83. package/dist/web/components/wd-select/wd-select.js +18 -8
  84. package/dist/web/components/wd-select-multiple/style.d.ts +2 -0
  85. package/dist/web/components/wd-select-multiple/style.js +2 -0
  86. package/dist/web/components/wd-select-multiple/wd-select-multiple.css +30 -4
  87. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +18 -7
  88. package/dist/web/components/wd-table/components/FieldRender/index.d.ts +7 -4
  89. package/dist/web/components/wd-table/components/FieldRender/index.js +42 -15
  90. package/dist/web/components/wd-table/components/ModalTable/index.js +4 -3
  91. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +1 -0
  92. package/dist/web/components/wd-table/hooks/useChooseList.js +55 -26
  93. package/dist/web/components/wd-table/utils/index.js +1 -1
  94. package/dist/web/components/wd-table/wd-table.js +2 -2
  95. package/dist/web/utils/isObjectEqual.d.ts +1 -1
  96. package/dist/web/utils/moment.d.ts +1 -0
  97. package/dist/web/utils/platform.js +3 -3
  98. package/dist/web/utils/tool.js +2 -2
  99. package/package.json +18 -13
  100. package/dist/configs/components/chart/bar.json +0 -1144
  101. /package/dist/web/components/wd-select/{relationalSetting.d.ts → relationSelect/relationalSetting.d.ts} +0 -0
@@ -0,0 +1,202 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import { useState, useImperativeHandle, useMemo, useEffect, useCallback, } from 'react';
4
+ import { LoadingTip } from 'tea-component';
5
+ import { SelectUI as Select } from '../select/selectUI';
6
+ import { WdIcon } from '../../wd-icon';
7
+ import { getTableColumns } from '../../wd-table/components/FieldRender';
8
+ import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
9
+ import { usePlatform } from '../../../utils/platform';
10
+ import { DataSource } from '../../../utils/datasource';
11
+ import { EnumHoc } from '../../../utils/hooks/EnumHoc';
12
+ import { useSyncValue } from '../../../utils/hooks/useSyncValue';
13
+ import isObjectEqual from '../../../utils/isObjectEqual';
14
+ import { requestEnumOption } from '../../form/select/request';
15
+ import { convertWhere } from '../../../utils/getModelParams';
16
+ import { useChooseList } from '../../wd-table/hooks/useChooseList';
17
+ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, }) => {
18
+ const platform = usePlatform();
19
+ const columns = useMemo(() => {
20
+ return getTableColumns({
21
+ fields: authFields,
22
+ columnSets: selectFields.map((i) => {
23
+ var _a, _b;
24
+ return ({
25
+ header: (_a = authFields.find((j) => j.name === i)) === null || _a === void 0 ? void 0 : _a.title,
26
+ key: (_b = authFields.find((j) => j.name === i)) === null || _b === void 0 ? void 0 : _b.name,
27
+ });
28
+ }),
29
+ isH5: false,
30
+ supportManyRelated: true,
31
+ slots: null,
32
+ fixedEnd: null,
33
+ fixedFront: null,
34
+ showRelationWithTag: false,
35
+ });
36
+ }, [authFields, selectFields]);
37
+ return (_jsxs("div", { className: "wd-relation-select-option-wrap", onClick: (e) => {
38
+ if (platform === 'pc' && mode !== 'multiple') {
39
+ e.stopPropagation();
40
+ e.preventDefault();
41
+ onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value);
42
+ }
43
+ }, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", children: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
44
+ onRelationOptionJump({ item: option });
45
+ }, 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.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.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))) })] })] }));
46
+ };
47
+ // 每次请求数据个数
48
+ const defaultSize = 50;
49
+ const defaultPage = 1;
50
+ export function RelationSelect(props) {
51
+ const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, } = props;
52
+ const { authFields } = useAuthFields({
53
+ dbName: dataSourceName,
54
+ dbFieldNames: [],
55
+ isNewData: true,
56
+ isModel: true,
57
+ columnSetsKey: [],
58
+ connectorMethod: '',
59
+ isNoDataSourceBind: false,
60
+ isExpression: false,
61
+ isApis: false,
62
+ });
63
+ // 是否具备展示自定义字段的条件
64
+ const isRelationSelectOption = selectFieldType === 'custom' && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length) && (authFields === null || authFields === void 0 ? void 0 : authFields.length);
65
+ const dataSourceAPI = useMemo(() => new DataSource(dataSourceName), [dataSourceName]); // datasource 方法-模型
66
+ const whereList = convertWhere(props);
67
+ const [query, setQuery] = useSyncValue({
68
+ pageNo: defaultPage,
69
+ pageSize: defaultSize,
70
+ where: whereList,
71
+ }, isObjectEqual);
72
+ const { result: options, total, isValidating: isLoading, empty, getRelationOptions, } = useChooseList({
73
+ dataSourceAPI,
74
+ childDbName: dataSourceName,
75
+ queryParams: query,
76
+ primaryColumn: primaryField,
77
+ value,
78
+ });
79
+ // 下拉选项数据
80
+ const customOptions = useMemo(() => {
81
+ return isRelationSelectOption
82
+ ? options === null || options === void 0 ? void 0 : options.map((i) => ({
83
+ ...i,
84
+ text: (_jsx(OptionText, { mode: mode, option: i, selectFields: selectFields, authFields: authFields, onChange: onChange, onRelationOptionJump: onRelationOptionJump, enableRelationOptionJump: enableRelationOptionJump })),
85
+ }))
86
+ : options;
87
+ }, [
88
+ authFields,
89
+ enableRelationOptionJump,
90
+ isRelationSelectOption,
91
+ mode,
92
+ onChange,
93
+ onRelationOptionJump,
94
+ options,
95
+ selectFields,
96
+ ]);
97
+ const searchOptionListWithWhere = useCallback((where = whereList) => {
98
+ empty();
99
+ setQuery({ ...query, pageNo: defaultPage, where });
100
+ }, [empty, query, setQuery, whereList]);
101
+ useImperativeHandle(childRef, () => {
102
+ return {
103
+ refresh: async () => {
104
+ setRefreshStatus(true);
105
+ if (query.pageNo === defaultPage) {
106
+ await getRelationOptions();
107
+ }
108
+ else {
109
+ searchOptionListWithWhere();
110
+ }
111
+ // eslint-disable-next-line rulesdir/no-timer
112
+ const timer = setTimeout(() => {
113
+ setRefreshStatus(false);
114
+ clearTimeout(timer);
115
+ }, 500);
116
+ },
117
+ };
118
+ }, [
119
+ getRelationOptions,
120
+ query.pageNo,
121
+ searchOptionListWithWhere,
122
+ setRefreshStatus,
123
+ ]);
124
+ const searchHandle = (keyword) => {
125
+ let where = whereList;
126
+ if (keyword === null || keyword === void 0 ? void 0 : keyword.length) {
127
+ // 筛选面板的查询条件与数据过滤的查询条件是且的关系
128
+ where = {
129
+ $and: [
130
+ ...whereList,
131
+ { $and: [{ [primaryField]: { $search: keyword } }] },
132
+ ],
133
+ };
134
+ }
135
+ searchOptionListWithWhere(where);
136
+ onSearch(keyword);
137
+ };
138
+ return (_jsx(EnumHoc, { fields: authFields, children: _jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, matchButtonWidth: true, placeholder: placeholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, tips: isLoading ? '' : undefined, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
139
+ if (!isLoading && customOptions.length < total) {
140
+ setQuery((query) => ({
141
+ ...query,
142
+ pageNo: query.pageNo + defaultPage,
143
+ }));
144
+ }
145
+ }, onOpen: () => {
146
+ searchOptionListWithWhere();
147
+ }, footer: addRelationButton, mode: mode }) }));
148
+ }
149
+ export function EnumSelect(props) {
150
+ const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
151
+ const [enumOption, setEnumOption] = useState([]);
152
+ const [isLoading, setLoading] = useState(false);
153
+ // 获取枚举字段类型的下拉选项
154
+ const getEnumOption = useCallback(async () => {
155
+ const params = {
156
+ format,
157
+ dataSourceName,
158
+ viewId,
159
+ where,
160
+ primaryField,
161
+ enumName,
162
+ };
163
+ setLoading(true);
164
+ const options = await requestEnumOption(params);
165
+ setEnumOption(options);
166
+ setLoading(false);
167
+ }, [dataSourceName, enumName, format, primaryField, viewId, where]);
168
+ useEffect(() => {
169
+ getEnumOption();
170
+ }, [getEnumOption]);
171
+ useImperativeHandle(childRef, () => {
172
+ return {
173
+ refresh: async () => {
174
+ setRefreshStatus(true);
175
+ await getEnumOption();
176
+ // eslint-disable-next-line rulesdir/no-timer
177
+ const timer = setTimeout(() => {
178
+ setRefreshStatus(false);
179
+ clearTimeout(timer);
180
+ }, 500);
181
+ },
182
+ };
183
+ }, [getEnumOption, setRefreshStatus]);
184
+ const searchHandle = (keyword) => {
185
+ onSearch(keyword);
186
+ };
187
+ return (_jsx(Select, { ...props, mode: mode, searchable: true, matchButtonWidth: true, placeholder: placeholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: enumOption, value: value, onChange: onChange, onSearch: searchHandle, footer: addRelationButton, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined }));
188
+ }
189
+ export function CustomSelect(props) {
190
+ const { format, addRelationButtonText, enableAddRelationButton, events } = props;
191
+ const isEnumType = format === 'x-enum';
192
+ const [refreshStatus, setRefreshStatus] = useState(false);
193
+ const listWidth = 700;
194
+ const addRelationButton = enableAddRelationButton && (_jsxs("span", { className: "wd-add-relation-button-wrap", onClick: () => {
195
+ var _a;
196
+ (_a = events === null || events === void 0 ? void 0 : events.onAddRelationButtonClick) === null || _a === void 0 ? void 0 : _a.call(events);
197
+ }, children: [_jsx(WdIcon, { size: 'xs', name: 'td:add-circle' }), addRelationButtonText] }));
198
+ if (refreshStatus) {
199
+ return _jsx(LoadingTip, {});
200
+ }
201
+ return isEnumType ? (_jsx(EnumSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus, listWidth: listWidth })) : (_jsx(RelationSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus, listWidth: listWidth, searchPlaceholder: '搜索主列' }));
202
+ }
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import WdIcon from '../wd-icon';
3
- import { useConfig } from '../../utils/config-context';
4
- import { useSize } from '../../utils/hooks/useFormLegacy';
5
- import classNames from '../../utils/classnames';
2
+ import WdIcon from '../../wd-icon';
3
+ import { useConfig } from '../../../utils/config-context';
4
+ import { useSize } from '../../../utils/hooks/useFormLegacy';
5
+ import classNames from '../../../utils/classnames';
6
6
  export const RelationalSetting = ({ refresh, setting, size: _size, enableRelationalSetting, enableRelationalRefresh, }) => {
7
7
  const { classPrefix } = useConfig();
8
8
  const size = useSize({ size: _size });
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function SelectCom(props: any): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConfigProvider } from 'tea-component';
3
+ import { CustomSelect } from '../relationSelect/relationSelect';
4
+ import { SelectUI as Select } from './selectUI';
5
+ export function SelectCom(props) {
6
+ const { isRelation } = props;
7
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: isRelation ? _jsx(CustomSelect, { ...props }) : _jsx(Select, { ...props }) }));
8
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import '../style';
3
+ export declare function SelectUI(props: any): JSX.Element;
@@ -0,0 +1,190 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useRef, useMemo, useEffect } from 'react';
3
+ import { Select, SelectMultiple, List } from 'tea-component';
4
+ import { WdFormItemReadOnly } from '../../wd-form-item';
5
+ import { Modal } from '../../wd-date/elements/Modal.h5';
6
+ import classNames from '../../../utils/classnames';
7
+ import { useConfig } from '../../../utils/config-context';
8
+ import { usePlatform } from '../../../utils/platform';
9
+ import { useSyncValue } from '../../../utils/hooks/useSyncValue';
10
+ import isObjectEqual from '../../../utils/isObjectEqual';
11
+ import AllEmpty from '../../form/select/status/allEmpty';
12
+ import '../style';
13
+ const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomTips, onScrollBottom, }) => {
14
+ return (_jsxs(List, { className: "weda-ui-custom-picker__cloumn", style: {
15
+ height: inputFocus ? 'calc(100vh - 190px)' : '250px',
16
+ }, onScrollBottom: onScrollBottom, children: [options === null || options === void 0 ? void 0 : options.map((item, index) => {
17
+ // is-selected 选中态
18
+ // is-disabled 禁用态,该状态备用,暂时不让生效index === -1
19
+ const itemCls = classNames('weda-ui-custom-picker__cloumn-item', {
20
+ 'is-selected': currentSelected.find((i) => i.value === item.value),
21
+ 'is-disabled': item.disabled,
22
+ });
23
+ return (_jsx(List.Item, { className: itemCls, onClick: () => optionClick(item), children: _jsx("p", { className: 'weda-ui-custom-picker__cloumn-item-text', children: item.text || item.label }) }, index));
24
+ }), bottomTips && (_jsx(List.Item, { children: _jsx("div", { className: "weda-ui-custom-picker__status weda-ui-custom-picker__status--empty", children: bottomTips }) }))] }));
25
+ };
26
+ const getSelectedItem = (options = [], value) => {
27
+ if (!value) {
28
+ return [];
29
+ }
30
+ const selectedVal = Array.isArray(value) ? value : [value];
31
+ return options === null || options === void 0 ? void 0 : options.filter((i) => selectedVal.find((j) => j === i.value));
32
+ };
33
+ function SelectH5(props) {
34
+ const { placeholder, name, disabled, footer, options, value, onChange, overlayClassName, searchable, bottomTips, onSearch, onOpen, onScrollBottom, mode, readValue, popupContainer, searchPlaceholder, } = props;
35
+ const isMultiple = mode === 'multiple';
36
+ const customPickerCls = classNames('weda-ui-custom-picker__cloumns', {
37
+ 'weda-ui-custom-picker__cloumns--select-multiple': isMultiple,
38
+ 'weda-ui-custom-picker__cloumns--select': !isMultiple,
39
+ [`${overlayClassName}`]: true,
40
+ });
41
+ const [visible, setVisible] = useState(false);
42
+ const { classPrefix } = useConfig();
43
+ const inputCls = `${classPrefix}-form-select_input`;
44
+ const focusRef = useRef();
45
+ // 聚焦在搜索框
46
+ const [inputFocus, setInputFocus] = useState(false);
47
+ const [searchValue, setSearchValue] = useState('');
48
+ const [isSearch, setIsSearch] = useState(false);
49
+ const [currentSelected, setCurrentSelected] = useSyncValue(getSelectedItem(options, value), isObjectEqual);
50
+ const getOptionList = () => {
51
+ return options.filter((i) => String(i === null || i === void 0 ? void 0 : i.label).toLowerCase().includes(searchValue.toLowerCase()));
52
+ };
53
+ // 前端查询
54
+ const customOptions = isSearch ? getOptionList() : options;
55
+ const handleZhStart = () => {
56
+ // 判断是否输入中文,则停止搜索
57
+ setIsSearch(false);
58
+ };
59
+ const handleZhEnd = (e) => {
60
+ setIsSearch(true);
61
+ handleSearch(e);
62
+ };
63
+ const handleSearch = (e) => {
64
+ const tValue = e.target.value.trim();
65
+ setSearchValue(tValue);
66
+ if (isSearch) {
67
+ onSearch(tValue);
68
+ }
69
+ };
70
+ // 搜索框
71
+ const renderSearch = () => {
72
+ return (_jsxs("div", { style: { margin: inputFocus ? '16px 16px 8px 16px' : '8px 16px' }, className: `${classPrefix}-custom-search
73
+ ${inputFocus ? 'is-focused' : ''}`, children: [_jsxs("div", { className: `${classPrefix}-custom-search-box `, "data-testid": `${classPrefix}-custom-search-box`, onClick: () => {
74
+ setInputFocus(true);
75
+ }, children: [inputFocus ? (_jsx("input", { className: `${classPrefix}-input`, ref: focusRef, value: searchValue, autoFocus: true, onChange: handleSearch, onCompositionStart: handleZhStart, onCompositionEnd: handleZhEnd, placeholder: searchPlaceholder })) : (
76
+ // 此处主要为了兼容 iOS
77
+ _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: () => {
78
+ getInitOptions();
79
+ } }))] }), _jsx("button", { className: `${classPrefix}-custom-search__btn-cancle`, onClick: () => {
80
+ setInputFocus(false);
81
+ getInitOptions();
82
+ }, children: "\u53D6\u6D88" })] }));
83
+ };
84
+ const getInitOptions = () => {
85
+ setSearchValue('');
86
+ setIsSearch(true);
87
+ setCurrentSelected([]);
88
+ if (onOpen) {
89
+ onOpen();
90
+ }
91
+ };
92
+ const handleClick = () => {
93
+ if (disabled)
94
+ return;
95
+ setVisible(true);
96
+ getInitOptions();
97
+ };
98
+ const handleOk = () => {
99
+ const selectedVal = currentSelected === null || currentSelected === void 0 ? void 0 : currentSelected.map((i) => i.value);
100
+ onChange(isMultiple ? selectedVal : selectedVal[0]);
101
+ setVisible(false);
102
+ };
103
+ // 处理当前选中值
104
+ const dealSelectedItem = (item) => {
105
+ const index = currentSelected.findIndex((v) => v.value === item.value);
106
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
107
+ if (index > -1) {
108
+ return [
109
+ ...currentSelected.slice(0, index),
110
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
111
+ ...currentSelected.slice(index + 1),
112
+ ];
113
+ }
114
+ return [...currentSelected, item];
115
+ };
116
+ const optionClick = (item) => {
117
+ if (item.disabled)
118
+ return;
119
+ setInputFocus(false);
120
+ if (!isMultiple) {
121
+ // 单选直接关弹窗
122
+ onChange(item.value);
123
+ setVisible(false);
124
+ setCurrentSelected([item]);
125
+ }
126
+ else {
127
+ setCurrentSelected(dealSelectedItem(item));
128
+ }
129
+ };
130
+ return (_jsxs(_Fragment, { children: [_jsx("input", { "data-testid": "form-item-select", className: inputCls, type: "text", name: name, placeholder: placeholder, autoComplete: "off", disabled: disabled, readOnly: true, value: readValue, onClick: handleClick }), _jsxs(Modal, { visible: visible, onClose: () => {
131
+ if (inputFocus) {
132
+ // 聚焦在搜索框
133
+ setInputFocus(false);
134
+ getInitOptions();
135
+ }
136
+ else {
137
+ setVisible(false);
138
+ }
139
+ }, onOk: handleOk, header: inputFocus, className: `${classPrefix}-cascader-modal`, okButtonVisible: isMultiple, popupContainer: popupContainer, children: [searchable && renderSearch(), _jsx("div", { className: `${classPrefix}-custom-view-content`, children: !bottomTips && !customOptions.length ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { children: [_jsx("div", { className: customPickerCls, "data-testid": "weda-ui-custom-picker__cloumns", style: {
140
+ height: inputFocus ? 'calc(100vh - 160px)' : '280px',
141
+ }, children: _jsx(OptionList, { onScrollBottom: onScrollBottom, options: customOptions, inputFocus: inputFocus, currentSelected: currentSelected, optionClick: optionClick, bottomTips: bottomTips }) }), footer] })) })] })] }));
142
+ }
143
+ export function SelectUI(props) {
144
+ const { placeholder, size, disabled, onChange, onSearch, searchable, options, value, footer, overlayClassName, onOpen, onScrollBottom, tips, bottomTips, mode, format, readOnly, setAllOption, listHeight, listWidth, popupContainer, searchPlaceholder = '搜索选项', } = props;
145
+ const platform = usePlatform();
146
+ const [currentOption] = useSyncValue(options.map(({ label, value }) => ({ label, value })), isObjectEqual);
147
+ // 更新option,从而更新最新的选项值
148
+ useEffect(() => {
149
+ if (setAllOption) {
150
+ setAllOption(currentOption);
151
+ }
152
+ }, [currentOption, setAllOption]);
153
+ const isMultiple = mode === 'multiple';
154
+ const readValue = useMemo(() => {
155
+ var _a, _b;
156
+ const selectedItem = getSelectedItem(options, value);
157
+ if (isMultiple) {
158
+ return selectedItem
159
+ .map((i) => (i === null || i === void 0 ? void 0 : i.label) || i.value)
160
+ .join(',');
161
+ }
162
+ else {
163
+ return ((_a = selectedItem[0]) === null || _a === void 0 ? void 0 : _a.label) || ((_b = selectedItem[0]) === null || _b === void 0 ? void 0 : _b.value) || '';
164
+ }
165
+ }, [isMultiple, options, value]);
166
+ const render = () => {
167
+ if (platform === 'h5') {
168
+ return (_jsx(SelectH5, { ...props, readValue: readValue, searchPlaceholder: searchPlaceholder }));
169
+ }
170
+ else if (mode === 'multiple') {
171
+ return (_jsx(SelectMultiple, { popupContainer: popupContainer, button: (selectedItem) => {
172
+ if (!(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.length)) {
173
+ return _jsx("div", { className: "wedatea2td-text-weak", children: placeholder });
174
+ }
175
+ return selectedItem
176
+ .map((i) => (i === null || i === void 0 ? void 0 : i.label) || i.value)
177
+ .join(',');
178
+ }, staging: false, overlayClassName: `${overlayClassName} multiple`, searchable: searchable, matchButtonWidth: true, placeholder: placeholder, searchPlaceholder: searchPlaceholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: options === null || options === void 0 ? void 0 : options.map((i) => ({ ...i, text: i.text || i.label })), value: Array.isArray(value) ? value : [], onChange: onChange, onSearch: onSearch, footer: footer, onOpen: onOpen, onScrollBottom: onScrollBottom, bottomTips: bottomTips, tips: tips, listHeight: listHeight, listWidth: listWidth }));
179
+ }
180
+ else {
181
+ return (_jsx(Select, { popupContainer: popupContainer, button: (selectedItem) => {
182
+ if (!selectedItem) {
183
+ return _jsx("div", { className: "wedatea2td-text-weak", children: placeholder });
184
+ }
185
+ return (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label) || (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value);
186
+ }, overlayClassName: overlayClassName, searchable: searchable, matchButtonWidth: true, placeholder: placeholder, searchPlaceholder: searchPlaceholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: options === null || options === void 0 ? void 0 : options.map((i) => ({ ...i, text: i.text || i.label })), value: value, onChange: onChange, onSearch: onSearch, footer: footer, onOpen: onOpen, onScrollBottom: onScrollBottom, bottomTips: bottomTips, tips: tips, listHeight: listHeight, listWidth: listWidth }));
187
+ }
188
+ };
189
+ return (_jsx(WdFormItemReadOnly, { after: props.after, before: props.before, onRelationTagClick: props.onRelationTagClick, readBeforeAfter: true, readOnly: readOnly, readValue: readValue, format: format, value: value, version: 'wd', children: _jsx("div", { "data-testid": isMultiple ? 'form-item-select-multiple-pc' : 'form-select', className: isMultiple ? 'form-select-multiple-pc' : 'form-select-pc', children: render() }) }));
190
+ }
@@ -1 +1,3 @@
1
+ import '../form/select/dropdown-select/index.css';
2
+ import '../style';
1
3
  import './wd-select.css';
@@ -1 +1,3 @@
1
+ import '../form/select/dropdown-select/index.css';
2
+ import '../style';
1
3
  import './wd-select.css';
@@ -93,6 +93,7 @@
93
93
  margin-right: 20px;
94
94
  color: var(--wd-color-brand, #0052d9);
95
95
  cursor: pointer;
96
+ white-space: pre-wrap;
96
97
  }
97
98
  .wd-add-relation-button-wrap .wd-icon {
98
99
  margin-right: 5px;
@@ -111,3 +112,85 @@
111
112
  width: 100%;
112
113
  padding-right: calc(var(--wd-size-icon-md));
113
114
  }
115
+
116
+ /* pc 端 关联下拉样式 */
117
+ .wd-relation-select-header {
118
+ display: flex;
119
+ align-items: center;
120
+ font-size: 16px;
121
+ margin: 5px 0;
122
+ }
123
+ .wd-relation-select-header span {
124
+ display: flex;
125
+ }
126
+ .wd-relation-select-header-text {
127
+ font-size: 16px;
128
+ }
129
+ .wd-relation-select-header .wd-icon {
130
+ color: var(--wd-color-brand, #0052d9);
131
+ }
132
+ .wd-relation-select-option-wrap .wd-tag-item {
133
+ max-width: 100%;
134
+ }
135
+
136
+ .wd-relation-select-option-wrap .wd-text-overflow {
137
+ /*将对象作为弹性伸缩盒子模型显示*/
138
+ display: -webkit-box;
139
+ overflow: hidden;
140
+ /*-webkit-line-clamp不是一个规范的属性,只有chrome浏览器支持,兼容性不好,适用于移动端,因为移动设备浏览器更多是基于webkit内核*/
141
+ -webkit-line-clamp: 1;
142
+ /*设置或检索伸缩盒对象的子元素的排列方式*/
143
+ -webkit-box-orient: vertical;
144
+ }
145
+ .wd-relation-select-option-wrap {
146
+ padding: 6px 8px;
147
+ }
148
+ .wd-relation-select-option-header,
149
+ .wd-relation-select-option-content {
150
+ display: flex;
151
+ color: var(--wd-color-text-secondary, rgba(0, 0, 0, 60%));
152
+ font-size: 14px;
153
+ }
154
+ .wd-relation-select-option-text {
155
+ margin-right: 5px;
156
+ }
157
+ .wd-relation-select-option-text .wd-text-overflow {
158
+ text-overflow: ellipsis;
159
+ display: block;
160
+ white-space: nowrap;
161
+ }
162
+ .wd-relation-select-overlay
163
+ .wedatea2td-dropdown-box
164
+ .wedatea2td-list--option
165
+ > li {
166
+ width: auto !important;
167
+ min-width: 100%;
168
+ padding: 0;
169
+ }
170
+ .wd-relation-select-overlay
171
+ .wedatea2td-dropdown-box
172
+ .wedatea2td-list--option
173
+ .wedatea2td-list__status {
174
+ padding: 6px 8px;
175
+ }
176
+ /* h5端关联下拉样式 */
177
+ .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select.wd-relation-select-overlay
178
+ .weda-ui-custom-picker__cloumn-item {
179
+ height: auto;
180
+ }
181
+ .wd-relation-select-overlay .weda-ui-custom-picker__cloumn-item-text {
182
+ margin: 0;
183
+ }
184
+ .weda-ui-custom-picker__cloumns.wd-relation-select-overlay {
185
+ overflow: auto;
186
+ }
187
+ .weda-ui-custom-picker__cloumns.wd-relation-select-overlay
188
+ .weda-ui-custom-picker__cloumn {
189
+ width: auto;
190
+ min-width: 100%;
191
+ }
192
+ .weda-ui-custom-picker__cloumns.wd-relation-select-overlay
193
+ .weda-ui-custom-picker__cloumn-item.is-selected {
194
+ background-color: var(--wd-color-brand-light, #ecf2fe);
195
+ border-radius: 3px;
196
+ }
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import type { CommonPropsType } from '../../types';
3
3
  import type { DataType } from '../../../configs/components/wd-select';
4
4
  import { AttachContainer } from 'tea-component/lib/_util/get-overlay-root';
5
- import './style';
6
5
  /**
7
6
  * 下拉单选-标准化
8
7
  */
@@ -3,22 +3,21 @@ import React, { forwardRef, useState, useCallback, useRef } from 'react';
3
3
  import { useHandleClear, useFixedIcon, SELECT_ICON_H5, SELECT_ICON_PC, } from '../../utils/hooks/useFormLegacy';
4
4
  import { useFormInputTrait } from '../../components/form-input-hooks';
5
5
  import { WdFormItem, WdInputGroup, WdInputWrap } from '../wd-form-item';
6
- import Select from '../form/select';
7
6
  import { isFormatWithRelation } from '../form/select/formats-util';
8
7
  import { emptyObject } from '../../utils/constant';
9
- import { RecycleProvider } from '../../utils/hooks/useRecycle';
10
8
  import { useSelected } from '../../utils/hooks/use-selected';
11
9
  import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
12
10
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
13
11
  import { useDelayEvents } from '../../utils/hooks/use-delay-events';
14
12
  import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
15
- import { RelationalSetting } from './relationalSetting';
16
- import './style';
13
+ import { RelationalSetting } from './relationSelect/relationalSetting';
14
+ import { SelectCom as Select } from './select';
17
15
  /**
18
16
  * 下拉单选-标准化
19
17
  */
20
18
  export const WdSelect = forwardRef(function WsSelect(props, ref) {
21
- 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, popupContainer, } = props;
19
+ 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 = [], // 自定义展示字段
20
+ selectFieldType = 'primary', } = props;
22
21
  const childRef = useRef(null);
23
22
  const [options, setOptions] = useState([]);
24
23
  const [innerHandle, setInnerHandle] = useState({});
@@ -41,6 +40,11 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
41
40
  onChange === null || onChange === void 0 ? void 0 : onChange(v);
42
41
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.change) === null || _a === void 0 ? void 0 : _a.call(delayEvents, { value: v });
43
42
  }, [onChange, delayEvents]);
43
+ const handleChange = (v) => {
44
+ var _a;
45
+ onChange === null || onChange === void 0 ? void 0 : onChange(v);
46
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.change) === null || _a === void 0 ? void 0 : _a.call(delayEvents, { value: v });
47
+ };
44
48
  const clearProps = useHandleClear({
45
49
  onChange: onClearChange,
46
50
  clearable,
@@ -86,7 +90,10 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
86
90
  }), [innerHandle, selectedLabel, selectFields, selectedItem, value], ref);
87
91
  const eventsRef = useSyncedRef(delayEvents);
88
92
  const debouncedTriggerSearchEvent = useDebouncedCallback((value) => {
89
- eventsRef.current.search({ value });
93
+ var _a, _b;
94
+ if (typeof ((_a = eventsRef.current) === null || _a === void 0 ? void 0 : _a.search) === 'function') {
95
+ (_b = eventsRef.current) === null || _b === void 0 ? void 0 : _b.search({ value });
96
+ }
90
97
  }, [eventsRef],
91
98
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
92
99
  300);
@@ -95,8 +102,11 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
95
102
  }, [debouncedTriggerSearchEvent]);
96
103
  if (!visible)
97
104
  return null;
98
- return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(RecycleProvider, { readOnly: readOnly, recycleBack: setOptions, format: format, portalContainer: popupContainer, onRelationTagClick: (item) => {
105
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(Select, { ...props, setAllOption: setOptions, onRelationTagClick: (item) => {
99
106
  var _a;
100
107
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
101
- }, children: _jsx(Select, { addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, defaultValue: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, range: range, size: "full", tipBlock: tipBlock, viewId: viewId, where: where, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, onChange: onChange, onSearchValueInput: onSearchValueInput, popupContainer: popupContainer }) }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
108
+ }, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
109
+ var _a;
110
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
111
+ }, 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: range, 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: true }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
102
112
  });
@@ -1 +1,3 @@
1
+ import '../form/selectMultiple/dropdown-select/index.css';
2
+ import '../style';
1
3
  import './wd-select-multiple.css';
@@ -1 +1,3 @@
1
+ import '../form/selectMultiple/dropdown-select/index.css';
2
+ import '../style';
1
3
  import './wd-select-multiple.css';