@cloudbase/weda-ui 3.10.2 → 3.11.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 (85) 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-rating.js +2 -2
  18. package/dist/configs/components/wd-select-multiple.d.ts +23 -0
  19. package/dist/configs/components/wd-select-multiple.js +26 -1
  20. package/dist/configs/components/wd-select.d.ts +23 -0
  21. package/dist/configs/components/wd-select.js +25 -0
  22. package/dist/configs/components/wd-side-tab.js +2 -2
  23. package/dist/configs/components/wd-table.d.ts +1 -1
  24. package/dist/configs/components/wd-table.js +1 -0
  25. package/dist/configs/components/wd-top-tab.js +2 -2
  26. package/dist/configs/components/wd-upload-image.js +1 -1
  27. package/dist/configs/components/wedaVideo.js +3 -3
  28. package/dist/configs/components/wxOpenApi/share.js +1 -1
  29. package/dist/configs/index.d.ts +1674 -2996
  30. package/dist/configs/index.js +1 -1
  31. package/dist/configs/type-utils/type-form.d.ts +6 -0
  32. package/dist/configs/type-utils/type-form.js +63 -22
  33. package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
  34. package/dist/configs/type-utils/x-runtime-default.js +1 -0
  35. package/dist/enum/index.js +5 -1
  36. package/dist/style/index.css +2 -0
  37. package/dist/style/index.scss +1 -1
  38. package/dist/style/weda-ui.min.css +2 -2
  39. package/dist/web/components/form/select/index.css +2 -2
  40. package/dist/web/components/form/select/request.d.ts +3 -3
  41. package/dist/web/components/form/select/request.js +1 -0
  42. package/dist/web/components/form/select/status/index.d.ts +3 -1
  43. package/dist/web/components/form/select/status/index.js +3 -1
  44. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +5 -5
  45. package/dist/web/components/form-date/index.d.ts +1 -1
  46. package/dist/web/components/form-email/index.d.ts +1 -1
  47. package/dist/web/components/form-input/index.d.ts +1 -1
  48. package/dist/web/components/form-input-hooks/index.js +10 -1
  49. package/dist/web/components/form-input-hooks/validator.d.ts +1 -0
  50. package/dist/web/components/form-input-hooks/validator.js +6 -2
  51. package/dist/web/components/form-phone/index.d.ts +1 -1
  52. package/dist/web/components/form-time/index.d.ts +1 -1
  53. package/dist/web/components/form-url/index.d.ts +1 -1
  54. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  55. package/dist/web/components/wd-date/elements/Modal.h5.js +3 -3
  56. package/dist/web/components/wd-form/index.js +1 -1
  57. package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
  58. package/dist/web/components/wd-input/wd-input.d.ts +1 -1
  59. package/dist/web/components/wd-input-email/wd-input-email.d.ts +1 -1
  60. package/dist/web/components/wd-input-phone/wd-input-phone.d.ts +1 -1
  61. package/dist/web/components/wd-input-url/wd-input-url.d.ts +1 -1
  62. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +4 -0
  63. package/dist/web/components/wd-select/relationSelect/relationSelect.js +202 -0
  64. package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js} +4 -4
  65. package/dist/web/components/wd-select/select/index.d.ts +2 -0
  66. package/dist/web/components/wd-select/select/index.js +8 -0
  67. package/dist/web/components/wd-select/select/selectUI.d.ts +3 -0
  68. package/dist/web/components/wd-select/select/selectUI.js +190 -0
  69. package/dist/web/components/wd-select/style.d.ts +2 -0
  70. package/dist/web/components/wd-select/style.js +2 -0
  71. package/dist/web/components/wd-select/wd-select.css +83 -0
  72. package/dist/web/components/wd-select/wd-select.d.ts +0 -1
  73. package/dist/web/components/wd-select/wd-select.js +18 -8
  74. package/dist/web/components/wd-select-multiple/style.d.ts +2 -0
  75. package/dist/web/components/wd-select-multiple/style.js +2 -0
  76. package/dist/web/components/wd-select-multiple/wd-select-multiple.css +30 -4
  77. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +18 -7
  78. package/dist/web/components/wd-table/components/FieldRender/index.d.ts +7 -4
  79. package/dist/web/components/wd-table/components/FieldRender/index.js +23 -7
  80. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +1 -0
  81. package/dist/web/components/wd-table/hooks/useChooseList.js +55 -26
  82. package/dist/web/utils/platform.js +3 -3
  83. package/package.json +2 -2
  84. package/dist/configs/components/chart/bar.json +0 -1144
  85. /package/dist/web/components/wd-select/{relationalSetting.d.ts → relationSelect/relationalSetting.d.ts} +0 -0
