@hitachivantara/uikit-react-core 5.87.2 → 5.88.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/ActionsGeneric/ActionsGeneric.cjs +1 -1
- package/dist/cjs/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/BaseInput/BaseInput.cjs +44 -83
- package/dist/cjs/BaseInput/BaseInput.styles.cjs +68 -142
- package/dist/cjs/BaseInput/validations.cjs +2 -1
- package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +0 -6
- package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.styles.cjs +1 -5
- package/dist/cjs/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/cjs/DatePicker/DatePicker.cjs +12 -12
- package/dist/cjs/Dropdown/Dropdown.cjs +8 -10
- package/dist/cjs/FilterGroup/FilterContent/FilterContent.cjs +1 -1
- package/dist/cjs/FormElement/Adornment/Adornment.cjs +15 -36
- package/dist/cjs/FormElement/Adornment/Adornment.styles.cjs +11 -17
- package/dist/cjs/InlineEditor/InlineEditor.cjs +10 -14
- package/dist/cjs/InlineEditor/InlineEditor.styles.cjs +13 -36
- package/dist/cjs/Input/Input.cjs +33 -56
- package/dist/cjs/Input/Input.styles.cjs +6 -19
- package/dist/cjs/List/List.cjs +12 -12
- package/dist/cjs/Pagination/Pagination.styles.cjs +2 -1
- package/dist/cjs/Pagination/Select.cjs +1 -1
- package/dist/cjs/Select/Select.styles.cjs +1 -1
- package/dist/cjs/Table/TableBody/TableBody.cjs +16 -17
- package/dist/cjs/TableSection/TableSection.styles.cjs +10 -10
- package/dist/cjs/Tag/Tag.cjs +1 -1
- package/dist/cjs/TagsInput/TagsInput.cjs +103 -169
- package/dist/cjs/TagsInput/TagsInput.styles.cjs +45 -111
- package/dist/cjs/TextArea/TextArea.cjs +1 -3
- package/dist/cjs/TextArea/TextArea.styles.cjs +1 -1
- package/dist/cjs/TimePicker/TimePicker.cjs +5 -4
- package/dist/cjs/TimePicker/Unit/Unit.cjs +0 -1
- package/dist/cjs/TimePicker/Unit/Unit.styles.cjs +0 -3
- package/dist/cjs/hooks/useFocus.cjs +38 -0
- package/dist/cjs/utils/CounterLabel.cjs +3 -2
- package/dist/cjs/utils/focusUtils.cjs +0 -4
- package/dist/esm/ActionsGeneric/ActionsGeneric.js +1 -1
- package/dist/esm/AvatarGroup/AvatarGroupContext.js +1 -1
- package/dist/esm/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/BaseCheckBox/BaseCheckBox.js +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.js +3 -3
- package/dist/esm/BaseInput/BaseInput.js +45 -84
- package/dist/esm/BaseInput/BaseInput.js.map +1 -1
- package/dist/esm/BaseInput/BaseInput.styles.js +68 -142
- package/dist/esm/BaseInput/BaseInput.styles.js.map +1 -1
- package/dist/esm/BaseInput/validations.js +2 -1
- package/dist/esm/BaseInput/validations.js.map +1 -1
- package/dist/esm/BaseRadio/BaseRadio.js +1 -1
- package/dist/esm/Button/Button.js +1 -1
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +1 -7
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js +1 -5
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js.map +1 -1
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/esm/ColorPicker/Fields/Fields.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/DatePicker/utils.js +1 -1
- package/dist/esm/Dialog/context.js +1 -1
- package/dist/esm/DotPagination/DotPagination.js +1 -1
- package/dist/esm/Dropdown/Dropdown.js +8 -10
- package/dist/esm/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/DropdownButton/DropdownButton.js.map +1 -1
- package/dist/esm/FilterGroup/FilterContent/FilterContent.js +1 -1
- package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
- package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/Focus/Focus.js +1 -1
- package/dist/esm/FormElement/Adornment/Adornment.js +15 -36
- package/dist/esm/FormElement/Adornment/Adornment.js.map +1 -1
- package/dist/esm/FormElement/Adornment/Adornment.styles.js +11 -17
- package/dist/esm/FormElement/Adornment/Adornment.styles.js.map +1 -1
- package/dist/esm/Header/Navigation/useSelectionPath.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.js +10 -14
- package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.styles.js +13 -36
- package/dist/esm/InlineEditor/InlineEditor.styles.js.map +1 -1
- package/dist/esm/Input/Input.js +34 -57
- package/dist/esm/Input/Input.js.map +1 -1
- package/dist/esm/Input/Input.styles.js +6 -19
- package/dist/esm/Input/Input.styles.js.map +1 -1
- package/dist/esm/List/List.js +12 -12
- package/dist/esm/List/List.js.map +1 -1
- package/dist/esm/Pagination/Pagination.styles.js +5 -4
- package/dist/esm/Pagination/Pagination.styles.js.map +1 -1
- package/dist/esm/Pagination/Select.js +1 -1
- package/dist/esm/QueryBuilder/Context.js +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js +1 -1
- package/dist/esm/QueryBuilder/utils/index.js +1 -1
- package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +1 -1
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/SelectionList/SelectionList.js.map +1 -1
- package/dist/esm/Slider/Slider.js +1 -1
- package/dist/esm/Slider/Slider.js.map +1 -1
- package/dist/esm/SnackbarProvider/SnackbarProvider.js +2 -2
- package/dist/esm/Table/TableBody/TableBody.js +16 -17
- package/dist/esm/Table/TableBody/TableBody.js.map +1 -1
- package/dist/esm/TableSection/TableSection.styles.js +24 -24
- package/dist/esm/Tag/Tag.js +1 -1
- package/dist/esm/Tag/Tag.js.map +1 -1
- package/dist/esm/TagsInput/TagsInput.js +103 -169
- package/dist/esm/TagsInput/TagsInput.js.map +1 -1
- package/dist/esm/TagsInput/TagsInput.styles.js +45 -111
- package/dist/esm/TagsInput/TagsInput.styles.js.map +1 -1
- package/dist/esm/TextArea/TextArea.js +1 -3
- package/dist/esm/TextArea/TextArea.js.map +1 -1
- package/dist/esm/TextArea/TextArea.styles.js +1 -1
- package/dist/esm/TextArea/TextArea.styles.js.map +1 -1
- package/dist/esm/TimePicker/TimePicker.js +1 -0
- package/dist/esm/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/TimePicker/Unit/Unit.js +0 -1
- package/dist/esm/TimePicker/Unit/Unit.js.map +1 -1
- package/dist/esm/TimePicker/Unit/Unit.styles.js +0 -3
- package/dist/esm/TimePicker/Unit/Unit.styles.js.map +1 -1
- package/dist/esm/TreeView/internals/TreeViewProvider.js +1 -1
- package/dist/esm/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.js +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/hooks/useFocus.js +38 -0
- package/dist/esm/hooks/useFocus.js.map +1 -0
- package/dist/esm/hooks/useScrollTo.js.map +1 -1
- package/dist/esm/utils/CounterLabel.js +3 -2
- package/dist/esm/utils/CounterLabel.js.map +1 -1
- package/dist/esm/utils/document.js.map +1 -1
- package/dist/esm/utils/focusUtils.js +0 -4
- package/dist/esm/utils/focusUtils.js.map +1 -1
- package/dist/types/index.d.ts +213 -274
- package/package.json +8 -8
|
@@ -5,68 +5,47 @@ import { HvFormElementContext, HvFormElementDescriptorsContext } from "../contex
|
|
|
5
5
|
import { useClasses } from "./Adornment.styles.js";
|
|
6
6
|
import { staticClasses } from "./Adornment.styles.js";
|
|
7
7
|
import { HvButtonBase } from "../../ButtonBase/ButtonBase.js";
|
|
8
|
-
const noop = () => {
|
|
9
|
-
};
|
|
10
8
|
const HvAdornment = forwardRef(function HvAdornment2(props, ref) {
|
|
11
9
|
const {
|
|
12
|
-
id,
|
|
13
10
|
classes: classesProp,
|
|
14
11
|
className,
|
|
15
12
|
icon,
|
|
16
13
|
showWhen,
|
|
17
14
|
onClick,
|
|
18
15
|
isVisible,
|
|
16
|
+
tabIndex,
|
|
19
17
|
...others
|
|
20
18
|
} = useDefaultProps("HvAdornment", props);
|
|
21
19
|
const { classes, cx } = useClasses(classesProp);
|
|
22
20
|
const { status, disabled } = useContext(HvFormElementContext);
|
|
23
21
|
const { input } = useContext(HvFormElementDescriptorsContext);
|
|
24
22
|
const displayIcon = isVisible ?? (showWhen == null || status === showWhen);
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
id,
|
|
30
|
-
focusableWhenDisabled: true,
|
|
31
|
-
ref,
|
|
32
|
-
type: "button",
|
|
33
|
-
tabIndex: -1,
|
|
34
|
-
"aria-controls": input?.[0]?.id,
|
|
35
|
-
className: cx(
|
|
36
|
-
classes.root,
|
|
37
|
-
classes.adornment,
|
|
38
|
-
classes.adornmentButton,
|
|
39
|
-
{
|
|
40
|
-
[classes.hideIcon]: !displayIcon,
|
|
41
|
-
[classes.disabled]: disabled
|
|
42
|
-
},
|
|
43
|
-
className
|
|
44
|
-
),
|
|
45
|
-
onClick,
|
|
46
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
47
|
-
onKeyDown: noop,
|
|
48
|
-
disabled,
|
|
49
|
-
...others,
|
|
50
|
-
children: /* @__PURE__ */ jsx("div", { className: classes.icon, children: icon })
|
|
51
|
-
}
|
|
52
|
-
) : /* @__PURE__ */ jsx(
|
|
53
|
-
"div",
|
|
23
|
+
const Component = onClick ? HvButtonBase : "div";
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
Component,
|
|
54
26
|
{
|
|
55
|
-
id,
|
|
56
27
|
ref,
|
|
28
|
+
"aria-hidden": tabIndex == null || tabIndex < 0 ? true : void 0,
|
|
57
29
|
className: cx(
|
|
58
30
|
classes.root,
|
|
59
31
|
classes.adornment,
|
|
60
|
-
classes.
|
|
32
|
+
classes.icon,
|
|
33
|
+
onClick ? classes.adornmentButton : classes.adornmentIcon,
|
|
61
34
|
{
|
|
62
35
|
[classes.hideIcon]: !displayIcon,
|
|
63
36
|
[classes.disabled]: disabled
|
|
64
37
|
},
|
|
65
38
|
className
|
|
66
39
|
),
|
|
67
|
-
|
|
40
|
+
...onClick && {
|
|
41
|
+
disabled,
|
|
42
|
+
tabIndex: tabIndex ?? -1,
|
|
43
|
+
"aria-controls": input?.[0]?.id,
|
|
44
|
+
onClick,
|
|
45
|
+
onMouseDown: (event) => event.preventDefault()
|
|
46
|
+
},
|
|
68
47
|
...others,
|
|
69
|
-
children:
|
|
48
|
+
children: icon
|
|
70
49
|
}
|
|
71
50
|
);
|
|
72
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adornment.js","sources":["../../../../src/FormElement/Adornment/Adornment.tsx"],"sourcesContent":["import { forwardRef, useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonBase } from \"../../ButtonBase\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n} from \"../context\";\nimport { HvFormStatus } from \"../FormElement\";\nimport { staticClasses, useClasses } from \"./Adornment.styles\";\n\
|
|
1
|
+
{"version":3,"file":"Adornment.js","sources":["../../../../src/FormElement/Adornment/Adornment.tsx"],"sourcesContent":["import { forwardRef, useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonBase } from \"../../ButtonBase\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n} from \"../context\";\nimport { HvFormStatus } from \"../FormElement\";\nimport { staticClasses, useClasses } from \"./Adornment.styles\";\n\nexport { staticClasses as adornmentClasses };\n\nexport type HvAdornmentClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvAdornmentProps\n extends HvBaseProps<\n HTMLDivElement | HTMLButtonElement,\n \"onMouseDown\" | \"onKeyDown\"\n > {\n /** The icon to be added into the input. */\n icon: React.ReactNode;\n /** Controls the visibility of the adornment based on the form element's status. `isVisible` overrides this behavior. */\n showWhen?: HvFormStatus;\n /** Function to be executed when this element is clicked. */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** If this property is defined the adornment visibility will be exclusively controlled by this value. */\n isVisible?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvAdornmentClasses;\n}\n\n/**\n * Allows to add a decorative icon or an action to a form element, usually on the right side of an input.\n * E.g., the reveal password button.\n *\n * This component disables keyboard navigation by default, ensuring that it doesn't steal focus from the input.\n * As such, its functionality, if any, for accessibility purposes must be provided through an alternative mean.\n * This behavior can be overridden by providing an a `tabIndex={0}`.\n */\nexport const HvAdornment = forwardRef<\n HTMLDivElement | HTMLButtonElement,\n HvAdornmentProps\n>(function HvAdornment(props, ref) {\n const {\n classes: classesProp,\n className,\n icon,\n showWhen,\n onClick,\n isVisible,\n tabIndex,\n ...others\n } = useDefaultProps(\"HvAdornment\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { status, disabled } = useContext(HvFormElementContext);\n const { input } = useContext(HvFormElementDescriptorsContext);\n\n const displayIcon = isVisible ?? (showWhen == null || status === showWhen);\n\n const Component = onClick ? HvButtonBase : \"div\";\n\n return (\n <Component\n ref={ref as React.ForwardedRef<any>}\n aria-hidden={tabIndex == null || tabIndex < 0 ? true : undefined}\n className={cx(\n classes.root,\n classes.adornment,\n classes.icon,\n onClick ? classes.adornmentButton : classes.adornmentIcon,\n {\n [classes.hideIcon]: !displayIcon,\n [classes.disabled]: disabled,\n },\n className,\n )}\n {...(onClick && {\n disabled,\n tabIndex: tabIndex ?? -1,\n \"aria-controls\": input?.[0]?.id,\n onClick: onClick as React.MouseEventHandler<any>,\n onMouseDown: (event) => event.preventDefault(),\n })}\n {...others}\n >\n {icon}\n </Component>\n );\n});\n"],"names":["HvAdornment"],"mappings":";;;;;;;AA4CO,MAAM,cAAc,WAGzB,SAASA,aAAY,OAAO,KAAK;AAC3B,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,eAAe,KAAK;AACxC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAE9C,QAAM,EAAE,QAAQ,aAAa,WAAW,oBAAoB;AAC5D,QAAM,EAAE,MAAA,IAAU,WAAW,+BAA+B;AAE5D,QAAM,cAAc,cAAc,YAAY,QAAQ,WAAW;AAE3D,QAAA,YAAY,UAAU,eAAe;AAGzC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,eAAa,YAAY,QAAQ,WAAW,IAAI,OAAO;AAAA,MACvD,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU,QAAQ,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,UACE,CAAC,QAAQ,QAAQ,GAAG,CAAC;AAAA,UACrB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAI,WAAW;AAAA,QACd;AAAA,QACA,UAAU,YAAY;AAAA,QACtB,iBAAiB,QAAQ,CAAC,GAAG;AAAA,QAC7B;AAAA,QACA,aAAa,CAAC,UAAU,MAAM,eAAe;AAAA,MAC/C;AAAA,MACC,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EACH;AAEJ,CAAC;"}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
2
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
|
-
import { outlineStyles } from "../../utils/focusUtils.js";
|
|
4
3
|
const { staticClasses, useClasses } = createClasses("HvAdornment", {
|
|
5
|
-
root: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
backgroundColor: "transparent",
|
|
9
|
-
border: "none",
|
|
10
|
-
padding: 0,
|
|
11
|
-
margin: 0
|
|
4
|
+
root: {
|
|
5
|
+
width: 32,
|
|
6
|
+
height: 30
|
|
12
7
|
},
|
|
13
|
-
|
|
8
|
+
/** @deprecated use `classes.root` */
|
|
9
|
+
icon: {},
|
|
10
|
+
/** @deprecated use `classes.root` */
|
|
11
|
+
adornment: {},
|
|
12
|
+
/** @deprecated use `classes.root` */
|
|
13
|
+
adornmentIcon: {},
|
|
14
14
|
hideIcon: { display: "none" },
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"&:focus": {
|
|
18
|
-
...outlineStyles
|
|
19
|
-
}
|
|
20
|
-
},
|
|
15
|
+
/** @deprecated use `classes.root` */
|
|
16
|
+
adornmentButton: {},
|
|
21
17
|
disabled: {
|
|
22
|
-
"&$adornmentButton": { cursor: "not-allowed" },
|
|
23
|
-
"&$adornmentIcon": { cursor: "not-allowed" },
|
|
24
18
|
"& svg *.color0": { fill: theme.colors.secondary_60 }
|
|
25
19
|
}
|
|
26
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adornment.styles.js","sources":["../../../../src/FormElement/Adornment/Adornment.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\
|
|
1
|
+
{"version":3,"file":"Adornment.styles.js","sources":["../../../../src/FormElement/Adornment/Adornment.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvAdornment\", {\n root: {\n width: 32,\n height: 30,\n },\n /** @deprecated use `classes.root` */\n icon: {},\n /** @deprecated use `classes.root` */\n adornment: {},\n /** @deprecated use `classes.root` */\n adornmentIcon: {},\n hideIcon: { display: \"none\" },\n /** @deprecated use `classes.root` */\n adornmentButton: {},\n disabled: {\n \"& svg *.color0\": { fill: theme.colors.secondary_60 },\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA,EACxE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA;AAAA,EAEA,MAAM,CAAC;AAAA;AAAA,EAEP,WAAW,CAAC;AAAA;AAAA,EAEZ,eAAe,CAAC;AAAA,EAChB,UAAU,EAAE,SAAS,OAAO;AAAA;AAAA,EAE5B,iBAAiB,CAAC;AAAA,EAClB,UAAU;AAAA,IACR,kBAAkB,EAAE,MAAM,MAAM,OAAO,aAAa;AAAA,EAAA;AAExD,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectionPath.js","sources":["../../../../src/Header/Navigation/useSelectionPath.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nexport interface HvHeaderNavigationItemProp {\n id: string;\n label: string;\n path?: string;\n href?: string;\n target?: string;\n data?: HvHeaderNavigationItemProp[];\n}\n\nconst getSelectionPath = (\n data: HvHeaderNavigationItemProp[] | undefined,\n selectedId: string | undefined,\n selection: string[] = [],\n idx = -1,\n parent: HvHeaderNavigationItemProp[] = [],\n): string[] => {\n data?.forEach((item: HvHeaderNavigationItemProp, i) => {\n const hasData = item.data?.length;\n\n const isSelected = item.id === selectedId;\n\n if (isSelected)\n selection.push(...(idx > -1 ? [parent[idx].id] : []), item.id);\n\n if (hasData) getSelectionPath(item.data, selectedId, selection, i, data);\n });\n\n return selection;\n};\n\nexport const useSelectionPath = (\n data: HvHeaderNavigationItemProp[],\n selectedId?: string,\n): string[] => {\n const [selectionPath, setSelectionPath] = useState<string[]>([]);\n\n useEffect(() => {\n const path = getSelectionPath(data, selectedId);\n\n setSelectionPath(path);\n }, [data, selectedId]);\n\n return selectionPath;\n};\n"],"names":[],"mappings":";AAWA,MAAM,mBAAmB,CACvB,MACA,YACA,YAAsB,
|
|
1
|
+
{"version":3,"file":"useSelectionPath.js","sources":["../../../../src/Header/Navigation/useSelectionPath.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nexport interface HvHeaderNavigationItemProp {\n id: string;\n label: string;\n path?: string;\n href?: string;\n target?: string;\n data?: HvHeaderNavigationItemProp[];\n}\n\nconst getSelectionPath = (\n data: HvHeaderNavigationItemProp[] | undefined,\n selectedId: string | undefined,\n selection: string[] = [],\n idx = -1,\n parent: HvHeaderNavigationItemProp[] = [],\n): string[] => {\n data?.forEach((item: HvHeaderNavigationItemProp, i) => {\n const hasData = item.data?.length;\n\n const isSelected = item.id === selectedId;\n\n if (isSelected)\n selection.push(...(idx > -1 ? [parent[idx].id] : []), item.id);\n\n if (hasData) getSelectionPath(item.data, selectedId, selection, i, data);\n });\n\n return selection;\n};\n\nexport const useSelectionPath = (\n data: HvHeaderNavigationItemProp[],\n selectedId?: string,\n): string[] => {\n const [selectionPath, setSelectionPath] = useState<string[]>([]);\n\n useEffect(() => {\n const path = getSelectionPath(data, selectedId);\n\n setSelectionPath(path);\n }, [data, selectedId]);\n\n return selectionPath;\n};\n"],"names":[],"mappings":";AAWA,MAAM,mBAAmB,CACvB,MACA,YACA,YAAsB,CAAC,GACvB,MAAM,IACN,SAAuC,OAC1B;AACP,QAAA,QAAQ,CAAC,MAAkC,MAAM;AAC/C,UAAA,UAAU,KAAK,MAAM;AAErB,UAAA,aAAa,KAAK,OAAO;AAE3B,QAAA;AACF,gBAAU,KAAK,GAAI,MAAM,KAAK,CAAC,OAAO,GAAG,EAAE,EAAE,IAAI,IAAK,KAAK,EAAE;AAE/D,QAAI,QAA0B,kBAAA,KAAK,MAAM,YAAY,WAAW,GAAG,IAAI;AAAA,EAAA,CACxE;AAEM,SAAA;AACT;AAEa,MAAA,mBAAmB,CAC9B,MACA,eACa;AACb,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAmB,CAAA,CAAE;AAE/D,YAAU,MAAM;AACR,UAAA,OAAO,iBAAiB,MAAM,UAAU;AAE9C,qBAAiB,IAAI;AAAA,EAAA,GACpB,CAAC,MAAM,UAAU,CAAC;AAEd,SAAA;AACT;"}
|
|
@@ -39,12 +39,9 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
|
39
39
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
40
40
|
const typographyStyles = activeTheme?.typography[variant] || {};
|
|
41
41
|
const { lineHeight } = typographyStyles;
|
|
42
|
-
const checkOverflow = () => {
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
inputRef.current.scrollWidth > inputRef.current.clientWidth
|
|
46
|
-
);
|
|
47
|
-
}
|
|
42
|
+
const checkOverflow = (el) => {
|
|
43
|
+
if (!el) return;
|
|
44
|
+
setIsOverflowing(el.scrollWidth > el.clientWidth);
|
|
48
45
|
};
|
|
49
46
|
useEnhancedEffect(() => {
|
|
50
47
|
const input = inputRef.current;
|
|
@@ -69,13 +66,11 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
|
69
66
|
newValue = cachedValue;
|
|
70
67
|
setEditMode(false);
|
|
71
68
|
setValue(newValue);
|
|
72
|
-
checkOverflow();
|
|
73
69
|
}
|
|
74
70
|
onKeyDown?.(event, newValue);
|
|
75
71
|
};
|
|
76
72
|
const handleChange = (event, val) => {
|
|
77
73
|
setValue(val);
|
|
78
|
-
checkOverflow();
|
|
79
74
|
onChange?.(event, val);
|
|
80
75
|
};
|
|
81
76
|
return /* @__PURE__ */ jsx("div", { className: cx(classes.root, className), children: editMode && !disabled ? /* @__PURE__ */ jsx(
|
|
@@ -85,8 +80,7 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
|
85
80
|
inputRef,
|
|
86
81
|
classes: {
|
|
87
82
|
root: classes.inputRoot,
|
|
88
|
-
input: classes.input
|
|
89
|
-
inputBorderContainer: classes.inputBorderContainer
|
|
83
|
+
input: classes.input
|
|
90
84
|
},
|
|
91
85
|
inputProps: {
|
|
92
86
|
style: {
|
|
@@ -100,7 +94,7 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
|
100
94
|
onKeyDown: handleKeyDown,
|
|
101
95
|
...others
|
|
102
96
|
}
|
|
103
|
-
) : /* @__PURE__ */ jsx(
|
|
97
|
+
) : /* @__PURE__ */ jsx(
|
|
104
98
|
HvButton,
|
|
105
99
|
{
|
|
106
100
|
variant: "secondaryGhost",
|
|
@@ -120,18 +114,20 @@ const HvInlineEditor = fixedForwardRef(function HvInlineEditor2(props, ref) {
|
|
|
120
114
|
onClick: handleClick,
|
|
121
115
|
disabled,
|
|
122
116
|
...buttonProps,
|
|
123
|
-
children: /* @__PURE__ */ jsx(
|
|
117
|
+
children: /* @__PURE__ */ jsx(HvTooltip, { title: isOverflowing && value, children: /* @__PURE__ */ jsx(
|
|
124
118
|
HvTypography,
|
|
125
119
|
{
|
|
120
|
+
component: "div",
|
|
121
|
+
ref: checkOverflow,
|
|
126
122
|
variant,
|
|
127
123
|
noWrap: true,
|
|
128
124
|
className: cx(classes.text, { [classes.textEmpty]: !value }),
|
|
129
125
|
...typographyProps,
|
|
130
126
|
children: value || placeholder
|
|
131
127
|
}
|
|
132
|
-
)
|
|
128
|
+
) })
|
|
133
129
|
}
|
|
134
|
-
) })
|
|
130
|
+
) });
|
|
135
131
|
});
|
|
136
132
|
export {
|
|
137
133
|
HvInlineEditor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useEnhancedEffect } from \"../hooks/useEnhancedEffect\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport { HvTooltip } from \"../Tooltip\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n HvTypography,\n HvTypographyProps,\n HvTypographyVariants,\n} from \"../Typography\";\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 /** Called when there's a keydown event on the input. */\n onKeyDown?: (\n event:\n | React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>\n | React.MouseEvent,\n value: string,\n ) => 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 const [isOverflowing, setIsOverflowing] = useState(false);\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n const checkOverflow = () => {\n if (
|
|
1
|
+
{"version":3,"file":"InlineEditor.js","sources":["../../../src/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { useRef, useState } from \"react\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useEnhancedEffect } from \"../hooks/useEnhancedEffect\";\nimport { HvInput, HvInputProps } from \"../Input\";\nimport { HvTooltip } from \"../Tooltip\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n HvTypography,\n HvTypographyProps,\n HvTypographyVariants,\n} from \"../Typography\";\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 /** Called when there's a keydown event on the input. */\n onKeyDown?: (\n event:\n | React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>\n | React.MouseEvent,\n value: string,\n ) => 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 const [isOverflowing, setIsOverflowing] = useState(false);\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n const checkOverflow = (el: HTMLElement | null) => {\n if (!el) return;\n setIsOverflowing(el.scrollWidth > el.clientWidth);\n };\n\n useEnhancedEffect(() => {\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 let newValue = value;\n if (isKey(event, \"Esc\")) {\n newValue = cachedValue;\n setEditMode(false);\n setValue(newValue);\n }\n onKeyDown?.(event, newValue);\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 }}\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 <HvTooltip title={isOverflowing && value}>\n <HvTypography\n component=\"div\"\n ref={checkOverflow}\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n </HvTooltip>\n </HvButton>\n )}\n </div>\n );\n});\n"],"names":["HvInlineEditor"],"mappings":"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"}
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
2
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
|
-
import { staticClasses as staticClasses$1 } from "../BaseInput/BaseInput.styles.js";
|
|
4
|
-
import "../BaseInput/BaseInput.js";
|
|
5
|
-
import { staticClasses as staticClasses$2 } from "../Input/Input.styles.js";
|
|
6
|
-
import "../Input/Input.js";
|
|
7
3
|
const { staticClasses, useClasses } = createClasses("HvInlineEditor", {
|
|
8
|
-
root: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
minHeight: "32px"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
inputBorderContainer: {
|
|
15
|
-
top: "unset",
|
|
16
|
-
bottom: 0
|
|
17
|
-
},
|
|
4
|
+
root: {},
|
|
5
|
+
/** @deprecated unused. use `classes.root::after` instead */
|
|
6
|
+
inputBorderContainer: {},
|
|
18
7
|
input: {},
|
|
19
|
-
inputRoot: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
textOverflow: "ellipsis",
|
|
23
|
-
whiteSpace: "nowrap",
|
|
24
|
-
alignSelf: "center"
|
|
8
|
+
inputRoot: {
|
|
9
|
+
height: "100%",
|
|
10
|
+
minHeight: "32px"
|
|
25
11
|
},
|
|
12
|
+
text: {},
|
|
26
13
|
largeText: {},
|
|
27
14
|
textEmpty: {
|
|
28
15
|
color: theme.colors.secondary_60
|
|
@@ -35,41 +22,31 @@ const { staticClasses, useClasses } = createClasses("HvInlineEditor", {
|
|
|
35
22
|
height: "100%",
|
|
36
23
|
width: "100%",
|
|
37
24
|
maxWidth: "100%",
|
|
38
|
-
justifyContent: "
|
|
25
|
+
justifyContent: "start",
|
|
26
|
+
textAlign: "start",
|
|
39
27
|
alignItems: "center",
|
|
40
28
|
backgroundColor: theme.colors.atmo1,
|
|
41
|
-
|
|
29
|
+
borderColor: "transparent",
|
|
42
30
|
"&:hover, &:focus": {
|
|
43
|
-
|
|
31
|
+
borderColor: theme.colors.primary,
|
|
44
32
|
backgroundColor: theme.colors.atmo1,
|
|
45
33
|
"& $icon": {
|
|
46
34
|
visibility: "visible"
|
|
47
35
|
}
|
|
48
36
|
},
|
|
49
37
|
"&:active": {
|
|
50
|
-
|
|
38
|
+
borderColor: theme.colors.secondary,
|
|
51
39
|
backgroundColor: "transparent",
|
|
52
40
|
"& $icon": {
|
|
53
41
|
visibility: "visible"
|
|
54
42
|
}
|
|
55
|
-
},
|
|
56
|
-
"& > div": {
|
|
57
|
-
width: "100%"
|
|
58
|
-
},
|
|
59
|
-
"& > div > span": {
|
|
60
|
-
width: "100%"
|
|
61
43
|
}
|
|
62
44
|
},
|
|
63
45
|
icon: {
|
|
64
46
|
cursor: "pointer",
|
|
65
47
|
visibility: "hidden",
|
|
66
48
|
alignSelf: "center",
|
|
67
|
-
height:
|
|
68
|
-
width: "32px",
|
|
69
|
-
minWidth: "32px",
|
|
70
|
-
"& svg": {
|
|
71
|
-
margin: theme.spacing(0, "xs")
|
|
72
|
-
}
|
|
49
|
+
height: 16
|
|
73
50
|
},
|
|
74
51
|
iconVisible: {
|
|
75
52
|
visibility: "visible"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEditor.styles.js","sources":["../../../src/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\
|
|
1
|
+
{"version":3,"file":"InlineEditor.styles.js","sources":["../../../src/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvInlineEditor\", {\n root: {},\n /** @deprecated unused. use `classes.root::after` instead */\n inputBorderContainer: {},\n input: {},\n inputRoot: {\n height: \"100%\",\n minHeight: \"32px\",\n },\n text: {},\n largeText: {},\n textEmpty: {\n color: theme.colors.secondary_60,\n },\n button: {\n padding: theme.spacing(\"6px\", \"8px\", \"5px\", \"8px\"),\n minHeight: \"32px\",\n\n boxSizing: \"border-box\",\n cursor: \"text\",\n height: \"100%\",\n width: \"100%\",\n maxWidth: \"100%\",\n justifyContent: \"start\",\n textAlign: \"start\",\n alignItems: \"center\",\n\n backgroundColor: theme.colors.atmo1,\n borderColor: \"transparent\",\n\n \"&:hover, &:focus\": {\n borderColor: theme.colors.primary,\n backgroundColor: theme.colors.atmo1,\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n\n \"&:active\": {\n borderColor: theme.colors.secondary,\n backgroundColor: \"transparent\",\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n },\n icon: {\n cursor: \"pointer\",\n visibility: \"hidden\",\n alignSelf: \"center\",\n height: 16,\n },\n iconVisible: {\n visibility: \"visible\",\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,kBAAkB;AAAA,EAC3E,MAAM,CAAC;AAAA;AAAA,EAEP,sBAAsB,CAAC;AAAA,EACvB,OAAO,CAAC;AAAA,EACR,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,MAAM,CAAC;AAAA,EACP,WAAW,CAAC;AAAA,EACZ,WAAW;AAAA,IACT,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,MAAM,QAAQ,OAAO,OAAO,OAAO,KAAK;AAAA,IACjD,WAAW;AAAA,IAEX,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,YAAY;AAAA,IAEZ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,aAAa;AAAA,IAEb,oBAAoB;AAAA,MAClB,aAAa,MAAM,OAAO;AAAA,MAC1B,iBAAiB,MAAM,OAAO;AAAA,MAE9B,WAAW;AAAA,QACT,YAAY;AAAA,MAAA;AAAA,IAEhB;AAAA,IAEA,YAAY;AAAA,MACV,aAAa,MAAM,OAAO;AAAA,MAC1B,iBAAiB;AAAA,MAEjB,WAAW;AAAA,QACT,YAAY;AAAA,MAAA;AAAA,IACd;AAAA,EAEJ;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,aAAa;AAAA,IACX,YAAY;AAAA,EAAA;AAEhB,CAAC;"}
|
package/dist/esm/Input/Input.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useState, useMemo, useCallback,
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, cloneElement, isValidElement, useEffect } from "react";
|
|
3
3
|
import { useForkRef } from "@mui/material/utils";
|
|
4
4
|
import { CloseXS, Search, PreviewOff, Preview, Success } from "@hitachivantara/uikit-react-icons";
|
|
5
5
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
@@ -53,7 +53,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
53
53
|
id,
|
|
54
54
|
name,
|
|
55
55
|
value: valueProp,
|
|
56
|
-
defaultValue
|
|
56
|
+
defaultValue,
|
|
57
57
|
required,
|
|
58
58
|
readOnly,
|
|
59
59
|
disabled,
|
|
@@ -98,8 +98,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
98
98
|
const suggestionsRef = useRef(null);
|
|
99
99
|
const [focused, setFocused] = useState(false);
|
|
100
100
|
const isDirty = useRef(false);
|
|
101
|
-
const
|
|
102
|
-
const isEmptyValue = value == null || value === "";
|
|
101
|
+
const isEmptyValue = !inputRef.current?.value;
|
|
103
102
|
const [validationState, setValidationState] = useControlled(
|
|
104
103
|
status,
|
|
105
104
|
validationStates.standBy
|
|
@@ -123,7 +122,6 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
123
122
|
const performValidation = useCallback(() => {
|
|
124
123
|
const inputValidity = validateInput(
|
|
125
124
|
inputRef.current,
|
|
126
|
-
String(value),
|
|
127
125
|
required,
|
|
128
126
|
minCharQuantity,
|
|
129
127
|
maxCharQuantity,
|
|
@@ -144,8 +142,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
144
142
|
setValidationMessage,
|
|
145
143
|
setValidationState,
|
|
146
144
|
validation,
|
|
147
|
-
validationType
|
|
148
|
-
value
|
|
145
|
+
validationType
|
|
149
146
|
]);
|
|
150
147
|
const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && hasBuiltInValidations(
|
|
151
148
|
required,
|
|
@@ -199,7 +196,6 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
199
196
|
};
|
|
200
197
|
const onChangeHandler = (event, newValue) => {
|
|
201
198
|
isDirty.current = true;
|
|
202
|
-
setValue(newValue);
|
|
203
199
|
onChange?.(event, newValue);
|
|
204
200
|
if (canShowSuggestions) {
|
|
205
201
|
suggestionHandler(newValue);
|
|
@@ -209,12 +205,12 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
209
205
|
if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;
|
|
210
206
|
setFocused(false);
|
|
211
207
|
const inputValidity = performValidation();
|
|
212
|
-
onBlur?.(event,
|
|
208
|
+
onBlur?.(event, event.target.value, inputValidity);
|
|
213
209
|
};
|
|
214
210
|
const onFocusHandler = (event) => {
|
|
215
211
|
setFocused(true);
|
|
216
212
|
setValidationState(validationStates.standBy);
|
|
217
|
-
onFocus?.(event,
|
|
213
|
+
onFocus?.(event, event.target.value);
|
|
218
214
|
};
|
|
219
215
|
const getSuggestions = (li) => {
|
|
220
216
|
const listEl = document.getElementById(
|
|
@@ -231,13 +227,14 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
231
227
|
}
|
|
232
228
|
};
|
|
233
229
|
const onKeyDownHandler = (event) => {
|
|
230
|
+
const { value } = event.currentTarget;
|
|
234
231
|
if (isKey(event, "ArrowDown") && hasSuggestions) {
|
|
235
232
|
const li = getSuggestions(0);
|
|
236
233
|
li?.focus();
|
|
237
234
|
} else if (isKey(event, "Enter")) {
|
|
238
|
-
onEnter?.(event,
|
|
235
|
+
onEnter?.(event, value);
|
|
239
236
|
}
|
|
240
|
-
onKeyDown?.(event,
|
|
237
|
+
onKeyDown?.(event, value);
|
|
241
238
|
};
|
|
242
239
|
const onContainerBlurHandler = (event) => {
|
|
243
240
|
if (event.relatedTarget) {
|
|
@@ -247,8 +244,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
247
244
|
}, 10);
|
|
248
245
|
}
|
|
249
246
|
};
|
|
250
|
-
const
|
|
251
|
-
const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!hasOnEnter || type !== "search" || disableSearchButton || validationState !== validationStates.standBy);
|
|
247
|
+
const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!onEnter || type !== "search" || disableSearchButton || validationState !== validationStates.standBy);
|
|
252
248
|
const showSearchIcon = type === "search" && !disableSearchButton;
|
|
253
249
|
const showRevealPasswordButton = type === "password" && !disableRevealPassword;
|
|
254
250
|
const handleClear = useCallback(
|
|
@@ -288,42 +284,27 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
288
284
|
elementId,
|
|
289
285
|
cx
|
|
290
286
|
]);
|
|
291
|
-
const handleSearch = useCallback(
|
|
292
|
-
(event) => {
|
|
293
|
-
onEnter?.(event, String(value));
|
|
294
|
-
},
|
|
295
|
-
[onEnter, value]
|
|
296
|
-
);
|
|
297
287
|
const searchButton = useMemo(() => {
|
|
298
|
-
const reallyShowIt = showSearchIcon && (isEmptyValue ||
|
|
299
|
-
if (!reallyShowIt)
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
288
|
+
const reallyShowIt = showSearchIcon && (isEmptyValue || onEnter && validationState === validationStates.standBy);
|
|
289
|
+
if (!reallyShowIt) return null;
|
|
302
290
|
return /* @__PURE__ */ jsx(
|
|
303
291
|
HvAdornment,
|
|
304
292
|
{
|
|
305
293
|
className: classes.adornmentButton,
|
|
306
|
-
onClick:
|
|
307
|
-
|
|
308
|
-
icon: /* @__PURE__ */ jsx(Search, {})
|
|
294
|
+
onClick: onEnter && ((evt) => onEnter?.(evt, inputRef.current?.value ?? "")),
|
|
295
|
+
icon: /* @__PURE__ */ jsx(Search, { title: labels.searchButtonLabel })
|
|
309
296
|
}
|
|
310
297
|
);
|
|
311
298
|
}, [
|
|
312
299
|
showSearchIcon,
|
|
313
300
|
isEmptyValue,
|
|
314
|
-
|
|
301
|
+
onEnter,
|
|
315
302
|
validationState,
|
|
316
303
|
classes.adornmentButton,
|
|
317
|
-
|
|
318
|
-
labels?.searchButtonLabel
|
|
304
|
+
labels.searchButtonLabel
|
|
319
305
|
]);
|
|
320
|
-
const handleRevealPassword = useCallback(() => {
|
|
321
|
-
setRevealPassword(!revealPassword);
|
|
322
|
-
}, [revealPassword]);
|
|
323
306
|
const revealPasswordButton = useMemo(() => {
|
|
324
|
-
if (!showRevealPasswordButton)
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
307
|
+
if (!showRevealPasswordButton) return null;
|
|
327
308
|
return /* @__PURE__ */ jsx(
|
|
328
309
|
HvTooltip,
|
|
329
310
|
{
|
|
@@ -334,10 +315,12 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
334
315
|
HvAdornment,
|
|
335
316
|
{
|
|
336
317
|
className: classes.adornmentButton,
|
|
337
|
-
onClick:
|
|
318
|
+
onClick: () => setRevealPassword((s) => !s),
|
|
338
319
|
"aria-label": labels?.revealPasswordButtonLabel,
|
|
339
320
|
"aria-controls": setId(elementId, "input"),
|
|
340
|
-
icon: revealPassword ? /* @__PURE__ */ jsx(PreviewOff, {}) : /* @__PURE__ */ jsx(Preview, {})
|
|
321
|
+
icon: revealPassword ? /* @__PURE__ */ jsx(PreviewOff, {}) : /* @__PURE__ */ jsx(Preview, {}),
|
|
322
|
+
tabIndex: 0,
|
|
323
|
+
...{ selected: revealPassword }
|
|
341
324
|
}
|
|
342
325
|
)
|
|
343
326
|
}
|
|
@@ -349,28 +332,23 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
349
332
|
labels?.revealPasswordButtonClickToShowTooltip,
|
|
350
333
|
labels?.revealPasswordButtonLabel,
|
|
351
334
|
classes.adornmentButton,
|
|
352
|
-
handleRevealPassword,
|
|
353
335
|
elementId
|
|
354
336
|
]);
|
|
355
337
|
const validationIcon = useMemo(() => {
|
|
356
|
-
if (!showValidationIcon)
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
if (!isValid(validationState)) {
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
338
|
+
if (!showValidationIcon) return null;
|
|
339
|
+
if (!isValid(validationState)) return null;
|
|
362
340
|
return /* @__PURE__ */ jsx(Success, { color: "positive", className: classes.icon });
|
|
363
341
|
}, [showValidationIcon, validationState, classes.icon]);
|
|
364
342
|
const customIconEl = useMemo(
|
|
365
|
-
() => isValidElement(endAdornment)
|
|
343
|
+
() => isValidElement(endAdornment) ? cloneElement(endAdornment, {
|
|
366
344
|
className: cx(endAdornment.props.className, classes.icon)
|
|
367
|
-
}),
|
|
345
|
+
}) : endAdornment,
|
|
368
346
|
[classes.icon, endAdornment, cx]
|
|
369
347
|
);
|
|
370
348
|
const adornments = useMemo(() => {
|
|
371
349
|
if (!clearButton && !revealPasswordButton && !searchButton && !validationIcon && !customIconEl)
|
|
372
350
|
return null;
|
|
373
|
-
return /* @__PURE__ */ jsxs("div", { className: classes.adornmentsBox,
|
|
351
|
+
return /* @__PURE__ */ jsxs("div", { className: classes.adornmentsBox, children: [
|
|
374
352
|
clearButton,
|
|
375
353
|
revealPasswordButton,
|
|
376
354
|
searchButton,
|
|
@@ -434,7 +412,8 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
434
412
|
{
|
|
435
413
|
id: hasLabel || showClear || showRevealPasswordButton ? setId(elementId, "input") : setId(id, "input"),
|
|
436
414
|
name,
|
|
437
|
-
value,
|
|
415
|
+
value: valueProp,
|
|
416
|
+
defaultValue,
|
|
438
417
|
required,
|
|
439
418
|
readOnly,
|
|
440
419
|
disabled,
|
|
@@ -447,11 +426,10 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
447
426
|
type: realType,
|
|
448
427
|
classes: {
|
|
449
428
|
input: classes.input,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
inputBorderContainer: classes.inputBorderContainer
|
|
429
|
+
root: classes.inputRoot,
|
|
430
|
+
focused: classes.inputRootFocused,
|
|
431
|
+
disabled: classes.inputRootDisabled,
|
|
432
|
+
multiline: classes.inputRootMultiline
|
|
455
433
|
},
|
|
456
434
|
invalid: isStateInvalid,
|
|
457
435
|
inputProps: {
|
|
@@ -461,13 +439,12 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
461
439
|
"aria-errormessage": errorMessageId,
|
|
462
440
|
"aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description ? setId(elementId, "description") : void 0,
|
|
463
441
|
"aria-controls": canShowSuggestions ? setId(elementId, "suggestions") : void 0,
|
|
464
|
-
ref: inputRef,
|
|
465
442
|
// prevent browsers auto-fill/suggestions when we have our own
|
|
466
443
|
autoComplete: canShowSuggestions ? "off" : void 0,
|
|
467
444
|
onFocus: (event) => {
|
|
468
445
|
inputProps.onFocus?.(event);
|
|
469
446
|
if (canShowSuggestions && suggestOnFocus) {
|
|
470
|
-
suggestionHandler(
|
|
447
|
+
suggestionHandler(event.currentTarget.value);
|
|
471
448
|
}
|
|
472
449
|
},
|
|
473
450
|
onClick: (event) => {
|
|
@@ -476,7 +453,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
|
|
|
476
453
|
},
|
|
477
454
|
...inputProps
|
|
478
455
|
},
|
|
479
|
-
|
|
456
|
+
ref: forkedRef,
|
|
480
457
|
endAdornment: adornments,
|
|
481
458
|
...others
|
|
482
459
|
}
|