@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,198 +0,0 @@
|
|
|
1
|
-
import { buttonIconSvgSize } from '@yahoo/uds/fixtures';
|
|
2
|
-
import type { MotionVariant, UniversalIconButtonProps } from '@yahoo/uds/tokens';
|
|
3
|
-
import { parseDeprecatedButtonPaletteVariant } from '@yahoo/uds/tokens';
|
|
4
|
-
import { Progress } from '@yahoo/uds-icons';
|
|
5
|
-
import type { HTMLMotionProps } from 'motion/react';
|
|
6
|
-
import { AnimatePresence, m, useReducedMotion } from 'motion/react';
|
|
7
|
-
import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
-
|
|
9
|
-
import { cx, getStyles } from '../../styles/styler';
|
|
10
|
-
import {
|
|
11
|
-
buttonMotionVariants,
|
|
12
|
-
iconMotionVariants,
|
|
13
|
-
loadingMotionVariants,
|
|
14
|
-
} from '../../tokens/consts/buttonMotionTokens';
|
|
15
|
-
import { Icon } from '../Icon';
|
|
16
|
-
import { SpringMotionConfig } from './SpringMotionConfig';
|
|
17
|
-
|
|
18
|
-
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'> &
|
|
19
|
-
Omit<HTMLMotionProps<'button'>, 'name'>;
|
|
20
|
-
interface IconButtonProps extends HtmlButtonProps, UniversalIconButtonProps {}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* **⚙️️ An icon button element that can be used to trigger an action**
|
|
24
|
-
*
|
|
25
|
-
* @componentType Client component
|
|
26
|
-
*
|
|
27
|
-
* @description An icon button is essentially an interactive icon. They should be used to display an icon which, when clicked, allows the user to trigger an action. Icon buttons provide additional features such hover states, focus states, and pressable functionality.
|
|
28
|
-
*
|
|
29
|
-
* @see
|
|
30
|
-
* Check out the {@link https://uds.build/docs/components/icon-button IconButton Docs} for more info
|
|
31
|
-
*
|
|
32
|
-
* @usage
|
|
33
|
-
* - When you need a button that is represented by an icon rather than text. This is useful in compact spaces, toolbars, or when the action is commonly understood through a visual symbol.
|
|
34
|
-
* - If you need a button that is used to trigger a non-critical action.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* 'use client';
|
|
39
|
-
* import { IconButton } from "@yahoo/uds";
|
|
40
|
-
* import { AddFolder } from "@yahoo/uds-icons";
|
|
41
|
-
*
|
|
42
|
-
* <IconButton name={AddFolder} variant="primary" />
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @related [Icon](https://uds.build/docs/components/icon), [Button](https://uds.build/docs/components/button), and [Pressable](https://uds.build/docs/components/pressable)
|
|
46
|
-
*
|
|
47
|
-
**/
|
|
48
|
-
|
|
49
|
-
const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(
|
|
50
|
-
{
|
|
51
|
-
// Button config props
|
|
52
|
-
variant,
|
|
53
|
-
size: iconButtonSize,
|
|
54
|
-
// Icon props
|
|
55
|
-
iconVariant,
|
|
56
|
-
// State props
|
|
57
|
-
loading,
|
|
58
|
-
disableEffects,
|
|
59
|
-
// Misc props
|
|
60
|
-
name,
|
|
61
|
-
// HTML props (className, disabled, aria-*, data-*, onClick, etc.)
|
|
62
|
-
type = 'button',
|
|
63
|
-
htmlName,
|
|
64
|
-
className,
|
|
65
|
-
children,
|
|
66
|
-
...rest
|
|
67
|
-
}: IconButtonProps,
|
|
68
|
-
forwardedRef,
|
|
69
|
-
) {
|
|
70
|
-
/* ------------------------------- Setup refs ------------------------------- */
|
|
71
|
-
const ref = useRef<HTMLButtonElement>(null);
|
|
72
|
-
useImperativeHandle(forwardedRef, () => ref.current as HTMLButtonElement);
|
|
73
|
-
|
|
74
|
-
/* ---------------------------- Setup classNames ---------------------------- */
|
|
75
|
-
const { palette: buttonPalette_DEPRECATED, variant: buttonVariant_DEPRECATED } =
|
|
76
|
-
parseDeprecatedButtonPaletteVariant({ flatVariant: variant });
|
|
77
|
-
|
|
78
|
-
const classNames = useMemo(
|
|
79
|
-
() => ({
|
|
80
|
-
button: getStyles({
|
|
81
|
-
// We're still using the button config props here
|
|
82
|
-
buttonVariant: buttonVariant_DEPRECATED,
|
|
83
|
-
buttonPalette: buttonPalette_DEPRECATED,
|
|
84
|
-
// Icon button specific props
|
|
85
|
-
iconButtonSize,
|
|
86
|
-
className: cx(
|
|
87
|
-
// Base class name
|
|
88
|
-
'uds-icon-button',
|
|
89
|
-
// Extend button
|
|
90
|
-
'uds-button',
|
|
91
|
-
// Focus ring
|
|
92
|
-
'uds-ring',
|
|
93
|
-
// Minimum hit target of 44px
|
|
94
|
-
'uds-hit-target',
|
|
95
|
-
// State
|
|
96
|
-
loading && 'uds-button-loading',
|
|
97
|
-
disableEffects && 'uds-button-without-effects',
|
|
98
|
-
// Consumer class names
|
|
99
|
-
className,
|
|
100
|
-
),
|
|
101
|
-
}),
|
|
102
|
-
loading: 'uds-button-icon start-content animate-spin',
|
|
103
|
-
icon: 'uds-button-icon start-content',
|
|
104
|
-
}),
|
|
105
|
-
[
|
|
106
|
-
buttonPalette_DEPRECATED,
|
|
107
|
-
buttonVariant_DEPRECATED,
|
|
108
|
-
className,
|
|
109
|
-
disableEffects,
|
|
110
|
-
iconButtonSize,
|
|
111
|
-
loading,
|
|
112
|
-
],
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
/* --------------------- Motion config setup for button --------------------- */
|
|
116
|
-
const prefersReducedMotion = useReducedMotion();
|
|
117
|
-
const layoutVariant: MotionVariant = useMemo(
|
|
118
|
-
() => (prefersReducedMotion ? 'smooth' : 'subtle'),
|
|
119
|
-
[prefersReducedMotion],
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const buttonVariants = useMemo(() => {
|
|
123
|
-
const { rest, hover, pressed } = buttonMotionVariants;
|
|
124
|
-
|
|
125
|
-
// Return empty variants if effects are disabled
|
|
126
|
-
if (disableEffects) {
|
|
127
|
-
return { rest: {}, hover: {}, pressed: {} };
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return { rest, hover, pressed };
|
|
131
|
-
}, [disableEffects]);
|
|
132
|
-
|
|
133
|
-
/* -------------------------------------------------------------------------- */
|
|
134
|
-
/* The IconButton */
|
|
135
|
-
/* -------------------------------------------------------------------------- */
|
|
136
|
-
return (
|
|
137
|
-
<SpringMotionConfig
|
|
138
|
-
layoutSpeed="3"
|
|
139
|
-
layoutVariant={layoutVariant}
|
|
140
|
-
reducedMotion={disableEffects ? 'always' : 'user'}
|
|
141
|
-
>
|
|
142
|
-
<m.button
|
|
143
|
-
ref={ref}
|
|
144
|
-
type={type}
|
|
145
|
-
className={classNames.button}
|
|
146
|
-
initial="icon"
|
|
147
|
-
variants={buttonVariants}
|
|
148
|
-
whileHover="hover"
|
|
149
|
-
whileTap="pressed"
|
|
150
|
-
name={htmlName}
|
|
151
|
-
{...rest}
|
|
152
|
-
>
|
|
153
|
-
<AnimatePresence initial={false} mode="popLayout">
|
|
154
|
-
{loading && (
|
|
155
|
-
<m.span
|
|
156
|
-
key="loading"
|
|
157
|
-
variants={loadingMotionVariants}
|
|
158
|
-
initial="loading"
|
|
159
|
-
animate="loading"
|
|
160
|
-
exit="hide"
|
|
161
|
-
>
|
|
162
|
-
<Icon
|
|
163
|
-
size={buttonIconSvgSize}
|
|
164
|
-
name={Progress}
|
|
165
|
-
variant={iconVariant}
|
|
166
|
-
color="current"
|
|
167
|
-
className={classNames.loading}
|
|
168
|
-
/>
|
|
169
|
-
</m.span>
|
|
170
|
-
)}
|
|
171
|
-
{name && !loading && (
|
|
172
|
-
<m.span
|
|
173
|
-
key={name.name}
|
|
174
|
-
variants={iconMotionVariants}
|
|
175
|
-
initial="icon"
|
|
176
|
-
animate="icon"
|
|
177
|
-
exit="hide"
|
|
178
|
-
>
|
|
179
|
-
{children || (
|
|
180
|
-
<Icon
|
|
181
|
-
size={buttonIconSvgSize}
|
|
182
|
-
name={name}
|
|
183
|
-
variant={iconVariant}
|
|
184
|
-
color="current"
|
|
185
|
-
className={classNames.icon}
|
|
186
|
-
/>
|
|
187
|
-
)}
|
|
188
|
-
</m.span>
|
|
189
|
-
)}
|
|
190
|
-
</AnimatePresence>
|
|
191
|
-
</m.button>
|
|
192
|
-
</SpringMotionConfig>
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
IconButton.displayName = 'IconButton';
|
|
197
|
-
|
|
198
|
-
export { IconButton, type IconButtonProps };
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/no-multi-comp */
|
|
2
|
-
import type {
|
|
3
|
-
IconPropsWithSVGProps,
|
|
4
|
-
MotionVariant,
|
|
5
|
-
UniversalIconProps,
|
|
6
|
-
UniversalInputProps,
|
|
7
|
-
} from '@yahoo/uds/tokens';
|
|
8
|
-
import { isFunction } from 'lodash';
|
|
9
|
-
import type { HTMLMotionProps } from 'motion/react';
|
|
10
|
-
import { useReducedMotion } from 'motion/react';
|
|
11
|
-
import type { ChangeEvent, InputHTMLAttributes } from 'react';
|
|
12
|
-
import { forwardRef, memo, useCallback, useId, useImperativeHandle, useRef, useState } from 'react';
|
|
13
|
-
|
|
14
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
15
|
-
import type { BoxProps } from '../../Box';
|
|
16
|
-
import { Box } from '../../Box';
|
|
17
|
-
import { HStack } from '../../HStack';
|
|
18
|
-
import { IconSlot } from '../../IconSlot';
|
|
19
|
-
import { VStack } from '../../VStack';
|
|
20
|
-
import { AnimateHeightChange } from '../AnimateHeightChange';
|
|
21
|
-
import { InputHelpTextInternal } from './InputHelpTextInternal';
|
|
22
|
-
|
|
23
|
-
type HtmlInputProps = React.InputHTMLAttributes<HTMLInputElement> & HTMLMotionProps<'input'>;
|
|
24
|
-
|
|
25
|
-
type NativeInputProps = Omit<HtmlInputProps, 'height' | 'size' | 'width' | 'color' | 'required'>;
|
|
26
|
-
|
|
27
|
-
// Required because of: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69864
|
|
28
|
-
type DataAttributes = {
|
|
29
|
-
[name: `data-${string}`]: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
interface InputProps extends NativeInputProps, UniversalInputProps {
|
|
33
|
-
/** The type of the input element. Reduced set of options from the HTML input type attribute.
|
|
34
|
-
* @default 'text'
|
|
35
|
-
*/
|
|
36
|
-
type?: Exclude<
|
|
37
|
-
NativeInputProps['type'],
|
|
38
|
-
'button' | 'checkbox' | 'color' | 'file' | 'radio' | 'range' | 'reset' | 'submit' | 'search'
|
|
39
|
-
>;
|
|
40
|
-
|
|
41
|
-
/** Props to be passed into various slots within the component. */
|
|
42
|
-
slotProps?: {
|
|
43
|
-
input?: Partial<InputHTMLAttributes<HTMLInputElement> & DataAttributes>;
|
|
44
|
-
inputWrapper?: Partial<BoxProps & DataAttributes>;
|
|
45
|
-
startIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
46
|
-
endIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type InputChangeEvent = ChangeEvent<HTMLInputElement>;
|
|
51
|
-
|
|
52
|
-
type HelpTextContentProps = Pick<InputProps, 'helpText' | 'helperTextIcon'> &
|
|
53
|
-
BoxProps & {
|
|
54
|
-
size?: InputProps['size'];
|
|
55
|
-
isFilled?: boolean;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// eslint-disable-next-line react/display-name
|
|
59
|
-
const HelpTextContent = memo(function HelpTextContentOriginal({
|
|
60
|
-
helpText,
|
|
61
|
-
helperTextIcon,
|
|
62
|
-
spacingStart,
|
|
63
|
-
spacingTop,
|
|
64
|
-
size,
|
|
65
|
-
isFilled,
|
|
66
|
-
...rest
|
|
67
|
-
}: HelpTextContentProps) {
|
|
68
|
-
if (!helpText) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Box spacingTop={spacingTop} spacingStart={spacingStart} {...rest}>
|
|
74
|
-
<InputHelpTextInternal startIcon={helperTextIcon} size={size} isFilled={isFilled}>
|
|
75
|
-
{isFunction(helpText) ? helpText() : helpText}
|
|
76
|
-
</InputHelpTextInternal>
|
|
77
|
-
</Box>
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
interface StartIconProps {
|
|
82
|
-
icon: InputProps['startIcon'];
|
|
83
|
-
className?: string;
|
|
84
|
-
iconProps?: Partial<UniversalIconProps>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line react/display-name
|
|
88
|
-
const StartIcon = memo(function StartIcon({ icon, className, iconProps }: StartIconProps) {
|
|
89
|
-
if (!icon) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<IconSlot icon={icon} iconProps={{ variant: 'outline', ...iconProps }} className={className} />
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
interface EndIconProps {
|
|
99
|
-
icon: InputProps['endIcon'];
|
|
100
|
-
className?: string;
|
|
101
|
-
iconProps?: Partial<UniversalIconProps>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// eslint-disable-next-line react/display-name
|
|
105
|
-
const EndIcon = memo(function EndIcon({ icon, className, iconProps }: EndIconProps) {
|
|
106
|
-
if (!icon) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<IconSlot
|
|
112
|
-
icon={icon}
|
|
113
|
-
iconProps={{
|
|
114
|
-
variant: 'outline',
|
|
115
|
-
...iconProps,
|
|
116
|
-
}}
|
|
117
|
-
className={className}
|
|
118
|
-
/>
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* **📦 An input that allows users to enter text and collect data.**
|
|
124
|
-
*
|
|
125
|
-
* @componentType Client component
|
|
126
|
-
*
|
|
127
|
-
* @description
|
|
128
|
-
* An input field is a component that takes text typed into it. It can also serve as a way to display a selection and trigger a dropdown menu. Inputs are interactive elements that users can click, tap, or otherwise engage with to collect data and open dropdowns, or both.
|
|
129
|
-
*
|
|
130
|
-
* @see
|
|
131
|
-
* Check out the {@link https://uds.build/docs/components/input Input Docs} for more info
|
|
132
|
-
*
|
|
133
|
-
* @usage
|
|
134
|
-
* - Forms: For collecting data like names, emails, passwords, etc. (e.g., sign-up, login, or contact forms).
|
|
135
|
-
* - Search Bars: Allowing users to enter search queries to find content.
|
|
136
|
-
* - Filters/Settings: When users need to specify preferences, like selecting a date or adjusting a number value.
|
|
137
|
-
* - Feedback/Comments: Letting users leave reviews, comments, or feedback.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```tsx
|
|
141
|
-
* 'use client';
|
|
142
|
-
* import { Input } from "@yahoo/uds";
|
|
143
|
-
*
|
|
144
|
-
* <Input label="Name" placeholder="Enter your name" required />
|
|
145
|
-
*```
|
|
146
|
-
*
|
|
147
|
-
* @related [Checkbox](https://uds.build/docs/components/checkbox), [Radio](https://uds.build/docs/components/radio).
|
|
148
|
-
**/
|
|
149
|
-
const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|
150
|
-
{
|
|
151
|
-
id,
|
|
152
|
-
label,
|
|
153
|
-
type = 'text',
|
|
154
|
-
size = 'md',
|
|
155
|
-
startIcon,
|
|
156
|
-
endIcon,
|
|
157
|
-
helpText,
|
|
158
|
-
helperTextIcon,
|
|
159
|
-
hasError,
|
|
160
|
-
width: containerWidth = 'full',
|
|
161
|
-
defaultValue,
|
|
162
|
-
required,
|
|
163
|
-
readOnly,
|
|
164
|
-
disabled,
|
|
165
|
-
reduceMotion: forceReduceMotion,
|
|
166
|
-
onChange,
|
|
167
|
-
slotProps,
|
|
168
|
-
className, // extract it from otherProps
|
|
169
|
-
...otherProps
|
|
170
|
-
}: InputProps,
|
|
171
|
-
forwardedRef,
|
|
172
|
-
) {
|
|
173
|
-
const generatedId = useId();
|
|
174
|
-
const uid = id ?? `uds-input-${generatedId}`;
|
|
175
|
-
const helpTextId = `uds-input-${uid}-help-text`;
|
|
176
|
-
|
|
177
|
-
const { className: inputClassName, ...inputProps } = slotProps?.input ?? {};
|
|
178
|
-
const { className: inputWrapperClassName, ...inputWrapperProps } = slotProps?.inputWrapper ?? {};
|
|
179
|
-
|
|
180
|
-
const ref = useRef<HTMLInputElement>(null);
|
|
181
|
-
useImperativeHandle(forwardedRef, () => ref.current as HTMLInputElement);
|
|
182
|
-
|
|
183
|
-
const [value, setValue] = useState(defaultValue ?? '');
|
|
184
|
-
|
|
185
|
-
const handleChange = useCallback(
|
|
186
|
-
(e: InputChangeEvent) => {
|
|
187
|
-
setValue(e.target.value);
|
|
188
|
-
onChange?.(e);
|
|
189
|
-
},
|
|
190
|
-
[onChange],
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
// Motion
|
|
194
|
-
const prefersReducedMotion = useReducedMotion();
|
|
195
|
-
const layoutVariant: MotionVariant = prefersReducedMotion ? 'smooth' : 'bouncy';
|
|
196
|
-
const reduceMotion = forceReduceMotion ? 'always' : 'user';
|
|
197
|
-
|
|
198
|
-
// Internal "states".
|
|
199
|
-
const isInteractive = !readOnly && !disabled;
|
|
200
|
-
|
|
201
|
-
const classNames = {
|
|
202
|
-
root: getStyles({
|
|
203
|
-
inputSizeRoot: size,
|
|
204
|
-
inputVariantRoot: 'default',
|
|
205
|
-
inputVariantValueRoot: !value ? 'empty' : 'filled',
|
|
206
|
-
className: cx([className, disabled ? 'opacity-50' : '']),
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
inputWrapper: cx(
|
|
210
|
-
getStyles({
|
|
211
|
-
inputSizeInputWrapper: size,
|
|
212
|
-
inputVariantInputWrapper: 'default',
|
|
213
|
-
inputVariantValueInputWrapper: !value ? 'empty' : 'filled',
|
|
214
|
-
}),
|
|
215
|
-
'min-w-[200px]',
|
|
216
|
-
inputWrapperClassName,
|
|
217
|
-
),
|
|
218
|
-
|
|
219
|
-
input: getStyles({
|
|
220
|
-
inputSizeInput: size,
|
|
221
|
-
inputVariantInput: 'default',
|
|
222
|
-
inputVariantValueInput: !value ? 'empty' : 'filled',
|
|
223
|
-
inputVariantInputPlaceholder: 'default',
|
|
224
|
-
inputVariantValueInputPlaceholder: !value ? 'empty' : 'filled',
|
|
225
|
-
|
|
226
|
-
className: cx(
|
|
227
|
-
'grow',
|
|
228
|
-
'uds-hit-target', // Minimum hit target of 44px
|
|
229
|
-
'bg-clip-text', // Remove auto-fill background color
|
|
230
|
-
'focus:outline-none',
|
|
231
|
-
// Readonly & disabled styles.
|
|
232
|
-
isInteractive ? 'cursor-text' : 'cursor-not-allowed',
|
|
233
|
-
// User overrides
|
|
234
|
-
inputClassName,
|
|
235
|
-
),
|
|
236
|
-
}),
|
|
237
|
-
label: cx(
|
|
238
|
-
getStyles({
|
|
239
|
-
inputSizeLabel: size,
|
|
240
|
-
inputVariantLabel: 'default',
|
|
241
|
-
inputVariantValueLabel: !value ? 'empty' : 'filled',
|
|
242
|
-
}),
|
|
243
|
-
),
|
|
244
|
-
labelRequired: getStyles({
|
|
245
|
-
inputVariantLabelRequired: 'default',
|
|
246
|
-
inputVariantValueLabelRequired: !value ? 'empty' : 'filled',
|
|
247
|
-
}),
|
|
248
|
-
startIcon: getStyles({
|
|
249
|
-
inputSizeStartIcon: size,
|
|
250
|
-
inputVariantStartIcon: 'default',
|
|
251
|
-
inputVariantValueStartIcon: !value ? 'empty' : 'filled',
|
|
252
|
-
}),
|
|
253
|
-
endIcon: getStyles({
|
|
254
|
-
inputSizeEndIcon: size,
|
|
255
|
-
inputVariantEndIcon: 'default',
|
|
256
|
-
inputVariantValueEndIcon: !value ? 'empty' : 'filled',
|
|
257
|
-
}),
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
return (
|
|
261
|
-
<VStack width={containerWidth} className={classNames.root}>
|
|
262
|
-
{label && (
|
|
263
|
-
<Box spacingBottom="2" columnGap="0.5" alignItems="flex-end" className={classNames.label}>
|
|
264
|
-
<label htmlFor={uid}>{isFunction(label) ? label() : label}</label>
|
|
265
|
-
{required && <span className={classNames.labelRequired}>*</span>}
|
|
266
|
-
</Box>
|
|
267
|
-
)}
|
|
268
|
-
|
|
269
|
-
<Box
|
|
270
|
-
position="relative"
|
|
271
|
-
alignItems="center"
|
|
272
|
-
{...inputWrapperProps}
|
|
273
|
-
className={classNames.inputWrapper}
|
|
274
|
-
>
|
|
275
|
-
<StartIcon
|
|
276
|
-
icon={startIcon}
|
|
277
|
-
className={classNames.startIcon}
|
|
278
|
-
iconProps={slotProps?.startIcon}
|
|
279
|
-
/>
|
|
280
|
-
|
|
281
|
-
<input
|
|
282
|
-
ref={ref}
|
|
283
|
-
id={uid}
|
|
284
|
-
type={type}
|
|
285
|
-
value={value}
|
|
286
|
-
required={required}
|
|
287
|
-
readOnly={readOnly}
|
|
288
|
-
disabled={disabled}
|
|
289
|
-
aria-describedby={helpTextId}
|
|
290
|
-
aria-invalid={hasError}
|
|
291
|
-
onChange={handleChange}
|
|
292
|
-
className={classNames.input}
|
|
293
|
-
{...otherProps}
|
|
294
|
-
{...inputProps}
|
|
295
|
-
/>
|
|
296
|
-
|
|
297
|
-
{/* Do not render the root element if endIcon is not present.
|
|
298
|
-
https://ouryahoo.atlassian.net/browse/UD-1447 */}
|
|
299
|
-
{endIcon && (
|
|
300
|
-
<HStack alignItems="center" gap="1">
|
|
301
|
-
<EndIcon icon={endIcon} className={classNames.endIcon} iconProps={slotProps?.endIcon} />
|
|
302
|
-
</HStack>
|
|
303
|
-
)}
|
|
304
|
-
</Box>
|
|
305
|
-
|
|
306
|
-
<AnimateHeightChange reduceMotion={reduceMotion} layoutVariant={layoutVariant}>
|
|
307
|
-
<HelpTextContent
|
|
308
|
-
id={helpTextId}
|
|
309
|
-
helpText={helpText}
|
|
310
|
-
spacingTop="2"
|
|
311
|
-
size={size}
|
|
312
|
-
isFilled={!!value}
|
|
313
|
-
helperTextIcon={helperTextIcon}
|
|
314
|
-
/>
|
|
315
|
-
</AnimateHeightChange>
|
|
316
|
-
</VStack>
|
|
317
|
-
);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// Need to re-set this because of the forwardRef wrapper
|
|
321
|
-
Input.displayName = 'Input';
|
|
322
|
-
|
|
323
|
-
export { Input, type InputProps };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getStyles } from '../../../styles/styler';
|
|
2
|
-
import { Box } from '../../Box';
|
|
3
|
-
import type { InputHelpTextInternalProps } from './InputHelpTextInternal';
|
|
4
|
-
import { InputHelpTextInternal } from './InputHelpTextInternal';
|
|
5
|
-
|
|
6
|
-
type InputHelpTextProps = InputHelpTextInternalProps;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* **📦 A component that displays helper text for input fields.**
|
|
10
|
-
*
|
|
11
|
-
* @componentType Client component
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* A component that displays helper text for input fields.
|
|
15
|
-
*
|
|
16
|
-
* @see
|
|
17
|
-
* Check out the {@link https://uds.build/docs/components/input Input Docs} for more info
|
|
18
|
-
*
|
|
19
|
-
* @usage
|
|
20
|
-
* - Help text that isn't tied to a specific Input.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* 'use client';
|
|
25
|
-
* import { InputHelpText } from "@yahoo/uds";
|
|
26
|
-
*
|
|
27
|
-
* <InputHelpText>
|
|
28
|
-
* This is some helper text for the input field.
|
|
29
|
-
* </InputHelpText>
|
|
30
|
-
*```
|
|
31
|
-
*
|
|
32
|
-
* @related [Input](https://uds.build/docs/components/input).
|
|
33
|
-
**/
|
|
34
|
-
const InputHelpText = ({ size = 'md', isFilled, ...props }: InputHelpTextProps) => {
|
|
35
|
-
const classNames = {
|
|
36
|
-
root: getStyles({
|
|
37
|
-
inputSizeRoot: size,
|
|
38
|
-
inputVariantRoot: 'default',
|
|
39
|
-
inputVariantValueRoot: !isFilled ? 'empty' : 'filled',
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Box asChild spacingTop="2" className={classNames.root}>
|
|
45
|
-
<InputHelpTextInternal size={size} isFilled={isFilled} {...props} />
|
|
46
|
-
</Box>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
InputHelpText.displayName = 'InputHelpText';
|
|
51
|
-
|
|
52
|
-
export { InputHelpText, type InputHelpTextProps };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
|
|
4
|
-
import { cx, getStyles } from '../../../styles/styler';
|
|
5
|
-
import type { UniversalIconSlot } from '../../../tokens';
|
|
6
|
-
import { HStack } from '../../HStack';
|
|
7
|
-
import type { IconProps } from '../../Icon';
|
|
8
|
-
import { IconSlot } from '../../IconSlot';
|
|
9
|
-
import type { InputProps } from './Input';
|
|
10
|
-
|
|
11
|
-
interface InputHelpTextInternalProps extends PropsWithChildren {
|
|
12
|
-
/** Icon to render at the start of the content */
|
|
13
|
-
startIcon?: UniversalIconSlot;
|
|
14
|
-
/** Icon to render at the end of the content */
|
|
15
|
-
endIcon?: UniversalIconSlot;
|
|
16
|
-
/**
|
|
17
|
-
* Props to pass to the start/end icon. If color is not provided, the icons
|
|
18
|
-
* will inherit the color from the `color` prop.
|
|
19
|
-
*/
|
|
20
|
-
iconProps?: Pick<IconProps, 'color' | 'size' | 'variant'>;
|
|
21
|
-
size?: InputProps['size'];
|
|
22
|
-
isFilled?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function InputHelpTextInternal({
|
|
26
|
-
startIcon,
|
|
27
|
-
endIcon,
|
|
28
|
-
iconProps,
|
|
29
|
-
children,
|
|
30
|
-
size,
|
|
31
|
-
isFilled,
|
|
32
|
-
...rest
|
|
33
|
-
}: InputHelpTextInternalProps) {
|
|
34
|
-
const defaultIconProps = {
|
|
35
|
-
variant: 'outline',
|
|
36
|
-
} satisfies InputHelpTextInternalProps['iconProps'];
|
|
37
|
-
|
|
38
|
-
const classNames = {
|
|
39
|
-
helperText: cx(
|
|
40
|
-
getStyles({
|
|
41
|
-
inputSizeHelperText: size,
|
|
42
|
-
inputVariantHelperText: 'default',
|
|
43
|
-
inputVariantValueHelperText: !isFilled ? 'empty' : 'filled',
|
|
44
|
-
}),
|
|
45
|
-
),
|
|
46
|
-
helperIcon: getStyles({
|
|
47
|
-
inputSizeHelperIcon: size,
|
|
48
|
-
inputVariantHelperIcon: 'default',
|
|
49
|
-
inputVariantValueHelperIcon: !isFilled ? 'empty' : 'filled',
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const props = { ...defaultIconProps, ...iconProps };
|
|
54
|
-
return (
|
|
55
|
-
<HStack gap="1" alignItems="center" {...rest}>
|
|
56
|
-
{startIcon && (
|
|
57
|
-
<IconSlot
|
|
58
|
-
icon={startIcon}
|
|
59
|
-
{...props}
|
|
60
|
-
iconProps={iconProps}
|
|
61
|
-
className={classNames.helperIcon}
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
<span className={classNames.helperText}>{children}</span>
|
|
65
|
-
{endIcon && (
|
|
66
|
-
<IconSlot
|
|
67
|
-
icon={endIcon}
|
|
68
|
-
{...props}
|
|
69
|
-
iconProps={iconProps}
|
|
70
|
-
className={classNames.helperIcon}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
</HStack>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
InputHelpTextInternal.displayName = 'InputHelpTextInternal';
|
|
78
|
-
|
|
79
|
-
const InputHelpTextInternalMemo = memo(InputHelpTextInternal);
|
|
80
|
-
|
|
81
|
-
export { InputHelpTextInternalMemo as InputHelpTextInternal, type InputHelpTextInternalProps };
|