@cloudtower/eagle 490.0.11 → 490.0.13

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.
@@ -0,0 +1,4 @@
1
+ const MessageWrapperStyle = "E_meo40fy";
2
+ const AlertStyle = "E_a1ctixr3";
3
+
4
+ export { AlertStyle, MessageWrapperStyle };
@@ -1,8 +1,11 @@
1
- import { XmarkRemove16RegularTertiaryCapsOffIcon, XmarkRemove16RegularPrimaryCapsOffIcon } from '@cloudtower/icons-react';
1
+ import { ArrowChevronUpSmall16BlueIcon, ArrowChevronDownSmall16BlueIcon, XmarkRemove16RegularTertiaryCapsOffIcon, XmarkRemove16RegularPrimaryCapsOffIcon } from '@cloudtower/icons-react';
2
2
  import Icon from '../Icon/index.js';
3
+ import Link from '../Link/index.js';
4
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
3
5
  import { Alert as Alert$2 } from 'antd';
4
6
  import cs from 'classnames';
5
- import React__default from 'react';
7
+ import React__default, { useState, useCallback } from 'react';
8
+ import { AlertStyle, MessageWrapperStyle } from './alert.style.js';
6
9
  import { getAlertIcon } from '../../utils/icon.js';
7
10
 
8
11
  var __defProp = Object.defineProperty;
@@ -11,76 +14,116 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
14
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
16
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value
19
- }) : obj[key] = value;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
18
  var __spreadValues = (a, b) => {
21
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
22
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
23
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
24
- }
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
25
27
  return a;
26
28
  };
27
29
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
30
  var __objRest = (source, exclude) => {
29
31
  var target = {};
30
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
31
- if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
33
- }
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
+ }
34
40
  return target;
35
41
  };
