@mackin.com/styleguide 9.2.2 → 9.2.5
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 +24 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1012,21 +1012,24 @@ const Autocomplete = (p) => {
|
|
|
1012
1012
|
listBorderRadius = theme.controls.borderRadius || '0.5rem';
|
|
1013
1013
|
}
|
|
1014
1014
|
const onPickValue = (v) => {
|
|
1015
|
-
|
|
1016
|
-
//
|
|
1015
|
+
var _a;
|
|
1016
|
+
// the TextInput will not respond to outer value changes if it has focus.
|
|
1017
|
+
// here we clear first and then onPickValue will re-focus after all updates.
|
|
1018
|
+
(_a = input.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
1017
1019
|
setTimeout(() => {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
+
// blur is now complete
|
|
1021
|
+
p.onPick(v);
|
|
1022
|
+
// wait for the re-render. the value will not update if the control has focus
|
|
1023
|
+
setTimeout(() => {
|
|
1024
|
+
var _a;
|
|
1025
|
+
(_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1026
|
+
}, 0);
|
|
1020
1027
|
}, 0);
|
|
1021
1028
|
};
|
|
1022
1029
|
return (React__namespace.createElement("div", { onClick: e => {
|
|
1023
1030
|
e.stopPropagation();
|
|
1024
1031
|
}, onKeyDown: e => {
|
|
1025
|
-
var _a;
|
|
1026
1032
|
if (e.key === 'Escape') {
|
|
1027
|
-
// the TextInput will not respond to outer value changes if it has focus.
|
|
1028
|
-
// here we clear first and then onPickValue will re-focus after all updates.
|
|
1029
|
-
(_a = input.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
1030
1033
|
onPickValue(undefined);
|
|
1031
1034
|
}
|
|
1032
1035
|
}, ref: element, className: css.cx(css.css({
|
|
@@ -1087,6 +1090,9 @@ const Autocomplete = (p) => {
|
|
|
1087
1090
|
(_b = getNextTabElement(listItemIndex, -1)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1088
1091
|
}
|
|
1089
1092
|
else if (e.key === 'Enter') {
|
|
1093
|
+
e.stopPropagation();
|
|
1094
|
+
// this will prevent the click event from firing in addition to this enter key event.
|
|
1095
|
+
e.preventDefault();
|
|
1090
1096
|
onPickValue(v);
|
|
1091
1097
|
}
|
|
1092
1098
|
}, className: css.cx(buttonMarkerClass + listItemIndex, css.css({
|
|
@@ -3634,20 +3640,21 @@ const SearchBox = React__namespace.forwardRef((props, ref) => {
|
|
|
3634
3640
|
return props.onSubmit();
|
|
3635
3641
|
});
|
|
3636
3642
|
const theme = useThemeSafely();
|
|
3637
|
-
let button;
|
|
3638
3643
|
const buttonStyles = css.cx(css.css({
|
|
3639
3644
|
color: `${theme.colors.font} !important;`,
|
|
3640
3645
|
fontSize: '1rem'
|
|
3641
3646
|
}), props.buttonClassName);
|
|
3647
|
+
let clearButton;
|
|
3642
3648
|
if (props.onClear && !!props.value) {
|
|
3643
|
-
|
|
3644
|
-
React__namespace.createElement(Icon, { id:
|
|
3645
|
-
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3649
|
+
clearButton = (React__namespace.createElement(Button, { onClick: props.onClear, tabIndex: -1, disabled: waiting, className: buttonStyles, variant: "icon", small: true },
|
|
3650
|
+
React__namespace.createElement(Icon, { id: "clear" })));
|
|
3651
|
+
}
|
|
3652
|
+
const saveButton = (React__namespace.createElement(Button, { tabIndex: -1, disabled: waiting, readOnly: !props.onSubmit, type: "submit", className: buttonStyles, variant: "icon", small: true },
|
|
3653
|
+
React__namespace.createElement(Icon, { id: waiting ? 'waiting' : 'search', spin: waiting })));
|
|
3654
|
+
const rightControls = clearButton ? React__namespace.createElement(React__namespace.Fragment, null,
|
|
3655
|
+
clearButton,
|
|
3656
|
+
saveButton) : saveButton;
|
|
3657
|
+
const input = (React__namespace.createElement(TextInput, Object.assign({}, inputProps, { ref: ref, wrapperClassName: props.inputWrapperClassName, className: props.inputClassName, rightControl: rightControls })));
|
|
3651
3658
|
const searchBoxWrapperStyles = css.cx(css.css({
|
|
3652
3659
|
label: 'SearchBox'
|
|
3653
3660
|
}), props.wrapperClassName);
|