auth0-lock 11.34.1 → 12.0.0-beta.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 (241) hide show
  1. package/.browserslistrc +1 -0
  2. package/.circleci/config.yml +4 -2
  3. package/.eslintrc.json +5 -5
  4. package/.github/workflows/codeql.yml +41 -0
  5. package/.shiprc +4 -5
  6. package/CHANGELOG.md +32 -0
  7. package/EXAMPLES.md +626 -0
  8. package/README.md +77 -649
  9. package/karma.conf.js +1 -1
  10. package/lib/CSSCore.js +1 -4
  11. package/lib/__tests__/auth_button.js +12 -22
  12. package/lib/__tests__/connection/database/actions.js +48 -49
  13. package/lib/__tests__/connection/database/index.js +22 -28
  14. package/lib/__tests__/connection/database/login_pane.js +20 -41
  15. package/lib/__tests__/connection/database/password_reset_confirmation.js +19 -26
  16. package/lib/__tests__/connection/database/reset_password.js +17 -39
  17. package/lib/__tests__/connection/database/signed_up_confirmation.js +19 -26
  18. package/lib/__tests__/connection/enterprise/actions.js +22 -47
  19. package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
  20. package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
  21. package/lib/__tests__/connection/enterprise/quick_auth_screen.js +27 -68
  22. package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
  23. package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +19 -26
  24. package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
  25. package/lib/__tests__/core/actions.js +23 -46
  26. package/lib/__tests__/core/client/index.js +10 -13
  27. package/lib/__tests__/core/index.js +46 -94
  28. package/lib/__tests__/core/remote_data.js +14 -20
  29. package/lib/__tests__/core/signed_in_confirmation.js +19 -26
  30. package/lib/__tests__/core/sso/last_login_screen.js +27 -50
  31. package/lib/__tests__/core/tenant.js +10 -12
  32. package/lib/__tests__/core/web_api/helper.js +6 -14
  33. package/lib/__tests__/core/web_api/p2_api.js +38 -33
  34. package/lib/__tests__/core/web_api.js +37 -33
  35. package/lib/__tests__/engine/classic/login.js +20 -41
  36. package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
  37. package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
  38. package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
  39. package/lib/__tests__/engine/classic.js +13 -6
  40. package/lib/__tests__/engine/passwordless.js +2 -5
  41. package/lib/__tests__/field/captcha/recaptcha_enterprise.js +27 -27
  42. package/lib/__tests__/field/captcha/recaptchav2.js +27 -27
  43. package/lib/__tests__/field/captcha.js +39 -51
  44. package/lib/__tests__/field/custom_input.js +23 -47
  45. package/lib/__tests__/field/email.js +2 -3
  46. package/lib/__tests__/field/email_pane.js +25 -48
  47. package/lib/__tests__/field/field.js +9 -13
  48. package/lib/__tests__/field/login_pane.js +30 -34
  49. package/lib/__tests__/field/mfa_code_pane.js +13 -28
  50. package/lib/__tests__/field/option_selection_pane.js +7 -25
  51. package/lib/__tests__/field/password.js +6 -12
  52. package/lib/__tests__/field/password_pane.js +29 -46
  53. package/lib/__tests__/field/phone_number_pane.js +18 -41
  54. package/lib/__tests__/field/social_buttons_pane.js +30 -47
  55. package/lib/__tests__/field/username.js +27 -48
  56. package/lib/__tests__/field/username_pane.js +30 -47
  57. package/lib/__tests__/field/vcode.js +5 -13
  58. package/lib/__tests__/field/vcode_pane.js +20 -44
  59. package/lib/__tests__/i18n.js +28 -53
  60. package/lib/__tests__/quick-auth/actions.js +4 -27
  61. package/lib/__tests__/setup-tests.js +7 -9
  62. package/lib/__tests__/testUtils.js +41 -58
  63. package/lib/__tests__/ui/box/chrome.js +24 -49
  64. package/lib/__tests__/ui/box/confirmation_pane.js +19 -36
  65. package/lib/__tests__/ui/box/container.js +21 -46
  66. package/lib/__tests__/ui/box/global_message.js +60 -37
  67. package/lib/__tests__/ui/input/email_input.js +6 -17
  68. package/lib/__tests__/ui/input/input_wrap.js +6 -19
  69. package/lib/__tests__/ui/input/password/password_strength.js +13 -15
  70. package/lib/__tests__/ui/input/password_input.js +22 -27
  71. package/lib/__tests__/utils/format.js +10 -17
  72. package/lib/__tests__/utils/url_utils.js +2 -5
  73. package/lib/avatar/gravatar_provider.js +13 -28
  74. package/lib/avatar.js +22 -41
  75. package/lib/browser.js +372 -23
  76. package/lib/connection/captcha.js +14 -32
  77. package/lib/connection/database/actions.js +39 -108
  78. package/lib/connection/database/index.js +90 -191
  79. package/lib/connection/database/login_pane.js +107 -147
  80. package/lib/connection/database/login_sign_up_tabs.js +106 -125
  81. package/lib/connection/database/mfa_pane.js +50 -69
  82. package/lib/connection/database/password_reset_confirmation.js +51 -73
  83. package/lib/connection/database/reset_password.js +116 -132
  84. package/lib/connection/database/reset_password_pane.js +45 -56
  85. package/lib/connection/database/sign_up_terms.js +17 -23
  86. package/lib/connection/database/signed_up_confirmation.js +52 -75
  87. package/lib/connection/enterprise/actions.js +23 -52
  88. package/lib/connection/enterprise/hrd_pane.js +60 -76
  89. package/lib/connection/enterprise/hrd_screen.js +60 -75
  90. package/lib/connection/enterprise/kerberos_screen.js +46 -60
  91. package/lib/connection/enterprise/quick_auth_screen.js +46 -64
  92. package/lib/connection/enterprise/single_sign_on_notice.js +14 -26
  93. package/lib/connection/enterprise.js +51 -84
  94. package/lib/connection/passwordless/actions.js +29 -62
  95. package/lib/connection/passwordless/ask_vcode.js +53 -60
  96. package/lib/connection/passwordless/email_sent_confirmation.js +129 -179
  97. package/lib/connection/passwordless/index.js +36 -68
  98. package/lib/connection/social/index.js +12 -15
  99. package/lib/core/actions.js +33 -85
  100. package/lib/core/client/index.js +38 -58
  101. package/lib/core/client/settings.js +12 -20
  102. package/lib/core/error_screen.js +38 -52
  103. package/lib/core/index.js +152 -301
  104. package/lib/core/loading_screen.js +61 -71
  105. package/lib/core/pane_separator.js +10 -10
  106. package/lib/core/remote_data.js +28 -48
  107. package/lib/core/screen.js +85 -79
  108. package/lib/core/signed_in_confirmation.js +51 -73
  109. package/lib/core/sso/data.js +9 -17
  110. package/lib/core/sso/index.js +5 -6
  111. package/lib/core/sso/last_login_screen.js +46 -63
  112. package/lib/core/tenant/index.js +37 -59
  113. package/lib/core/tenant/settings.js +11 -15
  114. package/lib/core/web_api/helper.js +24 -30
  115. package/lib/core/web_api/p2_api.js +156 -165
  116. package/lib/core/web_api.js +101 -90
  117. package/lib/core.js +126 -160
  118. package/lib/engine/classic/login.js +92 -144
  119. package/lib/engine/classic/mfa_login_screen.js +61 -67
  120. package/lib/engine/classic/sign_up_pane.js +89 -123
  121. package/lib/engine/classic/sign_up_screen.js +112 -158
  122. package/lib/engine/classic.js +122 -183
  123. package/lib/engine/passwordless/social_or_email_login_screen.js +71 -106
  124. package/lib/engine/passwordless/social_or_phone_number_login_screen.js +70 -100
  125. package/lib/engine/passwordless.js +75 -104
  126. package/lib/field/actions.js +11 -17
  127. package/lib/field/captcha/captcha_pane.js +82 -102
  128. package/lib/field/captcha/recaptcha.js +140 -145
  129. package/lib/field/captcha.js +7 -10
  130. package/lib/field/custom_input.js +37 -50
  131. package/lib/field/email/email_pane.js +90 -109
  132. package/lib/field/email.js +17 -35
  133. package/lib/field/index.js +51 -88
  134. package/lib/field/mfa-code/mfa_code_pane.js +57 -71
  135. package/lib/field/mfa_code.js +15 -21
  136. package/lib/field/option_selection_pane.js +16 -22
  137. package/lib/field/password/password_pane.js +79 -91
  138. package/lib/field/password.js +8 -14
  139. package/lib/field/phone-number/locations.js +7 -3
  140. package/lib/field/phone-number/phone_number_pane.js +87 -124
  141. package/lib/field/phone_number.js +16 -30
  142. package/lib/field/social/event.js +9 -12
  143. package/lib/field/social/social_buttons_pane.js +93 -121
  144. package/lib/field/username/username_pane.js +105 -123
  145. package/lib/field/username.js +16 -26
  146. package/lib/field/vcode/vcode_pane.js +67 -93
  147. package/lib/field/vcode.js +5 -5
  148. package/lib/i18n/af.js +7 -4
  149. package/lib/i18n/ar.js +7 -4
  150. package/lib/i18n/az.js +7 -4
  151. package/lib/i18n/bg.js +7 -4
  152. package/lib/i18n/ca.js +7 -4
  153. package/lib/i18n/cs.js +7 -4
  154. package/lib/i18n/da.js +7 -4
  155. package/lib/i18n/de.js +7 -3
  156. package/lib/i18n/el.js +7 -4
  157. package/lib/i18n/en.js +9 -4
  158. package/lib/i18n/es.js +7 -3
  159. package/lib/i18n/et.js +7 -4
  160. package/lib/i18n/fa.js +7 -4
  161. package/lib/i18n/fi.js +7 -4
  162. package/lib/i18n/fr.js +7 -4
  163. package/lib/i18n/he.js +7 -4
  164. package/lib/i18n/hr.js +7 -4
  165. package/lib/i18n/hu.js +7 -4
  166. package/lib/i18n/id.js +7 -4
  167. package/lib/i18n/it.js +7 -3
  168. package/lib/i18n/ja.js +7 -4
  169. package/lib/i18n/ko.js +7 -4
  170. package/lib/i18n/lt.js +7 -4
  171. package/lib/i18n/lv.js +7 -4
  172. package/lib/i18n/ms.js +7 -4
  173. package/lib/i18n/nb.js +7 -4
  174. package/lib/i18n/nl.js +7 -4
  175. package/lib/i18n/nn.js +7 -4
  176. package/lib/i18n/no.js +7 -4
  177. package/lib/i18n/pl.js +7 -4
  178. package/lib/i18n/pt-br.js +7 -3
  179. package/lib/i18n/pt.js +7 -4
  180. package/lib/i18n/ro.js +7 -4
  181. package/lib/i18n/ru.js +7 -4
  182. package/lib/i18n/sk.js +7 -4
  183. package/lib/i18n/sl.js +7 -4
  184. package/lib/i18n/sr.js +7 -4
  185. package/lib/i18n/sv.js +7 -4
  186. package/lib/i18n/tr.js +7 -4
  187. package/lib/i18n/ua.js +7 -4
  188. package/lib/i18n/uk.js +7 -4
  189. package/lib/i18n/vi.js +7 -4
  190. package/lib/i18n/zh-tw.js +7 -4
  191. package/lib/i18n/zh.js +7 -4
  192. package/lib/i18n.js +38 -75
  193. package/lib/index.js +14 -17
  194. package/lib/lock.js +29 -32
  195. package/lib/passwordless.js +29 -31
  196. package/lib/quick-auth/actions.js +19 -26
  197. package/lib/quick_auth.js +8 -10
  198. package/lib/sanitizer.js +5 -5
  199. package/lib/store/index.js +22 -42
  200. package/lib/sync.js +21 -42
  201. package/lib/ui/box/button.js +85 -105
  202. package/lib/ui/box/chrome.js +463 -548
  203. package/lib/ui/box/confirmation_pane.js +34 -48
  204. package/lib/ui/box/container.js +305 -339
  205. package/lib/ui/box/global_message.js +51 -60
  206. package/lib/ui/box/header.js +155 -177
  207. package/lib/ui/box/multisize_slide.js +233 -229
  208. package/lib/ui/box/success_pane.js +34 -37
  209. package/lib/ui/box.js +88 -93
  210. package/lib/ui/button/auth_button.js +44 -51
  211. package/lib/ui/input/captcha_input.js +162 -181
  212. package/lib/ui/input/checkbox_input.js +57 -59
  213. package/lib/ui/input/email_input.js +117 -124
  214. package/lib/ui/input/input_wrap.js +65 -80
  215. package/lib/ui/input/location_input.js +130 -150
  216. package/lib/ui/input/mfa_code_input.js +98 -98
  217. package/lib/ui/input/password/password_strength.js +103 -127
  218. package/lib/ui/input/password_input.js +141 -147
  219. package/lib/ui/input/phone_number_input.js +101 -109
  220. package/lib/ui/input/select_input.js +120 -132
  221. package/lib/ui/input/text_input.js +89 -84
  222. package/lib/ui/input/username_input.js +109 -115
  223. package/lib/ui/input/vcode_input.js +110 -118
  224. package/lib/ui/list.js +224 -247
  225. package/lib/ui/pane/quick_auth_pane.js +55 -80
  226. package/lib/utils/atom.js +55 -48
  227. package/lib/utils/cache.js +54 -43
  228. package/lib/utils/cdn_utils.js +17 -31
  229. package/lib/utils/createRef.js +3 -1
  230. package/lib/utils/data_utils.js +10 -16
  231. package/lib/utils/fn_utils.js +5 -4
  232. package/lib/utils/format.js +6 -8
  233. package/lib/utils/id_utils.js +4 -3
  234. package/lib/utils/jsonp_utils.js +20 -17
  235. package/lib/utils/media_utils.js +4 -2
  236. package/lib/utils/preload_utils.js +4 -3
  237. package/lib/utils/string_utils.js +4 -4
  238. package/lib/utils/url_utils.js +4 -3
  239. package/opslevel.yml +6 -0
  240. package/package.json +53 -38
  241. package/webpack.config.js +36 -3
