import { type Boxes, type BoxStyle } from "./box-styles.js"; import { type LiteralUnion } from "type-fest"; import { type ForegroundColorName } from "ansi-styles"; import { type GridPlacement, type Line, type GridTemplateComponent, type TrackSizingFunction, type GridTemplateArea } from "taffy-layout"; import { type TaffyNode } from "./taffy-node.js"; export interface Styles { /** * Text wrapping behavior. * * - `wrap`: Text wraps to the next line. * - `end`: Truncates the end of the text. * - `middle`: Truncates the middle of the text. * - `truncate-end`: Truncates the end of the text. * - `truncate`: Truncates the end of the text. * - `truncate-middle`: Truncates the middle of the text. * - `truncate-start`: Truncates the beginning of the text. */ readonly textWrap?: "wrap" | "end" | "middle" | "truncate-end" | "truncate" | "truncate-middle" | "truncate-start"; /** * Positioning strategy. * * - `absolute`: Positioned relative to the nearest positioned ancestor. * - `relative`: Positioned relative to normal position. */ readonly position?: "absolute" | "relative"; /** * Size of the gap between an element's columns. */ readonly columnGap?: number; /** * Size of the gap between an element's rows. */ readonly rowGap?: number; /** * Size of the gap between an element's columns and rows. * This is a shorthand for `columnGap` and `rowGap`. */ readonly gap?: number; /** * Margin on all sides. * Equivalent to setting `marginTop`, `marginBottom`, `marginLeft`, * and `marginRight`. */ readonly margin?: number; /** * Horizontal margin. * Equivalent to setting `marginLeft` and `marginRight`. */ readonly marginX?: number; /** * Vertical margin. * Equivalent to setting `marginTop` and `marginBottom`. */ readonly marginY?: number; /** * Top margin. */ readonly marginTop?: number; /** * Bottom margin. */ readonly marginBottom?: number; /** * Left margin. */ readonly marginLeft?: number; /** * Right margin. */ readonly marginRight?: number; /** * Padding on all sides. * Equivalent to setting `paddingTop`, `paddingBottom`, `paddingLeft`, * and `paddingRight`. */ readonly padding?: number; /** * Horizontal padding. * Equivalent to setting `paddingLeft` and `paddingRight`. */ readonly paddingX?: number; /** * Vertical padding. * Equivalent to setting `paddingTop` and `paddingBottom`. */ readonly paddingY?: number; /** * Top padding. */ readonly paddingTop?: number; /** * Bottom padding. */ readonly paddingBottom?: number; /** * Left padding. */ readonly paddingLeft?: number; /** * Right padding. */ readonly paddingRight?: number; /** * Flex grow factor. * Defines how much a flex item will grow relative to the rest of the flex * items when there is available vertical/horizontal space. * * @see [flex-grow](https://css-tricks.com/almanac/properties/f/flex-grow/) */ readonly flexGrow?: number; /** * Flex shrink factor. * Defines how much a flex item will shrink relative to the rest of the flex * items when there is not enough space. * * @see [flex-shrink](https://css-tricks.com/almanac/properties/f/flex-shrink/) */ readonly flexShrink?: number; /** * Flex direction. * Establishes the main-axis, defining the direction flex items are placed * in the flex container. * * @see [flex-direction](https://css-tricks.com/almanac/properties/f/flex-direction/) * * @example * ```tsx * * I am item 1 * I am item 2 * * ``` */ readonly flexDirection?: "row" | "column" | "row-reverse" | "column-reverse"; /** * Flex basis. * Specifies the initial size of the flex item before any available space * is distributed. * * @see [flex-basis](https://css-tricks.com/almanac/properties/f/flex-basis/) */ readonly flexBasis?: number | string; /** * Flex wrap behavior. * Defines whether flex items are forced onto one line or can wrap onto * multiple lines. * * @see [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/) */ readonly flexWrap?: "nowrap" | "wrap" | "wrap-reverse"; /** * Align items. * Defines the default behavior for how flex items are laid out along the * cross axis on the current line. * * @see [align-items](https://css-tricks.com/almanac/properties/a/align-items/) * * @example * ```tsx * * I am centered * * ``` */ readonly alignItems?: "flex-start" | "center" | "flex-end" | "stretch" | "start" | "end"; /** * Align self. * Allows overriding the `alignItems` value for specific flex items. * * @see [align-self](https://css-tricks.com/almanac/properties/a/align-self/) */ readonly alignSelf?: "flex-start" | "center" | "flex-end" | "auto" | "start" | "end"; /** * Justify content. * Defines the alignment along the main axis. * * @see [justify-content](https://css-tricks.com/almanac/properties/j/justify-content/) * * @example * ```tsx * * Left * Right * * ``` */ readonly justifyContent?: "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly" | "center" | "start" | "end"; /** * Align content. * Modifies the behavior of `flexWrap`. It aligns flex lines much like * `alignItems` aligns flex items. * * @see [align-content](https://css-tricks.com/almanac/properties/a/align-content/) */ readonly alignContent?: "flex-start" | "flex-end" | "space-between" | "space-around" | "stretch" | "center" | "space-evenly" | "start" | "end"; /** * Justify items. * Defines the default `justify-self` for all items of the box. * * @see [justify-items](https://css-tricks.com/almanac/properties/j/justify-items/) */ readonly justifyItems?: "flex-start" | "end" | "flex-end" | "center" | "stretch"; /** * Justify self. * Sets the way a box is justified inside its alignment container along * the appropriate axis. * * @see [justify-self](https://css-tricks.com/almanac/properties/j/justify-self/) */ readonly justifySelf?: "auto" | "flex-start" | "end" | "flex-end" | "center" | "stretch"; /** * Width of the element. * Can be a number (in spaces) or a percentage string (e.g., "50%"). */ readonly width?: number | string; /** * Height of the element. * Can be a number (in lines) or a percentage string (e.g., "50%"). */ readonly height?: number | string; /** * Minimum width of the element. */ readonly minWidth?: number | string; /** * Minimum height of the element. */ readonly minHeight?: number | string; /** * Display type of the element. * * - `flex`: Displays the element as a flex container (default). * - `grid`: Displays the element as a grid container. * - `none`: Hides the element. */ readonly display?: "flex" | "grid" | "none"; /** * Border style. * If `undefined` (default), no border is added. * * @example * ```tsx * * Hello World * * ``` */ readonly borderStyle?: keyof Boxes | BoxStyle; /** * Top border visibility. * @default true */ readonly borderTop?: boolean; /** * Bottom border visibility. * @default true */ readonly borderBottom?: boolean; /** * Left border visibility. * @default true */ readonly borderLeft?: boolean; /** * Right border visibility. * @default true */ readonly borderRight?: boolean; /** * Border color. * Shorthand for setting `borderTopColor`, `borderRightColor`, * `borderBottomColor`, and `borderLeftColor`. */ readonly borderColor?: LiteralUnion; /** * Top border color. */ readonly borderTopColor?: LiteralUnion; /** * Bottom border color. */ readonly borderBottomColor?: LiteralUnion; /** * Left border color. */ readonly borderLeftColor?: LiteralUnion; /** * Right border color. */ readonly borderRightColor?: LiteralUnion; /** * Dim border color. * Shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, * `borderLeftDimColor`, and `borderRightDimColor`. * @default false */ readonly borderDimColor?: boolean; /** * Dim top border color. * @default false */ readonly borderTopDimColor?: boolean; /** * Dim bottom border color. * @default false */ readonly borderBottomDimColor?: boolean; /** * Dim left border color. * @default false */ readonly borderLeftDimColor?: boolean; /** * Dim right border color. * @default false */ readonly borderRightDimColor?: boolean; /** * Overflow behavior. * Sets the behavior for an element's overflow in both directions. * * @default 'visible' */ readonly overflow?: "visible" | "hidden"; /** * Horizontal overflow behavior. * * @default 'visible' */ readonly overflowX?: "visible" | "hidden"; /** * Vertical overflow behavior. * * @default 'visible' */ readonly overflowY?: "visible" | "hidden"; /** * Background color. * Accepts the same values as `color` in the `` component. */ readonly backgroundColor?: LiteralUnion; /** * CSS Grid Layout properties */ /** * Grid template columns. * Defines the columns of the grid with a space-separated list of values. * * @see [grid-template-columns](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridTemplateColumns?: (GridTemplateComponent | number)[]; /** * Grid template rows. * Defines the rows of the grid with a space-separated list of values. * * @see [grid-template-rows](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridTemplateRows?: (GridTemplateComponent | number)[]; /** * Grid auto columns. * Specifies the size of an implicitly-created grid column track. * * @see [grid-auto-columns](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridAutoColumns?: (TrackSizingFunction | number)[]; /** * Grid auto rows. * Specifies the size of an implicitly-created grid row track. * * @see [grid-auto-rows](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridAutoRows?: (TrackSizingFunction | number)[]; /** * Grid auto flow. * Controls how the auto-placement algorithm works. * * @see [grid-auto-flow](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridAutoFlow?: "row" | "column" | "row-dense" | "column-dense"; /** * Grid row. * Specifies a grid item’s size and location within a grid row. * * @see [grid-row](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) */ readonly gridRow?: Line; /** * Grid column. * Specifies a grid item's size and location within a grid column. * * @see [grid-column](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridColumn?: Line; /** * Grid template areas. * Specifies named grid areas. * * @see [grid-template-areas](https://developer.mozilla.org/en-US/docs/Web/CSS/) */ readonly gridTemplateAreas?: GridTemplateArea[]; } export declare const applyStyles: (node: TaffyNode, style?: Styles) => void;