@agilemotion/oui-react-js 1.8.71 → 1.8.72

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,15 @@
1
+ .alert-fade {
2
+ opacity: 0;
3
+ transform: translateY(-8px);
4
+ transition: opacity .45s ease, transform .45s cubic-bezier(.2,.8,.2,1);
5
+ }
6
+
7
+ .alert-fade.alert-show {
8
+ opacity: 1;
9
+ transform: translateY(0);
10
+ }
11
+
12
+ .alert-fade.alert-hide {
13
+ opacity: 0;
14
+ transform: translateY(-6px);
15
+ }
@@ -9,12 +9,14 @@ var _Utils = _interopRequireDefault(require("../Utils"));
9
9
  var _Alert = _interopRequireDefault(require("react-bootstrap/Alert"));
10
10
  var _EventType = _interopRequireDefault(require("../event/EventType"));
11
11
  var _Observable = _interopRequireDefault(require("../event/Observable"));
12
- var _OverlayTrigger = _interopRequireDefault(require("react-bootstrap/OverlayTrigger"));
13
- var _Tooltip = _interopRequireDefault(require("react-bootstrap/Tooltip"));
12
+ require("./AlertBar.css");
14
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
14
  const AlertBar = /*#__PURE__*/_react.default.memo(props => {
15
+ var _props$config;
16
16
  const [message, setMessage] = _react.default.useState(props.config.message);
17
- const [variant, setVariant] = _react.default.useState(props.config.variant ? props.config.variant : 'info');
17
+ const [variant, setVariant] = _react.default.useState(props.config.variant || 'info');
18
+ const [visible, setVisible] = _react.default.useState(false);
19
+ const placement = ((_props$config = props.config) === null || _props$config === void 0 || (_props$config = _props$config.attributes) === null || _props$config === void 0 ? void 0 : _props$config.placement) || "overlay";
18
20
  _react.default.useEffect(() => {
19
21
  props.handle.api = api();
20
22
  let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
@@ -26,21 +28,15 @@ const AlertBar = /*#__PURE__*/_react.default.memo(props => {
26
28
  }
27
29
  };
28
30
  if (_Utils.default.isNull(eventHandlingConfig.subscriptions)) {
29
- // Add default subscription
30
- eventHandlingConfig.subscriptions = [];
31
- let subscription = {
31
+ eventHandlingConfig.subscriptions = [{
32
32
  publisher: 'applicationManager',
33
33
  eventType: _EventType.default.MESSAGE_ARRIVED,
34
34
  actions: [defaultAction]
35
- };
36
- eventHandlingConfig.subscriptions.push(subscription);
35
+ }];
37
36
  } else {
38
37
  for (const subscription of eventHandlingConfig.subscriptions) {
39
- if (_Utils.default.isNull(subscription.actions)) {
40
- subscription.actions = [];
41
- }
42
- if (subscription.actions.length === 0) {
43
- subscription.actions.push(defaultAction);
38
+ if (_Utils.default.isNull(subscription.actions) || subscription.actions.length === 0) {
39
+ subscription.actions = [defaultAction];
44
40
  }
45
41
  }
46
42
  }
@@ -49,6 +45,41 @@ const AlertBar = /*#__PURE__*/_react.default.memo(props => {
49
45
  _Observable.default.clearComponentEventListeners(props.handle);
50
46
  };
51
47
  }, []);
48
+
49
+ /*
50
+ Show animation when message arrives
51
+ (hidden first, then visible next frame)
52
+ */
53
+ _react.default.useEffect(() => {
54
+ if (message) {
55
+ setVisible(false);
56
+ const frame = requestAnimationFrame(() => {
57
+ setVisible(true);
58
+ });
59
+ return () => cancelAnimationFrame(frame);
60
+ }
61
+ }, [message]);
62
+
63
+ /*
64
+ Auto close non-error messages
65
+ */
66
+ _react.default.useEffect(() => {
67
+ if (!message) return;
68
+ if (variant === "danger") return;
69
+ const timeout = variant === "warning" ? 6000 : 3000;
70
+ const timer = setTimeout(() => {
71
+ closeAlert();
72
+ }, timeout);
73
+ return () => clearTimeout(timer);
74
+ }, [message, variant]);
75
+ const closeAlert = () => {
76
+ setVisible(false);
77
+
78
+ // allow fade-out animation to complete
79
+ setTimeout(() => {
80
+ setMessage(null);
81
+ }, 250);
82
+ };
52
83
  const api = () => {
53
84
  return {
54
85
  get id() {
@@ -57,31 +88,43 @@ const AlertBar = /*#__PURE__*/_react.default.memo(props => {
57
88
  set message(message) {
58
89
  setMessage(message);
59
90
  },
60
- getChildren: () => {
61
- return [];
62
- },
63
91
  set variant(variant) {
64
92
  setVariant(variant);
65
- }
93
+ },
94
+ getChildren: () => []
66
95
  };
67
96
  };
97
+ const overlayStyle = {
98
+ position: "absolute",
99
+ top: "calc(var(--view-header-h) + 24px)",
100
+ left: "50%",
101
+ transform: "translateX(-50%)",
102
+ width: "calc(100% - 320px)",
103
+ maxWidth: "60dvw",
104
+ zIndex: 1050,
105
+ pointerEvents: "none"
106
+ };
107
+ const strictStyle = {
108
+ padding: "0 32px",
109
+ maxHeight: "64px"
110
+ };
111
+ const containerStyle = placement === "strict" ? strictStyle : overlayStyle;
68
112
  return !_Utils.default.isNull(props.config) ? /*#__PURE__*/_react.default.createElement("div", {
69
- style: _Utils.default.mergeStyles({
70
- padding: '0 32px 0 32px',
71
- maxHeight: '64px'
72
- }, props.config)
73
- }, /*#__PURE__*/_react.default.createElement(_Alert.default, {
113
+ style: _Utils.default.mergeStyles(containerStyle, props.config)
114
+ }, message && /*#__PURE__*/_react.default.createElement(_Alert.default, {
115
+ className: "alert-fade ".concat(visible ? "alert-show" : "alert-hide"),
74
116
  variant: variant,
75
- show: !_Utils.default.isNull(message),
76
- onClose: () => setMessage(null),
117
+ onClose: closeAlert,
77
118
  dismissible: true,
78
119
  style: {
79
- width: '100%'
120
+ width: '100%',
121
+ pointerEvents: 'auto',
122
+ boxShadow: '0 6px 16px rgba(0,0,0,0.18)'
80
123
  }
81
124
  }, /*#__PURE__*/_react.default.createElement("p", {
82
125
  title: message,
83
126
  style: {
84
- color: 'rgba(255, 255, 255, 0.8)',
127
+ color: 'rgba(255,255,255,0.9)',
85
128
  overflow: 'hidden',
86
129
  textOverflow: 'ellipsis',
87
130
  whiteSpace: 'nowrap',
@@ -59,7 +59,6 @@
59
59
  }
60
60
 
61
61
  .view .sticky-header {
62
- position: sticky;
63
62
  top: 0;
64
63
  z-index: 10;
65
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemotion/oui-react-js",
3
- "version": "1.8.71",
3
+ "version": "1.8.72",
4
4
  "description": "AgileMotion React UI Component Library - A comprehensive collection of dashboard components, forms, media controls, and more",
5
5
  "license": "ISC",
6
6
  "author": "",