@popmenu/common-ui 0.97.1 → 0.99.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.
- package/build/components/FollowerAuthenticationDialog/FollowerAuthenticationDialogProps.d.ts +5 -1
- package/build/components/SplitInput/SplitInputProps.d.ts +2 -0
- package/build/index.es.js +45 -9
- package/build/index.es.js.map +1 -1
- package/build/index.js +45 -9
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -988,11 +988,11 @@ var useSplitInputStyles = styles.makeStyles(function () { return ({
|
|
|
988
988
|
}); });
|
|
989
989
|
|
|
990
990
|
var SplitInput = function (props) {
|
|
991
|
-
var TextFieldProps = props.TextFieldProps, ButtonProps = props.ButtonProps, color = props.color, onChange = props.onChange, onClick = props.onClick;
|
|
991
|
+
var buttonLabel = props.buttonLabel, TextFieldProps = props.TextFieldProps, ButtonProps = props.ButtonProps, color = props.color, onChange = props.onChange, onClick = props.onClick;
|
|
992
992
|
var classes = useSplitInputStyles(props);
|
|
993
993
|
return (React__default['default'].createElement(core.Box, { display: "flex" },
|
|
994
994
|
React__default['default'].createElement(TextField__default['default'], __assign({ classes: { root: classes.textfield }, InputProps: { classes: { root: classes.input, focused: classes.focused } }, color: color, variant: "outlined", onChange: onChange }, TextFieldProps)),
|
|
995
|
-
React__default['default'].createElement(Button, __assign({ classes: { root: classes.button }, disableElevation: true, color: color, variant: "contained", onClick: onClick }, ButtonProps),
|
|
995
|
+
React__default['default'].createElement(Button, __assign({ classes: { root: classes.button }, disableElevation: true, color: color, variant: "contained", onClick: onClick }, ButtonProps), buttonLabel)));
|
|
996
996
|
};
|
|
997
997
|
SplitInput.displayName = 'SplitInput';
|
|
998
998
|
SplitInput.defaultProps = {
|
|
@@ -1172,6 +1172,35 @@ var useStyles$2 = core.makeStyles(function () { return ({
|
|
|
1172
1172
|
var FollowerAuthenticationForm = function () {
|
|
1173
1173
|
var _a = useFollowerAuthenticationDialogContext(), state = _a.state, messages = _a.messages, locationOptions = _a.locationOptions, dispatch = _a.dispatch, loading = _a.loading;
|
|
1174
1174
|
var classes = useStyles$2();
|
|
1175
|
+
// sign-up form state
|
|
1176
|
+
var formRef = React.useRef(null);
|
|
1177
|
+
var _b = React.useState(false), formValidity = _b[0], setFormValidity = _b[1];
|
|
1178
|
+
var _c = React.useState(), showPhoneErrorText = _c[0], setShowPhoneErrorText = _c[1];
|
|
1179
|
+
var _d = React.useState(), showEmailErrorText = _d[0], setShowEmailErrorText = _d[1];
|
|
1180
|
+
var _e = React.useState(), showLocationErrorText = _e[0], setShowLocationErrorText = _e[1];
|
|
1181
|
+
var _f = React.useState(state.defaultFormValues.phone || ''), signUpPhoneValue = _f[0], setSignUpPhoneValue = _f[1];
|
|
1182
|
+
var _g = React.useState(state.defaultFormValues.email || ''), signUpEmailValue = _g[0], setSignUpEmailValue = _g[1];
|
|
1183
|
+
var checkFieldValidity = function (e) {
|
|
1184
|
+
var _a, _b;
|
|
1185
|
+
var fieldName = e.target.name;
|
|
1186
|
+
var fieldValidity = (_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.elements.namedItem(fieldName)) === null || _b === void 0 ? void 0 : _b.validity.valid;
|
|
1187
|
+
switch (fieldName) {
|
|
1188
|
+
case 'phone':
|
|
1189
|
+
setSignUpPhoneValue(e.target.value);
|
|
1190
|
+
setShowPhoneErrorText(!fieldValidity);
|
|
1191
|
+
break;
|
|
1192
|
+
case 'email':
|
|
1193
|
+
setSignUpEmailValue(e.target.value);
|
|
1194
|
+
setShowEmailErrorText(!fieldValidity);
|
|
1195
|
+
break;
|
|
1196
|
+
case 'location':
|
|
1197
|
+
setShowLocationErrorText(!e.target.value);
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
React.useEffect(function () {
|
|
1202
|
+
setFormValidity(['phone', 'email', 'location'].every(function (fieldName) { var _a, _b; return (_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.elements.namedItem(fieldName)) === null || _b === void 0 ? void 0 : _b.validity.valid; }));
|
|
1203
|
+
}, [showPhoneErrorText, showEmailErrorText, showLocationErrorText, signUpPhoneValue, signUpEmailValue]);
|
|
1175
1204
|
var handleSubmit = function (e) {
|
|
1176
1205
|
e.preventDefault();
|
|
1177
1206
|
var form = e.target;
|
|
@@ -1190,15 +1219,23 @@ var FollowerAuthenticationForm = function () {
|
|
|
1190
1219
|
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.initialInputLabel, key: "identifier-input", id: "identifier-input", name: "identifier" }),
|
|
1191
1220
|
React__default['default'].createElement(core.Button, { disabled: loading, type: "submit" }, messages.initialCtaButtonLabel)));
|
|
1192
1221
|
case 'signUp':
|
|
1193
|
-
return (React__default['default'].createElement("form", __assign({}, formProps)
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.
|
|
1197
|
-
|
|
1222
|
+
return (React__default['default'].createElement("form", __assign({ ref: formRef }, formProps, { onInvalid: function (e) {
|
|
1223
|
+
e.preventDefault();
|
|
1224
|
+
} }),
|
|
1225
|
+
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.signUpPhoneInputLabel, key: "phone-input", id: "phone-input", name: "phone", onChange: checkFieldValidity, error: showPhoneErrorText, helperText: showPhoneErrorText && messages.signUpPhoneErrorText, inputProps: {
|
|
1226
|
+
pattern: '^[0-9]{10}$',
|
|
1227
|
+
required: signUpEmailValue ? false : true,
|
|
1228
|
+
} }),
|
|
1229
|
+
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.signUpNameInputLabel, key: "name-input", id: "name-input", name: "name", inputProps: { required: true } }),
|
|
1230
|
+
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.signUpEmailInputLabel, key: "email-input", id: "email-input", name: "email", error: showEmailErrorText, helperText: showEmailErrorText && messages.signUpEmailErrorText, onChange: checkFieldValidity, inputProps: {
|
|
1231
|
+
required: signUpPhoneValue ? false : true,
|
|
1232
|
+
type: 'email',
|
|
1233
|
+
} }),
|
|
1234
|
+
React__default['default'].createElement(core.TextField, { disabled: loading, select: true, onChange: checkFieldValidity, label: messages.signUpLocationInputLabel, error: showLocationErrorText, helperText: showLocationErrorText && messages.signUpLocationErrorText, key: "location-input", id: "location-input", inputProps: { required: true }, name: "location" }, locationOptions.map(function (locationOption) { return (React__default['default'].createElement(core.MenuItem, { key: locationOption.value, value: locationOption.value }, locationOption.label)); })),
|
|
1198
1235
|
React__default['default'].createElement(core.Typography, { style: { alignSelf: 'start' } }, messages.signUpBirthdaySectionLabel),
|
|
1199
1236
|
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.signUpMonthInputLabel, key: "birthday-month-input", id: "birthday-month-input", name: "birthdayMonth" }),
|
|
1200
1237
|
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.signUpDayInputLabel, key: "birthday-date-input", id: "birthday-date-input", name: "birthdayDate" }),
|
|
1201
|
-
React__default['default'].createElement(core.Button, { disabled: loading, type: "submit" }, messages.signUp)));
|
|
1238
|
+
React__default['default'].createElement(core.Button, { disabled: loading || !formValidity, type: "submit" }, messages.signUp)));
|
|
1202
1239
|
case 'emailFound':
|
|
1203
1240
|
return (React__default['default'].createElement("form", __assign({}, formProps),
|
|
1204
1241
|
React__default['default'].createElement(core.TextField, { disabled: loading, label: messages.emailFoundInputLabel, key: "email-input", id: "email-input", name: "email", value: state.defaultFormValues.email }),
|
|
@@ -1312,7 +1349,6 @@ var FollowerAuthenticationBody = function () {
|
|
|
1312
1349
|
|
|
1313
1350
|
var FollowerAuthenticationFooter = function () {
|
|
1314
1351
|
var _a = useFollowerAuthenticationDialogContext(), messages = _a.messages, logos = _a.logos;
|
|
1315
|
-
console.log(logos.popmenu);
|
|
1316
1352
|
return (React__default['default'].createElement(core.Box, { display: "flex", gridGap: 8 },
|
|
1317
1353
|
React__default['default'].createElement(core.Typography, { variant: "body2" }, messages.poweredBy),
|
|
1318
1354
|
logos.popmenu));
|