@@ -1,67 +1,53 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- exports.__esModule = true;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.humanLocation = humanLocation;
7
+ exports.humanPhoneNumberWithDiallingCode = humanPhoneNumberWithDiallingCode;
4
8
  exports.initLocation = initLocation;
5
- exports.validatePhoneNumber = validatePhoneNumber;
6
- exports.setPhoneNumber = setPhoneNumber;
7
9
  exports.phoneNumberWithDiallingCode = phoneNumberWithDiallingCode;
8
- exports.humanPhoneNumberWithDiallingCode = humanPhoneNumberWithDiallingCode;
9
- exports.humanLocation = humanLocation;
10
-
11
- var _immutable = require('immutable');
12
-
13
- var _immutable2 = _interopRequireDefault(_immutable);
14
-
15
- var _index = require('./index');
16
-
17
- var _locations = require('./phone-number/locations');
18
-
19
- var _locations2 = _interopRequireDefault(_locations);
20
-
10
+ exports.setPhoneNumber = setPhoneNumber;
11
+ exports.validatePhoneNumber = validatePhoneNumber;
12
+ var _immutable = _interopRequireDefault(require("immutable"));
13
+ var _index = require("./index");
14
+ var _locations = _interopRequireDefault(require("./phone-number/locations"));
21
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
23
- var locationOptions = _immutable2.default.fromJS(_locations2.default.map(function (x) {
16
+ var locationOptions = _immutable.default.fromJS(_locations.default.map(function (x) {
24
17
  return {
25
18
  country: x[0],
26
19
  diallingCode: x[2],
27
20
  isoCode: x[1],
28
- label: x[2] + ' ' + x[1] + ' ' + x[0],
29
- value: x[2] + ' ' + x[1]
21
+ label: "".concat(x[2], " ").concat(x[1], " ").concat(x[0]),
22
+ value: "".concat(x[2], " ").concat(x[1])
30
23
  };
31
24
  }));
32
-
33
25
  function findLocation(isoCode) {
34
26
  return locationOptions.find(function (x) {
35
27
  return x.get('isoCode') === isoCode;
36
28
  });
37
29
  }
38
-
39
30
  function initLocation(m, isoCode) {
40
31
  var location = findLocation(isoCode) || findLocation('US');
41
32
  return (0, _index.registerOptionField)(m, 'location', locationOptions, location.get('value'));
42
33
  }
43
-
44
34
  function validatePhoneNumber(str) {
45
35
  var regExp = /^[0-9]([0-9 -])*[0-9]$/;
46
36
  return regExp.test(str);
47
37
  }
48
-
49
38
  function setPhoneNumber(m, str) {
50
39
  return (0, _index.setField)(m, 'phoneNumber', str, validatePhoneNumber);
51
40
  }
52
-
53
41
  function phoneNumberWithDiallingCode(m) {
54
42
  return humanPhoneNumberWithDiallingCode(m).replace(/[\s-]+/g, '');
55
43
  }
56
-
57
44
  function humanPhoneNumberWithDiallingCode(m) {
58
45
  var location = (0, _index.getField)(m, 'location');
59
46
  var code = location.get('diallingCode', '');
60
47
  var number = (0, _index.getFieldValue)(m, 'phoneNumber', '');
61
- return code ? code + ' ' + number : number;
48
+ return code ? "".concat(code, " ").concat(number) : number;
62
49
  }
63
-
64
50
  function humanLocation(m) {
65
51
  var location = (0, _index.getField)(m, 'location');
66
- return location.get('diallingCode') + ' ' + location.get('country');
52
+ return "".concat(location.get('diallingCode'), " ").concat(location.get('country'));
67
53
  }
@@ -1,23 +1,20 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- exports.__esModule = true;
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
4
7
  exports.emitFederatedLoginEvent = emitFederatedLoginEvent;
5
-
6
- var _index = require('../../core/index');
7
-
8
- var l = _interopRequireWildcard(_index);
9
-
10
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
11
-
8
+ var l = _interopRequireWildcard(require("../../core/index"));
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ 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; }
12
11
  function emitFederatedLoginEvent(lock, provider, isSignUp) {
13
- var prov = void 0;
14
-
12
+ var prov;
15
13
  try {
16
14
  prov = provider.toJS();
17
15
  } catch (e) {
18
16
  prov = provider;
19
17
  }
20
-
21
18
  l.emitEvent(lock, 'federated login', {
22
19
  name: prov.name,
23
20
  strategy: prov.strategy,
@@ -1,136 +1,108 @@
1
- 'use strict';
2
-
3
- exports.__esModule = true;
4
-
5
- var _propTypes = require('prop-types');
6
-
7
- var _propTypes2 = _interopRequireDefault(_propTypes);
8
-
9
- var _react = require('react');
10
-
11
- var _react2 = _interopRequireDefault(_react);
12
-
13
- var _auth_button = require('../../ui/button/auth_button');
14
-
15
- var _auth_button2 = _interopRequireDefault(_auth_button);
16
-
17
- var _index = require('../../core/index');
18
-
19
- var l = _interopRequireWildcard(_index);
20
-
21
- var _actions = require('../../quick-auth/actions');
22
-
23
- var _index2 = require('../../connection/social/index');
24
-
25
- var _event = require('./event');
26
-
27
- var _index3 = require('../../connection/database/index');
28
-
29
- var _actions2 = require('../../connection/database/actions');
30
-
31
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
32
-
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _auth_button = _interopRequireDefault(require("../../ui/button/auth_button"));
11
+ var l = _interopRequireWildcard(require("../../core/index"));
12
+ var _actions = require("../../quick-auth/actions");
13
+ var _index2 = require("../../connection/social/index");
14
+ var _event = require("./event");
15
+ var _index3 = require("../../connection/database/index");
16
+ var _actions2 = require("../../connection/database/actions");
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ 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; }
33
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
-
35
20
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
-
37
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
38
-
39
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
40
-
41
- var SocialButtonsPane = function (_React$Component) {
21
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
24
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
25
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
26
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
28
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
29
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
+ var SocialButtonsPane = /*#__PURE__*/function (_React$Component) {
42
33
  _inherits(SocialButtonsPane, _React$Component);
43
-
34
+ var _super = _createSuper(SocialButtonsPane);
44
35
  function SocialButtonsPane() {
45
36
  _classCallCheck(this, SocialButtonsPane);
46
-
47
- return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
37
+ return _super.apply(this, arguments);
48
38
  }
49
-
50
- SocialButtonsPane.prototype.handleSubmit = function handleSubmit(lock, provider, isSignUp) {
51
- if (isSignUp && !(0, _index3.termsAccepted)(lock)) {
52
- return (0, _actions2.signUpError)(lock.get('id'), { code: 'social_signup_needs_terms_acception' });
39
+ _createClass(SocialButtonsPane, [{
40
+ key: "handleSubmit",
41
+ value: function handleSubmit(lock, provider, isSignUp) {
42
+ if (isSignUp && !(0, _index3.termsAccepted)(lock)) {
43
+ return (0, _actions2.signUpError)(lock.get('id'), {
44
+ code: 'social_signup_needs_terms_acception'
45
+ });
46
+ }
47
+ (0, _event.emitFederatedLoginEvent)(this.props.lock, provider, isSignUp);
48
+ return (0, _actions.logIn)(l.id(this.props.lock), provider);
53
49
  }
54
- (0, _event.emitFederatedLoginEvent)(this.props.lock, provider, isSignUp);
55
- return (0, _actions.logIn)(l.id(this.props.lock), provider);
56
- };
57
-
58
- SocialButtonsPane.prototype.render = function render() {
59
- var _this2 = this;
60
-
61
- // TODO: i don't like that it receives the instructions tanslated
62
- // but it also takes the t fn
63
- var _props = this.props,
64
- instructions = _props.instructions,
65
- labelFn = _props.labelFn,
66
- lock = _props.lock,
67
- showLoading = _props.showLoading,
68
- signUp = _props.signUp;
69
-
70
-
71
- var headerText = instructions || null;
72
- var header = headerText && _react2.default.createElement(
73
- 'p',
74
- null,
75
- headerText
76
- );
77
-
78
- var themes = (0, _index2.authButtonsTheme)(lock);
79
-
80
- var buttons = (0, _index2.socialConnections)(lock).map(function (x) {
81
- var buttonTheme = themes.get(x.get('name'));
82
- var connectionName = buttonTheme && buttonTheme.get('displayName');
83
- var primaryColor = buttonTheme && buttonTheme.get('primaryColor');
84
- var foregroundColor = buttonTheme && buttonTheme.get('foregroundColor');
85
- var icon = buttonTheme && buttonTheme.get('icon');
86
-
87
- return _react2.default.createElement(_auth_button2.default, {
88
- key: x.get('name'),
89
- label: labelFn(signUp ? 'signUpWithLabel' : 'loginWithLabel', connectionName || (0, _index2.displayName)(x)),
90
- onClick: function onClick() {
91
- return _this2.handleSubmit(lock, x, signUp);
92
- },
93
- strategy: x.get('strategy'),
94
- primaryColor: primaryColor,
95
- foregroundColor: foregroundColor,
96
- icon: icon
50
+ }, {
51
+ key: "render",
52
+ value: function render() {
53
+ var _this = this;
54
+ // TODO: i don't like that it receives the instructions tanslated
55
+ // but it also takes the t fn
56
+ var _this$props = this.props,
57
+ instructions = _this$props.instructions,
58
+ labelFn = _this$props.labelFn,
59
+ lock = _this$props.lock,
60
+ showLoading = _this$props.showLoading,
61
+ signUp = _this$props.signUp;
62
+ var headerText = instructions || null;
63
+ var header = headerText && /*#__PURE__*/_react.default.createElement("p", null, headerText);
64
+ var themes = (0, _index2.authButtonsTheme)(lock);
65
+ var buttons = (0, _index2.socialConnections)(lock).map(function (x) {
66
+ var buttonTheme = themes.get(x.get('name'));
67
+ var connectionName = buttonTheme && buttonTheme.get('displayName');
68
+ var primaryColor = buttonTheme && buttonTheme.get('primaryColor');
69
+ var foregroundColor = buttonTheme && buttonTheme.get('foregroundColor');
70
+ var icon = buttonTheme && buttonTheme.get('icon');
71
+ return /*#__PURE__*/_react.default.createElement(_auth_button.default, {
72
+ key: x.get('name'),
73
+ label: labelFn(signUp ? 'signUpWithLabel' : 'loginWithLabel', connectionName || (0, _index2.displayName)(x)),
74
+ onClick: function onClick() {
75
+ return _this.handleSubmit(lock, x, signUp);
76
+ },
77
+ strategy: x.get('strategy'),
78
+ primaryColor: primaryColor,
79
+ foregroundColor: foregroundColor,
80
+ icon: icon
81
+ });
97
82
  });
98
- });
99
-
100
- var loading = showLoading && _react2.default.createElement(
101
- 'div',
102
- { className: 'auth0-loading-container' },
103
- _react2.default.createElement('div', { className: 'auth0-loading' })
104
- );
105
-
106
- return _react2.default.createElement(
107
- 'div',
108
- { className: 'auth-lock-social-buttons-pane' },
109
- header,
110
- _react2.default.createElement(
111
- 'div',
112
- { className: 'auth0-lock-social-buttons-container' },
113
- buttons
114
- ),
115
- loading
116
- );
117
- };
118
-
83
+ var loading = showLoading && /*#__PURE__*/_react.default.createElement("div", {
84
+ className: "auth0-loading-container"
85
+ }, /*#__PURE__*/_react.default.createElement("div", {
86
+ className: "auth0-loading"
87
+ }));
88
+ return /*#__PURE__*/_react.default.createElement("div", {
89
+ className: "auth-lock-social-buttons-pane"
90
+ }, header, /*#__PURE__*/_react.default.createElement("div", {
91
+ className: "auth0-lock-social-buttons-container"
92
+ }, buttons), loading);
93
+ }
94
+ }]);
119
95
  return SocialButtonsPane;
120
- }(_react2.default.Component);
121
-
96
+ }(_react.default.Component);
122
97
  exports.default = SocialButtonsPane;
123
-
124
-
125
98
  SocialButtonsPane.propTypes = {
126
- instructions: _propTypes2.default.any,
127
- labelFn: _propTypes2.default.func.isRequired,
128
- lock: _propTypes2.default.object.isRequired,
129
- showLoading: _propTypes2.default.bool.isRequired,
130
- signUp: _propTypes2.default.bool.isRequired,
131
- e: _propTypes2.default.bool
99
+ instructions: _propTypes.default.any,
100
+ labelFn: _propTypes.default.func.isRequired,
101
+ lock: _propTypes.default.object.isRequired,
102
+ showLoading: _propTypes.default.bool.isRequired,
103
+ signUp: _propTypes.default.bool.isRequired,
104
+ e: _propTypes.default.bool
132
105
  };
133
-
134
106
  SocialButtonsPane.defaultProps = {
135
107
  showLoading: false,
136
108
  e: false
@@ -1,138 +1,120 @@
1
- 'use strict';
2
-
3
- exports.__esModule = true;
4
-
5
- var _propTypes = require('prop-types');
6
-
7
- var _propTypes2 = _interopRequireDefault(_propTypes);
8
-
9
- var _react = require('react');
10
-
11
- var _react2 = _interopRequireDefault(_react);
12
-
13
- var _username_input = require('../../ui/input/username_input');
14
-
15
- var _username_input2 = _interopRequireDefault(_username_input);
16
-
17
- var _index = require('../index');
18
-
19
- var c = _interopRequireWildcard(_index);
20
-
21
- var _index2 = require('../../store/index');
22
-
23
- var _index3 = require('../../core/index');
24
-
25
- var l = _interopRequireWildcard(_index3);
26
-
27
- var _username = require('../username');
28
-
29
- var _avatar = require('../../avatar');
30
-
31
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
32
-
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _username_input = _interopRequireDefault(require("../../ui/input/username_input"));
11
+ var c = _interopRequireWildcard(require("../index"));
12
+ var _index2 = require("../../store/index");
13
+ var l = _interopRequireWildcard(require("../../core/index"));
14
+ var _username = require("../username");
15
+ var _avatar = require("../../avatar");
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ 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; }
33
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
-
35
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
-
37
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
38
-
39
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
40
-
41
- var UsernamePane = function (_React$Component) {
20
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
21
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
25
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
27
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
28
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
+ var UsernamePane = /*#__PURE__*/function (_React$Component) {
42
32
  _inherits(UsernamePane, _React$Component);
43
-
33
+ var _super = _createSuper(UsernamePane);
44
34
  function UsernamePane() {
45
35
  _classCallCheck(this, UsernamePane);
46
-
47
- return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
36
+ return _super.apply(this, arguments);
48
37
  }
49
-
50
- UsernamePane.prototype.componentDidMount = function componentDidMount(e) {
51
- var _props = this.props,
52
- lock = _props.lock,
53
- validateFormat = _props.validateFormat,
54
- usernameStyle = _props.usernameStyle,
55
- strictValidation = _props.strictValidation;
56
-
57
- if (l.ui.avatar(lock) && c.username(lock)) {
58
- (0, _avatar.requestAvatar)(l.id(lock), c.username(lock));
59
- }
60
- (0, _index2.swap)(_index2.updateEntity, 'lock', l.id(lock), _username.setUsername, c.username(lock), usernameStyle, validateFormat, strictValidation);
61
- };
62
-
63
- UsernamePane.prototype.handleChange = function handleChange(e) {
64
- var _props2 = this.props,
65
- lock = _props2.lock,
66
- validateFormat = _props2.validateFormat,
67
- usernameStyle = _props2.usernameStyle,
68
- strictValidation = _props2.strictValidation;
69
-
70
- if (l.ui.avatar(lock)) {
71
- (0, _avatar.debouncedRequestAvatar)(l.id(lock), e.target.value);
72
- }
73
- (0, _index2.swap)(_index2.updateEntity, 'lock', l.id(lock), _username.setUsername, e.target.value, usernameStyle, validateFormat, strictValidation);
74
- };
75
-
76
- UsernamePane.prototype.render = function render() {
77
- var _props3 = this.props,
78
- i18n = _props3.i18n,
79
- lock = _props3.lock,
80
- placeholder = _props3.placeholder,
81
- validateFormat = _props3.validateFormat;
82
-
83
- var allowAutocomplete = l.ui.allowAutocomplete(lock);
84
- var value = c.getFieldValue(lock, 'username');
85
- var usernameValidation = validateFormat ? (0, _username.getUsernameValidation)(lock) : {};
86
-
87
- // TODO: invalidErrorHint and blankErrorHint are deprecated.
88
- // They are kept for backwards compatibiliy in the code for the customers overwriting
89
- // them with languageDictionary. They can be removed in the next major release.
90
- var invalidHintKey = function invalidHintKey(str) {
91
- if (!str) {
92
- return i18n.str('blankErrorHint') ? 'blankErrorHint' : 'blankUsernameErrorHint';
38
+ _createClass(UsernamePane, [{
39
+ key: "componentDidMount",
40
+ value: function componentDidMount(e) {
41
+ var _this$props = this.props,
42
+ lock = _this$props.lock,
43
+ validateFormat = _this$props.validateFormat,
44
+ usernameStyle = _this$props.usernameStyle,
45
+ strictValidation = _this$props.strictValidation;
46
+ if (l.ui.avatar(lock) && c.username(lock)) {
47
+ (0, _avatar.requestAvatar)(l.id(lock), c.username(lock));
93
48
  }
94
- if ((0, _username.usernameLooksLikeEmail)(str) || !validateFormat) return i18n.str('invalidErrorHint') ? 'invalidErrorHint' : 'invalidUsernameErrorHint';
95
- return 'usernameFormatErrorHint';
96
- };
97
-
98
- var invalidHint = function invalidHint(str) {
99
- var hintKey = invalidHintKey(str);
100
-
101
- // only show format info in the error if it should validate the format and
102
- // if there is any format restrictions for the connection
103
- if ('usernameFormatErrorHint' === hintKey && validateFormat && usernameValidation != null) {
104
- return i18n.str(hintKey, usernameValidation.min, usernameValidation.max);
49
+ (0, _index2.swap)(_index2.updateEntity, 'lock', l.id(lock), _username.setUsername, c.username(lock), usernameStyle, validateFormat, strictValidation);
50
+ }
51
+ }, {
52
+ key: "handleChange",
53
+ value: function handleChange(e) {
54
+ var _this$props2 = this.props,
55
+ lock = _this$props2.lock,
56
+ validateFormat = _this$props2.validateFormat,
57
+ usernameStyle = _this$props2.usernameStyle,
58
+ strictValidation = _this$props2.strictValidation;
59
+ if (l.ui.avatar(lock)) {
60
+ (0, _avatar.debouncedRequestAvatar)(l.id(lock), e.target.value);
105
61
  }
106
-
107
- return i18n.str(hintKey);
108
- };
109
-
110
- return _react2.default.createElement(_username_input2.default, {
111
- value: value,
112
- invalidHint: invalidHint(value),
113
- isValid: !c.isFieldVisiblyInvalid(lock, 'username'),
114
- onChange: this.handleChange.bind(this),
115
- placeholder: placeholder,
116
- autoComplete: allowAutocomplete,
117
- disabled: l.submitting(lock)
118
- });
119
- };
120
-
62
+ (0, _index2.swap)(_index2.updateEntity, 'lock', l.id(lock), _username.setUsername, e.target.value, usernameStyle, validateFormat, strictValidation);
63
+ }
64
+ }, {
65
+ key: "render",
66
+ value: function render() {
67
+ var _this$props3 = this.props,
68
+ i18n = _this$props3.i18n,
69
+ lock = _this$props3.lock,
70
+ placeholder = _this$props3.placeholder,
71
+ validateFormat = _this$props3.validateFormat;
72
+ var allowAutocomplete = l.ui.allowAutocomplete(lock);
73
+ var value = c.getFieldValue(lock, 'username');
74
+ var usernameValidation = validateFormat ? (0, _username.getUsernameValidation)(lock) : {};
75
+
76
+ // TODO: invalidErrorHint and blankErrorHint are deprecated.
77
+ // They are kept for backwards compatibility in the code for the customers overwriting
78
+ // them with languageDictionary. They can be removed in the next major release.
79
+ var invalidHintKey = function invalidHintKey(str) {
80
+ if (!str) {
81
+ return i18n.str('blankErrorHint') ? 'blankErrorHint' : 'blankUsernameErrorHint';
82
+ }
83
+ if ((0, _username.usernameLooksLikeEmail)(str) || !validateFormat) return i18n.str('invalidErrorHint') ? 'invalidErrorHint' : 'invalidUsernameErrorHint';
84
+ return 'usernameFormatErrorHint';
85
+ };
86
+ var invalidHint = function invalidHint(str) {
87
+ var hintKey = invalidHintKey(str);
88
+
89
+ // only show format info in the error if it should validate the format and
90
+ // if there is any format restrictions for the connection
91
+ if ('usernameFormatErrorHint' === hintKey && validateFormat && usernameValidation != null) {
92
+ return i18n.str(hintKey, usernameValidation.min, usernameValidation.max);
93
+ }
94
+ return i18n.str(hintKey);
95
+ };
96
+ return /*#__PURE__*/_react.default.createElement(_username_input.default, {
97
+ value: value,
98
+ invalidHint: invalidHint(value),
99
+ isValid: !c.isFieldVisiblyInvalid(lock, 'username'),
100
+ onChange: this.handleChange.bind(this),
101
+ placeholder: placeholder,
102
+ autoComplete: allowAutocomplete,
103
+ disabled: l.submitting(lock)
104
+ });
105
+ }
106
+ }]);
121
107
  return UsernamePane;
122
- }(_react2.default.Component);
123
-
108
+ }(_react.default.Component);
124
109
  exports.default = UsernamePane;
125
-
126
-
127
110
  UsernamePane.propTypes = {
128
- i18n: _propTypes2.default.object.isRequired,
129
- lock: _propTypes2.default.object.isRequired,
130
- placeholder: _propTypes2.default.string.isRequired,
131
- validateFormat: _propTypes2.default.bool.isRequired,
132
- usernameStyle: _propTypes2.default.oneOf(['any', 'email', 'username']),
133
- strictValidation: _propTypes2.default.bool.isRequired
111
+ i18n: _propTypes.default.object.isRequired,
112
+ lock: _propTypes.default.object.isRequired,
113
+ placeholder: _propTypes.default.string.isRequired,
114
+ validateFormat: _propTypes.default.bool.isRequired,
115
+ usernameStyle: _propTypes.default.oneOf(['any', 'email', 'username']),
116
+ strictValidation: _propTypes.default.bool.isRequired
134
117
  };
135
-
136
118
  UsernamePane.defaultProps = {
137
119
  validateFormat: false,
138
120
  usernameStyle: 'username'