powr-sdk-web 6.17.0 → 6.17.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.
- package/dist/auth/index.js +30 -2
- package/dist/components/PhoneInput.js +68 -30
- package/dist/utils/phone.js +0 -8
- package/package.json +1 -1
package/dist/auth/index.js
CHANGED
|
@@ -53,6 +53,8 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
53
53
|
forgotPasswordChannel = _ref$forgotPasswordCh === void 0 ? null : _ref$forgotPasswordCh,
|
|
54
54
|
_ref$otpApp = _ref.otpApp,
|
|
55
55
|
otpApp = _ref$otpApp === void 0 ? null : _ref$otpApp,
|
|
56
|
+
_ref$powrAccountUrl = _ref.powrAccountUrl,
|
|
57
|
+
powrAccountUrl = _ref$powrAccountUrl === void 0 ? 'https://lawazia.tech/#identity' : _ref$powrAccountUrl,
|
|
56
58
|
_ref$otpReset = _ref.otpReset,
|
|
57
59
|
otpReset = _ref$otpReset === void 0 ? false : _ref$otpReset,
|
|
58
60
|
_ref$completeProfileO = _ref.completeProfileOnLogin,
|
|
@@ -1147,7 +1149,32 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
1147
1149
|
style: styles.subtitleContainer
|
|
1148
1150
|
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
1149
1151
|
style: styles.subtitle
|
|
1150
|
-
},
|
|
1152
|
+
}, isLogin ? 'Sign in to your ' : 'Create your ', powrAccountUrl ? /*#__PURE__*/_react["default"].createElement("a", {
|
|
1153
|
+
href: powrAccountUrl,
|
|
1154
|
+
target: "_blank",
|
|
1155
|
+
rel: "noopener noreferrer",
|
|
1156
|
+
style: styles.powrAccountText,
|
|
1157
|
+
onMouseEnter: function onMouseEnter() {
|
|
1158
|
+
return setShowTooltip(true);
|
|
1159
|
+
},
|
|
1160
|
+
onMouseLeave: function onMouseLeave() {
|
|
1161
|
+
return setShowTooltip(false);
|
|
1162
|
+
}
|
|
1163
|
+
}, "PowrAccount") : /*#__PURE__*/_react["default"].createElement("span", {
|
|
1164
|
+
style: styles.powrAccountText,
|
|
1165
|
+
onMouseEnter: function onMouseEnter() {
|
|
1166
|
+
return setShowTooltip(true);
|
|
1167
|
+
},
|
|
1168
|
+
onMouseLeave: function onMouseLeave() {
|
|
1169
|
+
return setShowTooltip(false);
|
|
1170
|
+
}
|
|
1171
|
+
}, "PowrAccount")), isLogin ? /*#__PURE__*/_react["default"].createElement("p", {
|
|
1172
|
+
style: _objectSpread(_objectSpread({}, styles.subtitle), {}, {
|
|
1173
|
+
marginTop: 6,
|
|
1174
|
+
fontSize: 14,
|
|
1175
|
+
fontWeight: 400
|
|
1176
|
+
})
|
|
1177
|
+
}, loginGate === 'password' ? 'Enter your password.' : smsResetStep === 'otp' ? 'Enter the code we sent.' : loginGate === 'help' ? 'WhatsApp us to get in.' : smsResetStep === 'password' ? 'Set a password for next time.' : 'Enter your mobile number.') : null, showTooltip && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1151
1178
|
style: styles.tooltip
|
|
1152
1179
|
}, "Secure authentication powered by Lawazia Tech"))), authView === 'add-name' && pendingAuth ? /*#__PURE__*/_react["default"].createElement(_profileNameStep.profileNameStep.Component, {
|
|
1153
1180
|
ctx: {
|
|
@@ -1876,7 +1903,8 @@ var styles = {
|
|
|
1876
1903
|
powrAccountText: {
|
|
1877
1904
|
color: '#ff6b35',
|
|
1878
1905
|
fontWeight: '600',
|
|
1879
|
-
cursor: '
|
|
1906
|
+
cursor: 'pointer',
|
|
1907
|
+
textDecoration: 'none'
|
|
1880
1908
|
},
|
|
1881
1909
|
tooltip: {
|
|
1882
1910
|
position: 'absolute',
|
|
@@ -61,6 +61,7 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
61
61
|
countryQuery = _useState8[0],
|
|
62
62
|
setCountryQuery = _useState8[1];
|
|
63
63
|
var countryBoxRef = (0, _react.useRef)(null);
|
|
64
|
+
var numberRef = (0, _react.useRef)(null);
|
|
64
65
|
var countryOptions = (0, _react.useMemo)(function () {
|
|
65
66
|
return (0, _phone.getCountryOptions)(allowedCountries);
|
|
66
67
|
}, [allowedCountries]);
|
|
@@ -105,6 +106,15 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
105
106
|
setCountryQuery('');
|
|
106
107
|
if (typeof onCountryChange === 'function') onCountryChange(nextCountry);
|
|
107
108
|
emitChange(nextCountry, localNumber);
|
|
109
|
+
if (numberRef.current) numberRef.current.focus();
|
|
110
|
+
};
|
|
111
|
+
var applyIngested = function applyIngested(ingested) {
|
|
112
|
+
setCountry(ingested.country);
|
|
113
|
+
setLocalNumber(ingested.localNumber);
|
|
114
|
+
if (ingested.country !== country && typeof onCountryChange === 'function') {
|
|
115
|
+
onCountryChange(ingested.country);
|
|
116
|
+
}
|
|
117
|
+
emitChange(ingested.country, ingested.localNumber);
|
|
108
118
|
};
|
|
109
119
|
var emitChange = function emitChange(nextCountry, nextLocal) {
|
|
110
120
|
var e164 = (0, _phone.buildPhoneFromParts)(nextLocal, nextCountry);
|
|
@@ -120,29 +130,45 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
120
130
|
}
|
|
121
131
|
};
|
|
122
132
|
var handleLocalChange = function handleLocalChange(e) {
|
|
123
|
-
|
|
124
|
-
setCountry(ingested.country);
|
|
125
|
-
setLocalNumber(ingested.localNumber);
|
|
126
|
-
if (ingested.country !== country && typeof onCountryChange === 'function') {
|
|
127
|
-
onCountryChange(ingested.country);
|
|
128
|
-
}
|
|
129
|
-
emitChange(ingested.country, ingested.localNumber);
|
|
133
|
+
applyIngested((0, _phone.ingestPhoneInput)(e.target.value || '', country));
|
|
130
134
|
};
|
|
131
135
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
132
136
|
style: _objectSpread(_objectSpread({}, styles.row), rowStyle)
|
|
133
137
|
}, international ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
134
138
|
ref: countryBoxRef,
|
|
135
139
|
style: styles.countryBox
|
|
136
|
-
}, /*#__PURE__*/_react["default"].createElement("
|
|
137
|
-
type: "
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
141
|
+
type: "button",
|
|
142
|
+
disabled: disabled,
|
|
143
|
+
"aria-label": "Country code",
|
|
144
|
+
"aria-expanded": countryOpen,
|
|
145
|
+
onClick: function onClick() {
|
|
146
|
+
setCountryOpen(function (open) {
|
|
147
|
+
return !open;
|
|
148
|
+
});
|
|
141
149
|
setCountryQuery('');
|
|
142
150
|
},
|
|
151
|
+
style: _objectSpread(_objectSpread({}, styles.select), selectStyle)
|
|
152
|
+
}, countryLabel), countryOpen ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
153
|
+
style: styles.menu
|
|
154
|
+
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
155
|
+
type: "text",
|
|
156
|
+
value: countryQuery,
|
|
157
|
+
autoFocus: true,
|
|
158
|
+
placeholder: "IN or 91",
|
|
159
|
+
autoComplete: "off",
|
|
160
|
+
"aria-label": "Search country",
|
|
143
161
|
onChange: function onChange(e) {
|
|
144
|
-
|
|
145
|
-
|
|
162
|
+
var next = e.target.value;
|
|
163
|
+
var digits = next.replace(/\D/g, '');
|
|
164
|
+
if (digits.length >= 6) {
|
|
165
|
+
applyIngested((0, _phone.ingestPhoneInput)(next, country));
|
|
166
|
+
setCountryOpen(false);
|
|
167
|
+
setCountryQuery('');
|
|
168
|
+
if (numberRef.current) numberRef.current.focus();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
setCountryQuery(next);
|
|
146
172
|
},
|
|
147
173
|
onKeyDown: function onKeyDown(e) {
|
|
148
174
|
if (e.key === 'Enter' && filteredCountries[0]) {
|
|
@@ -154,14 +180,9 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
154
180
|
setCountryQuery('');
|
|
155
181
|
}
|
|
156
182
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"aria-label": "Country code",
|
|
161
|
-
"aria-expanded": countryOpen,
|
|
162
|
-
style: _objectSpread(_objectSpread({}, styles.select), selectStyle)
|
|
163
|
-
}), countryOpen ? /*#__PURE__*/_react["default"].createElement("ul", {
|
|
164
|
-
style: styles.menu,
|
|
183
|
+
style: styles.menuSearch
|
|
184
|
+
}), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
185
|
+
style: styles.menuList,
|
|
165
186
|
role: "listbox"
|
|
166
187
|
}, filteredCountries.length === 0 ? /*#__PURE__*/_react["default"].createElement("li", {
|
|
167
188
|
style: styles.menuEmpty
|
|
@@ -179,16 +200,18 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
179
200
|
},
|
|
180
201
|
style: _objectSpread(_objectSpread({}, styles.menuItem), opt.code === country ? styles.menuItemActive : {})
|
|
181
202
|
}, opt.label));
|
|
182
|
-
})) : null) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
203
|
+
}))) : null) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
183
204
|
style: styles.prefix
|
|
184
205
|
}, "+", callingCode), /*#__PURE__*/_react["default"].createElement("input", {
|
|
206
|
+
ref: numberRef,
|
|
185
207
|
type: "tel",
|
|
186
208
|
value: localNumber,
|
|
187
209
|
onChange: handleLocalChange,
|
|
188
210
|
placeholder: placeholder,
|
|
189
211
|
disabled: disabled,
|
|
190
212
|
style: _objectSpread(_objectSpread({}, styles.input), inputStyle),
|
|
191
|
-
autoComplete: "tel-national"
|
|
213
|
+
autoComplete: "tel-national",
|
|
214
|
+
autoFocus: true
|
|
192
215
|
}));
|
|
193
216
|
};
|
|
194
217
|
var styles = {
|
|
@@ -221,26 +244,41 @@ var styles = {
|
|
|
221
244
|
border: '2px solid #e5e7eb',
|
|
222
245
|
borderRadius: 8,
|
|
223
246
|
fontSize: 13,
|
|
247
|
+
fontWeight: 700,
|
|
224
248
|
background: '#fff',
|
|
225
249
|
boxSizing: 'border-box',
|
|
226
|
-
height: 48
|
|
250
|
+
height: 48,
|
|
251
|
+
cursor: 'pointer'
|
|
227
252
|
},
|
|
228
253
|
menu: {
|
|
229
254
|
position: 'absolute',
|
|
230
255
|
zIndex: 20,
|
|
231
256
|
left: 0,
|
|
232
|
-
|
|
257
|
+
minWidth: 220,
|
|
233
258
|
top: '100%',
|
|
234
259
|
margin: 0,
|
|
235
|
-
padding:
|
|
236
|
-
listStyle: 'none',
|
|
237
|
-
maxHeight: 220,
|
|
238
|
-
overflowY: 'auto',
|
|
260
|
+
padding: 8,
|
|
239
261
|
background: '#fff',
|
|
240
262
|
border: '1px solid #e5e7eb',
|
|
241
263
|
borderRadius: 8,
|
|
242
264
|
boxShadow: '0 8px 24px rgba(0,0,0,0.12)'
|
|
243
265
|
},
|
|
266
|
+
menuSearch: {
|
|
267
|
+
width: '100%',
|
|
268
|
+
boxSizing: 'border-box',
|
|
269
|
+
padding: '8px 10px',
|
|
270
|
+
marginBottom: 6,
|
|
271
|
+
border: '1px solid #e5e7eb',
|
|
272
|
+
borderRadius: 6,
|
|
273
|
+
fontSize: 14
|
|
274
|
+
},
|
|
275
|
+
menuList: {
|
|
276
|
+
margin: 0,
|
|
277
|
+
padding: 0,
|
|
278
|
+
listStyle: 'none',
|
|
279
|
+
maxHeight: 200,
|
|
280
|
+
overflowY: 'auto'
|
|
281
|
+
},
|
|
244
282
|
menuItem: {
|
|
245
283
|
display: 'block',
|
|
246
284
|
width: '100%',
|
package/dist/utils/phone.js
CHANGED
|
@@ -188,14 +188,6 @@ function ingestPhoneInput(raw) {
|
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
var parsed = parsePhone(trimmed, currentCountry) || parsePhone(digits, currentCountry);
|
|
192
|
-
if (parsed !== null && parsed !== void 0 && parsed.nationalNumber) {
|
|
193
|
-
var nextCountry = parsed.country || currentCountry;
|
|
194
|
-
return {
|
|
195
|
-
country: nextCountry,
|
|
196
|
-
localNumber: capNationalDigits(String(parsed.nationalNumber), nextCountry)
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
191
|
var local = digits;
|
|
200
192
|
try {
|
|
201
193
|
var calling = String((0, _libphonenumberJs.getCountryCallingCode)(currentCountry));
|