@cdx-ui/components 0.0.1-alpha.3 → 0.0.1-alpha.30
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,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper around React Native's `Image`.
|
|
3
|
+
*
|
|
4
|
+
* Design-system layout (sizes, radii, loading/error UI) is intentionally
|
|
5
|
+
* NOT baked in here — use purpose-built components like `Avatar` instead.
|
|
6
|
+
*
|
|
7
|
+
* What this wrapper adds over a raw RN `Image`:
|
|
8
|
+
* - Accepts a plain URI **string** as `source` (auto-normalized to `{ uri }`).
|
|
9
|
+
* - Extends the prop surface with **web-only** HTML attributes (`sizes`,
|
|
10
|
+
* `loading`, `decoding`, etc.) for better `react-native-web` support.
|
|
11
|
+
* Props already covered by RN 0.81+ (`alt`, `srcSet`, `crossOrigin`,
|
|
12
|
+
* `referrerPolicy`) are inherited from the native typings.
|
|
13
|
+
* - All other props and `ref` are forwarded to the underlying `Image`.
|
|
14
|
+
*
|
|
15
|
+
* Inspired by Expo's html-elements Image primitive:
|
|
16
|
+
* @see https://github.com/expo/expo/blob/main/packages/html-elements/src/primitives/Image.tsx
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { forwardRef, type ComponentPropsWithoutRef, type ComponentRef } from 'react';
|
|
20
|
+
import { Image as RNImage, type ImageSourcePropType } from 'react-native';
|
|
21
|
+
|
|
22
|
+
/** Coerces a plain URI string into the `{ uri }` shape RN expects. */
|
|
23
|
+
function normalizeSource(source: string | ImageSourcePropType): ImageSourcePropType {
|
|
24
|
+
if (typeof source === 'string') {
|
|
25
|
+
return { uri: source };
|
|
26
|
+
}
|
|
27
|
+
return source;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Web-oriented props not yet covered by react-native's Image typings.
|
|
32
|
+
// Props already present in RN 0.81+ (alt, srcSet, crossOrigin,
|
|
33
|
+
// referrerPolicy) are inherited from the native Image props.
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* HTML-ish attributes not in RN’s core typings. Forwarded to `Image` with `...props`;
|
|
38
|
+
* **react-native-web** maps supported ones to the DOM `<img>`. On iOS/Android they are
|
|
39
|
+
* typically ignored (no visual effect).
|
|
40
|
+
*/
|
|
41
|
+
export interface WebImageProps {
|
|
42
|
+
/** DOM `sizes` for responsive selection with `srcSet` — web only. */
|
|
43
|
+
sizes?: string;
|
|
44
|
+
/** DOM lazy-loading hint — web only. */
|
|
45
|
+
loading?: 'lazy' | 'eager';
|
|
46
|
+
/** DOM decode hint — web only. */
|
|
47
|
+
decoding?: 'async' | 'auto' | 'sync';
|
|
48
|
+
/** DOM drag behavior — web only. */
|
|
49
|
+
draggable?: boolean;
|
|
50
|
+
/** DOM focus order — web only. */
|
|
51
|
+
tabIndex?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// ImageProps = native Image props (minus `source`) + WebImageProps + our overrides.
|
|
56
|
+
// `source` is re-declared to also accept a plain string.
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
export type ImageProps = WebImageProps &
|
|
60
|
+
Omit<ComponentPropsWithoutRef<typeof RNImage>, 'source'> & {
|
|
61
|
+
/** URI string (normalized to `{ uri }`) or standard `ImageSourcePropType`. */
|
|
62
|
+
source: string | ImageSourcePropType;
|
|
63
|
+
className?: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Component
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
export const Image = forwardRef<ComponentRef<typeof RNImage>, ImageProps>(function Image(
|
|
71
|
+
{ source, ...props },
|
|
72
|
+
ref,
|
|
73
|
+
) {
|
|
74
|
+
return <RNImage source={normalizeSource(source)} {...props} ref={ref} />;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
Image.displayName = 'Image';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Image, type ImageProps, type WebImageProps } from './Image';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { TextInput, type TextInputProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const androidDefaults = {
|
|
5
|
+
includeFontPadding: false,
|
|
6
|
+
textAlignVertical: 'center' as const,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const BaseInput = forwardRef<TextInput, TextInputProps>((props, ref) => (
|
|
10
|
+
<TextInput ref={ref} {...props} style={[androidDefaults, props.style]} />
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
BaseInput.displayName = 'BaseInput';
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type IInputSlotProps,
|
|
8
8
|
} from '@cdx-ui/primitives';
|
|
9
9
|
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
10
|
+
import { Icon, IconProps } from '../Icon';
|
|
10
11
|
import { BaseInput } from './BaseInput';
|
|
11
12
|
import {
|
|
12
13
|
type InputVariantProps,
|
|
@@ -25,7 +26,6 @@ const useInputStyleContext = () => useStyleContext(SCOPE) as InputVariantProps;
|
|
|
25
26
|
|
|
26
27
|
const InputPrimitive = createInput({
|
|
27
28
|
Root,
|
|
28
|
-
Icon: View,
|
|
29
29
|
Slot: View,
|
|
30
30
|
Field: BaseInput,
|
|
31
31
|
});
|
|
@@ -40,7 +40,7 @@ export interface InputProps extends ViewProps, IInputFieldProps, InputVariantPro
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const InputRoot = forwardRef<View, InputProps>(
|
|
43
|
-
({ variant = 'outline', size = '
|
|
43
|
+
({ variant = 'outline', size = 'default', className, children, style, ...props }, ref) => {
|
|
44
44
|
const computedClassName = cn(inputRootVariants({ variant, size }), className);
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -103,9 +103,7 @@ export interface InputSlotProps extends ViewProps, IInputSlotProps {
|
|
|
103
103
|
|
|
104
104
|
const InputSlot = forwardRef<View, InputSlotProps>(
|
|
105
105
|
({ className, children, style, ...props }, ref) => {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const computedClassName = cn(inputSlotVariants({ size }), className);
|
|
106
|
+
const computedClassName = cn(inputSlotVariants(), className);
|
|
109
107
|
|
|
110
108
|
return (
|
|
111
109
|
<InputPrimitive.Slot ref={ref} className={computedClassName} style={style} {...props}>
|
|
@@ -121,24 +119,15 @@ InputSlot.displayName = 'Input.Slot';
|
|
|
121
119
|
// INPUT ICON
|
|
122
120
|
// =============================================================================
|
|
123
121
|
|
|
124
|
-
export interface InputIconProps extends
|
|
125
|
-
className?: string;
|
|
126
|
-
children?: ReactNode;
|
|
127
|
-
}
|
|
122
|
+
export interface InputIconProps extends Omit<IconProps, 'children'> {}
|
|
128
123
|
|
|
129
|
-
const InputIcon =
|
|
130
|
-
|
|
131
|
-
const { size } = useInputStyleContext();
|
|
124
|
+
const InputIcon = ({ className, style, as, ...props }: InputIconProps) => {
|
|
125
|
+
const { size } = useInputStyleContext();
|
|
132
126
|
|
|
133
|
-
|
|
127
|
+
const computedClassName = cn(inputIconVariants({ size }), className);
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{children}
|
|
138
|
-
</InputPrimitive.Icon>
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
);
|
|
129
|
+
return <Icon as={as} className={computedClassName} style={style} {...props} />;
|
|
130
|
+
};
|
|
142
131
|
|
|
143
132
|
InputIcon.displayName = 'Input.Icon';
|
|
144
133
|
|
|
@@ -157,5 +146,3 @@ export const Input = Object.assign(InputRoot, {
|
|
|
157
146
|
Slot: InputSlot,
|
|
158
147
|
Icon: InputIcon,
|
|
159
148
|
}) as InputCompoundComponent;
|
|
160
|
-
|
|
161
|
-
export type { InputVariantProps };
|
|
@@ -1,83 +1,88 @@
|
|
|
1
1
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import {
|
|
3
|
+
COLOR_BG_PRIMARY,
|
|
4
|
+
COLOR_BORDER_DEFAULT,
|
|
5
|
+
COLOR_TEXT_MUTED,
|
|
6
|
+
COLOR_TEXT_PRIMARY,
|
|
7
|
+
DISABLED_CURSOR,
|
|
8
|
+
DISABLED_OPACITY,
|
|
9
|
+
RADIUS_SM,
|
|
10
|
+
SHADOW_SM,
|
|
11
|
+
SIZE_SCALE,
|
|
12
|
+
TRANSITION_COLORS,
|
|
13
|
+
} from '../../styles/primitives';
|
|
2
14
|
|
|
3
15
|
export const inputRootVariants = cva(
|
|
4
16
|
[
|
|
5
|
-
'w-full flex-row items-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
'w-full flex-row items-stretch border',
|
|
18
|
+
COLOR_BG_PRIMARY,
|
|
19
|
+
COLOR_BORDER_DEFAULT,
|
|
20
|
+
RADIUS_SM,
|
|
21
|
+
SHADOW_SM,
|
|
22
|
+
TRANSITION_COLORS,
|
|
23
|
+
DISABLED_OPACITY,
|
|
24
|
+
DISABLED_CURSOR,
|
|
25
|
+
'data-[disabled=true]:bg-slate-50 data-[disabled=true]:border-slate-300',
|
|
26
|
+
'data-[readonly=true]:cursor-default',
|
|
27
|
+
'data-[readonly=true]:bg-slate-50',
|
|
28
|
+
'web:data-[hover=true]:data-[active=false]:border-slate-300',
|
|
29
|
+
'data-[focus=true]:border-slate-900',
|
|
9
30
|
'data-[invalid=true]:border-red-500',
|
|
10
31
|
],
|
|
11
32
|
{
|
|
12
33
|
variants: {
|
|
13
34
|
variant: {
|
|
14
35
|
outline: [
|
|
15
|
-
'
|
|
16
|
-
'web:focus-within:border-
|
|
17
|
-
'web:data-[invalid=true]:focus-within:border-red-500 web:data-[invalid=true]:focus-within:ring-red-300/50',
|
|
36
|
+
'web:focus-within:border-slate-900 web:focus-within:ring-2 web:focus-within:ring-slate-400/50 web:focus-within:ring-offset-0',
|
|
37
|
+
'web:data-[invalid=true]:focus-within:border-red-500 web:data-[invalid=true]:focus-within:ring-2 web:data-[invalid=true]:focus-within:ring-red-400/50',
|
|
18
38
|
],
|
|
19
|
-
underlined:
|
|
20
|
-
'rounded-none border-t-0 border-l-0 border-r-0 border-b-neutral-border data-[focus=true]:border-b-interactive-focus shadow-none',
|
|
21
39
|
},
|
|
22
40
|
size: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
lg: 'h-12 py-2',
|
|
41
|
+
default: `${SIZE_SCALE.default.height} ${SIZE_SCALE.default.px} py-2 ${SIZE_SCALE.default.gap}`,
|
|
42
|
+
small: `${SIZE_SCALE.small.height} ${SIZE_SCALE.small.px} py-1.5 ${SIZE_SCALE.small.gap}`,
|
|
26
43
|
},
|
|
27
44
|
},
|
|
28
45
|
defaultVariants: {
|
|
29
46
|
variant: 'outline',
|
|
30
|
-
size: '
|
|
47
|
+
size: 'default',
|
|
31
48
|
},
|
|
32
49
|
},
|
|
33
50
|
);
|
|
34
51
|
|
|
35
52
|
export const inputFieldVariants = cva(
|
|
36
53
|
[
|
|
37
|
-
'flex-1 bg-transparent
|
|
38
|
-
|
|
54
|
+
'flex-1 justify-center bg-transparent p-0',
|
|
55
|
+
COLOR_TEXT_PRIMARY,
|
|
56
|
+
'placeholder:text-slate-400',
|
|
39
57
|
'web:outline-none',
|
|
40
58
|
],
|
|
41
59
|
{
|
|
42
60
|
variants: {
|
|
43
61
|
size: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
lg: 'text-lg leading-none',
|
|
62
|
+
default: 'text-[1rem]',
|
|
63
|
+
small: 'text-[0.875rem]',
|
|
47
64
|
},
|
|
48
65
|
},
|
|
49
66
|
defaultVariants: {
|
|
50
|
-
size: '
|
|
67
|
+
size: 'default',
|
|
51
68
|
},
|
|
52
69
|
},
|
|
53
70
|
);
|
|
54
71
|
|
|
55
|
-
export const inputSlotVariants = cva(['items-center justify-center']
|
|
56
|
-
variants: {
|
|
57
|
-
size: {
|
|
58
|
-
sm: 'h-4 w-4',
|
|
59
|
-
md: 'h-5 w-5',
|
|
60
|
-
lg: 'h-6 w-6',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
defaultVariants: {
|
|
64
|
-
size: 'sm',
|
|
65
|
-
},
|
|
66
|
-
});
|
|
72
|
+
export const inputSlotVariants = cva(['items-center justify-center self-center']);
|
|
67
73
|
|
|
68
|
-
export const inputIconVariants = cva([
|
|
74
|
+
export const inputIconVariants = cva([COLOR_TEXT_MUTED], {
|
|
69
75
|
variants: {
|
|
70
76
|
size: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
lg: 'h-5 w-5',
|
|
77
|
+
default: 'size-5',
|
|
78
|
+
small: 'size-4',
|
|
74
79
|
},
|
|
75
80
|
},
|
|
76
81
|
defaultVariants: {
|
|
77
|
-
size: '
|
|
82
|
+
size: 'default',
|
|
78
83
|
},
|
|
79
84
|
});
|
|
80
85
|
|
|
81
|
-
export const inputFieldPlaceholderVariants = cva(['accent-
|
|
86
|
+
export const inputFieldPlaceholderVariants = cva(['accent-slate-400']);
|
|
82
87
|
|
|
83
88
|
export type InputVariantProps = VariantProps<typeof inputRootVariants>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Pressable, Text as RNText, type TextProps, type View } from 'react-native';
|
|
3
|
+
import { createLink, type ILinkProps } from '@cdx-ui/primitives';
|
|
4
|
+
import { cn } from '@cdx-ui/utils';
|
|
5
|
+
import { Icon, type IconProps } from '../Icon';
|
|
6
|
+
import { linkRootVariants, linkLabelVariants, linkIconVariants } from './styles';
|
|
7
|
+
|
|
8
|
+
export { LinkProvider, type LinkConfig, type LinkAction } from '@cdx-ui/primitives';
|
|
9
|
+
|
|
10
|
+
const LinkPrimitive = createLink({
|
|
11
|
+
Root: Pressable,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// STYLED ROOT COMPONENT
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
export interface LinkProps extends ILinkProps {
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const LinkRoot = forwardRef<View, LinkProps>(({ className, children, style, ...props }, ref) => {
|
|
23
|
+
const rootClassName = cn(linkRootVariants(), className);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<LinkPrimitive ref={ref} className={rootClassName} style={style} {...props}>
|
|
27
|
+
{children}
|
|
28
|
+
</LinkPrimitive>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
LinkRoot.displayName = 'Link';
|
|
33
|
+
|
|
34
|
+
// =============================================================================
|
|
35
|
+
// STYLED LABEL COMPONENT
|
|
36
|
+
// =============================================================================
|
|
37
|
+
|
|
38
|
+
export interface LinkLabelProps extends TextProps {
|
|
39
|
+
className?: string;
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const LinkLabel = forwardRef<RNText, LinkLabelProps>(
|
|
44
|
+
({ className, children, style, ...props }, ref) => {
|
|
45
|
+
const computedClassName = cn(linkLabelVariants(), className);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<RNText ref={ref} className={computedClassName} style={style} {...props}>
|
|
49
|
+
{children}
|
|
50
|
+
</RNText>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
LinkLabel.displayName = 'Link.Label';
|
|
56
|
+
|
|
57
|
+
// =============================================================================
|
|
58
|
+
// STYLED ICON COMPONENT
|
|
59
|
+
// =============================================================================
|
|
60
|
+
|
|
61
|
+
export interface LinkIconProps extends Omit<IconProps, 'children'> {}
|
|
62
|
+
|
|
63
|
+
const LinkIcon = ({ className, style, as, ...props }: LinkIconProps) => {
|
|
64
|
+
const computedClassName = cn(linkIconVariants(), className);
|
|
65
|
+
|
|
66
|
+
return <Icon as={as} className={computedClassName} style={style} {...props} />;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
LinkIcon.displayName = 'Link.Icon';
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// COMPOUND COMPONENT EXPORT
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
type LinkCompoundComponent = typeof LinkRoot & {
|
|
76
|
+
Label: typeof LinkLabel;
|
|
77
|
+
Icon: typeof LinkIcon;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const Link = Object.assign(LinkRoot, {
|
|
81
|
+
Label: LinkLabel,
|
|
82
|
+
Icon: LinkIcon,
|
|
83
|
+
}) as LinkCompoundComponent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { TRANSITION_COLORS } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
export const linkRootVariants = cva([
|
|
6
|
+
'flex-row items-center gap-1',
|
|
7
|
+
'web:outline-none web:focus:outline-none web:focus-visible:outline-none',
|
|
8
|
+
'text-blue-600',
|
|
9
|
+
'underline decoration-slate-300 underline-offset-4',
|
|
10
|
+
TRANSITION_COLORS,
|
|
11
|
+
Platform.select({
|
|
12
|
+
web: 'data-[hover=true]:decoration-slate-900',
|
|
13
|
+
default: '',
|
|
14
|
+
}),
|
|
15
|
+
'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-slate-400/50 web:data-[focus-visible=true]:ring-offset-2',
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export const linkLabelVariants = cva(['text-sm font-medium', 'text-blue-600']);
|
|
19
|
+
|
|
20
|
+
export const linkIconVariants = cva(['size-4', 'text-blue-600']);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { cn } from '@cdx-ui/utils';
|
|
4
|
+
import {
|
|
5
|
+
progressSegmentedVariants,
|
|
6
|
+
segmentVariants,
|
|
7
|
+
type ProgressSegmentedVariants,
|
|
8
|
+
} from './styles';
|
|
9
|
+
|
|
10
|
+
export interface ProgressSegmentedProps extends ViewProps, ProgressSegmentedVariants {
|
|
11
|
+
/** Current step (1-based index into the segment count) */
|
|
12
|
+
readonly step: number;
|
|
13
|
+
/** Total number of segments */
|
|
14
|
+
readonly total?: number;
|
|
15
|
+
/** When true, the current step segment is marked as complete rather than in-progress */
|
|
16
|
+
readonly isStepComplete?: boolean;
|
|
17
|
+
/** Returns the accessibility value text announced by screen readers. Receives the clamped step, total, and whether the step is complete. */
|
|
18
|
+
readonly getAccessibilityText?: (step: number, total: number, isStepComplete: boolean) => string;
|
|
19
|
+
readonly className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
step,
|
|
26
|
+
total = 5,
|
|
27
|
+
isStepComplete = false,
|
|
28
|
+
getAccessibilityText,
|
|
29
|
+
className,
|
|
30
|
+
accessibilityLabel = 'Progress',
|
|
31
|
+
...props
|
|
32
|
+
},
|
|
33
|
+
ref,
|
|
34
|
+
) => {
|
|
35
|
+
const clampedStep = Math.max(0, Math.min(step, total));
|
|
36
|
+
|
|
37
|
+
const segments = useMemo(() => {
|
|
38
|
+
return Array.from({ length: total }, (_, index) => {
|
|
39
|
+
const segmentIndex = index + 1;
|
|
40
|
+
let state: 'complete' | 'incomplete' | 'inprogress' = 'incomplete';
|
|
41
|
+
|
|
42
|
+
if (segmentIndex < clampedStep || (isStepComplete && segmentIndex === clampedStep)) {
|
|
43
|
+
state = 'complete';
|
|
44
|
+
} else if (segmentIndex === clampedStep) {
|
|
45
|
+
state = 'inprogress';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return state;
|
|
49
|
+
});
|
|
50
|
+
}, [total, clampedStep, isStepComplete]);
|
|
51
|
+
|
|
52
|
+
let accessibilityText = `Step ${String(clampedStep)} of ${String(total)}`;
|
|
53
|
+
if (getAccessibilityText) {
|
|
54
|
+
accessibilityText = getAccessibilityText(clampedStep, total, isStepComplete);
|
|
55
|
+
} else if (isStepComplete) {
|
|
56
|
+
accessibilityText = `Step ${String(clampedStep)} of ${String(total)}, completed`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
ref={ref}
|
|
62
|
+
accessibilityRole="progressbar"
|
|
63
|
+
accessibilityLabel={accessibilityLabel}
|
|
64
|
+
accessibilityValue={{
|
|
65
|
+
min: 0,
|
|
66
|
+
max: total,
|
|
67
|
+
now: clampedStep,
|
|
68
|
+
text: accessibilityText,
|
|
69
|
+
}}
|
|
70
|
+
className={cn(progressSegmentedVariants(), className)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{segments.map((state, index) => (
|
|
74
|
+
<View key={index} className={cn(segmentVariants({ state }))} />
|
|
75
|
+
))}
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
ProgressSegmented.displayName = 'ProgressSegmented';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
export const progressSegmentedVariants = cva(['flex-row gap-1 w-full']);
|
|
4
|
+
|
|
5
|
+
export const segmentVariants = cva(['flex-1 h-2 rounded'], {
|
|
6
|
+
variants: {
|
|
7
|
+
state: {
|
|
8
|
+
complete: 'bg-slate-900',
|
|
9
|
+
incomplete: 'bg-slate-300',
|
|
10
|
+
inprogress: 'bg-gradient-to-r from-slate-900 from-50% to-slate-300 to-50%',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
state: 'incomplete',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type ProgressSegmentedVariants = VariantProps<typeof progressSegmentedVariants>;
|
|
19
|
+
export type SegmentVariants = VariantProps<typeof segmentVariants>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import type { PressableProps } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export type SelectTriggerHostProps = PressableProps & { className?: string };
|
|
6
|
+
|
|
7
|
+
/** Props that must not be forwarded to a DOM `<button>`. */
|
|
8
|
+
const OMIT = new Set<string>([
|
|
9
|
+
'hitSlop',
|
|
10
|
+
'pressRetentionOffset',
|
|
11
|
+
'android_ripple',
|
|
12
|
+
'android_disableSound',
|
|
13
|
+
'unstable_pressDelay',
|
|
14
|
+
'onLongPress',
|
|
15
|
+
'delayLongPress',
|
|
16
|
+
'onPress',
|
|
17
|
+
'onPressIn',
|
|
18
|
+
'onPressOut',
|
|
19
|
+
'onHoverIn',
|
|
20
|
+
'onHoverOut',
|
|
21
|
+
'disabled',
|
|
22
|
+
'style',
|
|
23
|
+
'className',
|
|
24
|
+
'testID',
|
|
25
|
+
'children',
|
|
26
|
+
'accessible',
|
|
27
|
+
'accessibilityActions',
|
|
28
|
+
'accessibilityElementsHidden',
|
|
29
|
+
'accessibilityHint',
|
|
30
|
+
'accessibilityIgnoresInvertColors',
|
|
31
|
+
'accessibilityLabel',
|
|
32
|
+
'accessibilityLabelledBy',
|
|
33
|
+
'accessibilityLiveRegion',
|
|
34
|
+
'accessibilityRole',
|
|
35
|
+
'accessibilityState',
|
|
36
|
+
'accessibilityValue',
|
|
37
|
+
'accessibilityViewIsModal',
|
|
38
|
+
'importantForAccessibility',
|
|
39
|
+
'needsOffscreenAlphaCompositing',
|
|
40
|
+
'collapsable',
|
|
41
|
+
'shouldRasterizeIOS',
|
|
42
|
+
'removeClippedSubviews',
|
|
43
|
+
'onAccessibilityAction',
|
|
44
|
+
'onAccessibilityEscape',
|
|
45
|
+
'onAccessibilityTap',
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
function resolveChildren(children: PressableProps['children']): React.ReactNode {
|
|
49
|
+
if (typeof children === 'function') {
|
|
50
|
+
return children({ pressed: false });
|
|
51
|
+
}
|
|
52
|
+
return children;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function filterDomProps(rest: object): React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
56
|
+
const entries = Object.entries(rest).filter(([key]) => !OMIT.has(key));
|
|
57
|
+
return Object.fromEntries(entries) as React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** UA `<button>` defaults (centered text, inline sizing) fight our flex + `justify-between` layout. */
|
|
61
|
+
const webButtonLayoutStyle: React.CSSProperties = {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'space-between',
|
|
66
|
+
width: '100%',
|
|
67
|
+
minWidth: 0,
|
|
68
|
+
textAlign: 'start',
|
|
69
|
+
boxSizing: 'border-box',
|
|
70
|
+
margin: 0,
|
|
71
|
+
font: 'inherit',
|
|
72
|
+
lineHeight: 'normal',
|
|
73
|
+
WebkitAppearance: 'none',
|
|
74
|
+
appearance: 'none',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Native `<button type="button">` so the trigger is HTML-labelable (`<label htmlFor>` focuses it).
|
|
79
|
+
* `Pressable` on web is a non-labelable div; no extra refs are needed for label association.
|
|
80
|
+
*/
|
|
81
|
+
export const SelectTriggerHost = forwardRef<HTMLButtonElement, SelectTriggerHostProps>(
|
|
82
|
+
function SelectTriggerHost(props, ref) {
|
|
83
|
+
const {
|
|
84
|
+
children,
|
|
85
|
+
onPress,
|
|
86
|
+
onPressIn,
|
|
87
|
+
onPressOut,
|
|
88
|
+
onHoverIn,
|
|
89
|
+
onHoverOut,
|
|
90
|
+
disabled,
|
|
91
|
+
style,
|
|
92
|
+
className,
|
|
93
|
+
testID,
|
|
94
|
+
...rest
|
|
95
|
+
} = props;
|
|
96
|
+
|
|
97
|
+
const domProps = filterDomProps(rest);
|
|
98
|
+
const flattened = StyleSheet.flatten(style) as React.CSSProperties | undefined;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<button
|
|
102
|
+
ref={ref}
|
|
103
|
+
{...domProps}
|
|
104
|
+
type="button"
|
|
105
|
+
disabled={!!disabled}
|
|
106
|
+
className={typeof className === 'string' ? className : undefined}
|
|
107
|
+
style={{ ...webButtonLayoutStyle, ...(flattened ?? {}) }}
|
|
108
|
+
data-testid={testID}
|
|
109
|
+
onClick={(e) => {
|
|
110
|
+
if (!disabled) {
|
|
111
|
+
onPress?.(e as unknown as Parameters<NonNullable<PressableProps['onPress']>>[0]);
|
|
112
|
+
}
|
|
113
|
+
}}
|
|
114
|
+
onPointerDown={(e) => {
|
|
115
|
+
onPressIn?.(e as unknown as Parameters<NonNullable<PressableProps['onPressIn']>>[0]);
|
|
116
|
+
}}
|
|
117
|
+
onPointerUp={(e) => {
|
|
118
|
+
onPressOut?.(e as unknown as Parameters<NonNullable<PressableProps['onPressOut']>>[0]);
|
|
119
|
+
}}
|
|
120
|
+
onPointerCancel={(e) => {
|
|
121
|
+
onPressOut?.(e as unknown as Parameters<NonNullable<PressableProps['onPressOut']>>[0]);
|
|
122
|
+
}}
|
|
123
|
+
onMouseEnter={(e) => {
|
|
124
|
+
onHoverIn?.(e as unknown as Parameters<NonNullable<PressableProps['onHoverIn']>>[0]);
|
|
125
|
+
}}
|
|
126
|
+
onMouseLeave={(e) => {
|
|
127
|
+
onHoverOut?.(e as unknown as Parameters<NonNullable<PressableProps['onHoverOut']>>[0]);
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{resolveChildren(children)}
|
|
131
|
+
</button>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
SelectTriggerHost.displayName = 'SelectTriggerHost';
|