@@ -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';
@@ -76,10 +76,6 @@
76
76
  color: var(--wd-color-text-placeholder) !important;
77
77
  }
78
78
 
79
- .wd-tag-root {
80
- cursor: pointer;
81
- }
82
-
83
79
  .wd-pc-select-multiple-root .wd-form-item-wrap__control {
84
80
  overflow: hidden;
85
81
  }
@@ -91,3 +87,33 @@
91
87
  width: 100%;
92
88
  padding-right: calc(var(--wd-size-icon-md));
93
89
  }
90
+
91
+ .wd-relation-select-overlay.multiple
92
+ .wedatea2td-dropdown-box
93
+ .wedatea2td-list--option
94
+ > li {
95
+ width: fit-content !important;
96
+ min-width: 100%;
97
+ padding: 0;
98
+ }
99
+ .wd-relation-select-overlay.multiple .wd-relation-select-option-wrap {
100
+ padding: 0 8px;
101
+ margin-top: -6px;
102
+ }
103
+ .wd-form-item.wd-pc-select-multiple-root .wedatea2td-dropdown__value div {
104
+ text-overflow: ellipsis;
105
+ white-space: nowrap;
106
+ overflow: hidden;
107
+ }
108
+ /* h5端关联下拉样式 */
109
+ .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple.wd-relation-select-overlay
110
+ .weda-ui-custom-picker__cloumn-item {
111
+ height: auto;
112
+ }
113
+ .weda-ui-custom-picker__cloumns--select-multiple
114
+ .weda-ui-custom-picker__cloumn-item-text {
115
+ overflow: hidden;
116
+ text-overflow: ellipsis;
117
+ white-space: nowrap;
118
+ margin-left: 30px;
119
+ }
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { forwardRef, useState, useCallback, useRef } from 'react';
3
3
  import { WdFormItem, WdInputGroup, WdInputWrap } from '../wd-form-item';
4
- import SelectMultiple from '../form/selectMultiple';
4
+ import { SelectCom as SelectMultiple } from '../wd-select/select';
5
5
  import { useHandleClear, useFixedIcon, SELECT_ICON_H5, SELECT_ICON_PC, } from '../../utils/hooks/useFormLegacy';
6
6
  import { useFormInputTrait } from '../../components/form-input-hooks';
7
- import { RecycleProvider } from '../../utils/hooks/useRecycle';
8
7
  import { useSelected } from '../../utils/hooks/use-selected';
9
8
  import { emptyObject } from '../../utils/constant';
10
9
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
@@ -13,12 +12,13 @@ import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default
13
12
  import './style';
14
13
  import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
15
14
  import { isFormatWithRelation } from '../form/select/formats-util';
16
- import { RelationalSetting } from '../wd-select/relationalSetting';
15
+ import { RelationalSetting } from '../wd-select/relationSelect/relationalSetting';
17
16
  /**
18
17
  * 下拉多选-标准化
19
18
  */
20
19
  export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref) {
21
- 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, popupContainer, } = props;
20
+ 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 = [], // 自定义展示字段
21
+ selectFieldType = 'primary', } = props;
22
22
  const childRef = useRef(null);
23
23
  const [options, setOptions] = useState([]);
24
24
  const [innerHandle, setInnerHandle] = useState({});
@@ -48,6 +48,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
48
48
  disabled,
49
49
  value,
50
50
  });
51
+ const handleChange = (v) => {
52
+ var _a;
53
+ onChange === null || onChange === void 0 ? void 0 : onChange(v);
54
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.change) === null || _a === void 0 ? void 0 : _a.call(delayEvents, { value: v });
55
+ };
51
56
  const isRelation = isFormatWithRelation(format);
