diff --git a/.changeset/polite-impalas-shine.md b/.changeset/polite-impalas-shine.md new file mode 100644 index 0000000000..61b89b1779 --- /dev/null +++ b/.changeset/polite-impalas-shine.md @@ -0,0 +1,5 @@ +--- +'@backstage/ui': patch +--- + +Cleaning up Backstage UI props definitions as well as removing ScrollArea in Card to improve accessibility. diff --git a/packages/ui/report.api.md b/packages/ui/report.api.md index 09392ceb24..8a19c039a7 100644 --- a/packages/ui/report.api.md +++ b/packages/ui/report.api.md @@ -57,13 +57,6 @@ import { TooltipTriggerComponentProps } from 'react-aria-components'; // @public (undocumented) export type AlignItems = 'stretch' | 'start' | 'center' | 'end'; -// @public (undocumented) -export type ArbitraryStylingPropDef = { - className: string; - customProperties: `--${string}`[]; - parseValue?: (value: string) => string | undefined; -}; - // @public (undocumented) export const Avatar: ForwardRefExoticComponent< AvatarProps & RefAttributes @@ -80,14 +73,6 @@ export interface AvatarProps src: string; } -// @public (undocumented) -export type BooleanPropDef = { - type: 'boolean'; - default?: boolean; - required?: boolean; - className?: string; -}; - // @public (undocumented) export type Border = 'none' | 'base' | 'error' | 'warning' | 'selected'; @@ -140,9 +125,6 @@ export interface BoxProps extends SpaceProps { // @public (undocumented) export type Breakpoint = 'initial' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'; -// @public (undocumented) -export const breakpoints: Breakpoint[]; - // @public (undocumented) export const Button: ForwardRefExoticComponent< ButtonProps & RefAttributes @@ -868,35 +850,6 @@ export interface DialogTriggerProps extends DialogTriggerProps_2 {} // @public (undocumented) export type Display = 'none' | 'flex' | 'block' | 'inline'; -// @public (undocumented) -export const displayPropDefs: { - display: { - type: 'enum'; - className: string; - values: readonly ['none', 'inline', 'inline-block', 'block']; - responsive: true; - }; -}; - -// @public (undocumented) -export type DisplayProps = GetPropDefTypes; - -// @public (undocumented) -export type EnumOrStringPropDef = { - type: 'enum | string'; - values: readonly T[]; - default?: T | string; - required?: boolean; -}; - -// @public (undocumented) -export type EnumPropDef = { - type: 'enum'; - values: readonly T[]; - default?: T; - required?: boolean; -}; - // @public (undocumented) export const FieldLabel: ForwardRefExoticComponent< FieldLabelProps & RefAttributes @@ -940,49 +893,6 @@ export interface FlexProps extends SpaceProps { // @public (undocumented) export type FlexWrap = 'wrap' | 'nowrap' | 'wrap-reverse'; -// @public (undocumented) -export const gapPropDefs: { - gap: { - type: 'enum | string'; - className: string; - customProperties: '--gap'[]; - values: string[]; - responsive: true; - default: string; - }; -}; - -// @public (undocumented) -export type GapProps = GetPropDefTypes; - -// @public (undocumented) -export type GetPropDefType = Def extends BooleanPropDef - ? Def extends ResponsivePropDef - ? Responsive - : boolean - : Def extends StringPropDef - ? Def extends ResponsivePropDef - ? Responsive - : string - : Def extends ReactNodePropDef - ? Def extends ResponsivePropDef - ? Responsive - : ReactNode - : Def extends EnumOrStringPropDef - ? Def extends ResponsivePropDef - ? Responsive - : string | Type - : Def extends EnumPropDef - ? Def extends ResponsivePropDef - ? Responsive - : Type - : never; - -// @public (undocumented) -export type GetPropDefTypes

