@hitachivantara/uikit-react-core 5.47.1 → 5.48.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/BaseDropdown/BaseDropdown.cjs.map +1 -1
- package/dist/cjs/Button/Button.cjs +53 -55
- package/dist/cjs/Button/Button.cjs.map +1 -1
- package/dist/cjs/DropDownMenu/DropDownMenu.cjs +2 -10
- package/dist/cjs/DropDownMenu/DropDownMenu.cjs.map +1 -1
- package/dist/cjs/Dropdown/Dropdown.cjs.map +1 -1
- package/dist/cjs/Dropdown/Dropdown.styles.cjs +1 -4
- package/dist/cjs/Dropdown/Dropdown.styles.cjs.map +1 -1
- package/dist/cjs/ListContainer/ListContainer.cjs +20 -10
- package/dist/cjs/ListContainer/ListContainer.cjs.map +1 -1
- package/dist/cjs/ListContainer/ListContext/ListContext.cjs.map +1 -1
- package/dist/cjs/ListContainer/ListItem/ListItem.cjs +5 -2
- package/dist/cjs/ListContainer/ListItem/ListItem.cjs.map +1 -1
- package/dist/cjs/TimeAgo/TimeAgo.cjs +25 -30
- package/dist/cjs/TimeAgo/TimeAgo.cjs.map +1 -1
- package/dist/cjs/TreeView/TreeView.cjs +2 -2
- package/dist/cjs/TreeView/TreeView.cjs.map +1 -1
- package/dist/cjs/Typography/Typography.cjs +35 -37
- package/dist/cjs/Typography/Typography.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/types/generic.cjs +8 -0
- package/dist/cjs/types/generic.cjs.map +1 -0
- package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/esm/Button/Button.js +53 -55
- package/dist/esm/Button/Button.js.map +1 -1
- package/dist/esm/DropDownMenu/DropDownMenu.js +2 -10
- package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/Dropdown/Dropdown.styles.js +1 -4
- package/dist/esm/Dropdown/Dropdown.styles.js.map +1 -1
- package/dist/esm/ListContainer/ListContainer.js +21 -11
- package/dist/esm/ListContainer/ListContainer.js.map +1 -1
- package/dist/esm/ListContainer/ListContext/ListContext.js.map +1 -1
- package/dist/esm/ListContainer/ListItem/ListItem.js +5 -2
- package/dist/esm/ListContainer/ListItem/ListItem.js.map +1 -1
- package/dist/esm/TimeAgo/TimeAgo.js +25 -28
- package/dist/esm/TimeAgo/TimeAgo.js.map +1 -1
- package/dist/esm/TreeView/TreeView.js +2 -2
- package/dist/esm/TreeView/TreeView.js.map +1 -1
- package/dist/esm/Typography/Typography.js +35 -37
- package/dist/esm/Typography/Typography.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/generic.js +8 -0
- package/dist/esm/types/generic.js.map +1 -0
- package/dist/types/index.d.ts +170 -70
- package/package.json +2 -2
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
import { jsx, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import isEmpty from "lodash/isEmpty";
|
|
4
2
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
3
|
+
import { fixedForwardRef } from "../types/generic.js";
|
|
5
4
|
import { useClasses } from "./TimeAgo.styles.js";
|
|
6
5
|
import { staticClasses } from "./TimeAgo.styles.js";
|
|
7
6
|
import useTimeAgo from "./useTimeAgo.js";
|
|
8
7
|
import { HvTypography } from "../Typography/Typography.js";
|
|
9
|
-
const HvTimeAgo =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
);
|
|
8
|
+
const HvTimeAgo = fixedForwardRef(function HvTimeAgo2(props, ref) {
|
|
9
|
+
const {
|
|
10
|
+
classes: classesProp,
|
|
11
|
+
className,
|
|
12
|
+
timestamp,
|
|
13
|
+
locale: localeProp = "en",
|
|
14
|
+
component: Component = HvTypography,
|
|
15
|
+
emptyElement = "—",
|
|
16
|
+
disableRefresh = false,
|
|
17
|
+
showSeconds = false,
|
|
18
|
+
justText = false,
|
|
19
|
+
...others
|
|
20
|
+
} = useDefaultProps("HvTimeAgo", props);
|
|
21
|
+
const { classes, cx } = useClasses(classesProp);
|
|
22
|
+
const locale = localeProp || "en";
|
|
23
|
+
const timeAgo = useTimeAgo(timestamp, {
|
|
24
|
+
locale,
|
|
25
|
+
disableRefresh,
|
|
26
|
+
showSeconds
|
|
27
|
+
});
|
|
28
|
+
if (justText && timestamp)
|
|
29
|
+
return /* @__PURE__ */ jsx(Fragment, { children: timeAgo });
|
|
30
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: cx(classes.root, className), ...others, children: !timestamp ? emptyElement : timeAgo });
|
|
31
|
+
});
|
|
35
32
|
export {
|
|
36
33
|
HvTimeAgo,
|
|
37
34
|
staticClasses as timeAgoClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeAgo.js","sources":["../../../src/TimeAgo/TimeAgo.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"TimeAgo.js","sources":["../../../src/TimeAgo/TimeAgo.tsx"],"sourcesContent":["import { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvTypography } from \"../Typography\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\n\nimport { staticClasses, useClasses } from \"./TimeAgo.styles\";\nimport useTimeAgo from \"./useTimeAgo\";\n\nexport { staticClasses as timeAgoClasses };\n\nexport type HvTimeAgoClasses = ExtractNames<typeof useClasses>;\n\nexport type HvTimeAgoProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /**\n * The timestamp to format, in seconds or milliseconds.\n * Defaults to `emptyElement` if value is null or 0\n */\n timestamp?: number;\n /**\n * The locale to be used. Should be on of the dayjs supported locales and explicitly imported\n * @see https://day.js.org/docs/en/i18n/i18n\n */\n locale?: string;\n /**\n * The element to render when the timestamp is null or 0\n * Defaults to `—` (Em Dash)\n */\n emptyElement?: React.ReactNode;\n /** Disables periodic date refreshes */\n disableRefresh?: boolean;\n /** Whether to show seconds in the rendered time */\n showSeconds?: boolean;\n /**\n * Whether the component should render just the string\n * Consider using `useTimeAgo` instead\n */\n justText?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTimeAgoClasses;\n }\n >;\n\n/**\n * The HvTimeAgo component implements the Design System relative time format guidelines.\n */\nexport const HvTimeAgo = fixedForwardRef(function HvTimeAgo<\n C extends React.ElementType = \"p\"\n>(props: HvTimeAgoProps<C>, ref: PolymorphicRef<C>) {\n const {\n classes: classesProp,\n className,\n timestamp,\n locale: localeProp = \"en\",\n component: Component = HvTypography,\n emptyElement = \"—\",\n disableRefresh = false,\n showSeconds = false,\n justText = false,\n ...others\n } = useDefaultProps(\"HvTimeAgo\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const locale = localeProp || \"en\";\n const timeAgo = useTimeAgo(timestamp, {\n locale,\n disableRefresh,\n showSeconds,\n });\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (justText && timestamp) return <>{timeAgo}</>;\n\n return (\n <Component ref={ref} className={cx(classes.root, className)} {...others}>\n {!timestamp ? emptyElement : timeAgo}\n </Component>\n );\n});\n"],"names":["HvTimeAgo"],"mappings":";;;;;;;AAoDO,MAAM,YAAY,gBAAgB,SAASA,WAEhD,OAA0B,KAAwB;AAC5C,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,QAAQ,aAAa;AAAA,IACrB,WAAW,YAAY;AAAA,IACvB,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,aAAa,KAAK;AAEtC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAC9C,QAAM,SAAS,cAAc;AACvB,QAAA,UAAU,WAAW,WAAW;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGD,MAAI,YAAY;AAAW,2CAAU,UAAQ,QAAA,CAAA;AAE7C,SACG,oBAAA,WAAA,EAAU,KAAU,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QAC9D,UAAC,CAAA,YAAY,eAAe,QAC/B,CAAA;AAEJ,CAAC;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
2
|
import { useSlotProps } from "@mui/base/utils";
|
|
4
3
|
import { DropDownXS, DropRightXS } from "@hitachivantara/uikit-react-icons";
|
|
4
|
+
import { fixedForwardRef } from "../types/generic.js";
|
|
5
5
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
6
6
|
import { useTreeView } from "./internals/hooks/useTreeView.js";
|
|
7
7
|
import { TreeViewProvider } from "./internals/TreeViewProvider.js";
|
|
8
8
|
import { useClasses } from "./TreeView.styles.js";
|
|
9
9
|
import { staticClasses } from "./TreeView.styles.js";
|
|
10
10
|
import { DEFAULT_TREE_VIEW_PLUGINS } from "./internals/hooks/plugins/defaultPlugins.js";
|
|
11
|
-
const HvTreeView =
|
|
11
|
+
const HvTreeView = fixedForwardRef(function HvTreeView2(props, ref) {
|
|
12
12
|
const {
|
|
13
13
|
id,
|
|
14
14
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sources":["../../../src/TreeView/TreeView.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"TreeView.js","sources":["../../../src/TreeView/TreeView.tsx"],"sourcesContent":["import { useSlotProps } from \"@mui/base/utils\";\nimport { DropDownXS, DropRightXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps, fixedForwardRef } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport {\n DEFAULT_TREE_VIEW_PLUGINS,\n DefaultTreeViewPluginParameters,\n} from \"./internals/hooks/plugins\";\nimport { useTreeView } from \"./internals/hooks/useTreeView\";\nimport { TreeViewProvider } from \"./internals/TreeViewProvider\";\nimport { staticClasses, useClasses } from \"./TreeView.styles\";\n\nexport { staticClasses as treeView2Classes }; // TODO: remove old `treeViewClasses`\n\nexport type HvTreeViewClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTreeViewProps<Multiple extends boolean | undefined>\n extends HvBaseProps<HTMLUListElement>,\n DefaultTreeViewPluginParameters<Multiple> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvTreeViewClasses;\n /** Tree View children. Usually a `HvTreeItem` instance, or a custom variation of it */\n children?: React.ReactNode;\n}\n\n/**\n * A Tree View displays hierarchical structures.\n * It also facilitates the exploration of categorical levels and their content.\n *\n * Tree structures are built through composing the `HvTreeItem` component,\n * or a custom variation of it.\n *\n * It is based on MUI's [TreeView](https://mui.com/x/react-tree-view) component.\n *\n * @example\n * ```tsx\n * <HvTreeView>\n * <HvTreeItem nodeId=\"1\" label=\"File1\" />\n * </HvTreeView>\n * ```\n */\nexport const HvTreeView = fixedForwardRef(function HvTreeView<\n Multiple extends boolean | undefined\n>(props: HvTreeViewProps<Multiple>, ref: React.Ref<HTMLUListElement>) {\n const {\n id,\n children,\n classes: classesProp,\n className,\n\n disabledItemsFocusable,\n multiSelect,\n expanded,\n defaultExpanded,\n selected,\n defaultSelected,\n disableSelection,\n defaultCollapseIcon = <DropDownXS role=\"none\" />,\n defaultExpandIcon = <DropRightXS role=\"none\" />,\n defaultEndIcon,\n defaultParentIcon,\n onNodeSelect,\n onNodeToggle,\n onNodeFocus,\n ...others\n } = useDefaultProps(\"HvTreeView\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { getRootProps, contextValue } = useTreeView({\n disabledItemsFocusable,\n expanded,\n defaultExpanded,\n onNodeToggle,\n onNodeFocus,\n disableSelection,\n defaultSelected,\n selected,\n multiSelect,\n onNodeSelect: onNodeSelect as HvTreeViewProps<any>[\"onNodeSelect\"],\n id,\n defaultCollapseIcon,\n defaultEndIcon,\n defaultExpandIcon,\n defaultParentIcon,\n plugins: DEFAULT_TREE_VIEW_PLUGINS,\n rootRef: ref,\n });\n\n const rootProps = useSlotProps({\n elementType: \"ul\",\n externalSlotProps: {},\n externalForwardedProps: others,\n className: classes.root,\n getSlotProps: getRootProps,\n ownerState: props,\n });\n\n return (\n <TreeViewProvider value={contextValue}>\n <ul className={cx(classes.root, className)} {...rootProps} {...others}>\n {children}\n </ul>\n </TreeViewProvider>\n );\n});\n"],"names":["HvTreeView"],"mappings":";;;;;;;;;;AA4CO,MAAM,aAAa,gBAAgB,SAASA,YAEjD,OAAkC,KAAkC;AAC9D,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAsB,oBAAC,YAAW,EAAA,MAAK,OAAO,CAAA;AAAA,IAC9C,oBAAoB,oBAAC,aAAY,EAAA,MAAK,OAAO,CAAA;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,cAAc,KAAK;AACvC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,EAAE,cAAc,aAAa,IAAI,YAAY;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAED,QAAM,YAAY,aAAa;AAAA,IAC7B,aAAa;AAAA,IACb,mBAAmB,CAAC;AAAA,IACpB,wBAAwB;AAAA,IACxB,WAAW,QAAQ;AAAA,IACnB,cAAc;AAAA,IACd,YAAY;AAAA,EAAA,CACb;AAED,6BACG,kBAAiB,EAAA,OAAO,cACvB,UAAA,oBAAC,QAAG,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,WAAY,GAAG,QAC5D,UACH,EACF,CAAA;AAEJ,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { fixedForwardRef } from "../types/generic.js";
|
|
3
3
|
import { useTheme } from "../hooks/useTheme.js";
|
|
4
4
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
5
5
|
import { mapVariant } from "./utils.js";
|
|
@@ -37,43 +37,41 @@ const HvTypographyMap = {
|
|
|
37
37
|
vizTextDisabled: "p",
|
|
38
38
|
xsInlineLink: "p"
|
|
39
39
|
};
|
|
40
|
-
const HvTypography =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const HvTypography = fixedForwardRef(function HvTypography2(props, ref) {
|
|
41
|
+
const {
|
|
42
|
+
className,
|
|
43
|
+
component: ComponentProp,
|
|
44
|
+
classes: classesProp,
|
|
45
|
+
variant: variantProp = "body",
|
|
46
|
+
link = false,
|
|
47
|
+
noWrap = false,
|
|
48
|
+
paragraph = false,
|
|
49
|
+
disabled = false,
|
|
50
|
+
...others
|
|
51
|
+
} = useDefaultProps("HvTypography", props);
|
|
52
|
+
const { classes, cx } = useClasses(classesProp);
|
|
53
|
+
const { activeTheme } = useTheme();
|
|
54
|
+
const variant = mapVariant(variantProp, activeTheme?.name);
|
|
55
|
+
const Component = ComponentProp || paragraph && "p" || HvTypographyMap[variant] || "span";
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
57
|
+
Component,
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
className: cx(
|
|
61
|
+
classes.root,
|
|
62
|
+
classes[variant],
|
|
63
|
+
{
|
|
64
|
+
[classes.isLink]: link,
|
|
65
|
+
[classes.noWrap]: noWrap,
|
|
66
|
+
[classes.disabled]: disabled
|
|
67
|
+
},
|
|
68
|
+
className
|
|
69
|
+
),
|
|
70
|
+
disabled,
|
|
51
71
|
...others
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const variant = mapVariant(variantProp, activeTheme?.name);
|
|
56
|
-
const Component = ComponentProp || paragraph && "p" || HvTypographyMap[variant] || "span";
|
|
57
|
-
return /* @__PURE__ */ jsx(
|
|
58
|
-
Component,
|
|
59
|
-
{
|
|
60
|
-
ref,
|
|
61
|
-
className: cx(
|
|
62
|
-
classes.root,
|
|
63
|
-
classes[variant],
|
|
64
|
-
{
|
|
65
|
-
[classes.isLink]: link,
|
|
66
|
-
[classes.noWrap]: noWrap,
|
|
67
|
-
[classes.disabled]: disabled
|
|
68
|
-
},
|
|
69
|
-
className
|
|
70
|
-
),
|
|
71
|
-
disabled,
|
|
72
|
-
...others
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
});
|
|
77
75
|
export {
|
|
78
76
|
HvTypography,
|
|
79
77
|
staticClasses as typographyClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n React.ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /**\n * If `true`, the typography will render a \"p\" element\n * @deprecated use `component=\"p\"` instead\n * */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography = fixedForwardRef(function HvTypography<\n C extends React.ElementType = \"p\"\n>(props: HvTypographyProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n});\n"],"names":["HvTypography"],"mappings":";;;;;;;AAmBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAmCO,MAAM,eAAe,gBAAgB,SAASA,cAEnD,OAA6B,KAAwB;AAC/C,QAAA;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,SAAS;AAAA,IACT,SAAS,cAAc;AAAA,IACvB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,gBAAgB,KAAK;AACzC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,QAAA,EAAE,gBAAgB;AAExB,QAAM,UAAU,WAAW,aAAa,aAAa,IAAI;AAEzD,QAAM,YACJ,iBAAkB,aAAa,OAAQ,gBAAgB,OAAO,KAAK;AAGnE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,OAAO;AAAA,QACf;AAAA,UACE,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { useUniqueId } from "./hooks/useUniqueId.js";
|
|
|
14
14
|
import { useWidth } from "./hooks/useWidth.js";
|
|
15
15
|
import { HvProvider } from "./providers/Provider.js";
|
|
16
16
|
import { HvThemeProvider } from "./providers/ThemeProvider.js";
|
|
17
|
+
import { fixedForwardRef } from "./types/generic.js";
|
|
17
18
|
import { withTooltip } from "./hocs/withTooltip.js";
|
|
18
19
|
import { isBrowser } from "./utils/browser.js";
|
|
19
20
|
import { checkValidHexColorValue } from "./utils/checkValidHexColorValue.js";
|
|
@@ -515,6 +516,7 @@ export {
|
|
|
515
516
|
staticClasses57 as filterGroupClasses,
|
|
516
517
|
filterProps,
|
|
517
518
|
findDescriptors,
|
|
519
|
+
fixedForwardRef,
|
|
518
520
|
staticClasses2 as focusClasses,
|
|
519
521
|
staticClasses58 as footerClasses,
|
|
520
522
|
staticClasses7 as formElementClasses,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.js","sources":["../../../src/types/generic.ts"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport type {\n HvExtraProps,\n HvExtraDeepProps,\n} from \"@hitachivantara/uikit-react-shared\";\n\nexport type { HvExtraProps, HvExtraDeepProps };\n\ntype AsProp<C extends React.ElementType> = {\n /** Custom element type to override the root component */\n component?: C;\n};\n\ntype PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);\n\n// Workaround to fix the use of Omit with ComponentPropsWithoutRef\n// Without this the event handlers return any instead of the type for the chosen element\ntype FixComponentProps<T> = T extends any ? T : never;\n\ntype PolymorphicComponent<\n C extends React.ElementType,\n Props = {}\n> = React.PropsWithChildren<Props & AsProp<C>> &\n FixComponentProps<\n Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>\n >;\n\nexport type PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>[\"ref\"];\n\nexport type PolymorphicComponentRef<\n C extends React.ElementType,\n Props = {}\n> = PolymorphicComponent<C, Props> & { ref?: PolymorphicRef<C> };\n\n/** HV Base Props. Extends `React.HTMLAttributes` of an element `E`, and filters `K` keys. */\nexport type HvBaseProps<\n E extends HTMLElement = HTMLDivElement,\n K extends keyof React.HTMLAttributes<E> = never\n> = Omit<React.HTMLAttributes<E>, K>;\n\n/** This type allows to do a deep partial by applying the Partial type to each key recursively */\nexport type DeepPartial<T> = T extends Object\n ? Partial<{\n [P in keyof T]: DeepPartial<T[P]>;\n }>\n : T;\n\n/** This type combines the HvExtraProps and DeepPartial types */\nexport type HvExtraDeepPartialProps<T> = Partial<{\n [P in keyof T]: DeepPartial<T[P]> & HvExtraProps;\n}> &\n HvExtraProps;\n\nexport type Arrayable<T> = T | T[];\n\n/** React.forwardRef with fixed type declarations */\nexport function fixedForwardRef<T, P = {}>(\n // TODO: change `React.ReactElement | null` to `React.ReactNode` in typescript@5\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null\n): (props: P & React.RefAttributes<T>) => React.ReactElement | null {\n return forwardRef(render) as any;\n}\n"],"names":[],"mappings":";AA0DO,SAAS,gBAEd,QACkE;AAClE,SAAO,WAAW,MAAM;AAC1B;"}
|