@plesk/ui-library 3.27.4 → 3.28.0

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 (46) hide show
  1. package/cjs/components/Form/Form.js +4 -2
  2. package/cjs/components/FormFieldPassword/estimatePassword.js +19 -10
  3. package/cjs/components/Skeleton/Skeleton.js +49 -0
  4. package/cjs/components/Skeleton/Skeleton.stories.js +26 -0
  5. package/cjs/components/Skeleton/SkeletonTabs.js +41 -0
  6. package/cjs/components/Skeleton/SkeletonTabs.stories.js +17 -0
  7. package/cjs/components/Skeleton/SkeletonText.js +45 -0
  8. package/cjs/components/Skeleton/SkeletonText.stories.js +35 -0
  9. package/cjs/components/Skeleton/index.js +31 -0
  10. package/cjs/components/index.js +22 -1
  11. package/cjs/components/utils.js +6 -2
  12. package/cjs/index.js +1 -1
  13. package/dist/plesk-ui-library-rtl.css +1 -1
  14. package/dist/plesk-ui-library-rtl.css.map +1 -1
  15. package/dist/plesk-ui-library.css +1 -1
  16. package/dist/plesk-ui-library.css.map +1 -1
  17. package/dist/plesk-ui-library.js +295 -14
  18. package/dist/plesk-ui-library.js.map +1 -1
  19. package/dist/plesk-ui-library.min.js +3 -3
  20. package/dist/plesk-ui-library.min.js.map +1 -1
  21. package/esm/components/Form/Form.js +4 -2
  22. package/esm/components/FormFieldPassword/estimatePassword.js +19 -10
  23. package/esm/components/Skeleton/Skeleton.js +34 -0
  24. package/esm/components/Skeleton/Skeleton.stories.js +10 -0
  25. package/esm/components/Skeleton/SkeletonTabs.js +26 -0
  26. package/esm/components/Skeleton/SkeletonTabs.stories.js +4 -0
  27. package/esm/components/Skeleton/SkeletonText.js +30 -0
  28. package/esm/components/Skeleton/SkeletonText.stories.js +16 -0
  29. package/esm/components/Skeleton/index.js +4 -0
  30. package/esm/components/index.js +3 -1
  31. package/esm/components/utils.js +2 -1
  32. package/esm/index.js +1 -1
  33. package/package.json +1 -1
  34. package/styleguide/build/bundle.24d5b0eb.js +2 -0
  35. package/styleguide/build/{bundle.5df0ee96.js.LICENSE.txt → bundle.24d5b0eb.js.LICENSE.txt} +0 -0
  36. package/styleguide/index.html +2 -2
  37. package/types/src/components/Skeleton/Skeleton.d.ts +49 -0
  38. package/types/src/components/Skeleton/Skeleton.stories.d.ts +12 -0
  39. package/types/src/components/Skeleton/SkeletonTabs.d.ts +23 -0
  40. package/types/src/components/Skeleton/SkeletonTabs.stories.d.ts +6 -0
  41. package/types/src/components/Skeleton/SkeletonText.d.ts +34 -0
  42. package/types/src/components/Skeleton/SkeletonText.stories.d.ts +38 -0
  43. package/types/src/components/Skeleton/index.d.ts +3 -0
  44. package/types/src/components/index.d.ts +2 -0
  45. package/types/src/components/utils.d.ts +1 -0
  46. package/styleguide/build/bundle.5df0ee96.js +0 -2
@@ -248,9 +248,11 @@ class Form extends Component {
248
248
  let field;
249
249
  let fieldErrors;
250
250
  Object.keys(this.fields).every(name => {
251
- if (errors && errors[name] && typeof errors[name] === 'object' && Object.keys(errors[name]).length > 0) {
251
+ const foundError = getIn(errors, name);
252
+
253
+ if (foundError && typeof foundError === 'object' && Object.keys(foundError).length > 0) {
252
254
  field = this.fields[name];
253
- fieldErrors = errors[name];
255
+ fieldErrors = foundError;
254
256
  return false;
255
257
  }
256
258
 
@@ -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;
@@ -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,6 @@ 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';
@@ -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.0";
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.0",
4
4
  "description": "Plesk UI Library",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",