@plesk/ui-library 3.28.3 → 3.29.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/README.md +15 -0
- package/cjs/components/ContentLoader/IconsLoader.js +31 -23
- package/cjs/components/FormField/FormField.js +1 -1
- package/cjs/components/Toast/Toast.js +23 -8
- package/cjs/components/Toaster/Toaster.js +4 -6
- package/cjs/index.js +1 -1
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +58 -37
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +2 -2
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/ContentLoader/IconsLoader.js +31 -23
- package/esm/components/FormField/FormField.js +1 -1
- package/esm/components/Toast/Toast.js +21 -8
- package/esm/components/Toaster/Toaster.js +4 -5
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/styleguide/build/bundle.73fec982.js +2 -0
- package/styleguide/build/{bundle.3b7e4d37.js.LICENSE.txt → bundle.73fec982.js.LICENSE.txt} +0 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/ContentLoader/IconsLoader.d.ts +6 -4
- package/types/src/components/Toast/Toast.d.ts +9 -0
- package/types/src/components/Toaster/Toaster.d.ts +2 -0
- package/styleguide/build/bundle.3b7e4d37.js +0 -2
package/README.md
CHANGED
|
@@ -33,3 +33,18 @@ function App() {
|
|
|
33
33
|
|
|
34
34
|
export default App;
|
|
35
35
|
```
|
|
36
|
+
|
|
37
|
+
## Development
|
|
38
|
+
|
|
39
|
+
Sometimes you need to fix UI Library bug that fires in your project using UI Library.
|
|
40
|
+
|
|
41
|
+
There is a way to test dev version of the UI Library with your project. You need to use `yarn link` command,
|
|
42
|
+
but there are some details.
|
|
43
|
+
|
|
44
|
+
* First, you need to run `yarn link` in your UI Library working copy root directory.
|
|
45
|
+
* Then, you need to run `yarn link @plesk/ui-library` in your project working copy root directory.
|
|
46
|
+
* Third. There is a bug with a React library that makes us to do additional steps. Run `yarn link` in your
|
|
47
|
+
project's `node_modules/react` and `node_modules/react-dom` directories.
|
|
48
|
+
* Then, run `yarn link react` and `yarn link react-dom` in your UI Library working copy root directory.
|
|
49
|
+
|
|
50
|
+
So, in this setup, your project will use the dev copy of UI Library. And UI Library will use React from your project.
|
|
@@ -21,10 +21,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
23
|
|
|
24
|
-
// Copyright 1999-
|
|
24
|
+
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
|
|
25
25
|
const DEFAULT_ICONS = ['clock', 'emoticon-smile', 'rocket', 'sand-clock', 'sleep', 'web', 'star'];
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const useIconCursor = (icons, initialCursor, isSync) => {
|
|
28
28
|
const targetRef = (0, _react.useRef)(null);
|
|
29
29
|
const [cursor, setCursor] = (0, _react.useState)(initialCursor);
|
|
30
30
|
(0, _react.useEffect)(() => {
|
|
@@ -46,50 +46,58 @@ const useIcon = (icons, initialCursor, isSync) => {
|
|
|
46
46
|
}
|
|
47
47
|
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
48
|
}, [icons]);
|
|
49
|
-
return
|
|
50
|
-
name: icons[cursor],
|
|
51
|
-
targetRef
|
|
52
|
-
};
|
|
49
|
+
return [icons[cursor], targetRef];
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
const IconsLoader = ({
|
|
56
53
|
baseClassName = `${_constants.CLS_PREFIX}icons-loader`,
|
|
57
54
|
className,
|
|
58
55
|
icons,
|
|
56
|
+
size,
|
|
57
|
+
style,
|
|
59
58
|
...props
|
|
60
59
|
}) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
var _icons;
|
|
61
|
+
|
|
62
|
+
const syncRef = (0, _react.useRef)('icon1');
|
|
63
|
+
|
|
64
|
+
if (!((_icons = icons) !== null && _icons !== void 0 && _icons.length)) {
|
|
65
|
+
icons = DEFAULT_ICONS;
|
|
66
|
+
} else if (icons.length === 1) {
|
|
67
|
+
icons = [icons[0], icons[0]];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const [icon1, icon1Ref] = useIconCursor(icons, 0, () => {
|
|
71
|
+
if (syncRef.current === 'icon1') {
|
|
72
|
+
syncRef.current = 'icon2';
|
|
66
73
|
return true;
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
return false;
|
|
70
77
|
});
|
|
71
|
-
const icon2 =
|
|
72
|
-
if (syncRef.current ===
|
|
73
|
-
syncRef.current
|
|
78
|
+
const [icon2, icon2Ref] = useIconCursor(icons, 1, () => {
|
|
79
|
+
if (syncRef.current === 'icon2') {
|
|
80
|
+
syncRef.current = 'icon1';
|
|
74
81
|
return true;
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
return false;
|
|
78
85
|
});
|
|
79
86
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
80
|
-
className: (0, _classnames.default)(baseClassName, className)
|
|
87
|
+
className: (0, _classnames.default)(baseClassName, className),
|
|
88
|
+
style: { ...style,
|
|
89
|
+
['--icons-loader-size']: size ? size : undefined
|
|
90
|
+
}
|
|
81
91
|
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
82
92
|
className: (0, _classnames.default)(`${baseClassName}__icon`, `${baseClassName}__icon--1`),
|
|
83
|
-
ref:
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
size: "64"
|
|
93
|
+
ref: icon1Ref
|
|
94
|
+
}, _Icon.default.create(icon1, {
|
|
95
|
+
size: size ? size : '64'
|
|
87
96
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
88
97
|
className: (0, _classnames.default)(`${baseClassName}__icon`, `${baseClassName}__icon--2`),
|
|
89
|
-
ref:
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
size: "64"
|
|
98
|
+
ref: icon2Ref
|
|
99
|
+
}, _Icon.default.create(icon2, {
|
|
100
|
+
size: size ? size : '64'
|
|
93
101
|
})));
|
|
94
102
|
};
|
|
95
103
|
|
|
@@ -225,7 +225,7 @@ class FormField extends _react.Component {
|
|
|
225
225
|
multi
|
|
226
226
|
} = this.props;
|
|
227
227
|
|
|
228
|
-
if (!description || multi && this.fieldApi.getValue().length - 1 > index) {
|
|
228
|
+
if (!description || multi && getArrayHelper(this.fieldApi.getValue()).length - 1 > index) {
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -23,11 +23,13 @@ var _Button = _interopRequireDefault(require("../Button"));
|
|
|
23
23
|
|
|
24
24
|
var _intentIconMap = require("../intentIconMap");
|
|
25
25
|
|
|
26
|
+
var _OnDarkContext = _interopRequireDefault(require("../OnDarkContext"));
|
|
27
|
+
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
31
|
|
|
30
|
-
// Copyright 1999-
|
|
32
|
+
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
|
|
31
33
|
const AUTOCLOSE_TIMEOUT = 6000;
|
|
32
34
|
|
|
33
35
|
class Toast extends _react.Component {
|
|
@@ -72,6 +74,10 @@ class Toast extends _react.Component {
|
|
|
72
74
|
className,
|
|
73
75
|
message,
|
|
74
76
|
intent,
|
|
77
|
+
accent,
|
|
78
|
+
icon = intent && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
79
|
+
name: _intentIconMap.intentIconMap[intent]
|
|
80
|
+
}),
|
|
75
81
|
onClose,
|
|
76
82
|
closable = true,
|
|
77
83
|
autoClosable,
|
|
@@ -79,18 +85,19 @@ class Toast extends _react.Component {
|
|
|
79
85
|
innerRef,
|
|
80
86
|
...props
|
|
81
87
|
} = this.props;
|
|
82
|
-
|
|
88
|
+
|
|
89
|
+
const result = /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
83
90
|
tabIndex: 0,
|
|
84
|
-
className: (0, _classnames.default)(baseClassName, intent && `${baseClassName}--${intent}`, className)
|
|
91
|
+
className: (0, _classnames.default)(baseClassName, intent && `${baseClassName}--${intent}`, accent && `${baseClassName}--accent`, className)
|
|
85
92
|
}, props, {
|
|
86
93
|
ref: innerRef
|
|
87
|
-
}),
|
|
94
|
+
}), icon ? /*#__PURE__*/_react.default.createElement("div", {
|
|
88
95
|
className: `${baseClassName}__icon`
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
})) : null, /*#__PURE__*/_react.default.createElement("
|
|
96
|
+
}, _Icon.default.create(icon, {
|
|
97
|
+
intent
|
|
98
|
+
})) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
92
99
|
className: `${baseClassName}__content`
|
|
93
|
-
}, message), closable ? /*#__PURE__*/_react.default.createElement("
|
|
100
|
+
}, message), closable ? /*#__PURE__*/_react.default.createElement("div", {
|
|
94
101
|
className: `${baseClassName}__action`
|
|
95
102
|
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
96
103
|
ghost: true,
|
|
@@ -101,6 +108,14 @@ class Toast extends _react.Component {
|
|
|
101
108
|
className: `${baseClassName}__close`,
|
|
102
109
|
onClick: onClose
|
|
103
110
|
})) : null);
|
|
111
|
+
|
|
112
|
+
if (accent) {
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_OnDarkContext.default.Provider, {
|
|
117
|
+
value: true
|
|
118
|
+
}, result);
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
}
|
|
@@ -25,8 +25,6 @@ var _Toast = _interopRequireDefault(require("../Toast"));
|
|
|
25
25
|
|
|
26
26
|
var _Layer = _interopRequireDefault(require("../Layer"));
|
|
27
27
|
|
|
28
|
-
var _OnDarkContext = _interopRequireDefault(require("../OnDarkContext"));
|
|
29
|
-
|
|
30
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
29
|
|
|
32
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -66,6 +64,8 @@ class Toaster extends _react.Component {
|
|
|
66
64
|
* Add a new toast
|
|
67
65
|
*
|
|
68
66
|
* `intent` - Visual intent color to apply to component. (Type: `oneOf` 'info', 'success', 'warning', 'danger'. *Required*.)<br>
|
|
67
|
+
* `accent` - Contrast (light) version of the component. (Type: `boolean`. Default: 'undefined'.)<br>
|
|
68
|
+
* `icon` - Name of icon or [Icon](#!/Icon) component. (Type: `oneOfType` 'string', 'object', 'element'. Default: `undefined`.)<br>
|
|
69
69
|
* `message` - Message to display in the body of the toast. (Type: `any`. Default: `undefined`.)<br>
|
|
70
70
|
* `onClose` - onClose handler. (Type: `func`. Default: `undefined`.)<br>
|
|
71
71
|
* `closable` - Show close control (cross mark). (Type: `boolean`. Default: `true`.)<br>
|
|
@@ -155,9 +155,7 @@ class Toaster extends _react.Component {
|
|
|
155
155
|
stack.reverse();
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
159
|
-
value: true
|
|
160
|
-
}, /*#__PURE__*/_react.default.createElement(_Layer.default, {
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement(_Layer.default, {
|
|
161
159
|
level: _constants.Z_INDEX_TOASTER
|
|
162
160
|
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
163
161
|
className: (0, _classnames.default)(baseClassName, {
|
|
@@ -203,7 +201,7 @@ class Toaster extends _react.Component {
|
|
|
203
201
|
},
|
|
204
202
|
innerRef: toastRef
|
|
205
203
|
})));
|
|
206
|
-
}))))
|
|
204
|
+
}))));
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
}
|
package/cjs/index.js
CHANGED