@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
package/src/components/Box.tsx
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import type { UniversalBoxProps } from '@yahoo/uds/tokens';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
|
|
4
|
-
import { getStyles } from '../styles/styler';
|
|
5
|
-
import { createSlot } from '../utils/createSlot';
|
|
6
|
-
|
|
7
|
-
const Slot = createSlot<React.ComponentType<DivProps>>();
|
|
8
|
-
|
|
9
|
-
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
10
|
-
|
|
11
|
-
interface BoxProps extends UniversalBoxProps, DivProps {}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* **📦 A layout component that can be used to compose other components**
|
|
15
|
-
*
|
|
16
|
-
* @description
|
|
17
|
-
* The most simple component we ship - a div. But with all the power of the UDS design system.
|
|
18
|
-
* By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,
|
|
19
|
-
* consider using [VStack](./v-stack) or [HStack](./h-stack) respectively.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* import { Box } from '@yahoo/uds';
|
|
24
|
-
*
|
|
25
|
-
* <Box backgroundColor="primary" spacing="6">
|
|
26
|
-
* Any kind of content can go here!
|
|
27
|
-
* </Box>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @usage
|
|
31
|
-
* - If you need to div-like container to apply padding, shapes, or other styling.
|
|
32
|
-
* - If you're creating card components.
|
|
33
|
-
*
|
|
34
|
-
* @see The {@link https://uds.build/docs/components/box Box Docs} for more info
|
|
35
|
-
*
|
|
36
|
-
* @related [HStack](https://uds.build/docs/components/h-stack), [VStack](https://uds.build/docs/components/v-stack)
|
|
37
|
-
*/
|
|
38
|
-
const Box = forwardRef<HTMLDivElement, BoxProps>(function Box(
|
|
39
|
-
{
|
|
40
|
-
asChild,
|
|
41
|
-
as: As = 'div',
|
|
42
|
-
className,
|
|
43
|
-
// background
|
|
44
|
-
backgroundColor,
|
|
45
|
-
// border
|
|
46
|
-
borderRadius,
|
|
47
|
-
borderTopStartRadius,
|
|
48
|
-
borderTopEndRadius,
|
|
49
|
-
borderBottomStartRadius,
|
|
50
|
-
borderBottomEndRadius,
|
|
51
|
-
borderColor,
|
|
52
|
-
borderStartColor,
|
|
53
|
-
borderEndColor,
|
|
54
|
-
borderTopColor,
|
|
55
|
-
borderBottomColor,
|
|
56
|
-
borderWidth,
|
|
57
|
-
borderVerticalWidth,
|
|
58
|
-
borderHorizontalWidth,
|
|
59
|
-
borderStartWidth,
|
|
60
|
-
borderEndWidth,
|
|
61
|
-
borderTopWidth,
|
|
62
|
-
borderBottomWidth,
|
|
63
|
-
// flex
|
|
64
|
-
alignContent,
|
|
65
|
-
alignItems,
|
|
66
|
-
alignSelf,
|
|
67
|
-
flex,
|
|
68
|
-
flexDirection,
|
|
69
|
-
flexGrow,
|
|
70
|
-
flexShrink,
|
|
71
|
-
flexWrap,
|
|
72
|
-
justifyContent,
|
|
73
|
-
flexBasis,
|
|
74
|
-
// layout
|
|
75
|
-
display = 'flex',
|
|
76
|
-
overflow,
|
|
77
|
-
overflowX,
|
|
78
|
-
overflowY,
|
|
79
|
-
position,
|
|
80
|
-
// spacing
|
|
81
|
-
spacing,
|
|
82
|
-
spacingHorizontal,
|
|
83
|
-
spacingVertical,
|
|
84
|
-
spacingBottom,
|
|
85
|
-
spacingEnd,
|
|
86
|
-
spacingStart,
|
|
87
|
-
spacingTop,
|
|
88
|
-
offset,
|
|
89
|
-
offsetVertical,
|
|
90
|
-
offsetHorizontal,
|
|
91
|
-
offsetBottom,
|
|
92
|
-
offsetEnd,
|
|
93
|
-
offsetStart,
|
|
94
|
-
offsetTop,
|
|
95
|
-
columnGap,
|
|
96
|
-
rowGap,
|
|
97
|
-
// size
|
|
98
|
-
width,
|
|
99
|
-
height,
|
|
100
|
-
// shadow
|
|
101
|
-
dropShadow,
|
|
102
|
-
insetShadow,
|
|
103
|
-
// rest
|
|
104
|
-
...props
|
|
105
|
-
}: BoxProps,
|
|
106
|
-
ref,
|
|
107
|
-
) {
|
|
108
|
-
const styles = getStyles({
|
|
109
|
-
// background
|
|
110
|
-
backgroundColor,
|
|
111
|
-
// border
|
|
112
|
-
borderRadius,
|
|
113
|
-
borderTopStartRadius,
|
|
114
|
-
borderTopEndRadius,
|
|
115
|
-
borderBottomStartRadius,
|
|
116
|
-
borderBottomEndRadius,
|
|
117
|
-
borderColor,
|
|
118
|
-
borderStartColor,
|
|
119
|
-
borderEndColor,
|
|
120
|
-
borderTopColor,
|
|
121
|
-
borderBottomColor,
|
|
122
|
-
borderWidth,
|
|
123
|
-
borderVerticalWidth,
|
|
124
|
-
borderHorizontalWidth,
|
|
125
|
-
borderStartWidth,
|
|
126
|
-
borderEndWidth,
|
|
127
|
-
borderTopWidth,
|
|
128
|
-
borderBottomWidth,
|
|
129
|
-
// flex
|
|
130
|
-
alignContent,
|
|
131
|
-
alignItems,
|
|
132
|
-
alignSelf,
|
|
133
|
-
flex,
|
|
134
|
-
flexDirection,
|
|
135
|
-
flexGrow,
|
|
136
|
-
flexShrink,
|
|
137
|
-
flexWrap,
|
|
138
|
-
justifyContent,
|
|
139
|
-
flexBasis,
|
|
140
|
-
// layout
|
|
141
|
-
display,
|
|
142
|
-
overflow,
|
|
143
|
-
overflowX,
|
|
144
|
-
overflowY,
|
|
145
|
-
position,
|
|
146
|
-
// spacing
|
|
147
|
-
spacing,
|
|
148
|
-
spacingHorizontal,
|
|
149
|
-
spacingVertical,
|
|
150
|
-
spacingBottom,
|
|
151
|
-
spacingEnd,
|
|
152
|
-
spacingStart,
|
|
153
|
-
spacingTop,
|
|
154
|
-
offset,
|
|
155
|
-
offsetVertical,
|
|
156
|
-
offsetHorizontal,
|
|
157
|
-
offsetBottom,
|
|
158
|
-
offsetEnd,
|
|
159
|
-
offsetStart,
|
|
160
|
-
offsetTop,
|
|
161
|
-
columnGap,
|
|
162
|
-
rowGap,
|
|
163
|
-
// size
|
|
164
|
-
width,
|
|
165
|
-
height,
|
|
166
|
-
// shadow
|
|
167
|
-
dropShadow,
|
|
168
|
-
insetShadow,
|
|
169
|
-
// rest
|
|
170
|
-
className,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const Comp = asChild ? Slot : As;
|
|
174
|
-
|
|
175
|
-
return <Comp className={styles} ref={ref} {...props} />;
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
179
|
-
Box.displayName = 'Box';
|
|
180
|
-
|
|
181
|
-
export { Box, type BoxProps, type DivProps };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { DividerInternalProps } from './DividerInternal';
|
|
4
|
-
import { DividerInternal } from './DividerInternal';
|
|
5
|
-
|
|
6
|
-
type DividerProps = Omit<DividerInternalProps, 'layerClassNames'>;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* **📦 A divider component that can be used to visually separate components**
|
|
10
|
-
*
|
|
11
|
-
* @description
|
|
12
|
-
* The Divider component is a visual element used to separate content and create clear groupings within a layout. It helps establish hierarchy, improve readability, and guide users through sections of an interface. Dividers can appear as horizontal or vertical lines and are commonly used between related content blocks, within menus, or in dense UI areas to reduce visual clutter.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* import { Divider } from '@yahoo/uds';
|
|
17
|
-
*
|
|
18
|
-
* // Default primary horizontal divider. Similar to <hr />
|
|
19
|
-
* <Divider />
|
|
20
|
-
*
|
|
21
|
-
* // A vertical divider.
|
|
22
|
-
* <Divider vertical />
|
|
23
|
-
*
|
|
24
|
-
* // A horizontal divider with the secondary styling.
|
|
25
|
-
* <Divider variant="secondary" />
|
|
26
|
-
*
|
|
27
|
-
* // A vertical divider with the tertiary styling.
|
|
28
|
-
* <Divider vertical variant="tertiary" />
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @usage
|
|
32
|
-
* - Visually separating parts of a page. Usually used in conjuction with [HStack](./h-stack) or [VStack](./v-stack).
|
|
33
|
-
*
|
|
34
|
-
* @see The {@link https://uds.build/docs/components/divider Divider Docs} for more info
|
|
35
|
-
*
|
|
36
|
-
* @related [Box](https://uds.build/docs/components/box), [HStack](https://uds.build/docs/components/h-stack), [VStack](https://uds.build/docs/components/v-stack)
|
|
37
|
-
*/
|
|
38
|
-
const Divider = forwardRef<HTMLDivElement, DividerProps>(function Divider(props, ref) {
|
|
39
|
-
return <DividerInternal ref={ref} {...props} />;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
Divider.displayName = 'Divider';
|
|
43
|
-
|
|
44
|
-
export { Divider, type DividerProps };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/no-multi-comp */
|
|
2
|
-
import type { CSSProperties } from 'react';
|
|
3
|
-
import { forwardRef, useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cx } from '../../styles/styler';
|
|
6
|
-
import type { UniversalDividerProps, UniversalStackProps } from '../../tokens/types';
|
|
7
|
-
import type { BoxProps } from '../Box';
|
|
8
|
-
import { Box } from '../Box';
|
|
9
|
-
import { HStack } from '../HStack';
|
|
10
|
-
import { Text } from '../Text';
|
|
11
|
-
import { VStack } from '../VStack';
|
|
12
|
-
|
|
13
|
-
const ORIENTATION_WIDTH_MAP = {
|
|
14
|
-
horizontal: 'w-full',
|
|
15
|
-
vertical: '',
|
|
16
|
-
} as const;
|
|
17
|
-
|
|
18
|
-
interface DividerCoreProps
|
|
19
|
-
extends Omit<BoxProps, 'color' | 'borderColor' | 'borderWidth'>,
|
|
20
|
-
Omit<UniversalStackProps, 'separator' | 'asChild'>,
|
|
21
|
-
Omit<UniversalDividerProps, 'variant'> {
|
|
22
|
-
layerClassNames?: {
|
|
23
|
-
root?: string;
|
|
24
|
-
text?: string;
|
|
25
|
-
line?: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const DividerCore = forwardRef<HTMLDivElement, DividerCoreProps>(function Divider(
|
|
30
|
-
{
|
|
31
|
-
vertical = false,
|
|
32
|
-
contentPosition = 'center',
|
|
33
|
-
className,
|
|
34
|
-
layerClassNames,
|
|
35
|
-
children,
|
|
36
|
-
...boxProps
|
|
37
|
-
}: DividerCoreProps,
|
|
38
|
-
ref,
|
|
39
|
-
) {
|
|
40
|
-
const direction = vertical ? 'vertical' : 'horizontal';
|
|
41
|
-
const InternalComponent = vertical ? VStack : HStack;
|
|
42
|
-
|
|
43
|
-
const classNames = useMemo(
|
|
44
|
-
() => ({
|
|
45
|
-
root: cx(ORIENTATION_WIDTH_MAP[direction], className, layerClassNames?.root),
|
|
46
|
-
label: cx(layerClassNames?.text),
|
|
47
|
-
line: layerClassNames?.line,
|
|
48
|
-
}),
|
|
49
|
-
[className, direction, layerClassNames?.root, layerClassNames?.text, layerClassNames?.line],
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// This needs to be style rather than classes because the automated configuration classes
|
|
53
|
-
// have a higher specificity and tailwind !important isn't working.
|
|
54
|
-
const lineStyle = useMemo(
|
|
55
|
-
(): CSSProperties =>
|
|
56
|
-
// Configurator sets all borders to 1.
|
|
57
|
-
direction === 'vertical'
|
|
58
|
-
? // For vertical, we keep only the left border.
|
|
59
|
-
{ borderTopWidth: 0, borderRightWidth: 0, borderBottomWidth: 0 }
|
|
60
|
-
: // For horizontal, we keep only the top border.
|
|
61
|
-
{ borderLeftWidth: 0, borderRightWidth: 0, borderBottomWidth: 0 },
|
|
62
|
-
|
|
63
|
-
[direction],
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
// eslint-disable-next-line react/display-name
|
|
67
|
-
const Line = () => <Box flex="1" className={classNames.line} style={lineStyle} />;
|
|
68
|
-
|
|
69
|
-
if (children) {
|
|
70
|
-
return (
|
|
71
|
-
<InternalComponent
|
|
72
|
-
flex="1"
|
|
73
|
-
alignItems="center"
|
|
74
|
-
className={classNames.root}
|
|
75
|
-
ref={ref}
|
|
76
|
-
{...boxProps}
|
|
77
|
-
>
|
|
78
|
-
{contentPosition !== 'start' && <Line />}
|
|
79
|
-
|
|
80
|
-
<Box flex="none">
|
|
81
|
-
<Text color="inherit" variant="inherit" className={classNames.label}>
|
|
82
|
-
{children}
|
|
83
|
-
</Text>
|
|
84
|
-
</Box>
|
|
85
|
-
|
|
86
|
-
{contentPosition !== 'end' && <Line />}
|
|
87
|
-
</InternalComponent>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<Box display="flex" flex="none" className={classNames.root} ref={ref} {...boxProps}>
|
|
93
|
-
<Line />
|
|
94
|
-
</Box>
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
99
|
-
DividerCore.displayName = 'DividerCore';
|
|
100
|
-
|
|
101
|
-
export { DividerCore, type DividerCoreProps };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cx, getStyles } from '../../styles/styler';
|
|
4
|
-
import type { UniversalDividerProps } from '../../tokens/types';
|
|
5
|
-
import type { DividerCoreProps } from './DividerCore';
|
|
6
|
-
import { DividerCore } from './DividerCore';
|
|
7
|
-
|
|
8
|
-
type VariantWithInherit = Exclude<UniversalDividerProps['variant'], undefined> | 'inherit';
|
|
9
|
-
|
|
10
|
-
interface DividerInternalProps extends DividerCoreProps {
|
|
11
|
-
// Add inherit option for configured component composition.
|
|
12
|
-
variant?: VariantWithInherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const DividerInternal = forwardRef<HTMLDivElement, DividerInternalProps>(function Divider(
|
|
16
|
-
{ variant = 'primary', layerClassNames, ...props }: DividerInternalProps,
|
|
17
|
-
ref,
|
|
18
|
-
) {
|
|
19
|
-
const coreLayerClassNames = useMemo(
|
|
20
|
-
(): DividerInternalProps['layerClassNames'] => ({
|
|
21
|
-
root: cx(
|
|
22
|
-
variant !== 'inherit' &&
|
|
23
|
-
getStyles({
|
|
24
|
-
dividerVariantRoot: variant,
|
|
25
|
-
}),
|
|
26
|
-
layerClassNames?.root,
|
|
27
|
-
),
|
|
28
|
-
|
|
29
|
-
text: cx(
|
|
30
|
-
variant !== 'inherit'
|
|
31
|
-
? getStyles({
|
|
32
|
-
dividerVariantLabel: variant,
|
|
33
|
-
})
|
|
34
|
-
: undefined,
|
|
35
|
-
layerClassNames?.text,
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
line: cx(
|
|
39
|
-
variant !== 'inherit' &&
|
|
40
|
-
getStyles({
|
|
41
|
-
dividerVariantLine: variant,
|
|
42
|
-
}),
|
|
43
|
-
layerClassNames?.line,
|
|
44
|
-
),
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
[layerClassNames?.line, layerClassNames?.root, layerClassNames?.text, variant],
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return <DividerCore ref={ref} layerClassNames={coreLayerClassNames} {...props} />;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
54
|
-
DividerInternal.displayName = 'DividerInternal';
|
|
55
|
-
|
|
56
|
-
export { DividerInternal, type DividerInternalProps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Divider, type DividerProps } from './Divider';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { UniversalFormLabelProps } from '@yahoo/uds/tokens';
|
|
2
|
-
import { isFunction } from 'lodash';
|
|
3
|
-
import type { PropsWithChildren } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cx } from '../styles/styler';
|
|
6
|
-
import type { TextProps } from './Text';
|
|
7
|
-
import { Text } from './Text';
|
|
8
|
-
|
|
9
|
-
type HtmlLabelProps = Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'color'>;
|
|
10
|
-
|
|
11
|
-
interface FormLabelProps extends UniversalFormLabelProps, PropsWithChildren, HtmlLabelProps {}
|
|
12
|
-
|
|
13
|
-
const FormLabel = ({
|
|
14
|
-
htmlFor,
|
|
15
|
-
required,
|
|
16
|
-
label,
|
|
17
|
-
children,
|
|
18
|
-
color = 'muted',
|
|
19
|
-
variant = 'label3',
|
|
20
|
-
hasError = false,
|
|
21
|
-
showRequiredAsterisk = false,
|
|
22
|
-
as = 'label',
|
|
23
|
-
className,
|
|
24
|
-
...rest
|
|
25
|
-
}: FormLabelProps) => {
|
|
26
|
-
const contents = label ? (isFunction(label) ? label() : label) : children;
|
|
27
|
-
|
|
28
|
-
if (!contents) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Text
|
|
34
|
-
variant={variant}
|
|
35
|
-
color={color}
|
|
36
|
-
as={as as TextProps['as']}
|
|
37
|
-
htmlFor={htmlFor}
|
|
38
|
-
className={cx(
|
|
39
|
-
// Use the same cursor as the wrapping form component.
|
|
40
|
-
// The form component controls pointer vs disabled so
|
|
41
|
-
// this keeps Text from resetting it back to text cursor.
|
|
42
|
-
'cursor-[inherit]',
|
|
43
|
-
className,
|
|
44
|
-
)}
|
|
45
|
-
{...rest}
|
|
46
|
-
>
|
|
47
|
-
{contents}
|
|
48
|
-
|
|
49
|
-
{required && showRequiredAsterisk && (
|
|
50
|
-
<Text
|
|
51
|
-
as="sup"
|
|
52
|
-
color={hasError ? 'alert' : 'inherit'}
|
|
53
|
-
variant="inherit"
|
|
54
|
-
spacingStart="0.5"
|
|
55
|
-
aria-hidden
|
|
56
|
-
>
|
|
57
|
-
*
|
|
58
|
-
</Text>
|
|
59
|
-
)}
|
|
60
|
-
</Text>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
FormLabel.displayName = 'FormLabel';
|
|
65
|
-
|
|
66
|
-
export { FormLabel, type FormLabelProps };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { UniversalStackProps } from '@yahoo/uds/tokens';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
|
|
4
|
-
import { intersperseReactChildren } from '../utils/intersperse';
|
|
5
|
-
import type { DivProps } from './Box';
|
|
6
|
-
import { Box } from './Box';
|
|
7
|
-
|
|
8
|
-
interface HStackProps extends UniversalStackProps, DivProps {}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* **📏 A layout component that arranges its children in columns using flexbox**
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* HStack is a layout primitive that arranges its children in a columns [flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox)
|
|
15
|
-
* and can be used to compose larger layouts. HStack is similar to [Box](./box) but provides additional features like a `gap` property to
|
|
16
|
-
* add spacing between children.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* import { HStack, Text } from '@yahoo/uds';
|
|
21
|
-
|
|
22
|
-
* <HStack gap="6">
|
|
23
|
-
* <Text variant="body1" color="primary">First</Text>
|
|
24
|
-
* <Text variant="body1" color="primary">Second</Text>
|
|
25
|
-
* <Text variant="body1" color="primary">Third</Text>
|
|
26
|
-
* </HStack>
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @usage
|
|
30
|
-
* - Create a row of items, optionally with gaps between items.
|
|
31
|
-
* - Create columns that are sized to their content.
|
|
32
|
-
* - Create columns that fill the available space within the parent container.
|
|
33
|
-
* - Create columns of proportionate size to each other (also known as a ratio-based layout).
|
|
34
|
-
*
|
|
35
|
-
* @see The {@link https://uds.build/docs/components/h-stack HStack Docs} for more info
|
|
36
|
-
*
|
|
37
|
-
* @related [Box](https://uds.build/docs/components/box), [VStack](https://uds.build/docs/components/v-stack)
|
|
38
|
-
**/
|
|
39
|
-
const HStack = forwardRef<HTMLDivElement, HStackProps>(function HStack(
|
|
40
|
-
{ gap, children, separator, ...props }: HStackProps,
|
|
41
|
-
ref,
|
|
42
|
-
) {
|
|
43
|
-
return (
|
|
44
|
-
<Box ref={ref} flexDirection="row" rowGap={gap} columnGap={gap} {...props}>
|
|
45
|
-
{separator ? intersperseReactChildren(children, separator) : children}
|
|
46
|
-
</Box>
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
51
|
-
HStack.displayName = 'HStack';
|
|
52
|
-
|
|
53
|
-
export { HStack, type HStackProps };
|
package/src/components/Icon.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cx, getStyles } from '../styles/styler';
|
|
4
|
-
import type { IconPropsWithSVGProps as IconProps } from '../tokens';
|
|
5
|
-
import { normalIconSizes } from '../tokens/configs/sizes';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* **🎨 A component for displaying icons**
|
|
9
|
-
*
|
|
10
|
-
* @description
|
|
11
|
-
* [Iconography](https://uds.build/docs/core-concepts/icons) contains small symbols for actions or
|
|
12
|
-
* other items. They are available in four different sizes: `xs`, `sm`, `md`, and
|
|
13
|
-
* `lg`. Each size also supports an outline and fill variant. Icons can be
|
|
14
|
-
* colored using the `color` prop.
|
|
15
|
-
*
|
|
16
|
-
* The component is available in the `@yahoo/uds` package but is meant to be used
|
|
17
|
-
* with the assets in `@yahoo/uds-icons`. You will need both packages to use icons.
|
|
18
|
-
* A separate package provides modularity from the core library, better
|
|
19
|
-
* versioning strategies, and tree shakeability.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* import { Icon } from '@yahoo/uds';
|
|
24
|
-
* import { AddFolder } from '@yahoo/uds-icons';
|
|
25
|
-
*
|
|
26
|
-
* <Icon name={AddFolder} variant="fill" size="sm" />
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @usage
|
|
30
|
-
* - If you need to display an icon.
|
|
31
|
-
*
|
|
32
|
-
* @see The {@link https://uds.build/docs/components/icon Icon Docs} for more info
|
|
33
|
-
*
|
|
34
|
-
* @related [IconButton](https://uds.build/docs/components/icon-button)
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
const Icon = forwardRef<SVGSVGElement, IconProps>(function BaseIcon(
|
|
38
|
-
{
|
|
39
|
-
name: SVGIcon,
|
|
40
|
-
size = 'md',
|
|
41
|
-
variant = 'outline',
|
|
42
|
-
color = 'primary',
|
|
43
|
-
className,
|
|
44
|
-
...props
|
|
45
|
-
}: IconProps,
|
|
46
|
-
ref,
|
|
47
|
-
) {
|
|
48
|
-
// Check if the requested variant is available
|
|
49
|
-
const availableVariants = SVGIcon.metadata?.variants ?? [];
|
|
50
|
-
const effectiveVariant = availableVariants.includes(variant)
|
|
51
|
-
? variant
|
|
52
|
-
: (availableVariants[0] ?? 'fill');
|
|
53
|
-
|
|
54
|
-
const isMulticolor = effectiveVariant === 'multicolor';
|
|
55
|
-
const styles = getStyles({
|
|
56
|
-
flex: 'none',
|
|
57
|
-
color: isMulticolor ? undefined : color,
|
|
58
|
-
className: cx(className, !isMulticolor && '[&_path]:fill-current'),
|
|
59
|
-
});
|
|
60
|
-
const sizePx = normalIconSizes[size]; // TODO: use scale modes when they are available.
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<svg
|
|
64
|
-
ref={ref}
|
|
65
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
-
width={sizePx}
|
|
67
|
-
height={sizePx}
|
|
68
|
-
viewBox={`0 0 ${sizePx} ${sizePx}`}
|
|
69
|
-
aria-hidden="true"
|
|
70
|
-
focusable="false"
|
|
71
|
-
className={styles}
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<SVGIcon size={size} variant={effectiveVariant} />
|
|
75
|
-
</svg>
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
80
|
-
Icon.displayName = 'Icon';
|
|
81
|
-
|
|
82
|
-
export { Icon, type IconProps };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { SvgIcon } from '@yahoo/uds-icons/types';
|
|
2
|
-
import { isFunction } from 'lodash';
|
|
3
|
-
import type { ReactElement } from 'react';
|
|
4
|
-
import React, { cloneElement, isValidElement, memo } from 'react';
|
|
5
|
-
|
|
6
|
-
import { cx } from '../styles/styler';
|
|
7
|
-
import type { IconPropsWithSVGProps, UniversalIconSlot } from '../tokens';
|
|
8
|
-
import { Icon } from './Icon';
|
|
9
|
-
|
|
10
|
-
interface IconSlotProps {
|
|
11
|
-
/** The icon to render. Can be a UDS icon, an Icon component, ReactNode, or a function that a ReactNode. */
|
|
12
|
-
icon?: UniversalIconSlot;
|
|
13
|
-
/** Props to spread onto the icon. */
|
|
14
|
-
iconProps?: Omit<IconPropsWithSVGProps, 'name'>;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A helper container to render a SvgIcon, Icon component, or ReactNode.
|
|
20
|
-
*
|
|
21
|
-
* Useful in components that use icons and have a startIcon and endIcon. It allows
|
|
22
|
-
* consumers to pass in a standard UDS icon (`SvgIcon`) or a ReactNode if they
|
|
23
|
-
* need to override props on the icon. For example, pass an `<Icon>` to override
|
|
24
|
-
* the icon variant. Pass a `<IconButton>` to support interactivity on an icon slot.
|
|
25
|
-
*
|
|
26
|
-
* Examples:
|
|
27
|
-
* ```
|
|
28
|
-
* <Input startIcon={Info} />
|
|
29
|
-
* <Input startIcon={<Icon name={Info} variant="fill" />} />
|
|
30
|
-
* <Input startIcon={() => <Icon name={Info} variant="fill" />} />
|
|
31
|
-
* <Input endIcon={() => <IconButton name={Info} aria-label="My label" />} />
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
const IconSlot = memo(function IconSlot({
|
|
35
|
-
icon,
|
|
36
|
-
iconProps,
|
|
37
|
-
className: slotClassName,
|
|
38
|
-
...rest
|
|
39
|
-
}: IconSlotProps) {
|
|
40
|
-
if (!icon) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const { className: iconPropsClassName, ...props } = iconProps || {};
|
|
45
|
-
|
|
46
|
-
const mergedClassName = cx(slotClassName, iconPropsClassName);
|
|
47
|
-
|
|
48
|
-
// Try as UDS SvgIcon first
|
|
49
|
-
const svgIcon = icon as SvgIcon;
|
|
50
|
-
if (svgIcon.metadata?.isSvgIcon) {
|
|
51
|
-
return <Icon name={svgIcon} {...props} {...rest} className={mergedClassName} />;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (isFunction(icon)) {
|
|
55
|
-
const iconEl = icon(iconProps || {}) as ReactElement;
|
|
56
|
-
const renderedElementClassName = iconEl?.props.className;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
isValidElement(iconEl) &&
|
|
60
|
-
cloneElement(iconEl, {
|
|
61
|
-
...rest,
|
|
62
|
-
className: cx(mergedClassName, renderedElementClassName),
|
|
63
|
-
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
} as any)
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
isValidElement(icon) &&
|
|
71
|
-
cloneElement(icon, {
|
|
72
|
-
...props, // default icons props from input
|
|
73
|
-
...(icon as ReactElement).props, // user's props on <Icon>
|
|
74
|
-
...rest, // anything else
|
|
75
|
-
className: cx(mergedClassName, (icon as ReactElement).props.className),
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
IconSlot.displayName = 'IconSlot';
|
|
81
|
-
|
|
82
|
-
export { IconSlot, type IconSlotProps };
|