UNPKG

@atlaskit/primitives

Version:

Primitives are token-backed low-level building blocks.

106 lines (105 loc) 4.32 kB
/** * @jsxRuntime classic * @jsx jsx */ import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ReactElement, type ReactNode } from 'react'; import { type StrictXCSSProp, type XCSSAllProperties, type XCSSAllPseudos } from '@atlaskit/css'; import type { BackgroundColorToken, SVGElements } from '../../utils/types'; import type { BasePrimitiveProps, PaddingToken, StyleProp, SurfaceColorToken } from './types'; type AllowedElements = Exclude<keyof JSX.IntrinsicElements, SVGElements | 'button' | 'a'>; type CustomElementType<P = any> = { [K in AllowedElements]: P extends JSX.IntrinsicElements[K] ? K : never; }[AllowedElements]; export type BoxProps<T extends CustomElementType> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & Omit<BasePrimitiveProps, 'xcss' | 'style'> & BaseBoxProps<T>; type BaseBoxProps<T extends CustomElementType> = { /** * The DOM element to render as the Box. Defaults to `div`. */ as?: T; /** * Elements to be rendered inside the Box. */ children?: ReactNode; /** * Token representing background color with a built-in fallback value. */ backgroundColor?: SurfaceColorToken | BackgroundColorToken; /** * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together. * * @see paddingBlock * @see paddingInline * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ padding?: PaddingToken; /** * Tokens representing CSS shorthand `paddingBlock`. * * @see paddingBlockStart * @see paddingBlockEnd * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ paddingBlock?: PaddingToken; /** * Tokens representing CSS `paddingBlockStart`. * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ paddingBlockStart?: PaddingToken; /** * Tokens representing CSS `paddingBlockEnd`. * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ paddingBlockEnd?: PaddingToken; /** * Tokens representing CSS shorthand `paddingInline`. * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. * * @see paddingInlineStart * @see paddingInlineEnd */ paddingInline?: PaddingToken; /** * Tokens representing CSS `paddingInlineStart`. * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ paddingInlineStart?: PaddingToken; /** * Tokens representing CSS `paddingInlineEnd`. * @private * @deprecated – Do not use shorthand props, use `props.xcss` instead as these will be deprecated in the future. */ paddingInlineEnd?: PaddingToken; /** * Forwarded ref. */ ref?: ComponentPropsWithRef<T>['ref']; /** * Inline styles to be applied to the Box. Only apply as a last resort, or where * styles cannot otherwise be calculated outside of the runtime of the component they're applied. */ style?: Omit<StyleProp['style'], 'backgroundColor'>; /** * Apply a subset of permitted styles powered by Atlassian Design System design tokens. * Note that `backgroundColor` is not allowed, use the `backgroundColor` prop instead for surface awareness. */ xcss?: StrictXCSSProp<Exclude<XCSSAllProperties, 'background' | 'backgroundColor'>, XCSSAllPseudos>; }; type BoxComponent = <T extends CustomElementType>(props: BoxProps<T>) => ReactElement | null; /** * __Box__ * * A Box is a primitive component that has the design decisions of the Atlassian Design System baked in. * Renders a `div` by default. * * - [Examples](https://atlassian.design/components/primitives/box/examples) * - [Code](https://atlassian.design/components/primitives/box/code) * - [Usage](https://atlassian.design/components/primitives/box/usage) */ declare const Box: BoxComponent; export default Box;