@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.
@@ -54,8 +54,12 @@ export declare type ReducerEvent = {
54
54
  type: 'sign-in-success';
55
55
  } | {
56
56
  type: 'code-sent';
57
+ } | {
58
+ type: 'start-google-auth';
59
+ } | {
60
+ type: 'start-facebook-auth';
57
61
  };
58
- declare type MessageKey = `${ReducerStateValue}Title` | `${ReducerStateValue}Info` | `${ReducerStateValue}GraphicAlt` | 'indirectUserFoundLabel' | 'indirectUserFoundCtaButtonLabel' | 'indirectUserFoundCtaButtonLabelAlt' | 'signUpPhoneInputLabel' | 'signUpNameInputLabel' | 'signUpEmailInputLabel' | 'signUpLocationInputLabel' | 'signUpBirthdaySectionLabel' | 'signUpMonthInputLabel' | 'signUpDayInputLabel' | 'signUp' | 'signUpFinePrint' | 'emailFoundInputLabel' | 'emailFoundCtaButtonLabel' | 'phoneFoundInputLabel' | 'phoneFoundCtaButtonLabel' | 'emailAuthCodeInputLabel' | 'phoneAuthCodeInputLabel' | 'or' | 'popmenuLogoAlt' | 'continueWithFacebookButtonLabel' | 'continueWithGoogleButtonLabel' | 'initialCtaButtonLabel' | 'initialInputLabel' | 'passwordInputLabel' | 'poweredBy' | 'done' | 'signIn' | 'signInWithPassword';
62
+ declare type MessageKey = `${ReducerStateValue}Title` | `${ReducerStateValue}Info` | `${ReducerStateValue}GraphicAlt` | 'indirectUserFoundLabel' | 'indirectUserFoundCtaButtonLabel' | 'indirectUserFoundCtaButtonLabelAlt' | 'signUpPhoneErrorText' | 'signUpPhoneInputLabel' | 'signUpNameInputLabel' | 'signUpEmailErrorText' | 'signUpEmailInputLabel' | 'signUpLocationErrorText' | 'signUpLocationInputLabel' | 'signUpBirthdaySectionLabel' | 'signUpMonthInputLabel' | 'signUpDayInputLabel' | 'signUp' | 'signUpFinePrint' | 'emailFoundInputLabel' | 'emailFoundCtaButtonLabel' | 'phoneFoundInputLabel' | 'phoneFoundCtaButtonLabel' | 'emailAuthCodeInputLabel' | 'phoneAuthCodeInputLabel' | 'or' | 'popmenuLogoAlt' | 'continueWithFacebookButtonLabel' | 'continueWithGoogleButtonLabel' | 'initialCtaButtonLabel' | 'initialInputLabel' | 'passwordInputLabel' | 'poweredBy' | 'done' | 'signIn' | 'signInWithPassword';
59
63
  declare type LocationOption = {
60
64
  label: string;
61
65
  value: string;
@@ -5,6 +5,8 @@ export interface SplitInputProps {
5
5
  TextFieldProps?: TextFieldProps;
6
6
  /** Props applied to the composed Button component */
7
7
  ButtonProps?: ButtonProps;
8
+ /** Label for the button element */
9
+ buttonLabel: string;
8
10
  /** Sets the color for both TextField and Button */
9
11
  color?: 'primary' | 'secondary';
10
12
  /** Sets the text color for the TextField */
package/build/index.es.js CHANGED
@@ -921,11 +921,11 @@ var useSplitInputStyles = makeStyles$1(function () { return ({
921
921
  }); });
922
922
 
923
923
  var SplitInput = function (props) {
924
- var TextFieldProps = props.TextFieldProps, ButtonProps = props.ButtonProps, color = props.color, onChange = props.onChange, onClick = props.onClick;
924
+ var buttonLabel = props.buttonLabel, TextFieldProps = props.TextFieldProps, ButtonProps = props.ButtonProps, color = props.color, onChange = props.onChange, onClick = props.onClick;
925
925
  var classes = useSplitInputStyles(props);
926
926
  return (React__default.createElement(Box, { display: "flex" },
927
927
  React__default.createElement(TextField, __assign({ classes: { root: classes.textfield }, InputProps: { classes: { root: classes.input, focused: classes.focused } }, color: color, variant: "outlined", onChange: onChange }, TextFieldProps)),
928
- React__default.createElement(Button, __assign({ classes: { root: classes.button }, disableElevation: true, color: color, variant: "contained", onClick: onClick }, ButtonProps), "Submit")));
928
+ React__default.createElement(Button, __assign({ classes: { root: classes.button }, disableElevation: true, color: color, variant: "contained", onClick: onClick }, ButtonProps), buttonLabel)));
929
929
  };
930
930
  SplitInput.displayName = 'SplitInput';