52
57
  const LabelAdornment = isRelation && (_jsx(RelationalSetting, { size: props.size, refresh: () => {
53
58
  var _a;
@@ -81,7 +86,10 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
81
86
  }), [innerHandle, selectedLabel, primaryField, selectedItem, value], ref);
82
87
  const eventsRef = useSyncedRef(events);
83
88
  const debouncedTriggerSearchEvent = useDebouncedCallback((value) => {
84
- eventsRef.current.search({ value });
89
+ var _a, _b;
90
+ if (typeof ((_a = eventsRef.current) === null || _a === void 0 ? void 0 : _a.search) === 'function') {
91
+ (_b = eventsRef.current) === null || _b === void 0 ? void 0 : _b.search({ value });
92
+ }
85
93
  }, [eventsRef],
86
94
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
87
95
  300);
@@ -90,8 +98,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
90
98
  }, [debouncedTriggerSearchEvent]);
91
99
  if (!visible)
92
100
  return null;
93
- 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) => {
101
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, setAllOption: setOptions, onRelationTagClick: (item) => {
94
102
  var _a;
95
103
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
96
- }, children: _jsx(SelectMultiple, { 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, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: onChange, onSearchValueInput: onSearchValueInput, popupContainer: popupContainer }) }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
104
+ }, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
105
+ var _a;
106
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
107
+ }, 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, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
97
108
  });
@@ -56,17 +56,18 @@ export declare const formatNumberFix: (val: any, field: any, setZero?: boolean)
56
56
  * 根据 fields 信息生成 column
57
57
  * h5 和 pc 部分参数不同
58
58
  */
59
- export declare const getColumns: ({ columnSets, fields, isH5, supportManyRelated, }: {
59
+ export declare const getColumns: ({ columnSets, fields, isH5, supportManyRelated, showRelationWithTag, }: {
60
60
  columnSets?: any[];
61
61
  fields: any;
62
62
  isH5?: boolean;
63
63
  supportManyRelated: any;
64
+ showRelationWithTag: any;
64
65
  }) => any;
65
66
  /**
66
67
  * 根据 field 属性,生成 column 配置
67
68
  * https://git.woa.com/QBase/lcap/common-application-specs/blob/master/types/platform/datasource.ts
68
69
  */
69
- export declare const formatFieldToColumn: (field: any, isH5: any, columnSets: any, supportManyRelated: any) => {
70
+ export declare const formatFieldToColumn: (field: any, isH5: any, columnSets: any, supportManyRelated: any, showRelationWithTag: any) => {
70
71
  width: any;
71
72
  render: (record: any) => JSX.Element;
72
73
  key: any;
@@ -109,13 +110,14 @@ export declare const slotRender: (Slot: any, props?: {}) => any;
109
110
  * slots: object 模型表格作用域插槽
110
111
  * isH5: 判断自定义插槽列能否展示,目前是正常展示
111
112
  */
112
- export declare const filterCustomColumns: ({ columns, columnSets, slots, fields, isH5, supportManyRelated, }: {
113
+ export declare const filterCustomColumns: ({ columns, columnSets, slots, fields, isH5, supportManyRelated, showRelationWithTag, }: {
113
114
  columns: any;
114
115
  columnSets: any;
115
116
  slots: any;
116
117
  fields: any;
117
118
  isH5: any;
118
119
  supportManyRelated: any;
120
+ showRelationWithTag: any;
119
121
  }) => any;
120
122
  /**
121
123
  * 过滤字段列表
@@ -137,7 +139,7 @@ export declare const getFixedColumnSets: ({ fixedFront, fixedEnd, columnSets, }:
137
139
  /**
138
140
  * 列管理字段转换
139
141
  */
140
- export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, }: {
142
+ export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, showRelationWithTag, }: {
141
143
  fields: any;
142
144
  columnSets: any;
143
145
  slots: any;
@@ -145,5 +147,6 @@ export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront,
145
147
  fixedEnd: any;
146
148
  isH5: any;
147
149
  supportManyRelated: any;
150
+ showRelationWithTag?: boolean;
148
151
  }) => any;
149
152
  export declare const mapColumKey: (columnSets: any) => any;