@cloudbase/weda-ui 3.21.1 → 3.21.3

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.
@@ -41,6 +41,15 @@ const popover = 'clearFormat bold italic underline color backgroundColor';
41
41
  let loadEditorPromise;
42
42
  // 默认视频类型
43
43
  const VIDEO_TYPES = ['video/*'];
44
+ function loadSrc(src) {
45
+ return new Promise((resolve, reject) => {
46
+ const script = document.createElement('script');
47
+ script.src = src;
48
+ script.onload = () => resolve('');
49
+ script.onerror = () => reject('');
50
+ document.body.appendChild(script);
51
+ });
52
+ }
44
53
  export default React.memo(RichText);
45
54
  function RichText({
46
55
  // 系统属性
@@ -149,32 +158,13 @@ initialContent, placeholder, iconPack, maxSize, cloudPath, visible, storageType
149
158
  React.useEffect(() => {
150
159
  if (!(window === null || window === void 0 ? void 0 : window.ExEditor3) && !loadEditorPromise) {
151
160
  // 挂载资源
152
- function loadSrc(src, css) {
153
- return new Promise((resolve, reject) => {
154
- const script = document.createElement('script');
155
- script.src = src;
156
- script.onload = () => resolve('');
157
- script.onerror = () => reject('');
158
- document.body.appendChild(script);
159
- const link = document.createElement('link');
160
- link.setAttribute('rel', 'stylesheet');
161
- link.setAttribute('href', css);
162
- const head = document.getElementsByTagName('head');
163
- if (head.length) {
164
- head[0].appendChild(link);
165
- }
166
- else {
167
- document.body.appendChild(link);
168
- }
169
- });
170
- }
171
161
  try {
172
162
  const cfg = onlineConfig.richText;
173
163
  if (isPrivate()) {
174
- loadEditorPromise = loadSrc(cfg.private.js, cfg.private.css).catch((_) => loadSrc(cfg.js, cfg.css));
164
+ loadEditorPromise = loadSrc(cfg.private.js).catch(() => loadSrc(cfg.js));
175
165
  }
176
166
  else {
177
- loadEditorPromise = loadSrc(cfg.js, cfg.css);
167
+ loadEditorPromise = loadSrc(cfg.js);
178
168
  }
179
169
  }
180
170
  catch (e) {
@@ -54,15 +54,15 @@
54
54
  font-size: 0.67em;
55
55
  }
56
56
 
57
- .weda-RichTextView ul {
57
+ /* .weda-RichTextView ul {
58
58
  list-style: disc !important;
59
59
  padding: revert !important;
60
- }
60
+ } */
61
61
 
62
- .weda-RichTextView ol {
62
+ /* .weda-RichTextView ol {
63
63
  list-style: decimal !important;
64
64
  padding: revert !important;
65
- }
65
+ } */
66
66
 
67
67
  .weda-RichTextView .tableWrapper,
68
68
  .weda-RichTextView div:has(> table) {
@@ -114,3 +114,55 @@
114
114
  .weda-RichTextView p {
115
115
  min-height: 1em;
116
116
  }
117
+
118
+ .weda-RichTextView ol,
119
+ .weda-RichTextView ul {
120
+ padding-inline-start: 32px;
121
+ padding-left: 32px;
122
+ }
123
+
124
+ .weda-RichTextView ol {
125
+ --ol-start: 1;
126
+ --ol-list-style-type: decimal;
127
+ list-style-type: none;
128
+ counter-reset: olCounter calc(var(--ol-start, 1) - 1);
129
+ position: relative;
130
+ }
131
+ .weda-RichTextView ol > li > :first-child::before {
132
+ content: counter(olCounter, var(--ol-list-style-type)) '. ';
133
+ counter-increment: olCounter;
134
+ font-variant-numeric: tabular-nums;
135
+ position: absolute;
136
+ transform: translate(-100%, 0);
137
+ }
138
+
139
+ .weda-RichTextView ul {
140
+ --ul-list-style-type: circle;
141
+ list-style-type: none;
142
+ position: relative;
143
+ }
144
+ .weda-RichTextView ul.nonUnicode-list-style-type > li > :first-child::before {
145
+ content: var(--ul-list-style-type) ' ';
146
+ font-variant-numeric: tabular-nums;
147
+ position: absolute;
148
+ transform: translate(-100%, 0.05em) scale(0.5);
149
+ }
150
+ .weda-RichTextView ul.unicode-list-style-type > li > :first-child::before {
151
+ content: var(--ul-list-style-type) ' ';
152
+ font-variant-numeric: tabular-nums;
153
+ position: absolute;
154
+ transform: translate(-100%, 0) scale(0.8);
155
+ }
156
+
157
+ .weda-RichTextView ul[data-type='todo'] {
158
+ padding-left: calc(2em + 10px);
159
+ }
160
+ .weda-RichTextView ul[data-type='todo'] > li > :first-child::before {
161
+ content: '';
162
+ }
163
+ .weda-RichTextView ul[data-type='todo'] > li > input[type='checkbox'] {
164
+ position: absolute;
165
+ left: 1em;
166
+ margin-top: 6px;
167
+ margin-right: 10px;
168
+ }
@@ -1,2 +1,3 @@
1
1
  import './index.css';
2
+ import '../richText/index.css';
2
3
  import '../style';
@@ -1,2 +1,3 @@
1
1
  import './index.css';
2
+ import '../richText/index.css';
2
3
  import '../style';
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from 'react';
3
- import { Modal, Radio, Form, Table, Checkbox, Icon, List, Status, Bubble, Tooltip, } from 'tea-component';
3
+ import { Modal, Radio, Form, Table, Checkbox, Icon, List, Status, Bubble, Tooltip } from 'tea-component';
4
4
  import { useImportingStatus } from '../hooks/useImportingStatus';
5
5
  import { callWedaApi } from '../../../utils/tcb';
6
6
  import { WdButton } from '../../wd-button';
@@ -25,13 +25,11 @@ export function ExportFileModalByApi({ onCancel, visible, fields, selectedKeysLi
25
25
  }
26
26
  });
27
27
  return {
28
- FieldId: (field === null || field === void 0 ? void 0 : field.isRelated)
29
- ? `@${field === null || field === void 0 ? void 0 : field.fieldKey}.${field === null || field === void 0 ? void 0 : field.relatedField}`
30
- : item,
28
+ FieldId: (field === null || field === void 0 ? void 0 : field.isRelated) ? `@${field === null || field === void 0 ? void 0 : field.fieldKey}.${field === null || field === void 0 ? void 0 : field.relatedField}` : item,
31
29
  ColumnName: item === '_id' ? '数据标识' : field === null || field === void 0 ? void 0 : field.header,
32
30
  };
33
31
  });
34
- const hadnleExport = async () => {
32
+ const handleExport = async () => {
35
33
  try {
36
34
  setStep('isExporting');
37
35
  // 启动导出接口
@@ -105,7 +103,7 @@ export function ExportFileModalByApi({ onCancel, visible, fields, selectedKeysLi
105
103
  header: '字段名称',
106
104
  },
107
105
  {
108
- key: 'name',
106
+ key: 'fieldKeyLabel',
109
107
  header: '字段标识',
110
108
  },
111
109
  {
@@ -113,7 +111,10 @@ export function ExportFileModalByApi({ onCancel, visible, fields, selectedKeysLi
113
111
  header: '字段类型',
114
112
  },
115
113
  ];
116
- return (_jsxs(Modal, { caption: "\u5BFC\u51FAExcel", visible: visible, onClose: onCancel, size: 'l', className: `weda-import-csv-file-modal`, children: [_jsxs(Modal.Body, { children: [step === 'fieldMap' && (_jsxs("div", { children: [_jsx(Form, { className: "weda-import-csv-file-modal weda-export-csv-file-modal", children: _jsx(Form.Item, { label: _jsx(_Fragment, { children: _jsx(Tooltip, { title: _jsx("span", { className: "weda-export-label-tooltip", children: "\u5982\u5BFC\u51FA\u6570\u636E\u91CF\u8D85\u51FA10\u4E07\u884C\uFF0C\u8BF7\u60A8\u7B5B\u9009\u6570\u636E\u540E\u5206\u591A\u6B21\u5BFC\u51FA\u3002" }), children: "\u5BFC\u51FA\u6570\u636E\u8303\u56F4(\u4E0A\u965010\u4E07\u884C)" }) }), children: _jsxs(Radio.Group, { value: exportType, onChange: (value) => setExportType(value), style: { display: 'flex' }, children: [_jsx(Radio, { name: "all", children: "\u5168\u90E8\u6570\u636E" }), _jsx(Radio, { name: "filter", children: "\u7B5B\u9009\u540E\u7684\u6570\u636E" }), _jsxs(Radio, { name: "selected", disabled: !(selectedKeysList === null || selectedKeysList === void 0 ? void 0 : selectedKeysList.length), children: ["\u9009\u4E2D\u7684\u6570\u636E", _jsx("span", { style: { color: 'rgba(0, 0, 0, 0.6)' }, children: !(selectedKeysList === null || selectedKeysList === void 0 ? void 0 : selectedKeysList.length) && '(无选中数据)' })] })] }) }) }), _jsx("p", { className: "weda-export-csv-file-modal__wrap_text", children: "\u5BFC\u51FA\u5B57\u6BB5" }), _jsx(Table, { records: fields, recordKey: "name", columns: columns, style: { border: '1px solid #E7E7E7', borderBottom: '0' }, addons: [
114
+ return (_jsxs(Modal, { caption: "\u5BFC\u51FAExcel", visible: visible, onClose: onCancel, size: 'l', className: `weda-import-csv-file-modal`, children: [_jsxs(Modal.Body, { children: [step === 'fieldMap' && (_jsxs("div", { children: [_jsx(Form, { className: "weda-import-csv-file-modal weda-export-csv-file-modal", children: _jsx(Form.Item, { label: _jsx(_Fragment, { children: _jsx(Tooltip, { title: _jsx("span", { className: "weda-export-label-tooltip", children: "\u5982\u5BFC\u51FA\u6570\u636E\u91CF\u8D85\u51FA10\u4E07\u884C\uFF0C\u8BF7\u60A8\u7B5B\u9009\u6570\u636E\u540E\u5206\u591A\u6B21\u5BFC\u51FA\u3002" }), children: "\u5BFC\u51FA\u6570\u636E\u8303\u56F4(\u4E0A\u965010\u4E07\u884C)" }) }), children: _jsxs(Radio.Group, { value: exportType, onChange: (value) => setExportType(value), style: { display: 'flex' }, children: [_jsx(Radio, { name: "all", children: "\u5168\u90E8\u6570\u636E" }), _jsx(Radio, { name: "filter", children: "\u7B5B\u9009\u540E\u7684\u6570\u636E" }), _jsxs(Radio, { name: "selected", disabled: !(selectedKeysList === null || selectedKeysList === void 0 ? void 0 : selectedKeysList.length), children: ["\u9009\u4E2D\u7684\u6570\u636E", _jsx("span", { style: { color: 'rgba(0, 0, 0, 0.6)' }, children: !(selectedKeysList === null || selectedKeysList === void 0 ? void 0 : selectedKeysList.length) && '(无选中数据)' })] })] }) }) }), _jsx("p", { className: "weda-export-csv-file-modal__wrap_text", children: "\u5BFC\u51FA\u5B57\u6BB5" }), _jsx(Table, { records: fields === null || fields === void 0 ? void 0 : fields.map((i) => ({
115
+ ...i,
116
+ fieldKeyLabel: i.isRelated ? `${i.fieldKey}.${i.relatedField}` : i.name,
117
+ })), recordKey: "name", columns: columns, style: { border: '1px solid #E7E7E7', borderBottom: '0' }, addons: [
117
118
  selectable({
118
119
  value: selectedKeys,
119
120
  onChange: (keys) => {
@@ -125,14 +126,10 @@ export function ExportFileModalByApi({ onCancel, visible, fields, selectedKeysLi
125
126
  maxHeight: 320,
126
127
  }),
127
128
  ] }), _jsx(Checkbox.Group, { value: exportIdentity, onChange: (value) => setExportIdentity(value), style: { margin: '16px 0', color: 'rgba(0, 0, 0, 0.6)' }, children: _jsx(Checkbox, { name: "exportIdentity", style: { color: 'rgba(0, 0, 0, 0.6)' }, children: _jsx(Bubble, { content: "\u52FE\u9009\u540E\uFF0C\u53EF\u5BFC\u51FA\u679A\u4E3E\u5B57\u6BB5\u7684\u9009\u9879\u6807\u8BC6\uFF0C\u4E0E\u5173\u8054\u5173\u7CFB/\u4E3B\u5B50\u660E\u7EC6\u5B57\u6BB5\u5173\u8054\u6570\u636E\u7684\u6570\u636E\u6807\u8BC6\uFF0C\u53EF\u7528\u4E8E\u5BFC\u5165\u65F6\u66F4\u65B0\u679A\u4E3E/\u5173\u8054\u5173\u7CFB/\u4E3B\u5B50\u660E\u7EC6\u5B57\u6BB5\u6570\u636E", children: "\u5BFC\u51FA\u9009\u9879\u6807\u8BC6\u548C\u5173\u8054\u6570\u636E\u6807\u8BC6" }) }) })] })), step === 'isExporting' && (_jsxs("div", { className: "import-file-result-wrap", children: [status === 'error' && (_jsxs("div", { className: "error-container", children: [_jsxs("div", { className: "error-tip", children: [_jsx(Icon, { type: "error", size: "s" }), _jsx("p", { children: "\u6570\u636E\u5BFC\u51FA\u5931\u8D25" })] }), _jsx("div", { className: "error-content", children: _jsx(List, { children: Array.isArray(errorMessage)
128
- ? errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.map((i, index) => (_jsx(List.Item, { children: i }, index)))
129
+ ? errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.map((i, index) => _jsx(List.Item, { children: i }, index))
129
130
  : errorMessage }) })] })), status !== 'validateError' && status !== 'error' && (_jsx("div", { className: `status-wrap ${status}`, children: _jsx(Status, { icon: 'blank', size: 'm', style: {
130
131
  maxWidth: '430px',
131
- }, title: status === 'success'
132
- ? '数据导出完成'
133
- : '数据导出中,请稍候...', description: status === 'success' ? (_jsx("a", { target: '_blank', href: fileImportErrorMessage === null || fileImportErrorMessage === void 0 ? void 0 : fileImportErrorMessage.DownloadUrl, rel: "noreferrer", style: { margin: '0 auto' }, className: "wd-table__a", children: "\u70B9\u51FB\u4E0B\u8F7D" })) : (_jsxs("div", { children: [status === 'timeout'
134
- ? '数据导出耗时较长,请稍后在'
135
- : '关闭弹窗后,导出任务会继续执行,可在', _jsx("a", { className: "wd-table__a", onClick: () => {
132
+ }, title: status === 'success' ? '数据导出完成' : '数据导出中,请稍候...', description: status === 'success' ? (_jsx("a", { target: '_blank', href: fileImportErrorMessage === null || fileImportErrorMessage === void 0 ? void 0 : fileImportErrorMessage.DownloadUrl, rel: "noreferrer", style: { margin: '0 auto' }, className: "wd-table__a", children: "\u70B9\u51FB\u4E0B\u8F7D" })) : (_jsxs("div", { children: [status === 'timeout' ? '数据导出耗时较长,请稍后在' : '关闭弹窗后,导出任务会继续执行,可在', _jsx("a", { className: "wd-table__a", onClick: () => {
136
133
  onCancel();
137
134
  handleInOrOutRecordModealVisible('export');
138
135
  }, children: "\u6211\u7684\u5BFC\u51FA\u8BB0\u5F55" }), "\u67E5\u770B\u4EFB\u52A1\u8FDB\u5EA6"] })) }) }))] }))] }), _jsxs(Modal.Footer, { children: [step === 'fieldMap' && (_jsx(WdButton, { text: "\u6211\u7684\u5BFC\u51FA\u8BB0\u5F55", variant: "link", style: { float: 'left' }, events: {
@@ -140,5 +137,5 @@ export function ExportFileModalByApi({ onCancel, visible, fields, selectedKeysLi
140
137
  onCancel();
141
138
  handleInOrOutRecordModealVisible('export');
142
139
  },
143
- } })), step === 'fieldMap' && (_jsxs(_Fragment, { children: [_jsx(WdButton, { text: "\u53D6\u6D88", events: { tap: onCancel }, theme: "secondary", variant: "outline", className: "wd-btn__margin-right" }), _jsx(WdButton, { text: "\u786E\u5B9A", events: { tap: hadnleExport }, disabled: !(selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.length) })] }))] })] }));
140
+ } })), step === 'fieldMap' && (_jsxs(_Fragment, { children: [_jsx(WdButton, { text: "\u53D6\u6D88", events: { tap: onCancel }, theme: "secondary", variant: "outline", className: "wd-btn__margin-right" }), _jsx(WdButton, { text: "\u786E\u5B9A", events: { tap: handleExport }, disabled: !(selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.length) })] }))] })] }));
144
141
  }
@@ -522,18 +522,20 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
522
522
  }
523
523
  }, [formFieldsValue]);
524
524
  const setFieldValue = useCallback(({ namePath, value }) => {
525
- const _formData = deepClone(formData);
526
- const _value = lodashGet(_formData, namePath, NOT_EXISTED_VALUE);
527
- if (isObjectEqual(_value, value)) {
528
- return;
529
- }
530
- lodashSet(_formData, namePath, value);
531
- if (typeof _formData !== 'object' || _formData === null) {
532
- console.warn('setValue data need expect a object but got null', _formData);
533
- return;
534
- }
535
- setFormData(_formData);
536
- }, [formData]);
525
+ setFormData((formData) => {
526
+ const _formData = deepClone(formData);
527
+ const _value = lodashGet(_formData, namePath, NOT_EXISTED_VALUE);
528
+ if (isObjectEqual(_value, value)) {
529
+ return _formData;
530
+ }
531
+ lodashSet(_formData, namePath, value);
532
+ if (typeof _formData !== 'object' || _formData === null) {
533
+ console.warn('setValue data need expect a object but got null', _formData);
534
+ return formData;
535
+ }
536
+ return _formData;
537
+ });
538
+ }, []);
537
539
  if (initValueLoadingStatus === 'hidden') {
538
540
  return null;
539
541
  }
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useRef, useMemo, useEffect } from 'react';
2
+ import { useState, useRef, useMemo } from 'react';
3
+ import { useDeepCompareEffect } from '@react-hookz/web';
3
4
  import { Select, SelectMultiple, List } from 'tea-component';
4
5
  import { WdFormItemReadOnly } from '../../wd-form-item';
5
6
  import { Modal } from '../../wd-date/elements/Modal.h5';
@@ -12,12 +13,12 @@ import AllEmpty from '../../form/select/status/allEmpty';
12
13
  import { X_RUNTIME_DEFAULT } from '../../../../configs/type-utils/x-runtime-default';
13
14
  import '../style';
14
15
  const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomTips, onScrollBottom }) => {
15
- return (_jsxs(List, { className: "weda-ui-custom-picker__column", style: {
16
+ return (_jsxs(List, { className: "weda-ui-custom-picker__column wd-select-list", style: {
16
17
  height: inputFocus ? 'calc(100vh - 190px)' : '250px',
17
18
  }, onScrollBottom: onScrollBottom, children: [options === null || options === void 0 ? void 0 : options.map((item, index) => {
18
19
  // is-selected 选中态
19
20
  // is-disabled 禁用态
20
- const itemCls = classNames('weda-ui-custom-picker__column-item', {
21
+ const itemCls = classNames('weda-ui-custom-picker__column-item', 'wd-select-list-item', {
21
22
  'is-selected': currentSelected.find((i) => i.value === item.value),
22
23
  'is-disabled': item.disabled,
23
24
  });
@@ -30,14 +31,15 @@ const getSelectedItem = (options = [], value) => {
30
31
  };
31
32
  function SelectH5(props) {
32
33
  const { placeholder, name, disabled, footer, options = [], value, onChange, overlayClassName, searchable, bottomTips, onSearch, onOpen, onScrollBottom, mode, readValue, popupContainer, searchPlaceholder, filterable, onBlur, onFocus, } = props;
34
+ const { classPrefix } = useConfig();
33
35
  const isMultiple = mode === 'multiple';
34
36
  const customPickerCls = classNames('weda-ui-custom-picker__columns', {
35
37
  'weda-ui-custom-picker__columns--select-multiple': isMultiple,
36
38
  'weda-ui-custom-picker__columns--select': !isMultiple,
37
39
  [`${overlayClassName}`]: true,
40
+ [`${classPrefix}-select-modal__columns`]: true,
38
41
  });
39
42
  const [visible, setVisible] = useState(false);
40
- const { classPrefix } = useConfig();
41
43
  const inputCls = `${classPrefix}-form-select_input`;
42
44
  const focusRef = useRef();
43
45
  // 聚焦在搜索框
@@ -133,7 +135,7 @@ function SelectH5(props) {
133
135
  else {
134
136
  setVisible(false);
135
137
  }
136
- }, 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 === null || customOptions === void 0 ? void 0 : customOptions.length) ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { children: [_jsx("div", { className: customPickerCls, "data-testid": "weda-ui-custom-picker__columns", style: {
138
+ }, onOk: handleOk, header: inputFocus, className: `${classPrefix}-select-modal`, okButtonVisible: isMultiple, popupContainer: popupContainer, children: [searchable && renderSearch(), _jsx("div", { className: `${classPrefix}-custom-view-content`, children: !bottomTips && !(customOptions === null || customOptions === void 0 ? void 0 : customOptions.length) ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { children: [_jsx("div", { className: customPickerCls, "data-testid": "weda-ui-custom-picker__columns", style: {
137
139
  height: inputFocus ? 'calc(100vh - 160px)' : '280px',
138
140
  }, children: _jsx(OptionList, { onScrollBottom: onScrollBottom, options: customOptions, inputFocus: inputFocus, currentSelected: currentSelected, optionClick: optionClick, bottomTips: bottomTips }) }), footer] })) })] })] }));
139
141
  }
@@ -142,14 +144,14 @@ export function SelectUI(props) {
142
144
  const platform = usePlatform();
143
145
  const [currentOption] = useSyncValue((options === null || options === void 0 ? void 0 : options.map(({ label, value }) => ({ label, value }))) || [], isObjectEqual);
144
146
  // 更新option,从而更新最新的选项值
145
- useEffect(() => {
147
+ useDeepCompareEffect(() => {
146
148
  if (setAllOption) {
147
149
  setAllOption(currentOption);
148
150
  }
149
151
  }, [currentOption, setAllOption]);
150
152
  const isMultiple = mode === 'multiple';
151
153
  const [selectedItem, setSelectedItem] = useState([]);
152
- useEffect(() => {
154
+ useDeepCompareEffect(() => {
153
155
  // 缓存展示的选中项
154
156
  setSelectedItem((selectItem) => {
155
157
  const newSelectItem = getSelectedItem(options, value);
@@ -19,7 +19,7 @@ import { SelectProvider } from './contexts/selectContext';
19
19
  * 下拉单选-标准化
20
20
  */
21
21
  export const WdSelect = forwardRef(function WsSelect(props, ref) {
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 = [], // 自定义展示字段
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
23
  selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, selectFieldLabel, } = props;
24
24
  const childRef = useRef(null);
25
25
  // 是否是关联
@@ -20,7 +20,7 @@ import { SelectProvider } from '../wd-select/contexts/selectContext';
20
20
  * 下拉多选-标准化
21
21
  */
22
22
  export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref) {
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 = [], // 自定义展示字段
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
24
  selectFieldType = 'primary', searchPlaceholder, searchable = X_RUNTIME_DEFAULT.searchable, filterable = X_RUNTIME_DEFAULT.filterable, selectFieldLabel, } = props;
25
25
  const childRef = useRef(null);
26
26
  // 是否是关联
@@ -3,7 +3,7 @@ import { useState, useCallback, useRef, useEffect } from 'react';
3
3
  import { useConfig } from '../../utils/config-context';
4
4
  import { usePlatform } from '../../utils/platform';
5
5
  import WdIcon from '../wd-icon';
6
- import { useSyncedRef } from '@react-hookz/web';
6
+ import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
7
7
  import { renderSlot } from './util';
8
8
  export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProps }) => {
9
9
  const { classPrefix } = useConfig();
@@ -35,16 +35,14 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
35
35
  data[index] += i === null || i === void 0 ? void 0 : i.clientWidth;
36
36
  }
37
37
  itemData.set(itemIndex, {
38
- offset: itemData.get(itemIndex - Number('1'))['offset'] +
39
- itemData.get(itemIndex - Number('1'))['clientWidth'],
38
+ offset: itemData.get(itemIndex - Number('1'))['offset'] + itemData.get(itemIndex - Number('1'))['clientWidth'],
40
39
  clientWidth: i === null || i === void 0 ? void 0 : i.clientWidth,
41
40
  });
42
41
  itemIndex = itemIndex + Number('1');
43
42
  }
44
43
  // 计算右侧是否显示遮罩
45
44
  const paddingWidth = 16;
46
- const showMask = itemData.get(menuItem.length)['offset'] +
47
- itemData.get(menuItem.length)['clientWidth'] >
45
+ const showMask = itemData.get(menuItem.length)['offset'] + itemData.get(menuItem.length)['clientWidth'] >
48
46
  parentWidth + paddingWidth;
49
47
  setShowMask(showMask);
50
48
  setItemOffsetData(itemData);
@@ -58,10 +56,16 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
58
56
  useEffect(() => {
59
57
  setSelectedTab(selectedIndex);
60
58
  }, [selectedIndex]);
59
+ const debouncedChangeEvent = useDebouncedCallback((value) => {
60
+ var _a;
61
+ (_a = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _a === void 0 ? void 0 : _a.change(value);
62
+ }, [restProps],
63
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
64
+ 300);
61
65
  // 渲染菜单
62
66
  const RenderTabItem = (index, item) => {
63
67
  return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: () => {
64
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
65
69
  if (!(item === null || item === void 0 ? void 0 : item.isDisabled) && !(item === null || item === void 0 ? void 0 : item.selected)) {
66
70
  if (restProps.direction !== 'vertical') {
67
71
  const parentWidths = (_b = (_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth;
@@ -77,8 +81,7 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
77
81
  itemOffset >
78
82
  parentWidths) {
79
83
  (_k = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _k === void 0 ? void 0 : _k.scrollTo(((_l = itemOffsetData.get(index + Number('1'))) === null || _l === void 0 ? void 0 : _l.offset) -
80
- (parentWidths -
81
- ((_m = itemOffsetData.get(index + Number('1'))) === null || _m === void 0 ? void 0 : _m.clientWidth)), 0);
84
+ (parentWidths - ((_m = itemOffsetData.get(index + Number('1'))) === null || _m === void 0 ? void 0 : _m.clientWidth)), 0);
82
85
  }
83
86
  }
84
87
  setSelectedTab(index);
@@ -86,13 +89,11 @@ export const WdTabsH5 = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
86
89
  // HACK widget 时序
87
90
  if ((_p = (_o = $node.current) === null || _o === void 0 ? void 0 : _o._getInstanceRef()) === null || _p === void 0 ? void 0 : _p.current) {
88
91
  const currentSelectedValue = item === null || item === void 0 ? void 0 : item.value;
89
- if (currentSelectedValue !==
90
- $node.current._getInstanceRef().current.selectedValue) {
91
- $node.current._getInstanceRef().current.selectedValue =
92
- currentSelectedValue;
92
+ if (currentSelectedValue !== $node.current._getInstanceRef().current.selectedValue) {
93
+ $node.current._getInstanceRef().current.selectedValue = currentSelectedValue;
93
94
  }
94
95
  }
95
- (_q = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _q === void 0 ? void 0 : _q.change({ value: item === null || item === void 0 ? void 0 : item.value });
96
+ debouncedChangeEvent({ value: item === null || item === void 0 ? void 0 : item.value });
96
97
  }
97
98
  }, children: [(item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'prefix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null, _jsx("div", { className: `${classPrefix}-tabs__item-text`, children: item === null || item === void 0 ? void 0 : item.label }), (item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'suffix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null] }));
98
99
  };
@@ -3,7 +3,7 @@ import { useState, useCallback, useRef, useEffect } from 'react';
3
3
  import { useConfig } from '../../utils/config-context';
4
4
  import { usePlatform } from '../../utils/platform';
5
5
  import WdIcon from '../wd-icon';
6
- import { useSyncedRef } from '@react-hookz/web';
6
+ import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
7
7
  import { renderSlot } from './util';
8
8
  export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProps }) => {
9
9
  const { classPrefix } = useConfig();
@@ -57,27 +57,29 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
57
57
  useEffect(() => {
58
58
  setSelectedTab(selectedIndex);
59
59
  }, [selectedIndex]);
60
+ const debouncedChangeEvent = useDebouncedCallback((value) => {
61
+ var _a;
62
+ (_a = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _a === void 0 ? void 0 : _a.change(value);
63
+ }, [restProps],
64
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
65
+ 300);
60
66
  // 渲染菜单
61
67
  const RenderTabItem = (index, item) => {
62
68
  return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: () => {
63
- var _a, _b, _c, _d, _e, _f, _g;
69
+ var _a, _b, _c, _d, _e, _f;
64
70
  if (!(item === null || item === void 0 ? void 0 : item.isDisabled) && !(item === null || item === void 0 ? void 0 : item.selected)) {
65
71
  if (restProps.direction !== 'vertical') {
66
72
  const parentWidths = (_b = (_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth;
67
73
  const result = parentWidths * ((position === null || position === void 0 ? void 0 : position.index) + Number('1')) -
68
- (((_c = itemOffsetData.get(index)) === null || _c === void 0 ? void 0 : _c.clientWidth) +
69
- ((_d = itemOffsetData.get(index)) === null || _d === void 0 ? void 0 : _d.offset));
70
- if (result >= 0 &&
71
- itemOffsetData.get(index).offset <=
72
- parentWidths * (position === null || position === void 0 ? void 0 : position.index)) {
74
+ (((_c = itemOffsetData.get(index)) === null || _c === void 0 ? void 0 : _c.clientWidth) + ((_d = itemOffsetData.get(index)) === null || _d === void 0 ? void 0 : _d.offset));
75
+ if (result >= 0 && itemOffsetData.get(index).offset <= parentWidths * (position === null || position === void 0 ? void 0 : position.index)) {
73
76
  setPosition({
74
77
  index: position.index,
75
78
  offset: -itemOffsetData.get(index).offset,
76
79
  });
77
80
  }
78
81
  // 大于父级容器
79
- if (result < 0 &&
80
- result - parentWidths * (position === null || position === void 0 ? void 0 : position.index) < position.offset) {
82
+ if (result < 0 && result - parentWidths * (position === null || position === void 0 ? void 0 : position.index) < position.offset) {
81
83
  setPosition({
82
84
  index: position.index,
83
85
  offset: result + position.offset,
@@ -89,13 +91,11 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
89
91
  // HACK widget 时序
90
92
  if ((_f = (_e = $node.current) === null || _e === void 0 ? void 0 : _e._getInstanceRef()) === null || _f === void 0 ? void 0 : _f.current) {
91
93
  const currentSelectedValue = item === null || item === void 0 ? void 0 : item.value;
92
- if (currentSelectedValue !==
93
- $node.current._getInstanceRef().current.selectedValue) {
94
- $node.current._getInstanceRef().current.selectedValue =
95
- currentSelectedValue;
94
+ if (currentSelectedValue !== $node.current._getInstanceRef().current.selectedValue) {
95
+ $node.current._getInstanceRef().current.selectedValue = currentSelectedValue;
96
96
  }
97
97
  }
98
- (_g = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _g === void 0 ? void 0 : _g.change({ value: item === null || item === void 0 ? void 0 : item.value });
98
+ debouncedChangeEvent({ value: item === null || item === void 0 ? void 0 : item.value });
99
99
  }
100
100
  }, children: [(item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'prefix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null, _jsx("div", { className: `${classPrefix}-tabs__item-text`, children: item === null || item === void 0 ? void 0 : item.label }), (item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'suffix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null] }));
101
101
  };
@@ -108,8 +108,7 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
108
108
  });
109
109
  } })), _jsx("div", { className: `${classPrefix}-tabs__header-item-wrap`, children: _jsx("div", { ref: navWrapRef, className: `${classPrefix}-tabs__header-item-content`, style: {
110
110
  transform: `translate(${position.offset}px, 0px)`,
111
- }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }) }), showButton &&
112
- position.index + Number('2') < Object.keys(menuOffset).length && (_jsx("div", { className: `${classPrefix}-tabs__header-nav-right`, onClick: () => {
111
+ }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }) }), showButton && position.index + Number('2') < Object.keys(menuOffset).length && (_jsx("div", { className: `${classPrefix}-tabs__header-nav-right`, onClick: () => {
113
112
  const result = menuPosition - menuOffset[position.index + Number('1')];
114
113
  setMenuPosition(result);
115
114
  setPosition({
@@ -81,7 +81,7 @@ export const getFieldsTypeName = (fields) => {
81
81
  else if (type === 'number' && format === 'time') {
82
82
  item.fieldsTypeName = '时间';
83
83
  }
84
- else if (type === 'string' && format === 'x-enum') {
84
+ else if (['string', 'array'].includes(type) && format === 'x-enum') {
85
85
  item.fieldsTypeName = '枚举';
86
86
  }
87
87
  else if (type === 'object' && format === 'x-location') {
@@ -102,6 +102,9 @@ export const getFieldsTypeName = (fields) => {
102
102
  else if (type === 'string' && format === 'related' && fatherAction === 'related') {
103
103
  item.fieldsTypeName = '主子明细';
104
104
  }
105
+ else if (type === 'string' && format === 'related') {
106
+ item.fieldsTypeName = '主子明细';
107
+ }
105
108
  else if (type === 'string' && format === 'father-son') {
106
109
  item.fieldsTypeName = '关联关系';
107
110
  }
@@ -117,6 +120,21 @@ export const getFieldsTypeName = (fields) => {
117
120
  else if (type === 'array' && format === 'one-many') {
118
121
  item.fieldsTypeName = '一对多';
119
122
  }
123
+ else if (format === 'many-one') {
124
+ item.fieldsTypeName = '多对一';
125
+ }
126
+ else if (format === 'one-one') {
127
+ item.fieldsTypeName = '一对一';
128
+ }
129
+ else if (format === 'many-many') {
130
+ item.fieldsTypeName = '多对多';
131
+ }
132
+ else if (format === 'one-many') {
133
+ item.fieldsTypeName = '一对多';
134
+ }
135
+ else if (type === 'string' && format === 'tel') {
136
+ item.fieldsTypeName = '电话';
137
+ }
120
138
  return item;
121
139
  });
122
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.21.1",
3
+ "version": "3.21.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",