@zat-design/sisyphus-react 4.7.2-beta.2 → 4.7.2

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.
@@ -15,7 +15,7 @@ const TextAreaDef = (props) => {
15
15
  const isView = typeof props.isView === "boolean" ? props.isView : isViewCon;
16
16
  const initialConfig = useProConfig("TextArea");
17
17
  if (isView) {
18
- return /* @__PURE__ */ jsx(Container, { nowrap: false, tooltip, viewEmpty, children: rest.value });
18
+ return /* @__PURE__ */ jsx("div", { style: { whiteSpace: "pre-wrap", width: "100%" }, children: /* @__PURE__ */ jsx(Container, { nowrap: false, tooltip, viewEmpty, children: rest.value }) });
19
19
  }
20
20
  const _className = classnames({
21
21
  "pro-textarea": true,
@@ -15,11 +15,24 @@ const defaultPickerValue = [dayjs(), dayjs()];
15
15
  const useControlled = (props) => {
16
16
  var _a, _b;
17
17
  const [value, setValue] = useState();
18
+ const [startDate, endDate] = [
19
+ ((_a = props.value) == null ? void 0 : _a[0]) && dayjs(props.value[0], props.format),
20
+ ((_b = props.value) == null ? void 0 : _b[1]) && dayjs(props.value[1], props.format)
21
+ ];
22
+ const internalValue = useMemo(
23
+ () => [startDate, endDate],
24
+ [
25
+ "value" in props,
26
+ props.format,
27
+ startDate == null ? void 0 : startDate.valueOf(),
28
+ startDate && startDate.utcOffset(),
29
+ startDate && startDate.locale(),
30
+ endDate == null ? void 0 : endDate.valueOf(),
31
+ endDate && endDate.utcOffset(),
32
+ endDate && endDate.locale()
33
+ ]
34
+ );
18
35
  if ("value" in props) {
19
- const internalValue = [
20
- ((_a = props.value) == null ? void 0 : _a[0]) && dayjs(props.value[0], props.format),
21
- ((_b = props.value) == null ? void 0 : _b[1]) && dayjs(props.value[1], props.format)
22
- ];
23
36
  const handleChange = (value2, other) => {
24
37
  var _a2;
25
38
  if (!value2) {
@@ -1,5 +1,5 @@
1
- import { FC, ReactNode } from 'react';
2
- import { UploadFile } from 'antd/es/upload/interface';
1
+ import type { FC, ReactNode } from 'react';
2
+ import type { UploadFile } from 'antd/es/upload/interface';
3
3
  import type { ProUploadType } from '../propsType';
4
4
  interface DragRenderProps extends Pick<ProUploadType, 'buttonProps' | 'disabled' | 'maxCount' | 'extraTipText' | 'showExampleContent' | 'exampleTitle' | 'exampleContent' | 'exampleModalProps'> {
5
5
  isView?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Button, Upload, Progress, Space, Modal } from "antd";
3
- import { useRef, useState } from "react";
3
+ import { useEffect, useState } from "react";
4
4
  import { DndContext } from "@dnd-kit/core";
5
5
  import { SortableContext, rectSortingStrategy } from "@dnd-kit/sortable";
6
6
  import isFunction from "lodash/isFunction";
@@ -19,8 +19,7 @@ const isImgage = (_fileExt) => {
19
19
  };
20
20
  const ImageRender = (props) => {
21
21
  var _a, _b;
22
- const [previewImg, setPreviewImg] = useState({});
23
- const proViewerRef = useRef(null);
22
+ const [previewImg, setPreviewImg] = useState(null);
24
23
  const {
25
24
  isView,
26
25
  disabled,
@@ -48,14 +47,18 @@ const ImageRender = (props) => {
48
47
  } else {
49
48
  const _fileExt = getFileExt(file.name || ((_a2 = file == null ? void 0 : file.url) == null ? void 0 : _a2.split("?")[0]));
50
49
  if (isImgage(_fileExt)) {
51
- setPreviewImg(file);
50
+ const objectUrl = !file.url && file.originFileObj ? URL.createObjectURL(file.originFileObj) : void 0;
51
+ const url = file.url || objectUrl;
52
+ if (url) {
53
+ setPreviewImg({ name: file.name, url, objectUrl });
54
+ }
52
55
  } else {
53
56
  window.open(file.url, "_blank");
54
57
  }
55
58
  }
56
59
  };
57
60
  const handlePreviewCancel = () => {
58
- setPreviewImg({});
61
+ setPreviewImg(null);
59
62
  };
60
63
  const handleDownload = (file) => {
61
64
  if (onDownload) {
@@ -93,6 +96,7 @@ const ImageRender = (props) => {
93
96
  {
94
97
  type: "link",
95
98
  className: "action-item",
99
+ disabled: !onPreview && isImg && !file.url && !file.originFileObj,
96
100
  onClick: () => {
97
101
  handlePreviewImg(file);
98
102
  },
@@ -154,6 +158,14 @@ const ImageRender = (props) => {
154
158
  const hasFooter = !isEmptyReactNode(footer);
155
159
  const hasCenterRender = typeof centerRender === "function" || !isEmptyReactNode(centerRender);
156
160
  const tipText = typeof extraTipText === "function" ? extraTipText() : extraTipText;
161
+ useEffect(() => {
162
+ const objectUrl = previewImg == null ? void 0 : previewImg.objectUrl;
163
+ return () => {
164
+ if (objectUrl) {
165
+ URL.revokeObjectURL(objectUrl);
166
+ }
167
+ };
168
+ }, [previewImg == null ? void 0 : previewImg.objectUrl]);
157
169
  return /* @__PURE__ */ jsxs(Fragment, { children: [
158
170
  /* @__PURE__ */ jsxs(Space, { orientation: "vertical", size: 8, className: "pro-upload-image", children: [
159
171
  headerRender(),
@@ -187,11 +199,11 @@ const ImageRender = (props) => {
187
199
  title: previewImg == null ? void 0 : previewImg.name,
188
200
  width: "600",
189
201
  style: { width: "400px" },
190
- open: (previewImg == null ? void 0 : previewImg.url) || (previewImg == null ? void 0 : previewImg.thumbUrl),
202
+ open: !!previewImg,
191
203
  wrapClassName: "proupload-modal-preview",
192
204
  onCancel: handlePreviewCancel,
193
205
  footer: false,
194
- children: /* @__PURE__ */ jsx("img", { alt: "example", style: { width: "100%" }, src: (previewImg == null ? void 0 : previewImg.url) || previewImg.thumbUrl })
206
+ children: /* @__PURE__ */ jsx("img", { alt: "example", style: { width: "100%" }, src: previewImg == null ? void 0 : previewImg.url })
195
207
  }
196
208
  )
197
209
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.7.2-beta.2",
3
+ "version": "4.7.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",