@cloudtower/eagle 0.35.9 → 481.0.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/core/Cascader/cascader.widget.js +12 -12
- package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/cjs/core/SearchInput/SearchInput.hook.js +124 -0
- package/dist/cjs/core/SearchInput/SearchInput.js +253 -0
- package/dist/cjs/core/SearchInput/SearchInput.style.js +13 -0
- package/dist/cjs/core/index.js +12 -15
- package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +4 -16
- package/dist/cjs/index.js +245 -253
- package/dist/cjs/legacy-antd.js +89 -89
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +2423 -2578
- package/dist/esm/core/Cascader/cascader.widget.js +1 -1
- package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
- package/dist/esm/core/SearchInput/SearchInput.hook.js +117 -0
- package/dist/esm/core/SearchInput/SearchInput.js +247 -0
- package/dist/esm/core/SearchInput/SearchInput.style.js +7 -0
- package/dist/esm/core/index.js +2 -4
- package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +4 -16
- package/dist/esm/index.js +1 -5
- package/dist/esm/legacy-antd.js +1 -1
- package/dist/esm/stats1.html +1 -1
- package/dist/linaria.merged.scss +3680 -3841
- package/dist/src/core/Cascader/cascader.type.d.ts +1 -1
- package/dist/src/core/SearchInput/SearchInput.d.ts +2 -0
- package/dist/src/core/SearchInput/SearchInput.hook.d.ts +9 -0
- package/dist/src/core/SearchInput/SearchInput.style.d.ts +5 -0
- package/dist/src/core/SearchInput/{searchInput.type.d.ts → SearchInput.type.d.ts} +18 -2
- package/dist/src/core/SearchInput/index.d.ts +2 -4
- package/dist/src/core/index.d.ts +0 -6
- package/dist/src/coreX/Dialogs/RejectDialog/RejectDialog.type.d.ts +1 -5
- package/dist/src/coreX/index.d.ts +0 -3
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/stories/docs/core/SearchInput.stories.d.ts +6 -1
- package/dist/stories/docs/coreX/Dialogs/RejectDialog.stories.d.ts +1 -3
- package/dist/style.css +2423 -2578
- package/package.json +4 -6
- package/dist/cjs/core/Duration/index.js +0 -78
- package/dist/cjs/core/LocalUpload/LocalUpload.hooks.js +0 -66
- package/dist/cjs/core/LocalUpload/LocalUpload.js +0 -103
- package/dist/cjs/core/LocalUpload/LocalUpload.style.js +0 -13
- package/dist/cjs/core/LocalUpload/LocalUpload.widget.js +0 -379
- package/dist/cjs/core/SearchInput/index.js +0 -164
- package/dist/cjs/coreX/Copy/CopyButton.js +0 -40
- package/dist/cjs/coreX/Copy/CopyTooltip.js +0 -66
- package/dist/cjs/hooks/useFormatDuration.js +0 -35
- package/dist/cjs/utils/formatDuration.js +0 -67
- package/dist/esm/core/Duration/index.js +0 -72
- package/dist/esm/core/LocalUpload/LocalUpload.hooks.js +0 -63
- package/dist/esm/core/LocalUpload/LocalUpload.js +0 -97
- package/dist/esm/core/LocalUpload/LocalUpload.style.js +0 -10
- package/dist/esm/core/LocalUpload/LocalUpload.widget.js +0 -365
- package/dist/esm/core/SearchInput/index.js +0 -157
- package/dist/esm/coreX/Copy/CopyButton.js +0 -34
- package/dist/esm/coreX/Copy/CopyTooltip.js +0 -59
- package/dist/esm/hooks/useFormatDuration.js +0 -33
- package/dist/esm/utils/formatDuration.js +0 -65
- package/dist/src/core/Duration/duration.type.d.ts +0 -42
- package/dist/src/core/Duration/index.d.ts +0 -4
- package/dist/src/core/LocalUpload/LocalUpload.d.ts +0 -15
- package/dist/src/core/LocalUpload/LocalUpload.hooks.d.ts +0 -32
- package/dist/src/core/LocalUpload/LocalUpload.style.d.ts +0 -3
- package/dist/src/core/LocalUpload/LocalUpload.type.d.ts +0 -175
- package/dist/src/core/LocalUpload/LocalUpload.widget.d.ts +0 -23
- package/dist/src/core/LocalUpload/index.d.ts +0 -2
- package/dist/src/coreX/Copy/CopyButton.d.ts +0 -5
- package/dist/src/coreX/Copy/CopyButton.type.d.ts +0 -8
- package/dist/src/coreX/Copy/CopyTooltip.d.ts +0 -5
- package/dist/src/coreX/Copy/CopyTooltip.typs.d.ts +0 -16
- package/dist/src/coreX/Copy/index.d.ts +0 -2
- package/dist/src/hooks/useFormatDuration.d.ts +0 -31
- package/dist/src/utils/__test__/formatDuration.spec.d.ts +0 -1
- package/dist/src/utils/formatDuration.d.ts +0 -28
- package/dist/stories/docs/core/Duration.stories.d.ts +0 -88
- package/dist/stories/docs/core/LocalUpload.stories.d.ts +0 -74
- package/dist/stories/docs/coreX/Copy/CopyButton.stories.d.ts +0 -66
- package/dist/stories/docs/coreX/Copy/CopyTooltip.stories.d.ts +0 -66
- /package/dist/src/{hooks/__tests__/useFormatDuration.test.d.ts → core/SearchInput/__test__/SearchInput.hook.test.d.ts} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var icons = require('@ant-design/icons');
|
|
4
|
-
var iconsReact = require('@cloudtower/icons-react');
|
|
5
|
-
var core = require('@linaria/core');
|
|
6
|
-
var index$1 = require('../Icon/index.js');
|
|
7
|
-
var index$3 = require('../Input/index.js');
|
|
8
|
-
var index$2 = require('../Tooltip/index.js');
|
|
9
|
-
var index = require('../Typo/index.js');
|
|
10
|
-
var useParrotTranslation = require('../../hooks/useParrotTranslation.js');
|
|
11
|
-
var _ = require('lodash');
|
|
12
|
-
var React = require('react');
|
|
13
|
-
|
|
14
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
|
|
16
|
-
var ___default = /*#__PURE__*/_interopDefault(_);
|
|
17
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
|
-
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __defProps = Object.defineProperties;
|
|
21
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
22
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
23
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
25
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value
|
|
30
|
-
}) : obj[key] = value;
|
|
31
|
-
var __spreadValues = (a, b) => {
|
|
32
|
-
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
33
|
-
if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
|
|
34
|
-
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
35
|
-
}
|
|
36
|
-
return a;
|
|
37
|
-
};
|
|
38
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
39
|
-
var __objRest = (source, exclude) => {
|
|
40
|
-
var target = {};
|
|
41
|
-
for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
|
|
42
|
-
if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
|
|
43
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
|
|
44
|
-
}
|
|
45
|
-
return target;
|
|
46
|
-
};
|
|
47
|
-
const InputStyle = "E_i11gg7mj";
|
|
48
|
-
const CountTextStyle = "E_cc368xp";
|
|
49
|
-
const IconContainerStyle = "E_i11o6xqj";
|
|
50
|
-
const DisabledIconStyle = "E_d19ruhdj";
|
|
51
|
-
const SearchInput = props => {
|
|
52
|
-
const _a = props,
|
|
53
|
-
{
|
|
54
|
-
onChange,
|
|
55
|
-
debounceWait = 300,
|
|
56
|
-
total = 0,
|
|
57
|
-
onSearchNext,
|
|
58
|
-
onSearchPrev,
|
|
59
|
-
prefixHoverIcon,
|
|
60
|
-
nextHoverIcon,
|
|
61
|
-
clearHoverIcon,
|
|
62
|
-
prefixIcon,
|
|
63
|
-
nextIcon,
|
|
64
|
-
clearIcon,
|
|
65
|
-
width,
|
|
66
|
-
searchIcon,
|
|
67
|
-
current: externalCurrent
|
|
68
|
-
} = _a,
|
|
69
|
-
restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
|
|
70
|
-
const [internalCurrent, setInternalCurrent] = React.useState(0);
|
|
71
|
-
const [value, setValue] = React.useState(props.value || "");
|
|
72
|
-
const {
|
|
73
|
-
t
|
|
74
|
-
} = useParrotTranslation();
|
|
75
|
-
const onSearch = ___default.default.debounce(onChange, debounceWait);
|
|
76
|
-
const isNoMatch = total === 0;
|
|
77
|
-
const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
|
|
78
|
-
const setCurrent = React.useCallback(newCurrent => {
|
|
79
|
-
if (externalCurrent === void 0) {
|
|
80
|
-
setInternalCurrent(newCurrent);
|
|
81
|
-
}
|
|
82
|
-
}, [externalCurrent]);
|
|
83
|
-
const next = React.useCallback(() => {
|
|
84
|
-
if (total) {
|
|
85
|
-
const nextCurrent = current + 1 > total ? 1 : current + 1;
|
|
86
|
-
onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
|
|
87
|
-
setCurrent(nextCurrent);
|
|
88
|
-
}
|
|
89
|
-
}, [onSearchNext, current, total, value, setCurrent]);
|
|
90
|
-
const prev = React.useCallback(() => {
|
|
91
|
-
if (total) {
|
|
92
|
-
const prevCurrent = current - 1 < 1 ? total : current - 1;
|
|
93
|
-
onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
|
|
94
|
-
setCurrent(prevCurrent);
|
|
95
|
-
}
|
|
96
|
-
}, [onSearchPrev, current, total, value, setCurrent]);
|
|
97
|
-
const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.default.createElement("span", {
|
|
98
|
-
className: core.cx(index.Typo.Label.l4_regular, "counter-text", CountTextStyle)
|
|
99
|
-
}, current, "/", total) : null, /* @__PURE__ */React__default.default.createElement("span", {
|
|
100
|
-
className: IconContainerStyle
|
|
101
|
-
}, isNoMatch ? /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
102
|
-
className: DisabledIconStyle,
|
|
103
|
-
src: iconsReact.ArrowChevronUp16SecondaryIcon,
|
|
104
|
-
style: {
|
|
105
|
-
opacity: 0.5
|
|
106
|
-
}
|
|
107
|
-
}) : /* @__PURE__ */React__default.default.createElement(index$2, {
|
|
108
|
-
title: t("components.prev")
|
|
109
|
-
}, /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
110
|
-
src: prefixIcon != null ? prefixIcon : iconsReact.ArrowChevronUp16SecondaryIcon,
|
|
111
|
-
hoverSrc: prefixHoverIcon != null ? prefixHoverIcon : iconsReact.ArrowChevronUp16BlueIcon,
|
|
112
|
-
onClick: prev
|
|
113
|
-
})), isNoMatch ? /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
114
|
-
className: DisabledIconStyle,
|
|
115
|
-
src: iconsReact.ArrowChevronDown16SecondaryIcon,
|
|
116
|
-
style: {
|
|
117
|
-
opacity: 0.5
|
|
118
|
-
}
|
|
119
|
-
}) : /* @__PURE__ */React__default.default.createElement(index$2, {
|
|
120
|
-
title: t("components.next")
|
|
121
|
-
}, /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
122
|
-
src: nextIcon != null ? nextIcon : iconsReact.ArrowChevronDown16SecondaryIcon,
|
|
123
|
-
hoverSrc: nextHoverIcon != null ? nextHoverIcon : iconsReact.ArrowChevronDown16BlueIcon,
|
|
124
|
-
onClick: next
|
|
125
|
-
})), /* @__PURE__ */React__default.default.createElement(index$2, {
|
|
126
|
-
title: t("components.clear")
|
|
127
|
-
}, /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
128
|
-
src: clearIcon != null ? clearIcon : iconsReact.XmarkCloseCircleFill16TertiaryIcon,
|
|
129
|
-
hoverSrc: clearHoverIcon != null ? clearHoverIcon : iconsReact.XmarkCloseCircleFill16SecondaryIcon,
|
|
130
|
-
onClick: () => {
|
|
131
|
-
onSearch("");
|
|
132
|
-
setValue("");
|
|
133
|
-
}
|
|
134
|
-
})))) : null;
|
|
135
|
-
React.useEffect(() => {
|
|
136
|
-
setValue(props.value || "");
|
|
137
|
-
}, [props.value]);
|
|
138
|
-
React.useEffect(() => {
|
|
139
|
-
if (externalCurrent === void 0) {
|
|
140
|
-
setCurrent(total ? 1 : 0);
|
|
141
|
-
}
|
|
142
|
-
}, [value, total, externalCurrent, setCurrent]);
|
|
143
|
-
return /* @__PURE__ */React__default.default.createElement(index$3, __spreadProps(__spreadValues({
|
|
144
|
-
style: {
|
|
145
|
-
width: width != null ? width : 276
|
|
146
|
-
},
|
|
147
|
-
prefix: searchIcon ? /* @__PURE__ */React__default.default.createElement(index$1, {
|
|
148
|
-
src: searchIcon
|
|
149
|
-
}) : /* @__PURE__ */React__default.default.createElement(icons.SearchOutlined, null),
|
|
150
|
-
suffix,
|
|
151
|
-
onChange: e => {
|
|
152
|
-
const newValue = e.target.value;
|
|
153
|
-
onSearch(newValue);
|
|
154
|
-
setValue(newValue);
|
|
155
|
-
},
|
|
156
|
-
onPressEnter: next,
|
|
157
|
-
value
|
|
158
|
-
}, restProps), {
|
|
159
|
-
className: core.cx(InputStyle, restProps.className)
|
|
160
|
-
}));
|
|
161
|
-
};
|
|
162
|
-
var SearchInput$1 = SearchInput;
|
|
163
|
-
|
|
164
|
-
module.exports = SearchInput$1;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('../../core/Button/index.js');
|
|
4
|
-
var useParrotTranslation = require('../../hooks/useParrotTranslation.js');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var CopyTooltip = require('./CopyTooltip.js');
|
|
7
|
-
|
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
|
-
|
|
12
|
-
const CopyButton = ({
|
|
13
|
-
text,
|
|
14
|
-
buttonText,
|
|
15
|
-
tooltipText
|
|
16
|
-
}) => {
|
|
17
|
-
const { t } = useParrotTranslation();
|
|
18
|
-
const [tooltipVisible, setTooltipVisible] = React.useState(false);
|
|
19
|
-
const handleCopy = async () => {
|
|
20
|
-
try {
|
|
21
|
-
setTooltipVisible(true);
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
setTooltipVisible(false);
|
|
24
|
-
}, 1e3);
|
|
25
|
-
} catch (err) {
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
return /* @__PURE__ */ React__default.default.createElement(
|
|
29
|
-
CopyTooltip,
|
|
30
|
-
{
|
|
31
|
-
tooltipProps: { visible: tooltipVisible },
|
|
32
|
-
text,
|
|
33
|
-
afterTooltip: tooltipText ? tooltipText : t("common.has_copied_to_clipboard")
|
|
34
|
-
},
|
|
35
|
-
/* @__PURE__ */ React__default.default.createElement(index, { onClick: handleCopy }, buttonText ? buttonText : t("common.copy"))
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
var CopyButton$1 = CopyButton;
|
|
39
|
-
|
|
40
|
-
module.exports = CopyButton$1;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var iconsReact = require('@cloudtower/icons-react');
|
|
4
|
-
var index = require('../../core/Icon/index.js');
|
|
5
|
-
var index$1 = require('../../core/Tooltip/index.js');
|
|
6
|
-
var useParrotTranslation = require('../../hooks/useParrotTranslation.js');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var CopyToClipboard = require('react-copy-to-clipboard');
|
|
9
|
-
|
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
|
-
var CopyToClipboard__default = /*#__PURE__*/_interopDefault(CopyToClipboard);
|
|
14
|
-
|
|
15
|
-
var __defProp = Object.defineProperty;
|
|
16
|
-
var __defProps = Object.defineProperties;
|
|
17
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
18
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
19
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
21
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
-
var __spreadValues = (a, b) => {
|
|
23
|
-
for (var prop in b || (b = {}))
|
|
24
|
-
if (__hasOwnProp.call(b, prop))
|
|
25
|
-
__defNormalProp(a, prop, b[prop]);
|
|
26
|
-
if (__getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
28
|
-
if (__propIsEnum.call(b, prop))
|
|
29
|
-
__defNormalProp(a, prop, b[prop]);
|
|
30
|
-
}
|
|
31
|
-
return a;
|
|
32
|
-
};
|
|
33
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
34
|
-
const CopyTooltip = React__default.default.forwardRef(
|
|
35
|
-
(props, ref) => {
|
|
36
|
-
const { t } = useParrotTranslation();
|
|
37
|
-
const {
|
|
38
|
-
text,
|
|
39
|
-
beforeTooltip = t("common.click_to_copy"),
|
|
40
|
-
afterTooltip = t("common.copy_done"),
|
|
41
|
-
children = /* @__PURE__ */ React__default.default.createElement(index, { src: iconsReact.ClipboardCopy16GradientGrayIcon }),
|
|
42
|
-
tooltipProps,
|
|
43
|
-
className
|
|
44
|
-
} = props;
|
|
45
|
-
const [tooltipText, setTooltipText] = React.useState(beforeTooltip);
|
|
46
|
-
return /* @__PURE__ */ React__default.default.createElement(
|
|
47
|
-
"span",
|
|
48
|
-
{
|
|
49
|
-
ref,
|
|
50
|
-
onMouseEnter: () => setTooltipText(beforeTooltip),
|
|
51
|
-
className
|
|
52
|
-
},
|
|
53
|
-
/* @__PURE__ */ React__default.default.createElement(index$1, __spreadProps(__spreadValues({}, tooltipProps), { title: tooltipText }), /* @__PURE__ */ React__default.default.createElement(
|
|
54
|
-
CopyToClipboard__default.default,
|
|
55
|
-
{
|
|
56
|
-
text,
|
|
57
|
-
onCopy: () => setTooltipText(afterTooltip)
|
|
58
|
-
},
|
|
59
|
-
children
|
|
60
|
-
))
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
var CopyTooltip$1 = CopyTooltip;
|
|
65
|
-
|
|
66
|
-
module.exports = CopyTooltip$1;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var formatDuration = require('../utils/formatDuration.js');
|
|
5
|
-
|
|
6
|
-
function useFormatDuration(milliseconds, options = {
|
|
7
|
-
maxDisplayUnits: 2,
|
|
8
|
-
useAbbreviation: false,
|
|
9
|
-
minUnit: "second"
|
|
10
|
-
}) {
|
|
11
|
-
const {
|
|
12
|
-
maxDisplayUnits = 2,
|
|
13
|
-
useAbbreviation = false,
|
|
14
|
-
minUnit = "second"
|
|
15
|
-
} = options;
|
|
16
|
-
const result = React.useMemo(() => {
|
|
17
|
-
const items = formatDuration.formatDuration(milliseconds, { maxDisplayUnits, minUnit });
|
|
18
|
-
const shouldUseAbbreviation = items.length > 1 && useAbbreviation;
|
|
19
|
-
const parts = items.map((item) => {
|
|
20
|
-
const suffix = shouldUseAbbreviation ? "_abbreviation" : "";
|
|
21
|
-
const i18nKey = `unit.${item.unit}${suffix}`;
|
|
22
|
-
return {
|
|
23
|
-
value: item.value,
|
|
24
|
-
unit: item.unit,
|
|
25
|
-
i18nKey
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
parts
|
|
30
|
-
};
|
|
31
|
-
}, [milliseconds, maxDisplayUnits, useAbbreviation, minUnit]);
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.useFormatDuration = useFormatDuration;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function formatDuration(milliseconds, options = {}) {
|
|
4
|
-
const { maxDisplayUnits = 2, minUnit = "second" } = options;
|
|
5
|
-
const effectiveMaxDisplayUnits = Math.max(1, maxDisplayUnits);
|
|
6
|
-
if (milliseconds < 0 || milliseconds === 0) {
|
|
7
|
-
const minUnitValue2 = minUnit || "second";
|
|
8
|
-
return [{ value: 0, unit: minUnitValue2 }];
|
|
9
|
-
}
|
|
10
|
-
const units = [
|
|
11
|
-
{ value: 365 * 24 * 60 * 60 * 1e3, unit: "year" },
|
|
12
|
-
{ value: 30 * 24 * 60 * 60 * 1e3, unit: "month" },
|
|
13
|
-
{ value: 7 * 24 * 60 * 60 * 1e3, unit: "week" },
|
|
14
|
-
{ value: 24 * 60 * 60 * 1e3, unit: "day" },
|
|
15
|
-
{ value: 60 * 60 * 1e3, unit: "hour" },
|
|
16
|
-
{ value: 60 * 1e3, unit: "minute" },
|
|
17
|
-
{ value: 1e3, unit: "second" },
|
|
18
|
-
{ value: 1, unit: "millisecond" }
|
|
19
|
-
];
|
|
20
|
-
const minUnitValue = minUnit || "second";
|
|
21
|
-
const minUnitIndex = units.findIndex((u) => u.unit === minUnitValue);
|
|
22
|
-
if (minUnitIndex === -1) {
|
|
23
|
-
const defaultMinUnitIndex = units.findIndex((u) => u.unit === "second");
|
|
24
|
-
const filteredUnits2 = units.slice(0, defaultMinUnitIndex + 1);
|
|
25
|
-
const parts2 = [];
|
|
26
|
-
let remaining2 = milliseconds;
|
|
27
|
-
for (const unitDef of filteredUnits2) {
|
|
28
|
-
if (remaining2 >= unitDef.value) {
|
|
29
|
-
const count = Math.floor(remaining2 / unitDef.value);
|
|
30
|
-
remaining2 = remaining2 % unitDef.value;
|
|
31
|
-
parts2.push({
|
|
32
|
-
value: count,
|
|
33
|
-
unit: unitDef.unit
|
|
34
|
-
});
|
|
35
|
-
if (parts2.length >= effectiveMaxDisplayUnits) {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (parts2.length === 0) {
|
|
41
|
-
return [{ value: 0, unit: "second" }];
|
|
42
|
-
}
|
|
43
|
-
return parts2;
|
|
44
|
-
}
|
|
45
|
-
const filteredUnits = units.slice(0, minUnitIndex + 1);
|
|
46
|
-
const parts = [];
|
|
47
|
-
let remaining = milliseconds;
|
|
48
|
-
for (const unitDef of filteredUnits) {
|
|
49
|
-
if (remaining >= unitDef.value) {
|
|
50
|
-
const count = Math.floor(remaining / unitDef.value);
|
|
51
|
-
remaining = remaining % unitDef.value;
|
|
52
|
-
parts.push({
|
|
53
|
-
value: count,
|
|
54
|
-
unit: unitDef.unit
|
|
55
|
-
});
|
|
56
|
-
if (parts.length >= effectiveMaxDisplayUnits) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (parts.length === 0) {
|
|
62
|
-
return [{ value: 0, unit: minUnitValue || "second" }];
|
|
63
|
-
}
|
|
64
|
-
return parts;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
exports.formatDuration = formatDuration;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { cx } from '@linaria/core';
|
|
3
|
-
import Empty from '../Empty/index.js';
|
|
4
|
-
import { ParrotTrans } from '../ParrotTrans/index.js';
|
|
5
|
-
import { useFormatDuration } from '../../hooks/useFormatDuration.js';
|
|
6
|
-
import isEmpty from '../../utils/isEmpty.js';
|
|
7
|
-
import { formatDuration } from '../../utils/formatDuration.js';
|
|
8
|
-
import { UnitStyle } from '../Styled/index.js';
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
12
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
-
var __spreadValues = (a, b) => {
|
|
16
|
-
for (var prop in b || (b = {}))
|
|
17
|
-
if (__hasOwnProp.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
if (__getOwnPropSymbols)
|
|
20
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
-
if (__propIsEnum.call(b, prop))
|
|
22
|
-
__defNormalProp(a, prop, b[prop]);
|
|
23
|
-
}
|
|
24
|
-
return a;
|
|
25
|
-
};
|
|
26
|
-
const Duration = ({
|
|
27
|
-
rawValue,
|
|
28
|
-
valueClassName,
|
|
29
|
-
unitClassName,
|
|
30
|
-
abbreviate,
|
|
31
|
-
emptyProps,
|
|
32
|
-
maxDisplayUnits = 2,
|
|
33
|
-
minUnit = "second",
|
|
34
|
-
noUnitOnZero = false,
|
|
35
|
-
contentRender
|
|
36
|
-
}) => {
|
|
37
|
-
const { parts } = useFormatDuration(rawValue != null ? rawValue : 0, {
|
|
38
|
-
maxDisplayUnits,
|
|
39
|
-
useAbbreviation: abbreviate,
|
|
40
|
-
minUnit
|
|
41
|
-
});
|
|
42
|
-
if (isEmpty(rawValue)) {
|
|
43
|
-
return /* @__PURE__ */ React__default.createElement(Empty, __spreadValues({}, emptyProps));
|
|
44
|
-
}
|
|
45
|
-
if (parts.length === 0) {
|
|
46
|
-
return /* @__PURE__ */ React__default.createElement(Empty, __spreadValues({}, emptyProps));
|
|
47
|
-
}
|
|
48
|
-
if (contentRender) {
|
|
49
|
-
const formatItems = formatDuration(rawValue, {
|
|
50
|
-
maxDisplayUnits,
|
|
51
|
-
minUnit
|
|
52
|
-
});
|
|
53
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, contentRender(formatItems));
|
|
54
|
-
}
|
|
55
|
-
const allZero = parts.every((part) => part.value === 0);
|
|
56
|
-
if (noUnitOnZero && allZero) {
|
|
57
|
-
return /* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }, "0");
|
|
58
|
-
}
|
|
59
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, parts.map((part, index) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: `${part.unit}-${index}` }, index > 0 && /* @__PURE__ */ React__default.createElement("span", null, " "), /* @__PURE__ */ React__default.createElement(
|
|
60
|
-
ParrotTrans,
|
|
61
|
-
{
|
|
62
|
-
parent: "span",
|
|
63
|
-
i18nKey: part.i18nKey,
|
|
64
|
-
count: part.value
|
|
65
|
-
},
|
|
66
|
-
/* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }),
|
|
67
|
-
/* @__PURE__ */ React__default.createElement("span", { className: cx("unit", UnitStyle, unitClassName) })
|
|
68
|
-
))));
|
|
69
|
-
};
|
|
70
|
-
var Duration$1 = Duration;
|
|
71
|
-
|
|
72
|
-
export { Duration$1 as default };
|
|
@@ -1,63 +0,0 @@
|
|
|
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 };
|
|
@@ -1,97 +0,0 @@
|
|
|
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 };
|
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|