@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,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts an object into an array of key-value pair entries.
|
|
3
|
-
*
|
|
4
|
-
* This function takes an object `item` and returns an array of its own enumerable
|
|
5
|
-
* property `[key, value]` pairs, where `key` is a string. The generic type `T` represents
|
|
6
|
-
* the type of the input object. The return type is an array of tuples, where each tuple
|
|
7
|
-
* consists of a string key and a value corresponding to the type of values in `T`.
|
|
8
|
-
*/
|
|
9
|
-
export function entries<T>(item: T) {
|
|
10
|
-
return Object.entries(item as Record<string, unknown>) as [
|
|
11
|
-
Extract<keyof T, string>,
|
|
12
|
-
T[keyof T],
|
|
13
|
-
][];
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts an array of key-value pair entries into an object.
|
|
3
|
-
*
|
|
4
|
-
* This function takes an array of `[key, value]` pairs and converts it into an object
|
|
5
|
-
* where each key is associated with its corresponding value. The generic types `T` and `K`
|
|
6
|
-
* represent the types of the keys and values, respectively. The keys are constrained to
|
|
7
|
-
* be strings.
|
|
8
|
-
*/
|
|
9
|
-
export function fromEntries<T extends string, K>(item: [T, K][] | (readonly [T, K])[]) {
|
|
10
|
-
return Object.fromEntries(item) as Record<T, K>;
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type AnyObject = Record<string, unknown>;
|
|
2
|
-
|
|
3
|
-
export function mapValues<
|
|
4
|
-
T extends AnyObject,
|
|
5
|
-
K extends (value: T[keyof T], key: keyof T, i: number) => unknown,
|
|
6
|
-
>(obj: T, callbackFn: K) {
|
|
7
|
-
return Object.keys(obj).reduce(
|
|
8
|
-
(acc, key: keyof T, i) => {
|
|
9
|
-
acc[key] = callbackFn(obj[key], key, i) as ReturnType<typeof callbackFn>;
|
|
10
|
-
return acc;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
{} as { [key in keyof T]: ReturnType<K> },
|
|
14
|
-
);
|
|
15
|
-
}
|
package/src/types.ts
DELETED
package/src/utils/composeRefs.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Set a given ref to a given value
|
|
5
|
-
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
|
6
|
-
*/
|
|
7
|
-
function setRef<T>(ref: PossibleRef<T>, value: T) {
|
|
8
|
-
if (typeof ref === 'function') {
|
|
9
|
-
ref(value);
|
|
10
|
-
} else if (ref !== null && ref !== undefined) {
|
|
11
|
-
(ref as React.MutableRefObject<T>).current = value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A utility to compose multiple refs together
|
|
17
|
-
* Accepts callback refs and RefObject(s)
|
|
18
|
-
*/
|
|
19
|
-
function composeRefs<T>(...refs: PossibleRef<T>[]) {
|
|
20
|
-
return (node: T) => refs.forEach((ref) => setRef(ref, node));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { composeRefs };
|
package/src/utils/createSlot.tsx
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Essentially @radix-ui/react-slot typed as a generic we can use with asChild
|
|
5
|
-
* @link: https://www.radix-ui.com/primitives/docs/utilities/slot
|
|
6
|
-
**/
|
|
7
|
-
|
|
8
|
-
/* -------------------------------------------------------------------------- */
|
|
9
|
-
/* Slot */
|
|
10
|
-
/* -------------------------------------------------------------------------- */
|
|
11
|
-
|
|
12
|
-
import { Children, cloneElement, forwardRef, isValidElement } from 'react';
|
|
13
|
-
|
|
14
|
-
import { composeRefs } from './composeRefs';
|
|
15
|
-
|
|
16
|
-
export function createSlot<T extends React.ComponentType<{ children?: any }>>() {
|
|
17
|
-
type SlotProps = React.ComponentPropsWithRef<T>;
|
|
18
|
-
// TODO: reenable react/prop-types. See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/70361
|
|
19
|
-
const Slot = forwardRef<T, SlotProps>((props, forwardedRef) => {
|
|
20
|
-
const { children, ...slotProps } = props;
|
|
21
|
-
const childrenArray = Children.toArray(children);
|
|
22
|
-
const slottable = childrenArray.find(isSlottable);
|
|
23
|
-
|
|
24
|
-
if (slottable) {
|
|
25
|
-
// the new element to render is the one passed as a child of `Slottable`
|
|
26
|
-
const newElement = slottable.props.children as React.ReactNode;
|
|
27
|
-
|
|
28
|
-
const newChildren = childrenArray.map((child) => {
|
|
29
|
-
if (child === slottable) {
|
|
30
|
-
// because the new element will be the one rendered, we are only interested
|
|
31
|
-
// in grabbing its children (`newElement.props.children`)
|
|
32
|
-
if (Children.count(newElement) > 1) {
|
|
33
|
-
return Children.only(null);
|
|
34
|
-
}
|
|
35
|
-
return isValidElement(newElement) ? (newElement.props.children as React.ReactNode) : null;
|
|
36
|
-
} else {
|
|
37
|
-
return child;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<SlotClone {...slotProps} ref={forwardedRef}>
|
|
43
|
-
{isValidElement(newElement) ? cloneElement(newElement, undefined, newChildren) : null}
|
|
44
|
-
</SlotClone>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<SlotClone {...slotProps} ref={forwardedRef}>
|
|
50
|
-
{children}
|
|
51
|
-
</SlotClone>
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
Slot.displayName = 'Slot';
|
|
56
|
-
|
|
57
|
-
/* -------------------------------------------------------------------------- */
|
|
58
|
-
/* SlotClone */
|
|
59
|
-
/* -------------------------------------------------------------------------- */
|
|
60
|
-
|
|
61
|
-
interface SlotCloneProps {
|
|
62
|
-
children: React.ReactNode;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// eslint-disable-next-line react/no-multi-comp
|
|
66
|
-
const SlotClone = forwardRef<any, SlotCloneProps>((props: SlotCloneProps, forwardedRef) => {
|
|
67
|
-
const { children, ...slotProps } = props;
|
|
68
|
-
|
|
69
|
-
if (isValidElement(children)) {
|
|
70
|
-
return cloneElement(children, {
|
|
71
|
-
...mergeProps(slotProps, children.props),
|
|
72
|
-
ref: forwardedRef
|
|
73
|
-
? composeRefs(forwardedRef, (children as any).ref)
|
|
74
|
-
: (children as any).ref,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return Children.count(children) > 1 ? Children.only(null) : null;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
SlotClone.displayName = 'SlotClone';
|
|
82
|
-
|
|
83
|
-
/* -------------------------------------------------------------------------- */
|
|
84
|
-
/* Slottable */
|
|
85
|
-
/* -------------------------------------------------------------------------- */
|
|
86
|
-
|
|
87
|
-
const Slottable = ({ children }: { children: React.ReactNode }) => {
|
|
88
|
-
return children;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/* ---------------------------------------------------------------------------------------------- */
|
|
92
|
-
|
|
93
|
-
type AnyProps = Record<string, any>;
|
|
94
|
-
|
|
95
|
-
function isSlottable(child: React.ReactNode): child is React.ReactElement {
|
|
96
|
-
return isValidElement(child) && child.type === Slottable;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function mergeProps(slotProps: AnyProps, childProps: AnyProps) {
|
|
100
|
-
// all child props should override
|
|
101
|
-
const overrideProps = { ...childProps };
|
|
102
|
-
|
|
103
|
-
for (const propName in childProps) {
|
|
104
|
-
const slotPropValue = slotProps[propName];
|
|
105
|
-
const childPropValue = childProps[propName];
|
|
106
|
-
|
|
107
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
108
|
-
if (isHandler) {
|
|
109
|
-
// if the handler exists on both, we compose them
|
|
110
|
-
if (slotPropValue && childPropValue) {
|
|
111
|
-
overrideProps[propName] = (...args: unknown[]) => {
|
|
112
|
-
childPropValue(...args);
|
|
113
|
-
slotPropValue(...args);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
// but if it exists only on the slot, we use only this one
|
|
117
|
-
else if (slotPropValue) {
|
|
118
|
-
overrideProps[propName] = slotPropValue;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// if it's `style`, we merge them
|
|
122
|
-
else if (propName === 'style') {
|
|
123
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return { ...slotProps, ...overrideProps };
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return Slot as unknown as T;
|
|
131
|
-
}
|
package/src/utils/entries.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MotionSpringConfigOptions,
|
|
3
|
-
MotionVariant,
|
|
4
|
-
MotionVariantSpeed,
|
|
5
|
-
} from '@yahoo/uds/tokens';
|
|
6
|
-
import { MOTION_PREFIX } from '@yahoo/uds/tokens';
|
|
7
|
-
|
|
8
|
-
export interface GetMotionVarParams {
|
|
9
|
-
variant: MotionVariant;
|
|
10
|
-
speed: MotionVariantSpeed;
|
|
11
|
-
control: MotionSpringConfigOptions;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getMotionVar({ variant, speed, control }: GetMotionVarParams) {
|
|
15
|
-
const cssVar = [`--${MOTION_PREFIX}`, variant, speed, control].join('-');
|
|
16
|
-
|
|
17
|
-
return `${cssVar}` as const;
|
|
18
|
-
}
|
package/src/utils/intersperse.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { isFunction } from 'lodash';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
import { Children, cloneElement, isValidElement } from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Given an array of items, place an item between each of the original values with either a constant
|
|
7
|
-
* value or the result of a function which knows the index it is being inserted before.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const ANIMALS = ["Lions", "Tigers", "Bears"];
|
|
11
|
-
* const animalesInterspersedWithAmpersands = intersperse(ANIMALS, "&");
|
|
12
|
-
* // ["Lions", "&", "Tigers", "&", "Bears"]
|
|
13
|
-
* console.log(animalesInterspersedWithAmpersands.join(" ") + '. OH MY!');
|
|
14
|
-
*/
|
|
15
|
-
export const intersperse = <T>(list: Array<T>, inter: T | ((index: number) => T)) => {
|
|
16
|
-
const interFn: (index: number) => T = isFunction(inter) ? inter : () => inter;
|
|
17
|
-
return list.flatMap((item, i) => (i !== 0 ? [interFn(i), item] : [item]));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Given ReactNode, if it is a list of children nodes, place a new React node between each of the
|
|
22
|
-
* original nodes with either a constant ReactElement or the result of a function which knows the
|
|
23
|
-
* index it is being inserted before.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* const SplitParagraphsWithHorizontalRule = ({ paragraphs }: { paragraphs: string[] }) => {
|
|
27
|
-
* const paragraphNodes = paragraphs.map((str) => <p>{str}</p>);
|
|
28
|
-
*
|
|
29
|
-
* return (<div>
|
|
30
|
-
* {intersperseReactChildren(paragraphNodes, <hr />)}
|
|
31
|
-
* </div>);
|
|
32
|
-
* }
|
|
33
|
-
*/
|
|
34
|
-
export const intersperseReactChildren = (
|
|
35
|
-
children: ReactNode,
|
|
36
|
-
inter: ReactNode | ((index: number) => ReactNode),
|
|
37
|
-
) => {
|
|
38
|
-
return intersperse(Children.toArray(children), (i) => {
|
|
39
|
-
const node = isFunction(inter) ? inter(i) : inter;
|
|
40
|
-
|
|
41
|
-
return isValidElement(node)
|
|
42
|
-
? cloneElement(node, { ...node.props, key: node.key ?? `interspersed-${i}` })
|
|
43
|
-
: null;
|
|
44
|
-
});
|
|
45
|
-
};
|
package/src/utils/mapValues.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type AnyObject = Record<string, unknown>;
|
|
2
|
-
|
|
3
|
-
export function mapValues<
|
|
4
|
-
T extends AnyObject,
|
|
5
|
-
K extends (value: T[keyof T], key: keyof T, i: number) => unknown,
|
|
6
|
-
>(obj: T, callbackFn: K) {
|
|
7
|
-
return Object.keys(obj).reduce(
|
|
8
|
-
(acc, key: keyof T, i) => {
|
|
9
|
-
acc[key] = callbackFn(obj[key], key, i) as ReturnType<typeof callbackFn>;
|
|
10
|
-
return acc;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
{} as { [key in keyof T]: ReturnType<K> },
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { cx } from '../styles/styler';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
const mergeSlotProp = <T extends Partial<Record<string, any>>>(
|
|
5
|
-
slotProp: T | undefined,
|
|
6
|
-
newSlotProp: T | undefined,
|
|
7
|
-
onConflict: 'overwriteOriginal' | 'keepOriginal' = 'overwriteOriginal',
|
|
8
|
-
): T => {
|
|
9
|
-
const allKeys = Array.from(
|
|
10
|
-
new Set([...Object.keys(slotProp ?? {}), ...Object.keys(newSlotProp ?? {})]),
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
return Object.fromEntries(
|
|
14
|
-
allKeys.map((key) => {
|
|
15
|
-
const originalValue = slotProp?.[key];
|
|
16
|
-
const newValue = newSlotProp?.[key];
|
|
17
|
-
|
|
18
|
-
if (originalValue && !newValue) {
|
|
19
|
-
return [key, originalValue] as const;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (newValue && !originalValue) {
|
|
23
|
-
return [key, newValue] as const;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (key === 'className') {
|
|
27
|
-
return [key, cx(originalValue, newValue)] as const;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (onConflict === 'keepOriginal') {
|
|
31
|
-
return [key, originalValue] as const;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// else overwriteOriginal
|
|
35
|
-
return [key, newValue] as const;
|
|
36
|
-
}),
|
|
37
|
-
) as T;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const mergeSlotProps = <
|
|
41
|
-
T1 extends {
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
[K in keyof T1]?: Record<string, any>;
|
|
44
|
-
},
|
|
45
|
-
T2 extends {
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
[K in keyof T2]?: Record<string, any>;
|
|
48
|
-
},
|
|
49
|
-
>(
|
|
50
|
-
slotProps: T1 | undefined,
|
|
51
|
-
newProps: T2,
|
|
52
|
-
onConflict: 'overwriteOriginal' | 'keepOriginal' = 'overwriteOriginal',
|
|
53
|
-
): (T1 & T2) | undefined => {
|
|
54
|
-
if (!slotProps) {
|
|
55
|
-
return newProps as T1 & T2;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const allKeys = Array.from(new Set([...Object.keys(slotProps), ...Object.keys(newProps)]));
|
|
59
|
-
|
|
60
|
-
return Object.fromEntries(
|
|
61
|
-
allKeys.map((key) => {
|
|
62
|
-
const originalValue = slotProps[key as keyof T1];
|
|
63
|
-
const newValue = newProps[key as keyof T2];
|
|
64
|
-
|
|
65
|
-
return [key, mergeSlotProp(originalValue, newValue, onConflict)] as const;
|
|
66
|
-
}),
|
|
67
|
-
) as T1 & T2;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export { mergeSlotProp, mergeSlotProps };
|