@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.
Files changed (78) hide show
  1. package/dist/cjs/core/Cascader/cascader.widget.js +12 -12
  2. package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
  3. package/dist/cjs/core/SearchInput/SearchInput.hook.js +124 -0
  4. package/dist/cjs/core/SearchInput/SearchInput.js +253 -0
  5. package/dist/cjs/core/SearchInput/SearchInput.style.js +13 -0
  6. package/dist/cjs/core/index.js +12 -15
  7. package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +4 -16
  8. package/dist/cjs/index.js +245 -253
  9. package/dist/cjs/legacy-antd.js +89 -89
  10. package/dist/cjs/stats1.html +1 -1
  11. package/dist/components.css +2423 -2578
  12. package/dist/esm/core/Cascader/cascader.widget.js +1 -1
  13. package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
  14. package/dist/esm/core/SearchInput/SearchInput.hook.js +117 -0
  15. package/dist/esm/core/SearchInput/SearchInput.js +247 -0
  16. package/dist/esm/core/SearchInput/SearchInput.style.js +7 -0
  17. package/dist/esm/core/index.js +2 -4
  18. package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +4 -16
  19. package/dist/esm/index.js +1 -5
  20. package/dist/esm/legacy-antd.js +1 -1
  21. package/dist/esm/stats1.html +1 -1
  22. package/dist/linaria.merged.scss +3680 -3841
  23. package/dist/src/core/Cascader/cascader.type.d.ts +1 -1
  24. package/dist/src/core/SearchInput/SearchInput.d.ts +2 -0
  25. package/dist/src/core/SearchInput/SearchInput.hook.d.ts +9 -0
  26. package/dist/src/core/SearchInput/SearchInput.style.d.ts +5 -0
  27. package/dist/src/core/SearchInput/{searchInput.type.d.ts → SearchInput.type.d.ts} +18 -2
  28. package/dist/src/core/SearchInput/index.d.ts +2 -4
  29. package/dist/src/core/index.d.ts +0 -6
  30. package/dist/src/coreX/Dialogs/RejectDialog/RejectDialog.type.d.ts +1 -5
  31. package/dist/src/coreX/index.d.ts +0 -3
  32. package/dist/src/hooks/index.d.ts +0 -1
  33. package/dist/src/utils/index.d.ts +0 -1
  34. package/dist/stories/docs/core/SearchInput.stories.d.ts +6 -1
  35. package/dist/stories/docs/coreX/Dialogs/RejectDialog.stories.d.ts +1 -3
  36. package/dist/style.css +2423 -2578
  37. package/package.json +4 -6
  38. package/dist/cjs/core/Duration/index.js +0 -78
  39. package/dist/cjs/core/LocalUpload/LocalUpload.hooks.js +0 -66
  40. package/dist/cjs/core/LocalUpload/LocalUpload.js +0 -103
  41. package/dist/cjs/core/LocalUpload/LocalUpload.style.js +0 -13
  42. package/dist/cjs/core/LocalUpload/LocalUpload.widget.js +0 -379
  43. package/dist/cjs/core/SearchInput/index.js +0 -164
  44. package/dist/cjs/coreX/Copy/CopyButton.js +0 -40
  45. package/dist/cjs/coreX/Copy/CopyTooltip.js +0 -66
  46. package/dist/cjs/hooks/useFormatDuration.js +0 -35
  47. package/dist/cjs/utils/formatDuration.js +0 -67
  48. package/dist/esm/core/Duration/index.js +0 -72
  49. package/dist/esm/core/LocalUpload/LocalUpload.hooks.js +0 -63
  50. package/dist/esm/core/LocalUpload/LocalUpload.js +0 -97
  51. package/dist/esm/core/LocalUpload/LocalUpload.style.js +0 -10
  52. package/dist/esm/core/LocalUpload/LocalUpload.widget.js +0 -365
  53. package/dist/esm/core/SearchInput/index.js +0 -157
  54. package/dist/esm/coreX/Copy/CopyButton.js +0 -34
  55. package/dist/esm/coreX/Copy/CopyTooltip.js +0 -59
  56. package/dist/esm/hooks/useFormatDuration.js +0 -33
  57. package/dist/esm/utils/formatDuration.js +0 -65
  58. package/dist/src/core/Duration/duration.type.d.ts +0 -42
  59. package/dist/src/core/Duration/index.d.ts +0 -4
  60. package/dist/src/core/LocalUpload/LocalUpload.d.ts +0 -15
  61. package/dist/src/core/LocalUpload/LocalUpload.hooks.d.ts +0 -32
  62. package/dist/src/core/LocalUpload/LocalUpload.style.d.ts +0 -3
  63. package/dist/src/core/LocalUpload/LocalUpload.type.d.ts +0 -175
  64. package/dist/src/core/LocalUpload/LocalUpload.widget.d.ts +0 -23
  65. package/dist/src/core/LocalUpload/index.d.ts +0 -2
  66. package/dist/src/coreX/Copy/CopyButton.d.ts +0 -5
  67. package/dist/src/coreX/Copy/CopyButton.type.d.ts +0 -8
  68. package/dist/src/coreX/Copy/CopyTooltip.d.ts +0 -5
  69. package/dist/src/coreX/Copy/CopyTooltip.typs.d.ts +0 -16
  70. package/dist/src/coreX/Copy/index.d.ts +0 -2
  71. package/dist/src/hooks/useFormatDuration.d.ts +0 -31
  72. package/dist/src/utils/__test__/formatDuration.spec.d.ts +0 -1
  73. package/dist/src/utils/formatDuration.d.ts +0 -28
  74. package/dist/stories/docs/core/Duration.stories.d.ts +0 -88
  75. package/dist/stories/docs/core/LocalUpload.stories.d.ts +0 -74
  76. package/dist/stories/docs/coreX/Copy/CopyButton.stories.d.ts +0 -66
  77. package/dist/stories/docs/coreX/Copy/CopyTooltip.stories.d.ts +0 -66
  78. /package/dist/src/{hooks/__tests__/useFormatDuration.test.d.ts → core/SearchInput/__test__/SearchInput.hook.test.d.ts} +0 -0
