@hitachivantara/uikit-react-core 5.76.0 → 5.77.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/dist/cjs/Forms/Suggestions/Suggestions.cjs +13 -2
- package/dist/cjs/Forms/Suggestions/Suggestions.styles.cjs +7 -4
- package/dist/cjs/Input/Input.cjs +25 -6
- package/dist/esm/Forms/Suggestions/Suggestions.js +13 -2
- package/dist/esm/Forms/Suggestions/Suggestions.js.map +1 -1
- package/dist/esm/Forms/Suggestions/Suggestions.styles.js +7 -4
- package/dist/esm/Forms/Suggestions/Suggestions.styles.js.map +1 -1
- package/dist/esm/Input/Input.js +25 -6
- package/dist/esm/Input/Input.js.map +1 -1
- package/dist/types/index.d.ts +24 -2
- package/package.json +2 -2
|
@@ -5,6 +5,8 @@ const React = require("react");
|
|
|
5
5
|
const ClickAwayListener = require("@mui/base/ClickAwayListener");
|
|
6
6
|
const Popper = require("@mui/base/Popper");
|
|
7
7
|
const utils = require("@mui/material/utils");
|
|
8
|
+
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
9
|
+
const document = require("../../utils/document.cjs");
|
|
8
10
|
const setId = require("../../utils/setId.cjs");
|
|
9
11
|
const Suggestions_styles = require("./Suggestions.styles.cjs");
|
|
10
12
|
const SelectionList = require("../../SelectionList/SelectionList.cjs");
|
|
@@ -16,6 +18,7 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
|
|
|
16
18
|
className,
|
|
17
19
|
classes: classesProp,
|
|
18
20
|
expanded = false,
|
|
21
|
+
enablePortal = false,
|
|
19
22
|
open: openProp,
|
|
20
23
|
anchorEl,
|
|
21
24
|
suggestionValues = [],
|
|
@@ -24,6 +27,7 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
|
|
|
24
27
|
...others
|
|
25
28
|
} = props;
|
|
26
29
|
const { classes, cx } = Suggestions_styles.useClasses(classesProp);
|
|
30
|
+
const { rootId } = uikitReactUtils.useTheme();
|
|
27
31
|
const { elementId } = React.useContext(FormElementContext.HvFormElementContext);
|
|
28
32
|
const localId = id ?? setId.setId(elementId, "suggestions");
|
|
29
33
|
const ref = React.useRef(null);
|
|
@@ -49,10 +53,17 @@ const HvSuggestions = React.forwardRef((props, extRef) => {
|
|
|
49
53
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
54
|
Popper.Popper,
|
|
51
55
|
{
|
|
56
|
+
style: {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
"--popper-width": enablePortal ? `${anchorEl?.clientWidth}px` : "100%"
|
|
59
|
+
},
|
|
52
60
|
open: openProp ?? isOpen,
|
|
53
|
-
disablePortal:
|
|
61
|
+
disablePortal: !enablePortal,
|
|
62
|
+
container: enablePortal ? document.getContainerElement(rootId) : void 0,
|
|
54
63
|
anchorEl,
|
|
55
|
-
className: classes.popper,
|
|
64
|
+
className: cx(classes.popper, {
|
|
65
|
+
[classes.portal]: enablePortal
|
|
66
|
+
}),
|
|
56
67
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
57
68
|
SelectionList.HvSelectionList,
|
|
58
69
|
{
|
|
@@ -11,11 +11,14 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvSuggestio
|
|
|
11
11
|
width: "100%"
|
|
12
12
|
},
|
|
13
13
|
popper: {
|
|
14
|
-
width: "
|
|
14
|
+
width: "var(--popper-width)",
|
|
15
15
|
position: "absolute",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
zIndex: uikitStyles.theme.zIndices.tooltip,
|
|
17
|
+
":not($portal)": {
|
|
18
|
+
transform: "translate3d(0, -1px, 0) !important"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
portal: {}
|
|
19
22
|
});
|
|
20
23
|
exports.staticClasses = staticClasses;
|
|
21
24
|
exports.useClasses = useClasses;
|
package/dist/cjs/Input/Input.cjs
CHANGED
|
@@ -57,6 +57,8 @@ const HvInput = React.forwardRef((props, ref) => {
|
|
|
57
57
|
required = false,
|
|
58
58
|
readOnly = false,
|
|
59
59
|
disabled = false,
|
|
60
|
+
enablePortal = false,
|
|
61
|
+
suggestOnFocus = false,
|
|
60
62
|
label,
|
|
61
63
|
"aria-label": ariaLabel,
|
|
62
64
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -249,11 +251,17 @@ const HvInput = React.forwardRef((props, ref) => {
|
|
|
249
251
|
const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!hasOnEnter || type !== "search" || disableSearchButton || validationState !== validationStates.default.standBy);
|
|
250
252
|
const showSearchIcon = type === "search" && !disableSearchButton;
|
|
251
253
|
const showRevealPasswordButton = type === "password" && !disableRevealPassword;
|
|
252
|
-
const handleClear = React.useCallback(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
const handleClear = React.useCallback(
|
|
255
|
+
(event) => {
|
|
256
|
+
setValidationState(validationStates.default.standBy);
|
|
257
|
+
changeInputValue(inputRef.current, "");
|
|
258
|
+
if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
|
|
259
|
+
else {
|
|
260
|
+
setTimeout(focusInput);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
[canShowSuggestions, setValidationState, suggestOnFocus]
|
|
264
|
+
);
|
|
257
265
|
const clearButton = React.useMemo(() => {
|
|
258
266
|
if (!showClear) {
|
|
259
267
|
return null;
|
|
@@ -455,6 +463,16 @@ const HvInput = React.forwardRef((props, ref) => {
|
|
|
455
463
|
ref: inputRef,
|
|
456
464
|
// prevent browsers auto-fill/suggestions when we have our own
|
|
457
465
|
autoComplete: canShowSuggestions ? "off" : void 0,
|
|
466
|
+
onFocus: (event) => {
|
|
467
|
+
inputProps.onFocus?.(event);
|
|
468
|
+
if (canShowSuggestions && suggestOnFocus) {
|
|
469
|
+
suggestionHandler(value);
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
onClick: (event) => {
|
|
473
|
+
inputProps.onClick?.(event);
|
|
474
|
+
if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
|
|
475
|
+
},
|
|
458
476
|
...inputProps
|
|
459
477
|
},
|
|
460
478
|
inputRef: forkedRef,
|
|
@@ -478,7 +496,8 @@ const HvInput = React.forwardRef((props, ref) => {
|
|
|
478
496
|
onClose: suggestionClearHandler,
|
|
479
497
|
onKeyDown: onSuggestionKeyDown,
|
|
480
498
|
onSuggestionSelected: suggestionSelectedHandler,
|
|
481
|
-
suggestionValues
|
|
499
|
+
suggestionValues,
|
|
500
|
+
enablePortal
|
|
482
501
|
}
|
|
483
502
|
)
|
|
484
503
|
] }),
|
|
@@ -3,6 +3,8 @@ import { forwardRef, useContext, useRef, useState, useEffect } from "react";
|
|
|
3
3
|
import { ClickAwayListener } from "@mui/base/ClickAwayListener";
|
|
4
4
|
import { Popper } from "@mui/base/Popper";
|
|
5
5
|
import { useForkRef } from "@mui/material/utils";
|
|
6
|
+
import { useTheme } from "@hitachivantara/uikit-react-utils";
|
|
7
|
+
import { getContainerElement } from "../../utils/document.js";
|
|
6
8
|
import { setId } from "../../utils/setId.js";
|
|
7
9
|
import { useClasses } from "./Suggestions.styles.js";
|
|
8
10
|
import { staticClasses } from "./Suggestions.styles.js";
|
|
@@ -15,6 +17,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
|
|
|
15
17
|
className,
|
|
16
18
|
classes: classesProp,
|
|
17
19
|
expanded = false,
|
|
20
|
+
enablePortal = false,
|
|
18
21
|
open: openProp,
|
|
19
22
|
anchorEl,
|
|
20
23
|
suggestionValues = [],
|
|
@@ -23,6 +26,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
|
|
|
23
26
|
...others
|
|
24
27
|
} = props;
|
|
25
28
|
const { classes, cx } = useClasses(classesProp);
|
|
29
|
+
const { rootId } = useTheme();
|
|
26
30
|
const { elementId } = useContext(HvFormElementContext);
|
|
27
31
|
const localId = id ?? setId(elementId, "suggestions");
|
|
28
32
|
const ref = useRef(null);
|
|
@@ -48,10 +52,17 @@ const HvSuggestions = forwardRef((props, extRef) => {
|
|
|
48
52
|
children: /* @__PURE__ */ jsx(
|
|
49
53
|
Popper,
|
|
50
54
|
{
|
|
55
|
+
style: {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
"--popper-width": enablePortal ? `${anchorEl?.clientWidth}px` : "100%"
|
|
58
|
+
},
|
|
51
59
|
open: openProp ?? isOpen,
|
|
52
|
-
disablePortal:
|
|
60
|
+
disablePortal: !enablePortal,
|
|
61
|
+
container: enablePortal ? getContainerElement(rootId) : void 0,
|
|
53
62
|
anchorEl,
|
|
54
|
-
className: classes.popper,
|
|
63
|
+
className: cx(classes.popper, {
|
|
64
|
+
[classes.portal]: enablePortal
|
|
65
|
+
}),
|
|
55
66
|
children: /* @__PURE__ */ jsx(
|
|
56
67
|
HvSelectionList,
|
|
57
68
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestions.js","sources":["../../../../src/Forms/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper
|
|
1
|
+
{"version":3,"file":"Suggestions.js","sources":["../../../../src/Forms/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { useTheme, type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvSelectionList } from \"../../SelectionList\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { getContainerElement } from \"../../utils/document\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../FormElement\";\nimport { staticClasses, useClasses } from \"./Suggestions.styles\";\n\nexport { staticClasses as suggestionsClasses };\n\nexport type HvSuggestionsClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSuggestion {\n id?: string;\n label: React.ReactNode;\n value?: string;\n disabled?: boolean;\n}\n\nexport interface HvSuggestionsProps extends HvBaseProps {\n /** Whether suggestions is visible */\n open?: boolean;\n /**\n * Whether suggestions is visible.\n * @deprecated use `open` instead.\n * */\n expanded?: boolean;\n /** The HTML element Suggestions attaches to. */\n anchorEl?: HTMLElement | null;\n /** Array of { id, label, ...others } values to display in the suggestion list */\n suggestionValues?: HvSuggestion[] | null;\n /** Function called when a suggestion is selected */\n onSuggestionSelected?: (event: React.MouseEvent, value: HvSuggestion) => void;\n /** Function called when suggestion list is closed */\n onClose?: ClickAwayListenerProps[\"onClickAway\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSuggestionsClasses;\n /**\n * If enabled, the suggestions list will be rendered using a portal.\n * If disabled, it will be under the DOM hierarchy of the parent component.\n * @default false\n * */\n enablePortal?: boolean;\n}\n\nexport const HvSuggestions = forwardRef((props: HvSuggestionsProps, extRef) => {\n const {\n id,\n className,\n classes: classesProp,\n expanded = false,\n enablePortal = false,\n open: openProp,\n anchorEl,\n suggestionValues = [],\n onClose,\n onSuggestionSelected,\n ...others\n } = props;\n\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const { elementId } = useContext(HvFormElementContext);\n const localId = id ?? setId(elementId, \"suggestions\");\n\n const ref = useRef<HTMLDivElement>(null);\n const forkedRef = useForkRef(ref, extRef);\n\n // TODO: remove controlled+uncontrolled `expanded` prop in v6\n const [isOpen, setIsOpen] = useState(expanded);\n useEffect(() => {\n setIsOpen(expanded);\n }, [expanded]);\n\n return (\n <div\n id={localId}\n ref={forkedRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <ClickAwayListener\n onClickAway={(event) => {\n setIsOpen(false);\n onClose?.(event);\n }}\n >\n <Popper\n style={{\n // @ts-ignore\n \"--popper-width\": enablePortal\n ? `${anchorEl?.clientWidth}px`\n : \"100%\",\n }}\n open={openProp ?? isOpen}\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={anchorEl}\n className={cx(classes.popper, {\n [classes.portal]: enablePortal,\n })}\n >\n <HvSelectionList\n className={classes.list}\n id={setId(localId, \"list\")}\n onChange={onSuggestionSelected}\n >\n {suggestionValues?.map((item) => (\n <HvListItem key={item.id} value={item} disabled={item.disabled}>\n {item.label}\n </HvListItem>\n ))}\n </HvSelectionList>\n </Popper>\n </ClickAwayListener>\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsDO,MAAM,gBAAgB,WAAW,CAAC,OAA2B,WAAW;AACvE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,eAAe;AAAA,IACf,MAAM;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACD,IAAA;AAEJ,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA,EAAE,WAAW;AAEnB,QAAM,EAAE,UAAA,IAAc,WAAW,oBAAoB;AACrD,QAAM,UAAU,MAAM,MAAM,WAAW,aAAa;AAE9C,QAAA,MAAM,OAAuB,IAAI;AACjC,QAAA,YAAY,WAAW,KAAK,MAAM;AAGxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,QAAQ;AAC7C,YAAU,MAAM;AACd,cAAU,QAAQ;AAAA,EAAA,GACjB,CAAC,QAAQ,CAAC;AAGX,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,MACpC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa,CAAC,UAAU;AACtB,sBAAU,KAAK;AACf,sBAAU,KAAK;AAAA,UACjB;AAAA,UAEA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA;AAAA,gBAEL,kBAAkB,eACd,GAAG,UAAU,WAAW,OACxB;AAAA,cACN;AAAA,cACA,MAAM,YAAY;AAAA,cAClB,eAAe,CAAC;AAAA,cAChB,WAAW,eAAe,oBAAoB,MAAM,IAAI;AAAA,cACxD;AAAA,cACA,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,MAAM,GAAG;AAAA,cAAA,CACnB;AAAA,cAED,UAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW,QAAQ;AAAA,kBACnB,IAAI,MAAM,SAAS,MAAM;AAAA,kBACzB,UAAU;AAAA,kBAET,UAAkB,kBAAA,IAAI,CAAC,6BACrB,YAAyB,EAAA,OAAO,MAAM,UAAU,KAAK,UACnD,UAAA,KAAK,SADS,KAAK,EAEtB,CACD;AAAA,gBAAA;AAAA,cACH;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
@@ -9,11 +9,14 @@ const { staticClasses, useClasses } = createClasses("HvSuggestions", {
|
|
|
9
9
|
width: "100%"
|
|
10
10
|
},
|
|
11
11
|
popper: {
|
|
12
|
-
width: "
|
|
12
|
+
width: "var(--popper-width)",
|
|
13
13
|
position: "absolute",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
zIndex: theme.zIndices.tooltip,
|
|
15
|
+
":not($portal)": {
|
|
16
|
+
transform: "translate3d(0, -1px, 0) !important"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
portal: {}
|
|
17
20
|
});
|
|
18
21
|
export {
|
|
19
22
|
staticClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/Forms/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"
|
|
1
|
+
{"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/Forms/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"var(--popper-width)\",\n position: \"absolute\",\n zIndex: theme.zIndices.tooltip,\n \":not($portal)\": {\n transform: \"translate3d(0, -1px, 0) !important\",\n },\n },\n portal: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,UAAU,WAAW;AAAA,EAC7B,MAAM;AAAA,IACJ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,WAAW,MAAM,OAAO;AAAA,IACxB,SAAS,MAAM,MAAM;AAAA,IACrB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ,MAAM,SAAS;AAAA,IACvB,iBAAiB;AAAA,MACf,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,QAAQ,CAAC;AACX,CAAC;"}
|
package/dist/esm/Input/Input.js
CHANGED
|
@@ -56,6 +56,8 @@ const HvInput = forwardRef((props, ref) => {
|
|
|
56
56
|
required = false,
|
|
57
57
|
readOnly = false,
|
|
58
58
|
disabled = false,
|
|
59
|
+
enablePortal = false,
|
|
60
|
+
suggestOnFocus = false,
|
|
59
61
|
label,
|
|
60
62
|
"aria-label": ariaLabel,
|
|
61
63
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -248,11 +250,17 @@ const HvInput = forwardRef((props, ref) => {
|
|
|
248
250
|
const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!hasOnEnter || type !== "search" || disableSearchButton || validationState$1 !== validationState.standBy);
|
|
249
251
|
const showSearchIcon = type === "search" && !disableSearchButton;
|
|
250
252
|
const showRevealPasswordButton = type === "password" && !disableRevealPassword;
|
|
251
|
-
const handleClear = useCallback(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
const handleClear = useCallback(
|
|
254
|
+
(event) => {
|
|
255
|
+
setValidationState(validationState.standBy);
|
|
256
|
+
changeInputValue(inputRef.current, "");
|
|
257
|
+
if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
|
|
258
|
+
else {
|
|
259
|
+
setTimeout(focusInput);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
[canShowSuggestions, setValidationState, suggestOnFocus]
|
|
263
|
+
);
|
|
256
264
|
const clearButton = useMemo(() => {
|
|
257
265
|
if (!showClear) {
|
|
258
266
|
return null;
|
|
@@ -454,6 +462,16 @@ const HvInput = forwardRef((props, ref) => {
|
|
|
454
462
|
ref: inputRef,
|
|
455
463
|
// prevent browsers auto-fill/suggestions when we have our own
|
|
456
464
|
autoComplete: canShowSuggestions ? "off" : void 0,
|
|
465
|
+
onFocus: (event) => {
|
|
466
|
+
inputProps.onFocus?.(event);
|
|
467
|
+
if (canShowSuggestions && suggestOnFocus) {
|
|
468
|
+
suggestionHandler(value);
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
onClick: (event) => {
|
|
472
|
+
inputProps.onClick?.(event);
|
|
473
|
+
if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
|
|
474
|
+
},
|
|
457
475
|
...inputProps
|
|
458
476
|
},
|
|
459
477
|
inputRef: forkedRef,
|
|
@@ -477,7 +495,8 @@ const HvInput = forwardRef((props, ref) => {
|
|
|
477
495
|
onClose: suggestionClearHandler,
|
|
478
496
|
onKeyDown: onSuggestionKeyDown,
|
|
479
497
|
onSuggestionSelected: suggestionSelectedHandler,
|
|
480
|
-
suggestionValues
|
|
498
|
+
suggestionValues,
|
|
499
|
+
enablePortal
|
|
481
500
|
}
|
|
482
501
|
)
|
|
483
502
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {\n CloseXS,\n Preview,\n PreviewOff,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n computeValidationMessage,\n computeValidationState,\n computeValidationType,\n DEFAULT_ERROR_MESSAGES,\n hasBuiltInValidations,\n HvInputValidity,\n validateInput,\n} from \"../BaseInput/validations\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isInvalid,\n isValid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { HvInputSuggestion, HvValidationMessages } from \"../types/forms\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string,\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity,\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string,\n ) => void;\n /** The input type. */\n type?: React.HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & Record<string, any>;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** The label of the clear button. */\n clearButtonLabel: \"Clear the text\",\n /** The label of the reveal password button. */\n revealPasswordButtonLabel: \"Reveal password\",\n /** The tooltip of the reveal password button when the password is hidden. */\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n /** The tooltip of the reveal password button when the password is revealed. */\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n /** The label of the search button. */\n searchButtonLabel: \"Search\",\n};\n\nexport type HvInputLabels = Partial<typeof DEFAULT_LABELS>;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: React.FocusEvent<any>,\n) {\n return !!container?.contains(event.relatedTarget);\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\",\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy,\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ],\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation,\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages),\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps,\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\",\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(() => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }, [setValidationState]);\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value],\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx],\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className,\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n />\n </>\n )}\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["validationState","validationStates"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4LA,MAAM,iBAAiB;AAAA;AAAA,EAErB,kBAAkB;AAAA;AAAA,EAElB,2BAA2B;AAAA;AAAA,EAE3B,wCAAwC;AAAA;AAAA,EAExC,wCAAwC;AAAA;AAAA,EAExC,mBAAmB;AACrB;AAIA,SAAS,6BACP,WACA,OACA;AACA,SAAO,CAAC,CAAC,WAAW,SAAS,MAAM,aAAa;AAClD;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAU,WAAuC,CAAC,OAAO,QAAQ;AACtE,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,I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AiB,qBACb,MAAM,WAAW,aAAa,IAC9B;AAAA,cAEJ,KAAK;AAAA;AAAA,cAGL,cAAc,qBAAqB,QAAQ;AAAA,cAE3C,GAAG;AAAA,YACL;AAAA,YACA,UAAU;AAAA,YACV,cAAc;AAAA,YACb,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,sBAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAA,sCACE,OAAI,EAAA,MAAK,gBAAe,WAAW,QAAQ,gBAAgB;AAAA,UAE9D;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,IAAI,MAAM,WAAW,aAAa;AAAA,cAClC,SAAS;AAAA,gBACP,MAAM,QAAQ;AAAA,gBACd,MAAM,QAAQ;AAAA,cAChB;AAAA,cACA,UAAU;AAAA,cACV,UAAU,SAAS,SAAS;AAAA,cAC5B,SAAS;AAAA,cACT,WAAW;AAAA,cACX,sBAAsB;AAAA,cACtB;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAED,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {\n CloseXS,\n Preview,\n PreviewOff,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n computeValidationMessage,\n computeValidationState,\n computeValidationType,\n DEFAULT_ERROR_MESSAGES,\n hasBuiltInValidations,\n HvInputValidity,\n validateInput,\n} from \"../BaseInput/validations\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isInvalid,\n isValid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { HvInputSuggestion, HvValidationMessages } from \"../types/forms\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string,\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity,\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string,\n ) => void;\n /** The input type. */\n type?: React.HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & Record<string, any>;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * If enabled, the suggestions list will be rendered using a portal.\n * If disabled, it will be under the DOM hierarchy of the parent component.\n * @default false\n * */\n enablePortal?: boolean;\n /**\n * Whether the suggestions should be triggered once the input is focused and not only when typing.\n * @default false\n * */\n suggestOnFocus?: boolean;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean; // TODO - rename in v6 since it doesn't disable but hides the button\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** The label of the clear button. */\n clearButtonLabel: \"Clear the text\",\n /** The label of the reveal password button. */\n revealPasswordButtonLabel: \"Reveal password\",\n /** The tooltip of the reveal password button when the password is hidden. */\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n /** The tooltip of the reveal password button when the password is revealed. */\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n /** The label of the search button. */\n searchButtonLabel: \"Search\",\n};\n\nexport type HvInputLabels = Partial<typeof DEFAULT_LABELS>;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: React.FocusEvent<any>,\n) {\n return !!container?.contains(event.relatedTarget);\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\",\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n enablePortal = false,\n suggestOnFocus = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy,\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ],\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation,\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages),\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps,\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\",\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // prevent triggering the suggestions when clicking on the clear button when suggestOnFocus is true\n if (canShowSuggestions && suggestOnFocus) event.stopPropagation();\n else {\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }\n },\n [canShowSuggestions, setValidationState, suggestOnFocus],\n );\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value],\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx],\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className,\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n onFocus: (event) => {\n inputProps.onFocus?.(event);\n\n // trigger suggestions when focusing the input\n if (canShowSuggestions && suggestOnFocus) {\n suggestionHandler(value);\n }\n },\n\n onClick: (event) => {\n inputProps.onClick?.(event);\n\n // prevent closing the suggestions when clicking on the input when suggestOnFocus is true\n if (canShowSuggestions && suggestOnFocus) event.stopPropagation();\n },\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n enablePortal={enablePortal}\n />\n </>\n )}\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["validationState","validationStates"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuMA,MAAM,iBAAiB;AAAA;AAAA,EAErB,kBAAkB;AAAA;AAAA,EAElB,2BAA2B;AAAA;AAAA,EAE3B,wCAAwC;AAAA;AAAA,EAExC,wCAAwC;AAAA;AAAA,EAExC,mBAAmB;AACrB;AAIA,SAAS,6BACP,WACA,OACA;AACA,SAAO,CAAC,CAAC,WAAW,SAAS,MAAM,aAAa;AAClD;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAU,WAAuC,CAAC,OAAO,QAAQ;AACtE,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,eAAe;AAAA,I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AW,aAAa,IAC9B;AAAA,cACR,iBAAiB,qBACb,MAAM,WAAW,aAAa,IAC9B;AAAA,cAEJ,KAAK;AAAA;AAAA,cAGL,cAAc,qBAAqB,QAAQ;AAAA,cAE3C,SAAS,CAAC,UAAU;AAClB,2BAAW,UAAU,KAAK;AAG1B,oBAAI,sBAAsB,gBAAgB;AACxC,oCAAkB,KAAK;AAAA,gBACzB;AAAA,cACF;AAAA,cAEA,SAAS,CAAC,UAAU;AAClB,2BAAW,UAAU,KAAK;AAGtB,oBAAA,sBAAsB,eAAgB,OAAM,gBAAgB;AAAA,cAClE;AAAA,cAEA,GAAG;AAAA,YACL;AAAA,YACA,UAAU;AAAA,YACV,cAAc;AAAA,YACb,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,sBAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAA,sCACE,OAAI,EAAA,MAAK,gBAAe,WAAW,QAAQ,gBAAgB;AAAA,UAE9D;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,IAAI,MAAM,WAAW,aAAa;AAAA,cAClC,SAAS;AAAA,gBACP,MAAM,QAAQ;AAAA,gBACd,MAAM,QAAQ;AAAA,cAChB;AAAA,cACA,UAAU;AAAA,cACV,UAAU,SAAS,SAAS;AAAA,cAC5B,SAAS;AAAA,cACT,WAAW;AAAA,cACX,sBAAsB;AAAA,cACtB;AAAA,cACA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAED,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4324,6 +4324,17 @@ export declare interface HvInputProps extends HvBaseProps<HTMLElement, "onChange
|
|
|
4324
4324
|
inputRef?: HvBaseInputProps["inputRef"];
|
|
4325
4325
|
/** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */
|
|
4326
4326
|
suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;
|
|
4327
|
+
/**
|
|
4328
|
+
* If enabled, the suggestions list will be rendered using a portal.
|
|
4329
|
+
* If disabled, it will be under the DOM hierarchy of the parent component.
|
|
4330
|
+
* @default false
|
|
4331
|
+
* */
|
|
4332
|
+
enablePortal?: boolean;
|
|
4333
|
+
/**
|
|
4334
|
+
* Whether the suggestions should be triggered once the input is focused and not only when typing.
|
|
4335
|
+
* @default false
|
|
4336
|
+
* */
|
|
4337
|
+
suggestOnFocus?: boolean;
|
|
4327
4338
|
/**
|
|
4328
4339
|
* The custom validation function, it receives the value and must return
|
|
4329
4340
|
* either `true` for valid or `false` for invalid, default validations would only
|
|
@@ -6049,7 +6060,10 @@ export declare type HvSuggestionsClasses = ExtractNames<typeof useClasses_17>;
|
|
|
6049
6060
|
export declare interface HvSuggestionsProps extends HvBaseProps {
|
|
6050
6061
|
/** Whether suggestions is visible */
|
|
6051
6062
|
open?: boolean;
|
|
6052
|
-
/**
|
|
6063
|
+
/**
|
|
6064
|
+
* Whether suggestions is visible.
|
|
6065
|
+
* @deprecated use `open` instead.
|
|
6066
|
+
* */
|
|
6053
6067
|
expanded?: boolean;
|
|
6054
6068
|
/** The HTML element Suggestions attaches to. */
|
|
6055
6069
|
anchorEl?: HTMLElement | null;
|
|
@@ -6061,6 +6075,12 @@ export declare interface HvSuggestionsProps extends HvBaseProps {
|
|
|
6061
6075
|
onClose?: ClickAwayListenerProps["onClickAway"];
|
|
6062
6076
|
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
6063
6077
|
classes?: HvSuggestionsClasses;
|
|
6078
|
+
/**
|
|
6079
|
+
* If enabled, the suggestions list will be rendered using a portal.
|
|
6080
|
+
* If disabled, it will be under the DOM hierarchy of the parent component.
|
|
6081
|
+
* @default false
|
|
6082
|
+
* */
|
|
6083
|
+
enablePortal?: boolean;
|
|
6064
6084
|
}
|
|
6065
6085
|
|
|
6066
6086
|
export { HvSupportColor }
|
|
@@ -8035,6 +8055,7 @@ export declare const suggestionsClasses: {
|
|
|
8035
8055
|
root: string;
|
|
8036
8056
|
list: string;
|
|
8037
8057
|
popper: string;
|
|
8058
|
+
portal: string;
|
|
8038
8059
|
};
|
|
8039
8060
|
|
|
8040
8061
|
export declare const switchClasses: {
|
|
@@ -8936,11 +8957,12 @@ declare const useClasses_16: (classesProp?: Partial<Record<"vertical" | "horizon
|
|
|
8936
8957
|
readonly cx: (...args: any) => string;
|
|
8937
8958
|
};
|
|
8938
8959
|
|
|
8939
|
-
declare const useClasses_17: (classesProp?: Partial<Record<"root" | "list" | "popper", string>>, addStatic?: boolean) => {
|
|
8960
|
+
declare const useClasses_17: (classesProp?: Partial<Record<"root" | "list" | "popper" | "portal", string>>, addStatic?: boolean) => {
|
|
8940
8961
|
readonly classes: {
|
|
8941
8962
|
root: string;
|
|
8942
8963
|
list: string;
|
|
8943
8964
|
popper: string;
|
|
8965
|
+
portal: string;
|
|
8944
8966
|
};
|
|
8945
8967
|
readonly css: any;
|
|
8946
8968
|
readonly cx: (...args: any) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.77.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"access": "public",
|
|
63
63
|
"directory": "package"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "15e4e3ff8298e486aa40ba892487db442976e925",
|
|
66
66
|
"exports": {
|
|
67
67
|
".": {
|
|
68
68
|
"types": "./dist/types/index.d.ts",
|