@cloudtower/eagle 0.35.1 → 0.35.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.
Files changed (81) hide show
  1. package/dist/cjs/UIKitProvider/index.js +5 -10
  2. package/dist/cjs/core/ConfigProvider/index.js +3 -1
  3. package/dist/cjs/core/Fields/FieldsTimePicker/index.js +4 -3
  4. package/dist/cjs/core/ImmersiveDialog/index.js +21 -14
  5. package/dist/cjs/core/{Modal → LegacyModal}/index.js +7 -3
  6. package/dist/cjs/core/LegacySelect/index.js +4 -0
  7. package/dist/cjs/core/LocalUpload/LocalUpload.hooks.js +66 -0
  8. package/dist/cjs/core/LocalUpload/LocalUpload.js +103 -0
  9. package/dist/cjs/core/LocalUpload/LocalUpload.style.js +13 -0
  10. package/dist/cjs/core/LocalUpload/LocalUpload.widget.js +379 -0
  11. package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
  12. package/dist/cjs/core/SmallDialog/SmallDialog.js +7 -5
  13. package/dist/cjs/core/Tab/Tab.js +113 -0
  14. package/dist/cjs/core/Tab/Tab.style.js +17 -0
  15. package/dist/cjs/core/Tab/Tab.type.js +9 -0
  16. package/dist/cjs/core/Tab/useTabAdaptiveLayout.js +73 -0
  17. package/dist/cjs/core/message/message.js +24 -1
  18. package/dist/cjs/coreX/KubeConfigModal/index.js +4 -4
  19. package/dist/cjs/hooks/useAntdPatchEnLocales.js +35 -0
  20. package/dist/cjs/hooks/useLegacyComponentWarning.js +16 -0
  21. package/dist/cjs/index.js +20 -16
  22. package/dist/cjs/legacy-antd.js +2 -2
  23. package/dist/cjs/stats1.html +1 -1
  24. package/dist/components.css +1926 -1557
  25. package/dist/esm/UIKitProvider/index.js +5 -10
  26. package/dist/esm/core/ConfigProvider/index.js +3 -1
  27. package/dist/esm/core/Fields/FieldsTimePicker/index.js +2 -1
  28. package/dist/esm/core/ImmersiveDialog/index.js +21 -14
  29. package/dist/esm/core/{Modal → LegacyModal}/index.js +9 -5
  30. package/dist/esm/core/LegacySelect/index.js +4 -0
  31. package/dist/esm/core/LocalUpload/LocalUpload.hooks.js +63 -0
  32. package/dist/esm/core/LocalUpload/LocalUpload.js +97 -0
  33. package/dist/esm/core/LocalUpload/LocalUpload.style.js +10 -0
  34. package/dist/esm/core/LocalUpload/LocalUpload.widget.js +365 -0
  35. package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
  36. package/dist/esm/core/SmallDialog/SmallDialog.js +6 -4
  37. package/dist/esm/core/Tab/Tab.js +107 -0
  38. package/dist/esm/core/Tab/Tab.style.js +12 -0
  39. package/dist/esm/core/Tab/Tab.type.js +7 -0
  40. package/dist/esm/core/Tab/useTabAdaptiveLayout.js +71 -0
  41. package/dist/esm/core/message/message.js +24 -1
  42. package/dist/esm/coreX/KubeConfigModal/index.js +5 -5
  43. package/dist/esm/hooks/useAntdPatchEnLocales.js +29 -0
  44. package/dist/esm/hooks/useLegacyComponentWarning.js +14 -0
  45. package/dist/esm/index.js +3 -1
  46. package/dist/esm/legacy-antd.js +4 -4
  47. package/dist/esm/stats1.html +1 -1
  48. package/dist/linaria.merged.scss +1968 -1541
  49. package/dist/src/core/ImmersiveDialog/type.d.ts +2 -2
  50. package/dist/src/core/{Modal/modal.type.d.ts → LegacyModal/LegacyModal.type.d.ts} +12 -1
  51. package/dist/src/core/LegacyModal/index.d.ts +16 -0
  52. package/dist/src/core/LocalUpload/LocalUpload.d.ts +15 -0
  53. package/dist/src/core/LocalUpload/LocalUpload.hooks.d.ts +32 -0
  54. package/dist/src/core/LocalUpload/LocalUpload.style.d.ts +3 -0
  55. package/dist/src/core/LocalUpload/LocalUpload.type.d.ts +175 -0
  56. package/dist/src/core/LocalUpload/LocalUpload.widget.d.ts +23 -0
  57. package/dist/src/core/LocalUpload/index.d.ts +2 -0
  58. package/dist/src/core/SmallDialog/SmallDialog.type.d.ts +2 -0
  59. package/dist/src/core/Tab/Tab.d.ts +3 -0
  60. package/dist/src/core/Tab/Tab.style.d.ts +5 -0
  61. package/dist/src/core/Tab/Tab.type.d.ts +42 -0
  62. package/dist/src/core/Tab/index.d.ts +1 -0
  63. package/dist/src/core/Tab/useTabAdaptiveLayout.d.ts +23 -0
  64. package/dist/src/core/index.d.ts +4 -2
  65. package/dist/src/core/message/message.d.ts +5 -0
  66. package/dist/src/hooks/useAntdPatchEnLocales.d.ts +431 -0
  67. package/dist/src/hooks/useLegacyComponentWarning.d.ts +2 -0
  68. package/dist/src/spec/base.d.ts +2 -2
  69. package/dist/stories/docs/core/ImmersiveDialog.stories.d.ts +5 -1
  70. package/dist/stories/docs/core/LegacyModal.stories.d.ts +23 -0
  71. package/dist/stories/docs/core/LocalUpload.stories.d.ts +74 -0
  72. package/dist/stories/docs/core/MediumDialog.stories.d.ts +5 -1
  73. package/dist/stories/docs/core/SmallDialog.stories.d.ts +5 -1
  74. package/dist/stories/docs/core/Tab.stories.d.ts +65 -0
  75. package/dist/stories/docs/core/WizardDialog.stories.d.ts +2 -1
  76. package/dist/stories/docs/core/message-group.stories.d.ts +1 -0
  77. package/dist/style.css +1926 -1557
  78. package/dist/variables.scss +3 -0
  79. package/package.json +4 -4
  80. package/dist/src/core/Modal/index.d.ts +0 -5
  81. package/dist/stories/docs/core/Modal.stories.d.ts +0 -13
