diff --git a/packages/lib/src/accordion/Accordion.tsx b/packages/lib/src/accordion/Accordion.tsx
index 1e7466c2e7..9cc4e2e631 100644
--- a/packages/lib/src/accordion/Accordion.tsx
+++ b/packages/lib/src/accordion/Accordion.tsx
@@ -2,15 +2,15 @@ import { JSX, Children, useCallback, useMemo, useState } from "react";
import styled from "@emotion/styled";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
-import AccordionPropsType, { AccordionContextProps } from "./types";
+import { AccordionProps, AccordionContextProps } from "./types";
import AccordionContext from "./AccordionContext";
import AccordionItem from "./AccordionItem";
-const calculateWidth = (margin: AccordionPropsType["margin"]) =>
+const calculateWidth = (margin: AccordionProps["margin"]) =>
`calc(100% - ${getMargin(margin, "left")} - ${getMargin(margin, "right")})`;
const AccordionContainer = styled.div<{
- margin: AccordionPropsType["margin"];
+ margin: AccordionProps["margin"];
}>`
width: ${(props) => calculateWidth(props.margin)};
margin: ${({ margin }) => (margin && typeof margin !== "object" ? spaces[margin] : "var(--spacing-padding-none)")};
@@ -74,7 +74,7 @@ const AccordionItemWithProvider = ({
return {child};
};
-const DxcAccordion = (props: AccordionPropsType): JSX.Element => {
+const DxcAccordion = (props: AccordionProps): JSX.Element => {
const { children, defaultIndexActive, independent, indexActive, margin, onActiveChange } = props;
const [innerIndexActive, setInnerIndexActive] = useState(
diff --git a/packages/lib/src/accordion/types.ts b/packages/lib/src/accordion/types.ts
index 8f44b489ad..0277ac928f 100644
--- a/packages/lib/src/accordion/types.ts
+++ b/packages/lib/src/accordion/types.ts
@@ -1,5 +1,5 @@
import { ReactNode, ReactElement } from "react";
-import { Margin, SVG, Space } from "../common/utils";
+import { Margin, PrettifyTypes, SVG, Space } from "../common/types";
export type AccordionItemProps = {
/**
@@ -103,7 +103,7 @@ type NonIndependentProps = CommonProps & {
onActiveChange?: (index: number[]) => void;
};
-type Props = IndependentProps | NonIndependentProps;
+export type AccordionProps = PrettifyTypes;
export type AccordionContextProps = {
index: number;
@@ -112,4 +112,4 @@ export type AccordionContextProps = {
independent?: boolean;
};
-export default Props;
+export type { AccordionProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/action-icon/ActionIcon.stories.tsx b/packages/lib/src/action-icon/ActionIcon.stories.tsx
index 86a96bfc76..b44b03b0f0 100644
--- a/packages/lib/src/action-icon/ActionIcon.stories.tsx
+++ b/packages/lib/src/action-icon/ActionIcon.stories.tsx
@@ -5,7 +5,7 @@ import DxcActionIcon from "./ActionIcon";
import DxcFlex from "../flex/Flex";
import Title from "../../.storybook/components/Title";
import ExampleContainer, { PseudoState } from "../../.storybook/components/ExampleContainer";
-import { ActionIconPropTypes, Status } from "./types";
+import { ActionIconProps, Status } from "./types";
export default {
title: "ActionIcon",
@@ -17,10 +17,10 @@ type Story = StoryObj;
type GroupingKey = "size" | "shape" | "color" | "statusPosition" | "statusMode" | "pseudoState";
type ActionIconRowProps = {
- sizes?: ActionIconPropTypes["size"][];
- shapes?: ActionIconPropTypes["shape"][];
- colors?: ActionIconPropTypes["color"][];
- icon?: ActionIconPropTypes["icon"];
+ sizes?: ActionIconProps["size"][];
+ shapes?: ActionIconProps["shape"][];
+ colors?: ActionIconProps["color"][];
+ icon?: ActionIconProps["icon"];
statusModes?: Status["mode"][];
statusPositions?: (Status["position"] | undefined)[];
pseudoStates?: (PseudoState | "disabled" | undefined)[];
@@ -30,7 +30,7 @@ type ActionIconRowProps = {
const ActionIconRow = ({
sizes = ["medium"],
shapes = ["circle"],
- colors = ["neutral"],
+ colors = [undefined],
statusModes,
statusPositions = [],
pseudoStates = [],
@@ -58,9 +58,9 @@ const ActionIconRow = ({
const renderGroup = (
level: number,
filters: {
- size?: ActionIconPropTypes["size"];
- shape?: ActionIconPropTypes["shape"];
- color?: ActionIconPropTypes["color"];
+ size?: ActionIconProps["size"];
+ shape?: ActionIconProps["shape"];
+ color?: ActionIconProps["color"];
statusMode?: Status["mode"];
statusPosition?: Status["position"];
pseudoState?: PseudoState | "disabled";
@@ -117,9 +117,9 @@ const ActionIconRow = ({
return values.map((value) => {
const newFilters = { ...filters };
- if (key === "size") newFilters.size = value as ActionIconPropTypes["size"];
- else if (key === "shape") newFilters.shape = value as ActionIconPropTypes["shape"];
- else if (key === "color") newFilters.color = value as ActionIconPropTypes["color"];
+ if (key === "size") newFilters.size = value as ActionIconProps["size"];
+ else if (key === "shape") newFilters.shape = value as ActionIconProps["shape"];
+ else if (key === "color") newFilters.color = value as ActionIconProps["color"];
else if (key === "statusPosition") newFilters.statusPosition = value as Status["position"];
else if (key === "statusMode") newFilters.statusMode = value as Status["mode"];
else if (key === "pseudoState") newFilters.pseudoState = value as PseudoState | "disabled";
@@ -144,6 +144,7 @@ export const Shapes: Story = {
sizes={["xsmall", "small", "medium", "large", "xlarge", "xxlarge"]}
shapes={["circle", "square"]}
groupBy={["shape", "size"]}
+ colors={["neutral"]}
/>
>
),
@@ -156,9 +157,10 @@ export const Colors: Story = {
+
>
),
};
@@ -167,10 +169,10 @@ export const PseudoStates: Story = {
render: () => (
<>
- console.log("hello")} />
+ console.log("hello")} />
(
- <>
-
-
-
-
- >
- ),
-};
+// export const Types: Story = {
+// render: () => (
+// <>
+//
+//
+//
+//
+// >
+// ),
+// };
const Tooltip = () => (
<>
diff --git a/packages/lib/src/action-icon/ActionIcon.tsx b/packages/lib/src/action-icon/ActionIcon.tsx
index 1442ed9c62..b2341f272c 100644
--- a/packages/lib/src/action-icon/ActionIcon.tsx
+++ b/packages/lib/src/action-icon/ActionIcon.tsx
@@ -1,6 +1,6 @@
import styled from "@emotion/styled";
import { css } from "@emotion/react";
-import { ActionIconPropTypes } from "./types";
+import { ActionIconProps } from "./types";
import { getBackgroundColor, getBorderRadius, getColor, getIconSize, getOutlineWidth, getSize } from "./utils";
import DxcIcon from "../icon/Icon";
import { Tooltip } from "../tooltip/Tooltip";
@@ -8,10 +8,10 @@ import { Tooltip } from "../tooltip/Tooltip";
const ActionIconContainer = styled.div<
{
hasAction?: boolean;
- shape: ActionIconPropTypes["shape"];
- size: ActionIconPropTypes["size"];
- disabled?: ActionIconPropTypes["disabled"];
- color: ActionIconPropTypes["color"];
+ shape: ActionIconProps["shape"];
+ size: ActionIconProps["size"];
+ disabled?: ActionIconProps["disabled"];
+ color?: ActionIconProps["color"];
} & React.AnchorHTMLAttributes
>`
/* Reset button default styles when rendered as button */
@@ -62,7 +62,7 @@ const ActionIconContainer = styled.div<
const IconContainerWrapper = styled.div<{
hasAction?: boolean;
- disabled: ActionIconPropTypes["disabled"];
+ disabled: ActionIconProps["disabled"];
}>`
height: 100%;
width: 100%;
@@ -82,7 +82,7 @@ const IconContainerWrapper = styled.div<{
`}
`;
-export const IconContainer = styled.div<{ size: ActionIconPropTypes["size"] }>`
+export const IconContainer = styled.div<{ size: ActionIconProps["size"] }>`
display: flex;
justify-content: center;
align-items: center;
@@ -100,7 +100,7 @@ export const IconContainer = styled.div<{ size: ActionIconPropTypes["size"] }>`
const ForwardedActionIcon = ({
ariaLabel,
content,
- color = "transparent",
+ color = undefined,
disabled = false,
icon,
linkHref,
@@ -110,7 +110,7 @@ const ForwardedActionIcon = ({
size = "medium",
tabIndex = 0,
title,
-}: ActionIconPropTypes) => {
+}: ActionIconProps) => {
return (
+export const getColor = (color: ActionIconProps["color"]) =>
color && contextualColorMap[color] ? contextualColorMap[color].text : contextualColorMap.transparent.text;
-export const getBackgroundColor = (color: ActionIconPropTypes["color"]) =>
+export const getBackgroundColor = (color: ActionIconProps["color"]) =>
color && contextualColorMap[color] ? contextualColorMap[color].background : contextualColorMap.transparent.background;
-export const getBorderRadius = (shape: ActionIconPropTypes["shape"], size: ActionIconPropTypes["size"]) => {
+export const getBorderRadius = (shape: ActionIconProps["shape"], size: ActionIconProps["size"]) => {
if (shape === "circle") {
return "100%";
}
@@ -91,10 +91,10 @@ export const getBorderRadius = (shape: ActionIconPropTypes["shape"], size: Actio
return "100%";
};
-export const getSize = (size: ActionIconPropTypes["size"]) => (size && sizeMap[size] ? sizeMap[size] : "40px");
+export const getSize = (size: ActionIconProps["size"]) => (size && sizeMap[size] ? sizeMap[size] : "40px");
-export const getIconSize = (size: ActionIconPropTypes["size"]) =>
+export const getIconSize = (size: ActionIconProps["size"]) =>
size && iconSizeMap[size] ? iconSizeMap[size] : "var(--height-s)";
-export const getOutlineWidth = (size: ActionIconPropTypes["size"]) =>
+export const getOutlineWidth = (size: ActionIconProps["size"]) =>
size && outlineWidthMap[size] ? outlineWidthMap[size] : "var(--border-width-m)";
diff --git a/packages/lib/src/alert/Actions.tsx b/packages/lib/src/alert/Actions.tsx
index 65ef62cfb8..80eb04af0b 100644
--- a/packages/lib/src/alert/Actions.tsx
+++ b/packages/lib/src/alert/Actions.tsx
@@ -1,7 +1,7 @@
import { memo } from "react";
import DxcButton from "../button/Button";
import DxcFlex from "../flex/Flex";
-import AlertPropsType from "./types";
+import { AlertProps } from "./types";
const Actions = memo(
({
@@ -9,7 +9,7 @@ const Actions = memo(
primaryAction,
secondaryAction,
semantic,
- }: Pick) =>
+ }: Pick) =>
(primaryAction != null || secondaryAction != null) && (
{secondaryAction?.onClick && (
diff --git a/packages/lib/src/alert/Alert.tsx b/packages/lib/src/alert/Alert.tsx
index 4c5f0d997e..2ce9104a91 100644
--- a/packages/lib/src/alert/Alert.tsx
+++ b/packages/lib/src/alert/Alert.tsx
@@ -1,7 +1,7 @@
import styled from "@emotion/styled";
import { css } from "@emotion/react";
import { useState, useId, useEffect, useCallback, use, useMemo } from "react";
-import AlertPropsType from "./types";
+import { AlertProps } from "./types";
import DxcIcon from "../icon/Icon";
import DxcDivider from "../divider/Divider";
import DxcActionIcon from "../action-icon/ActionIcon";
@@ -11,8 +11,8 @@ import ModalAlertWrapper from "./ModalAlertWrapper";
import { HalstackLanguageContext } from "../HalstackContext";
const AlertContainer = styled.div<{
- semantic: AlertPropsType["semantic"];
- mode: AlertPropsType["mode"];
+ semantic: AlertProps["semantic"];
+ mode: AlertProps["mode"];
}>`
box-sizing: border-box;
display: flex;
@@ -35,7 +35,7 @@ const AlertContainer = styled.div<{
overflow: hidden;
`;
-const TitleContainer = styled.div<{ mode: AlertPropsType["mode"]; semantic: AlertPropsType["semantic"] }>`
+const TitleContainer = styled.div<{ mode: AlertProps["mode"]; semantic: AlertProps["semantic"] }>`
flex-grow: 1;
display: flex;
align-items: center;
@@ -55,13 +55,13 @@ const typographyStyles = css`
font-weight: var(--typography-helper-text-regular);
`;
-const Title = styled.span<{ mode: AlertPropsType["mode"] }>`
+const Title = styled.span<{ mode: AlertProps["mode"] }>`
${typographyStyles}
font-size: ${(props) => (props.mode === "modal" ? "var(--typography-title-xl)" : "var(--typography-title-s)")};
font-weight: var(--typography-title-bold);
`;
-const Message = styled.div<{ mode: AlertPropsType["mode"] }>`
+const Message = styled.div<{ mode: AlertProps["mode"] }>`
${typographyStyles}
white-space: ${(props) => props.mode === "banner" && "nowrap"};
text-overflow: ${(props) => props.mode === "banner" && "ellipsis"};
@@ -79,7 +79,7 @@ const NavigationText = styled.span`
font-size: var(--typography-helper-text-s);
`;
-const getIcon = (semantic: AlertPropsType["semantic"]) => {
+const getIcon = (semantic: AlertProps["semantic"]) => {
switch (semantic) {
case "info":
return ;
@@ -100,7 +100,7 @@ const DxcAlert = ({
secondaryAction,
semantic = "info",
title = "",
-}: AlertPropsType) => {
+}: AlertProps) => {
const messages = useMemo(() => (Array.isArray(message) ? message : [message]), [message]);
const [currentIndex, setCurrentIndex] = useState(0);
diff --git a/packages/lib/src/alert/types.ts b/packages/lib/src/alert/types.ts
index b348298997..581898af17 100644
--- a/packages/lib/src/alert/types.ts
+++ b/packages/lib/src/alert/types.ts
@@ -1,7 +1,7 @@
import { ReactNode } from "react";
-import { SVG } from "../common/utils";
+import { PrettifyTypes, SVG } from "../common/types";
-type Action = {
+export type AlertAction = {
/**
* The icon of the action. It can be a string with the name of the icon or an SVG component.
*/
@@ -16,7 +16,7 @@ type Action = {
onClick: () => void;
};
-type Message = {
+export type AlertMessage = {
/**
* The function that will be executed when the user clicks on the close action button.
*/
@@ -39,11 +39,11 @@ type CommonProps = {
/**
* Primary action of the alert.
*/
- primaryAction?: Action;
+ primaryAction?: AlertAction;
/**
* Secondary action of the alert.
*/
- secondaryAction?: Action;
+ secondaryAction?: AlertAction;
/**
* Specifies the semantic meaning of the alert.
*/
@@ -56,37 +56,37 @@ type CommonProps = {
type ModeSpecificProps =
| {
- /**
- * List of messages to be displayed. Each message has a close action that will,
- * apart from remove from the alert the current message, call the onClose if it is defined.
- * If the message is an array, the alert will show a navigation bar to move between the messages.
- * The modal mode only allows one message per alert. In this case, the message must be an object
- * and the presence of the onClose attribute is mandatory, since the management of the closing
- * of the alert relies completely on the user.
- */
- message?: Message | Message[];
- /**
- * The mode of the alert.
- */
- mode?: "inline" | "banner";
- }
+ /**
+ * List of messages to be displayed. Each message has a close action that will,
+ * apart from remove from the alert the current message, call the onClose if it is defined.
+ * If the message is an array, the alert will show a navigation bar to move between the messages.
+ * The modal mode only allows one message per alert. In this case, the message must be an object
+ * and the presence of the onClose attribute is mandatory, since the management of the closing
+ * of the alert relies completely on the user.
+ */
+ message?: AlertMessage | AlertMessage[];
+ /**
+ * The mode of the alert.
+ */
+ mode?: "inline" | "banner";
+ }
| {
- /**
- * List of messages to be displayed. Each message has a close action that will,
- * apart from remove from the alert the current message, call the onClose if it is defined.
- * If the message is an array, the alert will show a navigation bar to move between the messages.
- * The modal mode only allows one message per alert. In this case, the message must be an object
- * and the presence of the onClose attribute is mandatory, since the management of the closing
- * of the alert relies completely on the user.
- */
- message: Required;
- /**
- * The mode of the alert.
- */
- mode: "modal";
- };
+ /**
+ * List of messages to be displayed. Each message has a close action that will,
+ * apart from remove from the alert the current message, call the onClose if it is defined.
+ * If the message is an array, the alert will show a navigation bar to move between the messages.
+ * The modal mode only allows one message per alert. In this case, the message must be an object
+ * and the presence of the onClose attribute is mandatory, since the management of the closing
+ * of the alert relies completely on the user.
+ */
+ message: Required;
+ /**
+ * The mode of the alert.
+ */
+ mode: "modal";
+ };
-type Props = CommonProps & ModeSpecificProps;
+export type AlertProps = PrettifyTypes;
export type ModalAlertWrapperProps = {
condition: boolean;
@@ -94,4 +94,4 @@ export type ModalAlertWrapperProps = {
children: ReactNode;
};
-export default Props;
+export type { AlertProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/avatar/types.ts b/packages/lib/src/avatar/types.ts
index 1f415bb4bf..1c7d9692d2 100644
--- a/packages/lib/src/avatar/types.ts
+++ b/packages/lib/src/avatar/types.ts
@@ -1,15 +1,12 @@
import { Ref } from "react";
-import { SVG } from "../common/utils";
+import { SVG, Color, Size, Shape } from "../common/types";
-type Size = "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
-type Shape = "circle" | "square";
-type Color = "primary" | "secondary" | "tertiary" | "success" | "info" | "neutral" | "warning" | "error";
-export interface Status {
+export type AvatarStatus = {
mode: "default" | "info" | "success" | "warning" | "error";
position: "top" | "bottom";
-}
+};
-type Props = {
+export type AvatarProps = {
/**
* Affects the visual style of the avatar. It can be used following semantic purposes or not.
*/
@@ -63,7 +60,7 @@ type Props = {
* Defines the color of the status indicator displayed on the avatar and where it will be placed.
* If not provided, no indicator will be rendered.
*/
- status?: Status;
+ status?: AvatarStatus;
/**
* Value of the tabindex attribute. It will only apply when the onClick property is passed.
*/
@@ -95,7 +92,7 @@ export type ContentType = {
initials: string;
icon?: string | SVG;
color: Color;
- status?: Status;
+ status?: AvatarStatus;
};
-export default Props;
+export type { AvatarProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/badge/Badge.tsx b/packages/lib/src/badge/Badge.tsx
index 1b99d52519..03f5dbecfd 100644
--- a/packages/lib/src/badge/Badge.tsx
+++ b/packages/lib/src/badge/Badge.tsx
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
-import BadgePropsType from "./types";
+import { BadgeProps } from "./types";
import DxcIcon from "../icon/Icon";
import { Tooltip } from "../tooltip/Tooltip";
@@ -82,13 +82,13 @@ const sizeMap = {
},
};
-const getColor = (mode: BadgePropsType["mode"], color: BadgePropsType["color"]) =>
+const getColor = (mode: BadgeProps["mode"], color: BadgeProps["color"]) =>
mode === "contextual" && color ? contextualColorMap[color].text : notificationColor.text;
-const getBackgroundColor = (mode: BadgePropsType["mode"], color: BadgePropsType["color"]) =>
+const getBackgroundColor = (mode: BadgeProps["mode"], color: BadgeProps["color"]) =>
mode === "contextual" && color ? contextualColorMap[color].background : notificationColor.background;
-const getPadding = (mode: BadgePropsType["mode"], size: BadgePropsType["size"], label: BadgePropsType["label"]) =>
+const getPadding = (mode: BadgeProps["mode"], size: BadgeProps["size"], label: BadgeProps["label"]) =>
size &&
(mode === "contextual"
? sizeMap[size].padding.contextual
@@ -97,10 +97,10 @@ const getPadding = (mode: BadgePropsType["mode"], size: BadgePropsType["size"],
: sizeMap[size].padding.notification);
const BadgeContainer = styled.div<{
- label: BadgePropsType["label"];
- mode: BadgePropsType["mode"];
- color: BadgePropsType["color"];
- size: BadgePropsType["size"];
+ label: BadgeProps["label"];
+ mode: BadgeProps["mode"];
+ color: BadgeProps["color"];
+ size: BadgeProps["size"];
}>`
box-sizing: border-box;
border-radius: ${(props) => props.size && sizeMap[props.size].borderRadius};
@@ -117,7 +117,7 @@ const BadgeContainer = styled.div<{
color: ${(props) => getColor(props.mode, props.color)};
`;
-const IconContainer = styled.div<{ size: BadgePropsType["size"] }>`
+const IconContainer = styled.div<{ size: BadgeProps["size"] }>`
display: flex;
font-size: ${(props) => props.size && sizeMap[props.size].iconSize};
@@ -127,7 +127,7 @@ const IconContainer = styled.div<{ size: BadgePropsType["size"] }>`
}
`;
-const Label = styled.span<{ size: BadgePropsType["size"] }>`
+const Label = styled.span<{ size: BadgeProps["size"] }>`
font-family: var(--typography-font-family);
font-size: ${(props) => props.size && sizeMap[props.size].fontSize};
font-style: normal;
@@ -145,7 +145,7 @@ const DxcBadge = ({
notificationLimit = 99,
ref,
size = "medium",
-}: BadgePropsType) => (
+}: BadgeProps) => (
;
+ /**
+ * Size of the component.
+ */
+ size?: "small" | "medium" | "large";
+};
+
+export type ContextualBadgeProps = CommonProps & {
/**
* Text to be placed in the badge.
*/
@@ -16,10 +35,10 @@ export type ContextualProps = {
/**
* Affects the visual style of the badge. It can be used following semantic purposes or not.
*/
- color?: "primary" | "secondary" | "tertiary" | "success" | "info" | "neutral" | "warning" | "error";
+ color?: Color;
};
-export type NotificationProps = {
+export type NotificationBadgeProps = CommonProps & {
/**
* Text to be placed in the badge.
*/
@@ -38,25 +57,6 @@ export type NotificationProps = {
color?: never;
};
-export type CommonProps = {
- /**
- * Text representing advisory information related to the badge. Under the hood, this prop also serves as an accessible label for the component.
- */
- title?: string;
- /**
- * Material Symbol name or SVG element used as the icon that will be placed next to the badge label in contextual mode.
- */
- icon?: string | SVG;
- /**
- * Ref to be forwarded to the badge container element.
- */
- ref?: React.Ref;
- /**
- * Size of the component.
- */
- size?: "small" | "medium" | "large";
-};
-
-type Props = (ContextualProps | NotificationProps) & CommonProps;
+export type BadgeProps = PrettifyTypes | PrettifyTypes;
-export default Props;
+export type { BadgeProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/base-menu/GroupItem.tsx b/packages/lib/src/base-menu/GroupItem.tsx
index 8b6cdf8642..cabbeb58e7 100644
--- a/packages/lib/src/base-menu/GroupItem.tsx
+++ b/packages/lib/src/base-menu/GroupItem.tsx
@@ -3,12 +3,12 @@ import DxcIcon from "../icon/Icon";
import SubMenu from "./SubMenu";
import ItemAction from "./ItemAction";
import MenuItem from "./MenuItem";
-import { GroupItemProps } from "./types";
+import { BaseGroupItemProps } from "./types";
import { useGroupItem } from "./useGroupItem";
import BaseMenuContext from "./BaseMenuContext";
import DxcPopover from "../popover/Popover";
-const GroupItem = ({ items, ...props }: GroupItemProps) => {
+const GroupItem = ({ items, ...props }: BaseGroupItemProps) => {
const groupMenuId = `group-menu-${useId()}`;
const contextValue = use(BaseMenuContext) ?? {};
const { groupSelected, isOpen, toggleOpen, hasPopOver, isHorizontal } = useGroupItem(
diff --git a/packages/lib/src/base-menu/ItemAction.tsx b/packages/lib/src/base-menu/ItemAction.tsx
index df7d2a0480..a6f39bcfa0 100644
--- a/packages/lib/src/base-menu/ItemAction.tsx
+++ b/packages/lib/src/base-menu/ItemAction.tsx
@@ -1,13 +1,13 @@
import { memo } from "react";
import styled from "@emotion/styled";
-import { ItemActionProps } from "./types";
+import { BaseItemActionProps } from "./types";
import DxcIcon from "../icon/Icon";
import { TooltipWrapper } from "../tooltip/Tooltip";
import { useItemAction } from "./useItemAction";
const Action = styled.a<{
- depthLevel: ItemActionProps["depthLevel"];
- selected: ItemActionProps["selected"];
+ depthLevel: BaseItemActionProps["depthLevel"];
+ selected: BaseItemActionProps["selected"];
displayGroupLines: boolean;
hasPopOver?: boolean;
isHorizontal?: boolean;
@@ -60,7 +60,7 @@ const Icon = styled.span`
}
`;
-const Text = styled.span<{ selected: ItemActionProps["selected"] }>`
+const Text = styled.span<{ selected: BaseItemActionProps["selected"] }>`
color: var(--color-fg-neutral-dark);
font-family: var(--typography-font-family);
font-size: var(--typography-label-m);
@@ -79,7 +79,7 @@ const Control = styled.span`
gap: var(--spacing-gap-s);
`;
-const ItemAction = memo(({ ...props }: ItemActionProps) => {
+const ItemAction = memo(({ ...props }: BaseItemActionProps) => {
const {
hasTooltip,
modifiedBadge,
diff --git a/packages/lib/src/base-menu/MenuItem.tsx b/packages/lib/src/base-menu/MenuItem.tsx
index b70663a489..6fad9c6975 100644
--- a/packages/lib/src/base-menu/MenuItem.tsx
+++ b/packages/lib/src/base-menu/MenuItem.tsx
@@ -1,7 +1,7 @@
import styled from "@emotion/styled";
import GroupItem from "./GroupItem";
import SingleItem from "./SingleItem";
-import { MenuItemProps } from "./types";
+import { BaseMenuItemProps } from "./types";
import { isGroupItem } from "./utils";
const MenuItemContainer = styled.li`
@@ -9,7 +9,7 @@ const MenuItemContainer = styled.li`
gap: var(--spacing-gap-xs);
`;
-export default function MenuItem({ item, depthLevel = 0 }: MenuItemProps) {
+export default function MenuItem({ item, depthLevel = 0 }: BaseMenuItemProps) {
return (
{isGroupItem(item) ? (
diff --git a/packages/lib/src/base-menu/Section.tsx b/packages/lib/src/base-menu/Section.tsx
index 7cb5a1f14f..5a730afe41 100644
--- a/packages/lib/src/base-menu/Section.tsx
+++ b/packages/lib/src/base-menu/Section.tsx
@@ -2,7 +2,7 @@ import { use, useId } from "react";
import styled from "@emotion/styled";
import SubMenu from "./SubMenu";
import MenuItem from "./MenuItem";
-import { SectionProps } from "./types";
+import { BaseSectionProps } from "./types";
import BaseMenuContext from "./BaseMenuContext";
import DxcInset from "../inset/Inset";
import DxcDivider from "../divider/Divider";
@@ -21,7 +21,7 @@ const Title = styled.h2`
padding: var(--spacing-padding-xxs);
`;
-export default function Section({ index, length, section }: SectionProps) {
+export default function Section({ index, length, section }: BaseSectionProps) {
const id = `section-${useId()}`;
const { hasPopOver } = use(BaseMenuContext) ?? {};
return (
diff --git a/packages/lib/src/base-menu/SingleItem.tsx b/packages/lib/src/base-menu/SingleItem.tsx
index c0482e574f..8699712bf4 100644
--- a/packages/lib/src/base-menu/SingleItem.tsx
+++ b/packages/lib/src/base-menu/SingleItem.tsx
@@ -1,9 +1,9 @@
import { use, useEffect } from "react";
import ItemAction from "./ItemAction";
-import { SingleItemProps } from "./types";
+import { BaseSingleItemProps } from "./types";
import BaseMenuContext from "./BaseMenuContext";
-export default function SingleItem({ id, onSelect, selected = false, ...props }: SingleItemProps) {
+export default function SingleItem({ id, onSelect, selected = false, ...props }: BaseSingleItemProps) {
const { selectedItemId, setSelectedItemId, hasPopOver, closePopOver, onSelectItem } = use(BaseMenuContext) ?? {};
const handleClick = () => {
diff --git a/packages/lib/src/base-menu/SubMenu.tsx b/packages/lib/src/base-menu/SubMenu.tsx
index 3874bd8859..902a7148c2 100644
--- a/packages/lib/src/base-menu/SubMenu.tsx
+++ b/packages/lib/src/base-menu/SubMenu.tsx
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
-import { SubMenuProps } from "./types";
+import { BaseSubMenuProps } from "./types";
import BaseMenuContext from "./BaseMenuContext";
import { use } from "react";
@@ -35,7 +35,7 @@ export default function SubMenu({
depthLevel = 0,
isHorizontal = false,
isPopOver = false,
-}: SubMenuProps) {
+}: BaseSubMenuProps) {
const { displayGroupLines } = use(BaseMenuContext) ?? {};
return (
void;
selected?: boolean;
href?: string;
renderItem?: (props: { children: ReactNode }) => ReactNode;
};
-type GroupItem = CommonItemProps & {
- items: (Item | GroupItem)[];
+type BaseGroupItem = BaseCommonItemProps & {
+ items: (BaseItem | BaseGroupItem)[];
defaultOpen?: boolean;
};
-type Section = { items: (Item | GroupItem)[]; title?: string };
-type Props = {
+type BaseSection = { items: (BaseItem | BaseGroupItem)[]; title?: string };
+type BaseMenuProps = {
/**
* Array of items to be displayed in the menu.
* Each item can be a single/simple item, a group item or a section.
*/
- items: (Item | GroupItem)[] | Section[];
+ items: (BaseItem | BaseGroupItem)[] | BaseSection[];
/**
* If true the menu will be displayed with a border.
*/
@@ -52,41 +52,41 @@ type Props = {
onSelectItem?: () => void;
};
-type ItemWithId = Item & { id: number };
+type BaseItemWithId = BaseItem & { id: number };
-type GroupItemWithId = Omit & {
- items: (ItemWithId | GroupItemWithId)[];
+type BaseGroupItemWithId = Omit & {
+ items: (BaseItemWithId | BaseGroupItemWithId)[];
};
-type SectionWithId = { items: (ItemWithId | GroupItemWithId)[]; title?: string };
+type BaseSectionWithId = { items: (BaseItemWithId | BaseGroupItemWithId)[]; title?: string };
-type SingleItemProps = ItemWithId & {
+type BaseSingleItemProps = BaseItemWithId & {
depthLevel: number;
};
-type GroupItemProps = GroupItemWithId & {
+type BaseGroupItemProps = BaseGroupItemWithId & {
depthLevel: number;
};
-type MenuItemProps = {
- item: ItemWithId | GroupItemWithId;
+type BaseMenuItemProps = {
+ item: BaseItemWithId | BaseGroupItemWithId;
depthLevel?: number;
};
-type ItemActionProps = ButtonHTMLAttributes & {
- badge?: Item["badge"];
+type BaseItemActionProps = ButtonHTMLAttributes & {
+ badge?: BaseItem["badge"];
collapseIcon?: ReactNode;
depthLevel: number;
- icon?: Item["icon"];
- label: Item["label"];
+ icon?: BaseItem["icon"];
+ label: BaseItem["label"];
ref?: React.Ref | undefined;
- selected: Item["selected"];
- href?: Item["href"];
- renderItem?: Item["renderItem"];
+ selected: BaseItem["selected"];
+ href?: BaseItem["href"];
+ renderItem?: BaseItem["renderItem"];
};
-type SectionProps = {
- section: SectionWithId;
+type BaseSectionProps = {
+ section: BaseSectionWithId;
index: number;
length: number;
};
-type SubMenuProps = {
+type BaseSubMenuProps = {
children: ReactNode;
id?: string;
depthLevel?: number;
@@ -105,20 +105,20 @@ type BaseMenuContextProps = {
};
export type {
- CommonItemProps,
+ BaseCommonItemProps,
BaseMenuContextProps,
- GroupItem,
- GroupItemProps,
- GroupItemWithId,
- Item,
- ItemActionProps,
- ItemWithId,
- SubMenuProps,
- MenuItemProps,
- Section,
- SectionWithId,
- SectionProps,
- SingleItemProps,
+ BaseGroupItem,
+ BaseGroupItemProps,
+ BaseGroupItemWithId,
+ BaseItem,
+ BaseItemActionProps,
+ BaseItemWithId,
+ BaseSubMenuProps,
+ BaseMenuItemProps,
+ BaseSection,
+ BaseSectionWithId,
+ BaseSectionProps,
+ BaseSingleItemProps,
+ BaseMenuProps,
+ BaseMenuProps as default,
};
-
-export default Props;
diff --git a/packages/lib/src/base-menu/useGroupItem.ts b/packages/lib/src/base-menu/useGroupItem.ts
index 96f11608bd..e349e4cd0e 100644
--- a/packages/lib/src/base-menu/useGroupItem.ts
+++ b/packages/lib/src/base-menu/useGroupItem.ts
@@ -1,14 +1,18 @@
import { useId, useMemo, useState } from "react";
-import { BaseMenuContextProps, GroupItemProps } from "./types";
+import { BaseMenuContextProps, BaseGroupItemProps } from "./types";
-const isGroupSelected = (items: GroupItemProps["items"], selectedItemId?: number): boolean =>
+const isGroupSelected = (items: BaseGroupItemProps["items"], selectedItemId?: number): boolean =>
items.some((item) => {
if ("items" in item) return isGroupSelected(item.items, selectedItemId);
else if (selectedItemId !== -1) return item.id === selectedItemId;
else return !!item.selected;
});
-export const useGroupItem = (items: GroupItemProps["items"], context: BaseMenuContextProps, defaultOpen?: boolean) => {
+export const useGroupItem = (
+ items: BaseGroupItemProps["items"],
+ context: BaseMenuContextProps,
+ defaultOpen?: boolean
+) => {
const groupMenuId = `group-menu-${useId()}`;
const { selectedItemId, hasPopOver } = context ?? {};
const groupSelected = useMemo(() => isGroupSelected(items, selectedItemId), [items, selectedItemId]);
diff --git a/packages/lib/src/base-menu/useItemAction.ts b/packages/lib/src/base-menu/useItemAction.ts
index 46ac53d040..a394986ca5 100644
--- a/packages/lib/src/base-menu/useItemAction.ts
+++ b/packages/lib/src/base-menu/useItemAction.ts
@@ -1,8 +1,8 @@
import { useState, use, cloneElement, ReactNode, ReactElement } from "react";
import BaseMenuContext from "./BaseMenuContext";
-import { ItemActionProps } from "./types";
+import { BaseItemActionProps } from "./types";
-export function useItemAction({ badge, renderItem }: ItemActionProps) {
+export function useItemAction({ badge, renderItem }: BaseItemActionProps) {
const [hasTooltip, setHasTooltip] = useState(false);
const modifiedBadge = badge && cloneElement(badge as ReactElement<{ size?: string }>, { size: "small" });
const { displayControlsAfter, hasPopOver, displayGroupLines, isHorizontal } = use(BaseMenuContext) ?? {};
diff --git a/packages/lib/src/base-menu/utils.ts b/packages/lib/src/base-menu/utils.ts
index 77db32b032..37182c3684 100644
--- a/packages/lib/src/base-menu/utils.ts
+++ b/packages/lib/src/base-menu/utils.ts
@@ -1,36 +1,36 @@
import ContextualMenuPropsType, {
- GroupItem,
- GroupItemProps,
- GroupItemWithId,
- Item,
- ItemWithId,
- Section as SectionType,
- SectionWithId,
+ BaseGroupItem,
+ BaseGroupItemProps,
+ BaseGroupItemWithId,
+ BaseItem,
+ BaseItemWithId,
+ BaseSection,
+ BaseSectionWithId,
} from "./types";
-export const isGroupItem = (item: Item | GroupItem): item is GroupItem => "items" in item;
+export const isGroupItem = (item: BaseItem | BaseGroupItem): item is BaseGroupItem => "items" in item;
-export const isSection = (item: SectionType | Item | GroupItem): item is SectionType =>
+export const isSection = (item: BaseSection | BaseItem | BaseGroupItem): item is BaseSection =>
"items" in item && !("label" in item);
export const addIdToItems = (
items: ContextualMenuPropsType["items"]
-): (ItemWithId | GroupItemWithId | SectionWithId)[] => {
+): (BaseItemWithId | BaseGroupItemWithId | BaseSectionWithId)[] => {
let accId = 0;
const innerAddIdToItems = (
items: ContextualMenuPropsType["items"]
- ): (ItemWithId | GroupItemWithId | SectionWithId)[] =>
- items.map((item: Item | GroupItem | SectionType) =>
+ ): (BaseItemWithId | BaseGroupItemWithId | BaseSectionWithId)[] =>
+ items.map((item: BaseItem | BaseGroupItem | BaseSection) =>
isSection(item)
- ? ({ ...item, items: innerAddIdToItems(item.items) } as SectionWithId)
+ ? ({ ...item, items: innerAddIdToItems(item.items) } as BaseSectionWithId)
: isGroupItem(item)
- ? ({ ...item, items: innerAddIdToItems(item.items) } as GroupItemWithId)
+ ? ({ ...item, items: innerAddIdToItems(item.items) } as BaseGroupItemWithId)
: { ...item, id: accId++ }
);
return innerAddIdToItems(items);
};
-export const isGroupSelected = (items: GroupItemProps["items"], selectedItemId?: number): boolean =>
+export const isGroupSelected = (items: BaseGroupItemProps["items"], selectedItemId?: number): boolean =>
items.some((item) => {
if ("items" in item) return isGroupSelected(item.items, selectedItemId);
else if (selectedItemId !== -1) return item.id === selectedItemId;
diff --git a/packages/lib/src/bleed/Bleed.tsx b/packages/lib/src/bleed/Bleed.tsx
index c4a9af9f6d..2f40334875 100644
--- a/packages/lib/src/bleed/Bleed.tsx
+++ b/packages/lib/src/bleed/Bleed.tsx
@@ -1,9 +1,9 @@
-import BleedPropsType from "./types";
+import { BleedProps } from "./types";
import DxcContainer from "../container/Container";
const getNegativeValue = (value?: string) => (value ? `calc(${value} * -1)` : null);
-const DxcBleed = ({ space, horizontal, vertical, top, right, bottom, left, children }: BleedPropsType) => (
+const DxcBleed = ({ space, horizontal, vertical, top, right, bottom, left, children }: BleedProps) => (
`
+const ListItem = styled.li<{ isCurrentPage?: BreadcrumbsItemProps["isCurrentPage"] }>`
display: flex;
align-items: center;
color: var(--color-fg-neutral-dark);
@@ -44,7 +44,7 @@ const Text = styled.span`
}
`;
-const Item = ({ isCurrentPage = false, href, label, onClick }: ItemPropsType) => {
+const Item = ({ isCurrentPage = false, href, label, onClick }: BreadcrumbsItemProps) => {
const currentItemRef = useRef(null);
const handleOnClick = (event: MouseEvent) => {
diff --git a/packages/lib/src/breadcrumbs/types.ts b/packages/lib/src/breadcrumbs/types.ts
index 2912e649d9..195857b5e2 100644
--- a/packages/lib/src/breadcrumbs/types.ts
+++ b/packages/lib/src/breadcrumbs/types.ts
@@ -1,8 +1,10 @@
-type Item = {
+import { PrettifyTypes } from "../common/types";
+
+export type BreadcrumbsItem = {
href?: string;
label: string;
};
-type Props = {
+export type BreadcrumbsProps = {
/**
* Provides a label that describes the type of navigation enabled by
* the component.
@@ -11,7 +13,7 @@ type Props = {
/**
* Array of objects representing the items of the breadcrumbs.
*/
- items: Item[];
+ items: BreadcrumbsItem[];
/**
* Number of items before showing a collapsed version of the
* breadcrumbs. It can't be lower than two (root/collapsed action and
@@ -34,9 +36,11 @@ type Props = {
showRoot?: boolean;
};
-export type ItemPropsType = Item & {
- isCurrentPage?: boolean;
- onClick?: (href: string) => void;
-};
+export type BreadcrumbsItemProps = PrettifyTypes<
+ BreadcrumbsItem & {
+ isCurrentPage?: boolean;
+ onClick?: (href: string) => void;
+ }
+>;
-export default Props;
+export type { BreadcrumbsProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/bulleted-list/BulletedList.tsx b/packages/lib/src/bulleted-list/BulletedList.tsx
index 5bae88571d..9ebfc89abe 100644
--- a/packages/lib/src/bulleted-list/BulletedList.tsx
+++ b/packages/lib/src/bulleted-list/BulletedList.tsx
@@ -2,7 +2,7 @@ import { JSX, Children } from "react";
import styled from "@emotion/styled";
import DxcFlex from "../flex/Flex";
import DxcTypography from "../typography/Typography";
-import BulletedListPropsType, { BulletedListItemPropsType } from "./types";
+import { BulletedListProps, BulletedListItemProps } from "./types";
import DxcIcon from "../icon/Icon";
const ListContainer = styled.div`
@@ -79,9 +79,9 @@ const ListItem = styled.li`
padding: var(--spacing-padding-none);
`;
-const BulletedListItem = ({ children }: BulletedListItemPropsType): JSX.Element => <>{children}>;
+const BulletedListItem = ({ children }: BulletedListItemProps): JSX.Element => <>{children}>;
-const DxcBulletedList = ({ children, type = "disc", icon = "" }: BulletedListPropsType): JSX.Element => (
+const DxcBulletedList = ({ children, type = "disc", icon = "" }: BulletedListProps): JSX.Element => (
{Children.map(children, (child, index) => (
diff --git a/packages/lib/src/bulleted-list/types.ts b/packages/lib/src/bulleted-list/types.ts
index 24ae1f1125..2a4c8aee13 100644
--- a/packages/lib/src/bulleted-list/types.ts
+++ b/packages/lib/src/bulleted-list/types.ts
@@ -1,7 +1,7 @@
import { ReactNode } from "react";
-import { SVG } from "../common/utils";
+import { PrettifyTypes, SVG } from "../common/types";
-type IconProps = {
+type BulletedListIconProps = {
/**
* Defines the style of the bullet point in the list.
*/
@@ -16,7 +16,7 @@ type IconProps = {
children: ReactNode;
};
-type OtherProps = {
+type BulletedListWithoutIconProps = {
/**
* Defines the style of the bullet point in the list.
*/
@@ -31,13 +31,13 @@ type OtherProps = {
children: ReactNode;
};
-type Props = IconProps | OtherProps;
+export type BulletedListProps = PrettifyTypes;
-export type BulletedListItemPropsType = {
+export type BulletedListItemProps = {
/**
* Text to be shown in the list.
*/
children?: ReactNode;
};
-export default Props;
+export type { BulletedListProps as default };
\ No newline at end of file
diff --git a/packages/lib/src/button/Button.tsx b/packages/lib/src/button/Button.tsx
index e7b9d09d8c..5784d59e22 100644
--- a/packages/lib/src/button/Button.tsx
+++ b/packages/lib/src/button/Button.tsx
@@ -1,17 +1,17 @@
import styled from "@emotion/styled";
import { spaces } from "../common/variables";
-import ButtonPropsType, { Mode, Semantic, Size } from "./types";
+import { ButtonMode, ButtonSemantic, ButtonSize, ButtonProps } from "./types";
import DxcIcon from "../icon/Icon";
import { Tooltip } from "../tooltip/Tooltip";
import { calculateWidth, getButtonStyles, getHeight } from "./utils";
const Button = styled.button<{
iconOnly: boolean;
- iconPosition: ButtonPropsType["iconPosition"];
- margin: ButtonPropsType["margin"];
- semantic: Semantic;
- size: Size;
- $mode: Mode;
+ iconPosition: ButtonProps["iconPosition"];
+ margin: ButtonProps["margin"];
+ semantic: ButtonSemantic;
+ size: ButtonSize;
+ $mode: ButtonMode;
}>`
display: inline-flex;
align-items: center;
@@ -54,7 +54,7 @@ const LabelContainer = styled.span`
`;
const IconContainer = styled.div<{
- size: Size;
+ size: ButtonSize;
}>`
display: flex;
font-size: ${({ size }) =>
@@ -80,7 +80,7 @@ const DxcButton = ({
tabIndex = 0,
title,
type = "button",
-}: ButtonPropsType) => {
+}: ButtonProps) => {
return (