@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/styles/styler.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
backgroundColors,
|
|
3
|
-
borderRadii,
|
|
4
|
-
borderWidths,
|
|
5
|
-
foregroundColors,
|
|
6
|
-
lineColors,
|
|
7
|
-
spectrumColors,
|
|
8
|
-
textVariants,
|
|
9
|
-
} from '@yahoo/uds/fixtures';
|
|
10
|
-
import { clsx } from 'clsx';
|
|
11
|
-
import { extendTailwindMerge } from 'tailwind-merge';
|
|
12
|
-
|
|
13
|
-
import { getFeatureFlags } from '../flags';
|
|
14
|
-
import { falsyToString } from '../utils/falsyToString';
|
|
15
|
-
import type { CVA, CX } from './stylerTypes';
|
|
16
|
-
import { variants } from './variants';
|
|
17
|
-
|
|
18
|
-
const createObjectWithoutPrototype = <T>(): T => Object.create(null) as T;
|
|
19
|
-
|
|
20
|
-
const { useGetStylesCache, skipTailwindMerge } = getFeatureFlags();
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Prepare and object for memoization
|
|
24
|
-
* Code uses old-school JS to hyper optimize component rendering hot paths.
|
|
25
|
-
**/
|
|
26
|
-
function normalizeObject(props: Record<string, unknown>) {
|
|
27
|
-
const sorted = createObjectWithoutPrototype<typeof props>();
|
|
28
|
-
const sortedKeys = Object.keys(props).sort();
|
|
29
|
-
|
|
30
|
-
for (let i = 0, len = sortedKeys.length; i < len; i++) {
|
|
31
|
-
const key = sortedKeys[i];
|
|
32
|
-
|
|
33
|
-
if (props[key] !== undefined) {
|
|
34
|
-
sorted[key] = props[key];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return sorted;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const twMerge = extendTailwindMerge({
|
|
42
|
-
extend: {
|
|
43
|
-
theme: {
|
|
44
|
-
borderColor: lineColors,
|
|
45
|
-
borderWidth: borderWidths,
|
|
46
|
-
borderRadius: borderRadii,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
override: {
|
|
50
|
-
classGroups: {
|
|
51
|
-
'text-color': [{ text: [...foregroundColors, ...spectrumColors] }],
|
|
52
|
-
'bg-color': [{ bg: backgroundColors }],
|
|
53
|
-
'font-family': [{ font: ['icons', ...textVariants] }],
|
|
54
|
-
leading: [{ leading: textVariants }],
|
|
55
|
-
},
|
|
56
|
-
conflictingClassGroups: {},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const cx: CX<string> = (...inputs) => {
|
|
61
|
-
const finalClassName = clsx(inputs);
|
|
62
|
-
return skipTailwindMerge ? finalClassName : twMerge(finalClassName);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const cva: CVA<string> = (config) => {
|
|
66
|
-
const { base, variants, defaultVariants, compoundVariants } = config;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* !WARNING
|
|
70
|
-
* This is a VERY performance-sensitive function. Do not change it
|
|
71
|
-
* without benchmarking first.
|
|
72
|
-
*/
|
|
73
|
-
return (maybeProps): string => {
|
|
74
|
-
if (!maybeProps) {
|
|
75
|
-
return cx(base);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const { className, ...props } = maybeProps;
|
|
79
|
-
|
|
80
|
-
if (!variants) {
|
|
81
|
-
return cx(base, className);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Using old-school for loop for performance (doesn't create intermediate arrays)
|
|
85
|
-
const variantClassNames: string[] = [];
|
|
86
|
-
|
|
87
|
-
for (const prop in defaultVariants) {
|
|
88
|
-
if (prop === undefined) {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (props[prop] !== undefined) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const defaultPropValue = defaultVariants[prop];
|
|
97
|
-
const variantKey = falsyToString(defaultPropValue) as keyof (typeof variants)[typeof prop];
|
|
98
|
-
variantClassNames.push(variants[prop][variantKey]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
for (const prop in props) {
|
|
102
|
-
if (prop === undefined) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const propValue = props[prop];
|
|
107
|
-
const variantKey = falsyToString(propValue) as keyof (typeof variants)[typeof prop];
|
|
108
|
-
variantClassNames.push(variants[prop][variantKey]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!compoundVariants) {
|
|
112
|
-
return cx(base, variantClassNames, className);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let compoundVariantClassNames = '';
|
|
116
|
-
|
|
117
|
-
// Using old-school for loop for performance (doesn't create intermediate arrays)
|
|
118
|
-
for (const compoundConfig of compoundVariants) {
|
|
119
|
-
const { className: compoundClassname, ...compoundVariantConfig } = compoundConfig;
|
|
120
|
-
|
|
121
|
-
let allMatch = true;
|
|
122
|
-
for (const cvKey in compoundVariantConfig) {
|
|
123
|
-
const cvValue = compoundVariantConfig[cvKey];
|
|
124
|
-
const propValue = props[cvKey] ?? defaultVariants?.[cvKey];
|
|
125
|
-
const isMatch = propValue === cvValue;
|
|
126
|
-
|
|
127
|
-
if (!isMatch) {
|
|
128
|
-
allMatch = false;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (allMatch) {
|
|
134
|
-
compoundVariantClassNames = cx(compoundVariantClassNames, compoundClassname);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return cx(base, variantClassNames, compoundVariantClassNames, className);
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const getStylesInternal = cva({
|
|
143
|
-
variants,
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// Extract the type of the props accepted by getStylesInternal
|
|
147
|
-
type GetStylesInternalProps = Parameters<typeof getStylesInternal>[0];
|
|
148
|
-
|
|
149
|
-
const styleCache = new Map<string, string>();
|
|
150
|
-
|
|
151
|
-
const getStylesCacheKeySymbol = Symbol('getStylesCacheKey');
|
|
152
|
-
|
|
153
|
-
const generateCacheKey = (props: Record<string, unknown>): string => {
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
-
if ((props as any)[getStylesCacheKeySymbol]) {
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
-
return (props as any)[getStylesCacheKeySymbol];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const sorted = normalizeObject(props);
|
|
161
|
-
|
|
162
|
-
let cacheKey = '';
|
|
163
|
-
|
|
164
|
-
for (const key in sorted) {
|
|
165
|
-
cacheKey += `${key}:${sorted[key]}|`;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
-
(props as any)[getStylesCacheKeySymbol] = cacheKey; // Cache the key on the props object itself
|
|
170
|
-
|
|
171
|
-
return cacheKey;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const cachedGetStyles = (props: Record<string, unknown>, onHit?: () => void) => {
|
|
175
|
-
if (!useGetStylesCache) {
|
|
176
|
-
return getStylesInternal(props);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const cacheKey = generateCacheKey(props);
|
|
180
|
-
|
|
181
|
-
if (styleCache.has(cacheKey)) {
|
|
182
|
-
onHit?.();
|
|
183
|
-
return styleCache.get(cacheKey)!;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const styles = getStylesInternal(props);
|
|
187
|
-
styleCache.set(cacheKey, styles);
|
|
188
|
-
|
|
189
|
-
return styles;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const getStyles = cachedGetStyles as (props: GetStylesInternalProps, onHit?: () => void) => string;
|
|
193
|
-
|
|
194
|
-
export { cva, cx, getStyles, getStylesCacheKeySymbol, normalizeObject };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { StylePropsVariantsAuto } from '../../generated/autoVariants';
|
|
2
|
-
import type {
|
|
3
|
-
ButtonPalette,
|
|
4
|
-
ButtonSize,
|
|
5
|
-
ButtonVariant,
|
|
6
|
-
ColorMode,
|
|
7
|
-
IconButtonSize,
|
|
8
|
-
ScaleMode,
|
|
9
|
-
StyleProps,
|
|
10
|
-
} from '../tokens/types';
|
|
11
|
-
|
|
12
|
-
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
13
|
-
|
|
14
|
-
type CvaStyleValue<T> = T | CvaStyleArray<T> | Record<string, unknown> | null | boolean | undefined;
|
|
15
|
-
|
|
16
|
-
type CvaStyleArray<T> = CvaStyleValue<T>[];
|
|
17
|
-
|
|
18
|
-
type CVAVariantSchema<T, V extends CVAVariantShape<T>> = {
|
|
19
|
-
[Variant in keyof V]?: StringToBoolean<keyof V[Variant]> | undefined;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type CVAVariantShape<T> = Record<string, Record<string, T>>;
|
|
23
|
-
|
|
24
|
-
type CVAStyleProp<T> = T extends string
|
|
25
|
-
? {
|
|
26
|
-
className?: T;
|
|
27
|
-
}
|
|
28
|
-
: {
|
|
29
|
-
style?: T;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type CVAConfigBase<T> = { base?: T | null };
|
|
33
|
-
|
|
34
|
-
interface CVA<T> {
|
|
35
|
-
<V extends CVAVariantShape<T>>(
|
|
36
|
-
config: V extends CVAVariantShape<T>
|
|
37
|
-
? CVAConfigBase<T> & {
|
|
38
|
-
base?: T;
|
|
39
|
-
variants?: V;
|
|
40
|
-
compoundVariants?: (V extends CVAVariantShape<T>
|
|
41
|
-
? (
|
|
42
|
-
| CVAVariantSchema<T, V>
|
|
43
|
-
| {
|
|
44
|
-
[Variant in keyof V]?: StringToBoolean<keyof V[Variant]> | undefined;
|
|
45
|
-
}
|
|
46
|
-
) &
|
|
47
|
-
CVAStyleProp<T>
|
|
48
|
-
: CVAStyleProp<T>)[];
|
|
49
|
-
defaultVariants?: CVAVariantSchema<T, V>;
|
|
50
|
-
}
|
|
51
|
-
: CVAConfigBase<T> & {
|
|
52
|
-
variants?: never;
|
|
53
|
-
compoundVariants?: never;
|
|
54
|
-
defaultVariants?: never;
|
|
55
|
-
},
|
|
56
|
-
): (
|
|
57
|
-
props?: V extends CVAVariantShape<T>
|
|
58
|
-
? CVAVariantSchema<T, V> & CVAStyleProp<T>
|
|
59
|
-
: CVAStyleProp<T>,
|
|
60
|
-
) => T;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface CX<T> {
|
|
64
|
-
(...inputs: CvaStyleValue<T>[]): T;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
type StylePropsVariants<ReturnType> = {
|
|
68
|
-
[key in keyof Required<StyleProps>]: Record<
|
|
69
|
-
Exclude<`${StyleProps[key]}`, 'undefined' | 'false'>,
|
|
70
|
-
ReturnType
|
|
71
|
-
>;
|
|
72
|
-
} & {
|
|
73
|
-
colorMode: Record<ColorMode, string>;
|
|
74
|
-
scaleMode: Record<ScaleMode, string>;
|
|
75
|
-
buttonPalette: Record<ButtonPalette, string>;
|
|
76
|
-
buttonVariant: Record<ButtonVariant, string>;
|
|
77
|
-
buttonSize: Record<ButtonSize, string>;
|
|
78
|
-
iconButtonSize: Record<IconButtonSize, string>;
|
|
79
|
-
} & StylePropsVariantsAuto<ReturnType>;
|
|
80
|
-
|
|
81
|
-
export { type CVA, type CX, type StylePropsVariants };
|
package/src/styles/toast.css
DELETED
|
File without changes
|