@hitachivantara/uikit-react-core 5.67.0 → 5.67.1
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/InlineEditor/InlineEditor.cjs +4 -2
- package/dist/cjs/TagsInput/TagsInput.cjs +5 -7
- package/dist/esm/InlineEditor/InlineEditor.js +4 -2
- package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/TagsInput/TagsInput.js +5 -7
- package/dist/esm/TagsInput/TagsInput.js.map +1 -1
- package/dist/types/index.d.ts +35 -36
- package/package.json +3 -3
|
@@ -6,12 +6,13 @@ const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
|
6
6
|
const uikitReactShared = require("@hitachivantara/uikit-react-shared");
|
|
7
7
|
const useControlled = require("../hooks/useControlled.cjs");
|
|
8
8
|
const useDefaultProps = require("../hooks/useDefaultProps.cjs");
|
|
9
|
+
const generic = require("../types/generic.cjs");
|
|
9
10
|
const keyboardUtils = require("../utils/keyboardUtils.cjs");
|
|
10
11
|
const InlineEditor_styles = require("./InlineEditor.styles.cjs");
|
|
11
12
|
const Button = require("../Button/Button.cjs");
|
|
12
13
|
const Input = require("../Input/Input.cjs");
|
|
13
14
|
const Typography = require("../Typography/Typography.cjs");
|
|
14
|
-
const HvInlineEditor = (props)
|
|
15
|
+
const HvInlineEditor = generic.fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
15
16
|
const {
|
|
16
17
|
className,
|
|
17
18
|
classes: classesProp,
|
|
@@ -68,6 +69,7 @@ const HvInlineEditor = (props) => {
|
|
|
68
69
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx(classes.root, className), children: editMode && !disabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
69
70
|
InputComponent,
|
|
70
71
|
{
|
|
72
|
+
ref,
|
|
71
73
|
inputRef,
|
|
72
74
|
classes: {
|
|
73
75
|
root: classes.inputRoot,
|
|
@@ -118,6 +120,6 @@ const HvInlineEditor = (props) => {
|
|
|
118
120
|
)
|
|
119
121
|
}
|
|
120
122
|
) });
|
|
121
|
-
};
|
|
123
|
+
});
|
|
122
124
|
exports.inlineEditorClasses = InlineEditor_styles.staticClasses;
|
|
123
125
|
exports.HvInlineEditor = HvInlineEditor;
|
|
@@ -50,10 +50,9 @@ const HvTagsInput = React.forwardRef(
|
|
|
50
50
|
hideCounter = false,
|
|
51
51
|
middleCountLabel = "/",
|
|
52
52
|
maxTagsQuantity,
|
|
53
|
-
autoFocus = false,
|
|
54
53
|
resizable = true,
|
|
55
|
-
inputProps
|
|
56
|
-
countCharProps
|
|
54
|
+
inputProps,
|
|
55
|
+
countCharProps,
|
|
57
56
|
multiline = false,
|
|
58
57
|
status,
|
|
59
58
|
statusMessage,
|
|
@@ -158,7 +157,7 @@ const HvTagsInput = React.forwardRef(
|
|
|
158
157
|
const container = containerRef.current;
|
|
159
158
|
if (container == null) return;
|
|
160
159
|
container.scrollLeft = element ? element.offsetLeft - container.getBoundingClientRect().width / 2 + element.getBoundingClientRect().width / 2 : 0;
|
|
161
|
-
},
|
|
160
|
+
}, 10);
|
|
162
161
|
element?.focus();
|
|
163
162
|
}
|
|
164
163
|
}, [multiline, tagCursorPos]);
|
|
@@ -302,7 +301,7 @@ const HvTagsInput = React.forwardRef(
|
|
|
302
301
|
addTag(evt, tagInput);
|
|
303
302
|
}
|
|
304
303
|
onBlur?.(evt, tagInput);
|
|
305
|
-
},
|
|
304
|
+
}, 10);
|
|
306
305
|
};
|
|
307
306
|
const onFocusHandler = (evt) => {
|
|
308
307
|
clearTimeout(blurTimeout.current);
|
|
@@ -435,7 +434,6 @@ const HvTagsInput = React.forwardRef(
|
|
|
435
434
|
onChange: onChangeHandler,
|
|
436
435
|
onKeyDown: onInputKeyDownHandler,
|
|
437
436
|
placeholder: value.length === 0 ? placeholder : "",
|
|
438
|
-
autoFocus,
|
|
439
437
|
className: cx({
|
|
440
438
|
[classes.singleLine]: !multiline
|
|
441
439
|
}),
|
|
@@ -454,7 +452,7 @@ const HvTagsInput = React.forwardRef(
|
|
|
454
452
|
"aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description && setId.setId(elementId, "description") || void 0,
|
|
455
453
|
...inputProps
|
|
456
454
|
},
|
|
457
|
-
inputRef,
|
|
455
|
+
ref: inputRef,
|
|
458
456
|
...others
|
|
459
457
|
}
|
|
460
458
|
)
|
|
@@ -4,13 +4,14 @@ import { Edit } from "@hitachivantara/uikit-react-icons";
|
|
|
4
4
|
import { useTheme } from "@hitachivantara/uikit-react-shared";
|
|
5
5
|
import { useControlled } from "../hooks/useControlled.js";
|
|
6
6
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
7
|
+
import { fixedForwardRef } from "../types/generic.js";
|
|
7
8
|
import { isKey } from "../utils/keyboardUtils.js";
|
|
8
9
|
import { useClasses } from "./InlineEditor.styles.js";
|
|
9
10
|
import { staticClasses } from "./InlineEditor.styles.js";
|
|
10
11
|
import { HvButton } from "../Button/Button.js";
|
|
11
12
|
import { HvInput } from "../Input/Input.js";
|
|
12
13
|
import { HvTypography } from "../Typography/Typography.js";
|
|
13
|
-
const HvInlineEditor = (props)
|
|
14
|
+
const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
14
15
|
const {
|
|
15
16
|
className,
|
|
16
17
|
classes: classesProp,
|
|
@@ -67,6 +68,7 @@ const HvInlineEditor = (props) => {
|
|
|
67
68
|
return /* @__PURE__ */ jsx("div", { className: cx(classes.root, className), children: editMode && !disabled ? /* @__PURE__ */ jsx(
|
|
68
69
|
InputComponent,
|
|
69
70
|
{
|
|
71
|
+
ref,
|
|
70
72
|
inputRef,
|
|
71
73
|
classes: {
|
|
72
74
|
root: classes.inputRoot,
|
|
@@ -117,7 +119,7 @@ const HvInlineEditor = (props) => {
|
|
|
117
119
|
)
|
|
118
120
|
}
|
|
119
121
|
) });
|
|
120
|
-
};
|
|
122
|
+
});
|
|
121
123
|
export {
|
|
122
124
|
HvInlineEditor,
|
|
123
125
|
staticClasses as inlineEditorClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport { useTheme } from \"@hitachivantara/uikit-react-shared\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport {
|
|
1
|
+
{"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport { useTheme } from \"@hitachivantara/uikit-react-shared\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n HvTypography,\n HvTypographyProps,\n HvTypographyVariants,\n} from \"../Typography\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./InlineEditor.styles\";\n\nexport { staticClasses as inlineEditorClasses };\n\nexport type HvInlineEditorClasses = ExtractNames<typeof useClasses>;\n\nexport type HvInlineEditorProps<C extends React.ElementType = typeof HvInput> =\n PolymorphicComponentRef<\n C,\n {\n /** The value of the form element. */\n value?: string;\n /** The default value of the form element. */\n defaultValue?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string,\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** Whether the editor is disabled or not. */\n disabled?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n /** The placeholder value of the input. */\n placeholder?: string;\n }\n >;\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = fixedForwardRef(function HvInlineEditor<\n C extends React.ElementType = typeof HvInput,\n>(props: HvInlineEditorProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n classes: classesProp,\n value: valueProp,\n defaultValue = \"\",\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n disabled,\n ...others\n } = useDefaultProps(\"HvInlineEditor\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n const { activeTheme } = useTheme();\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur: HvInputProps[\"onBlur\"] = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown: HvInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event as any);\n };\n\n const handleChange: HvInputProps[\"onChange\"] = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <div className={cx(classes.root, className)}>\n {editMode && !disabled ? (\n <InputComponent\n ref={ref}\n inputRef={inputRef}\n classes={{\n root: classes.inputRoot,\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n endIcon={\n <Edit\n color=\"secondary_60\"\n className={cx(classes.icon, {\n [classes.iconVisible]: showIcon,\n })}\n />\n }\n className={cx(classes.button, {\n [classes.largeText]: parseInt(lineHeight as string, 10) >= 28,\n })}\n onClick={handleClick}\n disabled={disabled}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n </HvButton>\n )}\n </div>\n );\n});\n"],"names":["HvInlineEditor"],"mappings":";;;;;;;;;;;;;AA8DO,MAAM,iBAAiB,gBAAgB,SAASA,gBAErD,OAA+B,KAAwB;AACjD,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,OAAO;AAAA,IACP,eAAe;AAAA,IACf;AAAA,IACA,WAAW,iBAAiB;AAAA,IAC5B,UAAU;AAAA,IACV,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,kBAAkB,KAAK;AAE3C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAI,cAAc,WAAW,YAAY;AAC/D,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,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;AAAA,EAAA,IAGN;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,oBAAoB;AAAA,MACpB,SACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,WAAW,GAAG,QAAQ,MAAM;AAAA,YAC1B,CAAC,QAAQ,WAAW,GAAG;AAAA,UAAA,CACxB;AAAA,QAAA;AAAA,MACH;AAAA,MAEF,WAAW,GAAG,QAAQ,QAAQ;AAAA,QAC5B,CAAC,QAAQ,SAAS,GAAG,SAAS,YAAsB,EAAE,KAAK;AAAA,MAAA,CAC5D;AAAA,MACD,SAAS;AAAA,MACT;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,QAAM;AAAA,UACN,WAAW,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,SAAS,GAAG,CAAC,OAAO;AAAA,UAC1D,GAAG;AAAA,UAEH,UAAS,SAAA;AAAA,QAAA;AAAA,MACZ;AAAA,IAAA;AAAA,EAGN,EAAA,CAAA;AAEJ,CAAC;"}
|
|
@@ -49,10 +49,9 @@ const HvTagsInput = forwardRef(
|
|
|
49
49
|
hideCounter = false,
|
|
50
50
|
middleCountLabel = "/",
|
|
51
51
|
maxTagsQuantity,
|
|
52
|
-
autoFocus = false,
|
|
53
52
|
resizable = true,
|
|
54
|
-
inputProps
|
|
55
|
-
countCharProps
|
|
53
|
+
inputProps,
|
|
54
|
+
countCharProps,
|
|
56
55
|
multiline = false,
|
|
57
56
|
status,
|
|
58
57
|
statusMessage,
|
|
@@ -157,7 +156,7 @@ const HvTagsInput = forwardRef(
|
|
|
157
156
|
const container = containerRef.current;
|
|
158
157
|
if (container == null) return;
|
|
159
158
|
container.scrollLeft = element ? element.offsetLeft - container.getBoundingClientRect().width / 2 + element.getBoundingClientRect().width / 2 : 0;
|
|
160
|
-
},
|
|
159
|
+
}, 10);
|
|
161
160
|
element?.focus();
|
|
162
161
|
}
|
|
163
162
|
}, [multiline, tagCursorPos]);
|
|
@@ -301,7 +300,7 @@ const HvTagsInput = forwardRef(
|
|
|
301
300
|
addTag(evt, tagInput);
|
|
302
301
|
}
|
|
303
302
|
onBlur?.(evt, tagInput);
|
|
304
|
-
},
|
|
303
|
+
}, 10);
|
|
305
304
|
};
|
|
306
305
|
const onFocusHandler = (evt) => {
|
|
307
306
|
clearTimeout(blurTimeout.current);
|
|
@@ -434,7 +433,6 @@ const HvTagsInput = forwardRef(
|
|
|
434
433
|
onChange: onChangeHandler,
|
|
435
434
|
onKeyDown: onInputKeyDownHandler,
|
|
436
435
|
placeholder: value.length === 0 ? placeholder : "",
|
|
437
|
-
autoFocus,
|
|
438
436
|
className: cx({
|
|
439
437
|
[classes.singleLine]: !multiline
|
|
440
438
|
}),
|
|
@@ -453,7 +451,7 @@ const HvTagsInput = forwardRef(
|
|
|
453
451
|
"aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description && setId(elementId, "description") || void 0,
|
|
454
452
|
...inputProps
|
|
455
453
|
},
|
|
456
|
-
inputRef,
|
|
454
|
+
ref: inputRef,
|
|
457
455
|
...others
|
|
458
456
|
}
|
|
459
457
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsInput.js","sources":["../../../src/TagsInput/TagsInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\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 { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { baseInputClasses } from \"../BaseInput\";\nimport { DEFAULT_ERROR_MESSAGES } from \"../BaseInput/validations\";\nimport {\n HvCharCounter,\n HvCharCounterProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvInput } from \"../Input\";\nimport { HvListContainer, HvListItem } from \"../ListContainer\";\nimport { HvTag, HvTagProps } from \"../Tag\";\nimport { HvTagSuggestion, HvValidationMessages } from \"../types/forms\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./TagsInput.styles\";\n\nexport { staticClasses as tagsInputClasses };\n\nexport type HvTagsInputClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagsInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\" | \"defaultValue\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string[] | HvTagProps[];\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string[] | HvTagProps[];\n /**\n * The label of the form element.\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 the form element is required. */\n required?: boolean;\n /** The function that will be executed onChange. */\n onChange?: (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n value: HvTagProps[],\n ) => void;\n /** The function that will be executed when the element is focused. */\n onFocus?: (event: React.FocusEvent<HTMLDivElement>, value: string) => void;\n /** The function that will be executed when the element is blurred. */\n onBlur?: (event: React.FocusEvent<HTMLDivElement>, value: string) => void;\n /** The function that will be executed when a tag is deleted. */\n onDelete?: (\n event:\n | React.KeyboardEvent<HTMLUListElement>\n | React.MouseEvent<HTMLElement>,\n value: HvTagProps,\n index: number,\n ) => void;\n /** The function that will be executed when a tag is added. */\n onAdd?: (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n value: HvTagProps,\n index: number,\n ) => void;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** If `true` the character counter isn't shown even if maxTagsQuantity is set. */\n hideCounter?: boolean;\n /** Text between the current char counter and max value. */\n middleCountLabel?: string;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxTagsQuantity?: number;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the component is resizable. */\n resizable?: boolean;\n /** Props passed to the HvCharCount component. */\n countCharProps?: Partial<HvCharCounterProps>;\n /** If `true` the component is in multiline mode. */\n multiline?: boolean;\n /** The status of the form element. */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: React.ReactNode;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** An array of strings that represent the character used to input a tag. This character is the string representation of the event.code from the input event. */\n commitTagOn?: string[];\n /** If `true` the tag will be committed when the blur event occurs. */\n commitOnBlur?: boolean;\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestions. */\n suggestionListCallback?: (value: string) => HvTagSuggestion[] | null;\n /** The validation function that will be executed when adding tags in the suggestions mode. */\n suggestionValidation?: (value: string) => boolean;\n /** When in suggestions mode, this property indicates that tags that are not present on the suggestions list can also be added. */\n suggestionsLoose?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagsInputClasses;\n}\n\n/**\n * A tags input is a single or multiline control that allows the input of tags.\n */\nexport const HvTagsInput = forwardRef<HTMLUListElement, HvTagsInputProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = [],\n readOnly = false,\n disabled = false,\n required = false,\n label: textAreaLabel,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onAdd,\n onDelete,\n onBlur,\n onFocus,\n placeholder,\n hideCounter = false,\n middleCountLabel = \"/\",\n maxTagsQuantity,\n autoFocus = false,\n resizable = true,\n inputProps = {},\n countCharProps = {},\n multiline = false,\n status,\n statusMessage,\n validationMessages,\n commitTagOn = [\"Enter\"],\n commitOnBlur = false,\n suggestionListCallback,\n suggestionValidation,\n suggestionsLoose = false,\n ...others\n } = useDefaultProps(\"HvTagsInput\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const hasLabel = textAreaLabel != null;\n const hasDescription = description != null;\n\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n const [tagInput, setTagInput] = useState(\"\");\n const [tagCursorPos, setTagCursorPos] = useState(value.length);\n const [stateValid, setStateValid] = useState(true);\n\n const inputRef = useRef<any>();\n const containerRef = useRef<any>();\n const skipReset = useRef(false);\n const blurTimeout = useRef<any>();\n const materialInputRef = useRef<any>(null);\n\n const forkedContainerRef = useForkRef(ref, containerRef);\n\n const isTagSelected = tagCursorPos >= 0 && tagCursorPos < value.length;\n const hasCounter = maxTagsQuantity != null && !hideCounter;\n\n // suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvTagSuggestion[] | null\n >(null);\n\n const isStateInvalid = useMemo(() => {\n return hasCounter && value.length > maxTagsQuantity;\n }, [hasCounter, maxTagsQuantity, value.length]);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n [validationMessages],\n );\n\n const performValidation = useCallback(\n (currValue: HvTagProps[]) => {\n if (\n maxTagsQuantity !== null &&\n maxTagsQuantity !== undefined &&\n currValue.length > maxTagsQuantity\n ) {\n setValidationState(validationStates.invalid);\n setValidationMessage(errorMessages.maxCharError);\n setStateValid(false);\n } else {\n setValidationState(validationStates.valid);\n setValidationMessage(\"\");\n setStateValid(true);\n }\n },\n [\n errorMessages.maxCharError,\n maxTagsQuantity,\n setValidationMessage,\n setValidationState,\n ],\n );\n\n /**\n * Deletes a Tag from the array of tags and sets the new position for the tag cursor.\n * Also executes the user provided onDelete and onChange events.\n *\n * @param {number} tagPos - the position at which to remove the tag\n * @param {Event} event - the event associated with the delete\n * @param {boolean} end - whether or not to set the cursor at the end of the array\n */\n const deleteTag = useCallback(\n (\n tagPos: number,\n event:\n | React.KeyboardEvent<HTMLUListElement>\n | React.MouseEvent<HTMLElement>,\n end: boolean,\n ) => {\n const newTagsArr = [\n ...value.slice(0, tagPos),\n ...value.slice(tagPos + 1),\n ] as HvTagProps[];\n setValue(newTagsArr);\n setTagCursorPos(\n end ? newTagsArr.length : tagCursorPos > 0 ? tagCursorPos - 1 : 0,\n );\n inputRef.current?.focus();\n performValidation(newTagsArr);\n onDelete?.(event, value[tagPos] as HvTagProps, tagPos);\n onChange?.(event, newTagsArr);\n skipReset.current = true;\n },\n [onChange, onDelete, performValidation, setValue, tagCursorPos, value],\n );\n\n /**\n * Adds a Tag to the array of tags.\n * Also executes the user provided onAdd and onDelete events.\n *\n * @param {Event} event - whatever event triggered adding a tag\n * @param {string} tag - the string for the tag\n */\n const addTag = useCallback(\n (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n tag: React.ReactNode,\n ) => {\n event.preventDefault();\n if (tag !== \"\") {\n const newTag: HvTagProps = { label: tag, type: \"semantic\" };\n const newTagsArr = [...value, newTag] as HvTagProps[];\n setValue(newTagsArr);\n performValidation(newTagsArr);\n onAdd?.(event, newTag, newTagsArr.length - 1);\n onChange?.(event, newTagsArr);\n }\n },\n [onAdd, onChange, performValidation, setValue, value],\n );\n\n const canShowError =\n (status !== undefined &&\n status === \"invalid\" &&\n statusMessage !== undefined) ||\n !stateValid;\n\n useEffect(() => {\n if (!multiline) {\n const element = containerRef?.current?.children[tagCursorPos];\n // this setTimeout is a workaround for Firefox not properly dealing\n // with setting the scrollLeft value.\n setTimeout(() => {\n const container = containerRef.current;\n if (container == null) return;\n container.scrollLeft = element\n ? element.offsetLeft -\n container.getBoundingClientRect().width / 2 +\n element.getBoundingClientRect().width / 2\n : 0;\n }, 50);\n\n element?.focus();\n }\n }, [multiline, tagCursorPos]);\n\n useEffect(() => {\n if (!skipReset.current) {\n setTagInput(\"\");\n setTagCursorPos(value.length);\n }\n skipReset.current = false;\n }, [value]);\n\n const isMounted = useIsMounted();\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n materialInputRef.current.focus();\n };\n\n const getSuggestions = useCallback(\n (li: number) => {\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 [elementId],\n );\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = useCallback(() => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n }, [isMounted]);\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = useCallback(\n (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n },\n [suggestionClearHandler, suggestionListCallback],\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 addTag(event, item.value || item.label);\n\n // set the input value (only when value is uncontrolled)\n setTagInput((item.value || item.label) as string); // TODO - in v6 review all types: this is not a string but a React.ReactNode\n\n focusInput();\n suggestionClearHandler();\n };\n\n /**\n * Handler for the `onKeyDown` event on the suggestions component\n */\n const onSuggestionKeyDown = (\n event: React.KeyboardEvent<HTMLDivElement>,\n ) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /**\n * Handler for the `onChange` event on the tag input\n */\n const onChangeHandler = useCallback(\n (\n event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,\n input: string,\n ) => {\n setTagInput(input);\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(input);\n }\n },\n [canShowSuggestions, suggestionHandler],\n );\n\n /**\n * Handler for the `onKeyDown` event on the form element\n */\n const onInputKeyDownHandler = useCallback(\n (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent,\n ) => {\n if (!canShowSuggestions && commitTagOn.includes((event as any).code)) {\n addTag(event, tagInput);\n }\n },\n [addTag, canShowSuggestions, commitTagOn, tagInput],\n );\n\n /**\n * Handler for the `onKeyDown` event on the list container.\n */\n const onKeyDownHandler = useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (tagInput === \"\") {\n switch (event.code) {\n case \"ArrowLeft\":\n setTagCursorPos(tagCursorPos > 0 ? tagCursorPos - 1 : 0);\n break;\n case \"ArrowRight\":\n setTagCursorPos(\n tagCursorPos < value.length ? tagCursorPos + 1 : value.length,\n );\n break;\n case \"Backspace\":\n if (isTagSelected) {\n deleteTag(tagCursorPos, event, false);\n } else {\n setTagCursorPos(value.length - 1);\n }\n break;\n case \"Delete\":\n if (isTagSelected) {\n deleteTag(tagCursorPos, event, false);\n }\n break;\n default:\n break;\n }\n } else {\n switch (event.code) {\n case \"ArrowDown\":\n getSuggestions(0)?.focus();\n break;\n case \"Enter\":\n if (\n canShowSuggestions &&\n suggestionsLoose &&\n (suggestionValidation?.(tagInput) || !suggestionValidation)\n ) {\n addTag(event, tagInput);\n\n // set the input value (only when value is uncontrolled)\n setTagInput(tagInput);\n\n focusInput();\n suggestionClearHandler();\n }\n break;\n default:\n break;\n }\n }\n },\n [\n addTag,\n canShowSuggestions,\n deleteTag,\n getSuggestions,\n isTagSelected,\n suggestionClearHandler,\n suggestionValidation,\n suggestionsLoose,\n tagCursorPos,\n tagInput,\n value.length,\n ],\n );\n\n /**\n * Handler for the `onDelete` event on the tag component\n */\n const onDeleteTagHandler = useCallback(\n (event: React.MouseEvent<HTMLElement>, i: number) => {\n deleteTag(i, event, true);\n setValidationState(validationStates.standBy);\n },\n [deleteTag, setValidationState],\n );\n\n /**\n * Handler for the `onClick` event on the list container\n */\n const onContainerClickHandler = useCallback(() => {\n inputRef.current?.focus();\n clearTimeout(blurTimeout.current);\n setTagCursorPos(value.length);\n }, [value.length]);\n\n const onBlurHandler: HvFormElementProps[\"onBlur\"] = (evt) => {\n blurTimeout.current = setTimeout(() => {\n if (commitOnBlur) {\n addTag(evt, tagInput);\n }\n onBlur?.(evt, tagInput);\n }, 250);\n };\n\n const onFocusHandler: HvFormElementProps[\"onFocus\"] = (evt) => {\n clearTimeout(blurTimeout.current);\n onFocus?.(evt, tagInput);\n };\n\n return (\n <HvFormElement\n id={id}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n required={required}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n className={cx(\n classes.root,\n { [classes.disabled]: disabled, [classes.readOnly]: readOnly },\n className,\n )}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n className={classes.label}\n id={setId(id, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={textAreaLabel}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n className={classes.description}\n id={setId(elementId, \"description\")}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n {hasCounter && (\n <HvCharCounter\n id={setId(elementId, \"charCounter\")}\n className={classes.characterCounter}\n separator={middleCountLabel}\n currentCharQuantity={value.length}\n maxCharQuantity={maxTagsQuantity}\n {...countCharProps}\n />\n )}\n\n <HvListContainer\n className={cx(classes.tagsList, {\n [classes.error]: canShowError,\n [classes.resizable]: resizable && multiline,\n [classes.invalid]: isStateInvalid,\n [classes.singleLine]: !multiline,\n })}\n onKeyDown={onKeyDownHandler}\n onClick={onContainerClickHandler}\n ref={forkedContainerRef}\n >\n {value?.map((t, i) => {\n const tag =\n typeof t === \"string\"\n ? {\n label: t,\n type: \"semantic\",\n }\n : t;\n const { label, type, ...otherProps } = tag;\n return (\n <HvListItem\n key={`${tag.label}-${i}`}\n tabIndex={-1}\n className={cx({ [classes.singleLine]: !multiline })}\n classes={{\n gutters: classes.listItemGutters,\n root: classes.listItemRoot,\n }}\n id={setId(elementId, `tag-${i}`)}\n >\n <HvTag\n label={label}\n className={cx({\n [classes.tagSelected]: i === tagCursorPos,\n })}\n classes={{\n chipRoot: classes.chipRoot,\n }}\n type={type as HvTagProps[\"type\"]}\n {...(!(readOnly || disabled || type === \"categorical\") && {\n onDelete: (event) => onDeleteTagHandler(event, i),\n })}\n deleteButtonProps={{\n tabIndex: -1,\n }}\n {...otherProps}\n />\n </HvListItem>\n );\n })}\n {!(disabled || readOnly) && (\n <HvListItem\n className={cx(\n {\n [classes.singleLine]: !multiline,\n [classes.tagInputRootEmpty]: value.length === 0,\n },\n !!isTagSelected &&\n css({\n [`& .${baseInputClasses.inputRoot}`]: {\n backgroundColor: theme.colors.atmo1,\n },\n }),\n )}\n classes={{\n root: classes.tagInputContainerRoot,\n gutters: classes.listItemGutters,\n }}\n id={setId(elementId, `tag-${value.length}`)}\n >\n <HvInput\n value={tagInput}\n disableClear\n onChange={onChangeHandler}\n onKeyDown={onInputKeyDownHandler}\n placeholder={value.length === 0 ? placeholder : \"\"}\n autoFocus={autoFocus}\n className={cx({\n [classes.singleLine]: !multiline,\n })}\n classes={{\n root: classes.tagInputRoot,\n input: classes.input,\n inputBorderContainer: classes.tagInputBorderContainer,\n inputRootFocused: classes.tagInputRootFocused,\n }}\n disabled={disabled}\n readOnly={readOnly || isTagSelected}\n inputProps={{\n ref: materialInputRef,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : (description && setId(elementId, \"description\")) ||\n undefined,\n\n ...inputProps,\n }}\n inputRef={inputRef}\n {...others}\n />\n </HvListItem>\n )}\n </HvListContainer>\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={containerRef?.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);\n"],"names":["validationState","validationStates","baseInputClasses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8IO,MAAM,cAAc;AAAA,EACzB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,eAAe,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C,SAAS;AAAA,kBACP,MAAM,QAAQ;AAAA,kBACd,MAAM,QAAQ;AAAA,gBAChB;AAAA,gBACA,UAAU;AAAA,gBACV,UAAU,cAAc,SAAS;AAAA,gBACjC,SAAS;AAAA,gBACT,WAAW;AAAA,gBACX,sBAAsB;AAAA,gBACtB;AAAA,cAAA;AAAA,YACF;AAAA,UAAA,GACF;AAAA,UAED,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
|
1
|
+
{"version":3,"file":"TagsInput.js","sources":["../../../src/TagsInput/TagsInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { baseInputClasses } from \"../BaseInput\";\nimport { DEFAULT_ERROR_MESSAGES } from \"../BaseInput/validations\";\nimport {\n HvCharCounter,\n HvCharCounterProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport { HvListContainer, HvListItem } from \"../ListContainer\";\nimport { HvTag, HvTagProps } from \"../Tag\";\nimport { HvTagSuggestion } from \"../types/forms\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./TagsInput.styles\";\n\nexport { staticClasses as tagsInputClasses };\n\nexport type HvTagsInputClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagsInputProps\n extends Omit<\n HvInputProps,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"value\" | \"defaultValue\"\n > {\n /** The value of the form element. */\n value?: string[] | HvTagProps[];\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string[] | HvTagProps[];\n\n /** The function that will be executed onChange. */\n onChange?: (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n value: HvTagProps[],\n ) => void;\n /** The function that will be executed when the element is focused. */\n onFocus?: (event: React.FocusEvent<HTMLDivElement>, value: string) => void;\n /** The function that will be executed when the element is blurred. */\n onBlur?: (event: React.FocusEvent<HTMLDivElement>, value: string) => void;\n /** The function that will be executed when a tag is deleted. */\n onDelete?: (\n event:\n | React.KeyboardEvent<HTMLUListElement>\n | React.MouseEvent<HTMLElement>,\n value: HvTagProps,\n index: number,\n ) => void;\n /** The function that will be executed when a tag is added. */\n onAdd?: (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n value: HvTagProps,\n index: number,\n ) => void;\n /** If `true` the character counter isn't shown even if maxTagsQuantity is set. */\n hideCounter?: boolean;\n /** Text between the current char counter and max value. */\n middleCountLabel?: string;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxTagsQuantity?: number;\n /** If `true` the component is resizable. */\n resizable?: boolean;\n /** Props passed to the HvCharCount component. */\n countCharProps?: Partial<HvCharCounterProps>;\n /** If `true` the component is in multiline mode. */\n multiline?: boolean;\n /** An array of strings that represent the character used to input a tag. This character is the string representation of the event.code from the input event. */\n commitTagOn?: string[];\n /** If `true` the tag will be committed when the blur event occurs. */\n commitOnBlur?: boolean;\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestions. */\n suggestionListCallback?: (value: string) => HvTagSuggestion[] | null;\n /** The validation function that will be executed when adding tags in the suggestions mode. */\n suggestionValidation?: (value: string) => boolean;\n /** When in suggestions mode, this property indicates that tags that are not present on the suggestions list can also be added. */\n suggestionsLoose?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagsInputClasses;\n}\n\n/**\n * A tags input is a single or multiline control that allows the input of tags.\n */\nexport const HvTagsInput = forwardRef<HTMLUListElement, HvTagsInputProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = [],\n readOnly = false,\n disabled = false,\n required = false,\n label: textAreaLabel,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onAdd,\n onDelete,\n onBlur,\n onFocus,\n placeholder,\n hideCounter = false,\n middleCountLabel = \"/\",\n maxTagsQuantity,\n resizable = true,\n inputProps,\n countCharProps,\n multiline = false,\n status,\n statusMessage,\n validationMessages,\n commitTagOn = [\"Enter\"],\n commitOnBlur = false,\n suggestionListCallback,\n suggestionValidation,\n suggestionsLoose = false,\n ...others\n } = useDefaultProps(\"HvTagsInput\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const hasLabel = textAreaLabel != null;\n const hasDescription = description != null;\n\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\",\n );\n\n const [tagInput, setTagInput] = useState(\"\");\n const [tagCursorPos, setTagCursorPos] = useState(value.length);\n const [stateValid, setStateValid] = useState(true);\n\n const inputRef = useRef<any>();\n const containerRef = useRef<any>();\n const skipReset = useRef(false);\n const blurTimeout = useRef<any>();\n const materialInputRef = useRef<any>(null);\n\n const forkedContainerRef = useForkRef(ref, containerRef);\n\n const isTagSelected = tagCursorPos >= 0 && tagCursorPos < value.length;\n const hasCounter = maxTagsQuantity != null && !hideCounter;\n\n // suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvTagSuggestion[] | null\n >(null);\n\n const isStateInvalid = useMemo(() => {\n return hasCounter && value.length > maxTagsQuantity;\n }, [hasCounter, maxTagsQuantity, value.length]);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n [validationMessages],\n );\n\n const performValidation = useCallback(\n (currValue: HvTagProps[]) => {\n if (\n maxTagsQuantity !== null &&\n maxTagsQuantity !== undefined &&\n currValue.length > maxTagsQuantity\n ) {\n setValidationState(validationStates.invalid);\n setValidationMessage(errorMessages.maxCharError);\n setStateValid(false);\n } else {\n setValidationState(validationStates.valid);\n setValidationMessage(\"\");\n setStateValid(true);\n }\n },\n [\n errorMessages.maxCharError,\n maxTagsQuantity,\n setValidationMessage,\n setValidationState,\n ],\n );\n\n /**\n * Deletes a Tag from the array of tags and sets the new position for the tag cursor.\n * Also executes the user provided onDelete and onChange events.\n *\n * @param {number} tagPos - the position at which to remove the tag\n * @param {Event} event - the event associated with the delete\n * @param {boolean} end - whether or not to set the cursor at the end of the array\n */\n const deleteTag = useCallback(\n (\n tagPos: number,\n event:\n | React.KeyboardEvent<HTMLUListElement>\n | React.MouseEvent<HTMLElement>,\n end: boolean,\n ) => {\n const newTagsArr = [\n ...value.slice(0, tagPos),\n ...value.slice(tagPos + 1),\n ] as HvTagProps[];\n setValue(newTagsArr);\n setTagCursorPos(\n end ? newTagsArr.length : tagCursorPos > 0 ? tagCursorPos - 1 : 0,\n );\n inputRef.current?.focus();\n performValidation(newTagsArr);\n onDelete?.(event, value[tagPos] as HvTagProps, tagPos);\n onChange?.(event, newTagsArr);\n skipReset.current = true;\n },\n [onChange, onDelete, performValidation, setValue, tagCursorPos, value],\n );\n\n /**\n * Adds a Tag to the array of tags.\n * Also executes the user provided onAdd and onDelete events.\n *\n * @param {Event} event - whatever event triggered adding a tag\n * @param {string} tag - the string for the tag\n */\n const addTag = useCallback(\n (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent\n | React.KeyboardEvent<HTMLUListElement>\n | React.FocusEvent<HTMLDivElement>,\n tag: React.ReactNode,\n ) => {\n event.preventDefault();\n if (tag !== \"\") {\n const newTag: HvTagProps = { label: tag, type: \"semantic\" };\n const newTagsArr = [...value, newTag] as HvTagProps[];\n setValue(newTagsArr);\n performValidation(newTagsArr);\n onAdd?.(event, newTag, newTagsArr.length - 1);\n onChange?.(event, newTagsArr);\n }\n },\n [onAdd, onChange, performValidation, setValue, value],\n );\n\n const canShowError =\n (status !== undefined &&\n status === \"invalid\" &&\n statusMessage !== undefined) ||\n !stateValid;\n\n useEffect(() => {\n if (!multiline) {\n const element = containerRef?.current?.children[tagCursorPos];\n // this setTimeout is a workaround for Firefox not properly dealing\n // with setting the scrollLeft value.\n setTimeout(() => {\n const container = containerRef.current;\n if (container == null) return;\n container.scrollLeft = element\n ? element.offsetLeft -\n container.getBoundingClientRect().width / 2 +\n element.getBoundingClientRect().width / 2\n : 0;\n }, 10);\n\n element?.focus();\n }\n }, [multiline, tagCursorPos]);\n\n useEffect(() => {\n if (!skipReset.current) {\n setTagInput(\"\");\n setTagCursorPos(value.length);\n }\n skipReset.current = false;\n }, [value]);\n\n const isMounted = useIsMounted();\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n materialInputRef.current.focus();\n };\n\n const getSuggestions = useCallback(\n (li: number) => {\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 [elementId],\n );\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = useCallback(() => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n }, [isMounted]);\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = useCallback(\n (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n },\n [suggestionClearHandler, suggestionListCallback],\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 addTag(event, item.value || item.label);\n\n // set the input value (only when value is uncontrolled)\n setTagInput((item.value || item.label) as string); // TODO - in v6 review all types: this is not a string but a React.ReactNode\n\n focusInput();\n suggestionClearHandler();\n };\n\n /**\n * Handler for the `onKeyDown` event on the suggestions component\n */\n const onSuggestionKeyDown = (\n event: React.KeyboardEvent<HTMLDivElement>,\n ) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /**\n * Handler for the `onChange` event on the tag input\n */\n const onChangeHandler = useCallback(\n (\n event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,\n input: string,\n ) => {\n setTagInput(input);\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(input);\n }\n },\n [canShowSuggestions, suggestionHandler],\n );\n\n /**\n * Handler for the `onKeyDown` event on the form element\n */\n const onInputKeyDownHandler = useCallback(\n (\n event:\n | React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>\n | React.MouseEvent,\n ) => {\n if (!canShowSuggestions && commitTagOn.includes((event as any).code)) {\n addTag(event, tagInput);\n }\n },\n [addTag, canShowSuggestions, commitTagOn, tagInput],\n );\n\n /**\n * Handler for the `onKeyDown` event on the list container.\n */\n const onKeyDownHandler = useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (tagInput === \"\") {\n switch (event.code) {\n case \"ArrowLeft\":\n setTagCursorPos(tagCursorPos > 0 ? tagCursorPos - 1 : 0);\n break;\n case \"ArrowRight\":\n setTagCursorPos(\n tagCursorPos < value.length ? tagCursorPos + 1 : value.length,\n );\n break;\n case \"Backspace\":\n if (isTagSelected) {\n deleteTag(tagCursorPos, event, false);\n } else {\n setTagCursorPos(value.length - 1);\n }\n break;\n case \"Delete\":\n if (isTagSelected) {\n deleteTag(tagCursorPos, event, false);\n }\n break;\n default:\n break;\n }\n } else {\n switch (event.code) {\n case \"ArrowDown\":\n getSuggestions(0)?.focus();\n break;\n case \"Enter\":\n if (\n canShowSuggestions &&\n suggestionsLoose &&\n (suggestionValidation?.(tagInput) || !suggestionValidation)\n ) {\n addTag(event, tagInput);\n\n // set the input value (only when value is uncontrolled)\n setTagInput(tagInput);\n\n focusInput();\n suggestionClearHandler();\n }\n break;\n default:\n break;\n }\n }\n },\n [\n addTag,\n canShowSuggestions,\n deleteTag,\n getSuggestions,\n isTagSelected,\n suggestionClearHandler,\n suggestionValidation,\n suggestionsLoose,\n tagCursorPos,\n tagInput,\n value.length,\n ],\n );\n\n /**\n * Handler for the `onDelete` event on the tag component\n */\n const onDeleteTagHandler = useCallback(\n (event: React.MouseEvent<HTMLElement>, i: number) => {\n deleteTag(i, event, true);\n setValidationState(validationStates.standBy);\n },\n [deleteTag, setValidationState],\n );\n\n /**\n * Handler for the `onClick` event on the list container\n */\n const onContainerClickHandler = useCallback(() => {\n inputRef.current?.focus();\n clearTimeout(blurTimeout.current);\n setTagCursorPos(value.length);\n }, [value.length]);\n\n const onBlurHandler: HvFormElementProps[\"onBlur\"] = (evt) => {\n blurTimeout.current = setTimeout(() => {\n if (commitOnBlur) {\n addTag(evt, tagInput);\n }\n onBlur?.(evt, tagInput);\n }, 10);\n };\n\n const onFocusHandler: HvFormElementProps[\"onFocus\"] = (evt) => {\n clearTimeout(blurTimeout.current);\n onFocus?.(evt, tagInput);\n };\n\n return (\n <HvFormElement\n id={id}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n required={required}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n className={cx(\n classes.root,\n { [classes.disabled]: disabled, [classes.readOnly]: readOnly },\n className,\n )}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n className={classes.label}\n id={setId(id, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={textAreaLabel}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n className={classes.description}\n id={setId(elementId, \"description\")}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n {hasCounter && (\n <HvCharCounter\n id={setId(elementId, \"charCounter\")}\n className={classes.characterCounter}\n separator={middleCountLabel}\n currentCharQuantity={value.length}\n maxCharQuantity={maxTagsQuantity}\n {...countCharProps}\n />\n )}\n\n <HvListContainer\n className={cx(classes.tagsList, {\n [classes.error]: canShowError,\n [classes.resizable]: resizable && multiline,\n [classes.invalid]: isStateInvalid,\n [classes.singleLine]: !multiline,\n })}\n onKeyDown={onKeyDownHandler}\n onClick={onContainerClickHandler}\n ref={forkedContainerRef}\n >\n {value?.map((t, i) => {\n const tag =\n typeof t === \"string\"\n ? {\n label: t,\n type: \"semantic\",\n }\n : t;\n const { label, type, ...otherProps } = tag;\n return (\n <HvListItem\n key={`${tag.label}-${i}`}\n tabIndex={-1}\n className={cx({ [classes.singleLine]: !multiline })}\n classes={{\n gutters: classes.listItemGutters,\n root: classes.listItemRoot,\n }}\n id={setId(elementId, `tag-${i}`)}\n >\n <HvTag\n label={label}\n className={cx({\n [classes.tagSelected]: i === tagCursorPos,\n })}\n classes={{\n chipRoot: classes.chipRoot,\n }}\n type={type as HvTagProps[\"type\"]}\n {...(!(readOnly || disabled || type === \"categorical\") && {\n onDelete: (event) => onDeleteTagHandler(event, i),\n })}\n deleteButtonProps={{\n tabIndex: -1,\n }}\n {...otherProps}\n />\n </HvListItem>\n );\n })}\n {!(disabled || readOnly) && (\n <HvListItem\n className={cx(\n {\n [classes.singleLine]: !multiline,\n [classes.tagInputRootEmpty]: value.length === 0,\n },\n !!isTagSelected &&\n css({\n [`& .${baseInputClasses.inputRoot}`]: {\n backgroundColor: theme.colors.atmo1,\n },\n }),\n )}\n classes={{\n root: classes.tagInputContainerRoot,\n gutters: classes.listItemGutters,\n }}\n id={setId(elementId, `tag-${value.length}`)}\n >\n <HvInput\n value={tagInput}\n disableClear\n onChange={onChangeHandler}\n onKeyDown={onInputKeyDownHandler}\n placeholder={value.length === 0 ? placeholder : \"\"}\n className={cx({\n [classes.singleLine]: !multiline,\n })}\n classes={{\n root: classes.tagInputRoot,\n input: classes.input,\n inputBorderContainer: classes.tagInputBorderContainer,\n inputRootFocused: classes.tagInputRootFocused,\n }}\n disabled={disabled}\n readOnly={readOnly || isTagSelected}\n inputProps={{\n ref: materialInputRef,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : (description && setId(elementId, \"description\")) ||\n undefined,\n\n ...inputProps,\n }}\n ref={inputRef}\n {...others}\n />\n </HvListItem>\n )}\n </HvListContainer>\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={containerRef?.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);\n"],"names":["validationState","validationStates","baseInputClasses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiHO,MAAM,cAAc;AAAA,EACzB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,eAAe,CAAC;AAAA,MAChB,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,OAAO;AAAA,MACP,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,CAAC,OAAO;AAAA,MACtB,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA,mBAAmB;AAAA,MACnB,GAAG;AAAA,IAAA,IACD,gBAAgB,eAAe,KAAK;AAExC,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAE7C,UAAA,YAAY,YAAY,EAAE;AAEhC,UAAM,WAAW,iBAAiB;AAClC,UAAM,iBAAiB,eAAe;AAEtC,UAAM,CAAC,OAAO,QAAQ,IAAI,cAAc,WAAW,YAAY;AAEzD,UAAA,CAACA,mBAAiB,kBAAkB,IAAI;AAAA,MAC5C;AAAA,MACA;AAAA,IAAA;AAEI,UAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,MAChD;AAAA,MACA;AAAA,IAAA;AAGF,UAAM,CAAC,UAAU,WAAW,IAAI,SAAS,EAAE;AAC3C,UAAM,CAAC,cAAc,eAAe,IAAI,SA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AAA,kBAAA;AAAA,gBACF;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,UACC,sBAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,YAAA,sCACE,OAAI,EAAA,MAAK,gBAAe,WAAW,QAAQ,gBAAgB;AAAA,YAE9D;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI,MAAM,WAAW,aAAa;AAAA,gBAClC,SAAS;AAAA,kBACP,MAAM,QAAQ;AAAA,kBACd,MAAM,QAAQ;AAAA,gBAChB;AAAA,gBACA,UAAU;AAAA,gBACV,UAAU,cAAc,SAAS;AAAA,gBACjC,SAAS;AAAA,gBACT,WAAW;AAAA,gBACX,sBAAsB;AAAA,gBACtB;AAAA,cAAA;AAAA,YACF;AAAA,UAAA,GACF;AAAA,UAED,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4100,25 +4100,52 @@ export declare interface HvInfoMessageProps extends HvTypographyProps<"label"> {
|
|
|
4100
4100
|
* An Inline Editor allows the user to edit a record without making a major switch
|
|
4101
4101
|
* between viewing and editing, making it an efficient method of updating a record.
|
|
4102
4102
|
*/
|
|
4103
|
-
export declare const HvInlineEditor: (props:
|
|
4103
|
+
export declare const HvInlineEditor: <C extends default_2.ElementType = default_2.ForwardRefExoticComponent<HvInputProps & default_2.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>>(props: {
|
|
4104
|
+
/** The value of the form element. */
|
|
4105
|
+
value?: string;
|
|
4106
|
+
/** The default value of the form element. */
|
|
4107
|
+
defaultValue?: string;
|
|
4108
|
+
/** Whether the Edit icon should always be visible */
|
|
4109
|
+
showIcon?: boolean;
|
|
4110
|
+
/** Variant of the HvTypography to display */
|
|
4111
|
+
variant?: HvTypographyVariants;
|
|
4112
|
+
/** Called when the input is blurred. */
|
|
4113
|
+
onBlur?: (event: default_2.FocusEvent<HTMLTextAreaElement | HTMLInputElement>, value: string) => void;
|
|
4114
|
+
/** Called when the input value changes. */
|
|
4115
|
+
onChange?: (event: default_2.SyntheticEvent, value: string) => void;
|
|
4116
|
+
/** Props passed to the HvButton component */
|
|
4117
|
+
buttonProps?: HvButtonProps;
|
|
4118
|
+
/** Props passed to the HvTypography text component */
|
|
4119
|
+
typographyProps?: HvTypographyProps;
|
|
4120
|
+
/** Whether the editor is disabled or not. */
|
|
4121
|
+
disabled?: boolean;
|
|
4122
|
+
/** A Jss Object used to override or extend the styles applied to the empty state component. */
|
|
4123
|
+
classes?: HvInlineEditorClasses;
|
|
4124
|
+
/** The placeholder value of the input. */
|
|
4125
|
+
placeholder?: string;
|
|
4126
|
+
} & {
|
|
4127
|
+
component?: C | undefined;
|
|
4128
|
+
} & {
|
|
4129
|
+
children?: default_2.ReactNode | undefined;
|
|
4130
|
+
} & (Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> extends infer T ? T extends Omit<default_2.PropsWithoutRef<default_2.ComponentProps<C>>, "value" | "classes" | "placeholder" | "disabled" | "variant" | "component" | "onBlur" | "onChange" | "defaultValue" | "showIcon" | "buttonProps" | "typographyProps"> ? T extends any ? T : never : never : never) & {
|
|
4131
|
+
ref?: PolymorphicRef<C> | undefined;
|
|
4132
|
+
} & default_2.RefAttributes<unknown>) => default_2.ReactElement | null;
|
|
4104
4133
|
|
|
4105
4134
|
export declare type HvInlineEditorClasses = ExtractNames<typeof useClasses_81>;
|
|
4106
4135
|
|
|
4107
|
-
export declare
|
|
4136
|
+
export declare type HvInlineEditorProps<C extends default_2.ElementType = typeof HvInput> = PolymorphicComponentRef<C, {
|
|
4108
4137
|
/** The value of the form element. */
|
|
4109
4138
|
value?: string;
|
|
4110
4139
|
/** The default value of the form element. */
|
|
4111
4140
|
defaultValue?: string;
|
|
4112
4141
|
/** Whether the Edit icon should always be visible */
|
|
4113
4142
|
showIcon?: boolean;
|
|
4114
|
-
/** Component to use as the input. The component "inherit" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */
|
|
4115
|
-
component?: React.ElementType;
|
|
4116
4143
|
/** Variant of the HvTypography to display */
|
|
4117
4144
|
variant?: HvTypographyVariants;
|
|
4118
4145
|
/** Called when the input is blurred. */
|
|
4119
|
-
onBlur?: (event:
|
|
4146
|
+
onBlur?: (event: default_2.FocusEvent<HTMLTextAreaElement | HTMLInputElement>, value: string) => void;
|
|
4120
4147
|
/** Called when the input value changes. */
|
|
4121
|
-
onChange?: (event:
|
|
4148
|
+
onChange?: (event: default_2.SyntheticEvent, value: string) => void;
|
|
4122
4149
|
/** Props passed to the HvButton component */
|
|
4123
4150
|
buttonProps?: HvButtonProps;
|
|
4124
4151
|
/** Props passed to the HvTypography text component */
|
|
@@ -4129,7 +4156,7 @@ export declare interface HvInlineEditorProps extends HvBaseProps<HTMLDivElement,
|
|
|
4129
4156
|
classes?: HvInlineEditorClasses;
|
|
4130
4157
|
/** The placeholder value of the input. */
|
|
4131
4158
|
placeholder?: string;
|
|
4132
|
-
}
|
|
4159
|
+
}>;
|
|
4133
4160
|
|
|
4134
4161
|
/**
|
|
4135
4162
|
* A text input box is a graphical control element intended to enable the user to input text information to be used by the software.
|
|
@@ -6498,27 +6525,11 @@ export declare const HvTagsInput: default_2.ForwardRefExoticComponent<HvTagsInpu
|
|
|
6498
6525
|
|
|
6499
6526
|
export declare type HvTagsInputClasses = ExtractNames<typeof useClasses_113>;
|
|
6500
6527
|
|
|
6501
|
-
export declare interface HvTagsInputProps extends
|
|
6502
|
-
/** The form element name. */
|
|
6503
|
-
name?: string;
|
|
6528
|
+
export declare interface HvTagsInputProps extends Omit<HvInputProps, "onChange" | "onBlur" | "onFocus" | "onKeyDown" | "value" | "defaultValue"> {
|
|
6504
6529
|
/** The value of the form element. */
|
|
6505
6530
|
value?: string[] | HvTagProps[];
|
|
6506
6531
|
/** When uncontrolled, defines the initial input value. */
|
|
6507
6532
|
defaultValue?: string[] | HvTagProps[];
|
|
6508
|
-
/**
|
|
6509
|
-
* The label of the form element.
|
|
6510
|
-
* The form element must be labeled for accessibility reasons.
|
|
6511
|
-
* If not provided, an aria-label or aria-labelledby must be inputted via inputProps.
|
|
6512
|
-
*/
|
|
6513
|
-
label?: default_2.ReactNode;
|
|
6514
|
-
/** Provide additional descriptive text for the form element. */
|
|
6515
|
-
description?: default_2.ReactNode;
|
|
6516
|
-
/** Indicates that the form element is disabled. */
|
|
6517
|
-
disabled?: boolean;
|
|
6518
|
-
/** Indicates that the form element is not editable. */
|
|
6519
|
-
readOnly?: boolean;
|
|
6520
|
-
/** Indicates that the form element is required. */
|
|
6521
|
-
required?: boolean;
|
|
6522
6533
|
/** The function that will be executed onChange. */
|
|
6523
6534
|
onChange?: (event: default_2.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement> | default_2.MouseEvent | default_2.KeyboardEvent<HTMLUListElement> | default_2.FocusEvent<HTMLDivElement>, value: HvTagProps[]) => void;
|
|
6524
6535
|
/** The function that will be executed when the element is focused. */
|
|
@@ -6529,30 +6540,18 @@ export declare interface HvTagsInputProps extends HvBaseProps<HTMLElement, "onCh
|
|
|
6529
6540
|
onDelete?: (event: default_2.KeyboardEvent<HTMLUListElement> | default_2.MouseEvent<HTMLElement>, value: HvTagProps, index: number) => void;
|
|
6530
6541
|
/** The function that will be executed when a tag is added. */
|
|
6531
6542
|
onAdd?: (event: default_2.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement> | default_2.MouseEvent | default_2.KeyboardEvent<HTMLUListElement> | default_2.FocusEvent<HTMLDivElement>, value: HvTagProps, index: number) => void;
|
|
6532
|
-
/** The placeholder value of the input. */
|
|
6533
|
-
placeholder?: string;
|
|
6534
6543
|
/** If `true` the character counter isn't shown even if maxTagsQuantity is set. */
|
|
6535
6544
|
hideCounter?: boolean;
|
|
6536
6545
|
/** Text between the current char counter and max value. */
|
|
6537
6546
|
middleCountLabel?: string;
|
|
6538
6547
|
/** The maximum allowed length of the characters, if this value is null no check will be performed. */
|
|
6539
6548
|
maxTagsQuantity?: number;
|
|
6540
|
-
/** Attributes applied to the input element. */
|
|
6541
|
-
inputProps?: InputBaseComponentProps;
|
|
6542
|
-
/** If `true` it should autofocus. */
|
|
6543
|
-
autoFocus?: boolean;
|
|
6544
6549
|
/** If `true` the component is resizable. */
|
|
6545
6550
|
resizable?: boolean;
|
|
6546
6551
|
/** Props passed to the HvCharCount component. */
|
|
6547
6552
|
countCharProps?: Partial<HvCharCounterProps>;
|
|
6548
6553
|
/** If `true` the component is in multiline mode. */
|
|
6549
6554
|
multiline?: boolean;
|
|
6550
|
-
/** The status of the form element. */
|
|
6551
|
-
status?: HvFormStatus;
|
|
6552
|
-
/** The error message to show when `status` is "invalid". */
|
|
6553
|
-
statusMessage?: default_2.ReactNode;
|
|
6554
|
-
/** An Object containing the various texts associated with the input. */
|
|
6555
|
-
validationMessages?: HvValidationMessages;
|
|
6556
6555
|
/** An array of strings that represent the character used to input a tag. This character is the string representation of the event.code from the input event. */
|
|
6557
6556
|
commitTagOn?: string[];
|
|
6558
6557
|
/** If `true` the tag will be committed when the blur event occurs. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.67.
|
|
3
|
+
"version": "5.67.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@emotion/cache": "^11.11.0",
|
|
34
34
|
"@emotion/serialize": "^1.1.2",
|
|
35
|
-
"@hitachivantara/uikit-react-icons": "^5.10.
|
|
35
|
+
"@hitachivantara/uikit-react-icons": "^5.10.7",
|
|
36
36
|
"@hitachivantara/uikit-react-shared": "^5.2.0",
|
|
37
37
|
"@hitachivantara/uikit-styles": "^5.31.1",
|
|
38
38
|
"@internationalized/date": "^3.2.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"access": "public",
|
|
62
62
|
"directory": "package"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "657262fc6de23b28f76b1b017a4c49ce78c78ab3",
|
|
65
65
|
"exports": {
|
|
66
66
|
".": {
|
|
67
67
|
"require": "./dist/cjs/index.cjs",
|