@plesk/ui-library 3.27.4 → 3.28.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 (62) hide show
  1. package/cjs/components/Button/Button.js +13 -6
  2. package/cjs/components/Form/Form.js +7 -2
  3. package/cjs/components/FormField/FormField.js +7 -0
  4. package/cjs/components/FormFieldPassword/estimatePassword.js +19 -10
  5. package/cjs/components/FormFieldText/FormFieldText.js +13 -5
  6. package/cjs/components/InputFile/InputFile.js +4 -2
  7. package/cjs/components/List/List.js +1 -6
  8. package/cjs/components/Skeleton/Skeleton.js +49 -0
  9. package/cjs/components/Skeleton/Skeleton.stories.js +26 -0
  10. package/cjs/components/Skeleton/SkeletonTabs.js +41 -0
  11. package/cjs/components/Skeleton/SkeletonTabs.stories.js +17 -0
  12. package/cjs/components/Skeleton/SkeletonText.js +45 -0
  13. package/cjs/components/Skeleton/SkeletonText.stories.js +35 -0
  14. package/cjs/components/Skeleton/index.js +31 -0
  15. package/cjs/components/index.js +31 -1
  16. package/cjs/components/utils.js +6 -2
  17. package/cjs/index.js +1 -1
  18. package/dist/plesk-ui-library-rtl.css +1 -1
  19. package/dist/plesk-ui-library-rtl.css.map +1 -1
  20. package/dist/plesk-ui-library.css +1 -1
  21. package/dist/plesk-ui-library.css.map +1 -1
  22. package/dist/plesk-ui-library.js +344 -32
  23. package/dist/plesk-ui-library.js.map +1 -1
  24. package/dist/plesk-ui-library.min.js +3 -3
  25. package/dist/plesk-ui-library.min.js.map +1 -1
  26. package/esm/components/Button/Button.js +14 -7
  27. package/esm/components/Form/Form.js +7 -2
  28. package/esm/components/FormField/FormField.js +7 -0
  29. package/esm/components/FormFieldPassword/estimatePassword.js +19 -10
  30. package/esm/components/FormFieldText/FormFieldText.js +13 -5
  31. package/esm/components/InputFile/InputFile.js +4 -2
  32. package/esm/components/List/List.js +1 -6
  33. package/esm/components/Skeleton/Skeleton.js +34 -0
  34. package/esm/components/Skeleton/Skeleton.stories.js +10 -0
  35. package/esm/components/Skeleton/SkeletonTabs.js +26 -0
  36. package/esm/components/Skeleton/SkeletonTabs.stories.js +4 -0
  37. package/esm/components/Skeleton/SkeletonText.js +30 -0
  38. package/esm/components/Skeleton/SkeletonText.stories.js +16 -0
  39. package/esm/components/Skeleton/index.js +4 -0
  40. package/esm/components/index.js +4 -1
  41. package/esm/components/utils.js +2 -1
  42. package/esm/index.js +1 -1
  43. package/package.json +1 -1
  44. package/styleguide/build/bundle.699238d9.js +2 -0
  45. package/styleguide/build/{bundle.5df0ee96.js.LICENSE.txt → bundle.699238d9.js.LICENSE.txt} +0 -0
  46. package/styleguide/index.html +2 -2
  47. package/types/src/components/Form/Form.d.ts +7 -136
  48. package/types/src/components/Form/FormContext.d.ts +2 -14
  49. package/types/src/components/Form/types.d.ts +125 -0
  50. package/types/src/components/FormFieldPassword/FormFieldPassword.d.ts +2 -2
  51. package/types/src/components/InputFile/InputFile.d.ts +6 -1
  52. package/types/src/components/Skeleton/Skeleton.d.ts +49 -0
  53. package/types/src/components/Skeleton/Skeleton.stories.d.ts +12 -0
  54. package/types/src/components/Skeleton/SkeletonTabs.d.ts +23 -0
  55. package/types/src/components/Skeleton/SkeletonTabs.stories.d.ts +6 -0
  56. package/types/src/components/Skeleton/SkeletonText.d.ts +34 -0
  57. package/types/src/components/Skeleton/SkeletonText.stories.d.ts +38 -0
  58. package/types/src/components/Skeleton/index.d.ts +3 -0
  59. package/types/src/components/TextArea/TextArea.d.ts +2 -2
  60. package/types/src/components/index.d.ts +3 -0
  61. package/types/src/components/utils.d.ts +1 -0
  62. package/styleguide/build/bundle.5df0ee96.js +0 -2
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  // Copyright 1999-2020. Plesk International GmbH. All rights reserved.
3
3
 
