@plesk/ui-library 3.27.0 → 3.27.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.
@@ -30,6 +30,20 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
30
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; }
31
31
 
32
32
  // Copyright 1999-2019. Plesk International GmbH. All rights reserved.
33
+ const renderAdditionalButtons = buttons => {
34
+ const buttonProcessing = button => {
35
+ if ( /*#__PURE__*/(0, _react.isValidElement)(button) && button.type === _Button.default) {
36
+ return /*#__PURE__*/(0, _react.cloneElement)(button, {
37
+ size: 'lg'
38
+ });
39
+ }
40
+
41
+ return button;
42
+ };
43
+
44
+ return Array.isArray(buttons) ? buttons.map(buttonProcessing) : buttonProcessing(buttons);
45
+ };
46
+
33
47
  class DrawerProgress extends _react.Component {
34
48
  constructor(...args) {
35
49
  super(...args);
@@ -143,7 +157,7 @@ class DrawerProgress extends _react.Component {
143
157
 
144
158
  const footer = hasFooter ? /*#__PURE__*/_react.default.createElement("div", {
145
159
  className: `${baseClassName}__footer`
146
- }, buttons, canCancel && /*#__PURE__*/_react.default.createElement(_Button.default, {
160
+ }, renderAdditionalButtons(buttons), canCancel && /*#__PURE__*/_react.default.createElement(_Button.default, {
147
161
  onClick: this.handleCancel,
148
162
  size: "lg"
149
163
  }, /*#__PURE__*/_react.default.createElement(_Translate.default, {
@@ -62,8 +62,15 @@ class FormFieldPassword extends _react.Component {
62
62
  super(...args);
63
63
  (0, _defineProperty2.default)(this, "state", {
64
64
  visible: false,
65
- passwordMeterVisible: false
65
+ passwordMeterVisible: false,
66
+ scoreResult: {
67
+ password: null,
68
+ intent: null,
69
+ strength: null,
70
+ unusedRules: []
71
+ }
66
72
  });
73
+ (0, _defineProperty2.default)(this, "passwordOnScoring", null);
67
74
  (0, _defineProperty2.default)(this, "targetRef", /*#__PURE__*/(0, _react.createRef)());
68
75
  (0, _defineProperty2.default)(this, "handleToggleClick", () => {
69
76
  this.setState(({
@@ -80,9 +87,10 @@ class FormFieldPassword extends _react.Component {
80
87
  (0, _defineProperty2.default)(this, "handleBlur", this.handleClosePasswordMeter);
81
88
  }
82
89
 
83
- passwordScore(value) {
90
+ async passwordScore(value) {
84
91
  if (!value) {
85
92
  return {
93
+ password: null,
86
94
  intent: null,
87
95
  strength: null,
88
96
  unusedRules: []
@@ -90,12 +98,15 @@ class FormFieldPassword extends _react.Component {
90
98
  }
91
99
 
92
100
  const {
93
- passwordScoreRules
101
+ passwordScoreRules,
102
+ customPasswordScore
94
103
  } = this.props;
104
+ const passwordScoreFunc = customPasswordScore || _passwordScore.default;
95
105
  const {
106
+ password,
96
107
  score,
97
108
  unusedRules
98
- } = (0, _passwordScore.default)(value, passwordScoreRules);
109
+ } = await passwordScoreFunc(value, passwordScoreRules);
99
110
  let intent = 'success';
100
111
 
101
112
  let strength = /*#__PURE__*/_react.default.createElement(_Translate.default, {
@@ -130,6 +141,7 @@ class FormFieldPassword extends _react.Component {
130
141
  }
131
142
 
132
143
  return {
144
+ password,
133
145
  intent,
134
146
  strength,
135
147
  unusedRules
@@ -144,10 +156,24 @@ class FormFieldPassword extends _react.Component {
144
156
  passwordMeterProps
145
157
  } = this.props;
146
158
  const {
159
+ password,
147
160
  intent,
148
161
  strength,
149
162
  unusedRules
150
- } = this.passwordScore(value);
163
+ } = this.state.scoreResult;
164
+
165
+ if (!!value && value !== password && value !== this.passwordOnScoring) {
166
+ this.passwordOnScoring = value;
167
+ this.passwordScore(value).then(scoreResult => {
168
+ if (this.passwordOnScoring === scoreResult.password) {
169
+ this.passwordOnScoring = null;
170
+ this.setState({
171
+ scoreResult
172
+ });
173
+ }
174
+ });
175
+ }
176
+
151
177
  return /*#__PURE__*/_react.default.createElement(_Popover.default, (0, _extends2.default)({
152
178
  visible: passwordMeterVisible && !!value,
153
179
  target: target,
@@ -234,6 +260,7 @@ class FormFieldPassword extends _react.Component {
234
260
  hidePasswordMeter,
235
261
  passwordMeterProps,
236
262
  passwordScoreRules,
263
+ customPasswordScore,
237
264
  size,
238
265
  autoFocus,
239
266
  autoComplete,
@@ -333,6 +360,12 @@ FormFieldPassword.propTypes = {
333
360
  score: _propTypes.default.func.isRequired
334
361
  })),
335
362
 
363
+ /**
364
+ * Custom password score estimator
365
+ * @since 3.27.1
366
+ */
367
+ customPasswordScore: _propTypes.default.func,
368
+
336
369
  /**
337
370
  * Size of the control
338
371
  * @since 1.5.6
@@ -374,6 +407,7 @@ FormFieldPassword.defaultProps = {
374
407
  hidePasswordMeter: false,
375
408
  passwordMeterProps: {},
376
409
  passwordScoreRules: undefined,
410
+ customPasswordScore: undefined,
377
411
  size: 'md',
378
412
  autoFocus: undefined,
379
413
  autoComplete: undefined,
@@ -21,10 +21,11 @@ const passwordScore = (password, rules = PASSWORD_SCORE_RULES) => {
21
21
  score += mark;
22
22
  }
23
23
  });
24
- return {
24
+ return Promise.resolve({
25
+ password,
25
26
  score,
26
27
  unusedRules
27
- };
28
+ });
28
29
  };
29
30
 
30
31
  const PASSWORD_SCORE_RULES = [{
@@ -126,7 +126,7 @@ const Icon = ({
126
126
  }, props), newName ? /*#__PURE__*/_react.default.createElement("svg", {
127
127
  focusable: "false"
128
128
  }, /*#__PURE__*/_react.default.createElement("use", {
129
- xlinkHref: getHref(newName, newSize)
129
+ href: getHref(newName, newSize)
130
130
  })) : src && /*#__PURE__*/_react.default.createElement("img", {
131
131
  src: src,
132
132
  alt: alt
@@ -1,6 +1,6 @@
1
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="248" viewBox="0 0 51 248">
1
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="56" height="248" viewBox="0 0 51 248">
2
2
  <defs><symbol id="star"><path stroke-width="3" d="m25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z"></path></symbol></defs>
3
- <use x="0" y="0" fill="none" stroke="#ff9500" xlink:href="#star"></use>
4
- <use x="0" y="100" fill="#ff9500" stroke="#ff9500" xlink:href="#star"></use>
5
- <use x="0" y="200" fill="#848484" stroke="#848484" xlink:href="#star"></use>
6
- </svg>
3
+ <use x="0" y="0" fill="none" stroke="#ff9500" href="#star"></use>
4
+ <use x="0" y="100" fill="#ff9500" stroke="#ff9500" href="#star"></use>
5
+ <use x="0" y="200" fill="#848484" stroke="#848484" href="#star"></use>
6
+ </svg>
package/cjs/index.js CHANGED
@@ -54,6 +54,6 @@ Object.keys(_components).forEach(function (key) {
54
54
  });
55
55
  });
56
56
  // Copyright 1999-2018. Plesk International GmbH. All rights reserved.
57
- const version = "3.27.0";
57
+ const version = "3.27.1";
58
58
  exports.version = version;
59
59
  (0, _svg4everybody.default)();
@@ -1,6 +1,6 @@
1
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="248" viewBox="0 0 51 248">
1
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="56" height="248" viewBox="0 0 51 248">
2
2
  <defs><symbol id="star"><path stroke-width="3" d="m25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z"></path></symbol></defs>
3
- <use x="0" y="0" fill="none" stroke="#ff9500" xlink:href="#star"></use>
4
- <use x="0" y="100" fill="#ff9500" stroke="#ff9500" xlink:href="#star"></use>
5
- <use x="0" y="200" fill="#848484" stroke="#848484" xlink:href="#star"></use>
6
- </svg>
3
+ <use x="0" y="0" fill="none" stroke="#ff9500" href="#star"></use>
4
+ <use x="0" y="100" fill="#ff9500" stroke="#ff9500" href="#star"></use>
5
+ <use x="0" y="200" fill="#848484" stroke="#848484" href="#star"></use>
6
+ </svg>