File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ---
Original file line number Diff line number Diff line change 1- import { type ComponentProps , type RenderProp , useRender } from '@clerk/headless/utils' ;
1+ import { useRender } from '@clerk/headless/utils' ;
22import * as stylex from '@stylexjs/stylex' ;
33import React from 'react' ;
44
5+ import type { MosaicComponentProps } from '../../props' ;
56import { mergeStyleProps , themeProps } from '../../props' ;
67import { colors , styles } from './badge.styles' ;
78
8- export type BadgeProps = Omit < ComponentProps < 'span' > , 'render '> & {
9+ export type BadgeProps = MosaicComponentProps < 'span' > & {
910 color ?: 'primary' | 'neutral' | 'warning' | 'negative' | 'positive' ;
10- render ?: RenderProp < React . ComponentPropsWithRef < 'span' > > | React . ReactElement ;
1111} ;
1212
1313/**
Original file line number Diff line number Diff line change 1- import type { RenderPropOrElement } from '@clerk/headless/utils' ;
21import { useRender } from '@clerk/headless/utils' ;
32import * as stylex from '@stylexjs/stylex' ;
43import React from 'react' ;
54
5+ import type { MosaicComponentProps } from '../../props' ;
66import { mergeStyleProps , themeProps } from '../../props' ;
77import { useContextProps } from '../../utils/context' ;
88import type { TypographyColor , TypographySize } from '../typography.styles' ;
99import { colors , sizes } from '../typography.styles' ;
1010import { styles } from './heading.styles' ;
1111
12- // `color` replaces the legacy HTML `color` attribute, whose `string` type would widen the variant.
13- export interface HeadingProps extends Omit < React . ComponentPropsWithRef < 'h2' > , 'color' > {
12+ export interface HeadingProps extends MosaicComponentProps < 'h2' > {
1413 size ?: TypographySize ;
1514 color ?: TypographyColor ;
16- render ?: RenderPropOrElement < 'h2' > ;
1715}
1816
1917export const HeadingContext = React . createContext < Partial < HeadingProps > | null > ( null ) ;
Original file line number Diff line number Diff line change 1- import type { RenderPropOrElement } from '@clerk/headless/utils' ;
21import { useRender } from '@clerk/headless/utils' ;
32import * as stylex from '@stylexjs/stylex' ;
43import React from 'react' ;
54
5+ import type { MosaicComponentProps } from '../../props' ;
66import { mergeStyleProps , themeProps } from '../../props' ;
77import { useContextProps } from '../../utils/context' ;
88import type { TypographyColor , TypographySize } from '../typography.styles' ;
99import { colors , sizes } from '../typography.styles' ;
1010
11- // `color` replaces the legacy HTML `color` attribute, whose `string` type would widen the variant.
12- export interface TextProps extends Omit < React . ComponentPropsWithRef < 'p' > , 'color' > {
11+ export interface TextProps extends MosaicComponentProps < 'p' > {
1312 size ?: TypographySize ;
1413 color ?: TypographyColor ;
15- render ?: RenderPropOrElement < 'p' > ;
1614}
1715
1816export const TextContext = React . createContext < Partial < TextProps > | null > ( null ) ;
Original file line number Diff line number Diff line change 1+ import type { RenderPropOrElement } from '@clerk/headless/utils' ;
12import type React from 'react' ;
23
4+ /**
5+ * The base props every Mosaic component accepts: the native props for its default
6+ * tag, plus the `render` escape hatch that swaps the rendered element.
7+ *
8+ * `color` is omitted because it is a non-standard HTML attribute typed `string`,
9+ * which would widen any component that exposes `color` as a variant. Omitting it
10+ * here rather than per component means a new component inherits the narrowing.
11+ */
12+ export type MosaicComponentProps < Tag extends keyof React . JSX . IntrinsicElements > = Omit <
13+ React . ComponentPropsWithRef < Tag > ,
14+ 'color'
15+ > & {
16+ render ?: RenderPropOrElement < Tag > ;
17+ } ;
18+
319// The public styling contract, emitted onto a component's root element:
420// 1. `--cl-*` vars — from `tokens.stylex.ts` (`:root { --cl-color-primary: … }`)
521// 2. `.cl-<slot>` class — from `themeProps` (`.cl-button { … }`)
You can’t perform that action at this time.
0 commit comments