@cloudtower/eagle 0.35.1 → 0.35.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.
- package/dist/cjs/UIKitProvider/index.js +5 -10
- package/dist/cjs/antd.js +4 -4
- package/dist/cjs/core/AutoComplete/AutoComplete.js +42 -0
- package/dist/cjs/core/ConfigProvider/index.js +3 -1
- package/dist/cjs/core/Fields/FieldsTimePicker/index.js +4 -3
- package/dist/cjs/core/ImmersiveDialog/index.js +21 -14
- package/dist/cjs/core/{Modal → LegacyModal}/index.js +7 -3
- package/dist/cjs/core/LegacySelect/index.js +4 -0
- package/dist/cjs/core/LocalUpload/LocalUpload.hooks.js +66 -0
- package/dist/cjs/core/LocalUpload/LocalUpload.js +103 -0
- package/dist/cjs/core/LocalUpload/LocalUpload.style.js +13 -0
- package/dist/cjs/core/LocalUpload/LocalUpload.widget.js +379 -0
- package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/cjs/core/SmallDialog/SmallDialog.js +7 -5
- package/dist/cjs/core/Tab/Tab.js +113 -0
- package/dist/cjs/core/Tab/Tab.style.js +17 -0
- package/dist/cjs/core/Tab/Tab.type.js +9 -0
- package/dist/cjs/core/Tab/useTabAdaptiveLayout.js +73 -0
- package/dist/cjs/core/message/message.js +24 -1
- package/dist/cjs/coreX/KubeConfigModal/index.js +4 -4
- package/dist/cjs/hooks/useAntdPatchEnLocales.js +35 -0
- package/dist/cjs/hooks/useLegacyComponentWarning.js +16 -0
- package/dist/cjs/index.js +26 -20
- package/dist/cjs/legacy-antd.js +2 -2
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +2654 -2271
- package/dist/esm/UIKitProvider/index.js +5 -10
- package/dist/esm/antd.js +1 -1
- package/dist/esm/core/AutoComplete/AutoComplete.js +35 -0
- package/dist/esm/core/ConfigProvider/index.js +3 -1
- package/dist/esm/core/Fields/FieldsTimePicker/index.js +2 -1
- package/dist/esm/core/ImmersiveDialog/index.js +21 -14
- package/dist/esm/core/{Modal → LegacyModal}/index.js +9 -5
- package/dist/esm/core/LegacySelect/index.js +4 -0
- package/dist/esm/core/LocalUpload/LocalUpload.hooks.js +63 -0
- package/dist/esm/core/LocalUpload/LocalUpload.js +97 -0
- package/dist/esm/core/LocalUpload/LocalUpload.style.js +10 -0
- package/dist/esm/core/LocalUpload/LocalUpload.widget.js +365 -0
- package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/esm/core/SmallDialog/SmallDialog.js +6 -4
- package/dist/esm/core/Tab/Tab.js +107 -0
- package/dist/esm/core/Tab/Tab.style.js +12 -0
- package/dist/esm/core/Tab/Tab.type.js +7 -0
- package/dist/esm/core/Tab/useTabAdaptiveLayout.js +71 -0
- package/dist/esm/core/message/message.js +24 -1
- package/dist/esm/coreX/KubeConfigModal/index.js +5 -5
- package/dist/esm/hooks/useAntdPatchEnLocales.js +29 -0
- package/dist/esm/hooks/useLegacyComponentWarning.js +14 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/legacy-antd.js +4 -4
- package/dist/esm/stats1.html +1 -1
- package/dist/linaria.merged.scss +2815 -2374
- package/dist/src/antd.d.ts +1 -1
- package/dist/src/core/AutoComplete/AutoComplete.d.ts +3 -0
- package/dist/src/core/AutoComplete/index.d.ts +1 -0
- package/dist/src/core/ImmersiveDialog/type.d.ts +2 -2
- package/dist/src/core/{Modal/modal.type.d.ts → LegacyModal/LegacyModal.type.d.ts} +12 -1
- package/dist/src/core/LegacyModal/index.d.ts +16 -0
- package/dist/src/core/LocalUpload/LocalUpload.d.ts +15 -0
- package/dist/src/core/LocalUpload/LocalUpload.hooks.d.ts +32 -0
- package/dist/src/core/LocalUpload/LocalUpload.style.d.ts +3 -0
- package/dist/src/core/LocalUpload/LocalUpload.type.d.ts +175 -0
- package/dist/src/core/LocalUpload/LocalUpload.widget.d.ts +23 -0
- package/dist/src/core/LocalUpload/index.d.ts +2 -0
- package/dist/src/core/SmallDialog/SmallDialog.type.d.ts +2 -0
- package/dist/src/core/Tab/Tab.d.ts +3 -0
- package/dist/src/core/Tab/Tab.style.d.ts +5 -0
- package/dist/src/core/Tab/Tab.type.d.ts +42 -0
- package/dist/src/core/Tab/index.d.ts +1 -0
- package/dist/src/core/Tab/useTabAdaptiveLayout.d.ts +23 -0
- package/dist/src/core/index.d.ts +5 -2
- package/dist/src/core/message/message.d.ts +5 -0
- package/dist/src/hooks/useAntdPatchEnLocales.d.ts +431 -0
- package/dist/src/hooks/useLegacyComponentWarning.d.ts +2 -0
- package/dist/src/spec/base.d.ts +2 -2
- package/dist/stories/docs/core/AutoComplete.stories.d.ts +41 -0
- package/dist/stories/docs/core/ImmersiveDialog.stories.d.ts +5 -1
- package/dist/stories/docs/core/LegacyModal.stories.d.ts +23 -0
- package/dist/stories/docs/core/LocalUpload.stories.d.ts +74 -0
- package/dist/stories/docs/core/MediumDialog.stories.d.ts +5 -1
- package/dist/stories/docs/core/SmallDialog.stories.d.ts +5 -1
- package/dist/stories/docs/core/Tab.stories.d.ts +65 -0
- package/dist/stories/docs/core/WizardDialog.stories.d.ts +2 -1
- package/dist/stories/docs/core/message-group.stories.d.ts +1 -0
- package/dist/stories/docs/coreX/CheckPointList.stories.d.ts +5 -0
- package/dist/style.css +2652 -2269
- package/dist/variables.scss +3 -0
- package/package.json +4 -4
- package/dist/src/core/Modal/index.d.ts +0 -5
- package/dist/stories/docs/core/Modal.stories.d.ts +0 -13
|
@@ -40,21 +40,16 @@ const UIKitProvider = (props) => {
|
|
|
40
40
|
});
|
|
41
41
|
}, [batchMessage, kit]);
|
|
42
42
|
useEffect(() => {
|
|
43
|
-
_message.config(omit(message, "batch"))
|
|
44
|
-
|
|
43
|
+
_message.config(__spreadProps(__spreadValues({}, omit(message, "batch")), {
|
|
44
|
+
configProviderProps: config
|
|
45
|
+
}));
|
|
46
|
+
}, [message, config]);
|
|
45
47
|
useEffect(() => {
|
|
46
48
|
if (parrotI18n.language !== lng) {
|
|
47
49
|
parrotI18n.changeLanguage(lng);
|
|
48
50
|
}
|
|
49
51
|
}, [lng]);
|
|
50
|
-
return /* @__PURE__ */ React__default.createElement(kitContext.Provider, { value: _kit }, /* @__PURE__ */ React__default.createElement(MessageContext.Provider, { value: batchMessage != null ? batchMessage : _message },
|
|
51
|
-
ConfigProvider,
|
|
52
|
-
{
|
|
53
|
-
antd4Configs: __spreadValues({}, config == null ? void 0 : config.antd4Configs),
|
|
54
|
-
antd5Configs: __spreadValues({}, config == null ? void 0 : config.antd5Configs)
|
|
55
|
-
},
|
|
56
|
-
children
|
|
57
|
-
)));
|
|
52
|
+
return /* @__PURE__ */ React__default.createElement(kitContext.Provider, { value: _kit }, /* @__PURE__ */ React__default.createElement(ConfigProvider, __spreadValues({}, config), /* @__PURE__ */ React__default.createElement(MessageContext.Provider, { value: batchMessage != null ? batchMessage : _message }, children)));
|
|
58
53
|
};
|
|
59
54
|
var UIKitProvider$1 = UIKitProvider;
|
|
60
55
|
const useUIKit = () => {
|
package/dist/esm/antd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatePicker, List, Menu, Skeleton, Tabs, Timeline, Typography, Upload, Select, Modal } from 'antd';
|
|
2
|
-
export { Badge as AntdBadge, Button as AntdButton, Checkbox as AntdCheckbox, Collapse as AntdCollapse, Divider as AntdDivider, Drawer as AntdDrawer, Empty as AntdEmpty, Input as AntdInput, message as AntdMessage, Select as AntdSelect, Skeleton as AntdSkeleton, Steps as AntdSteps, Switch as AntdSwitch, Table as AntdTable, TimePicker as AntdTimePicker, Timeline as AntdTimeline, Tooltip as AntdTooltip, TreeSelect as AntdTreeSelect,
|
|
2
|
+
export { AutoComplete as AntdAutoComplete, Badge as AntdBadge, Button as AntdButton, Checkbox as AntdCheckbox, Collapse as AntdCollapse, Divider as AntdDivider, Drawer as AntdDrawer, Empty as AntdEmpty, Input as AntdInput, message as AntdMessage, Select as AntdSelect, Skeleton as AntdSkeleton, Steps as AntdSteps, Switch as AntdSwitch, Table as AntdTable, TimePicker as AntdTimePicker, Timeline as AntdTimeline, Tooltip as AntdTooltip, TreeSelect as AntdTreeSelect, Col, DatePicker, Dropdown, Layout, List, Menu, Popover, Row, Tabs, Tree, Typography, Upload } from 'antd';
|
|
3
3
|
|
|
4
4
|
const DatePickerRangePicker = DatePicker.RangePicker;
|
|
5
5
|
const ListItem = List.Item;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AutoComplete as AutoComplete$1 } from 'antd5';
|
|
2
|
+
import cs from 'classnames';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { SelectStyle } from '../LegacySelect/select.style.js';
|
|
5
|
+
import { SelectStyle as SelectStyle$1 } from '../Select/select.style.js';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
const AutoComplete = (props) => {
|
|
27
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
28
|
+
AutoComplete$1,
|
|
29
|
+
__spreadProps(__spreadValues({}, props), {
|
|
30
|
+
className: cs(SelectStyle, SelectStyle$1, props.className)
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { AutoComplete };
|
|
@@ -8,6 +8,7 @@ import antd5zhCN from 'antd5/lib/locale/zh_CN';
|
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import moment from 'moment';
|
|
10
10
|
import React__default, { createContext, useContext, useEffect } from 'react';
|
|
11
|
+
import { useAntdPatchEnLocales } from '../../hooks/useAntdPatchEnLocales.js';
|
|
11
12
|
|
|
12
13
|
var __defProp = Object.defineProperty;
|
|
13
14
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -44,6 +45,7 @@ const ConfigProvider = ({
|
|
|
44
45
|
i18n.on("languageChanged", adjustDateLocale);
|
|
45
46
|
adjustDateLocale(i18n.language);
|
|
46
47
|
}, [i18n]);
|
|
48
|
+
const patchEnLocale = useAntdPatchEnLocales(enUS);
|
|
47
49
|
return /* @__PURE__ */ React__default.createElement(ConfigProviderContext.Provider, { value: config }, /* @__PURE__ */ React__default.createElement(
|
|
48
50
|
ConfigProvider$1,
|
|
49
51
|
__spreadValues({
|
|
@@ -54,7 +56,7 @@ const ConfigProvider = ({
|
|
|
54
56
|
ConfigProvider$2,
|
|
55
57
|
__spreadValues({
|
|
56
58
|
autoInsertSpaceInButton: false,
|
|
57
|
-
locale: i18n.language === "zh-CN" ? zhCN :
|
|
59
|
+
locale: i18n.language === "zh-CN" ? zhCN : patchEnLocale
|
|
58
60
|
}, antd4Configs),
|
|
59
61
|
children
|
|
60
62
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import TimePicker from '../../TimePicker/index.js';
|
|
3
|
+
import { ConfigProvider } from '../../ConfigProvider/index.js';
|
|
3
4
|
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __defProps = Object.defineProperties;
|
|
@@ -40,7 +41,7 @@ const FieldsTimePicker = (_a) => {
|
|
|
40
41
|
"input",
|
|
41
42
|
"meta"
|
|
42
43
|
]);
|
|
43
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
44
|
+
return /* @__PURE__ */ React__default.createElement(ConfigProvider, null, /* @__PURE__ */ React__default.createElement(
|
|
44
45
|
TimePicker,
|
|
45
46
|
__spreadValues(__spreadProps(__spreadValues({}, input), {
|
|
46
47
|
error: meta.touched && (meta.error || !meta.dirtySinceLastSubmit && meta.submitError)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ExclamationErrorCircleFill16RedIcon, XmarkCloseBold24TertiaryIcon, XmarkCloseBold24SecondaryIcon } from '@cloudtower/icons-react';
|
|
2
2
|
import { cx } from '@linaria/core';
|
|
3
3
|
import Button from '../Button/index.js';
|
|
4
|
+
import Icon from '../Icon/index.js';
|
|
4
5
|
import { usePopModal } from '../KitStoreProvider/index.js';
|
|
5
6
|
import { Typo } from '../Typo/index.js';
|
|
6
|
-
import Icon from '../Icon/index.js';
|
|
7
7
|
import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
|
|
8
8
|
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
9
9
|
import { Modal } from 'antd';
|
|
@@ -54,12 +54,13 @@ function ImmersiveDialog(props) {
|
|
|
54
54
|
footer,
|
|
55
55
|
showCancel = true,
|
|
56
56
|
showOk = true,
|
|
57
|
-
|
|
57
|
+
confirmLoading,
|
|
58
58
|
okButtonProps,
|
|
59
59
|
cancelButtonProps,
|
|
60
60
|
okText,
|
|
61
61
|
cancelText,
|
|
62
62
|
error,
|
|
63
|
+
hideFooter = false,
|
|
63
64
|
showFooterErrorIcon = true,
|
|
64
65
|
visible = true,
|
|
65
66
|
isContentFull,
|
|
@@ -80,12 +81,13 @@ function ImmersiveDialog(props) {
|
|
|
80
81
|
"footer",
|
|
81
82
|
"showCancel",
|
|
82
83
|
"showOk",
|
|
83
|
-
"
|
|
84
|
+
"confirmLoading",
|
|
84
85
|
"okButtonProps",
|
|
85
86
|
"cancelButtonProps",
|
|
86
87
|
"okText",
|
|
87
88
|
"cancelText",
|
|
88
89
|
"error",
|
|
90
|
+
"hideFooter",
|
|
89
91
|
"showFooterErrorIcon",
|
|
90
92
|
"visible",
|
|
91
93
|
"isContentFull",
|
|
@@ -111,6 +113,8 @@ function ImmersiveDialog(props) {
|
|
|
111
113
|
if (initializing) {
|
|
112
114
|
return null;
|
|
113
115
|
}
|
|
116
|
+
if (hideFooter)
|
|
117
|
+
return /* @__PURE__ */ React__default.createElement("div", null);
|
|
114
118
|
return footer || /* @__PURE__ */ React__default.createElement("div", { className: FooterStyle }, /* @__PURE__ */ React__default.createElement("div", { className: FooterButtonStyle }, footerLeftAction, error && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("span", { className: cx(ErrorStyle, Typo.Label.l2_regular) }, showFooterErrorIcon && /* @__PURE__ */ React__default.createElement(
|
|
115
119
|
ExclamationErrorCircleFill16RedIcon,
|
|
116
120
|
{
|
|
@@ -147,25 +151,27 @@ function ImmersiveDialog(props) {
|
|
|
147
151
|
onOk == null ? void 0 : onOk(e);
|
|
148
152
|
},
|
|
149
153
|
type: "primary",
|
|
150
|
-
loading:
|
|
154
|
+
loading: confirmLoading
|
|
151
155
|
}, okButtonProps),
|
|
152
156
|
_confirmText
|
|
153
157
|
) : null));
|
|
154
158
|
}, [
|
|
159
|
+
initializing,
|
|
160
|
+
hideFooter,
|
|
161
|
+
footer,
|
|
155
162
|
footerLeftAction,
|
|
156
|
-
|
|
163
|
+
error,
|
|
164
|
+
showFooterErrorIcon,
|
|
165
|
+
showCancel,
|
|
157
166
|
cancelButtonProps,
|
|
158
167
|
_cancelText,
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
showOk,
|
|
169
|
+
confirmLoading,
|
|
161
170
|
okButtonProps,
|
|
162
|
-
|
|
163
|
-
onCancel,
|
|
164
|
-
onOk,
|
|
171
|
+
_confirmText,
|
|
165
172
|
popModal,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
initializing
|
|
173
|
+
onCancel,
|
|
174
|
+
onOk
|
|
169
175
|
]);
|
|
170
176
|
return /* @__PURE__ */ React__default.createElement(
|
|
171
177
|
Modal,
|
|
@@ -177,7 +183,8 @@ function ImmersiveDialog(props) {
|
|
|
177
183
|
isContentFull ? FullContentStyle : MultiAreaStyle,
|
|
178
184
|
className,
|
|
179
185
|
{
|
|
180
|
-
"initializing-error": initializingError
|
|
186
|
+
"initializing-error": initializingError,
|
|
187
|
+
"no-footer": hideFooter
|
|
181
188
|
}
|
|
182
189
|
),
|
|
183
190
|
closeIcon: closeIcon != null ? closeIcon : /* @__PURE__ */ React__default.createElement(
|
|
@@ -3,8 +3,9 @@ import Button from '../Button/index.js';
|
|
|
3
3
|
import { useKitSelector, useKitDispatch } from '../KitStoreProvider/index.js';
|
|
4
4
|
import Steps from '../Steps/index.js';
|
|
5
5
|
import { WizardBody } from '../Styled/index.js';
|
|
6
|
+
import useLegacyComponentWarning from '../../hooks/useLegacyComponentWarning.js';
|
|
6
7
|
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
7
|
-
import { Modal
|
|
8
|
+
import { Modal } from 'antd';
|
|
8
9
|
import cs from 'classnames';
|
|
9
10
|
import React__default, { useRef, useMemo } from 'react';
|
|
10
11
|
import { ModalActions } from '../../store/modal.js';
|
|
@@ -40,9 +41,12 @@ var __objRest = (source, exclude) => {
|
|
|
40
41
|
}
|
|
41
42
|
return target;
|
|
42
43
|
};
|
|
43
|
-
const
|
|
44
|
+
const LegacyModal = (props) => {
|
|
44
45
|
var _b;
|
|
45
46
|
const { t } = useParrotTranslation();
|
|
47
|
+
useLegacyComponentWarning(
|
|
48
|
+
"Warning: LegacyModal is deprecated and will be removed in future versions. Please use Dialog/MediumDialog/SmallDialog/ImmersiveDialog/WizardDialog instead."
|
|
49
|
+
);
|
|
46
50
|
const _a = props, {
|
|
47
51
|
error,
|
|
48
52
|
okText = t("common.confirm"),
|
|
@@ -120,7 +124,7 @@ const Modal = (props) => {
|
|
|
120
124
|
stepsRef.current[wizard.step] = wizard.steps[wizard.step].render;
|
|
121
125
|
}
|
|
122
126
|
return /* @__PURE__ */ React__default.createElement(
|
|
123
|
-
Modal
|
|
127
|
+
Modal,
|
|
124
128
|
__spreadProps(__spreadValues({
|
|
125
129
|
maskClosable,
|
|
126
130
|
className: cs(
|
|
@@ -224,6 +228,6 @@ const Modal = (props) => {
|
|
|
224
228
|
))), wizard.right && /* @__PURE__ */ React__default.createElement("div", { className: "right" }, wizard.right)) : restProps.children
|
|
225
229
|
);
|
|
226
230
|
};
|
|
227
|
-
var
|
|
231
|
+
var LegacyModal$1 = LegacyModal;
|
|
228
232
|
|
|
229
|
-
export {
|
|
233
|
+
export { LegacyModal$1 as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Loading from '../Loading/index.js';
|
|
2
2
|
import { Typo } from '../Typo/index.js';
|
|
3
|
+
import useLegacyComponentWarning from '../../hooks/useLegacyComponentWarning.js';
|
|
3
4
|
import { Select } from 'antd';
|
|
4
5
|
import cs from 'classnames';
|
|
5
6
|
import _ from 'lodash';
|
|
@@ -113,6 +114,9 @@ const LegacySelect = (_a) => {
|
|
|
113
114
|
);
|
|
114
115
|
}
|
|
115
116
|
}, [selectRef, placeholder]);
|
|
117
|
+
useLegacyComponentWarning(
|
|
118
|
+
"Warning: LegacySelect is deprecated and will be removed in future versions. Please use Select instead."
|
|
119
|
+
);
|
|
116
120
|
return /* @__PURE__ */ React__default.createElement(
|
|
117
121
|
Select,
|
|
118
122
|
__spreadValues(__spreadProps(__spreadValues({}, input), {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const useFileValidation = ({
|
|
4
|
+
fileList,
|
|
5
|
+
setFileList,
|
|
6
|
+
validate,
|
|
7
|
+
createNewFile = false
|
|
8
|
+
}) => {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!validate)
|
|
11
|
+
return;
|
|
12
|
+
const updateFile = (fileId, file) => {
|
|
13
|
+
const index = fileList.findIndex((f) => f.uid === fileId);
|
|
14
|
+
if (index !== -1) {
|
|
15
|
+
const newList = [...fileList];
|
|
16
|
+
const fileToUpdate = createNewFile ? (() => {
|
|
17
|
+
const newFile = new File([file], file.name, { type: file.type });
|
|
18
|
+
Object.assign(newFile, file);
|
|
19
|
+
return newFile;
|
|
20
|
+
})() : file;
|
|
21
|
+
newList.splice(index, 1, fileToUpdate);
|
|
22
|
+
setFileList(newList);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
for (const _file of fileList) {
|
|
26
|
+
if (_file.fileStatus !== "need-validate") {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
_file.fileStatus = "validating";
|
|
30
|
+
updateFile(_file.uid, _file);
|
|
31
|
+
validate(_file, fileList).then((result) => {
|
|
32
|
+
if (result.error) {
|
|
33
|
+
_file.error = result.error;
|
|
34
|
+
_file.fileStatus = "error";
|
|
35
|
+
} else {
|
|
36
|
+
_file.error = void 0;
|
|
37
|
+
_file.fileStatus = "success";
|
|
38
|
+
_file.data = result.data;
|
|
39
|
+
}
|
|
40
|
+
updateFile(_file.uid, _file);
|
|
41
|
+
return;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [fileList, setFileList, validate, createNewFile]);
|
|
45
|
+
};
|
|
46
|
+
const useFileCountErrorClear = ({
|
|
47
|
+
fileList,
|
|
48
|
+
maxCount,
|
|
49
|
+
setError
|
|
50
|
+
}) => {
|
|
51
|
+
const fileCountRef = useRef(fileList.length);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (fileList.length === fileCountRef.current) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
fileCountRef.current = fileList.length;
|
|
57
|
+
if (fileCountRef.current <= maxCount) {
|
|
58
|
+
setError("");
|
|
59
|
+
}
|
|
60
|
+
}, [fileList.length, maxCount, setError]);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { useFileCountErrorClear, useFileValidation };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { UploadWrapper } from './LocalUpload.style.js';
|
|
4
|
+
import { UploadLabel, UploadDescription, UploadButton, UploadDragger, UploadFileList, UploadFileInfo } from './LocalUpload.widget.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
const UploadComp = React__default.forwardRef(
|
|
23
|
+
({
|
|
24
|
+
className,
|
|
25
|
+
label,
|
|
26
|
+
description,
|
|
27
|
+
type = "dragger",
|
|
28
|
+
multiple = false,
|
|
29
|
+
accept,
|
|
30
|
+
disabled,
|
|
31
|
+
maxCount,
|
|
32
|
+
info,
|
|
33
|
+
fileList,
|
|
34
|
+
setFileList,
|
|
35
|
+
validate,
|
|
36
|
+
buttonProps,
|
|
37
|
+
listType = "list",
|
|
38
|
+
disableRemoveList = false,
|
|
39
|
+
onRemove
|
|
40
|
+
}, ref) => {
|
|
41
|
+
const { t } = useParrotTranslation();
|
|
42
|
+
const removeFile = (id) => {
|
|
43
|
+
const index = fileList.findIndex((f) => f.uid === id);
|
|
44
|
+
if (index !== -1) {
|
|
45
|
+
const file = fileList[index];
|
|
46
|
+
fileList.splice(index, 1);
|
|
47
|
+
setFileList([...fileList]);
|
|
48
|
+
onRemove == null ? void 0 : onRemove(file);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const _maxCount = multiple ? maxCount || Infinity : 1;
|
|
52
|
+
const isSingleSelect = _maxCount === 1;
|
|
53
|
+
return /* @__PURE__ */ React__default.createElement(UploadComp.Wrapper, { className, ref }, label ? /* @__PURE__ */ React__default.createElement(UploadComp.Label, null, label) : null, description ? /* @__PURE__ */ React__default.createElement(UploadComp.Description, null, description) : null, type === "button" ? /* @__PURE__ */ React__default.createElement(
|
|
54
|
+
UploadComp.Button,
|
|
55
|
+
__spreadValues({}, __spreadValues({
|
|
56
|
+
accept,
|
|
57
|
+
multiple,
|
|
58
|
+
disabled,
|
|
59
|
+
maxCount,
|
|
60
|
+
fileList,
|
|
61
|
+
setFileList,
|
|
62
|
+
validate
|
|
63
|
+
}, buttonProps)),
|
|
64
|
+
t("components.select_file")
|
|
65
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
66
|
+
UploadComp.Dragger,
|
|
67
|
+
__spreadValues({}, {
|
|
68
|
+
accept,
|
|
69
|
+
multiple,
|
|
70
|
+
disabled,
|
|
71
|
+
maxCount,
|
|
72
|
+
fileList,
|
|
73
|
+
setFileList,
|
|
74
|
+
validate
|
|
75
|
+
})
|
|
76
|
+
), info != null ? info : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), type === "button" || !isSingleSelect ? /* @__PURE__ */ React__default.createElement(
|
|
77
|
+
UploadComp.FileList,
|
|
78
|
+
{
|
|
79
|
+
fileList,
|
|
80
|
+
removeFile,
|
|
81
|
+
type: listType,
|
|
82
|
+
disableRemove: disableRemoveList,
|
|
83
|
+
onRemove
|
|
84
|
+
}
|
|
85
|
+
) : null);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
UploadComp.Wrapper = UploadWrapper;
|
|
89
|
+
UploadComp.Label = UploadLabel;
|
|
90
|
+
UploadComp.Description = UploadDescription;
|
|
91
|
+
UploadComp.Button = UploadButton;
|
|
92
|
+
UploadComp.Dragger = UploadDragger;
|
|
93
|
+
UploadComp.FileList = UploadFileList;
|
|
94
|
+
UploadComp.FileInfo = UploadFileInfo;
|
|
95
|
+
const LocalUpload = UploadComp;
|
|
96
|
+
|
|
97
|
+
export { LocalUpload };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { styled } from '@linaria/react';
|
|
2
|
+
|
|
3
|
+
const UploadWrapper = /*#__PURE__*/styled('div')({
|
|
4
|
+
name: "UploadWrapper",
|
|
5
|
+
class: "E_u3l9ivi",
|
|
6
|
+
propsAsIs: false
|
|
7
|
+
});
|
|
8
|
+
const FileInfoWrapperStyle = "E_ftdwz1g";
|
|
9
|
+
|
|
10
|
+
export { FileInfoWrapperStyle, UploadWrapper };
|