Cleaning up
Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/ui': patch
|
||||
---
|
||||
|
||||
Cleaning up Backstage UI props definitions as well as removing ScrollArea in Card to improve accessibility.
|
||||
@@ -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<HTMLSpanElement>
|
||||
@@ -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<HTMLButtonElement>
|
||||
@@ -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<typeof displayPropDefs>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type EnumOrStringPropDef<T> = {
|
||||
type: 'enum | string';
|
||||
values: readonly T[];
|
||||
default?: T | string;
|
||||
required?: boolean;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type EnumPropDef<T> = {
|
||||
type: 'enum';
|
||||
values: readonly T[];
|
||||
default?: T;
|
||||
required?: boolean;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const FieldLabel: ForwardRefExoticComponent<
|
||||
FieldLabelProps & RefAttributes<HTMLDivElement>
|
||||
@@ -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<typeof gapPropDefs>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type GetPropDefType<Def> = Def extends BooleanPropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<boolean>
|
||||
: boolean
|
||||
: Def extends StringPropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<string>
|
||||
: string
|
||||
: Def extends ReactNodePropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<ReactNode>
|
||||
: ReactNode
|
||||
: Def extends EnumOrStringPropDef<infer Type>
|
||||
? Def extends ResponsivePropDef<infer Type extends string>
|
||||
? Responsive<string | Type>
|
||||
: string | Type
|
||||
: Def extends EnumPropDef<infer Type>
|
||||
? Def extends ResponsivePropDef<infer Type>
|
||||
? Responsive<Type>
|
||||
: Type
|
||||
: never;
|
||||
|
||||
// @public (undocumented)
|
||||
export type GetPropDefTypes<P> = {
|
||||
[K in keyof P]?: GetPropDefType<P[K]>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const Grid: {
|
||||
Root: ForwardRefExoticComponent<GridProps & RefAttributes<HTMLDivElement>>;
|
||||
@@ -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<typeof heightPropDefs>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const Icon: (props: IconProps) => JSX_2.Element | null;
|
||||
|
||||
@@ -1226,62 +1111,6 @@ export interface LinkProps extends LinkProps_2 {
|
||||
weight?: TextWeights | Partial<Record<Breakpoint, TextWeights>>;
|
||||
}
|
||||
|
||||
// @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<typeof marginPropDefs>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const Menu: (props: MenuProps<object>) => 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<typeof paddingPropDefs>;
|
||||
|
||||
// @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<typeof positionPropDefs>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type PropDef<T = any> = RegularPropDef<T> | ResponsivePropDef<T>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const Radio: ForwardRefExoticComponent<
|
||||
RadioProps & RefAttributes<HTMLLabelElement>
|
||||
@@ -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<T> =
|
||||
| ReactNodePropDef
|
||||
| BooleanPropDef
|
||||
| (StringPropDef & ArbitraryStylingPropDef)
|
||||
| (StringPropDef & NonStylingPropDef)
|
||||
| (EnumPropDef<T> & StylingPropDef)
|
||||
| (EnumPropDef<T> & NonStylingPropDef)
|
||||
| (EnumOrStringPropDef<T> & ArbitraryStylingPropDef)
|
||||
| (EnumOrStringPropDef<T> & NonStylingPropDef);
|
||||
|
||||
// @public (undocumented)
|
||||
export type Responsive<T> = T | Partial<Record<Breakpoint, T>>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type ResponsivePropDef<T = any> = RegularPropDef<T> & {
|
||||
responsive: true;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export function Row<T extends object>(props: RowProps<T>): JSX_2.Element;
|
||||
|
||||
@@ -1659,19 +1386,6 @@ export interface SpaceProps {
|
||||
py?: Responsive<Space>;
|
||||
}
|
||||
|
||||
// @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<Columns | 'full'>;
|
||||
}
|
||||
|
||||
// @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<typeof widthPropDefs>;
|
||||
```
|
||||
|
||||
@@ -26,7 +26,6 @@ export const Avatar = forwardRef<
|
||||
ElementRef<typeof AvatarPrimitive.Root>,
|
||||
AvatarProps
|
||||
>((props, ref) => {
|
||||
// const { className, src, name, ...rest } = props;
|
||||
const { classNames, dataAttributes, cleanedProps } = useStyles('Avatar', {
|
||||
size: 'medium',
|
||||
...props,
|
||||
|
||||
@@ -26,11 +26,7 @@ import styles from './Checkbox.module.css';
|
||||
export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(
|
||||
(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 = (
|
||||
<CheckboxPrimitive.Root
|
||||
|
||||
@@ -58,11 +58,6 @@ export const PasswordField = forwardRef<HTMLDivElement, PasswordFieldProps>(
|
||||
...props,
|
||||
});
|
||||
|
||||
console.log({
|
||||
size: 'small',
|
||||
...props,
|
||||
});
|
||||
|
||||
const {
|
||||
className,
|
||||
description,
|
||||
|
||||
@@ -60,7 +60,6 @@ export * from './components/Switch';
|
||||
|
||||
// Types
|
||||
export * from './types';
|
||||
export * from './props';
|
||||
|
||||
// Hooks
|
||||
export { useBreakpoint } from './hooks/useBreakpoint';
|
||||
|
||||
@@ -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<typeof displayPropDefs>;
|
||||
|
||||
export { displayPropDefs };
|
||||
export type { DisplayProps };
|
||||
@@ -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<typeof gapPropDefs>;
|
||||
|
||||
export { gapPropDefs };
|
||||
export type { GapProps };
|
||||
@@ -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<string>;
|
||||
minHeight: PropDef<string>;
|
||||
maxHeight: PropDef<string>;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
type HeightProps = GetPropDefTypes<typeof heightPropDefs>;
|
||||
|
||||
export { heightPropDefs };
|
||||
export type { HeightProps };
|
||||
@@ -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';
|
||||
@@ -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<typeof marginPropDefs>;
|
||||
|
||||
export { marginPropDefs };
|
||||
export type { MarginProps };
|
||||
@@ -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<typeof paddingPropDefs>;
|
||||
|
||||
export { paddingPropDefs };
|
||||
export type { PaddingProps };
|
||||
@@ -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<typeof positionPropDefs>;
|
||||
|
||||
export { positionPropDefs };
|
||||
export type { PositionProps };
|
||||
@@ -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<T> = {
|
||||
type: 'enum';
|
||||
values: readonly T[];
|
||||
default?: T;
|
||||
required?: boolean;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type EnumOrStringPropDef<T> = {
|
||||
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<T> =
|
||||
| ReactNodePropDef
|
||||
| BooleanPropDef
|
||||
| (StringPropDef & ArbitraryStylingPropDef)
|
||||
| (StringPropDef & NonStylingPropDef)
|
||||
| (EnumPropDef<T> & StylingPropDef)
|
||||
| (EnumPropDef<T> & NonStylingPropDef)
|
||||
| (EnumOrStringPropDef<T> & ArbitraryStylingPropDef)
|
||||
| (EnumOrStringPropDef<T> & NonStylingPropDef);
|
||||
|
||||
/** @public */
|
||||
type ResponsivePropDef<T = any> = RegularPropDef<T> & {
|
||||
responsive: true;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
type PropDef<T = any> = RegularPropDef<T> | ResponsivePropDef<T>;
|
||||
|
||||
/** @public */
|
||||
export type GetPropDefType<Def> = Def extends BooleanPropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<boolean>
|
||||
: boolean
|
||||
: Def extends StringPropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<string>
|
||||
: string
|
||||
: Def extends ReactNodePropDef
|
||||
? Def extends ResponsivePropDef
|
||||
? Responsive<ReactNode>
|
||||
: ReactNode
|
||||
: Def extends EnumOrStringPropDef<infer Type>
|
||||
? Def extends ResponsivePropDef<infer Type extends string>
|
||||
? Responsive<string | Type>
|
||||
: string | Type
|
||||
: Def extends EnumPropDef<infer Type>
|
||||
? Def extends ResponsivePropDef<infer Type>
|
||||
? Responsive<Type>
|
||||
: Type
|
||||
: never;
|
||||
|
||||
/** @public */
|
||||
type GetPropDefTypes<P> = {
|
||||
[K in keyof P]?: GetPropDefType<P[K]>;
|
||||
};
|
||||
|
||||
export { breakpoints };
|
||||
export type {
|
||||
PropDef,
|
||||
GetPropDefTypes,
|
||||
ResponsivePropDef,
|
||||
Breakpoint,
|
||||
Responsive,
|
||||
};
|
||||
@@ -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),
|
||||
};
|
||||
@@ -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<string>;
|
||||
minWidth: PropDef<string>;
|
||||
maxWidth: PropDef<string>;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
type WidthProps = GetPropDefTypes<typeof widthPropDefs>;
|
||||
|
||||
export { widthPropDefs };
|
||||
export type { WidthProps };
|
||||
Reference in New Issue
Block a user