@@ -0,0 +1,365 @@
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,5 +1,5 @@
1
- import React__default from 'react';
2
1
  import { cx } from '@linaria/core';
2
+ import React__default from 'react';
3
3
  import { Typo } from '../Typo/index.js';
4
4
  import { SmallDialog } from '../SmallDialog/SmallDialog.js';
5
5
 
@@ -1,14 +1,14 @@
1
1
  import { ExclamationErrorCircleFill16RedIcon, XmarkCloseBold24TertiaryIcon, XmarkCloseBold24SecondaryIcon } from '@cloudtower/icons-react';
2
2
  import { cx } from '@linaria/core';
3
3
  import { usePopModal } from '../KitStoreProvider/index.js';
4
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
4
5
  import { Modal } from 'antd';
5
- import React__default from 'react';
6
6
  import cs from 'classnames';
7
+ import React__default from 'react';
7
8
  import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
8
9
  import { Show } from '../../coreX/Show/index.js';
9
10
  import { FooterStyle, ErrorTextStyle, DialogStyle, CloseIconStyle } from './SmallDialog.style.js';
10
11
  import { ModelTitleSkeleton, ModelContentSkeleton, ModelInitializingError } from './SmallDialog.widget.js';
11
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
12
12
  import Icon from '../Icon/index.js';
13
13
  import Button from '../Button/index.js';
14
14
  import { Flex } from 'antd5';