@@ -1,365 +0,0 @@
1
- import { Uploading16GradientGrayIcon, Uploading16GradientBlueIcon, Upload24GradientGrayIcon, Upload24GradientBlueIcon, Upload48GradientBlueIcon, XmarkRemove16SecondaryIcon, ExclamationErrorCircleFill16RedIcon, File16GradientBlueIcon, Loading16GradientBlueIcon, XmarkRemove24SecondaryIcon } from '@cloudtower/icons-react';
2
- import { cx } from '@linaria/core';
3
- import Button from '../Button/index.js';
4
- import Byte from '../Byte/index.js';
5
- import Icon from '../Icon/index.js';
6
- import Tooltip from '../Tooltip/index.js';
7
- import { Typo } from '../Typo/index.js';
8
- import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
9
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
10
- import cs from 'classnames';
11
- import _ from 'lodash';
12
- import React__default, { useState } from 'react';
13
- import { useFileValidation, useFileCountErrorClear } from './LocalUpload.hooks.js';
14
- import { FileInfoWrapperStyle } from './LocalUpload.style.js';
15
- import { Upload } from 'antd';
16
-
17
- var __defProp = Object.defineProperty;
18
- var __defProps = Object.defineProperties;
19
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
20
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
21
- var __hasOwnProp = Object.prototype.hasOwnProperty;
22
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
23
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
24
- var __spreadValues = (a, b) => {
25
- for (var prop in b || (b = {}))
26
- if (__hasOwnProp.call(b, prop))
27
- __defNormalProp(a, prop, b[prop]);
28
- if (__getOwnPropSymbols)
29
- for (var prop of __getOwnPropSymbols(b)) {
30
- if (__propIsEnum.call(b, prop))
31
- __defNormalProp(a, prop, b[prop]);
32
- }
33
- return a;
34
- };
35
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
36
- const STATUS_ICON_MAP = {
37
- error: ExclamationErrorCircleFill16RedIcon,
38
- success: File16GradientBlueIcon,
39
- validating: Loading16GradientBlueIcon,
40
- "need-validate": Loading16GradientBlueIcon
41
- };
42
- const createBeforeUploadHandler = ({
43
- fileList,
44
- setFileList,
45
- validate,
46
- maxCount,
47
- isSingleSelect,
48
- setError,
49
- t,
50
- checkSingleSelectCount = false
51
- }) => {
52
- return (file, _fileList) => {
53
- if (isSingleSelect) {
54
- if (checkSingleSelectCount && _fileList.length > 1) {
55
- setError(t("components.exceed_max_count", { count: 1 }) || "");
56
- return false;
57
- } else {
58
- setError("");
59
- }
60
- const _file2 = file;
61
- _file2.fileStatus = validate ? "need-validate" : "success";
62
- setFileList([_file2]);
63
- return false;
64
- }
65
- if (fileList.length + _fileList.length > maxCount) {
66
- setError(t("components.exceed_max_count", { count: maxCount }) || "");
67
- } else {
68
- setError("");
69
- }
70
- const _file = file;
71
- _file.fileStatus = validate ? "need-validate" : "success";
72
- const index = _fileList.findIndex((f) => f.uid === _file.uid);
73
- if (index !== -1) {
74
- const newList = _.uniqBy(
75
- [...fileList, ..._fileList.slice(0, index + 1)],
76
- "uid"
77
- );
78
- setFileList(newList);
79
- }
80
- return false;
81
- };
82
- };
83
- const UploadLabel = ({ className, children }) => {
84
- return /* @__PURE__ */ React__default.createElement("label", { className: cx("upload-label", Typo.Label.l2_regular, className) }, children);
85
- };
86
- const UploadDescription = ({ className, children }) => {
87
- return /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-description", Typo.Label.l4_regular, className) }, children);
88
- };
89
- const UploadButton = ({
90
- children,
91
- hideIcon = false,
92
- className,
93
- fileList,
94
- setFileList,
95
- validate,
96
- maxCount,
97
- multiple = false,
98
- disabled,
99
- accept
100
- }) => {
101
- const { t } = useParrotTranslation();
102
- const [error, setError] = useState("");
103
- const _maxCount = multiple ? maxCount || Infinity : 1;
104
- const isSingleSelect = _maxCount === 1;
105
- useFileValidation({
106
- fileList,
107
- setFileList,
108
- validate,
109
- createNewFile: false
110
- });
111
- useFileCountErrorClear({
112
- fileList,
113
- maxCount: _maxCount,
114
- setError
115
- });
116
- const props = {
117
- accept,
118
- fileList,
119
- showUploadList: false,
120
- beforeUpload: createBeforeUploadHandler({
121
- fileList,
122
- setFileList,
123
- validate,
124
- maxCount: _maxCount,
125
- isSingleSelect,
126
- setError,
127
- t,
128
- checkSingleSelectCount: false
129
- }),
130
- multiple
131
- };
132
- return /* @__PURE__ */ React__default.createElement(Upload, __spreadProps(__spreadValues({}, props), { className: cs("upload-button", className) }), /* @__PURE__ */ React__default.createElement(
133
- Button,
134
- {
135
- disabled,
136
- prefixIcon: !hideIcon ? /* @__PURE__ */ React__default.createElement(Icon, { src: Uploading16GradientGrayIcon }) : void 0,
137
- hoverPrefixIcon: !hideIcon ? /* @__PURE__ */ React__default.createElement(Icon, { src: Uploading16GradientBlueIcon }) : void 0
138
- },
139
- children
140
- ), error ? /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-error", Typo.Label.l4_regular) }, error) : null);
141
- };
142
- const UploadDragger = ({
143
- children,
144
- className,
145
- fileList,
146
- setFileList,
147
- validate,
148
- maxCount,
149
- multiple = false,
150
- disabled,
151
- accept
152
- }) => {
153
- var _a;
154
- const { t } = useParrotTranslation();
155
- const [error, setError] = useState("");
156
- const _maxCount = multiple ? maxCount || Infinity : 1;
157
- const isSingleSelect = _maxCount === 1;
158
- const reachMaxCount = !!maxCount && !isSingleSelect && fileList.length >= maxCount;
159
- useFileValidation({
160
- fileList,
161
- setFileList,
162
- validate,
163
- createNewFile: true
164
- });
165
- useFileCountErrorClear({
166
- fileList,
167
- maxCount: _maxCount,
168
- setError
169
- });
170
- const props = {
171
- accept,
172
- fileList,
173
- showUploadList: false,
174
- beforeUpload: createBeforeUploadHandler({
175
- fileList,
176
- setFileList,
177
- validate,
178
- maxCount: _maxCount,
179
- isSingleSelect,
180
- setError,
181
- t,
182
- checkSingleSelectCount: true
183
- }),
184
- disabled,
185
- multiple
186
- };
187
- const DefaultChildren = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
188
- Icon,
189
- {
190
- src: (fileList == null ? void 0 : fileList.length) ? reachMaxCount ? Upload24GradientGrayIcon : Upload24GradientBlueIcon : Upload48GradientBlueIcon,
191
- iconHeight: (fileList == null ? void 0 : fileList.length) ? 24 : 48,
192
- iconWidth: (fileList == null ? void 0 : fileList.length) ? 24 : 48
193
- }
194
- ), /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-drag-text", Typo.Label.l2_regular) }, t("components.upload_file_desc")));
195
- const fileStatus = isSingleSelect ? ((_a = fileList[0]) == null ? void 0 : _a.fileStatus) || "success" : void 0;
196
- const FileInfo = ({ file }) => {
197
- const fileStatus2 = file.fileStatus || "success";
198
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "file-info", onClick: (e) => e.preventDefault() }, /* @__PURE__ */ React__default.createElement(
199
- Icon,
200
- {
201
- src: STATUS_ICON_MAP[fileStatus2],
202
- isRotate: fileStatus2 === "validating" || fileStatus2 === "need-validate"
203
- }
204
- ), /* @__PURE__ */ React__default.createElement("div", { className: cx("file-name", Typo.Label.l4_regular) }, file.name || file.fileName)), /* @__PURE__ */ React__default.createElement(Button, { className: Typo.Label.l2_regular, type: "link" }, t("components.reselect_file")));
205
- };
206
- const Error2 = () => {
207
- if (error) {
208
- return /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-error", Typo.Label.l4_regular) }, error);
209
- }
210
- const file = fileList[0];
211
- if (isSingleSelect && (file == null ? void 0 : file.fileStatus) === "error" && file.error) {
212
- return /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-error", Typo.Label.l4_regular) }, file.error);
213
- }
214
- return null;
215
- };
216
- return /* @__PURE__ */ React__default.createElement("div", { className: cs("upload-drag", className) }, /* @__PURE__ */ React__default.createElement(
217
- Upload.Dragger,
218
- __spreadProps(__spreadValues({}, props), {
219
- disabled: disabled || fileStatus === "validating",
220
- className: cs(
221
- "upload-drag-area",
222
- fileList.length ? "has-file" : "",
223
- reachMaxCount && "reach-max-count",
224
- isSingleSelect && "single",
225
- fileStatus === "error" && "file-error",
226
- fileStatus === "validating" && "file-validating"
227
- )
228
- }),
229
- isSingleSelect && fileList.length ? /* @__PURE__ */ React__default.createElement(FileInfo, { file: fileList[0] }) : children || DefaultChildren
230
- ), /* @__PURE__ */ React__default.createElement(Error2, null));
231
- };
232
- const UploadFileInfo = ({
233
- file,
234
- removeFile,
235
- disabled,
236
- onRemove
237
- }) => {
238
- const fileStatus = file.fileStatus || "success";
239
- const handleRemove = () => {
240
- var _a;
241
- removeFile((_a = file.uid) != null ? _a : "");
242
- if (onRemove && "fileStatus" in file) {
243
- onRemove(file);
244
- }
245
- };
246
- return /* @__PURE__ */ React__default.createElement(
247
- "div",
248
- {
249
- className: cs(FileInfoWrapperStyle, {
250
- "file-error-wrapper": fileStatus === "error",
251
- disabled
252
- })
253
- },
254
- /* @__PURE__ */ React__default.createElement(
255
- Icon,
256
- {
257
- src: STATUS_ICON_MAP[fileStatus],
258
- isRotate: fileStatus === "validating" || fileStatus === "need-validate"
259
- }
260
- ),
261
- /* @__PURE__ */ React__default.createElement("div", { className: cx("file-info", Typo.Label.l4_regular) }, /* @__PURE__ */ React__default.createElement(
262
- OverflowTooltip,
263
- {
264
- className: "file-name",
265
- content: file.name || file.fileName,
266
- tooltip: file.name || file.fileName
267
- }
268
- ), file.size ? /* @__PURE__ */ React__default.createElement("div", { className: "file-info" }, /* @__PURE__ */ React__default.createElement(
269
- Byte,
270
- {
271
- rawValue: file.size,
272
- valueClassName: "file-size",
273
- unitClassName: "file-size-unit"
274
- }
275
- )) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), file.fileStatus === "error" && !!file.error && /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-file-error", Typo.Footnote.f2_regular) }, file.error)),
276
- /* @__PURE__ */ React__default.createElement(
277
- Icon,
278
- {
279
- src: XmarkRemove16SecondaryIcon,
280
- onClick: disabled ? void 0 : handleRemove
281
- }
282
- )
283
- );
284
- };
285
- const FileListItem = ({ file, removeFile, onRemove }) => {
286
- const fileStatus = file.fileStatus || "success";
287
- const { t } = useParrotTranslation();
288
- const handleRemove = (e) => {
289
- e.stopPropagation();
290
- removeFile(file.uid);
291
- onRemove == null ? void 0 : onRemove(file);
292
- };
293
- return /* @__PURE__ */ React__default.createElement(
294
- "div",
295
- {
296
- className: cx("upload-file-item", Typo.Label.l4_regular),
297
- key: file.uid
298
- },
299
- /* @__PURE__ */ React__default.createElement("div", { className: "upload-file-info" }, /* @__PURE__ */ React__default.createElement("div", { className: "file-info" }, /* @__PURE__ */ React__default.createElement(
300
- Icon,
301
- {
302
- src: STATUS_ICON_MAP[fileStatus],
303
- isRotate: fileStatus === "validating" || fileStatus === "need-validate"
304
- }
305
- ), /* @__PURE__ */ React__default.createElement(
306
- "div",
307
- {
308
- className: fileStatus === "validating" || fileStatus === "need-validate" ? "validating" : ""
309
- },
310
- file.name || file.fileName
311
- )), /* @__PURE__ */ React__default.createElement(Tooltip, { title: t("common.remove") }, /* @__PURE__ */ React__default.createElement(
312
- Icon,
313
- {
314
- className: "remove-button",
315
- src: XmarkRemove24SecondaryIcon,
316
- onClick: handleRemove
317
- }
318
- ))),
319
- file.fileStatus === "error" && !!file.error && /* @__PURE__ */ React__default.createElement("div", { className: cx("upload-file-error", Typo.Footnote.f2_regular) }, file.error)
320
- );
321
- };
322
- const UploadFileList = ({
323
- className,
324
- fileList,
325
- removeFile,
326
- type = "list",
327
- disableRemove = false,
328
- onRemove
329
- }) => {
330
- if (!fileList.length) {
331
- return null;
332
- }
333
- return /* @__PURE__ */ React__default.createElement(
334
- "div",
335
- {
336
- className: cs(
337
- "upload-file-list",
338
- type === "list" ? "" : "upload-file-info-list",
339
- className
340
- )
341
- },
342
- fileList.map(
343
- (file) => type === "list" ? /* @__PURE__ */ React__default.createElement(
344
- FileListItem,
345
- {
346
- key: file.uid,
347
- file,
348
- removeFile,
349
- onRemove
350
- }
351
- ) : /* @__PURE__ */ React__default.createElement(
352
- UploadFileInfo,
353
- {
354
- key: file.uid,
355
- file,
356
- removeFile,
357
- disabled: disableRemove,
358
- onRemove
359
- }
360
- )
361
- )
362
- );
363
- };
364
-
365
- export { FileListItem, UploadButton, UploadDescription, UploadDragger, UploadFileInfo, UploadFileList, UploadLabel };
@@ -1,157 +0,0 @@
1
- import { SearchOutlined } from '@ant-design/icons';
2
- import { ArrowChevronUp16SecondaryIcon, ArrowChevronUp16BlueIcon, ArrowChevronDown16SecondaryIcon, ArrowChevronDown16BlueIcon, XmarkCloseCircleFill16TertiaryIcon, XmarkCloseCircleFill16SecondaryIcon } from '@cloudtower/icons-react';
3
- import { cx } from '@linaria/core';
4
- import Icon from '../Icon/index.js';
5
- import Input from '../Input/index.js';
6
- import Tooltip from '../Tooltip/index.js';
7
- import { Typo } from '../Typo/index.js';
8
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
9
- import _ from 'lodash';
10
- import React__default, { useState, useCallback, useEffect } from 'react';
11
-
12
- var __defProp = Object.defineProperty;
13
- var __defProps = Object.defineProperties;
14
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
15
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
18
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value
23
- }) : obj[key] = value;
24
- var __spreadValues = (a, b) => {
25
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
26
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
27
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
28
- }
29
- return a;
30
- };
31
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
32
- var __objRest = (source, exclude) => {
33
- var target = {};
34
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
35
- if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
36
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
37
- }
38
- return target;
39
- };
40
- const InputStyle = "E_i11gg7mj";
41
- const CountTextStyle = "E_cc368xp";
42
- const IconContainerStyle = "E_i11o6xqj";
43
- const DisabledIconStyle = "E_d19ruhdj";
44
- const SearchInput = props => {
45
- const _a = props,
46
- {
47
- onChange,
48
- debounceWait = 300,
49
- total = 0,
50
- onSearchNext,
51
- onSearchPrev,
52
- prefixHoverIcon,
53
- nextHoverIcon,
54
- clearHoverIcon,
55
- prefixIcon,
56
- nextIcon,
57
- clearIcon,
58
- width,
59
- searchIcon,
60
- current: externalCurrent
61
- } = _a,
62
- restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
63
- const [internalCurrent, setInternalCurrent] = useState(0);
64
- const [value, setValue] = useState(props.value || "");
65
- const {
66
- t
67
- } = useParrotTranslation();
68
- const onSearch = _.debounce(onChange, debounceWait);
69
- const isNoMatch = total === 0;
70
- const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
71
- const setCurrent = useCallback(newCurrent => {
72
- if (externalCurrent === void 0) {
73
- setInternalCurrent(newCurrent);
74
- }
75
- }, [externalCurrent]);
76
- const next = useCallback(() => {
77
- if (total) {
78
- const nextCurrent = current + 1 > total ? 1 : current + 1;
79
- onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
80
- setCurrent(nextCurrent);
81
- }
82
- }, [onSearchNext, current, total, value, setCurrent]);
83
- const prev = useCallback(() => {
84
- if (total) {
85
- const prevCurrent = current - 1 < 1 ? total : current - 1;
86
- onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
87
- setCurrent(prevCurrent);
88
- }
89
- }, [onSearchPrev, current, total, value, setCurrent]);
90
- const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.createElement(React__default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.createElement("span", {
91
- className: cx(Typo.Label.l4_regular, "counter-text", CountTextStyle)
92
- }, current, "/", total) : null, /* @__PURE__ */React__default.createElement("span", {
93
- className: IconContainerStyle
94
- }, isNoMatch ? /* @__PURE__ */React__default.createElement(Icon, {
95
- className: DisabledIconStyle,
96
- src: ArrowChevronUp16SecondaryIcon,
97
- style: {
98
- opacity: 0.5
99
- }
100
- }) : /* @__PURE__ */React__default.createElement(Tooltip, {
101
- title: t("components.prev")
102
- }, /* @__PURE__ */React__default.createElement(Icon, {
103
- src: prefixIcon != null ? prefixIcon : ArrowChevronUp16SecondaryIcon,
104
- hoverSrc: prefixHoverIcon != null ? prefixHoverIcon : ArrowChevronUp16BlueIcon,
105
- onClick: prev
106
- })), isNoMatch ? /* @__PURE__ */React__default.createElement(Icon, {
107
- className: DisabledIconStyle,
108
- src: ArrowChevronDown16SecondaryIcon,
109
- style: {
110
- opacity: 0.5
111
- }
112
- }) : /* @__PURE__ */React__default.createElement(Tooltip, {
113
- title: t("components.next")
114
- }, /* @__PURE__ */React__default.createElement(Icon, {
115
- src: nextIcon != null ? nextIcon : ArrowChevronDown16SecondaryIcon,
116
- hoverSrc: nextHoverIcon != null ? nextHoverIcon : ArrowChevronDown16BlueIcon,
117
- onClick: next
118
- })), /* @__PURE__ */React__default.createElement(Tooltip, {
119
- title: t("components.clear")
120
- }, /* @__PURE__ */React__default.createElement(Icon, {
121
- src: clearIcon != null ? clearIcon : XmarkCloseCircleFill16TertiaryIcon,
122
- hoverSrc: clearHoverIcon != null ? clearHoverIcon : XmarkCloseCircleFill16SecondaryIcon,
123
- onClick: () => {
124
- onSearch("");
125
- setValue("");
126
- }
127
- })))) : null;
128
- useEffect(() => {
129
- setValue(props.value || "");
130
- }, [props.value]);
131
- useEffect(() => {
132
- if (externalCurrent === void 0) {
133
- setCurrent(total ? 1 : 0);
134
- }
135
- }, [value, total, externalCurrent, setCurrent]);
136
- return /* @__PURE__ */React__default.createElement(Input, __spreadProps(__spreadValues({
137
- style: {
138
- width: width != null ? width : 276
139
- },
140
- prefix: searchIcon ? /* @__PURE__ */React__default.createElement(Icon, {
141
- src: searchIcon
142
- }) : /* @__PURE__ */React__default.createElement(SearchOutlined, null),
143
- suffix,
144
- onChange: e => {
145
- const newValue = e.target.value;
146
- onSearch(newValue);
147
- setValue(newValue);
148
- },
149
- onPressEnter: next,
150
- value
151
- }, restProps), {
152
- className: cx(InputStyle, restProps.className)
153
- }));
154
- };
155
- var SearchInput$1 = SearchInput;
156
-
157
- export { SearchInput$1 as default };
@@ -1,34 +0,0 @@
1
- import Button from '../../core/Button/index.js';
2
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
3
- import React__default, { useState } from 'react';
4
- import CopyTooltip from './CopyTooltip.js';
5
-
6
- const CopyButton = ({
7
- text,
8
- buttonText,
9
- tooltipText
10
- }) => {
11
- const { t } = useParrotTranslation();
12
- const [tooltipVisible, setTooltipVisible] = useState(false);
13
- const handleCopy = async () => {
14
- try {
15
- setTooltipVisible(true);
16
- setTimeout(() => {
17
- setTooltipVisible(false);
18
- }, 1e3);
19
- } catch (err) {
20
- }
21
- };
22
- return /* @__PURE__ */ React__default.createElement(
23
- CopyTooltip,
24
- {
25
- tooltipProps: { visible: tooltipVisible },
26
- text,
27
- afterTooltip: tooltipText ? tooltipText : t("common.has_copied_to_clipboard")
28
- },
29
- /* @__PURE__ */ React__default.createElement(Button, { onClick: handleCopy }, buttonText ? buttonText : t("common.copy"))
30
- );
31
- };
32
- var CopyButton$1 = CopyButton;
33
-
34
- export { CopyButton$1 as default };
@@ -1,59 +0,0 @@
1
- import { ClipboardCopy16GradientGrayIcon } from '@cloudtower/icons-react';
2
- import Icon from '../../core/Icon/index.js';
3
- import Tooltip from '../../core/Tooltip/index.js';
4
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
5
- import React__default, { useState } from 'react';
6
- import CopyToClipboard from 'react-copy-to-clipboard';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __defProps = Object.defineProperties;
10
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
- const CopyTooltip = React__default.forwardRef(
28
- (props, ref) => {
29
- const { t } = useParrotTranslation();
30
- const {
31
- text,
32
- beforeTooltip = t("common.click_to_copy"),
33
- afterTooltip = t("common.copy_done"),
34
- children = /* @__PURE__ */ React__default.createElement(Icon, { src: ClipboardCopy16GradientGrayIcon }),
35
- tooltipProps,
36
- className
37
- } = props;
38
- const [tooltipText, setTooltipText] = useState(beforeTooltip);
39
- return /* @__PURE__ */ React__default.createElement(
40
- "span",
41
- {
42
- ref,
43
- onMouseEnter: () => setTooltipText(beforeTooltip),
44
- className
45
- },
46
- /* @__PURE__ */ React__default.createElement(Tooltip, __spreadProps(__spreadValues({}, tooltipProps), { title: tooltipText }), /* @__PURE__ */ React__default.createElement(
47
- CopyToClipboard,
48
- {
49
- text,
50
- onCopy: () => setTooltipText(afterTooltip)
51
- },
52
- children
53
- ))
54
- );
55
- }
56
- );
57
- var CopyTooltip$1 = CopyTooltip;
58
-
59
- export { CopyTooltip$1 as default };
@@ -1,33 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { formatDuration } from '../utils/formatDuration.js';
3
-
4
- function useFormatDuration(milliseconds, options = {
5
- maxDisplayUnits: 2,
6
- useAbbreviation: false,
7
- minUnit: "second"
8
- }) {
9
- const {
10
- maxDisplayUnits = 2,
11
- useAbbreviation = false,
12
- minUnit = "second"
13
- } = options;
14
- const result = useMemo(() => {
15
- const items = formatDuration(milliseconds, { maxDisplayUnits, minUnit });
16
- const shouldUseAbbreviation = items.length > 1 && useAbbreviation;
17
- const parts = items.map((item) => {
18
- const suffix = shouldUseAbbreviation ? "_abbreviation" : "";
19
- const i18nKey = `unit.${item.unit}${suffix}`;
20
- return {
21
- value: item.value,
22
- unit: item.unit,
23
- i18nKey
24
- };
25
- });
26
- return {
27
- parts
28
- };
29
- }, [milliseconds, maxDisplayUnits, useAbbreviation, minUnit]);
30
- return result;
31
- }
32
-
33
- export { useFormatDuration };