@hitachivantara/uikit-react-core 5.73.2 → 5.75.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/Accordion/Accordion.cjs +23 -55
- package/dist/cjs/Accordion/Accordion.styles.cjs +2 -27
- package/dist/cjs/ActionsGeneric/ActionsGeneric.styles.cjs +4 -8
- package/dist/cjs/Badge/Badge.cjs +18 -13
- package/dist/cjs/Badge/Badge.styles.cjs +25 -14
- package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.cjs +0 -1
- package/dist/cjs/BaseDropdown/BaseDropdown.cjs +4 -0
- package/dist/cjs/BaseDropdown/BaseDropdownContext/BaseDropdownContext.cjs +1 -2
- package/dist/cjs/BreadCrumb/BreadCrumb.cjs +6 -10
- package/dist/cjs/ButtonBase/ButtonBase.cjs +53 -0
- package/dist/cjs/ButtonBase/ButtonBase.styles.cjs +34 -0
- package/dist/cjs/Calendar/CalendarNavigation/MonthSelector/MonthSelector.cjs +6 -22
- package/dist/cjs/Calendar/CalendarNavigation/MonthSelector/MonthSelector.styles.cjs +6 -38
- package/dist/cjs/Calendar/SingleCalendar/CalendarCell.cjs +4 -10
- package/dist/cjs/Calendar/SingleCalendar/CalendarCell.styles.cjs +1 -20
- package/dist/cjs/ColorPicker/SavedColors/SavedColors.cjs +0 -1
- package/dist/cjs/DatePicker/DatePicker.cjs +2 -1
- package/dist/cjs/DatePicker/DatePicker.styles.cjs +2 -1
- package/dist/cjs/InlineEditor/InlineEditor.cjs +2 -1
- package/dist/cjs/Loading/Loading.cjs +12 -7
- package/dist/cjs/Loading/Loading.styles.cjs +33 -82
- package/dist/cjs/LoadingContainer/LoadingContainer.cjs +4 -2
- package/dist/cjs/LoadingContainer/LoadingContainer.styles.cjs +1 -1
- package/dist/cjs/Section/Section.cjs +10 -14
- package/dist/cjs/Table/hooks/useBulkActions.cjs +1 -2
- package/dist/cjs/Table/hooks/useFilters.cjs +1 -2
- package/dist/cjs/Table/hooks/useGlobalFilter.cjs +1 -2
- package/dist/cjs/Table/hooks/useHeaderGroups.cjs +1 -2
- package/dist/cjs/Table/hooks/usePagination.cjs +1 -2
- package/dist/cjs/Table/hooks/useResizeColumns.cjs +1 -2
- package/dist/cjs/Table/hooks/useRowExpand.cjs +1 -2
- package/dist/cjs/Table/hooks/useRowSelection.cjs +1 -2
- package/dist/cjs/Table/hooks/useRowState.cjs +1 -2
- package/dist/cjs/Table/hooks/useSortBy.cjs +1 -2
- package/dist/cjs/Table/hooks/useSticky.cjs +1 -2
- package/dist/cjs/Table/hooks/useTableStyles.cjs +1 -2
- package/dist/cjs/TextArea/TextArea.styles.cjs +1 -1
- package/dist/cjs/hooks/useExpandable.cjs +32 -0
- package/dist/cjs/hooks/useUniqueId.cjs +2 -1
- package/dist/cjs/index.cjs +41 -37
- package/dist/esm/Accordion/Accordion.js +24 -56
- package/dist/esm/Accordion/Accordion.js.map +1 -1
- package/dist/esm/Accordion/Accordion.styles.js +2 -27
- package/dist/esm/Accordion/Accordion.styles.js.map +1 -1
- package/dist/esm/ActionsGeneric/ActionsGeneric.styles.js +4 -8
- package/dist/esm/ActionsGeneric/ActionsGeneric.styles.js.map +1 -1
- package/dist/esm/Badge/Badge.js +18 -13
- package/dist/esm/Badge/Badge.js.map +1 -1
- package/dist/esm/Badge/Badge.styles.js +25 -14
- package/dist/esm/Badge/Badge.styles.js.map +1 -1
- package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js +0 -1
- package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js.map +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.js +4 -0
- package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/esm/BaseDropdown/BaseDropdownContext/BaseDropdownContext.js +1 -2
- package/dist/esm/BaseDropdown/BaseDropdownContext/BaseDropdownContext.js.map +1 -1
- package/dist/esm/BreadCrumb/BreadCrumb.js +6 -10
- package/dist/esm/BreadCrumb/BreadCrumb.js.map +1 -1
- package/dist/esm/ButtonBase/ButtonBase.js +54 -0
- package/dist/esm/ButtonBase/ButtonBase.js.map +1 -0
- package/dist/esm/ButtonBase/ButtonBase.styles.js +34 -0
- package/dist/esm/ButtonBase/ButtonBase.styles.js.map +1 -0
- package/dist/esm/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js +6 -22
- package/dist/esm/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js.map +1 -1
- package/dist/esm/Calendar/CalendarNavigation/MonthSelector/MonthSelector.styles.js +6 -38
- package/dist/esm/Calendar/CalendarNavigation/MonthSelector/MonthSelector.styles.js.map +1 -1
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.js +4 -10
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.js.map +1 -1
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.styles.js +1 -20
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.styles.js.map +1 -1
- package/dist/esm/ColorPicker/SavedColors/SavedColors.js +0 -1
- package/dist/esm/ColorPicker/SavedColors/SavedColors.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.js +2 -1
- package/dist/esm/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.styles.js +2 -1
- package/dist/esm/DatePicker/DatePicker.styles.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.js +3 -2
- package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/Loading/Loading.js +13 -8
- package/dist/esm/Loading/Loading.js.map +1 -1
- package/dist/esm/Loading/Loading.styles.js +33 -82
- package/dist/esm/Loading/Loading.styles.js.map +1 -1
- package/dist/esm/LoadingContainer/LoadingContainer.js +4 -2
- package/dist/esm/LoadingContainer/LoadingContainer.js.map +1 -1
- package/dist/esm/LoadingContainer/LoadingContainer.styles.js +1 -1
- package/dist/esm/LoadingContainer/LoadingContainer.styles.js.map +1 -1
- package/dist/esm/Section/Section.js +11 -15
- package/dist/esm/Section/Section.js.map +1 -1
- package/dist/esm/Table/hooks/useBulkActions.js +1 -2
- package/dist/esm/Table/hooks/useBulkActions.js.map +1 -1
- package/dist/esm/Table/hooks/useFilters.js +1 -2
- package/dist/esm/Table/hooks/useFilters.js.map +1 -1
- package/dist/esm/Table/hooks/useGlobalFilter.js +1 -2
- package/dist/esm/Table/hooks/useGlobalFilter.js.map +1 -1
- package/dist/esm/Table/hooks/useHeaderGroups.js +1 -2
- package/dist/esm/Table/hooks/useHeaderGroups.js.map +1 -1
- package/dist/esm/Table/hooks/usePagination.js +1 -2
- package/dist/esm/Table/hooks/usePagination.js.map +1 -1
- package/dist/esm/Table/hooks/useResizeColumns.js +1 -2
- package/dist/esm/Table/hooks/useResizeColumns.js.map +1 -1
- package/dist/esm/Table/hooks/useRowExpand.js +1 -2
- package/dist/esm/Table/hooks/useRowExpand.js.map +1 -1
- package/dist/esm/Table/hooks/useRowSelection.js +1 -2
- package/dist/esm/Table/hooks/useRowSelection.js.map +1 -1
- package/dist/esm/Table/hooks/useRowState.js +1 -2
- package/dist/esm/Table/hooks/useRowState.js.map +1 -1
- package/dist/esm/Table/hooks/useSortBy.js +1 -2
- package/dist/esm/Table/hooks/useSortBy.js.map +1 -1
- package/dist/esm/Table/hooks/useSticky.js +1 -2
- package/dist/esm/Table/hooks/useSticky.js.map +1 -1
- package/dist/esm/Table/hooks/useTable.js +2 -2
- package/dist/esm/Table/hooks/useTable.js.map +1 -1
- package/dist/esm/Table/hooks/useTableStyles.js +1 -2
- package/dist/esm/Table/hooks/useTableStyles.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/hooks/useExpandable.js +32 -0
- package/dist/esm/hooks/useExpandable.js.map +1 -0
- package/dist/esm/hooks/useUniqueId.js +2 -1
- package/dist/esm/hooks/useUniqueId.js.map +1 -1
- package/dist/esm/index.js +254 -250
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +2175 -2112
- package/package.json +7 -7
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import { DropUpXS
|
|
3
|
+
import { DropUpXS } from "@hitachivantara/uikit-react-icons";
|
|
4
4
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
5
|
-
import {
|
|
6
|
-
import { useUniqueId } from "../hooks/useUniqueId.js";
|
|
7
|
-
import { setId } from "../utils/setId.js";
|
|
5
|
+
import { useExpandable } from "../hooks/useExpandable.js";
|
|
8
6
|
import { useClasses } from "./Accordion.styles.js";
|
|
9
7
|
import { staticClasses } from "./Accordion.styles.js";
|
|
8
|
+
import { HvButtonBase } from "../ButtonBase/ButtonBase.js";
|
|
10
9
|
import { HvTypography } from "../Typography/Typography.js";
|
|
11
10
|
const HvAccordion = (props) => {
|
|
12
11
|
const {
|
|
@@ -25,72 +24,44 @@ const HvAccordion = (props) => {
|
|
|
25
24
|
disableEventHandling,
|
|
26
25
|
...others
|
|
27
26
|
} = useDefaultProps("HvAccordion", props);
|
|
28
|
-
const id = useUniqueId(idProp);
|
|
29
27
|
const { classes, cx } = useClasses(classesProp);
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
const { isOpen, toggleOpen, buttonProps, regionProps } = useExpandable({
|
|
29
|
+
id: idProp,
|
|
30
|
+
expanded,
|
|
31
|
+
disabled,
|
|
32
|
+
defaultExpanded
|
|
33
|
+
});
|
|
34
|
+
const handleClick = useCallback(
|
|
32
35
|
(event) => {
|
|
33
36
|
if (!disabled) {
|
|
34
37
|
onChange?.(event, isOpen);
|
|
35
|
-
|
|
36
|
-
return true;
|
|
38
|
+
toggleOpen();
|
|
37
39
|
}
|
|
38
|
-
return false;
|
|
39
|
-
},
|
|
40
|
-
[disabled, onChange, isOpen, setIsOpen]
|
|
41
|
-
);
|
|
42
|
-
const handleClick = useCallback(
|
|
43
|
-
(event) => {
|
|
44
|
-
handleAction(event);
|
|
45
40
|
if (!disableEventHandling) {
|
|
46
41
|
event.preventDefault();
|
|
47
42
|
event.stopPropagation();
|
|
48
43
|
}
|
|
49
44
|
},
|
|
50
|
-
[disableEventHandling,
|
|
51
|
-
);
|
|
52
|
-
const handleKeyDown = useCallback(
|
|
53
|
-
(event) => {
|
|
54
|
-
let isEventHandled = false;
|
|
55
|
-
const { key } = event;
|
|
56
|
-
if (event.altKey || event.ctrlKey || event.metaKey || event.currentTarget !== event.target) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
switch (key) {
|
|
60
|
-
case "Enter":
|
|
61
|
-
case " ":
|
|
62
|
-
isEventHandled = handleAction(event);
|
|
63
|
-
break;
|
|
64
|
-
default:
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (isEventHandled && !disableEventHandling) {
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
event.stopPropagation();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
[disableEventHandling, handleAction]
|
|
45
|
+
[disableEventHandling, disabled, isOpen, onChange, toggleOpen]
|
|
73
46
|
);
|
|
74
|
-
const accordionHeaderId = setId(id, "button");
|
|
75
|
-
const accordionContainer = setId(id, "container");
|
|
76
47
|
const accordionHeader = useMemo(() => {
|
|
77
|
-
const color = disabled ? "secondary_60" : void 0;
|
|
78
48
|
const accordionButton = /* @__PURE__ */ jsxs(
|
|
79
49
|
HvTypography,
|
|
80
50
|
{
|
|
81
|
-
|
|
82
|
-
component:
|
|
83
|
-
role: "button",
|
|
51
|
+
...buttonProps,
|
|
52
|
+
component: HvButtonBase,
|
|
84
53
|
className: cx(classes.label, { [classes.disabled]: disabled }),
|
|
85
54
|
disabled,
|
|
86
|
-
tabIndex: 0,
|
|
87
|
-
onKeyDown: handleKeyDown,
|
|
88
55
|
onClick: handleClick,
|
|
89
56
|
variant: labelVariant,
|
|
90
|
-
"aria-expanded": isOpen,
|
|
91
|
-
"aria-disabled": disabled,
|
|
92
57
|
children: [
|
|
93
|
-
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
DropUpXS,
|
|
60
|
+
{
|
|
61
|
+
color: "inherit",
|
|
62
|
+
style: { rotate: isOpen ? void 0 : "180deg" }
|
|
63
|
+
}
|
|
64
|
+
),
|
|
94
65
|
label
|
|
95
66
|
]
|
|
96
67
|
}
|
|
@@ -100,24 +71,21 @@ const HvAccordion = (props) => {
|
|
|
100
71
|
cx,
|
|
101
72
|
classes,
|
|
102
73
|
handleClick,
|
|
103
|
-
handleKeyDown,
|
|
104
74
|
label,
|
|
105
|
-
|
|
75
|
+
buttonProps,
|
|
106
76
|
disabled,
|
|
107
77
|
headingLevel,
|
|
108
78
|
isOpen,
|
|
109
79
|
labelVariant
|
|
110
80
|
]);
|
|
111
|
-
return /* @__PURE__ */ jsxs("div", { id, className: cx(classes.root, className), ...others, children: [
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", { id: idProp, className: cx(classes.root, className), ...others, children: [
|
|
112
82
|
accordionHeader,
|
|
113
83
|
/* @__PURE__ */ jsx(
|
|
114
84
|
"div",
|
|
115
85
|
{
|
|
116
|
-
id: accordionContainer,
|
|
117
|
-
role: "region",
|
|
118
|
-
"aria-labelledby": accordionHeaderId,
|
|
119
86
|
className: cx(classes.container, { [classes.hidden]: !isOpen }),
|
|
120
87
|
hidden: !isOpen,
|
|
88
|
+
...regionProps,
|
|
121
89
|
...containerProps,
|
|
122
90
|
children
|
|
123
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../src/Accordion/Accordion.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../../src/Accordion/Accordion.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { DropUpXS } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonBase } from \"../ButtonBase\";\nimport { useExpandable } from \"../hooks/useExpandable\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography, HvTypographyVariants } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Accordion.styles\";\n\nexport { staticClasses as accordionClasses };\n\nexport type HvAccordionClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvAccordionProps\n extends HvBaseProps<HTMLDivElement, \"onChange\" | \"children\"> {\n /** Content to be rendered. */\n children: React.ReactNode;\n /** The accordion label button. */\n label?: string;\n /** The function that will be executed whenever the accordion toggles. It will receive the state of the accordion. */\n onChange?: (event: React.SyntheticEvent, value: boolean) => void;\n /** Whether the accordion is open or not. If this property is defined the accordion must be fully controlled. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** An object containing props to be passed onto container holding the accordion children. */\n containerProps?: React.HTMLAttributes<HTMLDivElement>;\n /** Heading level to apply to accordion button. If ´undefined´ the button won't have a header wrapper. */\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** Whether the accordion is disabled. */\n disabled?: boolean;\n /** Typography variant for the label. */\n labelVariant?: HvTypographyVariants;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvAccordionClasses;\n /** Whether to disable the internal usage of `preventDefault` and `stopPropagation` when the `onChange` event is triggered. */\n disableEventHandling?: boolean; // TODO - remove in v6 as this should be the default behavior: `preventDefault` and `stopPropagation` shouldn't be triggered internally\n}\n\n/**\n * A accordion is a design element that expands in place to expose hidden information.\n */\nexport const HvAccordion = (props: HvAccordionProps) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n disabled = false,\n label,\n onChange,\n children,\n expanded,\n headingLevel,\n defaultExpanded = false,\n containerProps,\n labelVariant = \"label\",\n disableEventHandling,\n ...others\n } = useDefaultProps(\"HvAccordion\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { isOpen, toggleOpen, buttonProps, regionProps } = useExpandable({\n id: idProp,\n expanded,\n disabled,\n defaultExpanded,\n });\n\n const handleClick = useCallback(\n (event: React.SyntheticEvent) => {\n if (!disabled) {\n onChange?.(event, isOpen);\n toggleOpen();\n }\n\n if (!disableEventHandling) {\n event.preventDefault();\n event.stopPropagation();\n }\n },\n [disableEventHandling, disabled, isOpen, onChange, toggleOpen],\n );\n\n const accordionHeader = useMemo(() => {\n const accordionButton = (\n <HvTypography\n {...buttonProps}\n component={HvButtonBase}\n className={cx(classes.label, { [classes.disabled]: disabled })}\n disabled={disabled}\n onClick={handleClick}\n variant={labelVariant}\n >\n <DropUpXS\n color=\"inherit\"\n style={{ rotate: isOpen ? undefined : \"180deg\" }}\n />\n {label}\n </HvTypography>\n );\n\n return headingLevel === undefined ? (\n accordionButton\n ) : (\n <HvTypography component={`h${headingLevel}`} variant={labelVariant}>\n {accordionButton}\n </HvTypography>\n );\n }, [\n cx,\n classes,\n handleClick,\n label,\n buttonProps,\n disabled,\n headingLevel,\n isOpen,\n labelVariant,\n ]);\n\n return (\n <div id={idProp} className={cx(classes.root, className)} {...others}>\n {accordionHeader}\n <div\n className={cx(classes.container, { [classes.hidden]: !isOpen })}\n hidden={!isOpen}\n {...regionProps}\n {...containerProps}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8Ca,MAAA,cAAc,CAAC,UAA4B;AAChD,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,eAAe,KAAK;AACxC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,EAAE,QAAQ,YAAY,aAAa,YAAA,IAAgB,cAAc;AAAA,IACrE,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA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AAAA,MAAA;AAAA,IACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
|
-
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
|
-
import { outlineStyles } from "../utils/focusUtils.js";
|
|
4
2
|
const { staticClasses, useClasses } = createClasses("HvAccordion", {
|
|
5
3
|
root: {
|
|
6
4
|
"& + root": {
|
|
@@ -14,32 +12,9 @@ const { staticClasses, useClasses } = createClasses("HvAccordion", {
|
|
|
14
12
|
display: "flex",
|
|
15
13
|
justifyContent: "flex-start",
|
|
16
14
|
alignItems: "center",
|
|
17
|
-
height: "32px"
|
|
18
|
-
"&[disabled], &:active": {
|
|
19
|
-
outline: "none"
|
|
20
|
-
},
|
|
21
|
-
"&:focus": {
|
|
22
|
-
outline: "none",
|
|
23
|
-
background: theme.colors.atmo3
|
|
24
|
-
},
|
|
25
|
-
"&:hover": {
|
|
26
|
-
background: theme.colors.atmo3
|
|
27
|
-
},
|
|
28
|
-
"&:focus-visible": {
|
|
29
|
-
...outlineStyles
|
|
30
|
-
},
|
|
31
|
-
cursor: "pointer"
|
|
15
|
+
height: "32px"
|
|
32
16
|
},
|
|
33
|
-
disabled: {
|
|
34
|
-
cursor: "not-allowed",
|
|
35
|
-
color: theme.colors.secondary_60,
|
|
36
|
-
"&:focus": {
|
|
37
|
-
background: "none"
|
|
38
|
-
},
|
|
39
|
-
"&:hover": {
|
|
40
|
-
background: "none"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
17
|
+
disabled: {}
|
|
43
18
|
});
|
|
44
19
|
export {
|
|
45
20
|
staticClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.styles.js","sources":["../../../src/Accordion/Accordion.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\
|
|
1
|
+
{"version":3,"file":"Accordion.styles.js","sources":["../../../src/Accordion/Accordion.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvAccordion\", {\n root: {\n \"& + root\": {\n paddingTop: 8,\n },\n },\n hidden: { height: 0, display: \"none\" },\n container: { paddingTop: 8, height: \"auto\" },\n label: {\n width: \"100%\",\n display: \"flex\",\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n height: \"32px\",\n },\n disabled: {},\n});\n"],"names":[],"mappings":";AAEO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA,EACxE,MAAM;AAAA,IACJ,YAAY;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACA,QAAQ,EAAE,QAAQ,GAAG,SAAS,OAAO;AAAA,EACrC,WAAW,EAAE,YAAY,GAAG,QAAQ,OAAO;AAAA,EAC3C,OAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAAA,EACA,UAAU,CAAC;AACb,CAAC;"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
2
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
3
|
const { staticClasses, useClasses } = createClasses("HvActionsGeneric", {
|
|
4
|
-
root: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
marginRight: theme.space.xs
|
|
8
|
-
},
|
|
9
|
-
"&:hover": {
|
|
10
|
-
backgroundColor: theme.alpha("base_light", 0.3)
|
|
11
|
-
}
|
|
4
|
+
root: {
|
|
5
|
+
display: "flex",
|
|
6
|
+
gap: theme.space.xs
|
|
12
7
|
},
|
|
8
|
+
button: {},
|
|
13
9
|
actionContainer: { display: "flex", alignItems: "center", float: "right" },
|
|
14
10
|
dropDownMenu: {},
|
|
15
11
|
dropDownMenuButton: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsGeneric.styles.js","sources":["../../../src/ActionsGeneric/ActionsGeneric.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvActionsGeneric\", {\n root: {
|
|
1
|
+
{"version":3,"file":"ActionsGeneric.styles.js","sources":["../../../src/ActionsGeneric/ActionsGeneric.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvActionsGeneric\", {\n root: {\n display: \"flex\",\n gap: theme.space.xs,\n },\n button: {},\n actionContainer: { display: \"flex\", alignItems: \"center\", float: \"right\" },\n dropDownMenu: {},\n dropDownMenuButton: {},\n dropDownMenuButtonSelected: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,oBAAoB;AAAA,EAC7E,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,iBAAiB,EAAE,SAAS,QAAQ,YAAY,UAAU,OAAO,QAAQ;AAAA,EACzE,cAAc,CAAC;AAAA,EACf,oBAAoB,CAAC;AAAA,EACrB,4BAA4B,CAAC;AAC/B,CAAC;"}
|
package/dist/esm/Badge/Badge.js
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
3
4
|
import { useClasses } from "./Badge.styles.js";
|
|
4
5
|
import { staticClasses } from "./Badge.styles.js";
|
|
5
6
|
import { HvTypography } from "../Typography/Typography.js";
|
|
6
|
-
const HvBadge = (props) => {
|
|
7
|
+
const HvBadge = forwardRef((props, ref) => {
|
|
7
8
|
const {
|
|
8
9
|
classes: classesProp,
|
|
9
10
|
className,
|
|
10
11
|
showCount = false,
|
|
11
|
-
count = 0,
|
|
12
|
+
count: countProp = 0,
|
|
12
13
|
maxCount = 99,
|
|
13
|
-
label
|
|
14
|
-
icon
|
|
15
|
-
text
|
|
16
|
-
textVariant
|
|
14
|
+
label,
|
|
15
|
+
icon,
|
|
16
|
+
text,
|
|
17
|
+
textVariant,
|
|
17
18
|
...others
|
|
18
19
|
} = useDefaultProps("HvBadge", props);
|
|
19
20
|
const { classes, cx } = useClasses(classesProp);
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const count = typeof label === "number" ? label : countProp;
|
|
22
|
+
const countValue = count > maxCount ? `${maxCount}+` : count;
|
|
23
|
+
const renderedCount = showCount && count > 0 ? countValue : "";
|
|
24
|
+
const renderedCountOrLabel = label && typeof label !== "number" ? label : renderedCount;
|
|
25
|
+
const children = icon || text && /* @__PURE__ */ jsx(HvTypography, { variant: textVariant, children: text });
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cx(classes.root, className), ...others, children: [
|
|
27
|
+
children,
|
|
28
|
+
/* @__PURE__ */ jsx("div", { className: cx({ [classes.badgeContainer]: children }), children: /* @__PURE__ */ jsx(
|
|
26
29
|
"div",
|
|
27
30
|
{
|
|
28
31
|
className: cx(classes.badgePosition, {
|
|
32
|
+
[classes.badgeHidden]: !(count > 0 || renderedCountOrLabel),
|
|
33
|
+
// TODO: remove unnecessary classes in v6 (hoist+rename `badge` to `badgePosition`)
|
|
29
34
|
[classes.badge]: !!(count > 0 || renderedCountOrLabel),
|
|
30
35
|
[classes.showCount]: !!(!label && renderedCountOrLabel),
|
|
31
36
|
[classes.showLabel]: !!label,
|
|
@@ -36,7 +41,7 @@ const HvBadge = (props) => {
|
|
|
36
41
|
}
|
|
37
42
|
) })
|
|
38
43
|
] });
|
|
39
|
-
};
|
|
44
|
+
});
|
|
40
45
|
export {
|
|
41
46
|
HvBadge,
|
|
42
47
|
staticClasses as badgeClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../src/Badge/Badge.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography, HvTypographyVariants } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Badge.styles\";\n\nexport { staticClasses as badgeClasses };\n\nexport type HvBadgeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBadgeProps extends HvBaseProps {\n /**\n * Count is the number of unread notifications.\n * Note count and label are mutually exclusive.\n * count is ignored when label is specified at the same time.\n */\n count?: number;\n /**\n * True if count should be displayed.\n
|
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../src/Badge/Badge.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography, HvTypographyVariants } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Badge.styles\";\n\nexport { staticClasses as badgeClasses };\n\nexport type HvBadgeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBadgeProps extends HvBaseProps {\n /**\n * Count is the number of unread notifications.\n * Note count and label are mutually exclusive.\n * count is ignored when label is specified at the same time.\n * @deprecated use numeric `label` instead\n */\n count?: number;\n /**\n * True if `count` should be displayed.\n *\n * NOTE: `showCount` is ignored when a **non-numeric** `label` is specified.\n */\n showCount?: boolean;\n /** The maximum number of unread notifications to be displayed */\n maxCount?: number;\n /**\n * Badge content to show in.\n *\n * If value is numeric, then `showCount` and `maxCount` will show or limit the value respectively.\n */\n label?: React.ReactNode;\n /** Icon which the notification will be attached. */\n icon?: React.ReactNode;\n /** Text which the notification will be attached. */\n text?: string;\n /** Text variant. */\n textVariant?: HvTypographyVariants;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvBadgeClasses;\n}\n\n/**\n * The badge is a component used to notify the user that something has occurred, in the app context.\n */\nexport const HvBadge = forwardRef<\n // no-indent\n HTMLDivElement,\n HvBadgeProps\n>((props, ref) => {\n const {\n classes: classesProp,\n className,\n showCount = false,\n count: countProp = 0,\n maxCount = 99,\n label,\n icon,\n text,\n textVariant,\n ...others\n } = useDefaultProps(\"HvBadge\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const count = typeof label === \"number\" ? label : countProp;\n const countValue = count > maxCount ? `${maxCount}+` : count;\n const renderedCount = showCount && count > 0 ? countValue : \"\";\n // If label is specified and non-empty, render it.\n // If showCount is specified and count > 0, render the count.\n // Otherwise, render nothing on the badge.\n // (Note count=0 should not be rendered to avoid ghosty 0.)\n const renderedCountOrLabel =\n label && typeof label !== \"number\" ? label : renderedCount;\n const children =\n icon || (text && <HvTypography variant={textVariant}>{text}</HvTypography>);\n\n return (\n <div ref={ref} className={cx(classes.root, className)} {...others}>\n {children}\n <div className={cx({ [classes.badgeContainer]: children })}>\n <div\n className={cx(classes.badgePosition, {\n [classes.badgeHidden]: !(count > 0 || renderedCountOrLabel),\n // TODO: remove unnecessary classes in v6 (hoist+rename `badge` to `badgePosition`)\n [classes.badge]: !!(count > 0 || renderedCountOrLabel),\n [classes.showCount]: !!(!label && renderedCountOrLabel),\n [classes.showLabel]: !!label,\n [classes.badgeIcon]: !!icon,\n [classes.badgeOneDigit]: String(renderedCountOrLabel).length === 1,\n })}\n >\n {renderedCountOrLabel}\n </div>\n </div>\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;AAiDO,MAAM,UAAU,WAIrB,CAAC,OAAO,QAAQ;AACV,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA,YAAY;AAAA,IACZ,OAAO,YAAY;AAAA,IACnB,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AA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|
5
|
-
padding: "0 5px",
|
|
6
|
-
color: theme.colors.atmo1,
|
|
7
|
-
lineHeight: "16px"
|
|
8
|
-
};
|
|
9
3
|
const { staticClasses, useClasses } = createClasses("HvBadge", {
|
|
10
4
|
root: { position: "relative", "&>*": { float: "left" } },
|
|
5
|
+
/** class applied to the badge container when it has content */
|
|
11
6
|
badgeContainer: { width: 0 },
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/** class applied to the badge */
|
|
8
|
+
badgePosition: {
|
|
9
|
+
...theme.typography.caption2,
|
|
10
|
+
color: theme.colors.atmo1,
|
|
11
|
+
borderRadius: theme.radii.full,
|
|
15
12
|
backgroundColor: theme.colors.secondary,
|
|
13
|
+
lineHeight: "16px",
|
|
14
|
+
minWidth: 8,
|
|
15
|
+
padding: "0 5px",
|
|
16
16
|
float: "left",
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
wordBreak: "keep-all",
|
|
18
|
+
textAlign: "center",
|
|
19
|
+
":empty": {
|
|
20
|
+
height: 8,
|
|
21
|
+
width: 8,
|
|
22
|
+
padding: 0
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
/** applied to the badge when it's visible */
|
|
26
|
+
badge: {},
|
|
27
|
+
/** applied to the badge when it's hidden */
|
|
28
|
+
badgeHidden: {
|
|
29
|
+
display: "none"
|
|
19
30
|
},
|
|
20
|
-
showCount: {
|
|
21
|
-
showLabel: {
|
|
31
|
+
showCount: {},
|
|
32
|
+
showLabel: {},
|
|
22
33
|
badgeIcon: { position: "relative", top: "1px", left: "-7px" },
|
|
23
|
-
badgeOneDigit: { padding: 0, width: "16px"
|
|
34
|
+
badgeOneDigit: { padding: 0, width: "16px" }
|
|
24
35
|
});
|
|
25
36
|
export {
|
|
26
37
|
staticClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.styles.js","sources":["../../../src/Badge/Badge.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\
|
|
1
|
+
{"version":3,"file":"Badge.styles.js","sources":["../../../src/Badge/Badge.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBadge\", {\n root: { position: \"relative\", \"&>*\": { float: \"left\" } },\n /** class applied to the badge container when it has content */\n badgeContainer: { width: 0 },\n /** class applied to the badge */\n badgePosition: {\n ...theme.typography.caption2,\n color: theme.colors.atmo1,\n borderRadius: theme.radii.full,\n backgroundColor: theme.colors.secondary,\n lineHeight: \"16px\",\n minWidth: 8,\n padding: \"0 5px\",\n float: \"left\",\n wordBreak: \"keep-all\",\n textAlign: \"center\",\n\n \":empty\": {\n height: 8,\n width: 8,\n padding: 0,\n },\n },\n /** applied to the badge when it's visible */\n badge: {},\n /** applied to the badge when it's hidden */\n badgeHidden: {\n display: \"none\",\n },\n showCount: {},\n showLabel: {},\n badgeIcon: { position: \"relative\", top: \"1px\", left: \"-7px\" },\n badgeOneDigit: { padding: 0, width: \"16px\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM,EAAE,UAAU,YAAY,OAAO,EAAE,OAAO,SAAS;AAAA;AAAA,EAEvD,gBAAgB,EAAE,OAAO,EAAE;AAAA;AAAA,EAE3B,eAAe;AAAA,IACb,GAAG,MAAM,WAAW;AAAA,IACpB,OAAO,MAAM,OAAO;AAAA,IACpB,cAAc,MAAM,MAAM;AAAA,IAC1B,iBAAiB,MAAM,OAAO;AAAA,IAC9B,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IAEX,UAAU;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA;AAAA,EAEA,OAAO,CAAC;AAAA;AAAA,EAER,aAAa;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,WAAW,CAAC;AAAA,EACZ,WAAW,CAAC;AAAA,EACZ,WAAW,EAAE,UAAU,YAAY,KAAK,OAAO,MAAM,OAAO;AAAA,EAC5D,eAAe,EAAE,SAAS,GAAG,OAAO,OAAO;AAC7C,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionContainer.js","sources":["../../../../../src/Banner/BannerContent/ActionContainer/ActionContainer.tsx"],"sourcesContent":["import { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvActionsGeneric,\n HvActionsGenericProps,\n} from \"../../../ActionsGeneric\";\nimport { HvButton } from \"../../../Button\";\nimport { HvBaseProps } from \"../../../types/generic\";\nimport { staticClasses, useClasses } from \"./ActionContainer.styles\";\n\nexport { staticClasses as actionContainerClasses };\n\nexport type HvActionContainerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvActionContainerProps\n extends HvBaseProps<HTMLButtonElement>,\n Pick<Partial<HvActionsGenericProps>, \"onAction\"> {\n /** Function called when clicking on the close button. */\n onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Actions to display. */\n action?: HvActionsGenericProps[\"actions\"]; // TODO - rename to actions in v6\n /**\n * The callback function called when an action is triggered, receiving `action` as parameter.\n *\n * @deprecated Use `onAction` instead.\n * */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvActionContainerClasses;\n}\n\nexport const HvActionContainer = (props: HvActionContainerProps) => {\n const {\n id,\n classes: classesProp,\n onClose,\n action,\n actionCallback, // TODO - remove in v6\n onAction,\n ...others\n } = props;\n const { classes } = useClasses(classesProp);\n return (\n <div className={classes.actionContainer}>\n <HvButton\n icon\n className={classes.closeAction}\n variant=\"semantic\"\n aria-label=\"Close\"\n onClick={onClose}\n
|
|
1
|
+
{"version":3,"file":"ActionContainer.js","sources":["../../../../../src/Banner/BannerContent/ActionContainer/ActionContainer.tsx"],"sourcesContent":["import { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvActionsGeneric,\n HvActionsGenericProps,\n} from \"../../../ActionsGeneric\";\nimport { HvButton } from \"../../../Button\";\nimport { HvBaseProps } from \"../../../types/generic\";\nimport { staticClasses, useClasses } from \"./ActionContainer.styles\";\n\nexport { staticClasses as actionContainerClasses };\n\nexport type HvActionContainerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvActionContainerProps\n extends HvBaseProps<HTMLButtonElement>,\n Pick<Partial<HvActionsGenericProps>, \"onAction\"> {\n /** Function called when clicking on the close button. */\n onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** Actions to display. */\n action?: HvActionsGenericProps[\"actions\"]; // TODO - rename to actions in v6\n /**\n * The callback function called when an action is triggered, receiving `action` as parameter.\n *\n * @deprecated Use `onAction` instead.\n * */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvActionContainerClasses;\n}\n\nexport const HvActionContainer = (props: HvActionContainerProps) => {\n const {\n id,\n classes: classesProp,\n onClose,\n action,\n actionCallback, // TODO - remove in v6\n onAction,\n ...others\n } = props;\n const { classes } = useClasses(classesProp);\n return (\n <div className={classes.actionContainer}>\n <HvButton\n icon\n className={classes.closeAction}\n variant=\"semantic\"\n aria-label=\"Close\"\n onClick={onClose}\n {...others}\n >\n <Close iconSize=\"XS\" className={classes.iconContainer} color=\"base2\" />\n </HvButton>\n {action && (\n <div className={classes.actionsInnerContainer}>\n <HvActionsGeneric\n id={id}\n variant=\"semantic\"\n actions={action}\n actionsCallback={actionCallback}\n onAction={onAction}\n />\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAgCa,MAAA,oBAAoB,CAAC,UAAkC;AAC5D,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACD,IAAA;AACJ,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAC1C,SACG,qBAAA,OAAA,EAAI,WAAW,QAAQ,iBACtB,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAI;AAAA,QACJ,WAAW,QAAQ;AAAA,QACnB,SAAQ;AAAA,QACR,cAAW;AAAA,QACX,SAAS;AAAA,QACR,GAAG;AAAA,QAEJ,UAAA,oBAAC,SAAM,UAAS,MAAK,WAAW,QAAQ,eAAe,OAAM,QAAQ,CAAA;AAAA,MAAA;AAAA,IACvE;AAAA,IACC,UACC,oBAAC,OAAI,EAAA,WAAW,QAAQ,uBACtB,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,SAAQ;AAAA,QACR,SAAS;AAAA,QACT,iBAAiB;AAAA,QACjB;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
|
@@ -9,6 +9,7 @@ import { useTheme, useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
|
9
9
|
import { useControlled } from "../hooks/useControlled.js";
|
|
10
10
|
import { useForkRef } from "../hooks/useForkRef.js";
|
|
11
11
|
import { useUniqueId } from "../hooks/useUniqueId.js";
|
|
12
|
+
import { getDocument } from "../utils/document.js";
|
|
12
13
|
import { getFirstAndLastFocus } from "../utils/focusableElementFinder.js";
|
|
13
14
|
import { isKey, isOneOfKeys } from "../utils/keyboardUtils.js";
|
|
14
15
|
import { setId } from "../utils/setId.js";
|
|
@@ -140,6 +141,9 @@ const BaseDropdown = forwardRef((props, ref) => {
|
|
|
140
141
|
...headerControlArias
|
|
141
142
|
}) : defaultHeaderElement;
|
|
142
143
|
const containerComponent = (() => {
|
|
144
|
+
if (!getDocument()) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
143
147
|
const handleContainerKeyDown = (event) => {
|
|
144
148
|
if (isKey(event, "Esc")) {
|
|
145
149
|
handleToggle(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDropdown.js","sources":["../../../src/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PopperProps, usePopper } from \"react-popper\";\nimport ClickAwayListener, {\n ClickAwayListenerProps,\n} from \"@mui/material/ClickAwayListener\";\nimport {\n detectOverflow,\n ModifierArguments,\n Options,\n Placement,\n} from \"@popperjs/core\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useForkRef } from \"../hooks/useForkRef\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { getFirstAndLastFocus } from \"../utils/focusableElementFinder\";\nimport { isKey, isOneOfKeys } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\nimport { useBaseDropdownContext } from \"./BaseDropdownContext/BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onToggle\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps<any>>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<HTMLDivElement>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n /** @ignore */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst BaseDropdown = forwardRef<\n HTMLDivElement,\n Omit<\n HvBaseDropdownProps,\n \"popperProps\" | \"variableWidth\" | \"placement\" | \"onContainerCreation\"\n >\n>((props, ref) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded,\n disabled,\n readOnly,\n required,\n disablePortal,\n \"aria-expanded\": ariaExpandedProp,\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledByProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n ...others\n } = props;\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n popperPlacement,\n popper,\n popperElement,\n referenceElement,\n setPopperElement,\n setReferenceElement,\n } = useBaseDropdownContext();\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref,\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp,\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const id = useUniqueId(idProp);\n const containerId = setId(id, \"children-container\");\n\n const headerControlArias = {\n \"aria-required\": required ?? undefined,\n \"aria-readonly\": readOnly ?? undefined,\n \"aria-disabled\": disabled ?? undefined,\n\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": isOpen ? containerId : undefined,\n \"aria-controls\": isOpen ? containerId : undefined,\n } satisfies React.AriaAttributes;\n\n const headerAriaLabels = {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledByProp,\n } satisfies React.AriaAttributes;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const handleToggle = useCallback(\n (event: any) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n setIsOpen(() => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n });\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement],\n );\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n const defaultHeaderElement = (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement?.includes(\"top\"),\n [classes.headerOpenDown]: isOpen && popperPlacement?.includes(\"bottom\"),\n })}\n // TODO: review \"textbox\" role\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n {...headerAriaLabels}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div\n className={cx(classes.selection, {\n [classes.selectionDisabled]: disabled,\n })}\n >\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography noWrap className={classes.placeholder}>\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n\n const headerElement =\n component && isValidElement(component)\n ? cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n ...headerControlArias,\n })\n : defaultHeaderElement;\n\n const containerComponent = (() => {\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: React.KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n ref={setPopperElement}\n className={classes.container}\n style={popper?.styles.popper}\n {...popper?.attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement?.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <div\n // TODO: review in v6. `containerId` needs to be on the role element (`children` has it)\n id={containerId}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement?.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement?.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n {popperPlacement?.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n },\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body,\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n ref={ref}\n id={id}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className,\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n {...(ariaRole && {\n role: ariaRole,\n ...headerAriaLabels,\n ...headerControlArias,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerElement}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n});\n\nexport const HvBaseDropdown = forwardRef<HTMLDivElement, HvBaseDropdownProps>(\n (props, ref) => {\n const {\n popperProps = {},\n variableWidth,\n placement: placementProp = \"right\",\n onContainerCreation,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n\n const placement: Placement = `bottom-${\n placementProp === \"right\" ? \"start\" : \"end\"\n }`;\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const [referenceElement, setReferenceElement] =\n useState<HTMLElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(\n null,\n );\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const onFirstUpdate = useCallback(() => {\n onContainerCreation?.(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (\n width !== popperMaxSize?.width ||\n height !== popperMaxSize?.height\n ) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize],\n );\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n [],\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n [],\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n [],\n );\n\n const modifiers = useMemo<Options[\"modifiers\"]>(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ],\n );\n\n const popper = usePopper(referenceElement, popperElement, {\n placement,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n });\n\n const value = useMemo(\n () => ({\n ...popperMaxSize,\n popperPlacement:\n popper?.attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\",\n popper,\n popperElement,\n setPopperElement,\n referenceElement,\n setReferenceElement,\n }),\n [popper, popperElement, popperMaxSize, referenceElement],\n );\n\n return (\n <BaseDropdownContext.Provider value={value}>\n <BaseDropdown ref={ref} {...others} />\n </BaseDropdownContext.Provider>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAqIA,MAAM,eAAe,WAMnB,CAAC,OAAO,QAAQ;AACV,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,S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AU,mBAAmB,MAAM;AAAA,UACtD,IAAI;AAAA,QACN;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,OAAO;AAAA,UACP,UAAU,CAAC,SAAS;AAAA,UACpB,IAAI;AAAA,QACN;AAAA,QACA,GAAG;AAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IAAA;AAGI,UAAA,SAAS,UAAU,kBAAkB,eAAe;AAAA,MACxD;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAED,UAAM,QAAQ;AAAA,MACZ,OAAO;AAAA,QACL,GAAG;AAAA,QACH,iBACE,QAAQ,WAAW,SAAS,uBAAuB,KAAK;AAAA,QAC1D;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,CAAC,QAAQ,eAAe,eAAe,gBAAgB;AAAA,IAAA;AAIvD,WAAA,oBAAC,oBAAoB,UAApB,EAA6B,OAC5B,8BAAC,cAAa,EAAA,KAAW,GAAG,OAAQ,CAAA,EACtC,CAAA;AAAA,EAEJ;AACF;"}
|
|
1
|
+
{"version":3,"file":"BaseDropdown.js","sources":["../../../src/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PopperProps, usePopper } from \"react-popper\";\nimport ClickAwayListener, {\n ClickAwayListenerProps,\n} from \"@mui/material/ClickAwayListener\";\nimport {\n detectOverflow,\n ModifierArguments,\n Options,\n Placement,\n} from \"@popperjs/core\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useForkRef } from \"../hooks/useForkRef\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { getDocument } from \"../utils/document\";\nimport { getFirstAndLastFocus } from \"../utils/focusableElementFinder\";\nimport { isKey, isOneOfKeys } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\nimport { useBaseDropdownContext } from \"./BaseDropdownContext/BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onToggle\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps<any>>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<HTMLDivElement>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n /** @ignore */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst BaseDropdown = forwardRef<\n HTMLDivElement,\n Omit<\n HvBaseDropdownProps,\n \"popperProps\" | \"variableWidth\" | \"placement\" | \"onContainerCreation\"\n >\n>((props, ref) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded,\n disabled,\n readOnly,\n required,\n disablePortal,\n \"aria-expanded\": ariaExpandedProp,\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledByProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n ...others\n } = props;\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n popperPlacement,\n popper,\n popperElement,\n referenceElement,\n setPopperElement,\n setReferenceElement,\n } = useBaseDropdownContext();\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref,\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp,\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const id = useUniqueId(idProp);\n const containerId = setId(id, \"children-container\");\n\n const headerControlArias = {\n \"aria-required\": required ?? undefined,\n \"aria-readonly\": readOnly ?? undefined,\n \"aria-disabled\": disabled ?? undefined,\n\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": isOpen ? containerId : undefined,\n \"aria-controls\": isOpen ? containerId : undefined,\n } satisfies React.AriaAttributes;\n\n const headerAriaLabels = {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledByProp,\n } satisfies React.AriaAttributes;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const handleToggle = useCallback(\n (event: any) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n setIsOpen(() => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n });\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement],\n );\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n const defaultHeaderElement = (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement?.includes(\"top\"),\n [classes.headerOpenDown]: isOpen && popperPlacement?.includes(\"bottom\"),\n })}\n // TODO: review \"textbox\" role\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n {...headerAriaLabels}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div\n className={cx(classes.selection, {\n [classes.selectionDisabled]: disabled,\n })}\n >\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography noWrap className={classes.placeholder}>\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n\n const headerElement =\n component && isValidElement(component)\n ? cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n ...headerControlArias,\n })\n : defaultHeaderElement;\n\n const containerComponent = (() => {\n if (!getDocument()) {\n return null;\n }\n\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: React.KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n ref={setPopperElement}\n className={classes.container}\n style={popper?.styles.popper}\n {...popper?.attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement?.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <div\n // TODO: review in v6. `containerId` needs to be on the role element (`children` has it)\n id={containerId}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement?.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement?.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n {popperPlacement?.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n },\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body,\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n ref={ref}\n id={id}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className,\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n {...(ariaRole && {\n role: ariaRole,\n ...headerAriaLabels,\n ...headerControlArias,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerElement}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n});\n\nexport const HvBaseDropdown = forwardRef<HTMLDivElement, HvBaseDropdownProps>(\n (props, ref) => {\n const {\n popperProps = {},\n variableWidth,\n placement: placementProp = \"right\",\n onContainerCreation,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n\n const placement: Placement = `bottom-${\n placementProp === \"right\" ? \"start\" : \"end\"\n }`;\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const [referenceElement, setReferenceElement] =\n useState<HTMLElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(\n null,\n );\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const onFirstUpdate = useCallback(() => {\n onContainerCreation?.(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (\n width !== popperMaxSize?.width ||\n height !== popperMaxSize?.height\n ) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize],\n );\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n [],\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n [],\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n [],\n );\n\n const modifiers = useMemo<Options[\"modifiers\"]>(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ],\n );\n\n const popper = usePopper(referenceElement, popperElement, {\n placement,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n });\n\n const value = useMemo(\n () => ({\n ...popperMaxSize,\n popperPlacement:\n popper?.attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\",\n popper,\n popperElement,\n setPopperElement,\n referenceElement,\n setReferenceElement,\n }),\n [popper, popperElement, popperMaxSize, referenceElement],\n );\n\n return (\n <BaseDropdownContext.Provider value={value}>\n <BaseDropdown ref={ref} {...others} />\n </BaseDropdownContext.Provider>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAsIA,MAAM,eAAe,WAMnB,CAAC,OAAO,QAAQ;AACV,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACD,IAAA;AAEJ,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,uBAAuB;AAErB,QAAA,EAAE,WAAW;AAEb,QAAA,CAAC,QAAQ,SAAS,IAAI,cAAc,UAAU,QAAQ,eAAe,CAAC;AAE5E,QAAM,8BAA8B;AAAA,IAClC;AAAA,IACA,qBAAqB;AAAA,EAAA;AAEv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,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,CAAC,QAAQ,eAAe,eAAe,gBAAgB;AAAA,IAAA;AAIvD,WAAA,oBAAC,oBAAoB,UAApB,EAA6B,OAC5B,8BAAC,cAAa,EAAA,KAAW,GAAG,OAAQ,CAAA,EACtC,CAAA;AAAA,EAEJ;AACF;"}
|
|
@@ -5,8 +5,7 @@ const BaseDropdownContext = createContext({
|
|
|
5
5
|
});
|
|
6
6
|
BaseDropdownContext.displayName = "BaseDropdownContext";
|
|
7
7
|
const useBaseDropdownContext = () => useContext(BaseDropdownContext);
|
|
8
|
-
const BaseDropdownContext$1 = BaseDropdownContext;
|
|
9
8
|
export {
|
|
10
|
-
BaseDropdownContext
|
|
9
|
+
BaseDropdownContext as default,
|
|
11
10
|
useBaseDropdownContext
|
|
12
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDropdownContext.js","sources":["../../../../src/BaseDropdown/BaseDropdownContext/BaseDropdownContext.tsx"],"sourcesContent":["import { createContext, Dispatch, SetStateAction, useContext } from \"react\";\nimport { usePopper } from \"react-popper\";\n\ninterface BaseDropdownValue {\n width?: number;\n height?: number;\n popperPlacement?: string;\n popper?: ReturnType<typeof usePopper>;\n referenceElement: HTMLElement | null;\n setReferenceElement?: Dispatch<SetStateAction<HTMLElement | null>>;\n popperElement: HTMLElement | null;\n setPopperElement?: Dispatch<SetStateAction<HTMLElement | null>>;\n}\n\nconst BaseDropdownContext = createContext<BaseDropdownValue>({\n referenceElement: null,\n popperElement: null,\n});\n\nBaseDropdownContext.displayName = \"BaseDropdownContext\";\n\nexport const useBaseDropdownContext = () => useContext(BaseDropdownContext);\n\nexport default BaseDropdownContext;\n"],"names":[],"mappings":";AAcA,MAAM,sBAAsB,cAAiC;AAAA,EAC3D,kBAAkB;AAAA,EAClB,eAAe;AACjB,CAAC;AAED,oBAAoB,cAAc;AAErB,MAAA,yBAAyB,MAAM,WAAW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"BaseDropdownContext.js","sources":["../../../../src/BaseDropdown/BaseDropdownContext/BaseDropdownContext.tsx"],"sourcesContent":["import { createContext, Dispatch, SetStateAction, useContext } from \"react\";\nimport { usePopper } from \"react-popper\";\n\ninterface BaseDropdownValue {\n width?: number;\n height?: number;\n popperPlacement?: string;\n popper?: ReturnType<typeof usePopper>;\n referenceElement: HTMLElement | null;\n setReferenceElement?: Dispatch<SetStateAction<HTMLElement | null>>;\n popperElement: HTMLElement | null;\n setPopperElement?: Dispatch<SetStateAction<HTMLElement | null>>;\n}\n\nconst BaseDropdownContext = createContext<BaseDropdownValue>({\n referenceElement: null,\n popperElement: null,\n});\n\nBaseDropdownContext.displayName = \"BaseDropdownContext\";\n\nexport const useBaseDropdownContext = () => useContext(BaseDropdownContext);\n\nexport default BaseDropdownContext;\n"],"names":[],"mappings":";AAcA,MAAM,sBAAsB,cAAiC;AAAA,EAC3D,kBAAkB;AAAA,EAClB,eAAe;AACjB,CAAC;AAED,oBAAoB,cAAc;AAErB,MAAA,yBAAyB,MAAM,WAAW,mBAAmB;"}
|