@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,81 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { UniversalChipProps } from '../../../tokens';
|
|
4
|
-
import type { ChipBaseProps } from './ChipBase';
|
|
5
|
-
import { ChipButton } from './ChipButton';
|
|
6
|
-
import { ChipDismissible } from './ChipDismissible';
|
|
7
|
-
import type { ChipLinkProps } from './ChipLink';
|
|
8
|
-
import { ChipLink } from './ChipLink';
|
|
9
|
-
import { ChipToggle } from './ChipToggle';
|
|
10
|
-
|
|
11
|
-
type HtmlDivProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onToggle' | 'label'>;
|
|
12
|
-
|
|
13
|
-
interface ChipProps extends UniversalChipProps, HtmlDivProps {
|
|
14
|
-
slotProps?: ChipBaseProps['slotProps'] & {
|
|
15
|
-
anchor: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type'>;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* **⚙️️ A chip.
|
|
21
|
-
*
|
|
22
|
-
* @componentType Client component
|
|
23
|
-
*
|
|
24
|
-
* @description
|
|
25
|
-
* Chips help people make selections, filter content, link out to other spaces or trigger actions. These actions are contextually driven and are not persistent across the product experiences differing them from buttons.
|
|
26
|
-
*
|
|
27
|
-
* @see
|
|
28
|
-
* Check out the {@link https://uds.build/docs/components/chip Chip Docs} for more info
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* 'use client';
|
|
33
|
-
* import { Chip } from "@yahoo/uds";
|
|
34
|
-
*
|
|
35
|
-
* <Chip>Label</Chip>
|
|
36
|
-
*```
|
|
37
|
-
*
|
|
38
|
-
* @related [Badge](https://uds.build/docs/components/badge), [Link](https://uds.build/docs/components/link).
|
|
39
|
-
**/
|
|
40
|
-
const Chip = forwardRef<HTMLDivElement, ChipProps>(function Chip(
|
|
41
|
-
{ onClick, href, linkProps, onDismiss, onToggle, isToggled, slotProps, ...rest }: ChipProps,
|
|
42
|
-
ref,
|
|
43
|
-
) {
|
|
44
|
-
const { anchor: anchorProps, ...restSlotProps } = slotProps ?? {};
|
|
45
|
-
|
|
46
|
-
if (onDismiss) {
|
|
47
|
-
return <ChipDismissible ref={ref} onDismiss={onDismiss} slotProps={restSlotProps} {...rest} />;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (onToggle) {
|
|
51
|
-
return (
|
|
52
|
-
<ChipToggle
|
|
53
|
-
ref={ref}
|
|
54
|
-
onToggle={onToggle}
|
|
55
|
-
isToggled={isToggled}
|
|
56
|
-
slotProps={restSlotProps}
|
|
57
|
-
{...rest}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (href) {
|
|
63
|
-
return (
|
|
64
|
-
<ChipLink
|
|
65
|
-
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
|
|
66
|
-
href={href}
|
|
67
|
-
slotProps={restSlotProps}
|
|
68
|
-
{...(rest as ChipLinkProps)}
|
|
69
|
-
{...linkProps}
|
|
70
|
-
{...anchorProps}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return <ChipButton ref={ref} onClick={onClick} slotProps={restSlotProps} {...rest} />;
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
79
|
-
Chip.displayName = 'Chip';
|
|
80
|
-
|
|
81
|
-
export { Chip, type ChipProps };
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { useReducedMotion } from 'motion/react';
|
|
2
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
5
|
-
import type {
|
|
6
|
-
ChipSize,
|
|
7
|
-
ChipVariant,
|
|
8
|
-
IconPropsWithSVGProps,
|
|
9
|
-
UniversalChipBaseProps,
|
|
10
|
-
} from '../../../tokens';
|
|
11
|
-
import { HStack } from '../../HStack';
|
|
12
|
-
import { IconSlot } from '../../IconSlot';
|
|
13
|
-
import type { TextProps } from '../../Text';
|
|
14
|
-
import { Text } from '../../Text';
|
|
15
|
-
|
|
16
|
-
type HtmlDivProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onToggle' | 'label'>;
|
|
17
|
-
|
|
18
|
-
// Required because of: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69864
|
|
19
|
-
type DataAttributes = {
|
|
20
|
-
[name: `data-${string}`]: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
interface ChipBaseProps extends HtmlDivProps, Omit<UniversalChipBaseProps, 'variant'> {
|
|
24
|
-
/** Props to be passed into various slots within the component. */
|
|
25
|
-
slotProps?: {
|
|
26
|
-
startIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
27
|
-
endIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
28
|
-
text?: Partial<TextProps & DataAttributes>;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const SIZE_DEFAULT: ChipSize = 'md';
|
|
33
|
-
const VARIANT_DEFAULT: ChipVariant = 'primary';
|
|
34
|
-
const MAX_WIDTH_DEFAULT = 200;
|
|
35
|
-
|
|
36
|
-
const ChipBase = forwardRef<HTMLDivElement, ChipBaseProps>(function ChipBase(
|
|
37
|
-
{
|
|
38
|
-
size = SIZE_DEFAULT,
|
|
39
|
-
minWidth,
|
|
40
|
-
maxWidth = MAX_WIDTH_DEFAULT,
|
|
41
|
-
startIcon,
|
|
42
|
-
endIcon,
|
|
43
|
-
as: As = 'div',
|
|
44
|
-
reduceMotion: forceReduceMotion,
|
|
45
|
-
disabled = false,
|
|
46
|
-
className,
|
|
47
|
-
slotProps,
|
|
48
|
-
children,
|
|
49
|
-
...rest
|
|
50
|
-
}: ChipBaseProps,
|
|
51
|
-
ref,
|
|
52
|
-
) {
|
|
53
|
-
// Motion
|
|
54
|
-
const prefersReducedMotion = useReducedMotion();
|
|
55
|
-
const cssAnimationDuration =
|
|
56
|
-
prefersReducedMotion || forceReduceMotion ? 'duration-0' : 'duration-120';
|
|
57
|
-
|
|
58
|
-
const { className: textClassName, ...textProps } = slotProps?.text ?? {};
|
|
59
|
-
const { className: startIconClassName, ...startIconProps } = slotProps?.startIcon ?? {};
|
|
60
|
-
const { className: endIconClassName, ...endIconProps } = slotProps?.endIcon ?? {};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Styles
|
|
64
|
-
*/
|
|
65
|
-
const classNames = useMemo(
|
|
66
|
-
() => ({
|
|
67
|
-
root: getStyles({
|
|
68
|
-
chipSizeRoot: size,
|
|
69
|
-
|
|
70
|
-
className: cx(
|
|
71
|
-
{
|
|
72
|
-
'pointer-events-none': disabled,
|
|
73
|
-
'cursor-default': disabled,
|
|
74
|
-
'opacity-50': disabled,
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
// Layout
|
|
78
|
-
'inline-flex',
|
|
79
|
-
'items-center',
|
|
80
|
-
|
|
81
|
-
// focus state
|
|
82
|
-
'focus-visible:-outline-offset-2',
|
|
83
|
-
'uds-ring',
|
|
84
|
-
|
|
85
|
-
// Animations
|
|
86
|
-
cssAnimationDuration,
|
|
87
|
-
'transition-[background-color,outline-color,box-shadow]',
|
|
88
|
-
|
|
89
|
-
className,
|
|
90
|
-
),
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
text: cx('truncate', 'whitespace-nowrap', 'text-center', 'flex-1', textClassName),
|
|
94
|
-
|
|
95
|
-
icon: getStyles({
|
|
96
|
-
chipSizeIcon: size,
|
|
97
|
-
}),
|
|
98
|
-
}),
|
|
99
|
-
[className, cssAnimationDuration, disabled, size, textClassName],
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const inlineStyles = useMemo(
|
|
103
|
-
() => ({
|
|
104
|
-
root: { maxWidth: `${maxWidth}px`, ...(minWidth ? { minWidth: `${minWidth}px` } : {}) },
|
|
105
|
-
}),
|
|
106
|
-
[maxWidth, minWidth],
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<HStack asChild ref={ref} className={classNames.root} style={inlineStyles.root} {...rest}>
|
|
111
|
-
<As disabled={disabled}>
|
|
112
|
-
{startIcon && (
|
|
113
|
-
<IconSlot
|
|
114
|
-
icon={startIcon}
|
|
115
|
-
iconProps={{
|
|
116
|
-
variant: 'fill',
|
|
117
|
-
className: cx(classNames.icon, startIconClassName),
|
|
118
|
-
...startIconProps,
|
|
119
|
-
}}
|
|
120
|
-
/>
|
|
121
|
-
)}
|
|
122
|
-
|
|
123
|
-
<Text
|
|
124
|
-
as="span"
|
|
125
|
-
color="current"
|
|
126
|
-
variant="inherit"
|
|
127
|
-
className={classNames.text}
|
|
128
|
-
{...textProps}
|
|
129
|
-
>
|
|
130
|
-
{children}
|
|
131
|
-
</Text>
|
|
132
|
-
|
|
133
|
-
{endIcon && (
|
|
134
|
-
<IconSlot
|
|
135
|
-
icon={endIcon}
|
|
136
|
-
iconProps={{
|
|
137
|
-
variant: 'fill',
|
|
138
|
-
className: cx(classNames.icon, endIconClassName),
|
|
139
|
-
...endIconProps,
|
|
140
|
-
}}
|
|
141
|
-
/>
|
|
142
|
-
)}
|
|
143
|
-
</As>
|
|
144
|
-
</HStack>
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
149
|
-
ChipBase.displayName = 'ChipBase';
|
|
150
|
-
|
|
151
|
-
export { ChipBase, type ChipBaseProps, VARIANT_DEFAULT };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { getStyles } from '../../../styles/styler';
|
|
4
|
-
import type { UniversalChipButtonProps } from '../../../tokens';
|
|
5
|
-
import { mergeSlotProps } from '../../../utils/mergeSlotProps';
|
|
6
|
-
import type { ChipBaseProps } from './ChipBase';
|
|
7
|
-
import { ChipBase, VARIANT_DEFAULT } from './ChipBase';
|
|
8
|
-
|
|
9
|
-
type HtmlDivProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onToggle' | 'label'>;
|
|
10
|
-
|
|
11
|
-
interface ChipButtonProps extends HtmlDivProps, Omit<UniversalChipButtonProps, 'type'> {
|
|
12
|
-
slotProps?: ChipBaseProps['slotProps'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const ChipButton = forwardRef<HTMLDivElement, ChipButtonProps>(function ChipButton(
|
|
16
|
-
{ variant = VARIANT_DEFAULT, slotProps, className, ...rest }: ChipButtonProps,
|
|
17
|
-
ref,
|
|
18
|
-
) {
|
|
19
|
-
const classNames = useMemo(
|
|
20
|
-
() => ({
|
|
21
|
-
root: getStyles({
|
|
22
|
-
chipLinkVariantRoot: variant,
|
|
23
|
-
className,
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
icon: getStyles({
|
|
27
|
-
chipLinkVariantIcon: variant,
|
|
28
|
-
}),
|
|
29
|
-
}),
|
|
30
|
-
[className, variant],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const mergedSlotProps = mergeSlotProps(slotProps, {
|
|
34
|
-
startIcon: { className: classNames.icon },
|
|
35
|
-
endIcon: { className: classNames.icon },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<ChipBase
|
|
40
|
-
as="button"
|
|
41
|
-
ref={ref}
|
|
42
|
-
// Required for Safari to render a focus ring
|
|
43
|
-
tabIndex={0}
|
|
44
|
-
className={classNames.root}
|
|
45
|
-
slotProps={mergedSlotProps}
|
|
46
|
-
{...rest}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
52
|
-
ChipButton.displayName = 'ChipButton';
|
|
53
|
-
|
|
54
|
-
export { ChipButton, type ChipButtonProps };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Cross } from '@yahoo/uds-icons';
|
|
2
|
-
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
5
|
-
import type { UniversalChipDismissibleProps } from '../../../tokens';
|
|
6
|
-
import { mergeSlotProps } from '../../../utils/mergeSlotProps';
|
|
7
|
-
import type { IconProps } from '../../Icon';
|
|
8
|
-
import { IconSlot } from '../../IconSlot';
|
|
9
|
-
import { Pressable } from '../Pressable';
|
|
10
|
-
import type { ChipBaseProps } from './ChipBase';
|
|
11
|
-
import { ChipBase, VARIANT_DEFAULT } from './ChipBase';
|
|
12
|
-
|
|
13
|
-
type HtmlDivProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onToggle' | 'label'>;
|
|
14
|
-
|
|
15
|
-
interface ChipDismissibleProps extends HtmlDivProps, Omit<UniversalChipDismissibleProps, 'type'> {
|
|
16
|
-
slotProps?: ChipBaseProps['slotProps'];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const ChipDismissible = forwardRef<HTMLDivElement, ChipDismissibleProps>(function ChipDismissible(
|
|
20
|
-
{
|
|
21
|
-
dismissButtonAriaLabel,
|
|
22
|
-
onDismiss,
|
|
23
|
-
dismissIcon,
|
|
24
|
-
variant = VARIANT_DEFAULT,
|
|
25
|
-
disabled,
|
|
26
|
-
slotProps,
|
|
27
|
-
className,
|
|
28
|
-
...rest
|
|
29
|
-
}: ChipDismissibleProps,
|
|
30
|
-
ref,
|
|
31
|
-
) {
|
|
32
|
-
const classNames = useMemo(
|
|
33
|
-
() => ({
|
|
34
|
-
root: getStyles({
|
|
35
|
-
chipDismissibleVariantRoot: variant,
|
|
36
|
-
className,
|
|
37
|
-
}),
|
|
38
|
-
|
|
39
|
-
icon: getStyles({
|
|
40
|
-
chipDismissibleVariantIcon: variant,
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
iconPressable: cx('uds-chip-dismissible-button', 'uds-hit-target'),
|
|
44
|
-
}),
|
|
45
|
-
[className, variant],
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Handlers
|
|
50
|
-
*/
|
|
51
|
-
const handleDismissClick = useCallback(
|
|
52
|
-
(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
53
|
-
e.stopPropagation();
|
|
54
|
-
onDismiss?.();
|
|
55
|
-
},
|
|
56
|
-
[onDismiss],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const mergedSlotProps = mergeSlotProps(slotProps, {
|
|
60
|
-
startIcon: { className: classNames.icon },
|
|
61
|
-
endIcon: { className: classNames.icon },
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<ChipBase
|
|
66
|
-
ref={ref}
|
|
67
|
-
disabled={disabled}
|
|
68
|
-
tabIndex={-1}
|
|
69
|
-
endIcon={(iconProps: Omit<IconProps, 'name'>) => (
|
|
70
|
-
<Pressable
|
|
71
|
-
// Note: asChild interferes with motion/react here so we keep the wrapper
|
|
72
|
-
aria-label={dismissButtonAriaLabel}
|
|
73
|
-
className={classNames.iconPressable}
|
|
74
|
-
onClick={handleDismissClick}
|
|
75
|
-
disabled={disabled}
|
|
76
|
-
>
|
|
77
|
-
<IconSlot icon={dismissIcon ?? Cross} iconProps={iconProps} />
|
|
78
|
-
</Pressable>
|
|
79
|
-
)}
|
|
80
|
-
className={classNames.root}
|
|
81
|
-
slotProps={mergedSlotProps}
|
|
82
|
-
{...rest}
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
88
|
-
ChipDismissible.displayName = 'ChipDismissible';
|
|
89
|
-
|
|
90
|
-
export { ChipDismissible, type ChipDismissibleProps };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { getStyles } from '../../../styles/styler';
|
|
4
|
-
import type { UniversalChipLinkProps } from '../../../tokens';
|
|
5
|
-
import { mergeSlotProps } from '../../../utils/mergeSlotProps';
|
|
6
|
-
import type { ChipBaseProps } from './ChipBase';
|
|
7
|
-
import { ChipBase, VARIANT_DEFAULT } from './ChipBase';
|
|
8
|
-
|
|
9
|
-
type HtmlAnchorProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'type'>;
|
|
10
|
-
|
|
11
|
-
interface ChipLinkProps extends HtmlAnchorProps, Omit<UniversalChipLinkProps, 'type'> {
|
|
12
|
-
slotProps?: ChipBaseProps['slotProps'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const ChipLink = forwardRef<HTMLAnchorElement, ChipLinkProps>(function ChipLink(
|
|
16
|
-
{ variant = VARIANT_DEFAULT, href, disabled, slotProps, className, ...rest }: ChipLinkProps,
|
|
17
|
-
ref,
|
|
18
|
-
) {
|
|
19
|
-
const classNames = useMemo(
|
|
20
|
-
() => ({
|
|
21
|
-
root: getStyles({
|
|
22
|
-
chipLinkVariantRoot: variant,
|
|
23
|
-
className,
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
icon: getStyles({
|
|
27
|
-
chipLinkVariantIcon: variant,
|
|
28
|
-
}),
|
|
29
|
-
}),
|
|
30
|
-
[className, variant],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const mergedSlotProps = mergeSlotProps(slotProps, {
|
|
34
|
-
startIcon: { className: classNames.icon },
|
|
35
|
-
endIcon: { className: classNames.icon },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<ChipBase
|
|
40
|
-
as="a"
|
|
41
|
-
ref={ref as React.ForwardedRef<HTMLDivElement>}
|
|
42
|
-
disabled={disabled}
|
|
43
|
-
className={classNames.root}
|
|
44
|
-
slotProps={mergedSlotProps}
|
|
45
|
-
// Required for Safari to render a focus ring
|
|
46
|
-
tabIndex={0}
|
|
47
|
-
{...({
|
|
48
|
-
...rest,
|
|
49
|
-
|
|
50
|
-
// Remove the href is the only way to disable a link
|
|
51
|
-
href: disabled ? undefined : href,
|
|
52
|
-
} as ChipBaseProps)}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
58
|
-
ChipLink.displayName = 'ChipLink';
|
|
59
|
-
|
|
60
|
-
export { ChipLink, type ChipLinkProps };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { ForwardedRef } from 'react';
|
|
2
|
-
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
import { getStyles } from '../../../styles/styler';
|
|
5
|
-
import type { UniversalChipToggleProps } from '../../../tokens';
|
|
6
|
-
import { mergeSlotProps } from '../../../utils/mergeSlotProps';
|
|
7
|
-
import type { ChipBaseProps } from './ChipBase';
|
|
8
|
-
import { ChipBase, VARIANT_DEFAULT } from './ChipBase';
|
|
9
|
-
|
|
10
|
-
type HtmlDivProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'label' | 'onToggle'>;
|
|
11
|
-
|
|
12
|
-
interface ChipToggleProps extends UniversalChipToggleProps, HtmlDivProps {
|
|
13
|
-
slotProps?: ChipBaseProps['slotProps'];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const ChipToggle = forwardRef<HTMLDivElement, ChipToggleProps>(function ChipToggle(
|
|
17
|
-
{
|
|
18
|
-
isToggled = false,
|
|
19
|
-
onToggle,
|
|
20
|
-
onClick,
|
|
21
|
-
variant = VARIANT_DEFAULT,
|
|
22
|
-
slotProps,
|
|
23
|
-
className,
|
|
24
|
-
role = 'checkbox',
|
|
25
|
-
...rest
|
|
26
|
-
}: ChipToggleProps,
|
|
27
|
-
ref,
|
|
28
|
-
) {
|
|
29
|
-
const classNames = useMemo(
|
|
30
|
-
() => ({
|
|
31
|
-
root: getStyles({
|
|
32
|
-
chipToggleVariantRoot: variant,
|
|
33
|
-
chipToggleVariantActiveRoot: isToggled ? 'on' : 'off',
|
|
34
|
-
className,
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
icon: getStyles({
|
|
38
|
-
chipToggleVariantIcon: variant,
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
[className, isToggled, variant],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const handleClick = useCallback(
|
|
45
|
-
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
46
|
-
onToggle?.(!isToggled);
|
|
47
|
-
onClick?.(e);
|
|
48
|
-
},
|
|
49
|
-
[isToggled, onClick, onToggle],
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const mergedSlotProps = mergeSlotProps(slotProps, {
|
|
53
|
-
startIcon: { className: classNames.icon },
|
|
54
|
-
endIcon: { className: classNames.icon },
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// If a user passes a role other than checkbox or switch, they should also manage aria attributes, if applicable, themselves.
|
|
58
|
-
const isCheckboxOrSwitch = role === 'checkbox' || role === 'switch';
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<ChipBase
|
|
62
|
-
ref={ref as ForwardedRef<HTMLDivElement>}
|
|
63
|
-
as="button"
|
|
64
|
-
role={role}
|
|
65
|
-
aria-checked={isCheckboxOrSwitch ? isToggled : undefined}
|
|
66
|
-
onClick={handleClick}
|
|
67
|
-
className={classNames.root}
|
|
68
|
-
slotProps={mergedSlotProps}
|
|
69
|
-
// Required for Safari to render a focus ring
|
|
70
|
-
tabIndex={0}
|
|
71
|
-
{...rest}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
77
|
-
ChipToggle.displayName = 'ChipToggle';
|
|
78
|
-
|
|
79
|
-
export { ChipToggle, type ChipToggleProps };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { Chip, type ChipProps } from './Chip';
|
|
2
|
-
export { ChipButton, type ChipButtonProps } from './ChipButton';
|
|
3
|
-
export { ChipDismissible, type ChipDismissibleProps } from './ChipDismissible';
|
|
4
|
-
export { ChipLink, type ChipLinkProps } from './ChipLink';
|
|
5
|
-
export { ChipToggle, type ChipToggleProps } from './ChipToggle';
|