@yahoo/uds 3.59.0-beta.1 → 3.59.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-darwin-x64 +0 -0
- package/cli/bin/uds-linux-arm64 +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/dist/components/Box.d.ts +2 -2
- package/dist/components/Box.d.ts.map +1 -1
- package/dist/components/Divider/Divider.d.cts +2 -2
- package/dist/components/Divider/Divider.d.ts +2 -2
- package/dist/components/Divider/DividerCore.d.cts +2 -2
- package/dist/components/Divider/DividerCore.d.ts +2 -2
- package/dist/components/Divider/DividerInternal.d.cts +2 -2
- package/dist/components/Divider/DividerInternal.d.ts +2 -2
- package/dist/components/FormLabel.d.ts +2 -2
- package/dist/components/HStack.d.ts +2 -2
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Link.d.ts +2 -2
- package/dist/components/Text.d.cts +5 -5
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +8 -8
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/VStack.d.ts +2 -2
- package/dist/components/VStack.d.ts.map +1 -1
- package/dist/components/client/AnimateHeightChange.d.cts +2 -2
- package/dist/components/client/AnimateHeightChange.d.ts +2 -2
- package/dist/components/client/Avatar/Avatar.d.cts +2 -2
- package/dist/components/client/Avatar/Avatar.d.cts.map +1 -1
- package/dist/components/client/Avatar/Avatar.d.ts +2 -2
- package/dist/components/client/Avatar/AvatarIcon.d.cts +2 -2
- package/dist/components/client/Avatar/AvatarIcon.d.cts.map +1 -1
- package/dist/components/client/Avatar/AvatarIcon.d.ts +2 -2
- package/dist/components/client/Avatar/AvatarImage.d.cts +2 -2
- package/dist/components/client/Avatar/AvatarImage.d.ts +2 -2
- package/dist/components/client/Avatar/AvatarText.d.cts +2 -2
- package/dist/components/client/Avatar/AvatarText.d.ts +2 -2
- package/dist/components/client/IconButton.d.cts +2 -2
- package/dist/components/client/IconButton.d.ts +2 -2
- package/dist/components/client/IconButton.d.ts.map +1 -1
- package/dist/components/client/Input/Input.d.cts +2 -2
- package/dist/components/client/Input/Input.d.ts +2 -2
- package/dist/components/client/Input/InputHelpText.d.cts +2 -2
- package/dist/components/client/Input/InputHelpText.d.cts.map +1 -1
- package/dist/components/client/Input/InputHelpText.d.ts +2 -2
- package/dist/components/client/Input/InputHelpTextInternal.d.cts +4 -4
- package/dist/components/client/Input/InputHelpTextInternal.d.cts.map +1 -1
- package/dist/components/client/Input/InputHelpTextInternal.d.ts +4 -4
- package/dist/components/client/Menu/Menu.Content.d.cts +2 -2
- package/dist/components/client/Menu/Menu.Content.d.ts +2 -2
- package/dist/components/client/Menu/Menu.Divider.d.cts +2 -2
- package/dist/components/client/Menu/Menu.Divider.d.ts +2 -2
- package/dist/components/client/Menu/Menu.Item.d.cts +2 -2
- package/dist/components/client/Menu/Menu.ItemBase.d.cts +2 -2
- package/dist/components/client/Menu/Menu.ItemBase.d.ts +2 -2
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +2 -2
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +2 -2
- package/dist/components/client/Menu/Menu.Provider.d.cts +2 -2
- package/dist/components/client/Menu/Menu.Provider.d.ts +2 -2
- package/dist/components/client/Menu/Menu.Trigger.d.cts +2 -2
- package/dist/components/client/Menu/Menu.Trigger.d.ts +2 -2
- package/dist/components/client/Pressable.d.cts +2 -2
- package/dist/components/client/Pressable.d.ts +2 -2
- package/dist/components/client/Pressable.d.ts.map +1 -1
- package/dist/components/client/Radio/RadioGroupStore.d.ts +2 -2
- package/dist/components/client/SpringMotionConfig.d.cts +3 -3
- package/dist/components/client/SpringMotionConfig.d.ts +3 -3
- package/dist/components/client/SpringMotionConfig.d.ts.map +1 -1
- package/dist/components/experimental/Spinner.d.cts +2 -2
- package/dist/components/experimental/Spinner.d.cts.map +1 -1
- package/dist/components/experimental/Spinner.d.ts +2 -2
- package/dist/components/experimental/Table.d.cts +2 -2
- package/dist/components/experimental/Table.d.ts +2 -2
- package/dist/components/experimental/client/Accordion.d.cts +2 -2
- package/dist/components/experimental/client/Accordion.d.cts.map +1 -1
- package/dist/components/experimental/client/Accordion.d.ts +2 -2
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.cts +2 -2
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.ts +2 -2
- package/dist/components/experimental/client/Modal.d.cts +3 -3
- package/dist/components/experimental/client/Modal.d.cts.map +1 -1
- package/dist/components/experimental/client/Modal.d.ts +3 -3
- package/dist/components/experimental/client/Popover.d.cts +3 -3
- package/dist/components/experimental/client/Popover.d.cts.map +1 -1
- package/dist/components/experimental/client/Popover.d.ts +3 -3
- package/dist/components/experimental/client/Tabs.d.cts +3 -3
- package/dist/components/experimental/client/Tabs.d.ts +6 -6
- package/dist/components/experimental/client/Toast.d.cts +2 -2
- package/dist/components/experimental/client/Toast.d.ts +2 -2
- package/dist/providers/ColorModeProvider.d.cts +4 -4
- package/dist/providers/ColorModeProvider.d.cts.map +1 -1
- package/dist/providers/ColorModeProvider.d.ts +4 -4
- package/dist/providers/ColorModeProvider.d.ts.map +1 -1
- package/dist/providers/ScaleModeProvider.d.cts +4 -4
- package/dist/providers/ScaleModeProvider.d.cts.map +1 -1
- package/dist/providers/ScaleModeProvider.d.ts +4 -4
- package/dist/providers/ScaleModeProvider.d.ts.map +1 -1
- package/dist/providers/ThemeProvider.d.cts +2 -2
- package/dist/providers/ThemeProvider.d.cts.map +1 -1
- package/dist/providers/ThemeProvider.d.ts +2 -2
- package/dist/styles/styler.d.cts +33 -33
- package/dist/styles/styler.d.ts +33 -33
- package/dist/styles/stylerTypes.d.ts.map +1 -1
- package/dist/tailwind/tailwind.config.d.ts +3 -3
- package/dist/tailwind/tailwindPlugin.d.ts +3 -3
- package/dist/tailwind/utils/getMotionStyles.d.cts +1 -1
- package/dist/tailwind/utils/getMotionStyles.d.ts +1 -1
- package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts.map +1 -1
- package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts.map +1 -1
- package/dist/tokens/types.d.cts.map +1 -1
- package/dist/tokens/types.d.ts.map +1 -1
- package/dist/utils/intersperse.d.cts +2 -2
- package/dist/utils/intersperse.d.ts +2 -2
- package/package.json +1 -3
- package/cli/FlattenButtonVariant.mock.tsx +0 -17
- package/src/components/Box.tsx +0 -181
- package/src/components/Divider/Divider.tsx +0 -44
- package/src/components/Divider/DividerCore.tsx +0 -101
- package/src/components/Divider/DividerInternal.tsx +0 -56
- package/src/components/Divider/index.ts +0 -1
- package/src/components/FormLabel.tsx +0 -66
- package/src/components/HStack.tsx +0 -53
- package/src/components/Icon.tsx +0 -82
- package/src/components/IconSlot.tsx +0 -82
- package/src/components/Image.tsx +0 -162
- package/src/components/Link.tsx +0 -134
- package/src/components/Text.tsx +0 -272
- package/src/components/VStack.tsx +0 -53
- package/src/components/client/AnimateHeightChange.tsx +0 -50
- package/src/components/client/Avatar/Avatar.tsx +0 -31
- package/src/components/client/Avatar/AvatarIcon.tsx +0 -103
- package/src/components/client/Avatar/AvatarImage.tsx +0 -147
- package/src/components/client/Avatar/AvatarText.tsx +0 -88
- package/src/components/client/Avatar/index.ts +0 -4
- package/src/components/client/Avatar/utils.ts +0 -105
- package/src/components/client/Badge.tsx +0 -133
- package/src/components/client/Button.tsx +0 -312
- package/src/components/client/Checkbox.tsx +0 -377
- package/src/components/client/Chip/Chip.tsx +0 -81
- package/src/components/client/Chip/ChipBase.tsx +0 -151
- package/src/components/client/Chip/ChipButton.tsx +0 -54
- package/src/components/client/Chip/ChipDismissible.tsx +0 -90
- package/src/components/client/Chip/ChipLink.tsx +0 -60
- package/src/components/client/Chip/ChipToggle.tsx +0 -79
- package/src/components/client/Chip/index.ts +0 -5
- package/src/components/client/IconButton.tsx +0 -198
- package/src/components/client/Input/Input.tsx +0 -323
- package/src/components/client/Input/InputHelpText.tsx +0 -52
- package/src/components/client/Input/InputHelpTextInternal.tsx +0 -81
- package/src/components/client/Input/index.ts +0 -2
- package/src/components/client/Menu/Menu.Content.tsx +0 -391
- package/src/components/client/Menu/Menu.Divider.tsx +0 -102
- package/src/components/client/Menu/Menu.Item.tsx +0 -114
- package/src/components/client/Menu/Menu.ItemBase.tsx +0 -265
- package/src/components/client/Menu/Menu.ItemCheckbox.tsx +0 -197
- package/src/components/client/Menu/Menu.Provider.tsx +0 -154
- package/src/components/client/Menu/Menu.Trigger.tsx +0 -119
- package/src/components/client/Menu/Menu.index.tsx +0 -9
- package/src/components/client/Menu/Menu.tsx +0 -2
- package/src/components/client/Menu/index.ts +0 -7
- package/src/components/client/Menu/utils/transformAriakitPlacement.ts +0 -66
- package/src/components/client/Pressable.tsx +0 -194
- package/src/components/client/Radio/Radio.tsx +0 -351
- package/src/components/client/Radio/RadioGroupProvider.tsx +0 -122
- package/src/components/client/Radio/RadioGroupStore.tsx +0 -56
- package/src/components/client/Radio/index.ts +0 -2
- package/src/components/client/Radio/useRadioGroup.ts +0 -149
- package/src/components/client/SpringMotionConfig.tsx +0 -151
- package/src/components/client/Switch.tsx +0 -377
- package/src/components/client/index.ts +0 -30
- package/src/components/client/motionFeatures/domAnimation.ts +0 -2
- package/src/components/client/motionFeatures/domMax.ts +0 -2
- package/src/components/experimental/Spinner.tsx +0 -30
- package/src/components/experimental/Table.mocks.tsx +0 -38
- package/src/components/experimental/Table.tsx +0 -239
- package/src/components/experimental/client/Accordion.tsx +0 -77
- package/src/components/experimental/client/AvoidMotionLibraryProvider.tsx +0 -10
- package/src/components/experimental/client/Modal.tsx +0 -68
- package/src/components/experimental/client/Popover.tsx +0 -63
- package/src/components/experimental/client/SwitchV2.tsx +0 -343
- package/src/components/experimental/client/Tabs.tsx +0 -106
- package/src/components/experimental/client/Toast.tsx +0 -186
- package/src/components/experimental/client/index.ts +0 -15
- package/src/components/experimental/index.ts +0 -48
- package/src/components/index.ts +0 -41
- package/src/defaultTokensConfig.ts +0 -31
- package/src/fixtures/index.ts +0 -638
- package/src/fixtures/macros/typesToConstants.ts +0 -42
- package/src/fixtures/utils/getScaleModeRamp.ts +0 -48
- package/src/fixtures/utils/getTailwindAsUdsColors.ts +0 -115
- package/src/flags.ts +0 -45
- package/src/hooks/useForkRef.ts +0 -34
- package/src/hooks/useNestedBorderRadius.ts +0 -138
- package/src/hooks/useRtl.ts +0 -64
- package/src/index.ts +0 -4
- package/src/providers/ColorModeProvider.tsx +0 -21
- package/src/providers/ScaleModeProvider.tsx +0 -29
- package/src/providers/ThemeProvider.tsx +0 -26
- package/src/styles/styler.ts +0 -194
- package/src/styles/stylerTypes.ts +0 -81
- package/src/styles/toast.css +0 -0
- package/src/styles/variants.ts +0 -1351
- package/src/tailwind/base/addColorModeVars.ts +0 -23
- package/src/tailwind/base/addColorModeVarsV2.ts +0 -57
- package/src/tailwind/base/addFontFaceDeclarations.ts +0 -13
- package/src/tailwind/base/addFontVars.ts +0 -9
- package/src/tailwind/base/addMotionVars.ts +0 -9
- package/src/tailwind/base/addScaleModeVars.ts +0 -33
- package/src/tailwind/base/types.ts +0 -8
- package/src/tailwind/components/getButtonStyles.ts +0 -240
- package/src/tailwind/components/getFocusRingStyles.ts +0 -32
- package/src/tailwind/components/getGroupedTextStyles.ts +0 -29
- package/src/tailwind/components/getHitTargetStyles.ts +0 -23
- package/src/tailwind/components/getIconButtonStyles.ts +0 -49
- package/src/tailwind/components/getIconStyles.ts +0 -13
- package/src/tailwind/components/getInputStyles.ts +0 -20
- package/src/tailwind/components/getResponsiveTextStyles.ts +0 -161
- package/src/tailwind/components/types.ts +0 -14
- package/src/tailwind/components/utils.ts +0 -73
- package/src/tailwind/defaultTailwindThemeAsUdsConfig.ts +0 -78
- package/src/tailwind/postcss.config.ts +0 -6
- package/src/tailwind/purger/index.ts +0 -1
- package/src/tailwind/tailwind.config.ts +0 -50
- package/src/tailwind/tailwind.d.ts +0 -5
- package/src/tailwind/tailwindPlugin.ts +0 -724
- package/src/tailwind/theme/getFontFamilyTheme.ts +0 -28
- package/src/tailwind/tsMorph.ts +0 -1
- package/src/tailwind/uds.css +0 -3
- package/src/tailwind/utils/addFontsPlugin.ts +0 -17
- package/src/tailwind/utils/getColorModeStyles.ts +0 -21
- package/src/tailwind/utils/getFontFaceDeclarations.ts +0 -12
- package/src/tailwind/utils/getFontStyles.ts +0 -38
- package/src/tailwind/utils/getMotionStyles.ts +0 -35
- package/src/tailwind/utils/getScaleModeStyles.ts +0 -23
- package/src/tailwind/utils/getShadowPresetValues.ts +0 -133
- package/src/tailwind/utils/getShadowStyles.ts +0 -26
- package/src/tailwind/utils/getShadowVars.ts +0 -40
- package/src/tailwind/utils/index.ts +0 -9
- package/src/tokens/automation/configs/avatar.ts +0 -297
- package/src/tokens/automation/configs/badge.ts +0 -306
- package/src/tokens/automation/configs/checkbox.ts +0 -226
- package/src/tokens/automation/configs/chip.ts +0 -521
- package/src/tokens/automation/configs/divider.ts +0 -112
- package/src/tokens/automation/configs/index.ts +0 -10
- package/src/tokens/automation/configs/input.ts +0 -496
- package/src/tokens/automation/configs/link.ts +0 -183
- package/src/tokens/automation/configs/menu.ts +0 -344
- package/src/tokens/automation/configs/radio.ts +0 -225
- package/src/tokens/automation/configs/switch.ts +0 -323
- package/src/tokens/automation/index.ts +0 -5
- package/src/tokens/automation/mapTextVariantFixtureToValue.ts +0 -8
- package/src/tokens/automation/properties.ts +0 -433
- package/src/tokens/automation/types/ComponentConfig.ts +0 -116
- package/src/tokens/automation/types/ComponentDB.ts +0 -1
- package/src/tokens/automation/types/ComponentStyles.ts +0 -47
- package/src/tokens/automation/types/index.ts +0 -2
- package/src/tokens/automation/utils/cartesianProduct.ts +0 -13
- package/src/tokens/automation/utils/coalesceConfigVariant.ts +0 -49
- package/src/tokens/automation/utils/defaults.ts +0 -29
- package/src/tokens/automation/utils/generateKeyFromFlatConfigPath.ts +0 -15
- package/src/tokens/automation/utils/generateSchemaKey.ts +0 -29
- package/src/tokens/automation/utils/getConfigComponentVariant.ts +0 -28
- package/src/tokens/automation/utils/getConfigVariantComponentStatesMatrix.ts +0 -40
- package/src/tokens/automation/utils/getConfigVariantProperties.ts +0 -32
- package/src/tokens/automation/utils/getConfigVariantPseudoStates.ts +0 -70
- package/src/tokens/automation/utils/getConfigVariants.ts +0 -73
- package/src/tokens/automation/utils/index.ts +0 -939
- package/src/tokens/automation/utils/mapColorFixtureToValue.ts +0 -34
- package/src/tokens/automation/utils/subcomponents.ts +0 -13
- package/src/tokens/automation/utils/variableData.ts +0 -79
- package/src/tokens/automation/utils/variantConfigGuards.ts +0 -17
- package/src/tokens/configs/borderRadius.ts +0 -23
- package/src/tokens/configs/borderWidth.ts +0 -17
- package/src/tokens/configs/button.ts +0 -888
- package/src/tokens/configs/colorMode.ts +0 -14
- package/src/tokens/configs/font.ts +0 -9
- package/src/tokens/configs/iconButton.ts +0 -28
- package/src/tokens/configs/motion.ts +0 -135
- package/src/tokens/configs/palette.ts +0 -124
- package/src/tokens/configs/scaleMode.ts +0 -28
- package/src/tokens/configs/shadow.ts +0 -286
- package/src/tokens/configs/sizes.ts +0 -23
- package/src/tokens/configs/spectrum.ts +0 -729
- package/src/tokens/configs/typography.ts +0 -417
- package/src/tokens/configs/yosConfig.ts +0 -7651
- package/src/tokens/consts/buttonMotionTokens.ts +0 -99
- package/src/tokens/consts/cssTokens.ts +0 -110
- package/src/tokens/consts/defaultModes.ts +0 -15
- package/src/tokens/consts/fontDeclarationsMap.ts +0 -509
- package/src/tokens/index.ts +0 -15
- package/src/tokens/parseButtonVariants.ts +0 -59
- package/src/tokens/parseTokens.ts +0 -122
- package/src/tokens/types.ts +0 -1882
- package/src/tokens/utils/entries.ts +0 -14
- package/src/tokens/utils/fromEntries.ts +0 -11
- package/src/tokens/utils/mapValues.ts +0 -15
- package/src/types.ts +0 -2
- package/src/utils/assertUnreachable.ts +0 -6
- package/src/utils/composeRefs.ts +0 -23
- package/src/utils/createSlot.tsx +0 -131
- package/src/utils/entries.ts +0 -6
- package/src/utils/falsyToString.ts +0 -3
- package/src/utils/getMotionVar.ts +0 -18
- package/src/utils/intersperse.ts +0 -45
- package/src/utils/mapValues.ts +0 -15
- package/src/utils/mergeSlotProps.ts +0 -70
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Building, Person } from '@yahoo/uds-icons';
|
|
2
|
-
import type { SvgIcon } from '@yahoo/uds-icons/types';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
6
|
-
import type {
|
|
7
|
-
AvatarVariant,
|
|
8
|
-
IconPropsWithSVGProps,
|
|
9
|
-
UniversalAvatarIconProps,
|
|
10
|
-
} from '../../../tokens';
|
|
11
|
-
import { Box } from '../../Box';
|
|
12
|
-
import { IconSlot } from '../../IconSlot';
|
|
13
|
-
import {
|
|
14
|
-
buildAvatarRootClasses,
|
|
15
|
-
buildInlineSizeStyles,
|
|
16
|
-
DEFAULT_AVATAR_SIZE,
|
|
17
|
-
DEFAULT_AVATAR_VARIANT,
|
|
18
|
-
} from './utils';
|
|
19
|
-
|
|
20
|
-
/** Maps avatar variant to icon */
|
|
21
|
-
// TODO: This should be configurable in the future
|
|
22
|
-
const mapVariantToIcon: Record<AvatarVariant, SvgIcon> = {
|
|
23
|
-
primary: Person,
|
|
24
|
-
secondary: Building,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Required because of: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69864
|
|
28
|
-
type DataAttributes = {
|
|
29
|
-
[name: `data-${string}`]: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
interface AvatarIconProps extends UniversalAvatarIconProps {
|
|
33
|
-
/** Props to be passed into various slots within the component. */
|
|
34
|
-
slotProps?: {
|
|
35
|
-
icon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* **AvatarIcon Component**
|
|
41
|
-
*
|
|
42
|
-
* Renders an Avatar with an icon representation.
|
|
43
|
-
*
|
|
44
|
-
* @param props - Props for icon variant.
|
|
45
|
-
* @returns The AvatarIcon element.
|
|
46
|
-
*/
|
|
47
|
-
const AvatarIcon = ({
|
|
48
|
-
size = DEFAULT_AVATAR_SIZE,
|
|
49
|
-
variant = DEFAULT_AVATAR_VARIANT,
|
|
50
|
-
customSize,
|
|
51
|
-
icon,
|
|
52
|
-
slotProps,
|
|
53
|
-
className,
|
|
54
|
-
...props
|
|
55
|
-
}: AvatarIconProps) => {
|
|
56
|
-
const classNames = useMemo(
|
|
57
|
-
() => ({
|
|
58
|
-
root: buildAvatarRootClasses(size, {
|
|
59
|
-
avatarIconVariantRoot: variant,
|
|
60
|
-
overflow: 'hidden',
|
|
61
|
-
className: cx('overflow-hidden', className),
|
|
62
|
-
}),
|
|
63
|
-
|
|
64
|
-
iconContainer: cx(
|
|
65
|
-
'w-full',
|
|
66
|
-
'h-full',
|
|
67
|
-
'shrink-0',
|
|
68
|
-
'overflow-hidden',
|
|
69
|
-
'text-center',
|
|
70
|
-
'inline-flex',
|
|
71
|
-
'justify-center',
|
|
72
|
-
'items-center',
|
|
73
|
-
),
|
|
74
|
-
|
|
75
|
-
icon: getStyles({ avatarSizeIcon: size }),
|
|
76
|
-
}),
|
|
77
|
-
[className, size, variant],
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const inlineStyles = useMemo(() => buildInlineSizeStyles(customSize), [customSize]);
|
|
81
|
-
|
|
82
|
-
const iconSvg = icon ?? mapVariantToIcon[variant ?? 'primary'];
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Box className={classNames.root} style={inlineStyles.root} {...props}>
|
|
86
|
-
<Box className={classNames.iconContainer} style={inlineStyles.contents}>
|
|
87
|
-
<IconSlot
|
|
88
|
-
icon={iconSvg}
|
|
89
|
-
iconProps={{
|
|
90
|
-
variant: 'fill',
|
|
91
|
-
color: 'current',
|
|
92
|
-
...slotProps?.icon,
|
|
93
|
-
}}
|
|
94
|
-
className={classNames.icon}
|
|
95
|
-
/>
|
|
96
|
-
</Box>
|
|
97
|
-
</Box>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
AvatarIcon.displayName = 'AvatarIcon';
|
|
102
|
-
|
|
103
|
-
export { AvatarIcon, type AvatarIconProps };
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cx } from '../../../styles/styler';
|
|
4
|
-
import type { ImagePropsWithImgProps, UniversalAvatarImageProps } from '../../../tokens';
|
|
5
|
-
import { Box } from '../../Box';
|
|
6
|
-
import { Image as UDSImage } from '../../Image';
|
|
7
|
-
import type { AvatarIconProps } from './AvatarIcon';
|
|
8
|
-
import { AvatarIcon } from './AvatarIcon';
|
|
9
|
-
import type { AvatarTextProps } from './AvatarText';
|
|
10
|
-
import { AvatarText } from './AvatarText';
|
|
11
|
-
import {
|
|
12
|
-
buildAvatarRootClasses,
|
|
13
|
-
buildInlineSizeStyles,
|
|
14
|
-
DEFAULT_AVATAR_SIZE,
|
|
15
|
-
DEFAULT_AVATAR_VARIANT,
|
|
16
|
-
} from './utils';
|
|
17
|
-
|
|
18
|
-
// Required because of: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69864
|
|
19
|
-
type DataAttributes = {
|
|
20
|
-
[name: `data-${string}`]: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
interface AvatarImageProps extends UniversalAvatarImageProps {
|
|
24
|
-
/** Props to be passed into various slots within the component. */
|
|
25
|
-
slotProps?: {
|
|
26
|
-
image?: Partial<
|
|
27
|
-
Omit<ImagePropsWithImgProps, 'src' | 'srcSet' | 'alt' | 'className' | 'height' | 'width'> &
|
|
28
|
-
DataAttributes
|
|
29
|
-
>;
|
|
30
|
-
} & AvatarIconProps['slotProps'] &
|
|
31
|
-
AvatarTextProps['slotProps'];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* **AvatarImage Component**
|
|
36
|
-
*
|
|
37
|
-
* Renders an Avatar with an image. If the image fails to load, it falls back first to
|
|
38
|
-
* a text representation (if a name or initials are provided) and then to an icon.
|
|
39
|
-
*
|
|
40
|
-
* @param props - Props for image variant.
|
|
41
|
-
* @returns The AvatarImage element.
|
|
42
|
-
*/
|
|
43
|
-
const AvatarImage = ({
|
|
44
|
-
size = DEFAULT_AVATAR_SIZE,
|
|
45
|
-
variant = DEFAULT_AVATAR_VARIANT,
|
|
46
|
-
src,
|
|
47
|
-
srcSet,
|
|
48
|
-
customSize,
|
|
49
|
-
alt,
|
|
50
|
-
abbreviationStrategy,
|
|
51
|
-
fallback,
|
|
52
|
-
className,
|
|
53
|
-
imageProps,
|
|
54
|
-
slotProps,
|
|
55
|
-
...props
|
|
56
|
-
}: AvatarImageProps) => {
|
|
57
|
-
const [loadingState, setLoadingState] = useState<'loading' | 'loaded' | 'error'>('loading');
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
let mounted = true;
|
|
61
|
-
if (src || srcSet) {
|
|
62
|
-
const img = new Image();
|
|
63
|
-
img.onload = () => {
|
|
64
|
-
if (mounted) {
|
|
65
|
-
setLoadingState('loaded');
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
img.onerror = () => {
|
|
69
|
-
if (mounted) {
|
|
70
|
-
setLoadingState('error');
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
if (src) {
|
|
74
|
-
img.src = src;
|
|
75
|
-
}
|
|
76
|
-
if (srcSet) {
|
|
77
|
-
img.srcset = srcSet;
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
setLoadingState('error');
|
|
81
|
-
}
|
|
82
|
-
return () => {
|
|
83
|
-
mounted = false;
|
|
84
|
-
};
|
|
85
|
-
}, [src, srcSet]);
|
|
86
|
-
|
|
87
|
-
const classNames = useMemo(
|
|
88
|
-
() => ({
|
|
89
|
-
root: buildAvatarRootClasses(size, {
|
|
90
|
-
avatarImageVariantRoot: variant,
|
|
91
|
-
className: cx('overflow-hidden', className),
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
contents: cx(
|
|
95
|
-
'w-full',
|
|
96
|
-
'h-full',
|
|
97
|
-
'shrink-0',
|
|
98
|
-
'text-center',
|
|
99
|
-
'inline-flex',
|
|
100
|
-
'justify-center',
|
|
101
|
-
'items-center',
|
|
102
|
-
'object-cover',
|
|
103
|
-
),
|
|
104
|
-
}),
|
|
105
|
-
[className, size, variant],
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const inlineStyles = useMemo(() => buildInlineSizeStyles(customSize), [customSize]);
|
|
109
|
-
|
|
110
|
-
if (loadingState === 'loaded') {
|
|
111
|
-
return (
|
|
112
|
-
<Box className={classNames.root} style={inlineStyles.root}>
|
|
113
|
-
<UDSImage
|
|
114
|
-
src={src}
|
|
115
|
-
srcSet={srcSet}
|
|
116
|
-
alt={alt}
|
|
117
|
-
className={classNames.contents}
|
|
118
|
-
style={inlineStyles.contents}
|
|
119
|
-
{...imageProps} // Deprecated
|
|
120
|
-
{...slotProps?.image}
|
|
121
|
-
/>
|
|
122
|
-
</Box>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const sharedProps = { ...props, size, customSize, variant };
|
|
127
|
-
|
|
128
|
-
// On image error, try to render text avatar
|
|
129
|
-
if (fallback || alt) {
|
|
130
|
-
return (
|
|
131
|
-
<AvatarText
|
|
132
|
-
name={alt}
|
|
133
|
-
initials={fallback}
|
|
134
|
-
abbreviationStrategy={abbreviationStrategy}
|
|
135
|
-
slotProps={{ text: slotProps?.text }}
|
|
136
|
-
{...sharedProps}
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// If no text data is available, render icon
|
|
142
|
-
return <AvatarIcon {...sharedProps} slotProps={{ icon: slotProps?.icon }} />;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
AvatarImage.displayName = 'AvatarImage';
|
|
146
|
-
|
|
147
|
-
export { AvatarImage, type AvatarImageProps };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cx } from '../../../styles/styler';
|
|
4
|
-
import type { UniversalAvatarTextProps } from '../../../tokens';
|
|
5
|
-
import { Box } from '../../Box';
|
|
6
|
-
import type { TextProps } from '../../Text';
|
|
7
|
-
import { Text } from '../../Text';
|
|
8
|
-
import {
|
|
9
|
-
buildAvatarRootClasses,
|
|
10
|
-
buildInlineSizeStyles,
|
|
11
|
-
DEFAULT_AVATAR_SIZE,
|
|
12
|
-
DEFAULT_AVATAR_VARIANT,
|
|
13
|
-
generateAvatarAbbreviation,
|
|
14
|
-
} from './utils';
|
|
15
|
-
|
|
16
|
-
// Required because of: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69864
|
|
17
|
-
type DataAttributes = {
|
|
18
|
-
[name: `data-${string}`]: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
interface AvatarTextProps extends UniversalAvatarTextProps {
|
|
22
|
-
/** Props to be passed into various slots within the component. */
|
|
23
|
-
slotProps?: {
|
|
24
|
-
text?: Partial<TextProps & DataAttributes>;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* **AvatarText Component**
|
|
30
|
-
*
|
|
31
|
-
* Renders an Avatar with text (initials) representation.
|
|
32
|
-
*
|
|
33
|
-
* @param props - Props for text variant.
|
|
34
|
-
* @returns The AvatarText element.
|
|
35
|
-
*/
|
|
36
|
-
const AvatarText = ({
|
|
37
|
-
size = DEFAULT_AVATAR_SIZE,
|
|
38
|
-
variant = DEFAULT_AVATAR_VARIANT,
|
|
39
|
-
name,
|
|
40
|
-
initials,
|
|
41
|
-
customSize,
|
|
42
|
-
abbreviationStrategy,
|
|
43
|
-
className,
|
|
44
|
-
slotProps,
|
|
45
|
-
...props
|
|
46
|
-
}: AvatarTextProps) => {
|
|
47
|
-
const classNames = useMemo(
|
|
48
|
-
() => ({
|
|
49
|
-
root: buildAvatarRootClasses(size, {
|
|
50
|
-
avatarTextVariantRoot: variant,
|
|
51
|
-
className: cx('overflow-hidden', 'truncate', className),
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
text: cx(
|
|
55
|
-
'w-full',
|
|
56
|
-
'h-full',
|
|
57
|
-
'shrink-0',
|
|
58
|
-
'overflow-hidden',
|
|
59
|
-
'text-center',
|
|
60
|
-
'inline-flex',
|
|
61
|
-
'justify-center',
|
|
62
|
-
'items-center',
|
|
63
|
-
'truncate',
|
|
64
|
-
),
|
|
65
|
-
}),
|
|
66
|
-
[className, size, variant],
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const inlineStyles = useMemo(() => buildInlineSizeStyles(customSize), [customSize]);
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<Box className={classNames.root} style={inlineStyles.root} {...props}>
|
|
73
|
-
<Text
|
|
74
|
-
color="inherit"
|
|
75
|
-
variant="inherit"
|
|
76
|
-
className={classNames.text}
|
|
77
|
-
style={inlineStyles.contents}
|
|
78
|
-
{...slotProps?.text}
|
|
79
|
-
>
|
|
80
|
-
{initials || generateAvatarAbbreviation(name, abbreviationStrategy)}
|
|
81
|
-
</Text>
|
|
82
|
-
</Box>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
AvatarText.displayName = 'AvatarText';
|
|
87
|
-
|
|
88
|
-
export { AvatarText, type AvatarTextProps };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { isFunction } from 'lodash';
|
|
2
|
-
import type { CSSProperties } from 'react';
|
|
3
|
-
|
|
4
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
5
|
-
import type {
|
|
6
|
-
AvatarAbbreviationStrategy,
|
|
7
|
-
AvatarSize,
|
|
8
|
-
AvatarVariant,
|
|
9
|
-
UniversalAvatarProps,
|
|
10
|
-
} from '../../../tokens';
|
|
11
|
-
|
|
12
|
-
/** Strategies for generating text abbreviation */
|
|
13
|
-
const abbrevStrategies: Record<
|
|
14
|
-
Extract<AvatarAbbreviationStrategy, string>,
|
|
15
|
-
(initials: string[]) => string
|
|
16
|
-
> = {
|
|
17
|
-
first: (initials) => initials[0] ?? '',
|
|
18
|
-
last: (initials) => initials[initials.length - 1] ?? '',
|
|
19
|
-
firstAndLast: (initials) =>
|
|
20
|
-
initials.length === 1 ? initials[0] : `${initials[0]}${initials[initials.length - 1]}`,
|
|
21
|
-
firstTwo: (initials) => initials.slice(0, 2).join(''),
|
|
22
|
-
firstThree: (initials) => initials.slice(0, 3).join(''),
|
|
23
|
-
firstOfEach: (initials) => initials.join(''),
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/* -------------------------------------------------------------------------- */
|
|
27
|
-
/* Helper Functions */
|
|
28
|
-
/* -------------------------------------------------------------------------- */
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generates an abbreviation from a name using a specified strategy.
|
|
32
|
-
*
|
|
33
|
-
* @param name - The full name.
|
|
34
|
-
* @param strategy - Abbreviation strategy key or custom function.
|
|
35
|
-
* @returns The generated abbreviation.
|
|
36
|
-
*/
|
|
37
|
-
const generateAvatarAbbreviation = (
|
|
38
|
-
name?: string,
|
|
39
|
-
strategy: AvatarAbbreviationStrategy = 'firstAndLast',
|
|
40
|
-
): string => {
|
|
41
|
-
if (!name) {
|
|
42
|
-
return '';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isFunction(strategy)) {
|
|
46
|
-
return strategy(name);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const words = name.trim().split(/\s+/);
|
|
50
|
-
const initials = words.map((word) => word[0].toUpperCase());
|
|
51
|
-
|
|
52
|
-
return abbrevStrategies[strategy](initials);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Builds the root CSS classes for the Avatar.
|
|
57
|
-
*
|
|
58
|
-
* @param size - The size of the Avatar.
|
|
59
|
-
* @returns A string of CSS classes.
|
|
60
|
-
*/
|
|
61
|
-
const buildAvatarRootClasses = (
|
|
62
|
-
size: UniversalAvatarProps['size'] = 'md',
|
|
63
|
-
styles?: Parameters<typeof getStyles>[0],
|
|
64
|
-
): string => {
|
|
65
|
-
const { className: stylesClassName, ...restStyles } = styles ?? {};
|
|
66
|
-
|
|
67
|
-
return getStyles({
|
|
68
|
-
avatarSizeRoot: size,
|
|
69
|
-
...restStyles,
|
|
70
|
-
className: cx(
|
|
71
|
-
'shrink-0',
|
|
72
|
-
'text-center',
|
|
73
|
-
'inline-flex',
|
|
74
|
-
'justify-center',
|
|
75
|
-
'items-center',
|
|
76
|
-
'overflow-visible',
|
|
77
|
-
'truncate',
|
|
78
|
-
stylesClassName,
|
|
79
|
-
),
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const buildInlineSizeStyles = (customSize?: UniversalAvatarProps['customSize']) => {
|
|
84
|
-
const rootStyles = customSize ? { height: customSize, width: customSize } : {};
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
root: rootStyles,
|
|
88
|
-
|
|
89
|
-
contents: {
|
|
90
|
-
...rootStyles,
|
|
91
|
-
boxSizing: 'content-box',
|
|
92
|
-
} satisfies CSSProperties,
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const DEFAULT_AVATAR_VARIANT: AvatarVariant = 'primary';
|
|
97
|
-
const DEFAULT_AVATAR_SIZE: AvatarSize = 'md';
|
|
98
|
-
|
|
99
|
-
export {
|
|
100
|
-
buildAvatarRootClasses,
|
|
101
|
-
buildInlineSizeStyles,
|
|
102
|
-
DEFAULT_AVATAR_SIZE,
|
|
103
|
-
DEFAULT_AVATAR_VARIANT,
|
|
104
|
-
generateAvatarAbbreviation,
|
|
105
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cx, getStyles } from '../../styles/styler';
|
|
4
|
-
import type { BadgeConfig, BaseSelector, UniversalBadgeProps } from '../../tokens';
|
|
5
|
-
import { HStack } from '../HStack';
|
|
6
|
-
import type { IconSlotProps } from '../IconSlot';
|
|
7
|
-
import { IconSlot } from '../IconSlot';
|
|
8
|
-
|
|
9
|
-
// TODO: we might not need these base classes with the new system
|
|
10
|
-
const BASE_CLASS: BaseSelector<typeof BadgeConfig> = 'uds-badge';
|
|
11
|
-
const VARIANT_BASE_CLASS = 'uds-badge-variant';
|
|
12
|
-
const SIZE_BASE_CLASS = 'uds-badge-size';
|
|
13
|
-
const ICON_SIZE_BASE_CLASS = 'uds-badge-iconSize';
|
|
14
|
-
const ICON_COLOR_BASE_CLASS = 'uds-badge-iconColor';
|
|
15
|
-
|
|
16
|
-
type HtmlDivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
17
|
-
|
|
18
|
-
interface BadgeProps extends HtmlDivProps, UniversalBadgeProps {}
|
|
19
|
-
|
|
20
|
-
const MAX_WIDTH_DEFAULT = 200;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* **⚙️️ A badge.
|
|
24
|
-
*
|
|
25
|
-
* @componentType Client component
|
|
26
|
-
*
|
|
27
|
-
* @description
|
|
28
|
-
* Badges show notifications, counts, or status information on navigation items and icons.
|
|
29
|
-
*
|
|
30
|
-
* @see
|
|
31
|
-
* Check out the {@link https://uds.build/docs/components/badge Badge Docs} for more info
|
|
32
|
-
*
|
|
33
|
-
* @usage
|
|
34
|
-
* - ???
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* 'use client';
|
|
39
|
-
* import { Badge } from "@yahoo/uds";
|
|
40
|
-
*
|
|
41
|
-
* <Badge>Label</Badge>
|
|
42
|
-
*```
|
|
43
|
-
*
|
|
44
|
-
* @related [Chip](https://uds.build/docs/components/chip).
|
|
45
|
-
**/
|
|
46
|
-
const Badge = forwardRef<HTMLDivElement, BadgeProps>(function Badge(
|
|
47
|
-
{
|
|
48
|
-
variant = 'primary',
|
|
49
|
-
size = 'md',
|
|
50
|
-
minWidth,
|
|
51
|
-
maxWidth = MAX_WIDTH_DEFAULT,
|
|
52
|
-
startIcon,
|
|
53
|
-
endIcon,
|
|
54
|
-
backgroundColor,
|
|
55
|
-
color,
|
|
56
|
-
iconColor,
|
|
57
|
-
borderColor,
|
|
58
|
-
children,
|
|
59
|
-
className,
|
|
60
|
-
...rest
|
|
61
|
-
}: BadgeProps,
|
|
62
|
-
ref,
|
|
63
|
-
) {
|
|
64
|
-
const rootStyles = getStyles({
|
|
65
|
-
badgeSizeRoot: size,
|
|
66
|
-
badgeVariantRoot: variant,
|
|
67
|
-
className: cx([BASE_CLASS, VARIANT_BASE_CLASS, SIZE_BASE_CLASS, className]),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const iconStyles = getStyles({
|
|
71
|
-
badgeVariantIcon: variant,
|
|
72
|
-
badgeSizeIcon: size,
|
|
73
|
-
className: cx([ICON_SIZE_BASE_CLASS, ICON_COLOR_BASE_CLASS]),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const containerStyles = useMemo(
|
|
77
|
-
() => ({
|
|
78
|
-
...(minWidth ? { minWidth: `${minWidth}px` } : {}),
|
|
79
|
-
...(maxWidth === 'full' ? {} : { maxWidth: `${maxWidth}px` }),
|
|
80
|
-
...(backgroundColor ? { backgroundColor } : {}),
|
|
81
|
-
...(borderColor ? { borderColor } : {}),
|
|
82
|
-
...(color ? { color } : {}),
|
|
83
|
-
}),
|
|
84
|
-
[backgroundColor, borderColor, color, maxWidth, minWidth],
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const iconProps = useMemo(
|
|
88
|
-
(): IconSlotProps['iconProps'] => ({
|
|
89
|
-
variant: 'fill',
|
|
90
|
-
style: {
|
|
91
|
-
...(iconColor ? { color: iconColor } : {}),
|
|
92
|
-
},
|
|
93
|
-
}),
|
|
94
|
-
[iconColor],
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<HStack
|
|
99
|
-
ref={ref}
|
|
100
|
-
gap="2"
|
|
101
|
-
display="inline-flex"
|
|
102
|
-
alignItems="center"
|
|
103
|
-
className={rootStyles}
|
|
104
|
-
style={containerStyles}
|
|
105
|
-
{...rest}
|
|
106
|
-
>
|
|
107
|
-
{startIcon && (
|
|
108
|
-
<IconSlot
|
|
109
|
-
icon={startIcon}
|
|
110
|
-
iconProps={iconProps}
|
|
111
|
-
data-testid="start-icon"
|
|
112
|
-
className={iconStyles}
|
|
113
|
-
/>
|
|
114
|
-
)}
|
|
115
|
-
|
|
116
|
-
<span className="flex-1 truncate whitespace-nowrap text-center">{children}</span>
|
|
117
|
-
|
|
118
|
-
{endIcon && (
|
|
119
|
-
<IconSlot
|
|
120
|
-
icon={endIcon}
|
|
121
|
-
iconProps={iconProps}
|
|
122
|
-
data-testid="end-icon"
|
|
123
|
-
className={iconStyles}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
</HStack>
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
131
|
-
Badge.displayName = 'Badge';
|
|
132
|
-
|
|
133
|
-
export { Badge, type BadgeProps };
|