@scaleflex/widget-informer 0.0.1
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/CHANGELOG.md +7452 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/lib/ErrorsModal/index.js +32 -0
- package/lib/Informer.styled.js +61 -0
- package/lib/InformerUI.js +110 -0
- package/lib/InformerUIDetails.js +32 -0
- package/lib/index.js +78 -0
- package/package.json +34 -0
- package/types/index.d.ts +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# `@scaleflex/widget-informer`
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<div align='center'>
|
|
12
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://cdn.scaleflex.com/plugins/filerobot-widget/assets/filerobot_widget_logo_with_fire.png?vh=b2ff09" width="140"/>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
A pop-up alert for showing info, warnings or errors in [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) when other plugins needs to show some message with any of the mentioned types.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### NPM
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save @scaleflex/widget-informer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### YARN
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @scaleflex/widget-informer
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
then
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import Informer from '@scaleflex/widget-informer'
|
|
35
|
+
...
|
|
36
|
+
...
|
|
37
|
+
...
|
|
38
|
+
scaleflexWidget.use(Informer, propertiesObject)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### CDN
|
|
42
|
+
|
|
43
|
+
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.Informer`
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const Informer = window.ScaleflexWidget.Informer
|
|
47
|
+
...
|
|
48
|
+
...
|
|
49
|
+
...
|
|
50
|
+
scaleflexWidget.use(Informer, propertiesObject)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> If you are using [`@scaleflex/widget-explorer`](../@scaleflex/widget-explorer/#filerobotexplorer) plugin you don't need to manually import this plugin as it is being imported automatically there with its styles and the default id `Explorer:Informer` Unless the Explorer id is changed.
|
|
54
|
+
|
|
55
|
+
### Plugin's styles
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import '@scaleflex/widget-core/dist/style.css'
|
|
59
|
+
import '@scaleflex/widget-informer/dist/style.css'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
or if you prefer the minified version
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import '@scaleflex/widget-core/dist/style.min.css'
|
|
66
|
+
import '@scaleflex/widget-informer/dist/style.min.css'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> The plugin's css file should be imported after the [Core's css file](../@scaleflex/widget-core/#modules-styles) for having the styles shown correctly.
|
|
70
|
+
|
|
71
|
+
<!-- Variables -->
|
|
72
|
+
|
|
73
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-informer
|
|
74
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
75
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
76
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-informer
|
|
77
|
+
[codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
|
|
78
|
+
|
|
79
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
80
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
81
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
82
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
83
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
84
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-informer?label=Version&style=for-the-badge&logo=npm
|
|
85
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Cross2, CopyOutline } from '@scaleflex/icons';
|
|
2
|
+
import Styled from '../Informer.styled';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
var ErrorsModal = function ErrorsModal(_ref) {
|
|
5
|
+
var i18n = _ref.i18n,
|
|
6
|
+
isErrorsModalOpen = _ref.isErrorsModalOpen,
|
|
7
|
+
closeErrorsModal = _ref.closeErrorsModal,
|
|
8
|
+
displayedErrors = _ref.displayedErrors,
|
|
9
|
+
handleCopyErrors = _ref.handleCopyErrors;
|
|
10
|
+
return /*#__PURE__*/_jsxs(Styled.ErrorsModal, {
|
|
11
|
+
open: isErrorsModalOpen,
|
|
12
|
+
onClose: closeErrorsModal,
|
|
13
|
+
children: [/*#__PURE__*/_jsx(Styled.ErrorsModalTitle, {
|
|
14
|
+
onClose: closeErrorsModal,
|
|
15
|
+
primary: i18n('informerErrorsModalTitle')
|
|
16
|
+
}), /*#__PURE__*/_jsx(Styled.ErrorsModalContent, {
|
|
17
|
+
children: /*#__PURE__*/_jsxs(Styled.ErrorsWrapper, {
|
|
18
|
+
children: [(Array.isArray(displayedErrors) ? displayedErrors : []).map(function (error, index) {
|
|
19
|
+
return /*#__PURE__*/_jsxs(Styled.Detail, {
|
|
20
|
+
children: [/*#__PURE__*/_jsx(Cross2, {}), "\u201C", error, "\u201D"]
|
|
21
|
+
}, index);
|
|
22
|
+
}), /*#__PURE__*/_jsx(Styled.CopyButton, {
|
|
23
|
+
color: "link-secondary",
|
|
24
|
+
startIcon: /*#__PURE__*/_jsx(CopyOutline, {}),
|
|
25
|
+
onClick: handleCopyErrors,
|
|
26
|
+
children: i18n('informerErrorsModalCopyButton')
|
|
27
|
+
})]
|
|
28
|
+
})
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export default ErrorsModal;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { FV, PC, PSH } from '@scaleflex/widget-common';
|
|
5
|
+
import { TooltipV2, ModalTitle, ModalContent, Modal, Button } from '@scaleflex/ui/core';
|
|
6
|
+
var InformerWrapper = styled.div(function (_ref) {
|
|
7
|
+
var isHidden = _ref.isHidden,
|
|
8
|
+
positionFixed = _ref.positionFixed,
|
|
9
|
+
theme = _ref.theme;
|
|
10
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: ", ";\n display: flex;\n justify-content: center;\n bottom: 40px;\n left: 50%;\n right: 0;\n z-index: 2000;\n width: fit-content;\n opacity: 1;\n transform: translateX(-50%);\n transition: all 300ms ease-in;\n background-color: ", ";\n visibility: visible; // we are using visibility to avoid any tabindex inside the div's children like button.\n\n ", ";\n\n .SfxButton-Label {\n font-size: 13px;\n }\n"])), positionFixed ? 'fixed' : 'absolute', theme.palette[PC.BackgroundStateless], isHidden && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n opacity: 0;\n transform: translate(-50%, 200px);\n visibility: hidden; // we are using visibility to avoid any tabindex inside the div's children like button.\n "]))));
|
|
11
|
+
});
|
|
12
|
+
var LabelsTooltip = styled(TooltipV2)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n background-color: ", ";\n box-shadow: ", ";\n padding-bottom: 0px;\n max-width: 276px;\n\n & + .SfxPopper-arrow::before {\n background: ", ";\n }\n"])), function (_ref2) {
|
|
13
|
+
var theme = _ref2.theme;
|
|
14
|
+
return theme.palette[PC.BackgroundStateless];
|
|
15
|
+
}, function (_ref3) {
|
|
16
|
+
var theme = _ref3.theme;
|
|
17
|
+
return theme.shadows[PSH.ShadowXl];
|
|
18
|
+
}, function (_ref4) {
|
|
19
|
+
var theme = _ref4.theme;
|
|
20
|
+
return theme.palette[PC.BackgroundStateless];
|
|
21
|
+
});
|
|
22
|
+
var ErrorsModal = styled(Modal)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 500px;\n max-width: 500px;\n z-index: 1800;\n"])));
|
|
23
|
+
var ErrorsModalTitle = styled(ModalTitle)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n text-align: center;\n\n .SfxModalTitle-LabelPrimary {\n ", "\n //TODO: fix issue of multiple passing props to modal title and label in Scaleflex/ui\n height: 35.12px;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .SfxModalTitle-Close {\n top: 12px;\n right: 12px;\n }\n"])), function (_ref5) {
|
|
24
|
+
var theme = _ref5.theme;
|
|
25
|
+
return theme.typography.font[FV.LabelLargeUp];
|
|
26
|
+
});
|
|
27
|
+
var ErrorsModalContent = styled(ModalContent)(function (_ref6) {
|
|
28
|
+
var palette = _ref6.theme.palette;
|
|
29
|
+
return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 24px;\n max-height: 536px;\n overflow-y: auto;\n\n &:hover {\n color: ", ";\n button {\n color: ", ";\n }\n }\n"])), function (_ref7) {
|
|
30
|
+
var palette = _ref7.theme.palette;
|
|
31
|
+
return palette[PC.AccentPrimaryHover];
|
|
32
|
+
}, function (_ref8) {
|
|
33
|
+
var palette = _ref8.theme.palette;
|
|
34
|
+
return palette[PC.AccentPrimaryHover];
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
var ErrorsWrapper = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background-color: ", ";\n flex-direction: column;\n display: flex;\n padding: 12px;\n gap: 12px;\n"])), function (_ref9) {
|
|
38
|
+
var palette = _ref9.theme.palette;
|
|
39
|
+
return palette[PC.BackgroundBaseLight];
|
|
40
|
+
});
|
|
41
|
+
var Detail = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: flex;\n gap: 8px;\n align-items: flex-start;\n ", ";\n\n > svg {\n margin-top: 4px;\n flex-shrink: 0;\n color: ", ";\n }\n"])), function (_ref10) {
|
|
42
|
+
var theme = _ref10.theme;
|
|
43
|
+
return theme.typography.font[FV.TextMedium];
|
|
44
|
+
}, function (_ref11) {
|
|
45
|
+
var palette = _ref11.theme.palette;
|
|
46
|
+
return palette[PC.Red];
|
|
47
|
+
});
|
|
48
|
+
var CopyButton = styled(Button)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n width: 100%;\n justify-content: flex-end;\n"])));
|
|
49
|
+
var DetailsButton = styled(Button)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n margin-left: 2px;\n"])));
|
|
50
|
+
var Styled = {
|
|
51
|
+
InformerWrapper: InformerWrapper,
|
|
52
|
+
ErrorsModal: ErrorsModal,
|
|
53
|
+
ErrorsModalTitle: ErrorsModalTitle,
|
|
54
|
+
ErrorsModalContent: ErrorsModalContent,
|
|
55
|
+
ErrorsWrapper: ErrorsWrapper,
|
|
56
|
+
DetailsButton: DetailsButton,
|
|
57
|
+
Detail: Detail,
|
|
58
|
+
CopyButton: CopyButton,
|
|
59
|
+
LabelsTooltip: LabelsTooltip
|
|
60
|
+
};
|
|
61
|
+
export default Styled;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import { useSelector } from 'react-redux';
|
|
9
|
+
import { useCore } from '@scaleflex/widget-core/lib/hooks';
|
|
10
|
+
import copyText from '@scaleflex/widget-utils/lib/copyText';
|
|
11
|
+
import { PopupContent as Informer } from '@scaleflex/ui/core';
|
|
12
|
+
import { selectInfo } from '@scaleflex/widget-core/lib/slices/info.slice';
|
|
13
|
+
import Styled from './Informer.styled';
|
|
14
|
+
import ErrorsModal from './ErrorsModal';
|
|
15
|
+
import InformerUIDetails from './InformerUIDetails';
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
var timeoutId = null;
|
|
18
|
+
var InformerUI = function InformerUI(_ref) {
|
|
19
|
+
var i18n = _ref.i18n,
|
|
20
|
+
hideInfo = _ref.hideInfo;
|
|
21
|
+
var _useSelector = useSelector(selectInfo),
|
|
22
|
+
isHidden = _useSelector.isHidden,
|
|
23
|
+
type = _useSelector.type,
|
|
24
|
+
message = _useSelector.message,
|
|
25
|
+
details = _useSelector.details,
|
|
26
|
+
errors = _useSelector.errors;
|
|
27
|
+
var _useState = useState(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
isVisibilityNotLocked = _useState2[0],
|
|
30
|
+
setIsVisibilityNotLocked = _useState2[1];
|
|
31
|
+
var _useState3 = useState(false),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
isErrorsModalOpen = _useState4[0],
|
|
34
|
+
setIsErrorsModalOpen = _useState4[1];
|
|
35
|
+
var _useState5 = useState(errors),
|
|
36
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
+
displayedErrors = _useState6[0],
|
|
38
|
+
setDisplayedErrors = _useState6[1];
|
|
39
|
+
var _useCore = useCore(),
|
|
40
|
+
info = _useCore.info;
|
|
41
|
+
var handleCopyErrors = function handleCopyErrors() {
|
|
42
|
+
copyText({
|
|
43
|
+
text: errors,
|
|
44
|
+
i18n: i18n,
|
|
45
|
+
info: info,
|
|
46
|
+
successMsgI18nKey: 'informerErrorsModalSuccessCopyMsg'
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var lockInformerVisibility = function lockInformerVisibility() {
|
|
50
|
+
if (isHidden && !timeoutId) return;
|
|
51
|
+
clearTimeout(timeoutId);
|
|
52
|
+
setIsVisibilityNotLocked(false);
|
|
53
|
+
};
|
|
54
|
+
var unLockInformerVisibility = function unLockInformerVisibility() {
|
|
55
|
+
if (isVisibilityNotLocked !== false) return;
|
|
56
|
+
// Giving it some more amount of time in-case the user needs to re-hover it again before hiding.
|
|
57
|
+
timeoutId = setTimeout(function () {
|
|
58
|
+
timeoutId = null;
|
|
59
|
+
setIsVisibilityNotLocked(null);
|
|
60
|
+
}, 250);
|
|
61
|
+
};
|
|
62
|
+
var onClose = function onClose() {
|
|
63
|
+
hideInfo();
|
|
64
|
+
if (isVisibilityNotLocked === false) {
|
|
65
|
+
setIsVisibilityNotLocked(null);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var closeErrorsModal = function closeErrorsModal() {
|
|
69
|
+
setIsErrorsModalOpen(false);
|
|
70
|
+
setDisplayedErrors(null);
|
|
71
|
+
};
|
|
72
|
+
var openErrorsModal = function openErrorsModal() {
|
|
73
|
+
setIsErrorsModalOpen(true);
|
|
74
|
+
setDisplayedErrors(errors);
|
|
75
|
+
hideInfo();
|
|
76
|
+
};
|
|
77
|
+
var renderMessage = function renderMessage() {
|
|
78
|
+
var hasDetails = details || errors;
|
|
79
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
80
|
+
children: [message || details, hasDetails && /*#__PURE__*/_jsx(InformerUIDetails, {
|
|
81
|
+
details: details,
|
|
82
|
+
errors: errors,
|
|
83
|
+
i18n: i18n,
|
|
84
|
+
openErrorsModal: openErrorsModal
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
89
|
+
children: [/*#__PURE__*/_jsx(Styled.InformerWrapper, {
|
|
90
|
+
isHidden: isVisibilityNotLocked !== null && isVisibilityNotLocked !== void 0 ? isVisibilityNotLocked : isHidden,
|
|
91
|
+
children: /*#__PURE__*/_jsx(Informer, {
|
|
92
|
+
status: type || 'info',
|
|
93
|
+
message: renderMessage(),
|
|
94
|
+
onClose: onClose,
|
|
95
|
+
onMouseOver: lockInformerVisibility,
|
|
96
|
+
onMouseLeave: unLockInformerVisibility,
|
|
97
|
+
onTouchStart: lockInformerVisibility,
|
|
98
|
+
onTouchCancel: unLockInformerVisibility,
|
|
99
|
+
onTouchEnd: unLockInformerVisibility
|
|
100
|
+
})
|
|
101
|
+
}), /*#__PURE__*/_jsx(ErrorsModal, {
|
|
102
|
+
i18n: i18n,
|
|
103
|
+
displayedErrors: displayedErrors,
|
|
104
|
+
isErrorsModalOpen: isErrorsModalOpen,
|
|
105
|
+
closeErrorsModal: closeErrorsModal,
|
|
106
|
+
handleCopyErrors: handleCopyErrors
|
|
107
|
+
})]
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
export default InformerUI;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Styled from './Informer.styled';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
var renderDetailsButton = function renderDetailsButton(_ref) {
|
|
4
|
+
var onClick = _ref.onClick,
|
|
5
|
+
i18n = _ref.i18n;
|
|
6
|
+
return /*#__PURE__*/_jsx(Styled.DetailsButton, {
|
|
7
|
+
size: "sm",
|
|
8
|
+
color: "link-primary",
|
|
9
|
+
onClick: onClick,
|
|
10
|
+
children: i18n('informerSeeDetailsButtonLabel')
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var InformerUIDetails = function InformerUIDetails(_ref2) {
|
|
14
|
+
var details = _ref2.details,
|
|
15
|
+
errors = _ref2.errors,
|
|
16
|
+
i18n = _ref2.i18n,
|
|
17
|
+
openErrorsModal = _ref2.openErrorsModal;
|
|
18
|
+
if (Array.isArray(errors)) return renderDetailsButton({
|
|
19
|
+
i18n: i18n,
|
|
20
|
+
onClick: openErrorsModal
|
|
21
|
+
});
|
|
22
|
+
return /*#__PURE__*/_jsx(Styled.LabelsTooltip, {
|
|
23
|
+
arrow: true,
|
|
24
|
+
position: "top",
|
|
25
|
+
size: "md",
|
|
26
|
+
title: details,
|
|
27
|
+
children: renderDetailsButton({
|
|
28
|
+
i18n: i18n
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export default InformerUIDetails;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
10
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
11
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
13
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
14
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
import { createElement } from 'react';
|
|
19
|
+
import { Plugin } from '@scaleflex/widget-core';
|
|
20
|
+
import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
|
|
21
|
+
import InformerUI from './InformerUI';
|
|
22
|
+
// TODO: find a way to show version of the current plugin
|
|
23
|
+
// why solution below isn't good?
|
|
24
|
+
// first import doesn't work with webpack 5 as it was deprecated
|
|
25
|
+
// second import fixes webpack 5 issue as it was mentioned in their docs
|
|
26
|
+
// but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
|
|
27
|
+
// https://github.com/axelpale/genversion
|
|
28
|
+
// https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
|
|
29
|
+
// https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
|
|
30
|
+
// import { version } from '../package.json'
|
|
31
|
+
// import packageInfo from '../package.json'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Informer
|
|
35
|
+
* Shows rad message bubbles
|
|
36
|
+
* used like this: `filerobot.info('hello world', 'info', 5000)`
|
|
37
|
+
* or for errors: `filerobot.info('Error uploading img.jpg', 'error', 5000)`
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
var Informer = /*#__PURE__*/function (_Plugin) {
|
|
41
|
+
// static VERSION = packageInfo.version
|
|
42
|
+
|
|
43
|
+
function Informer(filerobot) {
|
|
44
|
+
var _this;
|
|
45
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
46
|
+
_classCallCheck(this, Informer);
|
|
47
|
+
_this = _callSuper(this, Informer, [filerobot, opts]);
|
|
48
|
+
_defineProperty(_this, "render", function (props) {
|
|
49
|
+
var _this$filerobot = _this.filerobot,
|
|
50
|
+
i18n = _this$filerobot.i18n,
|
|
51
|
+
hideInfo = _this$filerobot.hideInfo;
|
|
52
|
+
return /*#__PURE__*/createElement(InformerUI, _objectSpread(_objectSpread({}, props), {}, {
|
|
53
|
+
i18n: i18n,
|
|
54
|
+
hideInfo: hideInfo
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
_this.type = 'progressindicator';
|
|
58
|
+
_this.id = opts.id || PLUGINS_IDS.INFORMER;
|
|
59
|
+
_this.title = 'Informer';
|
|
60
|
+
|
|
61
|
+
// set default options
|
|
62
|
+
var defaultOptions = {};
|
|
63
|
+
// merge default options with the ones set by user
|
|
64
|
+
_this.opts = _extends({}, defaultOptions, opts);
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
_inherits(Informer, _Plugin);
|
|
68
|
+
return _createClass(Informer, [{
|
|
69
|
+
key: "install",
|
|
70
|
+
value: function install() {
|
|
71
|
+
var target = this.opts.target;
|
|
72
|
+
if (target) {
|
|
73
|
+
this.mount(target, this);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}]);
|
|
77
|
+
}(Plugin);
|
|
78
|
+
export { Informer as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scaleflex/widget-informer",
|
|
3
|
+
"description": "A notification and error pop-up bar for Scaleflex.",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"style": "dist/style.min.css",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"/dist",
|
|
11
|
+
"/lib",
|
|
12
|
+
"/types"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@scaleflex/ui": "^3.0.0-beta.11",
|
|
19
|
+
"@scaleflex/widget-common": "^0.0.1",
|
|
20
|
+
"@scaleflex/widget-icons": "^0.0.1",
|
|
21
|
+
"@scaleflex/widget-utils": "^0.0.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"react": "^19.0.0",
|
|
25
|
+
"react-dom": "^19.0.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@scaleflex/widget-core": "^0.0.0",
|
|
29
|
+
"@scaleflex/widget-explorer": "^0.0.0",
|
|
30
|
+
"react": ">=19.0.0",
|
|
31
|
+
"react-dom": ">=19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "64ea82e745b7deda36d6794863350e6671e9010d"
|
|
34
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Filerobot = require("@scaleflex/widget-core");
|
|
2
|
+
|
|
3
|
+
declare module Informer {
|
|
4
|
+
interface InformerOptions extends Filerobot.PluginOptions {
|
|
5
|
+
replaceTargetContent?: boolean;
|
|
6
|
+
target?: Filerobot.PluginTarget;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare class Informer extends Filerobot.Plugin<Informer.InformerOptions> {}
|
|
11
|
+
|
|
12
|
+
export = Informer;
|