@cloudbase/weda-ui 3.11.11 → 3.12.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.
- package/dist/configs/components/dataView.d.ts +1 -0
- package/dist/configs/components/dataView.js +2 -1
- package/dist/configs/components/listView.js +5 -12
- package/dist/configs/components/wd-form-arr.d.ts +4 -1
- package/dist/configs/components/wd-form-arr.js +11 -140
- package/dist/configs/components/wd-form-obj.d.ts +2 -0
- package/dist/configs/components/wd-form-obj.js +13 -1
- package/dist/configs/components/wd-modal.d.ts +10 -1
- package/dist/configs/components/wd-modal.js +52 -1
- package/dist/configs/components/wd-table.d.ts +10 -0
- package/dist/configs/components/wd-table.js +9 -17
- package/dist/configs/components/web-view.d.ts +4 -0
- package/dist/configs/components/web-view.js +19 -1
- package/dist/configs/index.d.ts +44 -4
- package/dist/configs/type-utils/type-form.d.ts +2 -0
- package/dist/configs/type-utils/type-form.js +5 -3
- package/dist/configs/utils/field.d.ts +4 -0
- package/dist/configs/utils/field.js +508 -0
- package/dist/style/index.css +41 -3
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/form/uploader/uploader.pc.d.ts +8 -1
- package/dist/web/components/form/uploader/uploader.pc.js +22 -20
- package/dist/web/components/uploaderView/index.d.ts +8 -1
- package/dist/web/components/uploaderView/index.js +5 -4
- package/dist/web/components/wd-form-item/wd-form-item.js +3 -3
- package/dist/web/components/wd-form-item/wd-input-wrap.js +8 -2
- package/dist/web/components/wd-form-obj/base-form-obj.js +4 -1
- package/dist/web/components/wd-image/ImagePreview.d.ts +1 -0
- package/dist/web/components/wd-image/ImagePreview.js +124 -0
- package/dist/web/components/wd-image/image.d.ts +2 -1
- package/dist/web/components/wd-image/image.js +47 -159
- package/dist/web/components/wd-image/index.d.ts +1 -0
- package/dist/web/components/wd-image/index.js +7 -3
- package/dist/web/components/wd-menu-list/CommonMenuList.js +12 -1
- package/dist/web/components/wd-rich-text/wd-rich-text.js +1 -1
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +7 -12
- package/dist/web/components/wd-select/select/selectUI.js +8 -13
- package/dist/web/components/wd-table/components/FieldRender/ImagePreview.js +8 -1
- package/dist/web/components/wd-table/components/FieldRender/index.js +2 -2
- package/dist/web/components/wd-table/wd-table.js +16 -46
- package/dist/web/components/wd-upload-file/wd-upload-file.js +1 -1
- package/dist/web/components/wd-upload-image/wd-upload-image.js +1 -1
- package/dist/web/components/web-view/web-view.d.ts +2 -0
- package/dist/web/components/web-view/web-view.js +2 -2
- package/dist/web/utils/getModelParams.js +8 -3
- package/package.json +3 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useImperativeHandle, useState, useMemo, useEffect
|
|
2
|
+
import { forwardRef, useImperativeHandle, useState, useMemo, useEffect } from 'react';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
import { ImageInner } from './image';
|
|
5
|
+
import { usePlatform } from '../../utils/platform';
|
|
5
6
|
import { emptyObject } from '../../utils/constant';
|
|
6
7
|
import { useTempUrl } from '../../utils/hooks/use-cloud-id-temp-url';
|
|
7
8
|
import { useConfig } from '../../utils/config-context';
|
|
@@ -10,13 +11,16 @@ export default forwardRef(function WdImage({
|
|
|
10
11
|
// 系统属性
|
|
11
12
|
className, events = emptyObject, style,
|
|
12
13
|
// 组件属性
|
|
13
|
-
src, alt, mode, lazyLoad = false, imgPreview = false, maskClosable = true, fit, id, isStopPropagation = false, }, ref) {
|
|
14
|
+
src, alt, mode, lazyLoad = false, imgPreview = false, maskClosable = true, fit, id, isStopPropagation = false, popupContainer, }, ref) {
|
|
14
15
|
const [isError, setIsError] = useState(false);
|
|
15
16
|
const { classPrefix } = useConfig();
|
|
17
|
+
const platform = usePlatform();
|
|
16
18
|
const cls = classNames({
|
|
17
19
|
[`${classPrefix}-image`]: true,
|
|
18
20
|
[`${classPrefix}-image__error`]: isError,
|
|
19
21
|
[className]: className,
|
|
22
|
+
[`${classPrefix}-${platform}-image`]: true,
|
|
23
|
+
[`${classPrefix}-image__zoom-in`]: imgPreview && !isError,
|
|
20
24
|
});
|
|
21
25
|
const objectFit = fit || getObjectFitByWxImageMode(mode);
|
|
22
26
|
const { data: realSrc, isLoading } = useTempUrl(src);
|
|
@@ -76,7 +80,7 @@ src, alt, mode, lazyLoad = false, imgPreview = false, maskClosable = true, fit,
|
|
|
76
80
|
*
|
|
77
81
|
* 4. 图片src未传,传入undefined,不展示占位符
|
|
78
82
|
*/
|
|
79
|
-
return isLoading || (!isLoading && src === undefined) ? null : (_jsx(ImageInner, { objectFit: realFit, style: realStyle, className: cls, alt: alt, src: realSrc || null, isError: isError, setIsError: setIsError, events: events, lazyLoad: lazyLoad, imgPreview: imgPreview, maskClosable: maskClosable, id: id, isStopPropagation: isStopPropagation }));
|
|
83
|
+
return isLoading || (!isLoading && src === undefined) ? null : (_jsx(ImageInner, { objectFit: realFit, style: realStyle, className: cls, alt: alt, src: realSrc || null, isError: isError, setIsError: setIsError, events: events, lazyLoad: lazyLoad, imgPreview: imgPreview, maskClosable: maskClosable, id: id, isStopPropagation: isStopPropagation, portalContainer: popupContainer }));
|
|
80
84
|
});
|
|
81
85
|
function getObjectFitByWxImageMode(mode) {
|
|
82
86
|
const array = [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useImperativeHandle, useState, useContext, useCallback, useMemo, } from 'react';
|
|
3
|
+
import destr from 'destr';
|
|
3
4
|
import classNames from '../../utils/classnames';
|
|
4
5
|
import { useConfig } from '../../utils/config-context';
|
|
5
6
|
import { usePlatform } from '../../utils/platform';
|
|
@@ -11,7 +12,15 @@ import { MenuLayoutContext } from '../wd-menu-layout/utils';
|
|
|
11
12
|
export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
|
|
12
13
|
const { className = '', style, id } = props;
|
|
13
14
|
const [selected, setSelected] = useState('');
|
|
14
|
-
const [openStatus, setOpenStatus] = useState({
|
|
15
|
+
const [openStatus, setOpenStatus] = useState(() => {
|
|
16
|
+
try {
|
|
17
|
+
const status = localStorage.getItem('menu_open_status');
|
|
18
|
+
return status ? destr(status) : {};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
});
|
|
15
24
|
const platform = usePlatform();
|
|
16
25
|
const menuLayoutContext = useContext(MenuLayoutContext);
|
|
17
26
|
// 样式
|
|
@@ -123,6 +132,8 @@ export const CommonMenuList = forwardRef(function CommonMenuList(props, ref) {
|
|
|
123
132
|
'is-disabled': !!disabled,
|
|
124
133
|
}), title: renderMenuTitle(item), defaultOpened: props.defaultOpened, opened: isOpened, onOpenedChange: (isOpened) => {
|
|
125
134
|
setOpenStatus((prev) => ({ ...prev, [itemKey]: isOpened }));
|
|
135
|
+
const result = { ...openStatus, [itemKey]: isOpened };
|
|
136
|
+
localStorage.setItem('menu_open_status', JSON.stringify(result));
|
|
126
137
|
}, children: children === null || children === void 0 ? void 0 : children.map((el) => renderSubMenu(el, true, String(Number(level) + Number('1')))) }, itemKey)) : (renderMenuItem(item, level));
|
|
127
138
|
};
|
|
128
139
|
return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("div", { id: id, className: classNames(classes, className), style: style, children: _jsx(Menu, { children: menuData === null || menuData === void 0 ? void 0 : menuData.map((item) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
-
import { useState, useImperativeHandle, useMemo, useEffect, useCallback
|
|
3
|
+
import { useState, useImperativeHandle, useMemo, useEffect, useCallback } from 'react';
|
|
4
4
|
import { LoadingTip } from 'tea-component';
|
|
5
5
|
import { SelectUI as Select } from '../select/selectUI';
|
|
6
6
|
import { WdIcon } from '../../wd-icon';
|
|
@@ -48,6 +48,7 @@ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelati
|
|
|
48
48
|
const defaultSize = 50;
|
|
49
49
|
const defaultPage = 1;
|
|
50
50
|
export function RelationSelect(props) {
|
|
51
|
+
var _a;
|
|
51
52
|
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, } = props;
|
|
52
53
|
const { authFields } = useAuthFields({
|
|
53
54
|
dbName: dataSourceName,
|
|
@@ -115,26 +116,20 @@ export function RelationSelect(props) {
|
|
|
115
116
|
}, 500);
|
|
116
117
|
},
|
|
117
118
|
};
|
|
118
|
-
}, [
|
|
119
|
-
getRelationOptions,
|
|
120
|
-
query.pageNo,
|
|
121
|
-
searchOptionListWithWhere,
|
|
122
|
-
setRefreshStatus,
|
|
123
|
-
]);
|
|
119
|
+
}, [getRelationOptions, query.pageNo, searchOptionListWithWhere, setRefreshStatus]);
|
|
124
120
|
const searchHandle = (keyword) => {
|
|
125
121
|
let where = whereList;
|
|
126
122
|
if (keyword === null || keyword === void 0 ? void 0 : keyword.length) {
|
|
127
123
|
// 筛选面板的查询条件与数据过滤的查询条件是且的关系
|
|
128
124
|
where = {
|
|
129
|
-
$and: [
|
|
130
|
-
...whereList,
|
|
131
|
-
{ $and: [{ [primaryField]: { $search: keyword } }] },
|
|
132
|
-
],
|
|
125
|
+
$and: [...whereList, { $and: [{ [primaryField]: { $search: keyword } }] }],
|
|
133
126
|
};
|
|
134
127
|
}
|
|
135
128
|
searchOptionListWithWhere(where);
|
|
136
129
|
onSearch(keyword);
|
|
137
130
|
};
|
|
131
|
+
const primaryFieldTitle = (_a = authFields === null || authFields === void 0 ? void 0 : authFields.find((j) => (j === null || j === void 0 ? void 0 : j.name) === primaryField)) === null || _a === void 0 ? void 0 : _a.title;
|
|
132
|
+
const searchPlaceholder = `搜索主列${primaryFieldTitle}[${primaryField}]`;
|
|
138
133
|
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
134
|
if (!isLoading && customOptions.length < total) {
|
|
140
135
|
setQuery((query) => ({
|
|
@@ -144,7 +139,7 @@ export function RelationSelect(props) {
|
|
|
144
139
|
}
|
|
145
140
|
}, onOpen: () => {
|
|
146
141
|
searchOptionListWithWhere();
|
|
147
|
-
}, footer: addRelationButton, mode: mode }) }));
|
|
142
|
+
}, footer: addRelationButton, mode: mode, searchPlaceholder: searchPlaceholder }) }));
|
|
148
143
|
}
|
|
149
144
|
export function EnumSelect(props) {
|
|
150
145
|
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
|
|
@@ -5,12 +5,12 @@ import { WdFormItemReadOnly } from '../../wd-form-item';
|
|
|
5
5
|
import { Modal } from '../../wd-date/elements/Modal.h5';
|
|
6
6
|
import classNames from '../../../utils/classnames';
|
|
7
7
|
import { useConfig } from '../../../utils/config-context';
|
|
8
|
-
import { usePlatform } from '../../../utils/platform';
|
|
8
|
+
import { usePlatform, textToString } from '../../../utils/platform';
|
|
9
9
|
import { useSyncValue } from '../../../utils/hooks/useSyncValue';
|
|
10
10
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
11
11
|
import AllEmpty from '../../form/select/status/allEmpty';
|
|
12
12
|
import '../style';
|
|
13
|
-
const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomTips, onScrollBottom
|
|
13
|
+
const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomTips, onScrollBottom }) => {
|
|
14
14
|
return (_jsxs(List, { className: "weda-ui-custom-picker__cloumn", style: {
|
|
15
15
|
height: inputFocus ? 'calc(100vh - 190px)' : '250px',
|
|
16
16
|
}, onScrollBottom: onScrollBottom, children: [options === null || options === void 0 ? void 0 : options.map((item, index) => {
|
|
@@ -20,15 +20,12 @@ const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomT
|
|
|
20
20
|
'is-selected': currentSelected.find((i) => i.value === item.value),
|
|
21
21
|
'is-disabled': item.disabled,
|
|
22
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));
|
|
23
|
+
return (_jsx(List.Item, { className: itemCls, onClick: () => optionClick(item), children: _jsx("p", { className: 'weda-ui-custom-picker__cloumn-item-text', children: textToString(item.text) || textToString(item.label) }) }, index));
|
|
24
24
|
}), bottomTips && (_jsx(List.Item, { children: _jsx("div", { className: "weda-ui-custom-picker__status weda-ui-custom-picker__status--empty", children: bottomTips }) }))] }));
|
|
25
25
|
};
|
|
26
26
|
const getSelectedItem = (options = [], value) => {
|
|
27
|
-
if (!value) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
27
|
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));
|
|
28
|
+
return options === null || options === void 0 ? void 0 : options.filter((i) => selectedVal.find((j) => j === i.value) !== undefined);
|
|
32
29
|
};
|
|
33
30
|
function SelectH5(props) {
|
|
34
31
|
const { placeholder, name, disabled, footer, options = [], value, onChange, overlayClassName, searchable, bottomTips, onSearch, onOpen, onScrollBottom, mode, readValue, popupContainer, searchPlaceholder, } = props;
|
|
@@ -156,25 +153,23 @@ export function SelectUI(props) {
|
|
|
156
153
|
const selectedItem = getSelectedItem(options, value);
|
|
157
154
|
if (isMultiple) {
|
|
158
155
|
return selectedItem
|
|
159
|
-
.map((i) => (i === null || i === void 0 ? void 0 : i.label) || i.value)
|
|
156
|
+
.map((i) => textToString(i === null || i === void 0 ? void 0 : i.label) || textToString(i.value))
|
|
160
157
|
.join(',');
|
|
161
158
|
}
|
|
162
159
|
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) || '';
|
|
160
|
+
return textToString((_a = selectedItem[0]) === null || _a === void 0 ? void 0 : _a.label) || textToString((_b = selectedItem[0]) === null || _b === void 0 ? void 0 : _b.value) || '';
|
|
164
161
|
}
|
|
165
162
|
}, [isMultiple, options, value]);
|
|
166
163
|
const render = () => {
|
|
167
164
|
if (platform === 'h5') {
|
|
168
|
-
return
|
|
165
|
+
return _jsx(SelectH5, { ...props, readValue: readValue, searchPlaceholder: searchPlaceholder });
|
|
169
166
|
}
|
|
170
167
|
else if (mode === 'multiple') {
|
|
171
168
|
return (_jsx(SelectMultiple, { popupContainer: popupContainer, button: (selectedItem) => {
|
|
172
169
|
if (!(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.length)) {
|
|
173
170
|
return _jsx("div", { className: "wedatea2td-text-weak", children: placeholder });
|
|
174
171
|
}
|
|
175
|
-
return selectedItem
|
|
176
|
-
.map((i) => (i === null || i === void 0 ? void 0 : i.label) || i.value)
|
|
177
|
-
.join(',');
|
|
172
|
+
return selectedItem.map((i) => (i === null || i === void 0 ? void 0 : i.label) || i.value).join(',');
|
|
178
173
|
}, 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
174
|
}
|
|
180
175
|
else {
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Image from '../../../wd-image';
|
|
3
|
+
import { ImagePreview as ImagePreviewCom } from '../../../wd-image/ImagePreview';
|
|
3
4
|
import { useConfig } from '../../../../utils/config-context';
|
|
4
5
|
export const ImagePreview = ({ srcList }) => {
|
|
5
6
|
const { classPrefix } = useConfig();
|
|
6
7
|
const res = [].concat(srcList);
|
|
7
|
-
return (_jsx("div", { className: `${classPrefix}-table-image-preview`,
|
|
8
|
+
return (_jsx("div", { className: `${classPrefix}-table-image-preview`, onClick: (e) => {
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
}, children: res === null || res === void 0 ? void 0 : res.map((i, index) => (_jsx(ImagePreviewCom, { index: index, previewImageList: res, src: i, children: (open) => {
|
|
11
|
+
return (_jsx("span", { onClick: () => {
|
|
12
|
+
open();
|
|
13
|
+
}, children: _jsx(Image, { src: i, maskClosable: false, alt: '', imgPreview: false, lazyLoad: true }) }));
|
|
14
|
+
} }, index))) }));
|
|
8
15
|
};
|
|
@@ -279,10 +279,10 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
279
279
|
textOverflow: 'ellipsis',
|
|
280
280
|
whiteSpace: 'nowrap',
|
|
281
281
|
overflow: 'hidden',
|
|
282
|
-
}, children: showStr.substring(1) }), ((_l = strRef === null || strRef === void 0 ? void 0 : strRef.current) === null || _l === void 0 ? void 0 : _l.scrollWidth) > ((_m = strRef === null || strRef === void 0 ? void 0 : strRef.current) === null || _m === void 0 ? void 0 : _m.offsetWidth) ? (_jsx("a", { className: "field-array-item", style: { margin: 'auto 2px' }, children: _jsx(QuoteModal, { className: "e-array-view-modal", size: modalSize, text: '更多', children: _jsx(ModalTable, { style: { height: '572px' }, bindMetadata: param, dataSourceType: 'data-model', columnSets: undefined, columnSelectType: 'disabled', whereModal: whereList }) }) })) : (_jsx(_Fragment, {}))] }));
|
|
282
|
+
}, children: showStr.substring(1) }), ((_l = strRef === null || strRef === void 0 ? void 0 : strRef.current) === null || _l === void 0 ? void 0 : _l.scrollWidth) > ((_m = strRef === null || strRef === void 0 ? void 0 : strRef.current) === null || _m === void 0 ? void 0 : _m.offsetWidth) ? (_jsx("a", { className: "field-array-item", style: { margin: 'auto 2px' }, children: _jsx(QuoteModal, { className: "e-array-view-modal", size: modalSize, text: '更多', children: _jsx(ModalTable, { style: { height: isH5 ? 'auto' : '572px' }, bindMetadata: param, dataSourceType: 'data-model', columnSets: undefined, columnSelectType: 'disabled', whereModal: whereList }) }) })) : (_jsx(_Fragment, {}))] }));
|
|
283
283
|
}
|
|
284
284
|
if (format === 'one-many') {
|
|
285
|
-
return (_jsx("a", { className: "field-array-item", children: _jsx(QuoteModal, { className: "e-array-view-modal", size: modalSize, text: '详情', children: _jsx(ModalTable, { style: { height: '572px' }, bindMetadata: param, dataSourceType: 'data-model', columnSets: undefined, columnSelectType: 'disabled', whereModal: whereList }) }) }));
|
|
285
|
+
return (_jsx("a", { className: "field-array-item", children: _jsx(QuoteModal, { className: "e-array-view-modal", size: modalSize, text: '详情', children: _jsx(ModalTable, { style: { height: isH5 ? 'auto' : '572px' }, bindMetadata: param, dataSourceType: 'data-model', columnSets: undefined, columnSelectType: 'disabled', whereModal: whereList }) }) }));
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable max-lines */
|
|
3
|
-
import { useRef, useEffect, useState, useMemo, forwardRef, memo
|
|
3
|
+
import { useRef, useEffect, useState, useMemo, forwardRef, memo } from 'react';
|
|
4
4
|
import { ConfigProvider } from 'tea-component';
|
|
5
5
|
import { Table, ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
|
|
6
6
|
import classNames from '../../utils/classnames';
|
|
@@ -19,7 +19,7 @@ import { useQueryParams } from './hooks/useQueryParams';
|
|
|
19
19
|
import { WdCompError } from '../../utils/error';
|
|
20
20
|
import { getSlots, getFilterFields, getSelectedView, getSortColumns, mapTableDataWithView, checkSupport, DataSourceType, getRecordKey, getCurrentPageData, } from './utils';
|
|
21
21
|
import { Mock } from './mock';
|
|
22
|
-
import { getTableColumns, slotRender, mapColumKey
|
|
22
|
+
import { getTableColumns, slotRender, mapColumKey } from './components/FieldRender';
|
|
23
23
|
import Modal from '../modal';
|
|
24
24
|
import { WdButton } from '../wd-button';
|
|
25
25
|
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
@@ -30,7 +30,7 @@ export const _defaultPageSize = 10;
|
|
|
30
30
|
export const TableOption = function TableOption({ slots, ...props }) {
|
|
31
31
|
return slotRender(slots[CELL_CUSTOM_OPTION], props);
|
|
32
32
|
};
|
|
33
|
-
export const GlobalButton = memo(function GlobalButtonDom({ classPrefix, slots
|
|
33
|
+
export const GlobalButton = memo(function GlobalButtonDom({ classPrefix, slots }) {
|
|
34
34
|
return _jsx("div", { className: `${classPrefix}-global-btn`, children: slotRender(slots) });
|
|
35
35
|
});
|
|
36
36
|
// eslint-disable-next-line complexity
|
|
@@ -92,9 +92,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
92
92
|
// 数据源类型是否是apis
|
|
93
93
|
const isApis = dataSourceType === DataSourceType.CustomConnector;
|
|
94
94
|
const { enabledFieldNames, isNewData, selectedViewIds } = bindMetadata;
|
|
95
|
-
const datasource = isModel
|
|
96
|
-
? bindMetadata.datasource
|
|
97
|
-
: bindConnectMetadata.datasource;
|
|
95
|
+
const datasource = isModel ? bindMetadata.datasource : bindConnectMetadata.datasource;
|
|
98
96
|
const { outParams } = connectorMethod;
|
|
99
97
|
const dbName = datasource === null || datasource === void 0 ? void 0 : datasource.name;
|
|
100
98
|
// 数据源名称
|
|
@@ -144,10 +142,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
144
142
|
initPageIndex = parseInt(initPageIndex);
|
|
145
143
|
initPageSize = parseInt(initPageSize);
|
|
146
144
|
// 排序规则
|
|
147
|
-
const _sort = useMemo(() => {
|
|
148
|
-
var _a;
|
|
149
|
-
return ((_a = sorter === null || sorter === void 0 ? void 0 : sorter.filter((n) => n.orderBy && n.orderType)) === null || _a === void 0 ? void 0 : _a.map((i) => ({ by: i.orderBy, order: i.orderType }))) || [];
|
|
150
|
-
}, [sorter]);
|
|
145
|
+
const _sort = useMemo(() => { var _a; return ((_a = sorter === null || sorter === void 0 ? void 0 : sorter.filter((n) => n.orderBy && n.orderType)) === null || _a === void 0 ? void 0 : _a.map((i) => ({ by: i.orderBy, order: i.orderType }))) || []; }, [sorter]);
|
|
151
146
|
const [queryParams, setQueryParams] = useState({
|
|
152
147
|
pageIndex: initPageIndex,
|
|
153
148
|
pageSize: initPageSize,
|
|
@@ -294,7 +289,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
294
289
|
isSupportMultipleSort,
|
|
295
290
|
});
|
|
296
291
|
// 查询数据
|
|
297
|
-
const { tableData, tableTotal, tableLoading, getNewList, isError, errorObj, emptyTable
|
|
292
|
+
const { tableData, tableTotal, tableLoading, getNewList, isError, errorObj, emptyTable } = useTableData({
|
|
298
293
|
dataSourceAPI,
|
|
299
294
|
dbName,
|
|
300
295
|
connectorMethod,
|
|
@@ -346,9 +341,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
346
341
|
if ((isTableLoading && !isH5) || isNoDataSourceBind) {
|
|
347
342
|
return [];
|
|
348
343
|
}
|
|
349
|
-
if (isTableLoading &&
|
|
350
|
-
isH5 &&
|
|
351
|
-
(queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageIndex) === _defaultPageIndex) {
|
|
344
|
+
if (isTableLoading && isH5 && (queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageIndex) === _defaultPageIndex) {
|
|
352
345
|
return [];
|
|
353
346
|
}
|
|
354
347
|
if (viewFieldsData === null || viewFieldsData === void 0 ? void 0 : viewFieldsData.selectedViewId) {
|
|
@@ -547,6 +540,10 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
547
540
|
});
|
|
548
541
|
}
|
|
549
542
|
},
|
|
543
|
+
// 清空选中项
|
|
544
|
+
clearSelection: () => {
|
|
545
|
+
onSelectChange([], {}, true);
|
|
546
|
+
},
|
|
550
547
|
// 当前页数据
|
|
551
548
|
records: isExpression && !enableTotal
|
|
552
549
|
? getCurrentPageData(dataRef.current.tableRecords, query.pageNo, query.pageSize)
|
|
@@ -563,9 +560,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
563
560
|
defaultPageSize,
|
|
564
561
|
defaultPageIndex,
|
|
565
562
|
dataSourceData: dataRef.current.dataSourceData,
|
|
566
|
-
sort: supportManyRelated
|
|
567
|
-
? query.orderBy
|
|
568
|
-
: [{ orderBy: query.orderBy, orderType: query.orderType }],
|
|
563
|
+
sort: supportManyRelated ? query.orderBy : [{ orderBy: query.orderBy, orderType: query.orderType }],
|
|
569
564
|
filter: supportManyRelated ? query.filter : query === null || query === void 0 ? void 0 : query.where,
|
|
570
565
|
dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
|
|
571
566
|
filterConfig,
|
|
@@ -614,15 +609,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
614
609
|
});
|
|
615
610
|
}
|
|
616
611
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
617
|
-
}, [
|
|
618
|
-
isH5,
|
|
619
|
-
isModel,
|
|
620
|
-
selectedRecords,
|
|
621
|
-
total,
|
|
622
|
-
tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length,
|
|
623
|
-
query.pageNo,
|
|
624
|
-
query.pageSize,
|
|
625
|
-
]);
|
|
612
|
+
}, [isH5, isModel, selectedRecords, total, tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length, query.pageNo, query.pageSize]);
|
|
626
613
|
useEffect(() => {
|
|
627
614
|
if (isModel || isExpression) {
|
|
628
615
|
setQueryParams((queryParams) => ({
|
|
@@ -645,19 +632,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
645
632
|
sort: [],
|
|
646
633
|
}));
|
|
647
634
|
}
|
|
648
|
-
}, [
|
|
649
|
-
defaultPageIndex,
|
|
650
|
-
defaultPageSize,
|
|
651
|
-
connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.pageSize,
|
|
652
|
-
connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.pageNo,
|
|
653
|
-
isModel,
|
|
654
|
-
orderBy,
|
|
655
|
-
orderType,
|
|
656
|
-
connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.orderBy,
|
|
657
|
-
connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.orderType,
|
|
658
|
-
isExpression,
|
|
659
|
-
_sort,
|
|
660
|
-
]);
|
|
635
|
+
}, [defaultPageIndex, defaultPageSize, connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.pageSize, connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.pageNo, isModel, orderBy, orderType, connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.orderBy, connectorParams === null || connectorParams === void 0 ? void 0 : connectorParams.orderType, isExpression, _sort]);
|
|
661
636
|
useEffect(() => {
|
|
662
637
|
if (isH5) {
|
|
663
638
|
setQueryParams((queryParams) => ({ ...queryParams, pageIndex: 1 }));
|
|
@@ -749,18 +724,13 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
749
724
|
const errorMsg = isError ? errorObj : fieldsError;
|
|
750
725
|
return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: authFields, children: _jsxs("div", { className: classNames(wrapClassList, className), style: style, id: id, children: [hasFilterButton && (_jsx(FilterFieldsPanel, { ref: filterMethodsRef, openMobileFilter: openMobileFilter, setOpenMobileFilter: setOpenMobileFilter, filterFields: filterFieldsData, fetchData: onFilterChange, setFilterConfig: setFilterConfig })), _jsxs("div", { className: `${classPrefix}-table-container`, children: [!isH5 && !isNoDataSourceBind && (_jsxs("div", { className: `${classPrefix}-table-wrap-toolbar`, children: [enableGlobalButton && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-start`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) })), (enableRefreshBtn || enableTableHeightSizeBtn) && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-end`, children: _jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
751
726
|
setOpenMobileFilter(true);
|
|
752
|
-
}, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination }) }))] })), isH5 &&
|
|
753
|
-
(enablePagination ||
|
|
754
|
-
enableRefreshBtn ||
|
|
755
|
-
enableTableHeightSizeBtn ||
|
|
756
|
-
hasFilterButton) && (_jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
727
|
+
}, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination }) }))] })), isH5 && (enablePagination || enableRefreshBtn || enableTableHeightSizeBtn || hasFilterButton) && (_jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
757
728
|
setOpenMobileFilter(true);
|
|
758
729
|
}, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination })), _jsx(Table, { events: events, emptyText: emptyText, isH5: isH5, isNoDataSourceBind: isNoDataSourceBind, className: tableClassList, recordKey: recordKey, currentSize: tableHightSize, defaultPageIndex: defaultPageIndex, defaultPageSize: defaultPageSize, sortColumns: sortColumns, enablePagination: !isH5 && enablePagination, columnSelectType: columnSelectType, columns: columns, setColumns: setColumns, records: tableRecords, sort: queryParams.sort, selectedKeys: selectedKeys, onSelectChange: onSelectChange, isLoading: isTableLoading, rowColor: rowColor, queryParams: queryParams, total: total, onQueryChange: onQueryChange, rowClick: rowClick, cellClick: cellClick, isError: errorStatus, errorObj: errorMsg, __innerSlot: __innerSlot }), isH5 && enableGlobalButton && !isNoDataSourceBind && (_jsx("div", { className: `${classPrefix}-h5-table-wrap-footer`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) }))] }), _jsx(ImportFileModal, { columnSets: columnSets, dbName: dbName, datasourceTitle: datasourceTitle, fields: fields, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, isImportFileModalByApiVisible: isImportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, refresh: refreshTable, supportManyRelated: supportManyRelated }), _jsx(ExportFileModal, { whereList: wList, fields: fields, columns: mapColumKey(columns), isExportFileModalByApiVisible: isExportFileModalByApiVisible, selectedKeys: selectedKeys, dbName: dbName, query: query, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible, supportManyRelated: supportManyRelated }), _jsx(InOrOutRecordModal, { dbName: dbName, isInOrOutRecordModalVisible: isInOrOutRecordModalVisible, setIsImportFileModalByApiVisible: setIsImportFileModalByApiVisible, setIsExportFileModalByApiVisible: setIsExportFileModalByApiVisible, setIsInOrOutRecordModalVisible: setIsInOrOutRecordModalVisible }), isH5 && (_jsx(Modal, { overlayClassName: `${classPrefix}-h5-table-overlay`, className: `${classPrefix}-h5-table-option-modal-wrap`, disableCloseIcon: true, title: "\u64CD\u4F5C", visible: isMobileOptionVisible, outerRef: modalRef, events: {
|
|
759
730
|
close: () => {
|
|
760
731
|
setIsMobileOptionVisible(false);
|
|
761
732
|
},
|
|
762
|
-
}, content: '', customContent: _jsx("div", { className: `${classPrefix}-h5-table-option-btn-wrap`, children: enableCellCustomOption &&
|
|
763
|
-
slotRender(slots[CELL_CUSTOM_OPTION], rowData) }), customButton: _jsx(WdButton, { variant: "text", text: "\u53D6\u6D88", events: {
|
|
733
|
+
}, content: '', customContent: _jsx("div", { className: `${classPrefix}-h5-table-option-btn-wrap`, children: enableCellCustomOption && slotRender(slots[CELL_CUSTOM_OPTION], rowData) }), customButton: _jsx(WdButton, { variant: "text", text: "\u53D6\u6D88", events: {
|
|
764
734
|
tap: () => {
|
|
765
735
|
setIsMobileOptionVisible(false);
|
|
766
736
|
},
|
|
@@ -4,6 +4,8 @@ import type { DataType, EventsType } from '../../../configs/components/web-view'
|
|
|
4
4
|
import './style';
|
|
5
5
|
export declare const WebView: React.ForwardRefExoticComponent<CommonPropsType & {
|
|
6
6
|
link: string;
|
|
7
|
+
allow: string;
|
|
8
|
+
sandbox: string;
|
|
7
9
|
} & {
|
|
8
10
|
events: {
|
|
9
11
|
load: (eventDetail: {
|
|
@@ -7,7 +7,7 @@ import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
|
7
7
|
import { Bubble } from 'tea-component';
|
|
8
8
|
import EmptyContent from '../statusContent';
|
|
9
9
|
import './style';
|
|
10
|
-
export const WebView = forwardRef(function WebView({ link = '', events, className, style }, ref) {
|
|
10
|
+
export const WebView = forwardRef(function WebView({ link = '', events, className, style, allow = 'microphone;camera;midi;encrypted-media;geolocation;fullscreen;clipboard-write;clipboard-read;', sandbox = 'allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads', }, ref) {
|
|
11
11
|
const platform = usePlatform();
|
|
12
12
|
const iframeRef = useRef(null);
|
|
13
13
|
// 样式
|
|
@@ -68,5 +68,5 @@ export const WebView = forwardRef(function WebView({ link = '', events, classNam
|
|
|
68
68
|
(events === null || events === void 0 ? void 0 : events.message) && (events === null || events === void 0 ? void 0 : events.message({ data: e.data }));
|
|
69
69
|
}, false);
|
|
70
70
|
}, [events, link]);
|
|
71
|
-
return (_jsx(_Fragment, { children: isInIde() ? (_jsx(_Fragment, { children: _jsx(Bubble, { content: "\u8BE5\u7EC4\u4EF6\u5728\u5C0F\u7A0B\u5E8F\u7AEF\u5C06\u94FA\u6EE1\u6574\u4E2A\u9875\u9762\u5E76\u8986\u76D6\u5176\u4ED6\u7EC4\u4EF6\uFF0C\u5E76\u4E14\u5C0F\u7A0B\u5E8F\u4E3A\u4F01\u4E1A\u4E3B\u4F53\u65F6\u624D\u80FD\u6B63\u5E38\u4F7F\u7528", children: link ? (_jsx("iframe", { src: link, style: style, className: classNames(classes, className) })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) }) })) : (_jsx(_Fragment, { children: link ? (_jsx("iframe", { onLoad: onLoad, onError: () => onError(), ref: iframeRef, id: 'web-view', name: 'web-view', src: link, title: 'web-view', style: style, className: classNames(classes, className) })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) })) }));
|
|
71
|
+
return (_jsx(_Fragment, { children: isInIde() ? (_jsx(_Fragment, { children: _jsx(Bubble, { content: "\u8BE5\u7EC4\u4EF6\u5728\u5C0F\u7A0B\u5E8F\u7AEF\u5C06\u94FA\u6EE1\u6574\u4E2A\u9875\u9762\u5E76\u8986\u76D6\u5176\u4ED6\u7EC4\u4EF6\uFF0C\u5E76\u4E14\u5C0F\u7A0B\u5E8F\u4E3A\u4F01\u4E1A\u4E3B\u4F53\u65F6\u624D\u80FD\u6B63\u5E38\u4F7F\u7528", children: link ? (_jsx("iframe", { src: link, style: style, className: classNames(classes, className) })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) }) })) : (_jsx(_Fragment, { children: link ? (_jsx("iframe", { onLoad: onLoad, onError: () => onError(), ref: iframeRef, id: 'web-view', name: 'web-view', src: link, title: 'web-view', style: style, className: classNames(classes, className), allow: allow, sandbox: sandbox })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) })) }));
|
|
72
72
|
});
|
|
@@ -66,9 +66,7 @@ const getSelectFields = (props) => {
|
|
|
66
66
|
let select = {};
|
|
67
67
|
// 支持自定义查询字段
|
|
68
68
|
if (props.selectFieldType === 'custom') {
|
|
69
|
-
const _selectFields = Array.isArray(props.selectFields)
|
|
70
|
-
? props.selectFields
|
|
71
|
-
: [];
|
|
69
|
+
const _selectFields = Array.isArray(props.selectFields) ? props.selectFields : [];
|
|
72
70
|
_selectFields.forEach((name) => {
|
|
73
71
|
select[name] = true;
|
|
74
72
|
});
|
|
@@ -95,6 +93,13 @@ export const getModelParams = (props) => {
|
|
|
95
93
|
if (((_a = props === null || props === void 0 ? void 0 : props.queryCondition) === null || _a === void 0 ? void 0 : _a.constructor) === Object) {
|
|
96
94
|
params['filter'] = getFilter(props.queryCondition);
|
|
97
95
|
}
|
|
96
|
+
else if (Array.isArray(props === null || props === void 0 ? void 0 : props.queryCondition)) {
|
|
97
|
+
params['filter'] = {
|
|
98
|
+
where: {
|
|
99
|
+
$and: props === null || props === void 0 ? void 0 : props.queryCondition,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
98
103
|
params.select = getSelectFields(props);
|
|
99
104
|
// 处理排序字段
|
|
100
105
|
if (params.orderBy && ['asc', 'desc'].includes(params.orderType)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"description": "腾讯云微搭低代码组件库模板",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@antv/g6": "^4.8.5",
|
|
88
|
-
"@cloudbase/weda-client": "^1.1.
|
|
88
|
+
"@cloudbase/weda-client": "^1.1.13",
|
|
89
89
|
"@codemirror/autocomplete": "^6.16.0",
|
|
90
90
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
91
91
|
"@codemirror/lang-json": "^6.0.1",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"@babel/preset-typescript": "^7.22.15",
|
|
150
150
|
"@cloudbase/cals": "^1.2.5",
|
|
151
151
|
"@cloudbase/lowcode-cli": "^0.21.14",
|
|
152
|
-
"@cloudbase/weda-cloud-sdk": "^1.0.
|
|
152
|
+
"@cloudbase/weda-cloud-sdk": "^1.0.89",
|
|
153
153
|
"@commitlint/cli": "^16.0.2",
|
|
154
154
|
"@commitlint/config-conventional": "^17.7.0",
|
|
155
155
|
"@craco/craco": "^7.1.0",
|