@cloudbase/weda-ui 3.11.10 → 3.12.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 (29) hide show
  1. package/dist/configs/components/wd-form-arr.d.ts +4 -1
  2. package/dist/configs/components/wd-form-arr.js +11 -140
  3. package/dist/configs/components/wd-form-obj.d.ts +2 -0
  4. package/dist/configs/components/wd-form-obj.js +13 -1
  5. package/dist/configs/components/wd-select-multiple.js +1 -1
  6. package/dist/configs/index.d.ts +8 -2
  7. package/dist/configs/type-utils/type-form.d.ts +2 -0
  8. package/dist/configs/type-utils/type-form.js +31 -3
  9. package/dist/configs/utils/field.d.ts +4 -0
  10. package/dist/configs/utils/field.js +508 -0
  11. package/dist/style/index.css +41 -3
  12. package/dist/style/index.scss +1 -1
  13. package/dist/style/weda-ui.min.css +1 -1
  14. package/dist/web/components/form/uploader/uploader.pc.d.ts +3 -1
  15. package/dist/web/components/form/uploader/uploader.pc.js +18 -14
  16. package/dist/web/components/wd-form-item/wd-form-item.js +3 -3
  17. package/dist/web/components/wd-form-obj/base-form-obj.js +4 -1
  18. package/dist/web/components/wd-image/ImagePreview.d.ts +1 -0
  19. package/dist/web/components/wd-image/ImagePreview.js +127 -0
  20. package/dist/web/components/wd-image/image.js +45 -155
  21. package/dist/web/components/wd-image/index.js +4 -0
  22. package/dist/web/components/wd-menu-list/CommonMenuList.js +12 -1
  23. package/dist/web/components/wd-rich-text/wd-rich-text.js +1 -1
  24. package/dist/web/components/wd-table/components/FieldRender/ImagePreview.js +8 -1
  25. package/dist/web/components/wd-table/components/FieldRender/index.js +2 -2
  26. package/dist/web/components/wd-table/hooks/useChooseList.js +2 -2
  27. package/dist/web/components/wd-upload-file/wd-upload-file.js +1 -1
  28. package/dist/web/components/wd-upload-image/wd-upload-image.js +1 -1
  29. package/package.json +3 -3
