@lumx/react 3.2.1 → 3.3.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/index.d.ts
CHANGED
|
@@ -2695,6 +2695,8 @@ interface TextFieldProps extends GenericProps, HasTheme {
|
|
|
2695
2695
|
onBlur?(event: React.FocusEvent): void;
|
|
2696
2696
|
/** On change callback. */
|
|
2697
2697
|
onChange(value: string, name?: string, event?: SyntheticEvent): void;
|
|
2698
|
+
/** On clear callback. */
|
|
2699
|
+
onClear?(event?: SyntheticEvent): void;
|
|
2698
2700
|
/** On focus callback. */
|
|
2699
2701
|
onFocus?(event: React.FocusEvent): void;
|
|
2700
2702
|
}
|
package/index.js
CHANGED
|
@@ -11718,8 +11718,8 @@ TabPanel.displayName = COMPONENT_NAME$1f;
|
|
|
11718
11718
|
TabPanel.className = CLASSNAME$1c;
|
|
11719
11719
|
TabPanel.defaultProps = DEFAULT_PROPS$Z;
|
|
11720
11720
|
|
|
11721
|
-
const _excluded$1k = ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name"],
|
|
11722
|
-
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"];
|
|
11721
|
+
const _excluded$1k = ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name", "hasError", "describedById"],
|
|
11722
|
+
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onClear", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"];
|
|
11723
11723
|
|
|
11724
11724
|
/**
|
|
11725
11725
|
* Defines the props of the component.
|
|
@@ -11799,7 +11799,9 @@ const renderInputNative = props => {
|
|
|
11799
11799
|
rows,
|
|
11800
11800
|
recomputeNumberOfRows,
|
|
11801
11801
|
type,
|
|
11802
|
-
name
|
|
11802
|
+
name,
|
|
11803
|
+
hasError,
|
|
11804
|
+
describedById
|
|
11803
11805
|
} = props,
|
|
11804
11806
|
forwardedProps = _objectWithoutProperties(props, _excluded$1k);
|
|
11805
11807
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -11835,6 +11837,8 @@ const renderInputNative = props => {
|
|
|
11835
11837
|
onFocus: onTextFieldFocus,
|
|
11836
11838
|
onBlur: onTextFieldBlur,
|
|
11837
11839
|
onChange: handleChange,
|
|
11840
|
+
'aria-invalid': hasError ? 'true' : undefined,
|
|
11841
|
+
'aria-describedby': describedById,
|
|
11838
11842
|
ref: mergeRefs(inputRef, ref)
|
|
11839
11843
|
});
|
|
11840
11844
|
if (multiline) {
|
|
@@ -11875,6 +11879,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11875
11879
|
name,
|
|
11876
11880
|
onBlur,
|
|
11877
11881
|
onChange,
|
|
11882
|
+
onClear,
|
|
11878
11883
|
onFocus,
|
|
11879
11884
|
placeholder,
|
|
11880
11885
|
textFieldRef,
|
|
@@ -11885,6 +11890,16 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11885
11890
|
} = props,
|
|
11886
11891
|
forwardedProps = _objectWithoutProperties(props, _excluded2$3);
|
|
11887
11892
|
const textFieldId = useMemo(() => id || `text-field-${uid()}`, [id]);
|
|
11893
|
+
/**
|
|
11894
|
+
* Generate unique ids for both the helper and error texts, in order to
|
|
11895
|
+
* later on add them to the input native as aria-describedby. If both the error and the helper are present,
|
|
11896
|
+
* we want to first use the most important one, which is the errorId. That way, screen readers will read first
|
|
11897
|
+
* the error and then the helper
|
|
11898
|
+
*/
|
|
11899
|
+
const helperId = helper ? `text-field-helper-${uid()}` : undefined;
|
|
11900
|
+
const errorId = error ? `text-field-error-${uid()}` : undefined;
|
|
11901
|
+
const describedByIds = [errorId, helperId].filter(Boolean);
|
|
11902
|
+
const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');
|
|
11888
11903
|
const [isFocus, setFocus] = useState(false);
|
|
11889
11904
|
const {
|
|
11890
11905
|
rows,
|
|
@@ -11899,11 +11914,14 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11899
11914
|
* and remove focus from the clear button.
|
|
11900
11915
|
* @param evt On clear event.
|
|
11901
11916
|
*/
|
|
11902
|
-
const
|
|
11917
|
+
const handleClear = evt => {
|
|
11903
11918
|
evt.nativeEvent.preventDefault();
|
|
11904
11919
|
evt.nativeEvent.stopPropagation();
|
|
11905
11920
|
evt.currentTarget.blur();
|
|
11906
11921
|
onChange('');
|
|
11922
|
+
if (onClear) {
|
|
11923
|
+
onClear(evt);
|
|
11924
|
+
}
|
|
11907
11925
|
};
|
|
11908
11926
|
return /*#__PURE__*/React.createElement("div", {
|
|
11909
11927
|
ref: ref,
|
|
@@ -11961,7 +11979,9 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11961
11979
|
setFocus,
|
|
11962
11980
|
type,
|
|
11963
11981
|
value,
|
|
11964
|
-
name
|
|
11982
|
+
name,
|
|
11983
|
+
hasError,
|
|
11984
|
+
describedById
|
|
11965
11985
|
}, forwardedProps))), !chips && /*#__PURE__*/React.createElement("div", {
|
|
11966
11986
|
className: `${CLASSNAME$1d}__input-wrapper`
|
|
11967
11987
|
}, renderInputNative(_objectSpread2({
|
|
@@ -11980,7 +12000,9 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11980
12000
|
setFocus,
|
|
11981
12001
|
type,
|
|
11982
12002
|
value,
|
|
11983
|
-
name
|
|
12003
|
+
name,
|
|
12004
|
+
hasError,
|
|
12005
|
+
describedById
|
|
11984
12006
|
}, forwardedProps))), (isValid || hasError) && /*#__PURE__*/React.createElement(Icon, {
|
|
11985
12007
|
className: `${CLASSNAME$1d}__input-validity`,
|
|
11986
12008
|
color: theme === Theme.dark ? 'light' : undefined,
|
|
@@ -11992,17 +12014,19 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11992
12014
|
emphasis: Emphasis.low,
|
|
11993
12015
|
size: Size.s,
|
|
11994
12016
|
theme: theme,
|
|
11995
|
-
onClick:
|
|
12017
|
+
onClick: handleClear,
|
|
11996
12018
|
type: "button"
|
|
11997
12019
|
})), afterElement && /*#__PURE__*/React.createElement("div", {
|
|
11998
12020
|
className: `${CLASSNAME$1d}__after-element`
|
|
11999
12021
|
}, afterElement)), hasError && error && /*#__PURE__*/React.createElement(InputHelper, {
|
|
12000
12022
|
className: `${CLASSNAME$1d}__helper`,
|
|
12001
12023
|
kind: Kind.error,
|
|
12002
|
-
theme: theme
|
|
12024
|
+
theme: theme,
|
|
12025
|
+
id: errorId
|
|
12003
12026
|
}, error), helper && /*#__PURE__*/React.createElement(InputHelper, {
|
|
12004
12027
|
className: `${CLASSNAME$1d}__helper`,
|
|
12005
|
-
theme: theme
|
|
12028
|
+
theme: theme,
|
|
12029
|
+
id: helperId
|
|
12006
12030
|
}, helper));
|
|
12007
12031
|
});
|
|
12008
12032
|
TextField.displayName = COMPONENT_NAME$1g;
|