@yahoo/uds-mobile 1.0.0
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/CONTRIBUTING.md +1174 -0
- package/README.md +614 -0
- package/cli/uds-mobile.js +10 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/bin/generateTheme.mjs +390 -0
- package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +74 -0
- package/dist/bin/uds/dist/fixtures.mjs +404 -0
- package/dist/bin/uds/dist/tokens/configs/palette/alwaysPalette.mjs +23 -0
- package/dist/bin/uds/dist/tokens/consts/defaultModes.mjs +6 -0
- package/dist/bin/uds/dist/tokens/consts/fontDeclarationsMap.mjs +652 -0
- package/dist/bin/uds-mobile.mjs +256 -0
- package/dist/components/Avatar.cjs +109 -0
- package/dist/components/Avatar.d.cts +60 -0
- package/dist/components/Avatar.d.cts.map +1 -0
- package/dist/components/Avatar.d.mts +60 -0
- package/dist/components/Avatar.d.mts.map +1 -0
- package/dist/components/Avatar.mjs +109 -0
- package/dist/components/Avatar.mjs.map +1 -0
- package/dist/components/Badge.cjs +68 -0
- package/dist/components/Badge.d.cts +43 -0
- package/dist/components/Badge.d.cts.map +1 -0
- package/dist/components/Badge.d.mts +43 -0
- package/dist/components/Badge.d.mts.map +1 -0
- package/dist/components/Badge.mjs +68 -0
- package/dist/components/Badge.mjs.map +1 -0
- package/dist/components/Box.cjs +114 -0
- package/dist/components/Box.d.cts +87 -0
- package/dist/components/Box.d.cts.map +1 -0
- package/dist/components/Box.d.mts +87 -0
- package/dist/components/Box.d.mts.map +1 -0
- package/dist/components/Box.mjs +114 -0
- package/dist/components/Box.mjs.map +1 -0
- package/dist/components/Button.cjs +187 -0
- package/dist/components/Button.d.cts +56 -0
- package/dist/components/Button.d.cts.map +1 -0
- package/dist/components/Button.d.mts +56 -0
- package/dist/components/Button.d.mts.map +1 -0
- package/dist/components/Button.mjs +186 -0
- package/dist/components/Button.mjs.map +1 -0
- package/dist/components/Checkbox.cjs +156 -0
- package/dist/components/Checkbox.d.cts +48 -0
- package/dist/components/Checkbox.d.cts.map +1 -0
- package/dist/components/Checkbox.d.mts +48 -0
- package/dist/components/Checkbox.d.mts.map +1 -0
- package/dist/components/Checkbox.mjs +155 -0
- package/dist/components/Checkbox.mjs.map +1 -0
- package/dist/components/Chip.cjs +124 -0
- package/dist/components/Chip.d.cts +60 -0
- package/dist/components/Chip.d.cts.map +1 -0
- package/dist/components/Chip.d.mts +60 -0
- package/dist/components/Chip.d.mts.map +1 -0
- package/dist/components/Chip.mjs +124 -0
- package/dist/components/Chip.mjs.map +1 -0
- package/dist/components/HStack.cjs +46 -0
- package/dist/components/HStack.d.cts +41 -0
- package/dist/components/HStack.d.cts.map +1 -0
- package/dist/components/HStack.d.mts +41 -0
- package/dist/components/HStack.d.mts.map +1 -0
- package/dist/components/HStack.mjs +46 -0
- package/dist/components/HStack.mjs.map +1 -0
- package/dist/components/Icon.cjs +150 -0
- package/dist/components/Icon.d.cts +90 -0
- package/dist/components/Icon.d.cts.map +1 -0
- package/dist/components/Icon.d.mts +90 -0
- package/dist/components/Icon.d.mts.map +1 -0
- package/dist/components/Icon.mjs +148 -0
- package/dist/components/Icon.mjs.map +1 -0
- package/dist/components/IconButton.cjs +127 -0
- package/dist/components/IconButton.d.cts +46 -0
- package/dist/components/IconButton.d.cts.map +1 -0
- package/dist/components/IconButton.d.mts +46 -0
- package/dist/components/IconButton.d.mts.map +1 -0
- package/dist/components/IconButton.mjs +127 -0
- package/dist/components/IconButton.mjs.map +1 -0
- package/dist/components/IconSlot.cjs +55 -0
- package/dist/components/IconSlot.d.cts +45 -0
- package/dist/components/IconSlot.d.cts.map +1 -0
- package/dist/components/IconSlot.d.mts +45 -0
- package/dist/components/IconSlot.d.mts.map +1 -0
- package/dist/components/IconSlot.mjs +55 -0
- package/dist/components/IconSlot.mjs.map +1 -0
- package/dist/components/Image.cjs +104 -0
- package/dist/components/Image.d.cts +85 -0
- package/dist/components/Image.d.cts.map +1 -0
- package/dist/components/Image.d.mts +85 -0
- package/dist/components/Image.d.mts.map +1 -0
- package/dist/components/Image.mjs +104 -0
- package/dist/components/Image.mjs.map +1 -0
- package/dist/components/Input.cjs +174 -0
- package/dist/components/Input.d.cts +39 -0
- package/dist/components/Input.d.cts.map +1 -0
- package/dist/components/Input.d.mts +39 -0
- package/dist/components/Input.d.mts.map +1 -0
- package/dist/components/Input.mjs +174 -0
- package/dist/components/Input.mjs.map +1 -0
- package/dist/components/Link.cjs +139 -0
- package/dist/components/Link.d.cts +45 -0
- package/dist/components/Link.d.cts.map +1 -0
- package/dist/components/Link.d.mts +45 -0
- package/dist/components/Link.d.mts.map +1 -0
- package/dist/components/Link.mjs +138 -0
- package/dist/components/Link.mjs.map +1 -0
- package/dist/components/Pressable.cjs +120 -0
- package/dist/components/Pressable.d.cts +90 -0
- package/dist/components/Pressable.d.cts.map +1 -0
- package/dist/components/Pressable.d.mts +90 -0
- package/dist/components/Pressable.d.mts.map +1 -0
- package/dist/components/Pressable.mjs +118 -0
- package/dist/components/Pressable.mjs.map +1 -0
- package/dist/components/Radio.cjs +153 -0
- package/dist/components/Radio.d.cts +46 -0
- package/dist/components/Radio.d.cts.map +1 -0
- package/dist/components/Radio.d.mts +46 -0
- package/dist/components/Radio.d.mts.map +1 -0
- package/dist/components/Radio.mjs +152 -0
- package/dist/components/Radio.mjs.map +1 -0
- package/dist/components/Screen.cjs +89 -0
- package/dist/components/Screen.d.cts +53 -0
- package/dist/components/Screen.d.cts.map +1 -0
- package/dist/components/Screen.d.mts +53 -0
- package/dist/components/Screen.d.mts.map +1 -0
- package/dist/components/Screen.mjs +89 -0
- package/dist/components/Screen.mjs.map +1 -0
- package/dist/components/Switch.cjs +172 -0
- package/dist/components/Switch.d.cts +42 -0
- package/dist/components/Switch.d.cts.map +1 -0
- package/dist/components/Switch.d.mts +42 -0
- package/dist/components/Switch.d.mts.map +1 -0
- package/dist/components/Switch.mjs +171 -0
- package/dist/components/Switch.mjs.map +1 -0
- package/dist/components/Text.cjs +107 -0
- package/dist/components/Text.d.cts +96 -0
- package/dist/components/Text.d.cts.map +1 -0
- package/dist/components/Text.d.mts +96 -0
- package/dist/components/Text.d.mts.map +1 -0
- package/dist/components/Text.mjs +107 -0
- package/dist/components/Text.mjs.map +1 -0
- package/dist/components/VStack.cjs +46 -0
- package/dist/components/VStack.d.cts +41 -0
- package/dist/components/VStack.d.cts.map +1 -0
- package/dist/components/VStack.d.mts +41 -0
- package/dist/components/VStack.d.mts.map +1 -0
- package/dist/components/VStack.mjs +46 -0
- package/dist/components/VStack.mjs.map +1 -0
- package/dist/icons/dist/glyphMap.cjs +5475 -0
- package/dist/icons/dist/glyphMap.d.cts +10 -0
- package/dist/icons/dist/glyphMap.d.cts.map +1 -0
- package/dist/icons/dist/glyphMap.d.mts +10 -0
- package/dist/icons/dist/glyphMap.d.mts.map +1 -0
- package/dist/icons/dist/glyphMap.mjs +5474 -0
- package/dist/icons/dist/glyphMap.mjs.map +1 -0
- package/dist/icons/dist/svgMap.cjs +525 -0
- package/dist/icons/dist/svgMap.d.cts +10 -0
- package/dist/icons/dist/svgMap.d.cts.map +1 -0
- package/dist/icons/dist/svgMap.d.mts +10 -0
- package/dist/icons/dist/svgMap.d.mts.map +1 -0
- package/dist/icons/dist/svgMap.mjs +524 -0
- package/dist/icons/dist/svgMap.mjs.map +1 -0
- package/dist/icons/dist/tokens.cjs +13 -0
- package/dist/icons/dist/tokens.mjs +13 -0
- package/dist/icons/dist/tokens.mjs.map +1 -0
- package/dist/icons/dist/types.d.cts +24 -0
- package/dist/icons/dist/types.d.cts.map +1 -0
- package/dist/icons/dist/types.d.mts +24 -0
- package/dist/icons/dist/types.d.mts.map +1 -0
- package/dist/motion.cjs +56 -0
- package/dist/motion.d.cts +46 -0
- package/dist/motion.d.cts.map +1 -0
- package/dist/motion.d.mts +46 -0
- package/dist/motion.d.mts.map +1 -0
- package/dist/motion.mjs +52 -0
- package/dist/motion.mjs.map +1 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.cts +13 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +13 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/uds/dist/components/Box.d.cts +3 -0
- package/dist/uds/dist/components/Box.d.mts +3 -0
- package/dist/uds/dist/components/Divider/Divider.d.cts +3 -0
- package/dist/uds/dist/components/Divider/Divider.d.mts +3 -0
- package/dist/uds/dist/components/Divider/DividerCore.d.cts +4 -0
- package/dist/uds/dist/components/Divider/DividerCore.d.mts +4 -0
- package/dist/uds/dist/components/Divider/DividerInternal.d.cts +4 -0
- package/dist/uds/dist/components/Divider/DividerInternal.d.mts +4 -0
- package/dist/uds/dist/components/Divider/index.d.cts +2 -0
- package/dist/uds/dist/components/Divider/index.d.mts +2 -0
- package/dist/uds/dist/components/FormLabel.d.cts +3 -0
- package/dist/uds/dist/components/FormLabel.d.mts +4 -0
- package/dist/uds/dist/components/HStack.d.cts +4 -0
- package/dist/uds/dist/components/HStack.d.mts +4 -0
- package/dist/uds/dist/components/Icon.d.cts +3 -0
- package/dist/uds/dist/components/Icon.d.mts +3 -0
- package/dist/uds/dist/components/Image.d.cts +2 -0
- package/dist/uds/dist/components/Image.d.mts +3 -0
- package/dist/uds/dist/components/Link.d.cts +3 -0
- package/dist/uds/dist/components/Link.d.mts +3 -0
- package/dist/uds/dist/components/Text.d.cts +3 -0
- package/dist/uds/dist/components/Text.d.mts +3 -0
- package/dist/uds/dist/components/VStack.d.cts +4 -0
- package/dist/uds/dist/components/VStack.d.mts +4 -0
- package/dist/uds/dist/components/client/Avatar/Avatar.d.cts +2 -0
- package/dist/uds/dist/components/client/Avatar/Avatar.d.mts +3 -0
- package/dist/uds/dist/components/client/Avatar/AvatarIcon.d.cts +2 -0
- package/dist/uds/dist/components/client/Avatar/AvatarIcon.d.mts +3 -0
- package/dist/uds/dist/components/client/Avatar/AvatarImage.d.cts +4 -0
- package/dist/uds/dist/components/client/Avatar/AvatarImage.d.mts +5 -0
- package/dist/uds/dist/components/client/Avatar/AvatarText.d.cts +3 -0
- package/dist/uds/dist/components/client/Avatar/AvatarText.d.mts +4 -0
- package/dist/uds/dist/components/client/Avatar/index.d.cts +5 -0
- package/dist/uds/dist/components/client/Avatar/index.d.mts +5 -0
- package/dist/uds/dist/components/client/Badge.d.cts +3 -0
- package/dist/uds/dist/components/client/Badge.d.mts +3 -0
- package/dist/uds/dist/components/client/Button.d.cts +3 -0
- package/dist/uds/dist/components/client/Button.d.mts +3 -0
- package/dist/uds/dist/components/client/Checkbox.d.cts +3 -0
- package/dist/uds/dist/components/client/Checkbox.d.mts +3 -0
- package/dist/uds/dist/components/client/Chip/Chip.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/Chip.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipBase.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipBase.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipButton.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipButton.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipDismissible.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipDismissible.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipLink.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipLink.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipToggle.d.cts +4 -0
- package/dist/uds/dist/components/client/Chip/ChipToggle.d.mts +4 -0
- package/dist/uds/dist/components/client/Chip/index.d.cts +6 -0
- package/dist/uds/dist/components/client/Chip/index.d.mts +6 -0
- package/dist/uds/dist/components/client/IconButton.d.cts +3 -0
- package/dist/uds/dist/components/client/IconButton.d.mts +3 -0
- package/dist/uds/dist/components/client/Input/Input.d.cts +4 -0
- package/dist/uds/dist/components/client/Input/Input.d.mts +4 -0
- package/dist/uds/dist/components/client/Input/InputHelpText.d.cts +2 -0
- package/dist/uds/dist/components/client/Input/InputHelpText.d.mts +3 -0
- package/dist/uds/dist/components/client/Input/InputHelpTextInternal.d.cts +5 -0
- package/dist/uds/dist/components/client/Input/InputHelpTextInternal.d.mts +6 -0
- package/dist/uds/dist/components/client/Input/index.d.cts +3 -0
- package/dist/uds/dist/components/client/Input/index.d.mts +3 -0
- package/dist/uds/dist/components/client/Menu/Menu.Content.d.cts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.Content.d.mts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.Divider.d.cts +3 -0
- package/dist/uds/dist/components/client/Menu/Menu.Divider.d.mts +3 -0
- package/dist/uds/dist/components/client/Menu/Menu.Item.d.cts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.Item.d.mts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.ItemCheckbox.d.mts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.Provider.d.cts +2 -0
- package/dist/uds/dist/components/client/Menu/Menu.Provider.d.mts +3 -0
- package/dist/uds/dist/components/client/Menu/Menu.Trigger.d.cts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.Trigger.d.mts +4 -0
- package/dist/uds/dist/components/client/Menu/Menu.d.cts +2 -0
- package/dist/uds/dist/components/client/Menu/Menu.d.mts +2 -0
- package/dist/uds/dist/components/client/Menu/Menu.index.d.cts +7 -0
- package/dist/uds/dist/components/client/Menu/Menu.index.d.mts +7 -0
- package/dist/uds/dist/components/client/Menu/index.d.cts +9 -0
- package/dist/uds/dist/components/client/Menu/index.d.mts +9 -0
- package/dist/uds/dist/components/client/Pressable.d.cts +3 -0
- package/dist/uds/dist/components/client/Pressable.d.mts +3 -0
- package/dist/uds/dist/components/client/Radio/Radio.d.cts +3 -0
- package/dist/uds/dist/components/client/Radio/Radio.d.mts +3 -0
- package/dist/uds/dist/components/client/Radio/RadioGroupProvider.d.cts +3 -0
- package/dist/uds/dist/components/client/Radio/RadioGroupProvider.d.mts +3 -0
- package/dist/uds/dist/components/client/Radio/index.d.cts +3 -0
- package/dist/uds/dist/components/client/Radio/index.d.mts +3 -0
- package/dist/uds/dist/components/client/SpringMotionConfig.d.cts +3 -0
- package/dist/uds/dist/components/client/SpringMotionConfig.d.mts +3 -0
- package/dist/uds/dist/components/client/Switch.d.cts +3 -0
- package/dist/uds/dist/components/client/Switch.d.mts +3 -0
- package/dist/uds/dist/components/client/index.d.cts +33 -0
- package/dist/uds/dist/components/client/index.d.mts +33 -0
- package/dist/uds/dist/components/index.d.cts +40 -0
- package/dist/uds/dist/components/index.d.mts +40 -0
- package/dist/uds/dist/index.d.cts +46 -0
- package/dist/uds/dist/index.d.mts +46 -0
- package/dist/uds/dist/styles/styler.d.cts +2 -0
- package/dist/uds/dist/styles/styler.d.mts +2 -0
- package/dist/uds/dist/styles/stylerTypes.d.cts +2 -0
- package/dist/uds/dist/styles/stylerTypes.d.mts +2 -0
- package/dist/uds/dist/tokens/automation/configs/avatar.d.cts +2 -0
- package/dist/uds/dist/tokens/automation/configs/avatar.d.mts +2 -0
- package/dist/uds/dist/tokens/automation/properties.d.cts +3 -0
- package/dist/uds/dist/tokens/automation/properties.d.mts +3 -0
- package/dist/uds/dist/tokens/automation/types/ComponentConfig.d.cts +3 -0
- package/dist/uds/dist/tokens/automation/types/ComponentConfig.d.mts +3 -0
- package/dist/uds/dist/tokens/configs/motion.cjs +109 -0
- package/dist/uds/dist/tokens/configs/motion.d.cts +20 -0
- package/dist/uds/dist/tokens/configs/motion.d.cts.map +1 -0
- package/dist/uds/dist/tokens/configs/motion.d.mts +20 -0
- package/dist/uds/dist/tokens/configs/motion.d.mts.map +1 -0
- package/dist/uds/dist/tokens/configs/motion.mjs +108 -0
- package/dist/uds/dist/tokens/configs/motion.mjs.map +1 -0
- package/dist/uds/dist/tokens/configs/palette/alwaysPalette.d.cts +32 -0
- package/dist/uds/dist/tokens/configs/palette/alwaysPalette.d.cts.map +1 -0
- package/dist/uds/dist/tokens/configs/palette/alwaysPalette.d.mts +32 -0
- package/dist/uds/dist/tokens/configs/palette/alwaysPalette.d.mts.map +1 -0
- package/dist/uds/dist/tokens/types.d.cts +426 -0
- package/dist/uds/dist/tokens/types.d.cts.map +1 -0
- package/dist/uds/dist/tokens/types.d.mts +426 -0
- package/dist/uds/dist/tokens/types.d.mts.map +1 -0
- package/dist/uds/dist/types.d.cts +2 -0
- package/dist/uds/dist/types.d.mts +2 -0
- package/fonts/centra-no2-black-italic.otf +0 -0
- package/fonts/centra-no2-black.otf +0 -0
- package/fonts/centra-no2-bold-italic.otf +0 -0
- package/fonts/centra-no2-bold.otf +0 -0
- package/fonts/centra-no2-book-italic.otf +0 -0
- package/fonts/centra-no2-book.otf +0 -0
- package/fonts/centra-no2-extrabold-italic.otf +0 -0
- package/fonts/centra-no2-extrabold.otf +0 -0
- package/fonts/centra-no2-hairline-italic.otf +0 -0
- package/fonts/centra-no2-hairline.otf +0 -0
- package/fonts/centra-no2-light-italic.otf +0 -0
- package/fonts/centra-no2-light.otf +0 -0
- package/fonts/centra-no2-medium-italic.otf +0 -0
- package/fonts/centra-no2-medium.otf +0 -0
- package/fonts/centra-no2-thin-italic.otf +0 -0
- package/fonts/centra-no2-thin.otf +0 -0
- package/fonts/gelica-black-italic.otf +0 -0
- package/fonts/gelica-black.otf +0 -0
- package/fonts/gelica-bold-italic.otf +0 -0
- package/fonts/gelica-bold.otf +0 -0
- package/fonts/gelica-extra-light-italic.otf +0 -0
- package/fonts/gelica-extra-light.otf +0 -0
- package/fonts/gelica-light-italic.otf +0 -0
- package/fonts/gelica-light.otf +0 -0
- package/fonts/gelica-medium-italic.otf +0 -0
- package/fonts/gelica-medium.otf +0 -0
- package/fonts/gelica-regular-italic.otf +0 -0
- package/fonts/gelica-regular.otf +0 -0
- package/fonts/gelica-semi-bold-italic.otf +0 -0
- package/fonts/gelica-semi-bold.otf +0 -0
- package/fonts/index.cjs +270 -0
- package/fonts/index.d.ts +10 -0
- package/fonts/index.mjs +272 -0
- package/fonts/inter-black.ttf +0 -0
- package/fonts/inter-bold.ttf +0 -0
- package/fonts/inter-extra-bold.ttf +0 -0
- package/fonts/inter-extra-light.ttf +0 -0
- package/fonts/inter-light.ttf +0 -0
- package/fonts/inter-medium.ttf +0 -0
- package/fonts/inter-regular.ttf +0 -0
- package/fonts/inter-semi-bold.ttf +0 -0
- package/fonts/inter-thin.ttf +0 -0
- package/fonts/roboto-mono-bold-italic.ttf +0 -0
- package/fonts/roboto-mono-bold.ttf +0 -0
- package/fonts/roboto-mono-light-italic.ttf +0 -0
- package/fonts/roboto-mono-light.ttf +0 -0
- package/fonts/roboto-mono-medium-italic.ttf +0 -0
- package/fonts/roboto-mono-medium.ttf +0 -0
- package/fonts/roboto-mono-regular-italic.ttf +0 -0
- package/fonts/roboto-mono-regular.ttf +0 -0
- package/fonts/roboto-mono-thin-italic.ttf +0 -0
- package/fonts/roboto-mono-thin.ttf +0 -0
- package/fonts/uds-icons.ttf +0 -0
- package/fonts/yahoo-product-sans-bold.otf +0 -0
- package/fonts/yahoo-product-sans-extended-black-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-black.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-bold-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-bold.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-light-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-light.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-medium-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-medium.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-regular-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-regular.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-semibold-italic.ttf +0 -0
- package/fonts/yahoo-product-sans-extended-semibold.ttf +0 -0
- package/fonts/yahoo-product-sans-medium.otf +0 -0
- package/fonts/yahoo-product-sans-regular.otf +0 -0
- package/fonts/yahoo-sans-beta-bold.otf +0 -0
- package/fonts/yahoo-sans-beta-medium.otf +0 -0
- package/fonts/yahoo-sans-beta-regular.otf +0 -0
- package/fonts/yahoo-sans-black.otf +0 -0
- package/fonts/yahoo-sans-bold.otf +0 -0
- package/fonts/yahoo-sans-condensed-black.otf +0 -0
- package/fonts/yahoo-sans-condensed-bold.otf +0 -0
- package/fonts/yahoo-sans-condensed-light.otf +0 -0
- package/fonts/yahoo-sans-condensed-medium.otf +0 -0
- package/fonts/yahoo-sans-condensed-regular.otf +0 -0
- package/fonts/yahoo-sans-condensed-xbold.ttf +0 -0
- package/fonts/yahoo-sans-cr4-bold.ttf +0 -0
- package/fonts/yahoo-sans-cr4-medium.ttf +0 -0
- package/fonts/yahoo-sans-cr4-regular.ttf +0 -0
- package/fonts/yahoo-sans-extrabold.otf +0 -0
- package/fonts/yahoo-sans-extralight.otf +0 -0
- package/fonts/yahoo-sans-italic.otf +0 -0
- package/fonts/yahoo-sans-light.otf +0 -0
- package/fonts/yahoo-sans-medium.otf +0 -0
- package/fonts/yahoo-sans-regular-italic.otf +0 -0
- package/fonts/yahoo-sans-regular.otf +0 -0
- package/fonts/yahoo-sans-semibold.otf +0 -0
- package/fonts/yahoo-serif-display-black.otf +0 -0
- package/fonts/yahoo-serif-display-bold.otf +0 -0
- package/fonts/yahoo-serif-display-extrabold.otf +0 -0
- package/fonts/yahoo-serif-display-light.otf +0 -0
- package/fonts/yahoo-serif-display-regular.otf +0 -0
- package/fonts/yahoo-serif-text-bold-italic.ttf +0 -0
- package/fonts/yahoo-serif-text-bold.otf +0 -0
- package/fonts/yahoo-serif-text-italic.otf +0 -0
- package/fonts/yahoo-serif-text-regular.otf +0 -0
- package/fonts/yas-black-italic.otf +0 -0
- package/fonts/yas-black.otf +0 -0
- package/fonts/yas-bold-italic.otf +0 -0
- package/fonts/yas-bold.otf +0 -0
- package/fonts/yas-condensed-black-italic.otf +0 -0
- package/fonts/yas-condensed-black.otf +0 -0
- package/fonts/yas-condensed-bold-italic.otf +0 -0
- package/fonts/yas-condensed-bold.otf +0 -0
- package/fonts/yas-condensed-light-italic.otf +0 -0
- package/fonts/yas-condensed-light.otf +0 -0
- package/fonts/yas-condensed-medium-italic.otf +0 -0
- package/fonts/yas-condensed-medium.otf +0 -0
- package/fonts/yas-condensed-regular-italic.otf +0 -0
- package/fonts/yas-condensed-regular.otf +0 -0
- package/fonts/yas-condensed-semibold-italic.otf +0 -0
- package/fonts/yas-condensed-semibold.otf +0 -0
- package/fonts/yas-extended-black-italic.otf +0 -0
- package/fonts/yas-extended-black.otf +0 -0
- package/fonts/yas-extended-bold-italic.otf +0 -0
- package/fonts/yas-extended-bold.otf +0 -0
- package/fonts/yas-extended-light-italic.otf +0 -0
- package/fonts/yas-extended-light.otf +0 -0
- package/fonts/yas-extended-medium-italic.otf +0 -0
- package/fonts/yas-extended-medium.otf +0 -0
- package/fonts/yas-extended-regular-italic.otf +0 -0
- package/fonts/yas-extended-regular.otf +0 -0
- package/fonts/yas-extended-semibold-italic.otf +0 -0
- package/fonts/yas-extended-semibold.otf +0 -0
- package/fonts/yas-light-italic.otf +0 -0
- package/fonts/yas-light.otf +0 -0
- package/fonts/yas-medium-italic.otf +0 -0
- package/fonts/yas-medium.otf +0 -0
- package/fonts/yas-regular-italic.otf +0 -0
- package/fonts/yas-regular.otf +0 -0
- package/fonts/yas-semibold-italic.otf +0 -0
- package/fonts/yas-semibold.otf +0 -0
- package/generated/styles.cjs +4510 -0
- package/generated/styles.d.cts +1 -0
- package/generated/styles.d.mts +1 -0
- package/generated/styles.d.ts +2965 -0
- package/generated/styles.mjs +4510 -0
- package/generated/unistyles.d.ts +4320 -0
- package/package.json +308 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_motion = require('../uds/dist/tokens/configs/motion.cjs');
|
|
4
|
+
const require_motion$1 = require('../motion.cjs');
|
|
5
|
+
const require_components_Icon = require('./Icon.cjs');
|
|
6
|
+
const require_components_Text = require('./Text.cjs');
|
|
7
|
+
const require_components_HStack = require('./HStack.cjs');
|
|
8
|
+
const require_components_Pressable = require('./Pressable.cjs');
|
|
9
|
+
let react = require("react");
|
|
10
|
+
let generated_styles = require("../../generated/styles");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
13
|
+
react_native_reanimated = require_rolldown_runtime.__toESM(react_native_reanimated);
|
|
14
|
+
|
|
15
|
+
//#region src/components/Checkbox.tsx
|
|
16
|
+
const VARIANT_ERROR_MAP = {
|
|
17
|
+
primary: "alert",
|
|
18
|
+
secondary: "alert-secondary"
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* **⚙️ A checkbox component**
|
|
22
|
+
*
|
|
23
|
+
* @componentType Client component
|
|
24
|
+
*
|
|
25
|
+
* @description
|
|
26
|
+
* A checkbox component allows users to select one or multiple options from a set.
|
|
27
|
+
* It represents a binary state, typically as checked or unchecked, and optionally
|
|
28
|
+
* includes a third "indeterminate" state to indicate partial selection.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { Checkbox } from '@yahoo/uds-mobile';
|
|
33
|
+
*
|
|
34
|
+
* <Checkbox label="Agree to terms" />
|
|
35
|
+
* <Checkbox label="Subscribe" checked={true} onChange={setChecked} />
|
|
36
|
+
* <Checkbox label="Partial" checked="indeterminate" />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @usage
|
|
40
|
+
* - Forms: For selecting options
|
|
41
|
+
* - Settings: For toggling preferences
|
|
42
|
+
* - Filters: For multi-select filtering
|
|
43
|
+
*
|
|
44
|
+
* @see The {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
|
|
45
|
+
*/
|
|
46
|
+
const Checkbox = (0, react.memo)(function Checkbox$1({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, onChange, ref, ...viewProps }) {
|
|
47
|
+
const uid = `uds-checkbox-${(0, react.useId)()}`;
|
|
48
|
+
const isControlled = checkedProp !== void 0;
|
|
49
|
+
const [internalChecked, setInternalChecked] = (0, react.useState)(isControlled ? checkedProp : defaultChecked ?? false);
|
|
50
|
+
const [pressed, setPressed] = (0, react.useState)(false);
|
|
51
|
+
const checked = isControlled ? checkedProp : internalChecked;
|
|
52
|
+
const valueState = (0, react.useMemo)(() => {
|
|
53
|
+
if (checked === "indeterminate") return "indeterminate";
|
|
54
|
+
return checked ? "checked" : "unchecked";
|
|
55
|
+
}, [checked]);
|
|
56
|
+
const iconName = valueState === "indeterminate" ? "Minus" : "Check";
|
|
57
|
+
const showIcon = valueState !== "unchecked";
|
|
58
|
+
const shouldAnimate = !reduceMotion;
|
|
59
|
+
const scaleProgress = (0, react_native_reanimated.useDerivedValue)(() => shouldAnimate ? (0, react_native_reanimated.withSpring)(pressed ? require_motion.SCALE_EFFECTS.down : require_motion.SCALE_EFFECTS.none, require_motion$1.BUTTON_SPRING_CONFIG) : require_motion.SCALE_EFFECTS.none, [pressed, shouldAnimate]);
|
|
60
|
+
const iconProgress = (0, react_native_reanimated.useDerivedValue)(() => shouldAnimate ? (0, react_native_reanimated.withSpring)(showIcon ? 1 : 0, require_motion$1.BUTTON_SPRING_CONFIG) : showIcon ? 1 : 0, [showIcon, shouldAnimate]);
|
|
61
|
+
const checkboxAnimatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ scale: scaleProgress.value }] }));
|
|
62
|
+
const iconAnimatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
63
|
+
opacity: (0, react_native_reanimated.interpolate)(iconProgress.value, [0, 1], [0, 1]),
|
|
64
|
+
transform: [{ scale: (0, react_native_reanimated.interpolate)(iconProgress.value, [0, 1], [.5, 1]) }]
|
|
65
|
+
}));
|
|
66
|
+
const handlePress = (0, react.useCallback)(() => {
|
|
67
|
+
if (disabled) return;
|
|
68
|
+
const newChecked = checked === "indeterminate" ? true : !checked;
|
|
69
|
+
if (!isControlled) setInternalChecked(newChecked);
|
|
70
|
+
onChange?.(newChecked);
|
|
71
|
+
}, [
|
|
72
|
+
disabled,
|
|
73
|
+
checked,
|
|
74
|
+
isControlled,
|
|
75
|
+
onChange
|
|
76
|
+
]);
|
|
77
|
+
const handlePressIn = (0, react.useCallback)(() => {
|
|
78
|
+
setPressed(true);
|
|
79
|
+
}, []);
|
|
80
|
+
const handlePressOut = (0, react.useCallback)(() => {
|
|
81
|
+
setPressed(false);
|
|
82
|
+
}, []);
|
|
83
|
+
const styleVariant = hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp;
|
|
84
|
+
generated_styles.checkboxStyles.useVariants({
|
|
85
|
+
size,
|
|
86
|
+
variant: styleVariant,
|
|
87
|
+
value: valueState,
|
|
88
|
+
disabled,
|
|
89
|
+
pressed
|
|
90
|
+
});
|
|
91
|
+
const rootStyle = (0, react.useMemo)(() => [generated_styles.checkboxStyles.root, { opacity: disabled ? .5 : 1 }], [generated_styles.checkboxStyles.root, disabled]);
|
|
92
|
+
const checkboxBoxStyle = (0, react.useMemo)(() => [
|
|
93
|
+
generated_styles.checkboxStyles.checkbox,
|
|
94
|
+
{
|
|
95
|
+
alignItems: "center",
|
|
96
|
+
justifyContent: "center"
|
|
97
|
+
},
|
|
98
|
+
checkboxAnimatedStyle
|
|
99
|
+
], [generated_styles.checkboxStyles.checkbox, checkboxAnimatedStyle]);
|
|
100
|
+
const labelContent = (0, react.useMemo)(() => {
|
|
101
|
+
if (!label) return null;
|
|
102
|
+
const content = typeof label === "function" ? label() : (0, react.isValidElement)(label) ? label : String(label);
|
|
103
|
+
const textContent = typeof content === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
104
|
+
style: generated_styles.checkboxStyles.text,
|
|
105
|
+
children: content
|
|
106
|
+
}) : content;
|
|
107
|
+
if (required) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_HStack.HStack, {
|
|
108
|
+
columnGap: "1",
|
|
109
|
+
alignItems: "flex-start",
|
|
110
|
+
children: [textContent, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
111
|
+
style: generated_styles.checkboxStyles.text,
|
|
112
|
+
children: "*"
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
return textContent;
|
|
116
|
+
}, [
|
|
117
|
+
label,
|
|
118
|
+
required,
|
|
119
|
+
generated_styles.checkboxStyles.text
|
|
120
|
+
]);
|
|
121
|
+
const a11yState = (0, react.useMemo)(() => ({
|
|
122
|
+
disabled,
|
|
123
|
+
checked: valueState === "checked" ? true : valueState === "indeterminate" ? "mixed" : false
|
|
124
|
+
}), [disabled, valueState]);
|
|
125
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Pressable.Pressable, {
|
|
126
|
+
ref,
|
|
127
|
+
nativeID: uid,
|
|
128
|
+
onPress: handlePress,
|
|
129
|
+
onPressIn: handlePressIn,
|
|
130
|
+
onPressOut: handlePressOut,
|
|
131
|
+
disabled,
|
|
132
|
+
flexDirection: labelPosition === "start" ? "row" : "row-reverse",
|
|
133
|
+
alignItems: "center",
|
|
134
|
+
alignSelf: "flex-start",
|
|
135
|
+
accessibilityRole: "checkbox",
|
|
136
|
+
accessibilityState: a11yState,
|
|
137
|
+
accessibilityLabel: typeof label === "string" ? label : void 0,
|
|
138
|
+
...viewProps,
|
|
139
|
+
style: rootStyle,
|
|
140
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
141
|
+
style: checkboxBoxStyle,
|
|
142
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
143
|
+
style: iconAnimatedStyle,
|
|
144
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
|
|
145
|
+
name: iconName,
|
|
146
|
+
size: "sm",
|
|
147
|
+
style: generated_styles.checkboxStyles.checkboxIcon
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
}), labelContent]
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
Checkbox.displayName = "Checkbox";
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
exports.Checkbox = Checkbox;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalCheckboxProps } from "../uds/dist/tokens/types.cjs";
|
|
3
|
+
import * as react4 from "react";
|
|
4
|
+
import { Ref } from "react";
|
|
5
|
+
import { View, ViewProps } from "react-native";
|
|
6
|
+
|
|
7
|
+
//#region src/components/Checkbox.d.ts
|
|
8
|
+
interface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {
|
|
9
|
+
ref?: Ref<View>;
|
|
10
|
+
/** Default checked state for uncontrolled mode */
|
|
11
|
+
defaultChecked?: boolean;
|
|
12
|
+
/** Whether the checkbox is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Whether the checkbox is required */
|
|
15
|
+
required?: boolean;
|
|
16
|
+
/** Callback fired when the checked state changes */
|
|
17
|
+
onChange?: (checked: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* **⚙️ A checkbox component**
|
|
21
|
+
*
|
|
22
|
+
* @componentType Client component
|
|
23
|
+
*
|
|
24
|
+
* @description
|
|
25
|
+
* A checkbox component allows users to select one or multiple options from a set.
|
|
26
|
+
* It represents a binary state, typically as checked or unchecked, and optionally
|
|
27
|
+
* includes a third "indeterminate" state to indicate partial selection.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { Checkbox } from '@yahoo/uds-mobile';
|
|
32
|
+
*
|
|
33
|
+
* <Checkbox label="Agree to terms" />
|
|
34
|
+
* <Checkbox label="Subscribe" checked={true} onChange={setChecked} />
|
|
35
|
+
* <Checkbox label="Partial" checked="indeterminate" />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @usage
|
|
39
|
+
* - Forms: For selecting options
|
|
40
|
+
* - Settings: For toggling preferences
|
|
41
|
+
* - Filters: For multi-select filtering
|
|
42
|
+
*
|
|
43
|
+
* @see The {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
|
|
44
|
+
*/
|
|
45
|
+
declare const Checkbox: react4.NamedExoticComponent<CheckboxProps>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Checkbox, type CheckboxProps };
|
|
48
|
+
//# sourceMappingURL=Checkbox.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.cts","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":[],"mappings":";;;;;;;UAyBU,aAAA,SAAsB,KAAK,qBAAqB;QAClD,IAAI;;EADF,cAAA,CAAA,EAAc,OAAA;EAAa;EACzB,QAAA,CAAA,EAAA,OAAA;EAAJ;EADwB,QAAA,CAAA,EAAA,OAAA;EAA0B;EAAsB,QAAA,CAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsD1E,UAAQ,MAAA,CAAA,qBAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalCheckboxProps } from "../uds/dist/tokens/types.mjs";
|
|
3
|
+
import * as react9 from "react";
|
|
4
|
+
import { Ref } from "react";
|
|
5
|
+
import { View, ViewProps } from "react-native";
|
|
6
|
+
|
|
7
|
+
//#region src/components/Checkbox.d.ts
|
|
8
|
+
interface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {
|
|
9
|
+
ref?: Ref<View>;
|
|
10
|
+
/** Default checked state for uncontrolled mode */
|
|
11
|
+
defaultChecked?: boolean;
|
|
12
|
+
/** Whether the checkbox is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Whether the checkbox is required */
|
|
15
|
+
required?: boolean;
|
|
16
|
+
/** Callback fired when the checked state changes */
|
|
17
|
+
onChange?: (checked: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* **⚙️ A checkbox component**
|
|
21
|
+
*
|
|
22
|
+
* @componentType Client component
|
|
23
|
+
*
|
|
24
|
+
* @description
|
|
25
|
+
* A checkbox component allows users to select one or multiple options from a set.
|
|
26
|
+
* It represents a binary state, typically as checked or unchecked, and optionally
|
|
27
|
+
* includes a third "indeterminate" state to indicate partial selection.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { Checkbox } from '@yahoo/uds-mobile';
|
|
32
|
+
*
|
|
33
|
+
* <Checkbox label="Agree to terms" />
|
|
34
|
+
* <Checkbox label="Subscribe" checked={true} onChange={setChecked} />
|
|
35
|
+
* <Checkbox label="Partial" checked="indeterminate" />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @usage
|
|
39
|
+
* - Forms: For selecting options
|
|
40
|
+
* - Settings: For toggling preferences
|
|
41
|
+
* - Filters: For multi-select filtering
|
|
42
|
+
*
|
|
43
|
+
* @see The {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
|
|
44
|
+
*/
|
|
45
|
+
declare const Checkbox: react9.NamedExoticComponent<CheckboxProps>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Checkbox, type CheckboxProps };
|
|
48
|
+
//# sourceMappingURL=Checkbox.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.mts","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":[],"mappings":";;;;;;;UAyBU,aAAA,SAAsB,KAAK,qBAAqB;QAClD,IAAI;;EADF,cAAA,CAAA,EAAc,OAAA;EAAa;EACzB,QAAA,CAAA,EAAA,OAAA;EAAJ;EADwB,QAAA,CAAA,EAAA,OAAA;EAA0B;EAAsB,QAAA,CAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsD1E,UAAQ,MAAA,CAAA,qBAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { SCALE_EFFECTS } from "../uds/dist/tokens/configs/motion.mjs";
|
|
3
|
+
import { BUTTON_SPRING_CONFIG } from "../motion.mjs";
|
|
4
|
+
import { Icon } from "./Icon.mjs";
|
|
5
|
+
import { Text } from "./Text.mjs";
|
|
6
|
+
import { HStack } from "./HStack.mjs";
|
|
7
|
+
import { Pressable } from "./Pressable.mjs";
|
|
8
|
+
import { isValidElement, memo, useCallback, useId, useMemo, useState } from "react";
|
|
9
|
+
import { checkboxStyles } from "../../generated/styles";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import Animated, { interpolate, useAnimatedStyle, useDerivedValue, withSpring } from "react-native-reanimated";
|
|
12
|
+
|
|
13
|
+
//#region src/components/Checkbox.tsx
|
|
14
|
+
const VARIANT_ERROR_MAP = {
|
|
15
|
+
primary: "alert",
|
|
16
|
+
secondary: "alert-secondary"
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* **⚙️ A checkbox component**
|
|
20
|
+
*
|
|
21
|
+
* @componentType Client component
|
|
22
|
+
*
|
|
23
|
+
* @description
|
|
24
|
+
* A checkbox component allows users to select one or multiple options from a set.
|
|
25
|
+
* It represents a binary state, typically as checked or unchecked, and optionally
|
|
26
|
+
* includes a third "indeterminate" state to indicate partial selection.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { Checkbox } from '@yahoo/uds-mobile';
|
|
31
|
+
*
|
|
32
|
+
* <Checkbox label="Agree to terms" />
|
|
33
|
+
* <Checkbox label="Subscribe" checked={true} onChange={setChecked} />
|
|
34
|
+
* <Checkbox label="Partial" checked="indeterminate" />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @usage
|
|
38
|
+
* - Forms: For selecting options
|
|
39
|
+
* - Settings: For toggling preferences
|
|
40
|
+
* - Filters: For multi-select filtering
|
|
41
|
+
*
|
|
42
|
+
* @see The {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
|
|
43
|
+
*/
|
|
44
|
+
const Checkbox = memo(function Checkbox$1({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, onChange, ref, ...viewProps }) {
|
|
45
|
+
const uid = `uds-checkbox-${useId()}`;
|
|
46
|
+
const isControlled = checkedProp !== void 0;
|
|
47
|
+
const [internalChecked, setInternalChecked] = useState(isControlled ? checkedProp : defaultChecked ?? false);
|
|
48
|
+
const [pressed, setPressed] = useState(false);
|
|
49
|
+
const checked = isControlled ? checkedProp : internalChecked;
|
|
50
|
+
const valueState = useMemo(() => {
|
|
51
|
+
if (checked === "indeterminate") return "indeterminate";
|
|
52
|
+
return checked ? "checked" : "unchecked";
|
|
53
|
+
}, [checked]);
|
|
54
|
+
const iconName = valueState === "indeterminate" ? "Minus" : "Check";
|
|
55
|
+
const showIcon = valueState !== "unchecked";
|
|
56
|
+
const shouldAnimate = !reduceMotion;
|
|
57
|
+
const scaleProgress = useDerivedValue(() => shouldAnimate ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG) : SCALE_EFFECTS.none, [pressed, shouldAnimate]);
|
|
58
|
+
const iconProgress = useDerivedValue(() => shouldAnimate ? withSpring(showIcon ? 1 : 0, BUTTON_SPRING_CONFIG) : showIcon ? 1 : 0, [showIcon, shouldAnimate]);
|
|
59
|
+
const checkboxAnimatedStyle = useAnimatedStyle(() => ({ transform: [{ scale: scaleProgress.value }] }));
|
|
60
|
+
const iconAnimatedStyle = useAnimatedStyle(() => ({
|
|
61
|
+
opacity: interpolate(iconProgress.value, [0, 1], [0, 1]),
|
|
62
|
+
transform: [{ scale: interpolate(iconProgress.value, [0, 1], [.5, 1]) }]
|
|
63
|
+
}));
|
|
64
|
+
const handlePress = useCallback(() => {
|
|
65
|
+
if (disabled) return;
|
|
66
|
+
const newChecked = checked === "indeterminate" ? true : !checked;
|
|
67
|
+
if (!isControlled) setInternalChecked(newChecked);
|
|
68
|
+
onChange?.(newChecked);
|
|
69
|
+
}, [
|
|
70
|
+
disabled,
|
|
71
|
+
checked,
|
|
72
|
+
isControlled,
|
|
73
|
+
onChange
|
|
74
|
+
]);
|
|
75
|
+
const handlePressIn = useCallback(() => {
|
|
76
|
+
setPressed(true);
|
|
77
|
+
}, []);
|
|
78
|
+
const handlePressOut = useCallback(() => {
|
|
79
|
+
setPressed(false);
|
|
80
|
+
}, []);
|
|
81
|
+
const styleVariant = hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp;
|
|
82
|
+
checkboxStyles.useVariants({
|
|
83
|
+
size,
|
|
84
|
+
variant: styleVariant,
|
|
85
|
+
value: valueState,
|
|
86
|
+
disabled,
|
|
87
|
+
pressed
|
|
88
|
+
});
|
|
89
|
+
const rootStyle = useMemo(() => [checkboxStyles.root, { opacity: disabled ? .5 : 1 }], [checkboxStyles.root, disabled]);
|
|
90
|
+
const checkboxBoxStyle = useMemo(() => [
|
|
91
|
+
checkboxStyles.checkbox,
|
|
92
|
+
{
|
|
93
|
+
alignItems: "center",
|
|
94
|
+
justifyContent: "center"
|
|
95
|
+
},
|
|
96
|
+
checkboxAnimatedStyle
|
|
97
|
+
], [checkboxStyles.checkbox, checkboxAnimatedStyle]);
|
|
98
|
+
const labelContent = useMemo(() => {
|
|
99
|
+
if (!label) return null;
|
|
100
|
+
const content = typeof label === "function" ? label() : isValidElement(label) ? label : String(label);
|
|
101
|
+
const textContent = typeof content === "string" ? /* @__PURE__ */ jsx(Text, {
|
|
102
|
+
style: checkboxStyles.text,
|
|
103
|
+
children: content
|
|
104
|
+
}) : content;
|
|
105
|
+
if (required) return /* @__PURE__ */ jsxs(HStack, {
|
|
106
|
+
columnGap: "1",
|
|
107
|
+
alignItems: "flex-start",
|
|
108
|
+
children: [textContent, /* @__PURE__ */ jsx(Text, {
|
|
109
|
+
style: checkboxStyles.text,
|
|
110
|
+
children: "*"
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
return textContent;
|
|
114
|
+
}, [
|
|
115
|
+
label,
|
|
116
|
+
required,
|
|
117
|
+
checkboxStyles.text
|
|
118
|
+
]);
|
|
119
|
+
const a11yState = useMemo(() => ({
|
|
120
|
+
disabled,
|
|
121
|
+
checked: valueState === "checked" ? true : valueState === "indeterminate" ? "mixed" : false
|
|
122
|
+
}), [disabled, valueState]);
|
|
123
|
+
return /* @__PURE__ */ jsxs(Pressable, {
|
|
124
|
+
ref,
|
|
125
|
+
nativeID: uid,
|
|
126
|
+
onPress: handlePress,
|
|
127
|
+
onPressIn: handlePressIn,
|
|
128
|
+
onPressOut: handlePressOut,
|
|
129
|
+
disabled,
|
|
130
|
+
flexDirection: labelPosition === "start" ? "row" : "row-reverse",
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
alignSelf: "flex-start",
|
|
133
|
+
accessibilityRole: "checkbox",
|
|
134
|
+
accessibilityState: a11yState,
|
|
135
|
+
accessibilityLabel: typeof label === "string" ? label : void 0,
|
|
136
|
+
...viewProps,
|
|
137
|
+
style: rootStyle,
|
|
138
|
+
children: [/* @__PURE__ */ jsx(Animated.View, {
|
|
139
|
+
style: checkboxBoxStyle,
|
|
140
|
+
children: /* @__PURE__ */ jsx(Animated.View, {
|
|
141
|
+
style: iconAnimatedStyle,
|
|
142
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
143
|
+
name: iconName,
|
|
144
|
+
size: "sm",
|
|
145
|
+
style: checkboxStyles.checkboxIcon
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}), labelContent]
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
Checkbox.displayName = "Checkbox";
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
export { Checkbox };
|
|
155
|
+
//# sourceMappingURL=Checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.mjs","names":["VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant>","Checkbox","valueState: CheckboxValueState","styleVariant: CheckboxStyleVariant"],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import type { CheckboxValue, CheckboxVariant, UniversalCheckboxProps } from '@yahoo/uds/tokens';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { checkboxStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { HStack } from './HStack';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype CheckboxStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Checkbox Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A checkbox component**\n *\n * @componentType Client component\n *\n * @description\n * A checkbox component allows users to select one or multiple options from a set.\n * It represents a binary state, typically as checked or unchecked, and optionally\n * includes a third \"indeterminate\" state to indicate partial selection.\n *\n * @example\n * ```tsx\n * import { Checkbox } from '@yahoo/uds-mobile';\n *\n * <Checkbox label=\"Agree to terms\" />\n * <Checkbox label=\"Subscribe\" checked={true} onChange={setChecked} />\n * <Checkbox label=\"Partial\" checked=\"indeterminate\" />\n * ```\n *\n * @usage\n * - Forms: For selecting options\n * - Settings: For toggling preferences\n * - Filters: For multi-select filtering\n *\n * @see The {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info\n */\nconst Checkbox = memo(function Checkbox({\n // Checkbox props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n onChange,\n ref,\n ...viewProps\n}: CheckboxProps) {\n const generatedId = useId();\n const uid = `uds-checkbox-${generatedId}`;\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<CheckboxValue>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: CheckboxValueState = useMemo(() => {\n if (checked === 'indeterminate') {\n return 'indeterminate';\n }\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n const iconName = valueState === 'indeterminate' ? 'Minus' : 'Check';\n const showIcon = valueState !== 'unchecked';\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n // Icon visibility animation\n // When reduceMotion is true, still show/hide the icon but without animation\n const iconProgress = useDerivedValue(\n () => (shouldAnimate ? withSpring(showIcon ? 1 : 0, BUTTON_SPRING_CONFIG) : showIcon ? 1 : 0),\n [showIcon, shouldAnimate],\n );\n\n const checkboxAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n const iconAnimatedStyle = useAnimatedStyle(() => ({\n opacity: interpolate(iconProgress.value, [0, 1], [0, 1]),\n transform: [{ scale: interpolate(iconProgress.value, [0, 1], [0.5, 1]) }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = checked === 'indeterminate' ? true : !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: CheckboxStyleVariant = hasError\n ? VARIANT_ERROR_MAP[variantProp]\n : variantProp;\n\n checkboxStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked, indeterminate\n disabled,\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [checkboxStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [checkboxStyles.root, disabled],\n );\n\n const checkboxBoxStyle = useMemo(\n () => [\n checkboxStyles.checkbox,\n { alignItems: 'center' as const, justifyContent: 'center' as const },\n checkboxAnimatedStyle,\n ],\n [checkboxStyles.checkbox, checkboxAnimatedStyle],\n );\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n const content =\n typeof label === 'function' ? label() : isValidElement(label) ? label : String(label);\n\n const textContent =\n typeof content === 'string' ? <Text style={checkboxStyles.text}>{content}</Text> : content;\n\n if (required) {\n return (\n <HStack columnGap=\"1\" alignItems=\"flex-start\">\n {textContent}\n <Text style={checkboxStyles.text}>*</Text>\n </HStack>\n );\n }\n\n return textContent;\n }, [label, required, checkboxStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked:\n valueState === 'checked'\n ? true\n : valueState === 'indeterminate'\n ? ('mixed' as const)\n : false,\n }),\n [disabled, valueState],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"checkbox\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={checkboxBoxStyle}>\n <Animated.View style={iconAnimatedStyle}>\n <Icon name={iconName} size=\"sm\" style={checkboxStyles.checkboxIcon} />\n </Animated.View>\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport { Checkbox, type CheckboxProps };\n"],"mappings":";;;;;;;;;;;;;AA4CA,MAAMA,oBAAmE;CACvE,SAAS;CACT,WAAW;CACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCD,MAAM,WAAW,KAAK,SAASC,WAAS,EAEtC,OACA,gBAAgB,SAChB,SAAS,cAAc,WACvB,OAAO,MACP,SAAS,aACT,UACA,cAEA,gBACA,UACA,UACA,UACA,KACA,GAAG,aACa;CAEhB,MAAM,MAAM,gBADQ,OAAO;CAI3B,MAAM,eAAe,gBAAgB;CACrC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,eAAe,cAAe,kBAAkB,MACjD;CACD,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAG7C,MAAM,UAAU,eAAe,cAAc;CAG7C,MAAMC,aAAiC,cAAc;AACnD,MAAI,YAAY,gBACd,QAAO;AAET,SAAO,UAAU,YAAY;IAC5B,CAAC,QAAQ,CAAC;CAEb,MAAM,WAAW,eAAe,kBAAkB,UAAU;CAC5D,MAAM,WAAW,eAAe;CAGhC,MAAM,gBAAgB,CAAC;CAGvB,MAAM,gBAAgB,sBAElB,gBACI,WAAW,UAAU,cAAc,OAAO,cAAc,MAAM,qBAAqB,GACnF,cAAc,MACpB,CAAC,SAAS,cAAc,CACzB;CAID,MAAM,eAAe,sBACZ,gBAAgB,WAAW,WAAW,IAAI,GAAG,qBAAqB,GAAG,WAAW,IAAI,GAC3F,CAAC,UAAU,cAAc,CAC1B;CAED,MAAM,wBAAwB,wBAAwB,EACpD,WAAW,CAAC,EAAE,OAAO,cAAc,OAAO,CAAC,EAC5C,EAAE;CAEH,MAAM,oBAAoB,wBAAwB;EAChD,SAAS,YAAY,aAAa,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;EACxD,WAAW,CAAC,EAAE,OAAO,YAAY,aAAa,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAK,EAAE,CAAC,EAAE,CAAC;EAC1E,EAAE;CAGH,MAAM,cAAc,kBAAkB;AACpC,MAAI,SACF;EAGF,MAAM,aAAa,YAAY,kBAAkB,OAAO,CAAC;AAEzD,MAAI,CAAC,aACH,oBAAmB,WAAW;AAGhC,aAAW,WAAW;IACrB;EAAC;EAAU;EAAS;EAAc;EAAS,CAAC;CAE/C,MAAM,gBAAgB,kBAAkB;AACtC,aAAW,KAAK;IACf,EAAE,CAAC;CAEN,MAAM,iBAAiB,kBAAkB;AACvC,aAAW,MAAM;IAChB,EAAE,CAAC;CAIN,MAAMC,eAAqC,WACvC,kBAAkB,eAClB;AAEJ,gBAAe,YAAY;EACzB;EACA,SAAS;EACT,OAAO;EACP;EACA;EACD,CAAC;CAEF,MAAM,YAAY,cACV,CAAC,eAAe,MAAM,EAAE,SAAS,WAAW,KAAM,GAAG,CAAC,EAC5D,CAAC,eAAe,MAAM,SAAS,CAChC;CAED,MAAM,mBAAmB,cACjB;EACJ,eAAe;EACf;GAAE,YAAY;GAAmB,gBAAgB;GAAmB;EACpE;EACD,EACD,CAAC,eAAe,UAAU,sBAAsB,CACjD;CAGD,MAAM,eAAe,cAAc;AACjC,MAAI,CAAC,MACH,QAAO;EAGT,MAAM,UACJ,OAAO,UAAU,aAAa,OAAO,GAAG,eAAe,MAAM,GAAG,QAAQ,OAAO,MAAM;EAEvF,MAAM,cACJ,OAAO,YAAY,WAAW,oBAAC;GAAK,OAAO,eAAe;aAAO;IAAe,GAAG;AAErF,MAAI,SACF,QACE,qBAAC;GAAO,WAAU;GAAI,YAAW;cAC9B,aACD,oBAAC;IAAK,OAAO,eAAe;cAAM;KAAQ;IACnC;AAIb,SAAO;IACN;EAAC;EAAO;EAAU,eAAe;EAAK,CAAC;CAE1C,MAAM,YAAY,eACT;EACL;EACA,SACE,eAAe,YACX,OACA,eAAe,kBACZ,UACD;EACT,GACD,CAAC,UAAU,WAAW,CACvB;AAGD,QACE,qBAAC;EACM;EACL,UAAU;EACV,SAAS;EACT,WAAW;EACX,YAAY;EACF;EACV,eAAe,kBAAkB,UAAU,QAAQ;EACnD,YAAW;EACX,WAAU;EACV,mBAAkB;EAClB,oBAAoB;EACpB,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EACxD,GAAI;EACJ,OAAO;aAEP,oBAAC,SAAS;GAAK,OAAO;aACpB,oBAAC,SAAS;IAAK,OAAO;cACpB,oBAAC;KAAK,MAAM;KAAU,MAAK;KAAK,OAAO,eAAe;MAAgB;KACxD;IACF,EAEf;GACS;EAEd;AAEF,SAAS,cAAc"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_components_IconSlot = require('./IconSlot.cjs');
|
|
4
|
+
const require_components_Text = require('./Text.cjs');
|
|
5
|
+
const require_components_HStack = require('./HStack.cjs');
|
|
6
|
+
const require_components_Pressable = require('./Pressable.cjs');
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let generated_styles = require("../../generated/styles");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
|
|
11
|
+
//#region src/components/Chip.tsx
|
|
12
|
+
/**
|
|
13
|
+
* **A chip component for selections, filters, or actions**
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Chips help people make selections, filter content, or trigger actions.
|
|
17
|
+
* They can be toggleable, dismissible, or simple pressable elements.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { Chip } from '~/components/ui/Chip';
|
|
22
|
+
*
|
|
23
|
+
* // Basic chip
|
|
24
|
+
* <Chip>Label</Chip>
|
|
25
|
+
*
|
|
26
|
+
* // Toggle chip
|
|
27
|
+
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
28
|
+
*
|
|
29
|
+
* // Dismissible chip
|
|
30
|
+
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
31
|
+
*
|
|
32
|
+
* // With icons
|
|
33
|
+
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
const Chip = (0, react.memo)(function Chip$1({ variant = "primary", size = "md", minWidth, maxWidth = 200, startIcon, endIcon, disabled = false, isToggled = false, onPress, onToggle, onDismiss, dismissButtonAriaLabel = "Dismiss", children, style, ref, ...rest }) {
|
|
37
|
+
const isInteractive = Boolean(onPress || onToggle);
|
|
38
|
+
const isDismissible = Boolean(onDismiss);
|
|
39
|
+
const isDisabled = disabled;
|
|
40
|
+
const toggleState = isToggled ? "on" : "off";
|
|
41
|
+
generated_styles.chipStyles.useVariants({
|
|
42
|
+
size,
|
|
43
|
+
link: variant,
|
|
44
|
+
dismissible: variant,
|
|
45
|
+
toggle: toggleState
|
|
46
|
+
});
|
|
47
|
+
const handlePress = (0, react.useCallback)(() => {
|
|
48
|
+
if (isDisabled) return;
|
|
49
|
+
if (onToggle) onToggle(!isToggled);
|
|
50
|
+
else if (onPress) onPress();
|
|
51
|
+
}, [
|
|
52
|
+
isDisabled,
|
|
53
|
+
onToggle,
|
|
54
|
+
isToggled,
|
|
55
|
+
onPress
|
|
56
|
+
]);
|
|
57
|
+
const handleDismiss = (0, react.useCallback)(() => {
|
|
58
|
+
if (isDisabled) return;
|
|
59
|
+
onDismiss?.();
|
|
60
|
+
}, [isDisabled, onDismiss]);
|
|
61
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
62
|
+
startIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
63
|
+
icon: startIcon,
|
|
64
|
+
variant: "fill",
|
|
65
|
+
style: generated_styles.chipStyles.icon
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
68
|
+
numberOfLines: 1,
|
|
69
|
+
textAlign: "center",
|
|
70
|
+
flexShrink: "1",
|
|
71
|
+
style: generated_styles.chipStyles.text,
|
|
72
|
+
children
|
|
73
|
+
}),
|
|
74
|
+
isDismissible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Pressable.Pressable, {
|
|
75
|
+
onPress: isDisabled ? void 0 : handleDismiss,
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
accessibilityLabel: dismissButtonAriaLabel,
|
|
78
|
+
accessibilityRole: "button",
|
|
79
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
80
|
+
icon: endIcon ?? "Cross",
|
|
81
|
+
variant: "fill",
|
|
82
|
+
style: generated_styles.chipStyles.icon
|
|
83
|
+
})
|
|
84
|
+
}) : endIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
85
|
+
icon: endIcon,
|
|
86
|
+
variant: "fill",
|
|
87
|
+
style: generated_styles.chipStyles.icon
|
|
88
|
+
})
|
|
89
|
+
] });
|
|
90
|
+
const a11yState = {
|
|
91
|
+
disabled: isDisabled,
|
|
92
|
+
checked: onToggle ? isToggled : void 0
|
|
93
|
+
};
|
|
94
|
+
const sharedProps = {
|
|
95
|
+
ref,
|
|
96
|
+
style: (0, react.useMemo)(() => [generated_styles.chipStyles.root, style], [generated_styles.chipStyles.root, style]),
|
|
97
|
+
flexDirection: "row",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
overflow: "hidden",
|
|
100
|
+
alignSelf: "flex-start",
|
|
101
|
+
maxWidth,
|
|
102
|
+
minWidth,
|
|
103
|
+
disabled: isDisabled,
|
|
104
|
+
opacity: isDisabled ? .5 : void 0,
|
|
105
|
+
accessibilityState: a11yState,
|
|
106
|
+
...rest
|
|
107
|
+
};
|
|
108
|
+
if (isInteractive) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Pressable.Pressable, {
|
|
109
|
+
onPress: handlePress,
|
|
110
|
+
accessibilityRole: onToggle ? "checkbox" : "button",
|
|
111
|
+
...sharedProps,
|
|
112
|
+
children: content
|
|
113
|
+
});
|
|
114
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_HStack.HStack, {
|
|
115
|
+
accessibilityRole: isDismissible ? "button" : void 0,
|
|
116
|
+
...sharedProps,
|
|
117
|
+
...rest,
|
|
118
|
+
children: content
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
Chip.displayName = "Chip";
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
exports.Chip = Chip;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
import { ChipSize, ChipVariant } from "../uds/dist/tokens/types.cjs";
|
|
3
|
+
import { IconSlotType } from "./IconSlot.cjs";
|
|
4
|
+
import * as react5 from "react";
|
|
5
|
+
import { Ref } from "react";
|
|
6
|
+
import { View, ViewProps } from "react-native";
|
|
7
|
+
|
|
8
|
+
//#region src/components/Chip.d.ts
|
|
9
|
+
interface ChipProps extends Omit<ViewProps, 'children'> {
|
|
10
|
+
ref?: Ref<View>;
|
|
11
|
+
/** @default 'primary' */
|
|
12
|
+
variant?: ChipVariant;
|
|
13
|
+
/** @default 'md' */
|
|
14
|
+
size?: ChipSize;
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
/** @default 200 */
|
|
17
|
+
maxWidth?: number;
|
|
18
|
+
startIcon?: IconSlotType;
|
|
19
|
+
endIcon?: IconSlotType;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Called when the chip is pressed. Makes the chip interactive. */
|
|
22
|
+
onPress?: () => void;
|
|
23
|
+
/** Whether the chip is toggled/selected. */
|
|
24
|
+
isToggled?: boolean;
|
|
25
|
+
/** Called when the chip toggle state changes. */
|
|
26
|
+
onToggle?: (toggled: boolean) => void;
|
|
27
|
+
/** Called when the dismiss button is pressed. Shows a dismiss icon. */
|
|
28
|
+
onDismiss?: () => void;
|
|
29
|
+
/** Accessibility label for the dismiss button. */
|
|
30
|
+
dismissButtonAriaLabel?: string;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* **A chip component for selections, filters, or actions**
|
|
35
|
+
*
|
|
36
|
+
* @description
|
|
37
|
+
* Chips help people make selections, filter content, or trigger actions.
|
|
38
|
+
* They can be toggleable, dismissible, or simple pressable elements.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { Chip } from '~/components/ui/Chip';
|
|
43
|
+
*
|
|
44
|
+
* // Basic chip
|
|
45
|
+
* <Chip>Label</Chip>
|
|
46
|
+
*
|
|
47
|
+
* // Toggle chip
|
|
48
|
+
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
49
|
+
*
|
|
50
|
+
* // Dismissible chip
|
|
51
|
+
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
52
|
+
*
|
|
53
|
+
* // With icons
|
|
54
|
+
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const Chip: react5.NamedExoticComponent<ChipProps>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Chip, type ChipProps };
|
|
60
|
+
//# sourceMappingURL=Chip.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip.d.cts","names":[],"sources":["../../src/components/Chip.tsx"],"sourcesContent":[],"mappings":";;;;;;;;UAYU,SAAA,SAAkB,KAAK;QACzB,IAAI;;EADF,OAAA,CAAA,EAGE,WAHQ;EAAa;EACrB,IAAA,CAAA,EAIH,QAJG;EAAJ,QAAA,CAAA,EAAA,MAAA;EAEI;EAEH,QAAA,CAAA,EAAA,MAAA;EAIK,SAAA,CAAA,EAAA,YAAA;EACF,OAAA,CAAA,EAAA,YAAA;EAYC,QAAM,CAAA,EAAA,OAAA;EAtBS;EAAI,OAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EAiD1B;;;;;;;;aA3BO,KAAA,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;cA2Bb,MAAI,MAAA,CAAA,qBAAA"}
|