= { - [K in keyof P]?: GetPropDefType; -}; - // @public (undocumented) export const Grid: { Root: ForwardRefExoticComponent>; @@ -1076,31 +986,6 @@ export interface HeaderTab { matchStrategy?: TabMatchStrategy; } -// @public (undocumented) -export const heightPropDefs: { - height: { - type: 'string'; - className: string; - customProperties: '--height'[]; - responsive: true; - }; - minHeight: { - type: 'string'; - className: string; - customProperties: '--min-height'[]; - responsive: true; - }; - maxHeight: { - type: 'string'; - className: string; - customProperties: '--max-height'[]; - responsive: true; - }; -}; - -// @public (undocumented) -export type HeightProps = GetPropDefTypes; - // @public (undocumented) export const Icon: (props: IconProps) => JSX_2.Element | null; @@ -1226,62 +1111,6 @@ export interface LinkProps extends LinkProps_2 { weight?: TextWeights | Partial>; } -// @public (undocumented) -export const marginPropDefs: (spacingValues: string[]) => { - m: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--m'[]; - responsive: true; - }; - mx: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--mx'[]; - responsive: true; - }; - my: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--my'[]; - responsive: true; - }; - mt: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--mt'[]; - responsive: true; - }; - mr: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--mr'[]; - responsive: true; - }; - mb: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--mb'[]; - responsive: true; - }; - ml: { - type: 'enum | string'; - values: string[]; - className: string; - customProperties: '--ml'[]; - responsive: true; - }; -}; - -// @public (undocumented) -export type MarginProps = GetPropDefTypes; - // @public (undocumented) export const Menu: (props: MenuProps) => JSX_2.Element; @@ -1409,85 +1238,6 @@ export const MenuTrigger: (props: MenuTriggerProps) => JSX_2.Element; // @public (undocumented) export interface MenuTriggerProps extends MenuTriggerProps_2 {} -// @public (undocumented) -export type NonStylingPropDef = { - className?: never; - customProperties?: never; - parseValue?: never; -}; - -// @public (undocumented) -export const paddingPropDefs: (spacingValues: string[]) => { - p: { - type: 'enum | string'; - className: string; - customProperties: '--p'[]; - values: string[]; - responsive: true; - }; - px: { - type: 'enum | string'; - className: string; - customProperties: '--px'[]; - values: string[]; - responsive: true; - }; - py: { - type: 'enum | string'; - className: string; - customProperties: '--py'[]; - values: string[]; - responsive: true; - }; - pt: { - type: 'enum | string'; - className: string; - customProperties: '--pt'[]; - values: string[]; - responsive: true; - }; - pr: { - type: 'enum | string'; - className: string; - customProperties: '--pr'[]; - values: string[]; - responsive: true; - }; - pb: { - type: 'enum | string'; - className: string; - customProperties: '--pb'[]; - values: string[]; - responsive: true; - }; - pl: { - type: 'enum | string'; - className: string; - customProperties: '--pl'[]; - values: string[]; - responsive: true; - }; -}; - -// @public (undocumented) -export type PaddingProps = GetPropDefTypes; - -// @public (undocumented) -export const positionPropDefs: { - position: { - type: 'enum'; - className: string; - values: readonly ['static', 'relative', 'absolute', 'fixed', 'sticky']; - responsive: true; - }; -}; - -// @public (undocumented) -export type PositionProps = GetPropDefTypes; - -// @public (undocumented) -export type PropDef = RegularPropDef | ResponsivePropDef; - // @public (undocumented) export const Radio: ForwardRefExoticComponent< RadioProps & RefAttributes @@ -1509,32 +1259,9 @@ export interface RadioGroupProps // @public (undocumented) export interface RadioProps extends RadioProps_2 {} -// @public (undocumented) -export type ReactNodePropDef = { - type: 'ReactNode'; - default?: ReactNode; - required?: boolean; -}; - -// @public (undocumented) -export type RegularPropDef = - | ReactNodePropDef - | BooleanPropDef - | (StringPropDef & ArbitraryStylingPropDef) - | (StringPropDef & NonStylingPropDef) - | (EnumPropDef & StylingPropDef) - | (EnumPropDef & NonStylingPropDef) - | (EnumOrStringPropDef & ArbitraryStylingPropDef) - | (EnumOrStringPropDef & NonStylingPropDef); - // @public (undocumented) export type Responsive = T | Partial>; -// @public (undocumented) -export type ResponsivePropDef = RegularPropDef & { - responsive: true; -}; - // @public (undocumented) export function Row(props: RowProps): JSX_2.Element; @@ -1659,19 +1386,6 @@ export interface SpaceProps { py?: Responsive; } -// @public (undocumented) -export type StringPropDef = { - type: 'string'; - default?: string; - required?: boolean; -}; - -// @public (undocumented) -export type StylingPropDef = { - className: string; - parseValue?: (value: string) => string | undefined; -}; - // @public (undocumented) export const SubmenuTrigger: (props: SubmenuTriggerProps) => JSX_2.Element; @@ -1950,29 +1664,4 @@ export interface UtilityProps extends SpaceProps { // (undocumented) rowSpan?: Responsive; } - -// @public (undocumented) -export const widthPropDefs: { - width: { - type: 'string'; - className: string; - customProperties: '--width'[]; - responsive: true; - }; - minWidth: { - type: 'string'; - className: string; - customProperties: '--min-width'[]; - responsive: true; - }; - maxWidth: { - type: 'string'; - className: string; - customProperties: '--max-width'[]; - responsive: true; - }; -}; - -// @public (undocumented) -export type WidthProps = GetPropDefTypes; ``` diff --git a/packages/ui/src/components/Avatar/Avatar.tsx b/packages/ui/src/components/Avatar/Avatar.tsx index c7c37acb9f..000087d451 100644 --- a/packages/ui/src/components/Avatar/Avatar.tsx +++ b/packages/ui/src/components/Avatar/Avatar.tsx @@ -26,7 +26,6 @@ export const Avatar = forwardRef< ElementRef, AvatarProps >((props, ref) => { - // const { className, src, name, ...rest } = props; const { classNames, dataAttributes, cleanedProps } = useStyles('Avatar', { size: 'medium', ...props, diff --git a/packages/ui/src/components/Checkbox/Checkbox.tsx b/packages/ui/src/components/Checkbox/Checkbox.tsx index bb91b86282..98ccdbc674 100644 --- a/packages/ui/src/components/Checkbox/Checkbox.tsx +++ b/packages/ui/src/components/Checkbox/Checkbox.tsx @@ -26,11 +26,7 @@ import styles from './Checkbox.module.css'; export const Checkbox = forwardRef( (props, ref) => { const { classNames, cleanedProps } = useStyles('Checkbox', props); - - const { label, onChange, className, ...rest } = props; - - console.log('props', props); - console.log('cleanedProps', cleanedProps); + const { label, onChange, className, ...rest } = cleanedProps; const checkboxElement = ( ( ...props, }); - console.log({ - size: 'small', - ...props, - }); - const { className, description, diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index efad69605b..8f79037f8f 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -60,7 +60,6 @@ export * from './components/Switch'; // Types export * from './types'; -export * from './props'; // Hooks export { useBreakpoint } from './hooks/useBreakpoint'; diff --git a/packages/ui/src/props/display.props.ts b/packages/ui/src/props/display.props.ts deleted file mode 100644 index 4a18aea910..0000000000 --- a/packages/ui/src/props/display.props.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { PropDef, GetPropDefTypes } from './prop-def'; - -const displayValues = ['none', 'inline', 'inline-block', 'block'] as const; - -/** @public */ -const displayPropDefs = { - display: { - type: 'enum', - className: 'bui-display', - values: displayValues, - responsive: true, - }, -} satisfies { - display: PropDef<(typeof displayValues)[number]>; -}; - -/** @public */ -type DisplayProps = GetPropDefTypes; - -export { displayPropDefs }; -export type { DisplayProps }; diff --git a/packages/ui/src/props/gap-props.ts b/packages/ui/src/props/gap-props.ts deleted file mode 100644 index 2701473004..0000000000 --- a/packages/ui/src/props/gap-props.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { PropDef } from './prop-def'; -import { GetPropDefTypes } from './prop-def'; -import { spacingValues } from './spacing.props'; - -/** @public */ -const gapPropDefs = { - gap: { - type: 'enum | string', - className: 'bui-gap', - customProperties: ['--gap'], - values: spacingValues, - responsive: true, - default: '4', - }, -} satisfies { - gap: PropDef<(typeof spacingValues)[number]>; -}; - -/** @public */ -type GapProps = GetPropDefTypes; - -export { gapPropDefs }; -export type { GapProps }; diff --git a/packages/ui/src/props/height.props.ts b/packages/ui/src/props/height.props.ts deleted file mode 100644 index d6195c1fae..0000000000 --- a/packages/ui/src/props/height.props.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import type { PropDef, GetPropDefTypes } from './prop-def'; - -/** @public */ -const heightPropDefs = { - height: { - type: 'string', - className: 'bui-h', - customProperties: ['--height'], - responsive: true, - }, - minHeight: { - type: 'string', - className: 'bui-min-h', - customProperties: ['--min-height'], - responsive: true, - }, - maxHeight: { - type: 'string', - className: 'bui-max-h', - customProperties: ['--max-height'], - responsive: true, - }, -} satisfies { - height: PropDef; - minHeight: PropDef; - maxHeight: PropDef; -}; - -/** @public */ -type HeightProps = GetPropDefTypes; - -export { heightPropDefs }; -export type { HeightProps }; diff --git a/packages/ui/src/props/index.ts b/packages/ui/src/props/index.ts deleted file mode 100644 index fc92cea12d..0000000000 --- a/packages/ui/src/props/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export type { DisplayProps, displayPropDefs } from './display.props'; -export type { HeightProps, heightPropDefs } from './height.props'; -export type { MarginProps, marginPropDefs } from './margin.props'; -export type { PaddingProps, paddingPropDefs } from './padding.props'; -export type { PositionProps, positionPropDefs } from './position.props'; -export type { WidthProps, widthPropDefs } from './width.props'; -export type { GapProps, gapPropDefs } from './gap-props'; -export * from './prop-def'; diff --git a/packages/ui/src/props/margin.props.ts b/packages/ui/src/props/margin.props.ts deleted file mode 100644 index 31ebf54747..0000000000 --- a/packages/ui/src/props/margin.props.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import type { PropDef, GetPropDefTypes } from './prop-def'; - -/** @public */ -const marginPropDefs = (spacingValues: string[]) => - ({ - m: { - type: 'enum | string', - values: spacingValues, - className: 'bui-m', - customProperties: ['--m'], - responsive: true, - }, - mx: { - type: 'enum | string', - values: spacingValues, - className: 'bui-mx', - customProperties: ['--mx'], - responsive: true, - }, - my: { - type: 'enum | string', - values: spacingValues, - className: 'bui-my', - customProperties: ['--my'], - responsive: true, - }, - mt: { - type: 'enum | string', - values: spacingValues, - className: 'bui-mt', - customProperties: ['--mt'], - responsive: true, - }, - mr: { - type: 'enum | string', - values: spacingValues, - className: 'bui-mr', - customProperties: ['--mr'], - responsive: true, - }, - mb: { - type: 'enum | string', - values: spacingValues, - className: 'bui-mb', - customProperties: ['--mb'], - responsive: true, - }, - ml: { - type: 'enum | string', - values: spacingValues, - className: 'bui-ml', - customProperties: ['--ml'], - responsive: true, - }, - } satisfies { - m: PropDef<(typeof spacingValues)[number]>; - mx: PropDef<(typeof spacingValues)[number]>; - my: PropDef<(typeof spacingValues)[number]>; - mt: PropDef<(typeof spacingValues)[number]>; - mr: PropDef<(typeof spacingValues)[number]>; - mb: PropDef<(typeof spacingValues)[number]>; - ml: PropDef<(typeof spacingValues)[number]>; - }); - -/** @public */ -type MarginProps = GetPropDefTypes; - -export { marginPropDefs }; -export type { MarginProps }; diff --git a/packages/ui/src/props/padding.props.ts b/packages/ui/src/props/padding.props.ts deleted file mode 100644 index 16d13cf957..0000000000 --- a/packages/ui/src/props/padding.props.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { PropDef } from './prop-def'; -import { GetPropDefTypes } from './prop-def'; - -/** @public */ -const paddingPropDefs = (spacingValues: string[]) => - ({ - p: { - type: 'enum | string', - className: 'bui-p', - customProperties: ['--p'], - values: spacingValues, - responsive: true, - }, - px: { - type: 'enum | string', - className: 'bui-px', - customProperties: ['--px'], - values: spacingValues, - responsive: true, - }, - py: { - type: 'enum | string', - className: 'bui-py', - customProperties: ['--py'], - values: spacingValues, - responsive: true, - }, - pt: { - type: 'enum | string', - className: 'bui-pt', - customProperties: ['--pt'], - values: spacingValues, - responsive: true, - }, - pr: { - type: 'enum | string', - className: 'bui-pr', - customProperties: ['--pr'], - values: spacingValues, - responsive: true, - }, - pb: { - type: 'enum | string', - className: 'bui-pb', - customProperties: ['--pb'], - values: spacingValues, - responsive: true, - }, - pl: { - type: 'enum | string', - className: 'bui-pl', - customProperties: ['--pl'], - values: spacingValues, - responsive: true, - }, - } satisfies { - p: PropDef<(typeof spacingValues)[number]>; - px: PropDef<(typeof spacingValues)[number]>; - py: PropDef<(typeof spacingValues)[number]>; - pt: PropDef<(typeof spacingValues)[number]>; - pr: PropDef<(typeof spacingValues)[number]>; - pb: PropDef<(typeof spacingValues)[number]>; - pl: PropDef<(typeof spacingValues)[number]>; - }); - -/** @public */ -type PaddingProps = GetPropDefTypes; - -export { paddingPropDefs }; -export type { PaddingProps }; diff --git a/packages/ui/src/props/position.props.ts b/packages/ui/src/props/position.props.ts deleted file mode 100644 index 027b5e2a63..0000000000 --- a/packages/ui/src/props/position.props.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import type { PropDef, GetPropDefTypes } from './prop-def'; - -/** @public */ -const positionValues = [ - 'static', - 'relative', - 'absolute', - 'fixed', - 'sticky', -] as const; - -/** @public */ -const positionPropDefs = { - position: { - type: 'enum', - className: 'bui-position', - values: positionValues, - responsive: true, - }, -} satisfies { - position: PropDef<(typeof positionValues)[number]>; -}; - -// Use all of the imported prop defs to ensure that JSDoc works -/** @public */ -type PositionProps = GetPropDefTypes; - -export { positionPropDefs }; -export type { PositionProps }; diff --git a/packages/ui/src/props/prop-def.ts b/packages/ui/src/props/prop-def.ts deleted file mode 100644 index dc6c798d51..0000000000 --- a/packages/ui/src/props/prop-def.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import type { ReactNode } from 'react'; -import type { Breakpoint, Responsive } from '../types'; - -/** @public */ -const breakpoints = ['initial', 'xs', 'sm', 'md', 'lg', 'xl'] as Breakpoint[]; - -/** @public */ -export type BooleanPropDef = { - type: 'boolean'; - default?: boolean; - required?: boolean; - className?: string; -}; - -/** @public */ -export type StringPropDef = { - type: 'string'; - default?: string; - required?: boolean; -}; - -/** @public */ -export type ReactNodePropDef = { - type: 'ReactNode'; - default?: ReactNode; - required?: boolean; -}; - -/** @public */ -export type EnumPropDef = { - type: 'enum'; - values: readonly T[]; - default?: T; - required?: boolean; -}; - -/** @public */ -export type EnumOrStringPropDef = { - type: 'enum | string'; - values: readonly T[]; - default?: T | string; - required?: boolean; -}; - -/** @public */ -export type NonStylingPropDef = { - className?: never; - customProperties?: never; - parseValue?: never; -}; - -/** @public */ -export type StylingPropDef = { - className: string; - parseValue?: (value: string) => string | undefined; -}; - -/** @public */ -export type ArbitraryStylingPropDef = { - className: string; - customProperties: `--${string}`[]; - parseValue?: (value: string) => string | undefined; -}; - -/** @public */ -export type RegularPropDef = - | ReactNodePropDef - | BooleanPropDef - | (StringPropDef & ArbitraryStylingPropDef) - | (StringPropDef & NonStylingPropDef) - | (EnumPropDef & StylingPropDef) - | (EnumPropDef & NonStylingPropDef) - | (EnumOrStringPropDef & ArbitraryStylingPropDef) - | (EnumOrStringPropDef & NonStylingPropDef); - -/** @public */ -type ResponsivePropDef = RegularPropDef & { - responsive: true; -}; - -/** @public */ -type PropDef = RegularPropDef | ResponsivePropDef; - -/** @public */ -export type GetPropDefType = Def extends BooleanPropDef - ? Def extends ResponsivePropDef - ? Responsive - : boolean - : Def extends StringPropDef - ? Def extends ResponsivePropDef - ? Responsive - : string - : Def extends ReactNodePropDef - ? Def extends ResponsivePropDef - ? Responsive - : ReactNode - : Def extends EnumOrStringPropDef - ? Def extends ResponsivePropDef - ? Responsive - : string | Type - : Def extends EnumPropDef - ? Def extends ResponsivePropDef - ? Responsive - : Type - : never; - -/** @public */ -type GetPropDefTypes

