@longline/aqua-ui 1.0.341 → 1.0.342
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/inputs/Input/Input.d.ts +11 -4
- package/inputs/Input/Input.js +14 -4
- package/package.json +1 -1
package/inputs/Input/Input.d.ts
CHANGED
|
@@ -129,14 +129,21 @@ interface IInputProps extends ITestable {
|
|
|
129
129
|
* Listeners are notified when the Input receives focus.
|
|
130
130
|
*/
|
|
131
131
|
onFocus?: () => void;
|
|
132
|
+
/**
|
|
133
|
+
* Key handler on the underlying input, e.g. for ↑/↓/Enter navigation when the
|
|
134
|
+
* Input drives a choice list. Receives the raw keyboard event.
|
|
135
|
+
*/
|
|
136
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Focus the input on mount.
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
autoFocus?: boolean;
|
|
132
142
|
/**
|
|
133
143
|
* Optional inline styles applied to the outer element, for one-off overrides
|
|
134
144
|
* of the default styling.
|
|
135
145
|
*/
|
|
136
146
|
style?: React.CSSProperties;
|
|
137
147
|
}
|
|
138
|
-
declare const Input:
|
|
139
|
-
(props: IInputProps): React.JSX.Element;
|
|
140
|
-
displayName: string;
|
|
141
|
-
};
|
|
148
|
+
declare const Input: React.ForwardRefExoticComponent<IInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
142
149
|
export { Input, IInputProps };
|
package/inputs/Input/Input.js
CHANGED
|
@@ -16,9 +16,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
16
16
|
import * as React from 'react';
|
|
17
17
|
import styled, { css } from 'styled-components';
|
|
18
18
|
import { InputWrapper } from './InputWrapper';
|
|
19
|
-
var InputBase = function (props) {
|
|
19
|
+
var InputBase = React.forwardRef(function (props, forwardedRef) {
|
|
20
20
|
var _a;
|
|
21
21
|
var inputRef = React.useRef(null);
|
|
22
|
+
// Attach the underlying input to both the internal ref (hotkey/clear focus) and
|
|
23
|
+
// any ref a consumer forwarded (e.g. to focus the input programmatically).
|
|
24
|
+
var setRefs = function (el) {
|
|
25
|
+
inputRef.current = el;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(el);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = el;
|
|
30
|
+
};
|
|
22
31
|
// Current value:
|
|
23
32
|
var _b = React.useState((_a = props.value) !== null && _a !== void 0 ? _a : ""), value = _b[0], setValue = _b[1];
|
|
24
33
|
var _c = React.useState(false), revealed = _c[0], setRevealed = _c[1];
|
|
@@ -74,10 +83,11 @@ var InputBase = function (props) {
|
|
|
74
83
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.select();
|
|
75
84
|
};
|
|
76
85
|
return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, icon: props.icon, iconPosition: props.iconPosition, onClear: (props.clearable && props.value) ? handleClear : undefined, onToggleReveal: props.revealable ? handleToggleReveal : undefined, revealed: revealed, unit: props.unit, style: props.style },
|
|
77
|
-
React.createElement("input", { "data-testid": props['data-testid'] || "Input", className: props.className, ref:
|
|
78
|
-
};
|
|
86
|
+
React.createElement("input", { "data-testid": props['data-testid'] || "Input", className: props.className, ref: setRefs, tabIndex: props.noTabIndex ? -1 : 0, value: value, placeholder: props.placeholder, disabled: props.disabled, type: props.type == 'password' ? (revealed ? 'text' : 'password') : props.type, maxLength: props.maxLength, autoComplete: props.autocomplete, autoFocus: props.autoFocus, onChange: handleChange, onKeyDown: props.onKeyDown, onFocus: props.onFocus })));
|
|
87
|
+
});
|
|
88
|
+
InputBase.displayName = 'InputBase';
|
|
79
89
|
var InputStyled = styled(InputBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Dimensions:\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n border: none;\n\n background: transparent;\n padding: 0;\n margin: 0;\n outline: none;\n\n // Font\n font: ", ";\n text-align: left;\n color: ", ";\n\n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Focus:\n &:focus {\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n\n ", "\n\n // Make sure HTML5 validation does not show up.\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n // Turn off number spinners.\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n appearance:textfield;\n -moz-appearance:textfield; /* Firefox */\n } \n"], ["\n // Dimensions:\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n border: none;\n\n background: transparent;\n padding: 0;\n margin: 0;\n outline: none;\n\n // Font\n font: ", ";\n text-align: left;\n color: ", ";\n\n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Focus:\n &:focus {\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n\n ", "\n\n // Make sure HTML5 validation does not show up.\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n // Turn off number spinners.\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n appearance:textfield;\n -moz-appearance:textfield; /* Firefox */\n } \n"])), function (p) { return p.theme.font.bodyMedium; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), p.theme.colors.neutral[50]); });
|
|
80
|
-
var Input = function (props) { return React.createElement(InputStyled, __assign({}, props)); };
|
|
90
|
+
var Input = React.forwardRef(function (props, ref) { return React.createElement(InputStyled, __assign({ ref: ref }, props)); });
|
|
81
91
|
Input.displayName = 'Input';
|
|
82
92
|
export { Input };
|
|
83
93
|
var templateObject_1, templateObject_2;
|