36
- const MessageWrapperStyle = "E_m74vjol";
37
- const AlertStyle = "E_a1o35uvh";
38
- const Alert = _a => {
39
- var _b = _a,
40
- {
41
- type,
42
- icon,
43
- showIcon = true,
44
- className,
45
- onClose,
46
- closeText,
47
- action,
48
- message,
49
- closable,
50
- "data-testid": dataTestId
51
- } = _b,
52
- props = __objRest(_b, ["type", "icon", "showIcon", "className", "onClose", "closeText", "action", "message", "closable", "data-testid"]);
53
- const _icon = /* @__PURE__ */React__default.createElement(Icon, {
54
- alt: type,
55
- src: getAlertIcon(type)
56
- });
42
+ const Alert = (_a) => {
43
+ var _b = _a, {
44
+ type,
45
+ icon,
46
+ showIcon = true,
47
+ className,
48
+ onClose,
49
+ closeText,
50
+ action,
51
+ message,
52
+ description,
53
+ closable,
54
+ expandConfig,
55
+ "data-testid": dataTestId
56
+ } = _b, props = __objRest(_b, [
57
+ "type",
58
+ "icon",
59
+ "showIcon",
60
+ "className",
61
+ "onClose",
62
+ "closeText",
63
+ "action",
64
+ "message",
65
+ "description",
66
+ "closable",
67
+ "expandConfig",
68
+ "data-testid"
69
+ ]);
70
+ var _a2;
71
+ const { t } = useParrotTranslation();
72
+ const _icon = /* @__PURE__ */ React__default.createElement(Icon, { alt: type, src: getAlertIcon(type) });
57
73
  const _type = type === "normal" ? "info" : type;
58
74
  const _closable = closable || Boolean(onClose) || Boolean(closeText);
59
- return /* @__PURE__ */React__default.createElement(Alert$2, __spreadProps(__spreadValues({}, props), {
60
- "data-testid": dataTestId,
61
- className: cs(AlertStyle, type ? `alert-${type}` : "", className, {
62
- action
63
- }),
64
- type: _type,
65
- message: /* @__PURE__ */React__default.createElement("div", {
66
- className: MessageWrapperStyle
67
- }, /* @__PURE__ */React__default.createElement("span", {
68
- style: {
69
- flex: 1
70
- }
71
- }, message), action ? /* @__PURE__ */React__default.createElement("span", {
72
- className: cs("action")
73
- }, action) : null),
74
- icon: icon || _icon,
75
- showIcon,
76
- onClose,
77
- closeText: closeText || _closable && /* @__PURE__ */React__default.createElement(Icon, {
78
- src: XmarkRemove16RegularTertiaryCapsOffIcon,
79
- hoverSrc: XmarkRemove16RegularPrimaryCapsOffIcon
80
- }),
81
- closable: _closable
82
- }));
75
+ const [internalExpanded, setInternalExpanded] = useState(
76
+ (_a2 = expandConfig == null ? void 0 : expandConfig.defaultExpanded) != null ? _a2 : false
77
+ );
78
+ const isControlled = (expandConfig == null ? void 0 : expandConfig.expanded) !== void 0;
79
+ const expanded = isControlled ? expandConfig.expanded : internalExpanded;
80
+ const handleToggle = useCallback(() => {
81
+ var _a3;
82
+ const next = !expanded;
83
+ if (!isControlled) {
84
+ setInternalExpanded(next);
85
+ }
86
+ (_a3 = expandConfig == null ? void 0 : expandConfig.onExpandChange) == null ? void 0 : _a3.call(expandConfig, next);
87
+ }, [expanded, isControlled, expandConfig == null ? void 0 : expandConfig.onExpandChange]);
88
+ const showExpandToggle = expandConfig && description;
89
+ const expandToggle = showExpandToggle ? /* @__PURE__ */ React__default.createElement(
90
+ Link,
91
+ {
92
+ onClick: handleToggle,
93
+ "data-testid": "alert-expand-toggle",
94
+ suffixIcon: /* @__PURE__ */ React__default.createElement(
95
+ Icon,
96
+ {
97
+ src: expanded ? ArrowChevronUpSmall16BlueIcon : ArrowChevronDownSmall16BlueIcon
98
+ }
99
+ )
100
+ },
101
+ expanded ? t("components.alert_collapse") : t("components.alert_expand")
102
+ ) : null;
103
+ return /* @__PURE__ */ React__default.createElement(
104
+ Alert$2,
105
+ __spreadProps(__spreadValues({}, props), {
106
+ "data-testid": dataTestId,
107
+ className: cs(AlertStyle, type ? `alert-${type}` : "", className, {
108
+ action: action || expandToggle
109
+ }),
110
+ type: _type,
111
+ message: /* @__PURE__ */ React__default.createElement("div", { className: MessageWrapperStyle }, /* @__PURE__ */ React__default.createElement("div", { style: { flex: 1 } }, message, showExpandToggle && expanded ? /* @__PURE__ */ React__default.createElement("div", null, description) : null), action ? /* @__PURE__ */ React__default.createElement("span", { className: cs("action") }, action) : null, expandToggle ? /* @__PURE__ */ React__default.createElement("span", { className: cs("action") }, expandToggle) : null),
112
+ description: expandConfig ? void 0 : description,
113
+ icon: icon || _icon,
114
+ showIcon,
115
+ onClose,
116
+ closeText: closeText || _closable && /* @__PURE__ */ React__default.createElement(
117
+ Icon,
118
+ {
119
+ src: XmarkRemove16RegularTertiaryCapsOffIcon,
120
+ hoverSrc: XmarkRemove16RegularPrimaryCapsOffIcon
121
+ }
122
+ ),
123
+ closable: _closable
124
+ })
125
+ );
83
126
  };
84
127
  var Alert$1 = Alert;
85
128
 
86
- export { Alert$1 as default };
129
+ export { AlertStyle, MessageWrapperStyle, Alert$1 as default };
package/dist/esm/index.js CHANGED
@@ -80,6 +80,7 @@ export { default as TimeZoneSelect } from './core/TimeZoneSelect/index.js';
80
80
  export { default as Token, TokenPresetColors } from './core/Token/index.js';
81
81
  export { default as Tooltip } from './core/Tooltip/index.js';
82
82
  export { default as Truncate } from './core/Truncate/index.js';
83
+ export { AlertStyle, MessageWrapperStyle } from './core/Alert/alert.style.js';
83
84
  export { Antd5Dropdown } from './core/Antd5Dropdown/Antd5Dropdown.js';
84
85
  export { Flex as Antd5Flex, Tree as Antd5Tree } from 'antd5';
85
86
  export { Architecture } from './core/Arch/arch.type.js';