= { - [K in keyof P]?: GetPropDefType; -}; - -export { breakpoints }; -export type { - PropDef, - GetPropDefTypes, - ResponsivePropDef, - Breakpoint, - Responsive, -}; diff --git a/packages/ui/src/props/spacing.props.ts b/packages/ui/src/props/spacing.props.ts deleted file mode 100644 index d33bab2aa5..0000000000 --- a/packages/ui/src/props/spacing.props.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { paddingPropDefs } from './padding.props'; -import { marginPropDefs } from './margin.props'; - -export const spacingValues = [ - '0.5', - '1', - '1.5', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', -]; - -export const spacingPropDefs = { - ...paddingPropDefs(spacingValues), - ...marginPropDefs(spacingValues), -}; diff --git a/packages/ui/src/props/width.props.ts b/packages/ui/src/props/width.props.ts deleted file mode 100644 index 019ec978ba..0000000000 --- a/packages/ui/src/props/width.props.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2025 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import type { GetPropDefTypes, PropDef } from './prop-def'; - -/** @public */ -const widthPropDefs = { - width: { - type: 'string', - className: 'bui-w', - customProperties: ['--width'], - responsive: true, - }, - minWidth: { - type: 'string', - className: 'bui-min-w', - customProperties: ['--min-width'], - responsive: true, - }, - maxWidth: { - type: 'string', - className: 'bui-max-w', - customProperties: ['--max-width'], - responsive: true, - }, -} satisfies { - width: PropDef; - minWidth: PropDef; - maxWidth: PropDef; -}; - -/** @public */ -type WidthProps = GetPropDefTypes; - -export { widthPropDefs }; -export type { WidthProps };