931
931
  SplitInput.defaultProps = {
@@ -1105,6 +1105,35 @@ var useStyles$2 = makeStyles(function () { return ({
1105
1105
  var FollowerAuthenticationForm = function () {
1106
1106
  var _a = useFollowerAuthenticationDialogContext(), state = _a.state, messages = _a.messages, locationOptions = _a.locationOptions, dispatch = _a.dispatch, loading = _a.loading;
1107
1107
  var classes = useStyles$2();
1108
+ // sign-up form state
1109
+ var formRef = useRef(null);
1110
+ var _b = useState(false), formValidity = _b[0], setFormValidity = _b[1];
1111
+ var _c = useState(), showPhoneErrorText = _c[0], setShowPhoneErrorText = _c[1];
1112
+ var _d = useState(), showEmailErrorText = _d[0], setShowEmailErrorText = _d[1];
1113
+ var _e = useState(), showLocationErrorText = _e[0], setShowLocationErrorText = _e[1];
1114
+ var _f = useState(state.defaultFormValues.phone || ''), signUpPhoneValue = _f[0], setSignUpPhoneValue = _f[1];
1115
+ var _g = useState(state.defaultFormValues.email || ''), signUpEmailValue = _g[0], setSignUpEmailValue = _g[1];
1116
+ var checkFieldValidity = function (e) {
1117
+ var _a, _b;
1118
+ var fieldName = e.target.name;
1119
+ 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;
1120
+ switch (fieldName) {
1121
+ case 'phone':
1122
+ setSignUpPhoneValue(e.target.value);
1123
+ setShowPhoneErrorText(!fieldValidity);
1124
+ break;
1125
+ case 'email':
1126
+ setSignUpEmailValue(e.target.value);
1127
+ setShowEmailErrorText(!fieldValidity);
1128
+ break;
1129
+ case 'location':
1130
+ setShowLocationErrorText(!e.target.value);
1131
+ break;
1132
+ }
1133
+ };
1134
+ useEffect(function () {
1135
+ 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; }));
1136
+ }, [showPhoneErrorText, showEmailErrorText, showLocationErrorText, signUpPhoneValue, signUpEmailValue]);
1108
1137
  var handleSubmit = function (e) {
1109
1138
  e.preventDefault();
1110
1139
  var form = e.target;
@@ -1123,15 +1152,23 @@ var FollowerAuthenticationForm = function () {
1123
1152
  React__default.createElement(TextField$1, { disabled: loading, label: messages.initialInputLabel, key: "identifier-input", id: "identifier-input", name: "identifier" }),
1124
1153
  React__default.createElement(Button$1, { disabled: loading, type: "submit" }, messages.initialCtaButtonLabel)));
1125
1154
  case 'signUp':
1126
- return (React__default.createElement("form", __assign({}, formProps),
1127
- React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpPhoneInputLabel, key: "phone-input", id: "phone-input", name: "phone" }),
1128
- React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpNameInputLabel, key: "name-input", id: "name-input", name: "name" }),
1129
- React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpEmailInputLabel, key: "email-input", id: "email-input", name: "email" }),
1130
- React__default.createElement(TextField$1, { disabled: loading, select: true, label: messages.signUpLocationInputLabel, key: "location-input", id: "location-input", name: "location" }, locationOptions.map(function (locationOption) { return (React__default.createElement(MenuItem, { key: locationOption.value, value: locationOption.value }, locationOption.label)); })),
1155
+ return (React__default.createElement("form", __assign({ ref: formRef }, formProps, { onInvalid: function (e) {
1156
+ e.preventDefault();
1157
+ } }),
1158
+ React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpPhoneInputLabel, key: "phone-input", id: "phone-input", name: "phone", onChange: checkFieldValidity, error: showPhoneErrorText, helperText: showPhoneErrorText && messages.signUpPhoneErrorText, inputProps: {
1159
+ pattern: '^[0-9]{10}$',
1160
+ required: signUpEmailValue ? false : true,
1161
+ } }),
1162
+ React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpNameInputLabel, key: "name-input", id: "name-input", name: "name", inputProps: { required: true } }),
1163
+ React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpEmailInputLabel, key: "email-input", id: "email-input", name: "email", error: showEmailErrorText, helperText: showEmailErrorText && messages.signUpEmailErrorText, onChange: checkFieldValidity, inputProps: {
1164
+ required: signUpPhoneValue ? false : true,
1165
+ type: 'email',
1166
+ } }),
1167
+ React__default.createElement(TextField$1, { 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.createElement(MenuItem, { key: locationOption.value, value: locationOption.value }, locationOption.label)); })),
1131
1168
  React__default.createElement(Typography$1, { style: { alignSelf: 'start' } }, messages.signUpBirthdaySectionLabel),
1132
1169
  React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpMonthInputLabel, key: "birthday-month-input", id: "birthday-month-input", name: "birthdayMonth" }),
1133
1170
  React__default.createElement(TextField$1, { disabled: loading, label: messages.signUpDayInputLabel, key: "birthday-date-input", id: "birthday-date-input", name: "birthdayDate" }),
1134
- React__default.createElement(Button$1, { disabled: loading, type: "submit" }, messages.signUp)));
1171
+ React__default.createElement(Button$1, { disabled: loading || !formValidity, type: "submit" }, messages.signUp)));
1135
1172
  case 'emailFound':
1136
1173
  return (React__default.createElement("form", __assign({}, formProps),
1137
1174
  React__default.createElement(TextField$1, { disabled: loading, label: messages.emailFoundInputLabel, key: "email-input", id: "email-input", name: "email", value: state.defaultFormValues.email }),
@@ -1245,7 +1282,6 @@ var FollowerAuthenticationBody = function () {
1245
1282
 
1246
1283
  var FollowerAuthenticationFooter = function () {
1247
1284
  var _a = useFollowerAuthenticationDialogContext(), messages = _a.messages, logos = _a.logos;
1248
- console.log(logos.popmenu);
1249
1285
  return (React__default.createElement(Box, { display: "flex", gridGap: 8 },
1250
1286
  React__default.createElement(Typography$1, { variant: "body2" }, messages.poweredBy),
1251
1287
  logos.popmenu));