@@ -51,6 +51,7 @@ const SmallDialog = ({
51
51
  okButtonProps,
52
52
  cancelButtonProps,
53
53
  children,
54
+ hideFooter = false,
54
55
  showFooterErrorIcon = true,
55
56
  error,
56
57
  confirmLoading,
@@ -84,7 +85,7 @@ const SmallDialog = ({
84
85
  visible: true,
85
86
  width,
86
87
  title: initializing ? /* @__PURE__ */ React__default.createElement(ModelTitleSkeleton, null) : /* @__PURE__ */ React__default.createElement(CustomTitleRender, { title: title || defaultTitle }),
87
- footer: initializing ? null : /* @__PURE__ */ React__default.createElement(
88
+ footer: initializing ? null : hideFooter ? /* @__PURE__ */ React__default.createElement("div", null) : /* @__PURE__ */ React__default.createElement(
88
89
  "div",
89
90
  {
90
91
  className: cs(FooterStyle, footerClassName, {
@@ -137,7 +138,8 @@ const SmallDialog = ({
137
138
  closable,
138
139
  maskClosable,
139
140
  className: cs(DialogStyle, className, {
140
- "initializing-error": initializingError
141
+ "initializing-error": initializingError,
142
+ "no-footer": hideFooter
141
143
  }),
142
144
  closeIcon: /* @__PURE__ */ React__default.createElement(
143
145
  Icon,
@@ -0,0 +1,107 @@
1
+ import { MoreMenu16BlueIcon, MoreMenu16GrayIcon } from '@cloudtower/icons-react';
2
+ import { cx } from '@linaria/core';
3
+ import { Dropdown, Menu } from 'antd';
4
+ import React__default, { useRef, useState, useMemo, useLayoutEffect } from 'react';
5
+ import Icon from '../Icon/index.js';
6
+ import { Typo } from '../Typo/index.js';
7
+ import { TabMenuWrapper, MoreThanTooltipStyle, TabTitleElStyle, IconStyle } from './Tab.style.js';
8
+ import { ActiveTabType } from './Tab.type.js';
9
+ import { useTabAdaptiveLayout } from './useTabAdaptiveLayout.js';
10
+
11
+ const getSelectedStyle = (key, type, selectedKey, activeTabType) => {
12
+ return key === selectedKey && activeTabType === type ? ["__selected", Typo.Label.l1_bold_title] : [Typo.Label.l1_regular];
13
+ };
14
+ const Tab = props => {
15
+ const {
16
+ className,
17
+ contentClassName,
18
+ tabs,
19
+ onChange,
20
+ selectedKey,
21
+ extraSlot,
22
+ size = "medium"
23
+ } = props;
24
+ const tabsRef = useRef(null);
25
+ const extraSlotRef = useRef(null);
26
+ const [isClickedMoreTabItem, setIsClickedMoreTabItem] = useState(false);
27
+ const allTabs = useMemo(() => {
28
+ return tabs.reduce((map, tab) => {
29
+ map.set(tab.key, tab);
30
+ return map;
31
+ }, /* @__PURE__ */new Map([]));
32
+ }, [tabs]);
33
+ const selectedTab = useMemo(() => allTabs.get(selectedKey), [allTabs, selectedKey]);
34
+ const moreTabs = useTabAdaptiveLayout(tabs, tabsRef, extraSlotRef, selectedKey);
35
+ const activeTabType = useMemo(() => {
36
+ if (moreTabs == null ? void 0 : moreTabs.find(tab => tab.key === (selectedTab == null ? void 0 : selectedTab.key))) {
37
+ return ActiveTabType.More;
38
+ }
39
+ if ((selectedTab == null ? void 0 : selectedTab.key) && allTabs.get(selectedTab.key)) {
40
+ return ActiveTabType.Common;
41
+ }
42
+ }, [moreTabs, allTabs, selectedTab == null ? void 0 : selectedTab.key]);
43
+ useLayoutEffect(() => {
44
+ var _a;
45
+ if (!allTabs.get(selectedKey) && ((_a = tabs == null ? void 0 : tabs[0]) == null ? void 0 : _a.key)) {
46
+ onChange == null ? void 0 : onChange(tabs[0].key);
47
+ }
48
+ }, [allTabs, onChange, selectedKey, tabs]);
49
+ return /* @__PURE__ */React__default.createElement(TabMenuWrapper, {
50
+ className: cx(className, size)
51
+ }, /* @__PURE__ */React__default.createElement("div", {
52
+ className: "tab-bar"
53
+ }, /* @__PURE__ */React__default.createElement("div", {
54
+ ref: tabsRef,
55
+ className: "common-tab-bar"
56
+ }, /* tab items */
57
+ tabs.map(tab => /* @__PURE__ */React__default.createElement("span", {
58
+ className: cx("tab-item-title", "common", ...getSelectedStyle(tab.key, ActiveTabType.Common, selectedKey, activeTabType)),
59
+ key: tab.key,
60
+ onClick: () => onChange == null ? void 0 : onChange(tab.key)
61
+ }, typeof tab.title === "function" ? tab.title({
62
+ isActive: tab.key === selectedKey
63
+ }) : tab.title)), /* more tab items */
64
+ moreTabs.length > 0 && /* @__PURE__ */React__default.createElement(React__default.Fragment, null, /* @__PURE__ */React__default.createElement(Dropdown, {
65
+ trigger: ["click"],
66
+ overlayClassName: MoreThanTooltipStyle,
67
+ onVisibleChange: visible => setIsClickedMoreTabItem(visible),
68
+ getPopupContainer: triggerNode => document.querySelector(".tab-bar") || triggerNode,
69
+ overlay: /* @__PURE__ */React__default.createElement(Menu, {
70
+ className: "menu-wrapper",
71
+ onClick: params => {
72
+ setIsClickedMoreTabItem(false);
73
+ onChange == null ? void 0 : onChange(params.key);
74
+ }
75
+ }, moreTabs.map(tab => {
76
+ return /* @__PURE__ */React__default.createElement(Menu.Item, {
77
+ className: cx("tab-menu-item", ...getSelectedStyle(tab.key, ActiveTabType.More, selectedKey, activeTabType)),
78
+ key: tab.key
79
+ }, typeof tab.title === "function" ? tab.title({
80
+ isActive: tab.key === selectedKey
81
+ }) : tab.title);
82
+ }))
83
+ }, /* @__PURE__ */React__default.createElement("span", {
84
+ className: cx("tab-item-title", "more", TabTitleElStyle, activeTabType === ActiveTabType.More && "__selected", activeTabType === ActiveTabType.More ? Typo.Label.l1_bold_title : Typo.Label.l1_regular)
85
+ }, /* @__PURE__ */React__default.createElement(Icon, {
86
+ className: IconStyle,
87
+ hoverSrc: MoreMenu16BlueIcon,
88
+ src: MoreMenu16GrayIcon,
89
+ active: isClickedMoreTabItem
90
+ }), activeTabType === ActiveTabType.More && /* @__PURE__ */React__default.createElement("span", {
91
+ className: "tab-title-text"
92
+ }, typeof (selectedTab == null ? void 0 : selectedTab.title) === "function" ? selectedTab == null ? void 0 : selectedTab.title({
93
+ isActive: true
94
+ }) : selectedTab == null ? void 0 : selectedTab.title))), extraSlot && /* @__PURE__ */React__default.createElement("span", {
95
+ className: "E_ckaaqep"
96
+ }))), extraSlot && /* @__PURE__ */React__default.createElement("div", {
97
+ ref: extraSlotRef
98
+ }, extraSlot)), tabs.map(tab => /* @__PURE__ */React__default.createElement("div", {
99
+ style: {
100
+ display: tab.key === selectedKey ? "block" : "none"
101
+ },
102
+ key: tab.key,
103
+ className: contentClassName
104
+ }, tab == null ? void 0 : tab.children)));
105
+ };
106
+
107
+ export { Tab };
@@ -0,0 +1,12 @@
1
+ import { styled } from '@linaria/react';
2
+
3
+ const TabMenuWrapper = /*#__PURE__*/styled('div')({
4
+ name: "TabMenuWrapper",
5
+ class: "E_t1tbywr9",
6
+ propsAsIs: false
7
+ });
8
+ const TabTitleElStyle = "E_ti12z2";
9
+ const MoreThanTooltipStyle = "E_m19lu3v";
10
+ const IconStyle = "E_i1bmwe2m";
11
+
12
+ export { IconStyle, MoreThanTooltipStyle, TabMenuWrapper, TabTitleElStyle };
@@ -0,0 +1,7 @@
1
+ var ActiveTabType = /* @__PURE__ */ ((ActiveTabType2) => {
2
+ ActiveTabType2[ActiveTabType2["Common"] = 0] = "Common";
3
+ ActiveTabType2[ActiveTabType2["More"] = 1] = "More";
4
+ return ActiveTabType2;
5
+ })(ActiveTabType || {});
6
+
7
+ export { ActiveTabType };
@@ -0,0 +1,71 @@
1
+ import { isEqual } from 'lodash';
2
+ import { useState, useCallback, useEffect } from 'react';
3
+
4
+ const getPlacementWidth = (el) => {
5
+ if (!el) {
6
+ return 0;
7
+ }
8
+ const computedStyle = window.getComputedStyle(el);
9
+ const width = el.offsetWidth;
10
+ const marginLeft = parseInt(computedStyle.marginLeft || "0");
11
+ const marginRight = parseInt(computedStyle.marginRight || "0");
12
+ return width + marginLeft + marginRight;
13
+ };
14
+ const useTabAdaptiveLayout = (tabs, tabsRef, extraSlotRef, selectedKey) => {
15
+ const [moreTabs, setMoreTabs] = useState([]);
16
+ const doAdapt = useCallback(() => {
17
+ if (!tabsRef.current)
18
+ return;
19
+ const tabBarEl = tabsRef.current;
20
+ const tabNodeList = tabBarEl.querySelectorAll(".tab-item-title.common");
21
+ const moreTabNode = tabBarEl.querySelector(
22
+ ".tab-item-title.more"
23
+ );
24
+ const moreTabPlacementWidth = getPlacementWidth(moreTabNode);
25
+ tabNodeList.forEach((tab) => tab.classList.remove("__hidden"));
26
+ const maxContentWidth = getPlacementWidth(tabBarEl.parentElement) - getPlacementWidth(extraSlotRef.current) - moreTabPlacementWidth;
27
+ let tabsTotalWidth = 24;
28
+ const hiddenItems = [];
29
+ let endIndex = Infinity;
30
+ for (let i = 0; i < tabNodeList.length; i++) {
31
+ const tab = tabNodeList[i];
32
+ const tabWidth = getPlacementWidth(tab);
33
+ if (maxContentWidth >= tabsTotalWidth + tabWidth) {
34
+ tabsTotalWidth += tabWidth;
35
+ } else {
36
+ endIndex = i;
37
+ break;
38
+ }
39
+ }
40
+ while (endIndex <= tabNodeList.length - 1) {
41
+ tabNodeList[endIndex].classList.add("__hidden");
42
+ hiddenItems.push(tabs[endIndex]);
43
+ endIndex++;
44
+ }
45
+ setMoreTabs((prevMoreTabs) => {
46
+ if (!isEqual(hiddenItems, prevMoreTabs)) {
47
+ return hiddenItems;
48
+ }
49
+ return prevMoreTabs;
50
+ });
51
+ }, [tabs, tabsRef, extraSlotRef]);
52
+ useEffect(() => {
53
+ doAdapt();
54
+ }, [doAdapt, selectedKey]);
55
+ useEffect(() => {
56
+ var _a;
57
+ const parentElement = (_a = tabsRef.current) == null ? void 0 : _a.parentElement;
58
+ if (!parentElement)
59
+ return;
60
+ const resizeObserver = new ResizeObserver(() => {
61
+ doAdapt();
62
+ });
63
+ resizeObserver.observe(parentElement);
64
+ return () => {
65
+ resizeObserver.disconnect();
66
+ };
67
+ }, [doAdapt, tabsRef]);
68
+ return moreTabs;
69
+ };
70
+
71
+ export { useTabAdaptiveLayout };
@@ -6,6 +6,7 @@ import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
6
6
  import RCNotification from '@cloudtower/rc-notification';
7
7
  import cs from 'classnames';
8
8
  import * as React from 'react';
9
+ import { ConfigProvider } from '../ConfigProvider/index.js';
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __defProps = Object.defineProperties;
@@ -26,7 +27,23 @@ var __spreadValues = (a, b) => {
26
27
  return a;
27
28
  };
28
29
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
+ var __objRest = (source, exclude) => {
31
+ var target = {};
32
+ for (var prop in source)
33
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
34
+ target[prop] = source[prop];
35
+ if (source != null && __getOwnPropSymbols)
36
+ for (var prop of __getOwnPropSymbols(source)) {
37
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
38
+ target[prop] = source[prop];
39
+ }
40
+ return target;
41
+ };
29
42
  const DEFAULT_DURATION = 3;
43
+ const ConfigProviderWrapper = (props) => {
44
+ const _a = props, { children } = _a, configProps = __objRest(_a, ["children"]);
45
+ return /* @__PURE__ */ React.createElement(ConfigProvider, __spreadValues({}, configProps), children);
46
+ };
30
47
  let messageInstance;
31
48
  let defaultDuration = DEFAULT_DURATION;
32
49
  let defaultTop;
@@ -36,6 +53,7 @@ let transitionName = "move-up";
36
53
  let getContainer;
37
54
  let maxCount;
38
55
  let rtl = false;
56
+ let globalConfigProviderProps = null;
39
57
  function getKeyThenIncreaseKey() {
40
58
  return key++;
41
59
  }
@@ -64,6 +82,10 @@ function setMessageConfig(options) {
64
82
  if (options.rtl !== void 0) {
65
83
  rtl = options.rtl;
66
84
  }
85
+ if (options.configProviderProps !== void 0) {
86
+ globalConfigProviderProps = options.configProviderProps;
87
+ messageInstance = null;
88
+ }
67
89
  }
68
90
  function getRCNotificationInstance(args, callback) {
69
91
  const prefixCls = args.prefixCls || localPrefixCls;
@@ -113,12 +135,13 @@ function getRCNoticeProps(args, prefixCls) {
113
135
  [`${prefixCls}-${args.type}`]: args.type,
114
136
  [`${prefixCls}-rtl`]: rtl === true
115
137
  });
138
+ const wrappedContent = globalConfigProviderProps ? /* @__PURE__ */ React.createElement(ConfigProviderWrapper, __spreadValues({}, globalConfigProviderProps), /* @__PURE__ */ React.createElement("div", { className: messageClass }, args.icon || IconComponent && /* @__PURE__ */ React.createElement(IconComponent, null), /* @__PURE__ */ React.createElement("span", null, args.content))) : /* @__PURE__ */ React.createElement("div", { className: messageClass }, args.icon || IconComponent && /* @__PURE__ */ React.createElement(IconComponent, null), /* @__PURE__ */ React.createElement("span", null, args.content));
116
139
  return {
117
140
  key: args.key,
118
141
  duration,
119
142
  style: args.style || {},
120
143
  className: args.className,
121
- content: /* @__PURE__ */ React.createElement("div", { className: messageClass }, args.icon || IconComponent && /* @__PURE__ */ React.createElement(IconComponent, null), /* @__PURE__ */ React.createElement("span", null, args.content)),
144
+ content: wrappedContent,
122
145
  onClose: args.onClose
123
146
  };
124
147
  }