authscape 1.0.149 → 1.0.150
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/index.js +65 -16
- package/package.json +1 -1
- package/src/components/GoogleMapsAutoComplete.js +73 -13
package/index.js
CHANGED
|
@@ -729,6 +729,7 @@ var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon")
|
|
|
729
729
|
var _LocationOnRounded = _interopRequireDefault(require("@mui/icons-material/LocationOnRounded"));
|
|
730
730
|
var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
|
|
731
731
|
var _reactCoolOnclickoutside = _interopRequireDefault(require("react-cool-onclickoutside"));
|
|
732
|
+
var _reactHookForm = require("react-hook-form");
|
|
732
733
|
var _Stack = _interopRequireDefault(require("@mui/material/Stack"));
|
|
733
734
|
var _usePlacesAutocomplete = _interopRequireWildcard(require("use-places-autocomplete"));
|
|
734
735
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -746,6 +747,7 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
746
747
|
onSelected = _ref.onSelected,
|
|
747
748
|
defaultValue = _ref.defaultValue,
|
|
748
749
|
react_hook_form_Control = _ref.react_hook_form_Control,
|
|
750
|
+
react_hook_form_errors = _ref.react_hook_form_errors,
|
|
749
751
|
onChange = _ref.onChange;
|
|
750
752
|
var txtAddressField = (0, _react.useRef)(null);
|
|
751
753
|
var dismissSuggestions = function dismissSuggestions() {
|
|
@@ -990,7 +992,7 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
990
992
|
sx: {
|
|
991
993
|
color: "red"
|
|
992
994
|
}
|
|
993
|
-
}, "Address is required.")), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(Controller, {
|
|
995
|
+
}, "Address is required.")), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
994
996
|
control: react_hook_form_Control,
|
|
995
997
|
rules: {
|
|
996
998
|
required: true
|
|
@@ -1033,7 +1035,11 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1033
1035
|
_ref4$_state = _ref4._state,
|
|
1034
1036
|
_state = _ref4$_state === void 0 ? "" : _ref4$_state,
|
|
1035
1037
|
_ref4$_postalCode = _ref4._postalCode,
|
|
1036
|
-
_postalCode = _ref4$_postalCode === void 0 ? "" : _ref4$_postalCode
|
|
1038
|
+
_postalCode = _ref4$_postalCode === void 0 ? "" : _ref4$_postalCode,
|
|
1039
|
+
_ref4$react_hook_form = _ref4.react_hook_form_Control,
|
|
1040
|
+
react_hook_form_Control = _ref4$react_hook_form === void 0 ? null : _ref4$react_hook_form,
|
|
1041
|
+
_ref4$react_hook_form2 = _ref4.react_hook_form_errors,
|
|
1042
|
+
react_hook_form_errors = _ref4$react_hook_form2 === void 0 ? null : _ref4$react_hook_form2;
|
|
1037
1043
|
var _useState = (0, _react.useState)(_address),
|
|
1038
1044
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1039
1045
|
address = _useState2[0],
|
|
@@ -1060,6 +1066,8 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1060
1066
|
setLng = _useState12[1];
|
|
1061
1067
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(AutoCompleteDialog, {
|
|
1062
1068
|
placeholder: "Address",
|
|
1069
|
+
react_hook_form_Control: react_hook_form_Control,
|
|
1070
|
+
react_hook_form_errors: react_hook_form_errors,
|
|
1063
1071
|
defaultValue: address,
|
|
1064
1072
|
onSelected: function onSelected(data) {
|
|
1065
1073
|
setAddress(data.address);
|
|
@@ -1082,35 +1090,79 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1082
1090
|
}, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
1083
1091
|
item: true,
|
|
1084
1092
|
xs: 6
|
|
1085
|
-
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1093
|
+
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, react_hook_form_Control == null && /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1086
1094
|
id: "outlined-basic",
|
|
1087
1095
|
label: "City",
|
|
1088
1096
|
name: "city",
|
|
1089
1097
|
variant: "outlined",
|
|
1090
1098
|
fullWidth: true,
|
|
1091
1099
|
value: city,
|
|
1092
|
-
InputProps: {
|
|
1093
|
-
readOnly: true
|
|
1094
|
-
},
|
|
1095
1100
|
onChange: function onChange(val) {
|
|
1096
1101
|
setCity(val.currentTarget.value);
|
|
1097
1102
|
}
|
|
1103
|
+
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1104
|
+
control: react_hook_form_Control,
|
|
1105
|
+
rules: {
|
|
1106
|
+
required: true
|
|
1107
|
+
},
|
|
1108
|
+
name: "city",
|
|
1109
|
+
render: function render(_ref5) {
|
|
1110
|
+
var field = _ref5.field;
|
|
1111
|
+
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1112
|
+
id: "outlined-basic",
|
|
1113
|
+
label: "City",
|
|
1114
|
+
name: "city",
|
|
1115
|
+
variant: "outlined"
|
|
1116
|
+
}, field, {
|
|
1117
|
+
fullWidth: true,
|
|
1118
|
+
value: city,
|
|
1119
|
+
onChange: function onChange(val) {
|
|
1120
|
+
setCity(val.currentTarget.value);
|
|
1121
|
+
}
|
|
1122
|
+
})), react_hook_form_errors != null && react_hook_form_errors.city && react_hook_form_errors.city.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1123
|
+
sx: {
|
|
1124
|
+
color: "red"
|
|
1125
|
+
}
|
|
1126
|
+
}, "City is required."));
|
|
1127
|
+
}
|
|
1098
1128
|
}))), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
1099
1129
|
item: true,
|
|
1100
1130
|
xs: 6
|
|
1101
|
-
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1131
|
+
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, react_hook_form_Control == null && /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1102
1132
|
id: "outlined-basic",
|
|
1103
1133
|
label: "State",
|
|
1104
1134
|
name: "state",
|
|
1105
1135
|
variant: "outlined",
|
|
1106
1136
|
fullWidth: true,
|
|
1107
|
-
InputProps: {
|
|
1108
|
-
readOnly: true
|
|
1109
|
-
},
|
|
1110
1137
|
value: state,
|
|
1111
1138
|
onChange: function onChange(val) {
|
|
1112
1139
|
setState(val.currentTarget.value);
|
|
1113
1140
|
}
|
|
1141
|
+
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1142
|
+
control: react_hook_form_Control,
|
|
1143
|
+
rules: {
|
|
1144
|
+
required: true
|
|
1145
|
+
},
|
|
1146
|
+
name: "state",
|
|
1147
|
+
render: function render(_ref6) {
|
|
1148
|
+
var field = _ref6.field;
|
|
1149
|
+
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1150
|
+
id: "outlined-basic",
|
|
1151
|
+
label: "State"
|
|
1152
|
+
}, field, {
|
|
1153
|
+
name: "state",
|
|
1154
|
+
variant: "outlined",
|
|
1155
|
+
fullWidth: true,
|
|
1156
|
+
value: state,
|
|
1157
|
+
onChange: function onChange(val) {
|
|
1158
|
+
setState(val.currentTarget.value);
|
|
1159
|
+
}
|
|
1160
|
+
})), react_hook_form_errors != null && react_hook_form_errors.state && react_hook_form_errors.state.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1161
|
+
sx: {
|
|
1162
|
+
color: "red"
|
|
1163
|
+
}
|
|
1164
|
+
}, "State is required."));
|
|
1165
|
+
}
|
|
1114
1166
|
})))), /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
1115
1167
|
sx: {
|
|
1116
1168
|
marginTop: 2
|
|
@@ -1122,20 +1174,17 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1122
1174
|
variant: "outlined",
|
|
1123
1175
|
fullWidth: true,
|
|
1124
1176
|
value: zip,
|
|
1125
|
-
InputProps: {
|
|
1126
|
-
readOnly: true
|
|
1127
|
-
},
|
|
1128
1177
|
onChange: function onChange(val) {
|
|
1129
1178
|
setPostalcode(val.currentTarget.value);
|
|
1130
1179
|
}
|
|
1131
|
-
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(Controller, {
|
|
1180
|
+
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1132
1181
|
control: react_hook_form_Control,
|
|
1133
1182
|
rules: {
|
|
1134
1183
|
required: true
|
|
1135
1184
|
},
|
|
1136
1185
|
name: "postalCode",
|
|
1137
|
-
render: function render(
|
|
1138
|
-
var field =
|
|
1186
|
+
render: function render(_ref7) {
|
|
1187
|
+
var field = _ref7.field;
|
|
1139
1188
|
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1140
1189
|
id: "outlined-basic",
|
|
1141
1190
|
label: "Postal code"
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
9
9
|
import LocationOnRoundedIcon from '@mui/icons-material/LocationOnRounded';
|
|
10
10
|
import ListItemText from '@mui/material/ListItemText';
|
|
11
11
|
import useOnclickOutside from "react-cool-onclickoutside";
|
|
12
|
+
import { useForm, Controller, useFieldArray } from "react-hook-form";
|
|
12
13
|
import Stack from "@mui/material/Stack";
|
|
13
14
|
|
|
14
15
|
import usePlacesAutocomplete, {
|
|
@@ -18,7 +19,7 @@ import usePlacesAutocomplete, {
|
|
|
18
19
|
getLatLng,
|
|
19
20
|
} from "use-places-autocomplete";
|
|
20
21
|
|
|
21
|
-
const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, react_hook_form_Control, onChange}) => {
|
|
22
|
+
const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, react_hook_form_Control, react_hook_form_errors, onChange}) => {
|
|
22
23
|
|
|
23
24
|
const txtAddressField = useRef(null);
|
|
24
25
|
|
|
@@ -369,7 +370,9 @@ export const GooglePlacesModal = ({
|
|
|
369
370
|
_address = "",
|
|
370
371
|
_city = "",
|
|
371
372
|
_state = "",
|
|
372
|
-
_postalCode = ""
|
|
373
|
+
_postalCode = "",
|
|
374
|
+
react_hook_form_Control = null,
|
|
375
|
+
react_hook_form_errors = null
|
|
373
376
|
}) => {
|
|
374
377
|
const [address, setAddress] = useState(_address);
|
|
375
378
|
const [city, setCity] = useState(_city);
|
|
@@ -384,6 +387,8 @@ export const GooglePlacesModal = ({
|
|
|
384
387
|
<Box>
|
|
385
388
|
<AutoCompleteDialog
|
|
386
389
|
placeholder={"Address"}
|
|
390
|
+
react_hook_form_Control={react_hook_form_Control}
|
|
391
|
+
react_hook_form_errors={react_hook_form_errors}
|
|
387
392
|
defaultValue={address}
|
|
388
393
|
onSelected={(data) => {
|
|
389
394
|
setAddress(data.address);
|
|
@@ -403,7 +408,8 @@ export const GooglePlacesModal = ({
|
|
|
403
408
|
<Grid container spacing={1} sx={{ marginTop: 1 }}>
|
|
404
409
|
<Grid item xs={6}>
|
|
405
410
|
<Box>
|
|
406
|
-
|
|
411
|
+
|
|
412
|
+
{react_hook_form_Control == null &&
|
|
407
413
|
<TextField
|
|
408
414
|
id="outlined-basic"
|
|
409
415
|
label="City"
|
|
@@ -411,13 +417,40 @@ export const GooglePlacesModal = ({
|
|
|
411
417
|
variant="outlined"
|
|
412
418
|
fullWidth={true}
|
|
413
419
|
value={city}
|
|
414
|
-
InputProps={{
|
|
415
|
-
readOnly: true,
|
|
416
|
-
}}
|
|
417
420
|
onChange={(val) => {
|
|
418
421
|
setCity(val.currentTarget.value);
|
|
419
422
|
}}
|
|
420
423
|
/>
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
{react_hook_form_Control != null &&
|
|
427
|
+
<Controller
|
|
428
|
+
control={react_hook_form_Control}
|
|
429
|
+
rules={{ required: true }}
|
|
430
|
+
name="city"
|
|
431
|
+
render={({ field }) => (
|
|
432
|
+
<Stack>
|
|
433
|
+
<TextField
|
|
434
|
+
id="outlined-basic"
|
|
435
|
+
label="City"
|
|
436
|
+
name="city"
|
|
437
|
+
variant="outlined"
|
|
438
|
+
{...field}
|
|
439
|
+
fullWidth={true}
|
|
440
|
+
value={city}
|
|
441
|
+
onChange={(val) => {
|
|
442
|
+
setCity(val.currentTarget.value);
|
|
443
|
+
}}
|
|
444
|
+
/>
|
|
445
|
+
|
|
446
|
+
{react_hook_form_errors != null && react_hook_form_errors.city &&
|
|
447
|
+
react_hook_form_errors.city.type === 'required'
|
|
448
|
+
&& <Typography sx={{color: "red"}}>City is required.</Typography>}
|
|
449
|
+
</Stack>
|
|
450
|
+
)}
|
|
451
|
+
/>
|
|
452
|
+
}
|
|
453
|
+
|
|
421
454
|
|
|
422
455
|
</Box>
|
|
423
456
|
</Grid>
|
|
@@ -425,21 +458,51 @@ export const GooglePlacesModal = ({
|
|
|
425
458
|
<Grid item xs={6}>
|
|
426
459
|
<Box>
|
|
427
460
|
|
|
461
|
+
{react_hook_form_Control == null &&
|
|
462
|
+
|
|
428
463
|
<TextField
|
|
429
464
|
id="outlined-basic"
|
|
430
465
|
label="State"
|
|
431
466
|
name="state"
|
|
432
467
|
variant="outlined"
|
|
433
468
|
fullWidth={true}
|
|
434
|
-
InputProps={{
|
|
435
|
-
readOnly: true,
|
|
436
|
-
}}
|
|
437
469
|
value={state}
|
|
438
470
|
onChange={(val) => {
|
|
439
471
|
setState(val.currentTarget.value);
|
|
440
472
|
}}
|
|
441
473
|
/>
|
|
442
|
-
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
{react_hook_form_Control != null &&
|
|
477
|
+
<Controller
|
|
478
|
+
control={react_hook_form_Control}
|
|
479
|
+
rules={{ required: true }}
|
|
480
|
+
name="state"
|
|
481
|
+
render={({ field }) => (
|
|
482
|
+
<Stack>
|
|
483
|
+
|
|
484
|
+
<TextField
|
|
485
|
+
id="outlined-basic"
|
|
486
|
+
label="State"
|
|
487
|
+
{...field}
|
|
488
|
+
name="state"
|
|
489
|
+
variant="outlined"
|
|
490
|
+
fullWidth={true}
|
|
491
|
+
value={state}
|
|
492
|
+
onChange={(val) => {
|
|
493
|
+
setState(val.currentTarget.value);
|
|
494
|
+
}}
|
|
495
|
+
/>
|
|
496
|
+
|
|
497
|
+
{react_hook_form_errors != null && react_hook_form_errors.state &&
|
|
498
|
+
react_hook_form_errors.state.type === 'required'
|
|
499
|
+
&& <Typography sx={{color: "red"}}>State is required.</Typography>}
|
|
500
|
+
</Stack>
|
|
501
|
+
)}
|
|
502
|
+
/>
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
|
|
443
506
|
|
|
444
507
|
|
|
445
508
|
</Box>
|
|
@@ -458,9 +521,6 @@ export const GooglePlacesModal = ({
|
|
|
458
521
|
variant="outlined"
|
|
459
522
|
fullWidth={true}
|
|
460
523
|
value={zip}
|
|
461
|
-
InputProps={{
|
|
462
|
-
readOnly: true,
|
|
463
|
-
}}
|
|
464
524
|
onChange={(val) => {
|
|
465
525
|
setPostalcode(val.currentTarget.value);
|
|
466
526
|
}}
|