@@ -12,11 +12,13 @@ interface TempFileProps {
12
12
  export declare function UploaderPCInner(props: PropsType): JSX.Element;
13
13
  export interface TcbImageProps {
14
14
  fileID?: string;
15
+ allFile?: TempFileProps[];
15
16
  tempFile?: TempFileProps;
17
+ index?: number;
16
18
  isZoom?: boolean;
17
19
  onError?: (e: unknown) => void;
18
20
  imgTypeCls?: string;
19
- preivewIcon?: string;
21
+ previewIcon?: string;
20
22
  actions?: React.ReactNode;
21
23
  }
22
24
  export declare const TcbImage: (props: TcbImageProps) => JSX.Element;
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { Upload, Icon, ErrorTip, ImagePreview, ConfigProvider, } from 'tea-component';
3
+ import { Upload, Icon, ErrorTip, ConfigProvider } from 'tea-component';
4
4
  import { useTempUrl } from '../../../utils/hooks/use-cloud-id-temp-url';
5
5
  import { toBase64Uri } from '../../../utils/file2base64';
6
6
  import { isNil } from '../../../utils/lodash';
7
7
  import { errorHandler } from '../../../utils/error';
8
8
  import { WdIcon } from '../../wd-icon';
9
9
  import { useUploader } from './useUploadFile';
10
+ import { ImagePreview } from '../../wd-image/ImagePreview';
10
11
  // 默认组件类前缀
11
12
  export const CLASS_PREFIX = 'weda-uploader-pc';
12
13
  // 默认图片类型
@@ -119,7 +120,7 @@ export function UploaderPCInner(props) {
119
120
  tips && (extraProps['title'] = tips);
120
121
  maxSize && (extraProps['maxSize'] = maxSize * 1024 * 1024);
121
122
  const hasActions = !uploading && !readOnly && !(disabled || sourceType === 'camera');
122
- return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsxs("div", { className: "_weda-fn-upload-result", children: [tempFile === null || tempFile === void 0 ? void 0 : tempFile.map((d) => (_jsx("div", { className: `_weda-fn-upload-result__item ${imgTypeCls}`, children: _jsx(TcbImage, { tempFile: d, imgTypeCls: imgTypeCls, isZoom: true, preivewIcon: "td:browse", actions: hasActions && (_jsx(WdIcon, { className: `${CLASS_PREFIX}__image-actions-delete`, name: "td:delete", onClick: () => deleteHandle(d), size: "sm" })) }) }, d.key))), _jsxs("div", { className: `${CLASS_PREFIX}__input-box`, children: [readOnly && tempFile.length < 1 && _jsx("div", { children: "-" }), sourceType === 'camera' || (disabled && !readOnly) ? (_jsx("li", { className: `_weda-fn-upload-result__item wedatea2td-disabled ${imgTypeCls}`, children: _jsxs("div", { className: "_weda-fn-upload-result__status", children: [_jsx("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }), _jsx("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset", children: btnTitle })] }) })) : (((!single && tempFile.length < maxUploadCount) ||
123
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsxs("div", { className: "_weda-fn-upload-result", children: [tempFile === null || tempFile === void 0 ? void 0 : tempFile.map((d, index) => (_jsx("div", { className: `_weda-fn-upload-result__item ${imgTypeCls}`, children: _jsx(TcbImage, { index: index, allFile: tempFile, tempFile: d, imgTypeCls: imgTypeCls, isZoom: true, previewIcon: "td:browse", actions: hasActions && (_jsx(WdIcon, { className: `${CLASS_PREFIX}__image-actions-delete`, name: "td:delete", onClick: () => deleteHandle(d), size: "sm" })) }) }, d.key))), _jsxs("div", { className: `${CLASS_PREFIX}__input-box`, children: [readOnly && tempFile.length < 1 && _jsx("div", { children: "-" }), sourceType === 'camera' || (disabled && !readOnly) ? (_jsx("li", { className: `_weda-fn-upload-result__item wedatea2td-disabled ${imgTypeCls}`, children: _jsxs("div", { className: "_weda-fn-upload-result__status", children: [_jsx("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }), _jsx("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset", children: btnTitle })] }) })) : (((!single && tempFile.length < maxUploadCount) ||
123
124
  (single && tempFile.length < 1 && !uploading)) &&
124
125
  !readOnly && (
125
126
  // single 模式时,当数组为空且不在上传文件过程中时显示
@@ -132,13 +133,13 @@ export function UploaderPCInner(props) {
132
133
  className: `_weda-fn-upload-result__item _weda-fn-upload-result__item--upload ${imgTypeCls}`, children: [imgTypeCls, _jsxs("div", { className: "_weda-fn-upload-result__status", children: [_jsx("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }), _jsx("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset", children: btnTitle })] })] }) })))] })] }) }));
133
134
  }
134
135
  export const TcbImage = (props) => {
135
- const { fileID, tempFile = { progress: 100, loading: false, realUrl: null, tempUrl: null }, isZoom, imgTypeCls, preivewIcon, actions, ...rest } = props;
136
+ const { fileID, tempFile = { progress: 100, loading: false, realUrl: null, tempUrl: null }, isZoom, imgTypeCls, previewIcon, actions, allFile, index, ...rest } = props;
136
137
  const { progress, loading, realUrl, tempUrl } = tempFile;
137
138
  const fileCloudID = (realUrl !== null && realUrl !== void 0 ? realUrl : tempUrl) || fileID;
138
139
  const [isError, setIsError] = React.useState(false);
139
140
  const { data: src, error: requestError } = useTempUrl(fileCloudID);
140
141
  const encodeSrc = encodeConvert(src);
141
- const renderImg = () => {
142
+ const renderImg = (open) => {
142
143
  if (isError || requestError)
143
144
  return _jsx(ErrorTip, {});
144
145
  if (!src)
@@ -146,28 +147,31 @@ export const TcbImage = (props) => {
146
147
  return (_jsxs(_Fragment, { children: [_jsx("img", { "data-testid": "uploaderpc_imgStyle", className: `${CLASS_PREFIX}__image ${imgTypeCls}`, ...rest, src: encodeURI(encodeSrc), onError: (e) => {
147
148
  setIsError(true);
148
149
  (props === null || props === void 0 ? void 0 : props.onError) && props.onError(e);
150
+ }, onClick: () => {
151
+ if (open) {
152
+ open();
153
+ }
149
154
  } }), loading && (_jsxs("div", { className: "_weda-fn-upload-result__status loading_bac", children: [_jsx(Icon, { type: "loading" }), _jsxs("div", { className: "wedatea2td-mt-1n wedatea2td-fz-reset", children: [progress, "%"] })] }))] }));
150
155
  };
151
156
  if (!isZoom)
152
157
  return renderImg();
158
+ const previewImageList = allFile.map((i) => i.realUrl || i.tempUrl);
153
159
  const previewProps = {
154
- key: fileCloudID,
160
+ index,
155
161
  'data-testid': 'uploaderpc_imgStyle',
156
162
  className: `${CLASS_PREFIX}__image ${imgTypeCls}`,
157
- ...rest,
158
- previewSrc: encodeURI(encodeSrc),
159
- onError: (e) => {
160
- setIsError(true);
161
- (props === null || props === void 0 ? void 0 : props.onError) && props.onError(e);
162
- },
163
+ src: encodeURI(encodeSrc),
164
+ previewImageList,
163
165
  };
164
- if (preivewIcon || actions) {
166
+ if (previewIcon || actions) {
165
167
  return (_jsx(ImagePreview, { ...previewProps, children: (open) => {
166
- return (_jsxs(_Fragment, { children: [renderImg(), _jsxs("div", { className: `_weda-fn-upload-result__op ${imgTypeCls} ${CLASS_PREFIX}__image-actions`, children: [preivewIcon && (_jsx(WdIcon, { name: preivewIcon, onClick: open, className: `${CLASS_PREFIX}__image-actions-open`, size: "sm" })), actions && (_jsxs("span", { className: `${CLASS_PREFIX}__image-actions-separator`, children: [' ', "|", ' '] })), actions] })] }));
168
+ return (_jsxs(_Fragment, { children: [renderImg(), _jsxs("div", { className: `_weda-fn-upload-result__op ${imgTypeCls} ${CLASS_PREFIX}__image-actions`, children: [previewIcon && (_jsx(WdIcon, { name: previewIcon, onClick: open, className: `${CLASS_PREFIX}__image-actions-open`, size: "sm" })), actions && (_jsx("span", { className: `${CLASS_PREFIX}__image-actions-separator`, children: "|" })), actions] })] }));
167
169
  } }));
168
170
  }
169
171
  else {
170
- return _jsx(ImagePreview, { ...previewProps, src: encodeURI(encodeSrc) });
172
+ return (_jsx(ImagePreview, { ...previewProps, children: (open) => {
173
+ return renderImg(open);
174
+ } }));
171
175
  }
172
176
  };
173
177
  //兼容私有化下载链接encodeURIComponent被编码情况
@@ -66,9 +66,9 @@ export function WdFormItem(props) {
66
66
  const Message = validateErrorMsg && (_jsx("p", { className: `${item}__help`, children: _jsx("span", { className: `${classPrefix}-g-text-${validateState} ${root}__error`, children: textToString(validateErrorMsg) }) }));
67
67
  if (!visible)
68
68
  return null;
69
- return (_jsxs("div", { className: cls, id: isRoot ? id : null, style: style, children: [_jsx("div", { className: itemWrap, children: LabelContainer ? (_jsx(LabelContainerComp, { LabelContainer: LabelContainer, isRoot: isRoot, isH5: isH5, Label: Label, Item: Item })) : (_jsxs(_Fragment, { children: [Label, Item] })) }), Message, Help] }));
69
+ return (_jsxs("div", { className: cls, id: isRoot ? id : null, style: style, children: [_jsx("div", { className: itemWrap, children: LabelContainer ? (_jsx(LabelContainerComp, { LabelContainer: LabelContainer, isRoot: isRoot, isH5: isH5, Label: Label, Item: Item, mode: props === null || props === void 0 ? void 0 : props.mode })) : (_jsxs(_Fragment, { children: [Label, Item] })) }), Message, Help] }));
70
70
  }
71
- const LabelContainerComp = ({ isRoot, isH5, Label, Item, LabelContainer }) => {
71
+ const LabelContainerComp = ({ isRoot, isH5, Label, Item, LabelContainer, mode, }) => {
72
72
  const showLabel = isRoot && !isH5;
73
- return (_jsxs(_Fragment, { children: [showLabel && Label, _jsx(LabelContainer, { isRoot: isRoot, Label: Label, Item: Item })] }));
73
+ return (_jsxs(_Fragment, { children: [showLabel && Label, _jsx(LabelContainer, { isRoot: isRoot, Label: Label, Item: Item, mode: mode })] }));
74
74
  };
@@ -27,7 +27,7 @@ const classRoot = 'form-obj';
27
27
  */
28
28
  const getValueName = (operateName, currentName) => operateName.replace(new RegExp(`^${currentName}(\\.)?`), '');
29
29
  const LabelContainer = (props) => {
30
- const { Label, Item } = props || {};
30
+ const { Label, Item, mode } = props || {};
31
31
  const cardRef = React.createRef();
32
32
  const [iconName, setIconName] = useState('chevronup');
33
33
  const headerSlot = (_jsxs(_Fragment, { children: [_jsx(WdIcon, { name: iconName, events: {
@@ -35,6 +35,9 @@ const LabelContainer = (props) => {
35
35
  setIconName(iconName === 'chevrondown' ? 'chevronup' : 'chevrondown');
36
36
  },
37
37
  } }), Label] }));
38
+ if (mode === 'custom' || mode === 'table') {
39
+ return _jsx(_Fragment, { children: Item });
40
+ }
38
41
  return (_jsx(WdCard, { ref: cardRef, className: iconName === 'chevrondown' ? 'wd-card-content__hidden' : '', showContent: true, headerSlot: headerSlot, contentSlot: Item, events: { tap: () => { } } }));
39
42
  };
40
43
  export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
@@ -0,0 +1 @@
1
+ export declare const ImagePreview: (props: any) => JSX.Element;
@@ -0,0 +1,127 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import React, { useState, useMemo } from 'react';
4
+ import { useGesture } from '@use-gesture/react';
5
+ import { Portal } from '../common/portal';
6
+ import { useConfig } from '../../utils/config-context';
7
+ import { usePlatform } from '../../utils/platform';
8
+ import { useSyncValue } from '../../utils/hooks/useSyncValue';
9
+ import isObjectEqual from '../../utils/isObjectEqual';
10
+ import { useTempUrl } from '../../utils/hooks/use-cloud-id-temp-url';
11
+ import { WdIcon } from '../wd-icon';
12
+ const ASPECT_RATIO = 1;
13
+ export const ImagePreview = (props) => {
14
+ const { portalContainer, isStopPropagation = false, maskClosable = false, src, style = {}, children, previewImageList = [], index = 0, } = props;
15
+ // cloud 或者 https
16
+ const [currentImg, setCurrentImg] = useSyncValue(previewImageList[index], isObjectEqual);
17
+ const [visible, setVisible] = useState(false);
18
+ const platform = usePlatform();
19
+ const [translateX, setTranslateX] = React.useState(0);
20
+ const [translateY, setTranslateY] = React.useState(0);
21
+ const [previewScale, setPreviewScale] = React.useState(ASPECT_RATIO);
22
+ const [rotate, setRotate] = React.useState(0);
23
+ const { data: realSrc } = useTempUrl(currentImg);
24
+ const previewStyle = platform === 'h5'
25
+ ? {
26
+ touchAction: 'none',
27
+ backgroundImage: `url('${realSrc || src}')`,
28
+ transform: `translate(${translateX}px, ${translateY}px) scale(${previewScale})`,
29
+ ...style,
30
+ }
31
+ : {
32
+ touchAction: 'none',
33
+ backgroundImage: `url('${realSrc || src}')`,
34
+ transform: `rotate(${rotate}deg)`,
35
+ ...style,
36
+ };
37
+ const { classPrefix } = useConfig();
38
+ React.useEffect(() => {
39
+ // 防止触发浏览器的放大缩小
40
+ const handler = (e) => e.preventDefault();
41
+ document.addEventListener('gesturestart', handler);
42
+ document.addEventListener('gesturechange', handler);
43
+ return () => {
44
+ document.removeEventListener('gesturestart', handler);
45
+ document.removeEventListener('gesturechange', handler);
46
+ };
47
+ }, []);
48
+ const onMaskClick = (e) => {
49
+ if (isStopPropagation) {
50
+ e.stopPropagation();
51
+ }
52
+ if (maskClosable) {
53
+ setVisible(false);
54
+ }
55
+ };
56
+ const bind = useGesture({
57
+ onClick: ({ event }) => {
58
+ // 防止冒泡出发关闭预览
59
+ event.stopPropagation();
60
+ if (maskClosable) {
61
+ setVisible(false);
62
+ }
63
+ },
64
+ onPinch: ({ offset }) => {
65
+ const [s] = offset;
66
+ setPreviewScale(s);
67
+ },
68
+ onDrag: ({ offset, event }) => {
69
+ event.stopPropagation();
70
+ const [x, y] = offset;
71
+ setTranslateX(x);
72
+ setTranslateY(y);
73
+ },
74
+ }, {
75
+ drag: {
76
+ delay: true,
77
+ preventDefault: true,
78
+ from: () => [translateX, translateY],
79
+ },
80
+ pinch: {
81
+ scaleBounds: { min: 0.6, max: 5 },
82
+ pointer: {
83
+ touch: true,
84
+ },
85
+ },
86
+ });
87
+ const child = useMemo(() => {
88
+ return children(() => {
89
+ setVisible(true);
90
+ // 重置
91
+ setPreviewScale(ASPECT_RATIO);
92
+ setRotate(0);
93
+ setTranslateX(0);
94
+ setTranslateY(0);
95
+ });
96
+ }, [children]);
97
+ return (_jsxs(_Fragment, { children: [child, visible && (_jsx(Portal, { type: "div", portalContainer: portalContainer, children: _jsx("div", { "data-testid": "portal-container", style: { zIndex: 1001, position: 'relative' }, className: `${classPrefix}-image-preview-container`, children: _jsxs("div", { className: `${classPrefix}-image-mask`, onClick: onMaskClick, children: [_jsx("div", { onClick: (e) => {
98
+ if (isStopPropagation) {
99
+ e.stopPropagation();
100
+ }
101
+ setVisible(false);
102
+ }, className: `${classPrefix}-image-mask__close-btn`, children: _jsx("i", { className: `${classPrefix}-image-mask__icon-close` }) }), _jsx("div", { ...bind(), className: `${classPrefix}-image-preview`, style: previewStyle }), platform === 'pc' && (_jsxs("div", { className: `${classPrefix}-image-preview-toolbar`, children: [(previewImageList === null || previewImageList === void 0 ? void 0 : previewImageList.length) > 1 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "wd-icon-wrap wd-event-tap", children: _jsx(WdIcon, { name: 'td:chevron-left', size: "sm", events: {
103
+ tap: () => {
104
+ const index = previewImageList.findIndex((i) => i === currentImg);
105
+ const currentIndex = index === 0
106
+ ? previewImageList.length - 1
107
+ : index - 1;
108
+ setCurrentImg(previewImageList[currentIndex]);
109
+ setRotate(0);
110
+ },
111
+ } }) }), _jsx("span", { className: "wd-icon-wrap wd-event-tap", children: _jsx(WdIcon, { name: 'td:chevron-right', size: "sm", events: {
112
+ tap: () => {
113
+ const index = previewImageList.findIndex((i) => i === currentImg);
114
+ const currentIndex = index === previewImageList.length - 1
115
+ ? 0
116
+ : index + 1;
117
+ setCurrentImg(previewImageList[currentIndex]);
118
+ setRotate(0);
119
+ },
120
+ } }) })] })), _jsx("span", { className: "wd-icon-wrap wd-event-tap", children: _jsx(WdIcon, { name: 'td:anticlockwise', size: "sm", events: {
121
+ tap: (arg, { originEvent: e }) => {
122
+ e.stopPropagation();
123
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
124
+ setRotate(rotate + 90);
125
+ },
126
+ } }) })] }))] }) }) }))] }));
127
+ };
@@ -1,27 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { usePlatform } from '../../utils/platform';
4
- import { useGesture } from '@use-gesture/react';
5
- import { useConfig } from '../../utils/config-context';
6
4
  import { useRef } from 'react';
7
- import { Portal } from '../common/portal';
5
+ import { ImagePreview } from './ImagePreview';
8
6
  const ASPECT_RASIO = 1;
9
7
  const OFFSET_RASIO = 0.5;
10
- const SCALE_RASIO_PC = 0.8;
11
- const SCALE_RASIO_H5 = 1;
8
+ const SCALE_RADIO_PC = 0.8;
9
+ const SCALE_RADIO_H5 = 1;
12
10
  export function ImageInner({ objectFit, style, className, alt, src, isError, setIsError, events, lazyLoad, maskClosable, imgPreview, id, isStopPropagation, }) {
13
11
  var _a;
14
- const { classPrefix } = useConfig();
15
12
  const platform = usePlatform();
16
- const [imgShow, setImgShow] = React.useState(false);
17
- const onMaskClick = (e) => {
18
- if (isStopPropagation) {
19
- e.stopPropagation();
20
- }
21
- if (maskClosable) {
22
- setImgShow(false);
23
- }
24
- };
25
13
  const portalContainer = useRef((_a = document.getElementById('root')) !== null && _a !== void 0 ? _a : document.body);
26
14
  const [showHeight, setShowHeight] = React.useState(0);
27
15
  const [showWidth, setShowWidth] = React.useState(0);
@@ -29,143 +17,45 @@ export function ImageInner({ objectFit, style, className, alt, src, isError, set
29
17
  const realHeight = React.useRef(0);
30
18
  const [offsetHeight, setOffsetHeight] = React.useState(0);
31
19
  const [offsetWidth, setOffsetWidth] = React.useState(0);
32
- const [translateX, setTranslateX] = React.useState(0);
33
- const [translateY, setTranslateY] = React.useState(0);
34
- const [previewScale, setPreviewScale] = React.useState(ASPECT_RASIO);
35
- React.useEffect(() => {
36
- // 防止触发浏览器的放大缩小
37
- const handler = (e) => e.preventDefault();
38
- document.addEventListener('gesturestart', handler);
39
- document.addEventListener('gesturechange', handler);
40
- return () => {
41
- document.removeEventListener('gesturestart', handler);
42
- document.removeEventListener('gesturechange', handler);
43
- };
44
- }, []);
45
- const bind = useGesture({
46
- onClick: ({ event }) => {
47
- // 防止冒泡出发关闭预览
48
- event.stopPropagation();
49
- if (maskClosable) {
50
- setImgShow(false);
51
- }
52
- },
53
- onPinch: ({ offset }) => {
54
- const [s] = offset;
55
- setPreviewScale(s);
56
- },
57
- onDrag: ({ offset, event }) => {
58
- event.stopPropagation();
59
- const [x, y] = offset;
60
- setTranslateX(x);
61
- setTranslateY(y);
62
- },
63
- }, {
64
- drag: {
65
- delay: true,
66
- preventDefault: true,
67
- from: () => [translateX, translateY],
68
- },
69
- pinch: {
70
- scaleBounds: { min: 0.6, max: 5 },
71
- pointer: {
72
- touch: true,
73
- },
74
- },
75
- });
76
- if (platform === 'h5' || !imgPreview || isError) {
77
- return (_jsxs(_Fragment, { children: [_jsx("img", { "data-testid": "wd-image", id: id, style: {
78
- objectFit,
79
- ...style,
80
- }, className: `${className} wd-h5-image`, alt: alt, src: src, onLoad: (e) => {
81
- const img = e.target;
82
- const { naturalHeight, naturalWidth } = img;
83
- realHeight.current = naturalHeight;
84
- realWidth.current = naturalWidth;
85
- setIsError(false);
86
- events.load && events.load({}, { originEvent: e });
87
- }, onError: (e) => {
88
- setIsError(true);
89
- events.error && events.error({}, { originEvent: e });
90
- }, onClick: (e) => {
91
- if (isStopPropagation) {
92
- e.stopPropagation();
93
- }
94
- if (imgPreview && !isError) {
95
- setTranslateX(0);
96
- setTranslateY(0);
97
- setPreviewScale(ASPECT_RASIO);
98
- const windowHeight = window.innerHeight;
99
- const windowWidth = window.innerWidth;
100
- const widthRasio = (windowWidth * SCALE_RASIO_H5) / realWidth.current;
101
- const heightRasio = (windowHeight * SCALE_RASIO_H5) / realHeight.current;
102
- const scale = Math.min(widthRasio, heightRasio, ASPECT_RASIO) || ASPECT_RASIO;
103
- setOffsetHeight((windowHeight - realHeight.current * scale) * OFFSET_RASIO);
104
- setOffsetWidth((windowWidth - realWidth.current * scale) * OFFSET_RASIO);
105
- setShowHeight(realHeight.current * scale);
106
- setShowWidth(realWidth.current * scale);
107
- setImgShow(true);
108
- }
109
- events.tap && events.tap({}, { originEvent: e });
110
- }, loading: lazyLoad ? 'lazy' : undefined }), imgShow && (_jsx(Portal, { type: "div", portalContainer: portalContainer, children: _jsx("div", { "data-testid": "portal-container", style: { zIndex: 1001, position: 'relative' }, className: `${classPrefix}-image-preview-container`, children: _jsxs("div", { className: `${classPrefix}-image-mask`, onClick: onMaskClick, children: [_jsx("div", { onClick: (e) => {
111
- if (isStopPropagation) {
112
- e.stopPropagation();
113
- }
114
- setImgShow(false);
115
- }, className: `${classPrefix}-image-mask__close-btn`, children: _jsx("i", { className: `${classPrefix}-image-mask__icon-close` }) }), _jsx("div", { ...bind(), className: `${classPrefix}-image-preview`, style: {
116
- touchAction: 'none',
117
- backgroundImage: `url('${src}')`,
118
- transform: `translate(${translateX}px, ${translateY}px) scale(${previewScale})`,
119
- width: showWidth,
120
- height: showHeight,
121
- marginTop: offsetHeight,
122
- marginLeft: offsetWidth,
123
- } })] }) }) }))] }));
124
- }
125
- else {
126
- return (_jsxs(_Fragment, { children: [_jsx("img", { "data-testid": "wd-image", id: id, style: {
127
- objectFit,
128
- cursor: 'zoom-in',
129
- ...style,
130
- }, className: `${className} wd-pc-image`, alt: alt, src: src, onLoad: (e) => {
131
- const img = e.target;
132
- const { naturalHeight, naturalWidth } = img;
133
- realHeight.current = naturalHeight;
134
- realWidth.current = naturalWidth;
135
- setIsError(false);
136
- events.load && events.load({}, { originEvent: e });
137
- }, onError: (e) => {
138
- setIsError(true);
139
- events.error && events.error({}, { originEvent: e });
140
- }, loading: lazyLoad ? 'lazy' : undefined, onClick: (e) => {
141
- if (isStopPropagation) {
142
- e.stopPropagation();
143
- }
144
- if (imgPreview && !isError) {
145
- const windowHeight = window.innerHeight;
146
- const windowWidth = window.innerWidth;
147
- const widthRasio = (windowWidth * SCALE_RASIO_PC) / realWidth.current;
148
- const heightRasio = (windowHeight * SCALE_RASIO_PC) / realHeight.current;
149
- const scale = Math.min(widthRasio, heightRasio, ASPECT_RASIO) || ASPECT_RASIO;
150
- setOffsetHeight((windowHeight - realHeight.current * scale) * OFFSET_RASIO);
151
- setOffsetWidth((windowWidth - realWidth.current * scale) * OFFSET_RASIO);
152
- setShowHeight(realHeight.current * scale);
153
- setShowWidth(realWidth.current * scale);
154
- setImgShow(true);
155
- }
156
- events.tap && events.tap({}, { originEvent: e });
157
- } }), imgShow && (_jsx(Portal, { type: "div", portalContainer: portalContainer, children: _jsx("div", { "data-testid": "portal-container", style: { zIndex: 1001, position: 'relative' }, className: `${classPrefix}-image-preview-container`, children: _jsxs("div", { className: `${classPrefix}-image-mask`, onClick: onMaskClick, children: [_jsx("div", { onClick: (e) => {
158
- if (isStopPropagation) {
159
- e.stopPropagation();
160
- }
161
- setImgShow(false);
162
- }, className: `${classPrefix}-image-mask__close-btn`, children: _jsx("i", { className: `${classPrefix}-image-mask__icon-close` }) }), _jsx("div", { ...bind(), className: `${classPrefix}-image-preview`, style: {
163
- touchAction: 'none',
164
- backgroundImage: `url('${src}')`,
165
- width: showWidth,
166
- height: showHeight,
167
- marginTop: offsetHeight,
168
- marginLeft: offsetWidth,
169
- } })] }) }) }))] }));
170
- }
20
+ const SCALE_RADIO = platform === 'h5' ? SCALE_RADIO_H5 : SCALE_RADIO_PC;
21
+ const previewStyle = {
22
+ width: showWidth,
23
+ height: showHeight,
24
+ marginTop: offsetHeight,
25
+ marginLeft: offsetWidth,
26
+ };
27
+ return (_jsx(ImagePreview, { portalContainer: portalContainer, maskClosable: maskClosable, style: previewStyle, src: src, children: (open) => {
28
+ return (_jsx("img", { "data-testid": "wd-image", id: id, style: {
29
+ objectFit,
30
+ ...style,
31
+ }, className: `${className}`, alt: alt, src: src, onLoad: (e) => {
32
+ const img = e.target;
33
+ const { naturalHeight, naturalWidth } = img;
34
+ realHeight.current = naturalHeight;
35
+ realWidth.current = naturalWidth;
36
+ setIsError(false);
37
+ events.load && events.load({}, { originEvent: e });
38
+ }, onError: (e) => {
39
+ setIsError(true);
40
+ events.error && events.error({}, { originEvent: e });
41
+ }, onClick: (e) => {
42
+ if (isStopPropagation) {
43
+ e.stopPropagation();
44
+ }
45
+ events.tap && events.tap({}, { originEvent: e });
46
+ if (imgPreview && !isError) {
47
+ const windowHeight = window.innerHeight;
48
+ const windowWidth = window.innerWidth;
49
+ const widthRasio = (windowWidth * SCALE_RADIO) / realWidth.current;
50
+ const heightRasio = (windowHeight * SCALE_RADIO) / realHeight.current;
51
+ const scale = Math.min(widthRasio, heightRasio, ASPECT_RASIO) ||
52
+ ASPECT_RASIO;
53
+ setOffsetHeight((windowHeight - realHeight.current * scale) * OFFSET_RASIO);
54
+ setOffsetWidth((windowWidth - realWidth.current * scale) * OFFSET_RASIO);
55
+ setShowHeight(realHeight.current * scale);
56
+ setShowWidth(realWidth.current * scale);
57
+ open();
58
+ }
59
+ }, loading: lazyLoad ? 'lazy' : undefined }));
60
+ } }));
171
61
  }
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
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';
@@ -13,10 +14,13 @@ className, events = emptyObject, style,
13
14
  src, alt, mode, lazyLoad = false, imgPreview = false, maskClosable = true, fit, id, isStopPropagation = false, }, 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`]: platform === 'h5' || !imgPreview || isError,
20
24
  });
21
25
  const objectFit = fit || getObjectFitByWxImageMode(mode);
22
26
  const { data: realSrc, isLoading } = useTempUrl(src);
@@ -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) => {
@@ -18,7 +18,7 @@ export const WdRichText = forwardRef(function WdRichText(props, ref) {
18
18
  ...trait,
19
19
  classRoot,
20
20
  readOnly: false,
21
- size: 'lg',
21
+ size: 'md',
22
22
  };
23
23
  if (!visible)
24
24
  return null;
@@ -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`, children: res === null || res === void 0 ? void 0 : res.map((i, index) => (_jsx(Image, { src: i, maskClosable: false, alt: '', imgPreview: true, lazyLoad: true, isStopPropagation: true }, index))) }));
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 {
@@ -61,7 +61,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
61
61
  db: childDbName,
62
62
  }),
63
63
  ];
64
- if (value === null || value === void 0 ? void 0 : value.length) {
64
+ if (value) {
65
65
  if (isMultiple) {
66
66
  value.forEach((i) => {
67
67
  if (i) {
@@ -94,7 +94,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
94
94
  setTotal(result === null || result === void 0 ? void 0 : result.total);
95
95
  setLoading(false);
96
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
97
- }, [childDbName, primaryColumn, queryParams]);
97
+ }, [childDbName, primaryColumn, queryParams, value]);
98
98
  useEffect(() => {
99
99
  if (childDbName) {
100
100
  fetchData();
@@ -30,7 +30,7 @@ export const WdUploadFile = forwardRef(function WdUploadFile(props, ref) {
30
30
  ...trait,
31
31
  classRoot,
32
32
  readOnly: false,
33
- size: 'lg',
33
+ size: 'md',
34
34
  };
35
35
  if (!visible)
36
36
  return null;
@@ -30,7 +30,7 @@ export const WdUploadImage = forwardRef(function WdUploadImage(props, ref) {
30
30
  ...trait,
31
31
  classRoot,
32
32
  readOnly: false,
33
- size: 'lg',
33
+ size: 'md',
34
34
  };
35
35
  if (!visible)
36
36
  return null;