4
4
  /* eslint-disable react/no-deprecated */
5
- import React, { cloneElement, isValidElement, useContext, useState } from 'react';
5
+ import React, { cloneElement, forwardRef, isValidElement, useContext, useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import classNames from 'classnames';
8
8
  import { CLS_PREFIX } from '../../constants';
@@ -72,7 +72,7 @@ const renderCaret = ({
72
72
  */
73
73
 
74
74
 
75
- const Button = ({
75
+ const Button = /*#__PURE__*/forwardRef(({
76
76
  baseClassName,
77
77
  className,
78
78
  component: Tag,
@@ -90,7 +90,7 @@ const Button = ({
90
90
  arrow,
91
91
  disabled,
92
92
  ...props
93
- }) => {
93
+ }, ref) => {
94
94
  const [selectedState, setSelectedState] = useState(false);
95
95
 
96
96
  const handleToggle = () => {
@@ -145,6 +145,7 @@ const Button = ({
145
145
  const isArrowButton = arrow === 'forward' || arrow === 'backward';
146
146
  const hasAriaDisabled = Tag === 'button' && disabled && tooltip;
147
147
  let button = /*#__PURE__*/React.createElement(Tag, _extends({
148
+ ref: ref,
148
149
  className: classNames(baseClassName, {
149
150
  [`${baseClassName}--${size}`]: size,
150
151
  [`${baseClassName}--${intent}`]: intent && !ghost,
@@ -184,8 +185,8 @@ const Button = ({
184
185
  }
185
186
 
186
187
  return button;
187
- };
188
-
188
+ });
189
+ Button.displayName = 'Button';
189
190
  Button.propTypes = {
190
191
  /**
191
192
  * Button size.
@@ -279,7 +280,12 @@ Button.propTypes = {
279
280
  /**
280
281
  * @ignore
281
282
  */
282
- baseClassName: PropTypes.string
283
+ baseClassName: PropTypes.string,
284
+
285
+ /**
286
+ * @ignore
287
+ */
288
+ onClick: PropTypes.func
283
289
  };
284
290
  Button.defaultProps = {
285
291
  size: undefined,
@@ -297,6 +303,7 @@ Button.defaultProps = {
297
303
  component: 'button',
298
304
  className: undefined,
299
305
  baseClassName: `${CLS_PREFIX}button`,
300
- arrow: undefined
306
+ arrow: undefined,
307
+ onClick: undefined
301
308
  };
302
309
  export default Button;
@@ -26,6 +26,9 @@ class Form extends Component {
26
26
  vertical: this.props.vertical || false,
27
27
  requiredFields: [],
28
28
  formContext: {
29
+ getValues: () => {
30
+ return this.state.values;
31
+ },
29
32
  getValue: (name, def) => {
30
33
  if (this.state.values) {
31
34
  return getIn(this.state.values, name, def);
@@ -248,9 +251,11 @@ class Form extends Component {
248
251
  let field;
249
252
  let fieldErrors;
250
253
  Object.keys(this.fields).every(name => {
251
- if (errors && errors[name] && typeof errors[name] === 'object' && Object.keys(errors[name]).length > 0) {
254
+ const foundError = getIn(errors, name);
255
+
256
+ if (foundError && typeof foundError === 'object' && Object.keys(foundError).length > 0) {
252
257
  field = this.fields[name];
253
- fieldErrors = errors[name];
258
+ fieldErrors = foundError;
254
259
  return false;
255
260
  }
256
261
 
@@ -311,6 +311,13 @@ class FormField extends Component {
311
311
  return null;
312
312
  },
313
313
  getName: () => this.props.name,
314
+ getValues: () => {
315
+ if (this.props.form) {
316
+ return this.props.form.getValues();
317
+ }
318
+
319
+ return null;
320
+ },
314
321
  getValue: def => {
315
322
  if (this.props.form && this.props.name) {
316
323
  return this.props.form.getValue(this.props.name, def);
@@ -2,6 +2,12 @@
2
2
  import React from 'react';
3
3
  import Translate from '../Translate';
4
4
  import locale from './locale/en-US';
5
+ const EXCLUSIONS = {
6
+ numbers1: 'numbers3',
7
+ specialChar1: 'specialChar2',
8
+ lettersLowerCase: 'comboUpperAndLower',
9
+ lettersUpperCase: 'comboUpperAndLower'
10
+ };
5
11
  export const DEFAULT_RULES = [{
6
12
  name: 'passwordTooShort',
7
13
  suggestion: /*#__PURE__*/React.createElement(Translate, {
@@ -142,18 +148,21 @@ export const DEFAULT_RULES = [{
142
148
 
143
149
  }];
144
150
  export default ((password, rules = DEFAULT_RULES) => {
145
- const suggestions = [];
146
151
  let passwordScore = 0;
147
- rules.forEach(({
148
- suggestion,
149
- score
150
- }) => {
151
- const ruleScore = score(password);
152
-
153
- if (ruleScore < 0 && suggestion) {
154
- suggestions.push(suggestion);
155
- } else {
152
+ const suggestions = [];
153
+ const skippedRules = new Set();
154
+ rules.forEach(rule => {
155
+ const ruleScore = rule.score(password);
156
+
157
+ if (ruleScore >= 0) {
156
158
  passwordScore += ruleScore;
159
+ return;
160
+ }
161
+
162
+ skippedRules.add(EXCLUSIONS[rule.name]);
163
+
164
+ if (!skippedRules.has(rule.name) && rule.suggestion) {
165
+ suggestions.push(rule.suggestion);
157
166
  }
158
167
  });
159
168
  let strength;
@@ -28,6 +28,7 @@ class FormFieldText extends Component {
28
28
  autoFocus,
29
29
  autoComplete,
30
30
  autoheight,
31
+ inputProps,
31
32
  ...props
32
33
  } = this.props;
33
34
  return /*#__PURE__*/React.createElement(FormField, _extends({
@@ -40,7 +41,7 @@ class FormFieldText extends Component {
40
41
  getValue,
41
42
  setValue,
42
43
  isDisabled
43
- }) => multiline ? /*#__PURE__*/React.createElement(TextArea, {
44
+ }) => multiline ? /*#__PURE__*/React.createElement(TextArea, _extends({
44
45
  id: getId(),
45
46
  name: getName(),
46
47
  value: getValue(''),
@@ -52,7 +53,7 @@ class FormFieldText extends Component {
52
53
  autoFocus: autoFocus,
53
54
  autoComplete: autoComplete,
54
55
  autoheight: autoheight
55
- }) : /*#__PURE__*/React.createElement(Input, {
56
+ }, inputProps)) : /*#__PURE__*/React.createElement(Input, _extends({
56
57
  id: getId(),
57
58
  name: getName(),
58
59
  className: `${baseClassName}__input`,
@@ -63,7 +64,7 @@ class FormFieldText extends Component {
63
64
  placeholder: placeholder,
64
65
  autoFocus: autoFocus,
65
66
  autoComplete: autoComplete
66
- }));
67
+ }, inputProps)));
67
68
  }
68
69
 
69
70
  }
@@ -134,7 +135,13 @@ FormFieldText.propTypes = {
134
135
  * Adjust height automatically when multiline option is set to true.
135
136
  * @since 1.9.0
136
137
  */
137
- autoheight: PropTypes.bool
138
+ autoheight: PropTypes.bool,
139
+
140
+ /**
141
+ * Props of underlying input element.
142
+ * @since 3.28.1
143
+ */
144
+ inputProps: PropTypes.object
138
145
  };
139
146
  FormFieldText.defaultProps = {
140
147
  size: undefined,
@@ -147,6 +154,7 @@ FormFieldText.defaultProps = {
147
154
  multi: undefined,
148
155
  className: undefined,
149
156
  baseClassName: `${CLS_PREFIX}form-field-text`,
150
- autoheight: false
157
+ autoheight: false,
158
+ inputProps: undefined
151
159
  };
152
160
  export default FormFieldText;
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- // Copyright 1999-2020. Plesk International GmbH. All rights reserved.
2
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
3
3
  import React, { useState, useRef, useEffect } from 'react';
4
4
  import classNames from 'classnames';
5
5
  import { CLS_PREFIX } from '../../constants';
@@ -24,6 +24,7 @@ const InputFile = ({
24
24
  disabled = false,
25
25
  locale,
26
26
  testId,
27
+ accept,
27
28
  ...props
28
29
  }) => {
29
30
  const [file, setFile] = useState();
@@ -81,7 +82,8 @@ const InputFile = ({
81
82
  ref: inputRef,
82
83
  "data-test": testId && `${testId}--file-input`,
83
84
  onFocus: handleFocus,
84
- onBlur: handleBlur
85
+ onBlur: handleBlur,
86
+ accept: accept
85
87
  }), /*#__PURE__*/React.createElement(Translate, {
86
88
  namespace: "InputFile",
87
89
  content: "browseButton",
@@ -875,14 +875,9 @@ class List extends Component {
875
875
 
876
876
  if (totalRows && /*#__PURE__*/isValidElement(pagination)) {
877
877
  const {
878
- itemsPerPageOptions = ITEMS_PER_PAGE_OPTIONS,
879
- itemsPerPage
878
+ itemsPerPageOptions = ITEMS_PER_PAGE_OPTIONS
880
879
  } = pagination.props;
881
880
 
882
- if (Number.isInteger(itemsPerPage)) {
883
- return totalRows > itemsPerPage;
884
- }
885
-
886
881
  if (Array.isArray(itemsPerPageOptions)) {
887
882
  const numericOptions = itemsPerPageOptions.filter(v => Number(v) === v);
888
883
 
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
3
+ import React from 'react';
4
+ import classNames from 'classnames';
5
+ import { normalizeSize } from '../utils';
6
+ import { CLS_PREFIX } from '../../constants';
7
+
8
+ /**
9
+ * `Skeleton` (or content-placeholder) is placeholder preview of content before the data gets loaded to reduce load-time frustration.
10
+ * Skeleton is used for non-text components, images, media-objects, etc.
11
+ * @since 3.28.0
12
+ */
13
+ const Skeleton = ({
14
+ width,
15
+ maxWidth,
16
+ height,
17
+ style,
18
+ component: Tag = 'span',
19
+ className,
20
+ baseClassName = `${CLS_PREFIX}skeleton`,
21
+ ...props
22
+ }) => {
23
+ const finalStyle = { ...style,
24
+ width: normalizeSize(width),
25
+ maxWidth: normalizeSize(maxWidth),
26
+ height: normalizeSize(height)
27
+ };
28
+ return /*#__PURE__*/React.createElement(Tag, _extends({
29
+ className: classNames(baseClassName, className),
30
+ style: finalStyle
31
+ }, props));
32
+ };
33
+
34
+ export default Skeleton;
@@ -0,0 +1,10 @@
1
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
2
+ import React from 'react';
3
+ import Skeleton from './Skeleton';
4
+ export const Basic = args => /*#__PURE__*/React.createElement(Skeleton, args);
5
+ Basic.args = {};
6
+ export const CustomSize = args => /*#__PURE__*/React.createElement(Basic, args);
7
+ CustomSize.args = {
8
+ width: 200,
9
+ height: 100
10
+ };
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
3
+ import React from 'react';
4
+ import classNames from 'classnames';
5
+ import SkeletonText from './SkeletonText';
6
+ import { CLS_PREFIX } from '../../constants';
7
+
8
+ /**
9
+ * Skeleton for tabs component
10
+ * @since `3.28.0
11
+ */
12
+ const SkeletonTabs = ({
13
+ count = 3,
14
+ className,
15
+ baseClassName = `${CLS_PREFIX}skeleton-tabs`,
16
+ ...props
17
+ }) => /*#__PURE__*/React.createElement("div", _extends({
18
+ className: classNames(baseClassName, className)
19
+ }, props), /*#__PURE__*/React.createElement(SkeletonText, {
20
+ lineProps: {
21
+ maxWidth: 100
22
+ },
23
+ lines: count
24
+ }));
25
+
26
+ export default SkeletonTabs;
@@ -0,0 +1,4 @@
1
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
2
+ import React from 'react';
3
+ import SkeletonTabs from './SkeletonTabs';
4
+ export const Basic = args => /*#__PURE__*/React.createElement(SkeletonTabs, args);
@@ -0,0 +1,30 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
3
+ import React from 'react';
4
+ import classNames from 'classnames';
5
+ import Skeleton from './Skeleton';
6
+ import { CLS_PREFIX } from '../../constants';
7
+
8
+ /**
9
+ * Skeleton for text-containing components. Is can be used inside Paragraph, as title, or single text
10
+ * @since 3.28.0
11
+ */
12
+ const SkeletonText = ({
13
+ lines = 3,
14
+ component: Tag = 'span',
15
+ className,
16
+ baseClassName = `${CLS_PREFIX}skeleton-text`,
17
+ lineProps = {},
18
+ ...props
19
+ }) => /*#__PURE__*/React.createElement(Tag, _extends({
20
+ className: classNames(baseClassName, className)
21
+ }, props), Array.from({
22
+ length: lines
23
+ }).map((_, key) => /*#__PURE__*/React.createElement(Skeleton // eslint-disable-next-line react/no-array-index-key
24
+ , _extends({
25
+ key: key
26
+ }, lineProps, {
27
+ className: classNames(`${baseClassName}__line`, lineProps === null || lineProps === void 0 ? void 0 : lineProps.className)
28
+ }))));
29
+
30
+ export default SkeletonText;
@@ -0,0 +1,16 @@
1
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
2
+ import React from 'react';
3
+ import SkeletonText from './SkeletonText';
4
+ export const Basic = args => /*#__PURE__*/React.createElement(SkeletonText, args);
5
+ Basic.args = {};
6
+ export const LinesCount = args => /*#__PURE__*/React.createElement(Basic, args);
7
+ LinesCount.args = {
8
+ lines: 5
9
+ };
10
+ export const Custom = args => /*#__PURE__*/React.createElement(Basic, args);
11
+ Custom.args = {
12
+ lines: 5,
13
+ lineProps: {
14
+ width: 200
15
+ }
16
+ };
@@ -0,0 +1,4 @@
1
+ // Copyright 1999-2022. Plesk International GmbH. All rights reserved.
2
+ export { default } from './Skeleton';
3
+ export { default as SkeletonText } from './SkeletonText';
4
+ export { default as SkeletonTabs } from './SkeletonTabs';
@@ -96,4 +96,7 @@ export * from './Toolbar';
96
96
  export { default as Tooltip } from './Tooltip';
97
97
  export { default as Tour } from './Tour';
98
98
  export { default as Translate } from './Translate';
99
- export { default as Link } from './Link';
99
+ export { default as Link } from './Link';
100
+ export { default as Skeleton } from './Skeleton';
101
+ export * from './Skeleton';
102
+ export { PortalContext } from './Layer';
@@ -223,4 +223,5 @@ export const mergeRefs = (...refs) => value => {
223
223
  ref.current = value;
224
224
  }
225
225
  });
226
- };
226
+ };
227
+ export const normalizeSize = value => String(Number(value)) === String(value) ? `${value}px` : value;
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 1999-2018. Plesk International GmbH. All rights reserved.
2
2
  import svg4everybody from 'svg4everybody';
3
- const version = "3.27.4";
3
+ const version = "3.28.2";
4
4
  export * from './publicPath';
5
5
  export { version };
6
6
  export * from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plesk/ui-library",
3
- "version": "3.27.4",
3
+ "version": "3.28.2",
4
4
  "description": "Plesk UI Library",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",