@niibase/uniwind 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/dist/common/components/index.js +314 -0
- package/dist/common/components/native/ActivityIndicator.js +21 -0
- package/dist/common/components/native/Button.js +18 -0
- package/dist/common/components/native/FlatList.js +30 -0
- package/dist/common/components/native/Image.js +21 -0
- package/dist/common/components/native/ImageBackground.js +23 -0
- package/dist/common/components/native/InputAccessoryView.js +21 -0
- package/dist/common/components/native/KeyboardAvoidingView.js +20 -0
- package/dist/common/components/native/Modal.js +21 -0
- package/dist/common/components/native/Pressable.js +29 -0
- package/dist/common/components/native/RefreshControl.js +27 -0
- package/dist/common/components/native/SafeAreaView.js +18 -0
- package/dist/common/components/native/ScrollView.js +23 -0
- package/dist/common/components/native/SectionList.js +27 -0
- package/dist/common/components/native/Switch.js +32 -0
- package/dist/common/components/native/Text.js +36 -0
- package/dist/common/components/native/TextInput.js +53 -0
- package/dist/common/components/native/TouchableHighlight.js +35 -0
- package/dist/common/components/native/TouchableNativeFeedback.js +32 -0
- package/dist/common/components/native/TouchableOpacity.js +32 -0
- package/dist/common/components/native/TouchableWithoutFeedback.js +32 -0
- package/dist/common/components/native/View.js +18 -0
- package/dist/common/components/native/VirtualizedList.js +27 -0
- package/dist/common/components/native/useStyle.js +29 -0
- package/dist/common/components/utils.js +18 -0
- package/dist/common/components/web/ActivityIndicator.js +20 -0
- package/dist/common/components/web/Button.js +18 -0
- package/dist/common/components/web/FlatList.js +22 -0
- package/dist/common/components/web/Image.js +20 -0
- package/dist/common/components/web/ImageBackground.js +21 -0
- package/dist/common/components/web/KeyboardAvoidingView.js +18 -0
- package/dist/common/components/web/Modal.js +17 -0
- package/dist/common/components/web/Pressable.js +17 -0
- package/dist/common/components/web/RefreshControl.js +17 -0
- package/dist/common/components/web/SafeAreaView.js +17 -0
- package/dist/common/components/web/ScrollView.js +18 -0
- package/dist/common/components/web/SectionList.js +20 -0
- package/dist/common/components/web/Switch.js +26 -0
- package/dist/common/components/web/Text.js +17 -0
- package/dist/common/components/web/TextInput.js +17 -0
- package/dist/common/components/web/TouchableHighlight.js +20 -0
- package/dist/common/components/web/TouchableNativeFeedback.js +13 -0
- package/dist/common/components/web/TouchableOpacity.js +17 -0
- package/dist/common/components/web/TouchableWithoutFeedback.js +17 -0
- package/dist/common/components/web/View.js +17 -0
- package/dist/common/components/web/VirtualizedList.js +20 -0
- package/dist/common/components/web/index.js +187 -0
- package/dist/common/components/web/metro-injected.js +1 -0
- package/dist/common/components/web/rnw.js +42 -0
- package/dist/common/core/config/config.common.js +80 -0
- package/dist/common/core/config/config.js +51 -0
- package/dist/common/core/config/config.native.js +67 -0
- package/dist/common/core/config/index.js +16 -0
- package/dist/common/core/index.js +16 -0
- package/dist/common/core/listener.js +51 -0
- package/dist/common/core/logger.js +18 -0
- package/dist/common/core/native/index.js +27 -0
- package/dist/common/core/native/native-utils.js +36 -0
- package/dist/common/core/native/parsers/boxShadow.js +10 -0
- package/dist/common/core/native/parsers/fontVariant.js +8 -0
- package/dist/common/core/native/parsers/gradient.js +31 -0
- package/dist/common/core/native/parsers/index.js +60 -0
- package/dist/common/core/native/parsers/textShadow.js +39 -0
- package/dist/common/core/native/parsers/transforms.js +44 -0
- package/dist/common/core/native/runtime.js +34 -0
- package/dist/common/core/native/store.js +181 -0
- package/dist/common/core/types.js +1 -0
- package/dist/common/core/web/cssListener.js +146 -0
- package/dist/common/core/web/formatColor.js +15 -0
- package/dist/common/core/web/getWebStyles.js +51 -0
- package/dist/common/core/web/index.js +49 -0
- package/dist/common/core/web/parseCSSValue.js +15 -0
- package/dist/common/css/index.js +26 -0
- package/dist/common/css/insets.js +64 -0
- package/dist/common/css/processFunctions.js +54 -0
- package/dist/common/css/themes.js +95 -0
- package/dist/common/css/variants.js +16 -0
- package/dist/common/hoc/index.js +16 -0
- package/dist/common/hoc/types.js +1 -0
- package/dist/common/hoc/withUniwind.js +95 -0
- package/dist/common/hoc/withUniwind.native.js +106 -0
- package/dist/common/hoc/withUniwindUtils.js +16 -0
- package/dist/common/hooks/index.js +49 -0
- package/dist/common/hooks/useCSSVariable/getVariableValue.js +19 -0
- package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +9 -0
- package/dist/common/hooks/useCSSVariable/index.js +16 -0
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +58 -0
- package/dist/common/hooks/useResolveClassNames.js +22 -0
- package/dist/common/hooks/useResolveClassNames.native.js +29 -0
- package/dist/common/hooks/useUniwind.js +28 -0
- package/dist/common/hooks/useUniwindAccent.js +13 -0
- package/dist/common/hooks/useUniwindAccent.native.js +12 -0
- package/dist/common/index.js +38 -0
- package/dist/common/types.js +28 -0
- package/dist/common/utils/buildDtsFile.js +18 -0
- package/dist/common/utils/stringifyThemes.js +8 -0
- package/dist/common/vite/index.d.ts +9 -0
- package/dist/common/vite/index.js +16 -0
- package/dist/common/vite/vite.js +72 -0
- package/dist/metro/index.cjs +166 -0
- package/dist/metro/index.d.ts +15 -0
- package/dist/metro/index.mjs +158 -0
- package/dist/metro/metro-transformer.cjs +1565 -0
- package/dist/metro/metro-transformer.mjs +1558 -0
- package/dist/module/components/index.d.ts +0 -0
- package/dist/module/components/index.js +312 -0
- package/dist/module/components/native/ActivityIndicator.d.ts +3 -0
- package/dist/module/components/native/ActivityIndicator.js +18 -0
- package/dist/module/components/native/Button.d.ts +3 -0
- package/dist/module/components/native/Button.js +15 -0
- package/dist/module/components/native/FlatList.d.ts +3 -0
- package/dist/module/components/native/FlatList.js +27 -0
- package/dist/module/components/native/Image.d.ts +3 -0
- package/dist/module/components/native/Image.js +18 -0
- package/dist/module/components/native/ImageBackground.d.ts +3 -0
- package/dist/module/components/native/ImageBackground.js +20 -0
- package/dist/module/components/native/InputAccessoryView.d.ts +3 -0
- package/dist/module/components/native/InputAccessoryView.js +21 -0
- package/dist/module/components/native/KeyboardAvoidingView.d.ts +3 -0
- package/dist/module/components/native/KeyboardAvoidingView.js +17 -0
- package/dist/module/components/native/Modal.d.ts +3 -0
- package/dist/module/components/native/Modal.js +18 -0
- package/dist/module/components/native/Pressable.d.ts +3 -0
- package/dist/module/components/native/Pressable.js +29 -0
- package/dist/module/components/native/RefreshControl.d.ts +3 -0
- package/dist/module/components/native/RefreshControl.js +24 -0
- package/dist/module/components/native/SafeAreaView.d.ts +3 -0
- package/dist/module/components/native/SafeAreaView.js +15 -0
- package/dist/module/components/native/ScrollView.d.ts +3 -0
- package/dist/module/components/native/ScrollView.js +20 -0
- package/dist/module/components/native/SectionList.d.ts +3 -0
- package/dist/module/components/native/SectionList.js +24 -0
- package/dist/module/components/native/Switch.d.ts +3 -0
- package/dist/module/components/native/Switch.js +26 -0
- package/dist/module/components/native/Text.d.ts +3 -0
- package/dist/module/components/native/Text.js +33 -0
- package/dist/module/components/native/TextInput.d.ts +3 -0
- package/dist/module/components/native/TextInput.js +50 -0
- package/dist/module/components/native/TouchableHighlight.d.ts +3 -0
- package/dist/module/components/native/TouchableHighlight.js +32 -0
- package/dist/module/components/native/TouchableNativeFeedback.d.ts +3 -0
- package/dist/module/components/native/TouchableNativeFeedback.js +29 -0
- package/dist/module/components/native/TouchableOpacity.d.ts +3 -0
- package/dist/module/components/native/TouchableOpacity.js +29 -0
- package/dist/module/components/native/TouchableWithoutFeedback.d.ts +3 -0
- package/dist/module/components/native/TouchableWithoutFeedback.js +29 -0
- package/dist/module/components/native/View.d.ts +3 -0
- package/dist/module/components/native/View.js +15 -0
- package/dist/module/components/native/VirtualizedList.d.ts +3 -0
- package/dist/module/components/native/VirtualizedList.js +24 -0
- package/dist/module/components/native/useStyle.d.ts +2 -0
- package/dist/module/components/native/useStyle.js +22 -0
- package/dist/module/components/utils.d.ts +1 -0
- package/dist/module/components/utils.js +11 -0
- package/dist/module/components/web/ActivityIndicator.d.ts +3 -0
- package/dist/module/components/web/ActivityIndicator.js +17 -0
- package/dist/module/components/web/Button.d.ts +3 -0
- package/dist/module/components/web/Button.js +15 -0
- package/dist/module/components/web/FlatList.d.ts +3 -0
- package/dist/module/components/web/FlatList.js +19 -0
- package/dist/module/components/web/Image.d.ts +3 -0
- package/dist/module/components/web/Image.js +17 -0
- package/dist/module/components/web/ImageBackground.d.ts +3 -0
- package/dist/module/components/web/ImageBackground.js +18 -0
- package/dist/module/components/web/KeyboardAvoidingView.d.ts +3 -0
- package/dist/module/components/web/KeyboardAvoidingView.js +15 -0
- package/dist/module/components/web/Modal.d.ts +3 -0
- package/dist/module/components/web/Modal.js +14 -0
- package/dist/module/components/web/Pressable.d.ts +3 -0
- package/dist/module/components/web/Pressable.js +14 -0
- package/dist/module/components/web/RefreshControl.d.ts +3 -0
- package/dist/module/components/web/RefreshControl.js +14 -0
- package/dist/module/components/web/SafeAreaView.d.ts +3 -0
- package/dist/module/components/web/SafeAreaView.js +14 -0
- package/dist/module/components/web/ScrollView.d.ts +3 -0
- package/dist/module/components/web/ScrollView.js +15 -0
- package/dist/module/components/web/SectionList.d.ts +3 -0
- package/dist/module/components/web/SectionList.js +17 -0
- package/dist/module/components/web/Switch.d.ts +3 -0
- package/dist/module/components/web/Switch.js +20 -0
- package/dist/module/components/web/Text.d.ts +3 -0
- package/dist/module/components/web/Text.js +14 -0
- package/dist/module/components/web/TextInput.d.ts +3 -0
- package/dist/module/components/web/TextInput.js +14 -0
- package/dist/module/components/web/TouchableHighlight.d.ts +3 -0
- package/dist/module/components/web/TouchableHighlight.js +17 -0
- package/dist/module/components/web/TouchableNativeFeedback.d.ts +2 -0
- package/dist/module/components/web/TouchableNativeFeedback.js +2 -0
- package/dist/module/components/web/TouchableOpacity.d.ts +3 -0
- package/dist/module/components/web/TouchableOpacity.js +14 -0
- package/dist/module/components/web/TouchableWithoutFeedback.d.ts +3 -0
- package/dist/module/components/web/TouchableWithoutFeedback.js +14 -0
- package/dist/module/components/web/View.d.ts +3 -0
- package/dist/module/components/web/View.js +14 -0
- package/dist/module/components/web/VirtualizedList.d.ts +3 -0
- package/dist/module/components/web/VirtualizedList.js +17 -0
- package/dist/module/components/web/index.d.ts +22 -0
- package/dist/module/components/web/index.js +22 -0
- package/dist/module/components/web/metro-injected.d.ts +0 -0
- package/dist/module/components/web/metro-injected.js +0 -0
- package/dist/module/components/web/rnw.d.ts +2 -0
- package/dist/module/components/web/rnw.js +35 -0
- package/dist/module/core/config/config.common.d.ts +18 -0
- package/dist/module/core/config/config.common.js +74 -0
- package/dist/module/core/config/config.d.ts +11 -0
- package/dist/module/core/config/config.js +48 -0
- package/dist/module/core/config/config.native.d.ts +12 -0
- package/dist/module/core/config/config.native.js +61 -0
- package/dist/module/core/config/index.d.ts +1 -0
- package/dist/module/core/config/index.js +1 -0
- package/dist/module/core/index.d.ts +1 -0
- package/dist/module/core/index.js +1 -0
- package/dist/module/core/listener.d.ts +12 -0
- package/dist/module/core/listener.js +45 -0
- package/dist/module/core/logger.d.ts +5 -0
- package/dist/module/core/logger.js +11 -0
- package/dist/module/core/native/index.d.ts +2 -0
- package/dist/module/core/native/index.js +2 -0
- package/dist/module/core/native/native-utils.d.ts +4 -0
- package/dist/module/core/native/native-utils.js +27 -0
- package/dist/module/core/native/parsers/boxShadow.d.ts +1 -0
- package/dist/module/core/native/parsers/boxShadow.js +3 -0
- package/dist/module/core/native/parsers/fontVariant.d.ts +1 -0
- package/dist/module/core/native/parsers/fontVariant.js +1 -0
- package/dist/module/core/native/parsers/gradient.d.ts +8 -0
- package/dist/module/core/native/parsers/gradient.js +26 -0
- package/dist/module/core/native/parsers/index.d.ts +5 -0
- package/dist/module/core/native/parsers/index.js +5 -0
- package/dist/module/core/native/parsers/textShadow.d.ts +1 -0
- package/dist/module/core/native/parsers/textShadow.js +32 -0
- package/dist/module/core/native/parsers/transforms.d.ts +1 -0
- package/dist/module/core/native/parsers/transforms.js +48 -0
- package/dist/module/core/native/runtime.d.ts +2 -0
- package/dist/module/core/native/runtime.js +28 -0
- package/dist/module/core/native/store.d.ts +19 -0
- package/dist/module/core/native/store.js +172 -0
- package/dist/module/core/types.d.ts +73 -0
- package/dist/module/core/types.js +0 -0
- package/dist/module/core/web/cssListener.d.ts +19 -0
- package/dist/module/core/web/cssListener.js +137 -0
- package/dist/module/core/web/formatColor.d.ts +1 -0
- package/dist/module/core/web/formatColor.js +8 -0
- package/dist/module/core/web/getWebStyles.d.ts +2 -0
- package/dist/module/core/web/getWebStyles.js +49 -0
- package/dist/module/core/web/index.d.ts +4 -0
- package/dist/module/core/web/index.js +4 -0
- package/dist/module/core/web/parseCSSValue.d.ts +1 -0
- package/dist/module/core/web/parseCSSValue.js +8 -0
- package/dist/module/css/index.d.ts +1 -0
- package/dist/module/css/index.js +25 -0
- package/dist/module/css/insets.d.ts +1 -0
- package/dist/module/css/insets.js +63 -0
- package/dist/module/css/processFunctions.d.ts +2 -0
- package/dist/module/css/processFunctions.js +36 -0
- package/dist/module/css/themes.d.ts +1 -0
- package/dist/module/css/themes.js +97 -0
- package/dist/module/css/variants.d.ts +1 -0
- package/dist/module/css/variants.js +9 -0
- package/dist/module/hoc/index.d.ts +1 -0
- package/dist/module/hoc/index.js +1 -0
- package/dist/module/hoc/types.d.ts +27 -0
- package/dist/module/hoc/types.js +0 -0
- package/dist/module/hoc/withUniwind.d.ts +2 -0
- package/dist/module/hoc/withUniwind.js +76 -0
- package/dist/module/hoc/withUniwind.native.d.ts +2 -0
- package/dist/module/hoc/withUniwind.native.js +81 -0
- package/dist/module/hoc/withUniwindUtils.d.ts +5 -0
- package/dist/module/hoc/withUniwindUtils.js +5 -0
- package/dist/module/hooks/index.d.ts +4 -0
- package/dist/module/hooks/index.js +4 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.js +12 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +2 -0
- package/dist/module/hooks/useCSSVariable/index.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/index.js +1 -0
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +13 -0
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +56 -0
- package/dist/module/hooks/useResolveClassNames.d.ts +2 -0
- package/dist/module/hooks/useResolveClassNames.js +18 -0
- package/dist/module/hooks/useResolveClassNames.native.d.ts +2 -0
- package/dist/module/hooks/useResolveClassNames.native.js +22 -0
- package/dist/module/hooks/useUniwind.d.ts +5 -0
- package/dist/module/hooks/useUniwind.js +21 -0
- package/dist/module/hooks/useUniwindAccent.d.ts +1 -0
- package/dist/module/hooks/useUniwindAccent.js +6 -0
- package/dist/module/hooks/useUniwindAccent.native.d.ts +2 -0
- package/dist/module/hooks/useUniwindAccent.native.js +5 -0
- package/dist/module/index.d.ts +5 -0
- package/dist/module/index.js +3 -0
- package/dist/module/types.d.ts +21 -0
- package/dist/module/types.js +22 -0
- package/dist/module/utils/buildDtsFile.d.ts +1 -0
- package/dist/module/utils/buildDtsFile.js +22 -0
- package/dist/module/utils/stringifyThemes.d.ts +1 -0
- package/dist/module/utils/stringifyThemes.js +1 -0
- package/dist/module/vite/index.d.ts +9 -0
- package/dist/module/vite/index.js +1 -0
- package/dist/module/vite/vite.d.ts +8 -0
- package/dist/module/vite/vite.js +73 -0
- package/dist/shared/uniwind.BZIuaszw.cjs +11 -0
- package/dist/shared/uniwind.BgZDHdUR.cjs +81 -0
- package/dist/shared/uniwind.Bt3kqZo6.mjs +290 -0
- package/dist/shared/uniwind.CyoRUwOj.mjs +9 -0
- package/dist/shared/uniwind.D3fvrgEG.mjs +68 -0
- package/dist/shared/uniwind.D_6s2EM-.cjs +301 -0
- package/dist/vite/index.cjs +80 -0
- package/dist/vite/index.d.ts +9 -0
- package/dist/vite/index.mjs +74 -0
- package/metro/package.json +3 -0
- package/package.json +106 -0
- package/readme.md +71 -0
- package/src/components/index.ts +313 -0
- package/src/components/native/ActivityIndicator.tsx +19 -0
- package/src/components/native/Button.tsx +16 -0
- package/src/components/native/FlatList.tsx +28 -0
- package/src/components/native/Image.tsx +19 -0
- package/src/components/native/ImageBackground.tsx +21 -0
- package/src/components/native/InputAccessoryView.tsx +23 -0
- package/src/components/native/KeyboardAvoidingView.tsx +18 -0
- package/src/components/native/Modal.tsx +19 -0
- package/src/components/native/Pressable.tsx +31 -0
- package/src/components/native/RefreshControl.tsx +25 -0
- package/src/components/native/SafeAreaView.tsx +16 -0
- package/src/components/native/ScrollView.tsx +21 -0
- package/src/components/native/SectionList.tsx +25 -0
- package/src/components/native/Switch.tsx +28 -0
- package/src/components/native/Text.tsx +39 -0
- package/src/components/native/TextInput.tsx +52 -0
- package/src/components/native/TouchableHighlight.tsx +34 -0
- package/src/components/native/TouchableNativeFeedback.tsx +31 -0
- package/src/components/native/TouchableOpacity.tsx +31 -0
- package/src/components/native/TouchableWithoutFeedback.tsx +31 -0
- package/src/components/native/View.tsx +16 -0
- package/src/components/native/VirtualizedList.tsx +25 -0
- package/src/components/native/useStyle.ts +33 -0
- package/src/components/utils.ts +16 -0
- package/src/components/web/ActivityIndicator.tsx +18 -0
- package/src/components/web/Button.tsx +16 -0
- package/src/components/web/FlatList.tsx +20 -0
- package/src/components/web/Image.tsx +18 -0
- package/src/components/web/ImageBackground.tsx +19 -0
- package/src/components/web/KeyboardAvoidingView.tsx +15 -0
- package/src/components/web/Modal.tsx +14 -0
- package/src/components/web/Pressable.tsx +14 -0
- package/src/components/web/RefreshControl.tsx +14 -0
- package/src/components/web/SafeAreaView.tsx +14 -0
- package/src/components/web/ScrollView.tsx +15 -0
- package/src/components/web/SectionList.tsx +17 -0
- package/src/components/web/Switch.tsx +21 -0
- package/src/components/web/Text.tsx +14 -0
- package/src/components/web/TextInput.tsx +14 -0
- package/src/components/web/TouchableHighlight.tsx +18 -0
- package/src/components/web/TouchableNativeFeedback.tsx +2 -0
- package/src/components/web/TouchableOpacity.tsx +14 -0
- package/src/components/web/TouchableWithoutFeedback.tsx +14 -0
- package/src/components/web/View.tsx +14 -0
- package/src/components/web/VirtualizedList.tsx +17 -0
- package/src/components/web/index.ts +22 -0
- package/src/components/web/metro-injected.ts +1 -0
- package/src/components/web/rnw.ts +52 -0
- package/src/core/config/config.common.ts +98 -0
- package/src/core/config/config.native.ts +79 -0
- package/src/core/config/config.ts +64 -0
- package/src/core/config/index.ts +1 -0
- package/src/core/index.ts +1 -0
- package/src/core/listener.ts +59 -0
- package/src/core/logger.ts +15 -0
- package/src/core/native/index.ts +2 -0
- package/src/core/native/native-utils.ts +41 -0
- package/src/core/native/parsers/boxShadow.ts +7 -0
- package/src/core/native/parsers/fontVariant.ts +3 -0
- package/src/core/native/parsers/gradient.ts +39 -0
- package/src/core/native/parsers/index.ts +5 -0
- package/src/core/native/parsers/textShadow.ts +37 -0
- package/src/core/native/parsers/transforms.ts +64 -0
- package/src/core/native/runtime.ts +32 -0
- package/src/core/native/store.ts +238 -0
- package/src/core/types.ts +92 -0
- package/src/core/web/cssListener.ts +185 -0
- package/src/core/web/formatColor.ts +13 -0
- package/src/core/web/getWebStyles.ts +76 -0
- package/src/core/web/index.ts +4 -0
- package/src/core/web/parseCSSValue.ts +10 -0
- package/src/css/index.ts +32 -0
- package/src/css/insets.ts +73 -0
- package/src/css/processFunctions.ts +39 -0
- package/src/css/themes.ts +130 -0
- package/src/css/variants.ts +11 -0
- package/src/hoc/index.ts +1 -0
- package/src/hoc/types.ts +45 -0
- package/src/hoc/withUniwind.native.tsx +118 -0
- package/src/hoc/withUniwind.tsx +115 -0
- package/src/hoc/withUniwindUtils.ts +10 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +3 -0
- package/src/hooks/useCSSVariable/getVariableValue.ts +19 -0
- package/src/hooks/useCSSVariable/index.ts +1 -0
- package/src/hooks/useCSSVariable/useCSSVariable.ts +89 -0
- package/src/hooks/useResolveClassNames.native.ts +29 -0
- package/src/hooks/useResolveClassNames.ts +26 -0
- package/src/hooks/useUniwind.ts +26 -0
- package/src/hooks/useUniwindAccent.native.ts +8 -0
- package/src/hooks/useUniwindAccent.ts +10 -0
- package/src/index.ts +5 -0
- package/src/metro/addMetaToStylesTemplate.ts +152 -0
- package/src/metro/compileVirtual.ts +74 -0
- package/src/metro/index.d.ts +15 -0
- package/src/metro/index.ts +1 -0
- package/src/metro/injectThemes.ts +23 -0
- package/src/metro/logger.ts +44 -0
- package/src/metro/metro-css-patches.ts +57 -0
- package/src/metro/metro-transformer.ts +99 -0
- package/src/metro/polyfillWeb.ts +14 -0
- package/src/metro/processor/color.ts +76 -0
- package/src/metro/processor/css.ts +541 -0
- package/src/metro/processor/functions.ts +199 -0
- package/src/metro/processor/index.ts +1 -0
- package/src/metro/processor/mq.ts +82 -0
- package/src/metro/processor/processor.ts +249 -0
- package/src/metro/processor/rn.ts +277 -0
- package/src/metro/processor/units.ts +58 -0
- package/src/metro/processor/var.ts +18 -0
- package/src/metro/resolvers.ts +101 -0
- package/src/metro/types.ts +74 -0
- package/src/metro/utils/common.ts +103 -0
- package/src/metro/utils/index.ts +2 -0
- package/src/metro/utils/serialize.ts +116 -0
- package/src/metro/withUniwindConfig.ts +60 -0
- package/src/types.ts +24 -0
- package/src/utils/buildDtsFile.ts +27 -0
- package/src/utils/stringifyThemes.ts +1 -0
- package/src/vite/index.d.ts +9 -0
- package/src/vite/index.ts +1 -0
- package/src/vite/vite.ts +86 -0
- package/types.d.ts +109 -0
- package/uniwind.css +262 -0
- package/vite/package.json +3 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { addMissingSpaces, isDefined, pipe, toCamelCase } from '../utils'
|
|
2
|
+
import type { ProcessorBuilder } from './processor'
|
|
3
|
+
|
|
4
|
+
const cssToRNMap: Record<string, (value: any) => Record<string, any>> = {
|
|
5
|
+
backgroundSize: value => {
|
|
6
|
+
return {
|
|
7
|
+
resizeMode: value,
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
transitionProperty: (value: string) => {
|
|
11
|
+
return {
|
|
12
|
+
transitionProperty: value
|
|
13
|
+
.replace(/"/g, '')
|
|
14
|
+
.split(',')
|
|
15
|
+
.filter(token => token !== '' && !token.startsWith('--'))
|
|
16
|
+
.map(token => `"${toCamelCase(token)}"`),
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
flex: (value: any) => {
|
|
20
|
+
if (typeof value === 'object') {
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
flex: value,
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
overflow: (value: any) => {
|
|
29
|
+
if (typeof value === 'object') {
|
|
30
|
+
return value
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
overflow: value,
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
backdropFilter: () => ({}),
|
|
38
|
+
backgroundImage: value => ({
|
|
39
|
+
experimental_backgroundImage: value,
|
|
40
|
+
}),
|
|
41
|
+
borderSpacing: () => ({}),
|
|
42
|
+
translate: value => {
|
|
43
|
+
if (typeof value === 'object' && 'x' in value && 'y' in value) {
|
|
44
|
+
return {
|
|
45
|
+
translateX: value.x,
|
|
46
|
+
translateY: value.y,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof value === 'string') {
|
|
51
|
+
const [x, y] = value.split(' ')
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
translateX: x,
|
|
55
|
+
translateY: y ?? x,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {}
|
|
60
|
+
},
|
|
61
|
+
rotate: value => {
|
|
62
|
+
if (typeof value === 'object') {
|
|
63
|
+
return value
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
rotate: value,
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
scale: value => {
|
|
71
|
+
if (typeof value === 'object') {
|
|
72
|
+
return {
|
|
73
|
+
scaleX: value.x,
|
|
74
|
+
scaleY: value.y,
|
|
75
|
+
scaleZ: value.z,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (typeof value === 'string') {
|
|
80
|
+
const [x, y, z] = value.split(' ')
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
scaleX: x,
|
|
84
|
+
scaleY: y,
|
|
85
|
+
scaleZ: z,
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {}
|
|
90
|
+
},
|
|
91
|
+
transform: value => {
|
|
92
|
+
if (typeof value === 'string' || Array.isArray(value)) {
|
|
93
|
+
return {
|
|
94
|
+
transform: value,
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (typeof value === 'object') {
|
|
99
|
+
return Object.keys(value).length === 0
|
|
100
|
+
? { transform: [] }
|
|
101
|
+
: value
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {}
|
|
105
|
+
},
|
|
106
|
+
fontSize: value => {
|
|
107
|
+
return {
|
|
108
|
+
fontSize: value,
|
|
109
|
+
'--uniwind-em': value,
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
borderInlineWidth: value => {
|
|
113
|
+
const borderWidth = typeof value === 'object'
|
|
114
|
+
? Object.values(value)[0]
|
|
115
|
+
: value
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
borderLeftWidth: borderWidth,
|
|
119
|
+
borderRightWidth: borderWidth,
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
borderBlockWidth: value => {
|
|
123
|
+
const borderWidth = typeof value === 'object'
|
|
124
|
+
? Object.values(value)[0]
|
|
125
|
+
: value
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
borderTopWidth: borderWidth,
|
|
129
|
+
borderBottomWidth: borderWidth,
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
borderInlineStyle: value => {
|
|
133
|
+
return {
|
|
134
|
+
borderStyle: value,
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
borderBlockStyle: value => {
|
|
138
|
+
return {
|
|
139
|
+
borderStyle: value,
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
borderStyle: value => {
|
|
143
|
+
const borderStyle = typeof value === 'object'
|
|
144
|
+
? Object.values(value)[0]
|
|
145
|
+
: value
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
borderStyle,
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
transformOrigin: value => {
|
|
152
|
+
if (typeof value === 'object') {
|
|
153
|
+
return {
|
|
154
|
+
transformOrigin: `${value.x} ${value.y}`,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
transformOrigin: value,
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
fontVariantNumeric: value => ({
|
|
163
|
+
fontVariant: value,
|
|
164
|
+
}),
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export class RN {
|
|
168
|
+
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
169
|
+
|
|
170
|
+
cssToRN(property: string, value: any) {
|
|
171
|
+
const transformedProperty = property.startsWith('--')
|
|
172
|
+
? property
|
|
173
|
+
: pipe(property)(
|
|
174
|
+
toCamelCase,
|
|
175
|
+
x => {
|
|
176
|
+
if (x.includes('padding') || x.includes('margin')) {
|
|
177
|
+
return x
|
|
178
|
+
.replace('Inline', 'Horizontal')
|
|
179
|
+
.replace('Block', 'Vertical')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return x
|
|
183
|
+
},
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
const rn = this.transformProperty(
|
|
187
|
+
transformedProperty,
|
|
188
|
+
typeof value === 'string' ? addMissingSpaces(value) : value,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
return Object.entries(rn).filter(([, value]) => isDefined(value)) as Array<[string, any]>
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private transformProperty(property: string, value: any) {
|
|
195
|
+
if (property in cssToRNMap) {
|
|
196
|
+
return cssToRNMap[property]!(value)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (typeof value === 'object') {
|
|
200
|
+
const transformed = this.transformObjectProperty(property, value)
|
|
201
|
+
|
|
202
|
+
if (transformed) {
|
|
203
|
+
return transformed
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
[property]: value,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private transformObjectProperty(property: string, value: Record<string, any>) {
|
|
213
|
+
const properties = Object.keys(value)
|
|
214
|
+
// border properties are border{X}Color instead of borderColor{X}
|
|
215
|
+
const propertyEnd = property.includes('border')
|
|
216
|
+
? property.split('border').at(-1) ?? ''
|
|
217
|
+
: ''
|
|
218
|
+
const transformedProperty = property.replace(propertyEnd, '')
|
|
219
|
+
const isSpacing = property.includes('margin') || property.includes('padding')
|
|
220
|
+
|
|
221
|
+
const wrapProperty = (prop: string) => `${transformedProperty}${prop}${propertyEnd}`
|
|
222
|
+
|
|
223
|
+
if (properties.every(property => ['row', 'column'].includes(property))) {
|
|
224
|
+
return {
|
|
225
|
+
rowGap: value.row,
|
|
226
|
+
columnGap: value.column,
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (properties.every(property => ['start', 'end'].includes(property))) {
|
|
231
|
+
if (isSpacing && property.includes('Horizontal')) {
|
|
232
|
+
return {
|
|
233
|
+
[`${property.replace('Horizontal', 'Left')}`]: value.start,
|
|
234
|
+
[`${property.replace('Horizontal', 'Right')}`]: value.end,
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (isSpacing && property.includes('Vertical')) {
|
|
239
|
+
return {
|
|
240
|
+
[`${property.replace('Vertical', 'Top')}`]: value.start,
|
|
241
|
+
[`${property.replace('Vertical', 'Bottom')}`]: value.end,
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
[wrapProperty('Start')]: value.start,
|
|
247
|
+
[wrapProperty('End')]: value.end,
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (properties.every(property => ['top', 'right', 'bottom', 'left'].includes(property))) {
|
|
252
|
+
return {
|
|
253
|
+
[wrapProperty('Top')]: value.top,
|
|
254
|
+
[wrapProperty('Right')]: value.right,
|
|
255
|
+
[wrapProperty('Bottom')]: value.bottom,
|
|
256
|
+
[wrapProperty('Left')]: value.left,
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (properties.every(property => ['topLeft', 'topRight', 'bottomRight', 'bottomLeft'].includes(property))) {
|
|
261
|
+
return {
|
|
262
|
+
[wrapProperty('TopLeft')]: value.topLeft,
|
|
263
|
+
[wrapProperty('TopRight')]: value.topRight,
|
|
264
|
+
[wrapProperty('BottomRight')]: value.bottomRight,
|
|
265
|
+
[wrapProperty('BottomLeft')]: value.bottomLeft,
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (properties.every(property => ['style', 'width', 'color'].includes(property))) {
|
|
270
|
+
return {
|
|
271
|
+
[wrapProperty('Style')]: value.style,
|
|
272
|
+
[wrapProperty('Width')]: value.width,
|
|
273
|
+
[wrapProperty('Color')]: value.color,
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DimensionPercentageFor_LengthValue, Length, LengthValue } from 'lightningcss'
|
|
2
|
+
import { Logger } from '../logger'
|
|
3
|
+
import type { ProcessorBuilder } from './processor'
|
|
4
|
+
|
|
5
|
+
export class Units {
|
|
6
|
+
private readonly logger = new Logger('Units')
|
|
7
|
+
|
|
8
|
+
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
9
|
+
|
|
10
|
+
processLength(length: LengthValue | DimensionPercentageFor_LengthValue | number) {
|
|
11
|
+
if (typeof length === 'number') {
|
|
12
|
+
return length
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if ('unit' in length) {
|
|
16
|
+
switch (length.unit) {
|
|
17
|
+
case 'px':
|
|
18
|
+
return this.replaceInfinity(length.value)
|
|
19
|
+
case 'vw':
|
|
20
|
+
return `rt.screen.width * ${length.value / 100}`
|
|
21
|
+
case 'vh':
|
|
22
|
+
return `rt.screen.height * ${length.value / 100}`
|
|
23
|
+
case 'rem':
|
|
24
|
+
return length.value * this.Processor.vars['--uniwind-em']
|
|
25
|
+
case 'em':
|
|
26
|
+
return `this[\`--uniwind-em\`] * ${length.value}`
|
|
27
|
+
default:
|
|
28
|
+
this.logger.warn(`Unsupported unit - ${length.unit}`)
|
|
29
|
+
|
|
30
|
+
return length.value
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.Processor.CSS.processValue(length)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
processAnyLength(length: DimensionPercentageFor_LengthValue | Length | LengthValue) {
|
|
38
|
+
if ('type' in length) {
|
|
39
|
+
switch (length.type) {
|
|
40
|
+
case 'value':
|
|
41
|
+
case 'dimension':
|
|
42
|
+
return this.processLength(length.value)
|
|
43
|
+
case 'percentage':
|
|
44
|
+
return `${length.value * 100}%`
|
|
45
|
+
default:
|
|
46
|
+
this.logger.warn(`Unsupported length type - ${length.type}`)
|
|
47
|
+
|
|
48
|
+
return length.value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return this.processLength(length)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
replaceInfinity(value: any) {
|
|
56
|
+
return value === Infinity ? 99999 : value
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Variable } from 'lightningcss'
|
|
2
|
+
import type { ProcessorBuilder } from './processor'
|
|
3
|
+
|
|
4
|
+
export class Var {
|
|
5
|
+
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
6
|
+
|
|
7
|
+
processVar(variable: Variable): string {
|
|
8
|
+
const value = `this[\`${variable.name.ident}\`]`
|
|
9
|
+
|
|
10
|
+
if (!variable.fallback || variable.fallback.length === 0) {
|
|
11
|
+
return value
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const fallback = this.Processor.CSS.processValue(variable.fallback)
|
|
15
|
+
|
|
16
|
+
return `${value} ?? ${fallback}`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
|
|
2
|
+
import { basename, resolve, sep } from 'node:path'
|
|
3
|
+
import { name } from '../../package.json'
|
|
4
|
+
|
|
5
|
+
type ResolverConfig = {
|
|
6
|
+
platform: string | null
|
|
7
|
+
resolver: CustomResolver
|
|
8
|
+
context: CustomResolutionContext
|
|
9
|
+
moduleName: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const thisModuleDist = resolve(__dirname, '../../dist')
|
|
13
|
+
const thisModuleSrc = resolve(__dirname, '../../src')
|
|
14
|
+
|
|
15
|
+
const isFromThisModule = (filename: string) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc)
|
|
16
|
+
|
|
17
|
+
const SUPPORTED_COMPONENTS = [
|
|
18
|
+
'ActivityIndicator',
|
|
19
|
+
'Button',
|
|
20
|
+
'FlatList',
|
|
21
|
+
'Image',
|
|
22
|
+
'ImageBackground',
|
|
23
|
+
'InputAccessoryView',
|
|
24
|
+
'KeyboardAvoidingView',
|
|
25
|
+
'Modal',
|
|
26
|
+
'Pressable',
|
|
27
|
+
'RefreshControl',
|
|
28
|
+
'SafeAreaView',
|
|
29
|
+
'ScrollView',
|
|
30
|
+
'SectionList',
|
|
31
|
+
'Switch',
|
|
32
|
+
'Text',
|
|
33
|
+
'TextInput',
|
|
34
|
+
'TouchableHighlight',
|
|
35
|
+
'TouchableNativeFeedback',
|
|
36
|
+
'TouchableOpacity',
|
|
37
|
+
'TouchableWithoutFeedback',
|
|
38
|
+
'View',
|
|
39
|
+
'VirtualizedList',
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
export const nativeResolver = ({
|
|
43
|
+
context,
|
|
44
|
+
moduleName,
|
|
45
|
+
platform,
|
|
46
|
+
resolver,
|
|
47
|
+
}: ResolverConfig) => {
|
|
48
|
+
const resolution = resolver(context, moduleName, platform)
|
|
49
|
+
const isInternal = isFromThisModule(context.originModulePath)
|
|
50
|
+
const isReactNativeIndex = context.originModulePath.endsWith(
|
|
51
|
+
`react-native${sep}index.js`,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if (isInternal || resolution.type !== 'sourceFile' || isReactNativeIndex) {
|
|
55
|
+
return resolution
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (moduleName === 'react-native') {
|
|
59
|
+
return resolver(context, `${name}/components`, platform)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)
|
|
64
|
+
) {
|
|
65
|
+
const filename = basename(resolution.filePath.split(sep).at(-1) ?? '')
|
|
66
|
+
const module = filename.split('.').at(0)
|
|
67
|
+
|
|
68
|
+
if (module !== undefined && SUPPORTED_COMPONENTS.includes(module)) {
|
|
69
|
+
return resolver(context, `${name}/components/${module}`, platform)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return resolution
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const webResolver = ({
|
|
77
|
+
context,
|
|
78
|
+
moduleName,
|
|
79
|
+
platform,
|
|
80
|
+
resolver,
|
|
81
|
+
}: ResolverConfig) => {
|
|
82
|
+
const resolution = resolver(context, moduleName, platform)
|
|
83
|
+
|
|
84
|
+
if (
|
|
85
|
+
isFromThisModule(context.originModulePath)
|
|
86
|
+
|| resolution.type !== 'sourceFile'
|
|
87
|
+
|| !resolution.filePath.includes(`${sep}react-native-web${sep}`)
|
|
88
|
+
) {
|
|
89
|
+
return resolution
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const segments = resolution.filePath.split(sep)
|
|
93
|
+
const isIndex = segments.at(-1)?.startsWith('index.')
|
|
94
|
+
const module = segments.at(-2)
|
|
95
|
+
|
|
96
|
+
if (!isIndex || module === undefined || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${sep}index.js`)) {
|
|
97
|
+
return resolution
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return resolver(context, `${name}/components/${module}`, platform)
|
|
101
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AbsoluteFontWeight,
|
|
3
|
+
Declaration,
|
|
4
|
+
GradientItemFor_DimensionPercentageFor_LengthValue,
|
|
5
|
+
LineDirection,
|
|
6
|
+
MathFunctionFor_DimensionPercentageFor_LengthValue,
|
|
7
|
+
MathFunctionFor_Length,
|
|
8
|
+
MediaFeatureValue,
|
|
9
|
+
ParsedComponent,
|
|
10
|
+
Token,
|
|
11
|
+
TokenOrValue,
|
|
12
|
+
UnresolvedColor,
|
|
13
|
+
} from 'lightningcss'
|
|
14
|
+
import { ColorScheme, Orientation } from '../types'
|
|
15
|
+
|
|
16
|
+
export type Polyfills = {
|
|
17
|
+
rem?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type UniwindConfig = {
|
|
21
|
+
cssEntryFile: string
|
|
22
|
+
themes: Array<string>
|
|
23
|
+
extraThemes?: Array<string>
|
|
24
|
+
dtsFile?: string
|
|
25
|
+
polyfills?: Polyfills
|
|
26
|
+
debug?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type MediaQueryResolver = {
|
|
30
|
+
maxWidth: any
|
|
31
|
+
minWidth: any
|
|
32
|
+
platform: Platform | null
|
|
33
|
+
rtl: boolean | null
|
|
34
|
+
important: boolean
|
|
35
|
+
importantProperties?: Array<string>
|
|
36
|
+
colorScheme: ColorScheme | null
|
|
37
|
+
theme: string | null
|
|
38
|
+
orientation: Orientation | null
|
|
39
|
+
disabled: boolean | null
|
|
40
|
+
active: boolean | null
|
|
41
|
+
focus: boolean | null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const enum Platform {
|
|
45
|
+
Android = 'android',
|
|
46
|
+
iOS = 'ios',
|
|
47
|
+
Web = 'web',
|
|
48
|
+
Native = 'native',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type TakeArray<T> = T extends Array<any> ? T : never
|
|
52
|
+
|
|
53
|
+
export type DeclarationValues =
|
|
54
|
+
| Declaration['value']
|
|
55
|
+
| TakeArray<Declaration['value']>[number]
|
|
56
|
+
| TokenOrValue
|
|
57
|
+
| Token
|
|
58
|
+
| ParsedComponent
|
|
59
|
+
| Array<TokenOrValue>
|
|
60
|
+
| MediaFeatureValue
|
|
61
|
+
| MathFunctionFor_DimensionPercentageFor_LengthValue
|
|
62
|
+
| MathFunctionFor_Length
|
|
63
|
+
| LineDirection
|
|
64
|
+
| GradientItemFor_DimensionPercentageFor_LengthValue
|
|
65
|
+
| AbsoluteFontWeight
|
|
66
|
+
| UnresolvedColor
|
|
67
|
+
|
|
68
|
+
export type ProcessMetaValues = {
|
|
69
|
+
className?: string | null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type StyleSheetTemplate = {
|
|
73
|
+
[K: string]: Array<MediaQueryResolver & Record<string, unknown>>
|
|
74
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const isDefined = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined
|
|
2
|
+
|
|
3
|
+
export const toCamelCase = (str: string) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
4
|
+
|
|
5
|
+
type P<I, O> = (data: I) => O
|
|
6
|
+
type PipeFns<T> = {
|
|
7
|
+
<A>(a: P<T, A>): A
|
|
8
|
+
<A, B>(a: P<T, A>, b: P<A, B>): B
|
|
9
|
+
<A, B, C>(a: P<T, A>, b: P<A, B>, c: P<B, C>): C
|
|
10
|
+
<A, B, C, D>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>): D
|
|
11
|
+
<A, B, C, D, E>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>, e: P<D, E>): E
|
|
12
|
+
<A, B, C, D, E, F>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>, e: P<D, E>, f: P<E, F>): F
|
|
13
|
+
<A, B, C, D, E, F, G>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>, e: P<D, E>, f: P<E, F>, g: P<F, G>): G
|
|
14
|
+
<A, B, C, D, E, F, G, H>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>, e: P<D, E>, f: P<E, F>, g: P<F, G>, h: P<G, H>): H
|
|
15
|
+
(...fns: Array<P<T, T>>): T
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const pipe = <T>(data: T) => ((...fns: Array<any>) => fns.reduce((acc, fn) => fn(acc), data)) as PipeFns<T>
|
|
19
|
+
|
|
20
|
+
export const isNumber = (data: any) => {
|
|
21
|
+
if (typeof data === 'number') {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof data === 'string' && data !== '') {
|
|
26
|
+
return !isNaN(Number(data))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const smartSplit = (str: string, separator = ' ' as string | RegExp) => {
|
|
33
|
+
const escaper = '&&&'
|
|
34
|
+
|
|
35
|
+
return pipe(str)(
|
|
36
|
+
x => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`),
|
|
37
|
+
x => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`),
|
|
38
|
+
x => x.split(separator),
|
|
39
|
+
x => x.map(token => token.replace(new RegExp(escaper, 'g'), ' ')),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const addMissingSpaces = (str: string) =>
|
|
44
|
+
pipe(str)(
|
|
45
|
+
x => x.trim(),
|
|
46
|
+
x => x.replace(/([^ {])this/g, '$1 this'),
|
|
47
|
+
x => x.replace(/\](?=\d)/g, '] '),
|
|
48
|
+
x => x.replace(/\)(?=\S)/g, ') '),
|
|
49
|
+
x => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" '),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
export const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr))
|
|
53
|
+
|
|
54
|
+
export const isValidJSValue = (jsValueString: string) => {
|
|
55
|
+
try {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
57
|
+
new Function(`const test = ${jsValueString}`)
|
|
58
|
+
|
|
59
|
+
return true
|
|
60
|
+
} catch {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const shouldBeSerialized = (value: string) => {
|
|
66
|
+
if (value.includes('-')) {
|
|
67
|
+
return value.split('-').some(shouldBeSerialized)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return [
|
|
71
|
+
isNumber(value),
|
|
72
|
+
value.startsWith('this['),
|
|
73
|
+
value.startsWith('rt.'),
|
|
74
|
+
/[*/+-]/.test(value),
|
|
75
|
+
value.includes('"'),
|
|
76
|
+
value.includes(' '),
|
|
77
|
+
].some(Boolean)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const roundToPrecision = (value: number, precision: number) => parseFloat(value.toFixed(precision))
|
|
81
|
+
|
|
82
|
+
export const deepEqual = <T>(a: T, b: T): boolean => {
|
|
83
|
+
if (Object.is(a, b)) {
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (
|
|
88
|
+
typeof a !== 'object'
|
|
89
|
+
|| a === null
|
|
90
|
+
|| typeof b !== 'object'
|
|
91
|
+
|| b === null
|
|
92
|
+
) {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const keysA = Object.keys(a) as Array<keyof T>
|
|
97
|
+
|
|
98
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return keysA.every(key => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key))
|
|
103
|
+
}
|