@cdx-ui/components 0.0.1-alpha.3 → 0.0.1-alpha.31
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/README.md +20 -2
- package/lib/commonjs/components/AlertDialog/index.js +117 -0
- package/lib/commonjs/components/AlertDialog/index.js.map +1 -0
- package/lib/commonjs/components/Avatar/index.js +156 -0
- package/lib/commonjs/components/Avatar/index.js.map +1 -0
- package/lib/commonjs/components/Avatar/styles.js +80 -0
- package/lib/commonjs/components/Avatar/styles.js.map +1 -0
- package/lib/commonjs/components/BottomSheet/index.js +248 -0
- package/lib/commonjs/components/BottomSheet/index.js.map +1 -0
- package/lib/commonjs/components/BottomSheet/styles.js +61 -0
- package/lib/commonjs/components/BottomSheet/styles.js.map +1 -0
- package/lib/commonjs/components/Box/Box.js +1 -0
- package/lib/commonjs/components/Box/Box.js.map +1 -1
- package/lib/commonjs/components/Button/buttonSharedVariants.js +200 -0
- package/lib/commonjs/components/Button/buttonSharedVariants.js.map +1 -0
- package/lib/commonjs/components/Button/index.js +31 -13
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Button/styles.js +170 -187
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/Card/index.js +104 -0
- package/lib/commonjs/components/Card/index.js.map +1 -0
- package/lib/commonjs/components/Card/styles.js +28 -0
- package/lib/commonjs/components/Card/styles.js.map +1 -0
- package/lib/commonjs/components/Checkbox/index.js +180 -0
- package/lib/commonjs/components/Checkbox/index.js.map +1 -0
- package/lib/commonjs/components/Checkbox/styles.js +68 -0
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -0
- package/lib/commonjs/components/Chip/index.js +103 -0
- package/lib/commonjs/components/Chip/index.js.map +1 -0
- package/lib/commonjs/components/Chip/styles.js +50 -0
- package/lib/commonjs/components/Chip/styles.js.map +1 -0
- package/lib/commonjs/components/Dialog/index.js +275 -0
- package/lib/commonjs/components/Dialog/index.js.map +1 -0
- package/lib/commonjs/components/Dialog/styles.js +63 -0
- package/lib/commonjs/components/Dialog/styles.js.map +1 -0
- package/lib/commonjs/components/Form/FormLabelRoot.js +33 -0
- package/lib/commonjs/components/Form/FormLabelRoot.js.map +1 -0
- package/lib/commonjs/components/Form/FormLabelRoot.web.js +18 -0
- package/lib/commonjs/components/Form/FormLabelRoot.web.js.map +1 -0
- package/lib/commonjs/components/Form/FormRoot.js +25 -0
- package/lib/commonjs/components/Form/FormRoot.js.map +1 -0
- package/lib/commonjs/components/Form/FormRoot.web.js +17 -0
- package/lib/commonjs/components/Form/FormRoot.web.js.map +1 -0
- package/lib/commonjs/components/Form/index.js +255 -0
- package/lib/commonjs/components/Form/index.js.map +1 -0
- package/lib/commonjs/components/Form/styles.js +57 -0
- package/lib/commonjs/components/Form/styles.js.map +1 -0
- package/lib/commonjs/components/Heading/index.js +35 -0
- package/lib/commonjs/components/Heading/index.js.map +1 -0
- package/lib/commonjs/components/Heading/styles.js +24 -0
- package/lib/commonjs/components/Heading/styles.js.map +1 -0
- package/lib/commonjs/components/Icon/index.js +61 -0
- package/lib/commonjs/components/Icon/index.js.map +1 -0
- package/lib/commonjs/components/IconButton/index.js +80 -0
- package/lib/commonjs/components/IconButton/index.js.map +1 -0
- package/lib/commonjs/components/IconButton/styles.js +91 -0
- package/lib/commonjs/components/IconButton/styles.js.map +1 -0
- package/lib/commonjs/components/Image/Image.js +69 -0
- package/lib/commonjs/components/Image/Image.js.map +1 -0
- package/lib/commonjs/components/Image/index.js +13 -0
- package/lib/commonjs/components/Image/index.js.map +1 -0
- package/lib/commonjs/components/Input/BaseInput.android.js +20 -0
- package/lib/commonjs/components/Input/BaseInput.android.js.map +1 -0
- package/lib/commonjs/components/Input/index.js +10 -16
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +16 -30
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/Link/index.js +94 -0
- package/lib/commonjs/components/Link/index.js.map +1 -0
- package/lib/commonjs/components/Link/styles.js +16 -0
- package/lib/commonjs/components/Link/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressSegmented/index.js +62 -0
- package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -0
- package/lib/commonjs/components/ProgressSegmented/styles.js +21 -0
- package/lib/commonjs/components/ProgressSegmented/styles.js.map +1 -0
- package/lib/commonjs/components/Select/SelectTriggerHost.js +10 -0
- package/lib/commonjs/components/Select/SelectTriggerHost.js.map +1 -0
- package/lib/commonjs/components/Select/SelectTriggerHost.web.js +98 -0
- package/lib/commonjs/components/Select/SelectTriggerHost.web.js.map +1 -0
- package/lib/commonjs/components/Select/index.js +13 -13
- package/lib/commonjs/components/Select/index.js.map +1 -1
- package/lib/commonjs/components/Select/styles.js +29 -53
- package/lib/commonjs/components/Select/styles.js.map +1 -1
- package/lib/commonjs/components/Stack/HStack.js +8 -21
- package/lib/commonjs/components/Stack/HStack.js.map +1 -1
- package/lib/commonjs/components/Stack/VStack.js +8 -21
- package/lib/commonjs/components/Stack/VStack.js.map +1 -1
- package/lib/commonjs/components/Stack/styles.js +39 -0
- package/lib/commonjs/components/Stack/styles.js.map +1 -0
- package/lib/commonjs/components/Switch/BaseSwitch.js +46 -0
- package/lib/commonjs/components/Switch/BaseSwitch.js.map +1 -0
- package/lib/commonjs/components/Switch/BaseSwitch.web.js +56 -0
- package/lib/commonjs/components/Switch/BaseSwitch.web.js.map +1 -0
- package/lib/commonjs/components/Switch/index.js +13 -0
- package/lib/commonjs/components/Switch/index.js.map +1 -0
- package/lib/commonjs/components/Switch/styles.js +128 -0
- package/lib/commonjs/components/Switch/styles.js.map +1 -0
- package/lib/commonjs/components/Text/index.js +18 -9
- package/lib/commonjs/components/Text/index.js.map +1 -1
- package/lib/commonjs/components/Text/styles.js +24 -0
- package/lib/commonjs/components/Text/styles.js.map +1 -0
- package/lib/commonjs/components/VirtualizedList/index.js +19 -0
- package/lib/commonjs/components/VirtualizedList/index.js.map +1 -0
- package/lib/commonjs/components/index.js +192 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +40 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/metro/withCdxMetroConfig.js +24 -0
- package/lib/commonjs/metro/withCdxMetroConfig.js.map +1 -0
- package/lib/commonjs/styles/index.js +17 -0
- package/lib/commonjs/styles/index.js.map +1 -0
- package/lib/commonjs/styles/primitives.js +123 -0
- package/lib/commonjs/styles/primitives.js.map +1 -0
- package/lib/module/components/AlertDialog/index.js +112 -0
- package/lib/module/components/AlertDialog/index.js.map +1 -0
- package/lib/module/components/Avatar/index.js +152 -0
- package/lib/module/components/Avatar/index.js.map +1 -0
- package/lib/module/components/Avatar/styles.js +77 -0
- package/lib/module/components/Avatar/styles.js.map +1 -0
- package/lib/module/components/BottomSheet/index.js +242 -0
- package/lib/module/components/BottomSheet/index.js.map +1 -0
- package/lib/module/components/BottomSheet/styles.js +58 -0
- package/lib/module/components/BottomSheet/styles.js.map +1 -0
- package/lib/module/components/Box/Box.js +1 -0
- package/lib/module/components/Box/Box.js.map +1 -1
- package/lib/module/components/Button/buttonSharedVariants.js +195 -0
- package/lib/module/components/Button/buttonSharedVariants.js.map +1 -0
- package/lib/module/components/Button/index.js +32 -14
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Button/styles.js +168 -186
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/Card/index.js +100 -0
- package/lib/module/components/Card/index.js.map +1 -0
- package/lib/module/components/Card/styles.js +25 -0
- package/lib/module/components/Card/styles.js.map +1 -0
- package/lib/module/components/Checkbox/index.js +176 -0
- package/lib/module/components/Checkbox/index.js.map +1 -0
- package/lib/module/components/Checkbox/styles.js +64 -0
- package/lib/module/components/Checkbox/styles.js.map +1 -0
- package/lib/module/components/Chip/index.js +99 -0
- package/lib/module/components/Chip/index.js.map +1 -0
- package/lib/module/components/Chip/styles.js +46 -0
- package/lib/module/components/Chip/styles.js.map +1 -0
- package/lib/module/components/Dialog/index.js +267 -0
- package/lib/module/components/Dialog/index.js.map +1 -0
- package/lib/module/components/Dialog/styles.js +60 -0
- package/lib/module/components/Dialog/styles.js.map +1 -0
- package/lib/module/components/Form/FormLabelRoot.js +29 -0
- package/lib/module/components/Form/FormLabelRoot.js.map +1 -0
- package/lib/module/components/Form/FormLabelRoot.web.js +13 -0
- package/lib/module/components/Form/FormLabelRoot.web.js.map +1 -0
- package/lib/module/components/Form/FormRoot.js +21 -0
- package/lib/module/components/Form/FormRoot.js.map +1 -0
- package/lib/module/components/Form/FormRoot.web.js +12 -0
- package/lib/module/components/Form/FormRoot.web.js.map +1 -0
- package/lib/module/components/Form/index.js +252 -0
- package/lib/module/components/Form/index.js.map +1 -0
- package/lib/module/components/Form/styles.js +53 -0
- package/lib/module/components/Form/styles.js.map +1 -0
- package/lib/module/components/Heading/index.js +31 -0
- package/lib/module/components/Heading/index.js.map +1 -0
- package/lib/module/components/Heading/styles.js +20 -0
- package/lib/module/components/Heading/styles.js.map +1 -0
- package/lib/module/components/Icon/index.js +57 -0
- package/lib/module/components/Icon/index.js.map +1 -0
- package/lib/module/components/IconButton/index.js +76 -0
- package/lib/module/components/IconButton/index.js.map +1 -0
- package/lib/module/components/IconButton/styles.js +87 -0
- package/lib/module/components/IconButton/styles.js.map +1 -0
- package/lib/module/components/Image/Image.js +67 -0
- package/lib/module/components/Image/Image.js.map +1 -0
- package/lib/module/components/Image/index.js +4 -0
- package/lib/module/components/Image/index.js.map +1 -0
- package/lib/module/components/Input/BaseInput.android.js +16 -0
- package/lib/module/components/Input/BaseInput.android.js.map +1 -0
- package/lib/module/components/Input/index.js +10 -16
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Input/styles.js +16 -30
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/Link/index.js +85 -0
- package/lib/module/components/Link/index.js.map +1 -0
- package/lib/module/components/Link/styles.js +12 -0
- package/lib/module/components/Link/styles.js.map +1 -0
- package/lib/module/components/ProgressSegmented/index.js +58 -0
- package/lib/module/components/ProgressSegmented/index.js.map +1 -0
- package/lib/module/components/ProgressSegmented/styles.js +17 -0
- package/lib/module/components/ProgressSegmented/styles.js.map +1 -0
- package/lib/module/components/Select/SelectTriggerHost.js +7 -0
- package/lib/module/components/Select/SelectTriggerHost.js.map +1 -0
- package/lib/module/components/Select/SelectTriggerHost.web.js +93 -0
- package/lib/module/components/Select/SelectTriggerHost.web.js.map +1 -0
- package/lib/module/components/Select/index.js +14 -14
- package/lib/module/components/Select/index.js.map +1 -1
- package/lib/module/components/Select/styles.js +29 -53
- package/lib/module/components/Select/styles.js.map +1 -1
- package/lib/module/components/Stack/HStack.js +8 -21
- package/lib/module/components/Stack/HStack.js.map +1 -1
- package/lib/module/components/Stack/VStack.js +8 -21
- package/lib/module/components/Stack/VStack.js.map +1 -1
- package/lib/module/components/Stack/styles.js +35 -0
- package/lib/module/components/Stack/styles.js.map +1 -0
- package/lib/module/components/Switch/BaseSwitch.js +42 -0
- package/lib/module/components/Switch/BaseSwitch.js.map +1 -0
- package/lib/module/components/Switch/BaseSwitch.web.js +52 -0
- package/lib/module/components/Switch/BaseSwitch.web.js.map +1 -0
- package/lib/module/components/Switch/index.js +9 -0
- package/lib/module/components/Switch/index.js.map +1 -0
- package/lib/module/components/Switch/styles.js +125 -0
- package/lib/module/components/Switch/styles.js.map +1 -0
- package/lib/module/components/Text/index.js +19 -1
- package/lib/module/components/Text/index.js.map +1 -1
- package/lib/module/components/Text/styles.js +20 -0
- package/lib/module/components/Text/styles.js.map +1 -0
- package/lib/module/components/VirtualizedList/index.js +15 -0
- package/lib/module/components/VirtualizedList/index.js.map +1 -0
- package/lib/module/components/index.js +16 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/metro/withCdxMetroConfig.js +20 -0
- package/lib/module/metro/withCdxMetroConfig.js.map +1 -0
- package/lib/module/styles/index.js +4 -0
- package/lib/module/styles/index.js.map +1 -0
- package/lib/module/styles/primitives.js +119 -0
- package/lib/module/styles/primitives.js.map +1 -0
- package/lib/typescript/components/AlertDialog/index.d.ts +30 -0
- package/lib/typescript/components/AlertDialog/index.d.ts.map +1 -0
- package/lib/typescript/components/Avatar/index.d.ts +40 -0
- package/lib/typescript/components/Avatar/index.d.ts.map +1 -0
- package/lib/typescript/components/Avatar/styles.d.ts +16 -0
- package/lib/typescript/components/Avatar/styles.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet/index.d.ts +61 -0
- package/lib/typescript/components/BottomSheet/index.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet/styles.d.ts +16 -0
- package/lib/typescript/components/BottomSheet/styles.d.ts.map +1 -0
- package/lib/typescript/components/Box/Box.d.ts +1 -0
- package/lib/typescript/components/Box/Box.d.ts.map +1 -1
- package/lib/typescript/components/Button/buttonSharedVariants.d.ts +29 -0
- package/lib/typescript/components/Button/buttonSharedVariants.d.ts.map +1 -0
- package/lib/typescript/components/Button/index.d.ts +6 -3
- package/lib/typescript/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/components/Button/styles.d.ts +14 -8
- package/lib/typescript/components/Button/styles.d.ts.map +1 -1
- package/lib/typescript/components/Card/index.d.ts +30 -0
- package/lib/typescript/components/Card/index.d.ts.map +1 -0
- package/lib/typescript/components/Card/styles.d.ts +6 -0
- package/lib/typescript/components/Card/styles.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/index.d.ts +46 -0
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/styles.d.ts +18 -0
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -0
- package/lib/typescript/components/Chip/index.d.ts +27 -0
- package/lib/typescript/components/Chip/index.d.ts.map +1 -0
- package/lib/typescript/components/Chip/styles.d.ts +12 -0
- package/lib/typescript/components/Chip/styles.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/index.d.ts +61 -0
- package/lib/typescript/components/Dialog/index.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/styles.d.ts +14 -0
- package/lib/typescript/components/Dialog/styles.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormLabelRoot.d.ts +18 -0
- package/lib/typescript/components/Form/FormLabelRoot.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormLabelRoot.web.d.ts +20 -0
- package/lib/typescript/components/Form/FormLabelRoot.web.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormRoot.d.ts +12 -0
- package/lib/typescript/components/Form/FormRoot.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormRoot.web.d.ts +10 -0
- package/lib/typescript/components/Form/FormRoot.web.d.ts.map +1 -0
- package/lib/typescript/components/Form/index.d.ts +64 -0
- package/lib/typescript/components/Form/index.d.ts.map +1 -0
- package/lib/typescript/components/Form/styles.d.ts +22 -0
- package/lib/typescript/components/Form/styles.d.ts.map +1 -0
- package/lib/typescript/components/Heading/index.d.ts +10 -0
- package/lib/typescript/components/Heading/index.d.ts.map +1 -0
- package/lib/typescript/components/Heading/styles.d.ts +6 -0
- package/lib/typescript/components/Heading/styles.d.ts.map +1 -0
- package/lib/typescript/components/Icon/index.d.ts +27 -0
- package/lib/typescript/components/Icon/index.d.ts.map +1 -0
- package/lib/typescript/components/IconButton/index.d.ts +15 -0
- package/lib/typescript/components/IconButton/index.d.ts.map +1 -0
- package/lib/typescript/components/IconButton/styles.d.ts +16 -0
- package/lib/typescript/components/IconButton/styles.d.ts.map +1 -0
- package/lib/typescript/components/Image/Image.d.ts +47 -0
- package/lib/typescript/components/Image/Image.d.ts.map +1 -0
- package/lib/typescript/components/Image/index.d.ts +2 -0
- package/lib/typescript/components/Image/index.d.ts.map +1 -0
- package/lib/typescript/components/Input/BaseInput.android.d.ts +3 -0
- package/lib/typescript/components/Input/BaseInput.android.d.ts.map +1 -0
- package/lib/typescript/components/Input/index.d.ts +7 -5
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts +5 -7
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/Link/index.d.ts +26 -0
- package/lib/typescript/components/Link/index.d.ts.map +1 -0
- package/lib/typescript/components/Link/styles.d.ts +4 -0
- package/lib/typescript/components/Link/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressSegmented/index.d.ts +15 -0
- package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -0
- package/lib/typescript/components/ProgressSegmented/styles.d.ts +8 -0
- package/lib/typescript/components/ProgressSegmented/styles.d.ts.map +1 -0
- package/lib/typescript/components/Select/SelectTriggerHost.d.ts +3 -0
- package/lib/typescript/components/Select/SelectTriggerHost.d.ts.map +1 -0
- package/lib/typescript/components/Select/SelectTriggerHost.web.d.ts +13 -0
- package/lib/typescript/components/Select/SelectTriggerHost.web.d.ts.map +1 -0
- package/lib/typescript/components/Select/index.d.ts +7 -4
- package/lib/typescript/components/Select/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/styles.d.ts +6 -8
- package/lib/typescript/components/Select/styles.d.ts.map +1 -1
- package/lib/typescript/components/Stack/HStack.d.ts +1 -12
- package/lib/typescript/components/Stack/HStack.d.ts.map +1 -1
- package/lib/typescript/components/Stack/VStack.d.ts +1 -12
- package/lib/typescript/components/Stack/VStack.d.ts.map +1 -1
- package/lib/typescript/components/Stack/styles.d.ts +10 -0
- package/lib/typescript/components/Stack/styles.d.ts.map +1 -0
- package/lib/typescript/components/Switch/BaseSwitch.d.ts +9 -0
- package/lib/typescript/components/Switch/BaseSwitch.d.ts.map +1 -0
- package/lib/typescript/components/Switch/BaseSwitch.web.d.ts +15 -0
- package/lib/typescript/components/Switch/BaseSwitch.web.d.ts.map +1 -0
- package/lib/typescript/components/Switch/index.d.ts +7 -0
- package/lib/typescript/components/Switch/index.d.ts.map +1 -0
- package/lib/typescript/components/Switch/styles.d.ts +26 -0
- package/lib/typescript/components/Switch/styles.d.ts.map +1 -0
- package/lib/typescript/components/Text/index.d.ts +9 -1
- package/lib/typescript/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/components/Text/styles.d.ts +6 -0
- package/lib/typescript/components/Text/styles.d.ts.map +1 -0
- package/lib/typescript/components/VirtualizedList/index.d.ts +8 -0
- package/lib/typescript/components/VirtualizedList/index.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +16 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/metro/withCdxMetroConfig.d.ts +19 -0
- package/lib/typescript/metro/withCdxMetroConfig.d.ts.map +1 -0
- package/lib/typescript/styles/index.d.ts +2 -0
- package/lib/typescript/styles/index.d.ts.map +1 -0
- package/lib/typescript/styles/primitives.d.ts +85 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -0
- package/package.json +23 -16
- package/src/components/AlertDialog/index.tsx +124 -0
- package/src/components/Avatar/index.tsx +172 -0
- package/src/components/Avatar/styles.ts +83 -0
- package/src/components/BottomSheet/index.tsx +316 -0
- package/src/components/BottomSheet/styles.ts +79 -0
- package/src/components/Box/Box.tsx +1 -0
- package/src/components/Button/buttonSharedVariants.ts +281 -0
- package/src/components/Button/index.tsx +24 -15
- package/src/components/Button/styles.ts +195 -229
- package/src/components/Card/index.tsx +115 -0
- package/src/components/Card/styles.ts +41 -0
- package/src/components/Checkbox/index.tsx +207 -0
- package/src/components/Checkbox/styles.ts +103 -0
- package/src/components/Chip/index.tsx +91 -0
- package/src/components/Chip/styles.ts +51 -0
- package/src/components/Dialog/index.tsx +304 -0
- package/src/components/Dialog/styles.ts +88 -0
- package/src/components/Form/FormLabelRoot.tsx +33 -0
- package/src/components/Form/FormLabelRoot.web.tsx +18 -0
- package/src/components/Form/FormRoot.tsx +19 -0
- package/src/components/Form/FormRoot.web.tsx +12 -0
- package/src/components/Form/index.tsx +272 -0
- package/src/components/Form/styles.ts +75 -0
- package/src/components/Heading/index.tsx +36 -0
- package/src/components/Heading/styles.tsx +26 -0
- package/src/components/Icon/index.tsx +54 -0
- package/src/components/IconButton/index.tsx +93 -0
- package/src/components/IconButton/styles.ts +131 -0
- package/src/components/Image/Image.tsx +77 -0
- package/src/components/Image/index.ts +1 -0
- package/src/components/Input/BaseInput.android.tsx +13 -0
- package/src/components/Input/index.tsx +9 -22
- package/src/components/Input/styles.ts +42 -37
- package/src/components/Link/index.tsx +83 -0
- package/src/components/Link/styles.ts +20 -0
- package/src/components/ProgressSegmented/index.tsx +81 -0
- package/src/components/ProgressSegmented/styles.ts +19 -0
- package/src/components/Select/SelectTriggerHost.tsx +4 -0
- package/src/components/Select/SelectTriggerHost.web.tsx +136 -0
- package/src/components/Select/index.tsx +14 -14
- package/src/components/Select/styles.ts +68 -75
- package/src/components/Stack/HStack.tsx +8 -19
- package/src/components/Stack/VStack.tsx +8 -23
- package/src/components/Stack/styles.ts +37 -0
- package/src/components/Switch/BaseSwitch.tsx +38 -0
- package/src/components/Switch/BaseSwitch.web.tsx +69 -0
- package/src/components/Switch/index.tsx +11 -0
- package/src/components/Switch/styles.ts +120 -0
- package/src/components/Text/index.tsx +16 -0
- package/src/components/Text/styles.tsx +26 -0
- package/src/components/VirtualizedList/index.tsx +19 -0
- package/src/components/index.ts +16 -0
- package/src/index.ts +3 -0
- package/src/metro/withCdxMetroConfig.ts +29 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/primitives.ts +107 -0
- package/lib/commonjs/components/Text/Text.js +0 -30
- package/lib/commonjs/components/Text/Text.js.map +0 -1
- package/lib/module/components/Text/Text.js +0 -26
- package/lib/module/components/Text/Text.js.map +0 -1
- package/lib/typescript/components/Text/Text.d.ts +0 -11
- package/lib/typescript/components/Text/Text.d.ts.map +0 -1
- package/src/components/Text/Text.tsx +0 -58
- package/src/components/Text/index.ts +0 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Text, View, type ViewProps, type TextProps } from 'react-native';
|
|
3
|
+
import { createForm, type IFormProps, type IFormFieldProps } from '@cdx-ui/primitives';
|
|
4
|
+
import { cn, withStyleContext, useStyleContext } from '@cdx-ui/utils';
|
|
5
|
+
import { Icon, type IconProps } from '../Icon';
|
|
6
|
+
import { BaseFormRoot, type BaseFormRootProps } from './FormRoot';
|
|
7
|
+
import { FormLabelRoot } from './FormLabelRoot';
|
|
8
|
+
import {
|
|
9
|
+
formRootVariants,
|
|
10
|
+
formFieldVariants,
|
|
11
|
+
formLabelVariants,
|
|
12
|
+
formHelperVariants,
|
|
13
|
+
formHelperTextVariants,
|
|
14
|
+
formErrorVariants,
|
|
15
|
+
formErrorTextVariants,
|
|
16
|
+
formErrorIconVariants,
|
|
17
|
+
} from './styles';
|
|
18
|
+
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// SCOPE + CONTEXT
|
|
21
|
+
// =============================================================================
|
|
22
|
+
|
|
23
|
+
const SCOPE = 'FORM';
|
|
24
|
+
|
|
25
|
+
const FieldRoot = withStyleContext(View, SCOPE);
|
|
26
|
+
|
|
27
|
+
interface FormFieldStyleContext {
|
|
28
|
+
size?: 'default' | 'small';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const useFormStyleContext = () => useStyleContext(SCOPE) as FormFieldStyleContext;
|
|
32
|
+
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// PRIMITIVE
|
|
35
|
+
// =============================================================================
|
|
36
|
+
|
|
37
|
+
const FormPrimitive = createForm({
|
|
38
|
+
Root: BaseFormRoot,
|
|
39
|
+
Field: FieldRoot,
|
|
40
|
+
Error: View,
|
|
41
|
+
ErrorText: Text,
|
|
42
|
+
ErrorIcon: View,
|
|
43
|
+
Label: FormLabelRoot,
|
|
44
|
+
Helper: View,
|
|
45
|
+
HelperText: Text,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// FORM ROOT (container — <form> on web, <View> on RN)
|
|
50
|
+
// =============================================================================
|
|
51
|
+
|
|
52
|
+
export interface FormProps extends BaseFormRootProps, IFormProps {
|
|
53
|
+
className?: string;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const FormRoot = forwardRef<View, FormProps>(({ className, children, style, ...props }, ref) => {
|
|
58
|
+
const computedClassName = cn(formRootVariants(), className);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<FormPrimitive ref={ref} className={computedClassName} style={style} {...props}>
|
|
62
|
+
{children}
|
|
63
|
+
</FormPrimitive>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
FormRoot.displayName = 'Form';
|
|
68
|
+
|
|
69
|
+
// =============================================================================
|
|
70
|
+
// FORM FIELD (per-field wrapper — provides context for label/error/helper/input)
|
|
71
|
+
// =============================================================================
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Field wrapper + context. For **initial focus**, pass `autoFocus` on `Input.Field` (not here).
|
|
75
|
+
*/
|
|
76
|
+
export interface FormFieldProps extends Omit<ViewProps, 'id' | 'name'>, IFormFieldProps {
|
|
77
|
+
className?: string;
|
|
78
|
+
children?: ReactNode;
|
|
79
|
+
size?: 'default' | 'small';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const FormField = forwardRef<View, FormFieldProps>(
|
|
83
|
+
({ size = 'default', className, children, style, ...props }, ref) => {
|
|
84
|
+
const computedClassName = cn(formFieldVariants(), className);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<FormPrimitive.Field
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={computedClassName}
|
|
90
|
+
style={style}
|
|
91
|
+
context={{ size }}
|
|
92
|
+
{...props}
|
|
93
|
+
>
|
|
94
|
+
{children}
|
|
95
|
+
</FormPrimitive.Field>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
FormField.displayName = 'Form.Field';
|
|
101
|
+
|
|
102
|
+
// =============================================================================
|
|
103
|
+
// FORM LABEL
|
|
104
|
+
// =============================================================================
|
|
105
|
+
|
|
106
|
+
export interface FormLabelProps extends ViewProps {
|
|
107
|
+
className?: string;
|
|
108
|
+
children?: ReactNode;
|
|
109
|
+
/** @platform web — passed to `<label htmlFor>`; defaults to the field input id. */
|
|
110
|
+
htmlFor?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// TODO: Accept accessibility labels for required indicator as props to support i18n
|
|
114
|
+
|
|
115
|
+
const FormLabel = forwardRef<View, FormLabelProps>(
|
|
116
|
+
({ className, children, style, htmlFor, ...props }, ref) => {
|
|
117
|
+
const { size } = useFormStyleContext();
|
|
118
|
+
const labelClassName = cn(formLabelVariants({ size }), className);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<FormPrimitive.Label
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={labelClassName}
|
|
124
|
+
style={style}
|
|
125
|
+
htmlFor={htmlFor}
|
|
126
|
+
requiredIndicator={
|
|
127
|
+
<Text className="text-red-500" aria-hidden>
|
|
128
|
+
{' *'}
|
|
129
|
+
</Text>
|
|
130
|
+
}
|
|
131
|
+
{...props}
|
|
132
|
+
>
|
|
133
|
+
{children}
|
|
134
|
+
</FormPrimitive.Label>
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
FormLabel.displayName = 'Form.Label';
|
|
140
|
+
|
|
141
|
+
// =============================================================================
|
|
142
|
+
// FORM HELPER
|
|
143
|
+
// =============================================================================
|
|
144
|
+
|
|
145
|
+
export interface FormHelperProps extends ViewProps {
|
|
146
|
+
className?: string;
|
|
147
|
+
children?: ReactNode;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const FormHelper = forwardRef<View, FormHelperProps>(
|
|
151
|
+
({ className, children, style, ...props }, ref) => {
|
|
152
|
+
const computedClassName = cn(formHelperVariants(), className);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<FormPrimitive.Helper ref={ref} className={computedClassName} style={style} {...props}>
|
|
156
|
+
{children}
|
|
157
|
+
</FormPrimitive.Helper>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
FormHelper.displayName = 'Form.Helper';
|
|
163
|
+
|
|
164
|
+
// =============================================================================
|
|
165
|
+
// FORM HELPER TEXT
|
|
166
|
+
// =============================================================================
|
|
167
|
+
|
|
168
|
+
export interface FormHelperTextProps extends TextProps {
|
|
169
|
+
className?: string;
|
|
170
|
+
children?: ReactNode;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const FormHelperText = forwardRef<Text, FormHelperTextProps>(
|
|
174
|
+
({ className, children, style, ...props }, ref) => {
|
|
175
|
+
const { size } = useFormStyleContext();
|
|
176
|
+
const computedClassName = cn(formHelperTextVariants({ size }), className);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<FormPrimitive.HelperText ref={ref} className={computedClassName} style={style} {...props}>
|
|
180
|
+
{children}
|
|
181
|
+
</FormPrimitive.HelperText>
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
FormHelperText.displayName = 'Form.HelperText';
|
|
187
|
+
|
|
188
|
+
// =============================================================================
|
|
189
|
+
// FORM ERROR
|
|
190
|
+
// =============================================================================
|
|
191
|
+
|
|
192
|
+
export interface FormErrorProps extends ViewProps {
|
|
193
|
+
className?: string;
|
|
194
|
+
children?: ReactNode;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const FormError = forwardRef<View, FormErrorProps>(
|
|
198
|
+
({ className, children, style, ...props }, ref) => {
|
|
199
|
+
const computedClassName = cn(formErrorVariants(), className);
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<FormPrimitive.Error ref={ref} className={computedClassName} style={style} {...props}>
|
|
203
|
+
{children}
|
|
204
|
+
</FormPrimitive.Error>
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
FormError.displayName = 'Form.Error';
|
|
210
|
+
|
|
211
|
+
// =============================================================================
|
|
212
|
+
// FORM ERROR TEXT
|
|
213
|
+
// =============================================================================
|
|
214
|
+
|
|
215
|
+
export interface FormErrorTextProps extends TextProps {
|
|
216
|
+
className?: string;
|
|
217
|
+
children?: ReactNode;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const FormErrorText = forwardRef<Text, FormErrorTextProps>(
|
|
221
|
+
({ className, children, style, ...props }, ref) => {
|
|
222
|
+
const { size } = useFormStyleContext();
|
|
223
|
+
const computedClassName = cn(formErrorTextVariants({ size }), className);
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<FormPrimitive.ErrorText ref={ref} className={computedClassName} style={style} {...props}>
|
|
227
|
+
{children}
|
|
228
|
+
</FormPrimitive.ErrorText>
|
|
229
|
+
);
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
FormErrorText.displayName = 'Form.ErrorText';
|
|
234
|
+
|
|
235
|
+
// =============================================================================
|
|
236
|
+
// FORM ERROR ICON
|
|
237
|
+
// =============================================================================
|
|
238
|
+
|
|
239
|
+
export interface FormErrorIconProps extends Omit<IconProps, 'children'> {}
|
|
240
|
+
|
|
241
|
+
const FormErrorIcon = ({ className, style, as, ...props }: FormErrorIconProps) => {
|
|
242
|
+
const { size } = useFormStyleContext();
|
|
243
|
+
const computedClassName = cn(formErrorIconVariants({ size }), className);
|
|
244
|
+
|
|
245
|
+
return <Icon as={as} className={computedClassName} style={style} {...props} />;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
FormErrorIcon.displayName = 'Form.ErrorIcon';
|
|
249
|
+
|
|
250
|
+
// =============================================================================
|
|
251
|
+
// COMPOUND EXPORT
|
|
252
|
+
// =============================================================================
|
|
253
|
+
|
|
254
|
+
type FormCompoundComponent = typeof FormRoot & {
|
|
255
|
+
Field: typeof FormField;
|
|
256
|
+
Label: typeof FormLabel;
|
|
257
|
+
Helper: typeof FormHelper;
|
|
258
|
+
HelperText: typeof FormHelperText;
|
|
259
|
+
Error: typeof FormError;
|
|
260
|
+
ErrorText: typeof FormErrorText;
|
|
261
|
+
ErrorIcon: typeof FormErrorIcon;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const Form = Object.assign(FormRoot, {
|
|
265
|
+
Field: FormField,
|
|
266
|
+
Label: FormLabel,
|
|
267
|
+
Helper: FormHelper,
|
|
268
|
+
HelperText: FormHelperText,
|
|
269
|
+
Error: FormError,
|
|
270
|
+
ErrorText: FormErrorText,
|
|
271
|
+
ErrorIcon: FormErrorIcon,
|
|
272
|
+
}) as FormCompoundComponent;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import {
|
|
3
|
+
COLOR_TEXT_INVALID,
|
|
4
|
+
COLOR_TEXT_SECONDARY,
|
|
5
|
+
DISABLED_OPACITY,
|
|
6
|
+
} from '../../styles/primitives';
|
|
7
|
+
|
|
8
|
+
export const formRootVariants = cva(['flex-col gap-4']);
|
|
9
|
+
|
|
10
|
+
export const formFieldVariants = cva(['flex-col gap-1.5 mb-4', 'web:last:mb-0', DISABLED_OPACITY]);
|
|
11
|
+
|
|
12
|
+
export const formLabelVariants = cva(
|
|
13
|
+
[
|
|
14
|
+
'flex-row items-center',
|
|
15
|
+
DISABLED_OPACITY,
|
|
16
|
+
'web:cursor-pointer',
|
|
17
|
+
'font-medium data-[invalid=true]:text-red-600',
|
|
18
|
+
],
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
default: 'text-sm',
|
|
23
|
+
small: 'text-xs',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
size: 'default',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const formHelperVariants = cva(['flex-row items-center']);
|
|
33
|
+
|
|
34
|
+
export const formHelperTextVariants = cva([COLOR_TEXT_SECONDARY], {
|
|
35
|
+
variants: {
|
|
36
|
+
size: {
|
|
37
|
+
default: 'text-xs',
|
|
38
|
+
small: 'text-[11px]',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
size: 'default',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const formErrorVariants = cva(['flex-row items-center gap-1']);
|
|
47
|
+
|
|
48
|
+
export const formErrorTextVariants = cva([COLOR_TEXT_INVALID, 'font-medium'], {
|
|
49
|
+
variants: {
|
|
50
|
+
size: {
|
|
51
|
+
default: 'text-xs',
|
|
52
|
+
small: 'text-[11px]',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
size: 'default',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const formErrorIconVariants = cva([COLOR_TEXT_INVALID], {
|
|
61
|
+
variants: {
|
|
62
|
+
size: {
|
|
63
|
+
default: 'size-3.5',
|
|
64
|
+
small: 'size-3',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
defaultVariants: {
|
|
68
|
+
size: 'default',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type FormLabelVariantProps = VariantProps<typeof formLabelVariants>;
|
|
73
|
+
export type FormHelperTextVariantProps = VariantProps<typeof formHelperTextVariants>;
|
|
74
|
+
export type FormErrorTextVariantProps = VariantProps<typeof formErrorTextVariants>;
|
|
75
|
+
export type FormErrorIconVariantProps = VariantProps<typeof formErrorIconVariants>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { forwardRef, memo, type ComponentRef, type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { cn } from '@cdx-ui/utils';
|
|
4
|
+
import { headingStyle, type HeadingVariantProps } from './styles';
|
|
5
|
+
|
|
6
|
+
const sizeToLevel = {
|
|
7
|
+
xl: 1,
|
|
8
|
+
lg: 2,
|
|
9
|
+
md: 3,
|
|
10
|
+
sm: 4,
|
|
11
|
+
xs: 5,
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
export type HeadingProps = HeadingVariantProps &
|
|
15
|
+
ComponentPropsWithoutRef<typeof Text> & {
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Heading = memo(
|
|
20
|
+
forwardRef<ComponentRef<typeof Text>, HeadingProps>(function Heading(
|
|
21
|
+
{ className, size = 'lg', ...props },
|
|
22
|
+
ref,
|
|
23
|
+
) {
|
|
24
|
+
return (
|
|
25
|
+
<Text
|
|
26
|
+
role="heading"
|
|
27
|
+
aria-level={sizeToLevel[size ?? 'lg']}
|
|
28
|
+
className={cn(headingStyle({ size }), className)}
|
|
29
|
+
{...props}
|
|
30
|
+
ref={ref}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
Heading.displayName = 'Heading';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { COLOR_TEXT_PRIMARY } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
export const headingStyle = cva(
|
|
6
|
+
[
|
|
7
|
+
`${COLOR_TEXT_PRIMARY} font-semibold tracking-tight my-0`,
|
|
8
|
+
Platform.select({
|
|
9
|
+
web: 'font-sans bg-transparent display-inline no-underline',
|
|
10
|
+
default: '',
|
|
11
|
+
}),
|
|
12
|
+
],
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
size: {
|
|
16
|
+
xl: 'text-6xl',
|
|
17
|
+
lg: 'text-5xl',
|
|
18
|
+
md: 'text-4xl',
|
|
19
|
+
sm: 'text-3xl',
|
|
20
|
+
xs: 'text-2xl',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export type HeadingVariantProps = VariantProps<typeof headingStyle>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { withUniwind } from 'uniwind';
|
|
2
|
+
import { cn } from '@cdx-ui/utils';
|
|
3
|
+
import type { CdxIcon, CdxIconProps } from '@cdx-ui/icons';
|
|
4
|
+
import { COLOR_TEXT_PRIMARY } from '../../styles/primitives';
|
|
5
|
+
|
|
6
|
+
export type IconProps = CdxIconProps & {
|
|
7
|
+
className?: string; // TODO: Why does this need to specified manually?
|
|
8
|
+
as: CdxIcon;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function IconImpl({ as: IconComponent, ...props }: IconProps) {
|
|
12
|
+
return <IconComponent {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const StyledIcon = withUniwind(IconImpl, {
|
|
16
|
+
size: {
|
|
17
|
+
fromClassName: 'className',
|
|
18
|
+
styleProperty: 'width',
|
|
19
|
+
},
|
|
20
|
+
color: {
|
|
21
|
+
fromClassName: 'className',
|
|
22
|
+
styleProperty: 'color',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A wrapper component for CDX icons with Uniwind `className` support via `withUniwind`.
|
|
28
|
+
*
|
|
29
|
+
* This component allows you to render any CDX icon while applying utility classes
|
|
30
|
+
* using `uniwind`. It avoids the need to wrap or configure each icon individually.
|
|
31
|
+
*
|
|
32
|
+
* @component
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { Icon } from '@cdx-ui/components';
|
|
36
|
+
* import { ArrowRight } from '@cdx-ui/icons';
|
|
37
|
+
*
|
|
38
|
+
* <Icon as={ArrowRight} className="text-red-500 size-4" />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {CdxIcon} as - The CDX icon component to render.
|
|
42
|
+
* @param {string} className - Utility classes to style the icon using Uniwind.
|
|
43
|
+
* @param {number} size - Icon size (overrides the size class).
|
|
44
|
+
* @param {...CdxIconProps} ...props - Additional icon props passed to the "as" icon.
|
|
45
|
+
*/
|
|
46
|
+
export function Icon({ as: IconComponent, className, ...props }: IconProps) {
|
|
47
|
+
return (
|
|
48
|
+
<StyledIcon
|
|
49
|
+
as={IconComponent}
|
|
50
|
+
className={cn(COLOR_TEXT_PRIMARY, 'size-5', className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { ActivityIndicator, Pressable, Text, View, type PressableProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
createButton,
|
|
5
|
+
dataAttributes,
|
|
6
|
+
type IButtonProps,
|
|
7
|
+
useButtonContext,
|
|
8
|
+
} from '@cdx-ui/primitives';
|
|
9
|
+
import type { CdxIcon } from '@cdx-ui/icons';
|
|
10
|
+
import { cn } from '@cdx-ui/utils';
|
|
11
|
+
import { Icon, type IconProps } from '../Icon';
|
|
12
|
+
import {
|
|
13
|
+
type IconButtonVariantProps,
|
|
14
|
+
iconButtonGlyphVariants,
|
|
15
|
+
iconButtonIconColorVariants,
|
|
16
|
+
iconButtonRootVariants,
|
|
17
|
+
} from './styles';
|
|
18
|
+
|
|
19
|
+
const IconButtonPrimitive = createButton({
|
|
20
|
+
Root: Pressable,
|
|
21
|
+
Text,
|
|
22
|
+
Group: View,
|
|
23
|
+
Spinner: ActivityIndicator,
|
|
24
|
+
Icon: View,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function IconButtonGlyph({ as: IconComponent, className }: { as: CdxIcon; className: string }) {
|
|
28
|
+
const { hover, focus, active, disabled, focusVisible } = useButtonContext();
|
|
29
|
+
return (
|
|
30
|
+
<Icon
|
|
31
|
+
as={IconComponent}
|
|
32
|
+
className={className}
|
|
33
|
+
{...dataAttributes({
|
|
34
|
+
hover,
|
|
35
|
+
focus,
|
|
36
|
+
active,
|
|
37
|
+
disabled,
|
|
38
|
+
focusVisible,
|
|
39
|
+
})}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IconButtonProps extends PressableProps, IButtonProps, IconButtonVariantProps {
|
|
45
|
+
className?: string;
|
|
46
|
+
/** CDX icon component to render (icon-only control). */
|
|
47
|
+
as: CdxIcon;
|
|
48
|
+
/** Passed through to the underlying `Icon`. */
|
|
49
|
+
iconClassName?: IconProps['className'];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const IconButtonRoot = forwardRef<View, IconButtonProps>(
|
|
53
|
+
(
|
|
54
|
+
{
|
|
55
|
+
variant = 'solid',
|
|
56
|
+
size = 'default',
|
|
57
|
+
mode = 'light',
|
|
58
|
+
className,
|
|
59
|
+
style,
|
|
60
|
+
as: IconComponent,
|
|
61
|
+
iconClassName,
|
|
62
|
+
accessibilityRole = 'button',
|
|
63
|
+
...props
|
|
64
|
+
},
|
|
65
|
+
ref,
|
|
66
|
+
) => {
|
|
67
|
+
const rootClassName = cn(iconButtonRootVariants({ variant, size, mode }), className);
|
|
68
|
+
|
|
69
|
+
const glyphClassName = cn(
|
|
70
|
+
iconButtonGlyphVariants({ size }),
|
|
71
|
+
iconButtonIconColorVariants({ variant, mode }),
|
|
72
|
+
iconClassName,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<IconButtonPrimitive
|
|
77
|
+
ref={ref}
|
|
78
|
+
accessibilityRole={accessibilityRole}
|
|
79
|
+
className={rootClassName}
|
|
80
|
+
style={style}
|
|
81
|
+
{...props}
|
|
82
|
+
>
|
|
83
|
+
<IconButtonGlyph as={IconComponent} className={glyphClassName} />
|
|
84
|
+
</IconButtonPrimitive>
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
IconButtonRoot.displayName = 'IconButton';
|
|
90
|
+
|
|
91
|
+
export const IconButton = IconButtonRoot;
|
|
92
|
+
|
|
93
|
+
export type { IconButtonVariantProps };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import {
|
|
4
|
+
COLOR_BORDER_DEFAULT,
|
|
5
|
+
DISABLED_CURSOR,
|
|
6
|
+
DISABLED_OPACITY,
|
|
7
|
+
RADIUS_FULL,
|
|
8
|
+
TRANSITION_COLORS,
|
|
9
|
+
} from '../../styles/primitives';
|
|
10
|
+
import {
|
|
11
|
+
type SharedButtonSemanticColor,
|
|
12
|
+
sharedGhostSurfaceCompounds,
|
|
13
|
+
sharedOutlineGhostForegroundTextCompounds,
|
|
14
|
+
} from '../Button/buttonSharedVariants';
|
|
15
|
+
|
|
16
|
+
function actionOnlyCompounds<T extends { color: SharedButtonSemanticColor }>(
|
|
17
|
+
compounds: T[],
|
|
18
|
+
): Omit<T, 'color'>[] {
|
|
19
|
+
return compounds
|
|
20
|
+
.filter((c) => c.color === 'action')
|
|
21
|
+
.map((c) => {
|
|
22
|
+
const { color, ...rest } = c;
|
|
23
|
+
void color;
|
|
24
|
+
return rest;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Dark-mode hover/active surface for ghost (solid uses a separate compound with border). */
|
|
29
|
+
const iconButtonDarkGhostSurfaceCompounds = actionOnlyCompounds(sharedGhostSurfaceCompounds).map(
|
|
30
|
+
(c) => ({
|
|
31
|
+
variant: 'ghost' as const,
|
|
32
|
+
...c,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const iconButtonForegroundTextCompounds = actionOnlyCompounds(
|
|
37
|
+
sharedOutlineGhostForegroundTextCompounds,
|
|
38
|
+
).map((c) => ({
|
|
39
|
+
variant: ['solid', 'ghost'] as ('solid' | 'ghost')[],
|
|
40
|
+
...c,
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
export const iconButtonRootVariants = cva(
|
|
44
|
+
[
|
|
45
|
+
'flex items-center justify-center',
|
|
46
|
+
RADIUS_FULL,
|
|
47
|
+
'web:outline-none web:focus:outline-none web:focus-visible:outline-none',
|
|
48
|
+
TRANSITION_COLORS,
|
|
49
|
+
DISABLED_OPACITY,
|
|
50
|
+
DISABLED_CURSOR,
|
|
51
|
+
'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-slate-400/50 web:data-[focus-visible=true]:ring-offset-2',
|
|
52
|
+
],
|
|
53
|
+
{
|
|
54
|
+
variants: {
|
|
55
|
+
variant: {
|
|
56
|
+
/** Same surface as ghost, with a light gray border (aligned with Button `outline`). */
|
|
57
|
+
solid: [
|
|
58
|
+
'bg-transparent',
|
|
59
|
+
`border ${COLOR_BORDER_DEFAULT}`,
|
|
60
|
+
'data-[hover=true]:bg-slate-50',
|
|
61
|
+
'data-[active=true]:bg-slate-100',
|
|
62
|
+
],
|
|
63
|
+
ghost: [
|
|
64
|
+
'bg-transparent',
|
|
65
|
+
'data-[hover=true]:bg-slate-50',
|
|
66
|
+
'data-[active=true]:bg-slate-100',
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
size: {
|
|
70
|
+
default: 'h-10 w-10 min-w-10 shrink-0 p-0',
|
|
71
|
+
small: 'h-8 w-8 min-w-8 shrink-0 p-0',
|
|
72
|
+
},
|
|
73
|
+
mode: {
|
|
74
|
+
light: [],
|
|
75
|
+
dark: [],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
compoundVariants: [
|
|
79
|
+
...iconButtonDarkGhostSurfaceCompounds,
|
|
80
|
+
{
|
|
81
|
+
variant: 'solid',
|
|
82
|
+
mode: 'dark',
|
|
83
|
+
className: [
|
|
84
|
+
'border-slate-700',
|
|
85
|
+
Platform.select({
|
|
86
|
+
default: 'data-[active=true]:bg-slate-700',
|
|
87
|
+
web: 'data-[hover=true]:bg-slate-800 data-[active=true]:data-[hover=true]:bg-slate-700',
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
defaultVariants: {
|
|
93
|
+
variant: 'solid',
|
|
94
|
+
size: 'default',
|
|
95
|
+
mode: 'light',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export const iconButtonGlyphVariants = cva([], {
|
|
101
|
+
variants: {
|
|
102
|
+
size: {
|
|
103
|
+
default: 'size-5',
|
|
104
|
+
small: 'size-4',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
defaultVariants: {
|
|
108
|
+
size: 'default',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/** Icon fill aligned with Button outline/ghost action label colors (solid matches ghost). */
|
|
113
|
+
export const iconButtonIconColorVariants = cva([], {
|
|
114
|
+
variants: {
|
|
115
|
+
variant: {
|
|
116
|
+
solid: [],
|
|
117
|
+
ghost: [],
|
|
118
|
+
},
|
|
119
|
+
mode: {
|
|
120
|
+
light: [],
|
|
121
|
+
dark: [],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
compoundVariants: [...iconButtonForegroundTextCompounds],
|
|
125
|
+
defaultVariants: {
|
|
126
|
+
variant: 'solid',
|
|
127
|
+
mode: 'light',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export type IconButtonVariantProps = VariantProps<typeof iconButtonRootVariants>;
|