@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 @@
|
|
|
1
|
+
export const parseFontVariant = (fontVariant) => fontVariant.split(" ").filter((token) => token !== "undefined");
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const gradientDirectionTokens = /* @__PURE__ */ new Set(["to", "top", "right", "bottom", "left"]);
|
|
2
|
+
export const resolveGradient = (value) => {
|
|
3
|
+
const tokens = value.split(", ");
|
|
4
|
+
const directionToken = tokens.find((token) => token.includes("to") || token.includes("deg"));
|
|
5
|
+
const filtered = tokens.filter((token) => token !== directionToken);
|
|
6
|
+
const colorStops = filtered.map((token) => {
|
|
7
|
+
const [color, position] = token.split(" ");
|
|
8
|
+
return {
|
|
9
|
+
color,
|
|
10
|
+
positions: position !== void 0 ? [position] : void 0
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
const direction = directionToken?.split(" ").reduce((acc, token) => {
|
|
14
|
+
if (gradientDirectionTokens.has(token) || token.includes("deg")) {
|
|
15
|
+
return `${acc} ${token.replace(",", "")}`;
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, "").trim();
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
colorStops,
|
|
22
|
+
type: "linear-gradient",
|
|
23
|
+
direction
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseTextShadowMutation: (styles: Record<string, any>) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const parseTextShadowMutation = (styles) => {
|
|
2
|
+
const tokens = styles.textShadow.replace(/,/g, "").split(" ");
|
|
3
|
+
if (tokens.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const color = tokens.find((token) => token.startsWith("#")) ?? "#000000";
|
|
7
|
+
const offsets = tokens.filter((token) => token !== color);
|
|
8
|
+
const [offsetX, offsetY, radius] = offsets;
|
|
9
|
+
if (offsetX !== void 0 && offsetY !== void 0) {
|
|
10
|
+
Object.defineProperty(styles, "textShadowOffset", {
|
|
11
|
+
configurable: true,
|
|
12
|
+
enumerable: true,
|
|
13
|
+
value: {
|
|
14
|
+
width: Number(offsetX),
|
|
15
|
+
height: Number(offsetY)
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
delete styles.textShadow;
|
|
19
|
+
}
|
|
20
|
+
if (radius !== void 0) {
|
|
21
|
+
Object.defineProperty(styles, "textShadowRadius", {
|
|
22
|
+
configurable: true,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
value: Number(radius)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(styles, "textShadowColor", {
|
|
28
|
+
configurable: true,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
value: color
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseTransformsMutation: (styles: Record<string, any>) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const transforms = [
|
|
2
|
+
"translateX",
|
|
3
|
+
"translateY",
|
|
4
|
+
"translateZ",
|
|
5
|
+
"rotate",
|
|
6
|
+
"rotateX",
|
|
7
|
+
"rotateY",
|
|
8
|
+
"rotateZ",
|
|
9
|
+
"scale",
|
|
10
|
+
"scaleX",
|
|
11
|
+
"scaleY",
|
|
12
|
+
"scaleZ",
|
|
13
|
+
"skewX",
|
|
14
|
+
"skewY",
|
|
15
|
+
"perspective"
|
|
16
|
+
];
|
|
17
|
+
const processTransform = (transform, value) => {
|
|
18
|
+
if (transform.startsWith("scale") && typeof value === "string") {
|
|
19
|
+
return parseFloat(value.replace("%", "")) / 100;
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
export const parseTransformsMutation = (styles) => {
|
|
24
|
+
const transformTokens = typeof styles.transform === "string" ? styles.transform.split(" ").filter((token) => token !== "undefined") : [];
|
|
25
|
+
const transformsResult = [];
|
|
26
|
+
for (const transform of transforms) {
|
|
27
|
+
if (transformTokens.length > 0) {
|
|
28
|
+
for (const token of transformTokens) {
|
|
29
|
+
if (!token.startsWith(transform)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const transformValue = token.slice(transform.length + 1, -1);
|
|
33
|
+
transformsResult.push({ [transform]: processTransform(transform, transformValue) });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (styles[transform] !== void 0) {
|
|
37
|
+
transformsResult.push({ [transform]: processTransform(transform, styles[transform]) });
|
|
38
|
+
delete styles[transform];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (transformsResult.length > 0) {
|
|
42
|
+
Object.defineProperty(styles, "transform", {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
value: transformsResult
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Appearance, Dimensions, I18nManager, PixelRatio, StyleSheet } from "react-native";
|
|
2
|
+
import { ColorScheme, Orientation } from "../../types.js";
|
|
3
|
+
import { colorMix, lightDark } from "./native-utils.js";
|
|
4
|
+
const window = Dimensions.get("window");
|
|
5
|
+
const initialColorScheme = Appearance.getColorScheme() ?? ColorScheme.Light;
|
|
6
|
+
export const UniwindRuntime = {
|
|
7
|
+
screen: {
|
|
8
|
+
width: window.width,
|
|
9
|
+
height: window.height
|
|
10
|
+
},
|
|
11
|
+
colorScheme: initialColorScheme,
|
|
12
|
+
currentThemeName: initialColorScheme,
|
|
13
|
+
orientation: window.width > window.height ? Orientation.Landscape : Orientation.Portrait,
|
|
14
|
+
fontScale: (value) => value * PixelRatio.getFontScale(),
|
|
15
|
+
hairlineWidth: StyleSheet.hairlineWidth,
|
|
16
|
+
rtl: I18nManager.isRTL,
|
|
17
|
+
insets: {
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
bottom: 0,
|
|
21
|
+
right: 0
|
|
22
|
+
},
|
|
23
|
+
colorMix,
|
|
24
|
+
pixelRatio: (value) => value * PixelRatio.get(),
|
|
25
|
+
cubicBezier: () => "",
|
|
26
|
+
lightDark: () => ""
|
|
27
|
+
};
|
|
28
|
+
UniwindRuntime.lightDark = lightDark.bind(UniwindRuntime);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StyleDependency } from '../../types';
|
|
2
|
+
import { ComponentState, CSSVariables, GenerateStyleSheetsCallback, RNStyle } from '../types';
|
|
3
|
+
type StylesResult = {
|
|
4
|
+
styles: RNStyle;
|
|
5
|
+
dependencies: Array<StyleDependency>;
|
|
6
|
+
};
|
|
7
|
+
declare class UniwindStoreBuilder {
|
|
8
|
+
runtime: import("../types").UniwindRuntime;
|
|
9
|
+
vars: Record<string, unknown>;
|
|
10
|
+
runtimeThemeVariables: Map<string, CSSVariables>;
|
|
11
|
+
private stylesheet;
|
|
12
|
+
private cache;
|
|
13
|
+
private generateStyleSheetCallbackResult;
|
|
14
|
+
getStyles(className?: string, state?: ComponentState): StylesResult;
|
|
15
|
+
reinit: (generateStyleSheetCallback?: GenerateStyleSheetsCallback) => void;
|
|
16
|
+
private resolveStyles;
|
|
17
|
+
}
|
|
18
|
+
export declare const UniwindStore: UniwindStoreBuilder;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Dimensions, Platform } from "react-native";
|
|
2
|
+
import { Orientation, StyleDependency } from "../../types.js";
|
|
3
|
+
import { UniwindListener } from "../listener.js";
|
|
4
|
+
import { cloneWithAccessors } from "./native-utils.js";
|
|
5
|
+
import { parseBoxShadow, parseFontVariant, parseTextShadowMutation, parseTransformsMutation, resolveGradient } from "./parsers/index.js";
|
|
6
|
+
import { UniwindRuntime } from "./runtime.js";
|
|
7
|
+
class UniwindStoreBuilder {
|
|
8
|
+
runtime = UniwindRuntime;
|
|
9
|
+
vars = {};
|
|
10
|
+
runtimeThemeVariables = /* @__PURE__ */ new Map();
|
|
11
|
+
stylesheet = {};
|
|
12
|
+
cache = /* @__PURE__ */ new Map();
|
|
13
|
+
generateStyleSheetCallbackResult = null;
|
|
14
|
+
getStyles(className, state) {
|
|
15
|
+
if (className === void 0 || className === "") {
|
|
16
|
+
return {
|
|
17
|
+
styles: {},
|
|
18
|
+
dependencies: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const cacheKey = `${className}${state?.isDisabled ?? false}${state?.isFocused ?? false}${state?.isPressed ?? false}`;
|
|
22
|
+
if (this.cache.has(cacheKey)) {
|
|
23
|
+
return this.cache.get(cacheKey);
|
|
24
|
+
}
|
|
25
|
+
const result = this.resolveStyles(className, state);
|
|
26
|
+
this.cache.set(cacheKey, result);
|
|
27
|
+
UniwindListener.subscribe(
|
|
28
|
+
() => this.cache.delete(cacheKey),
|
|
29
|
+
result.dependencies,
|
|
30
|
+
{ once: true }
|
|
31
|
+
);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
reinit = (generateStyleSheetCallback) => {
|
|
35
|
+
const config = generateStyleSheetCallback?.(this.runtime) ?? this.generateStyleSheetCallbackResult;
|
|
36
|
+
if (!config) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { scopedVars, stylesheet, vars } = config;
|
|
40
|
+
this.generateStyleSheetCallbackResult = config;
|
|
41
|
+
this.stylesheet = stylesheet;
|
|
42
|
+
this.vars = vars;
|
|
43
|
+
const themeVars = scopedVars[`__uniwind-theme-${this.runtime.currentThemeName}`];
|
|
44
|
+
const platformVars = scopedVars[`__uniwind-platform-${Platform.OS}`];
|
|
45
|
+
const runtimeThemeVars = this.runtimeThemeVariables.get(this.runtime.currentThemeName);
|
|
46
|
+
if (themeVars) {
|
|
47
|
+
Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(themeVars));
|
|
48
|
+
}
|
|
49
|
+
if (platformVars) {
|
|
50
|
+
Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(platformVars));
|
|
51
|
+
}
|
|
52
|
+
if (runtimeThemeVars) {
|
|
53
|
+
Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(runtimeThemeVars));
|
|
54
|
+
}
|
|
55
|
+
if (__DEV__ && generateStyleSheetCallback) {
|
|
56
|
+
UniwindListener.notifyAll();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
resolveStyles(classNames, state) {
|
|
60
|
+
const result = {};
|
|
61
|
+
let vars = this.vars;
|
|
62
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
63
|
+
const bestBreakpoints = /* @__PURE__ */ new Map();
|
|
64
|
+
for (const className of classNames.split(" ")) {
|
|
65
|
+
if (!(className in this.stylesheet)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const style of this.stylesheet[className]) {
|
|
69
|
+
if (style.dependencies) {
|
|
70
|
+
style.dependencies.forEach((dep) => dependencies.add(dep));
|
|
71
|
+
}
|
|
72
|
+
if (style.minWidth > this.runtime.screen.width || style.maxWidth < this.runtime.screen.width || style.theme !== null && this.runtime.currentThemeName !== style.theme || style.orientation !== null && this.runtime.orientation !== style.orientation || style.rtl !== null && this.runtime.rtl !== style.rtl || style.active !== null && state?.isPressed !== style.active || style.focus !== null && state?.isFocused !== style.focus || style.disabled !== null && state?.isDisabled !== style.disabled) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const [property, valueGetter] of style.entries) {
|
|
76
|
+
const previousBest = bestBreakpoints.get(property);
|
|
77
|
+
if (previousBest && (previousBest.minWidth > style.minWidth || previousBest.complexity > style.complexity || previousBest.importantProperties.includes(property))) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (property[0] === "-") {
|
|
81
|
+
if (vars === this.vars) {
|
|
82
|
+
vars = cloneWithAccessors(this.vars);
|
|
83
|
+
}
|
|
84
|
+
Object.defineProperty(vars, property, {
|
|
85
|
+
configurable: true,
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: valueGetter
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
Object.defineProperty(result, property, {
|
|
91
|
+
configurable: true,
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: () => valueGetter.call(vars)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
bestBreakpoints.set(property, style);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (result.lineHeight !== void 0 && result.lineHeight < 6) {
|
|
101
|
+
Object.defineProperty(result, "lineHeight", {
|
|
102
|
+
value: result.fontSize * result.lineHeight,
|
|
103
|
+
configurable: true,
|
|
104
|
+
enumerable: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (result.boxShadow !== void 0) {
|
|
108
|
+
Object.defineProperty(result, "boxShadow", {
|
|
109
|
+
value: parseBoxShadow(result.boxShadow),
|
|
110
|
+
configurable: true,
|
|
111
|
+
enumerable: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (result.visibility === "hidden") {
|
|
115
|
+
Object.defineProperty(result, "display", {
|
|
116
|
+
value: "none",
|
|
117
|
+
configurable: true,
|
|
118
|
+
enumerable: true
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (result.borderStyle !== void 0 && result.borderColor === void 0) {
|
|
122
|
+
Object.defineProperty(result, "borderColor", {
|
|
123
|
+
value: "#000000",
|
|
124
|
+
configurable: true,
|
|
125
|
+
enumerable: true
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (result.outlineStyle !== void 0 && result.outlineColor === void 0) {
|
|
129
|
+
Object.defineProperty(result, "outlineColor", {
|
|
130
|
+
value: "#000000",
|
|
131
|
+
configurable: true,
|
|
132
|
+
enumerable: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (result.fontVariant !== void 0) {
|
|
136
|
+
Object.defineProperty(result, "fontVariant", {
|
|
137
|
+
value: parseFontVariant(result.fontVariant),
|
|
138
|
+
configurable: true,
|
|
139
|
+
enumerable: true
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
parseTransformsMutation(result);
|
|
143
|
+
if (result.experimental_backgroundImage !== void 0) {
|
|
144
|
+
Object.defineProperty(result, "experimental_backgroundImage", {
|
|
145
|
+
value: resolveGradient(result.experimental_backgroundImage),
|
|
146
|
+
configurable: true,
|
|
147
|
+
enumerable: true
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (result.textShadow !== void 0) {
|
|
151
|
+
parseTextShadowMutation(result);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
styles: { ...result },
|
|
155
|
+
dependencies: Array.from(dependencies)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export const UniwindStore = new UniwindStoreBuilder();
|
|
160
|
+
Dimensions.addEventListener("change", ({ window }) => {
|
|
161
|
+
const newOrientation = window.width > window.height ? Orientation.Landscape : Orientation.Portrait;
|
|
162
|
+
const orientationChanged = UniwindStore.runtime.orientation !== newOrientation;
|
|
163
|
+
UniwindStore.runtime.screen = {
|
|
164
|
+
width: window.width,
|
|
165
|
+
height: window.height
|
|
166
|
+
};
|
|
167
|
+
UniwindStore.runtime.orientation = newOrientation;
|
|
168
|
+
UniwindListener.notify([
|
|
169
|
+
...orientationChanged ? [StyleDependency.Orientation] : [],
|
|
170
|
+
StyleDependency.Dimensions
|
|
171
|
+
]);
|
|
172
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { ColorScheme, Orientation, StyleDependency, UniwindConfig } from '../types';
|
|
3
|
+
export type Style = {
|
|
4
|
+
entries: Array<[string, () => unknown]>;
|
|
5
|
+
minWidth: number;
|
|
6
|
+
maxWidth: number;
|
|
7
|
+
orientation: Orientation | null;
|
|
8
|
+
theme: ColorScheme | null;
|
|
9
|
+
rtl: boolean | null;
|
|
10
|
+
native: boolean;
|
|
11
|
+
dependencies: Array<StyleDependency> | null;
|
|
12
|
+
index: number;
|
|
13
|
+
className: string;
|
|
14
|
+
importantProperties: Array<string>;
|
|
15
|
+
complexity: number;
|
|
16
|
+
active: boolean | null;
|
|
17
|
+
focus: boolean | null;
|
|
18
|
+
disabled: boolean | null;
|
|
19
|
+
};
|
|
20
|
+
export type StyleSheets = Record<string, Array<Style>>;
|
|
21
|
+
export type GenerateStyleSheetsCallback = (rt: UniwindRuntime) => {
|
|
22
|
+
stylesheet: StyleSheets;
|
|
23
|
+
vars: Record<string, unknown>;
|
|
24
|
+
scopedVars: Partial<Record<string, Record<string, unknown>>>;
|
|
25
|
+
};
|
|
26
|
+
type UserThemes = UniwindConfig extends {
|
|
27
|
+
themes: infer T extends readonly string[];
|
|
28
|
+
} ? T : readonly string[];
|
|
29
|
+
export type ThemeName = UserThemes[number];
|
|
30
|
+
export type UniwindRuntime = {
|
|
31
|
+
screen: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
};
|
|
35
|
+
orientation: Orientation;
|
|
36
|
+
colorScheme: ColorScheme;
|
|
37
|
+
currentThemeName: ThemeName;
|
|
38
|
+
rtl: boolean;
|
|
39
|
+
insets: {
|
|
40
|
+
top: number;
|
|
41
|
+
bottom: number;
|
|
42
|
+
left: number;
|
|
43
|
+
right: number;
|
|
44
|
+
};
|
|
45
|
+
hairlineWidth: number;
|
|
46
|
+
pixelRatio: (value: number) => number;
|
|
47
|
+
fontScale: (value: number) => number;
|
|
48
|
+
colorMix: (color: string, weight: number | string, mixColor: string) => string;
|
|
49
|
+
cubicBezier: (x1: number, y1: number, x2: number, y2: number) => string;
|
|
50
|
+
lightDark: (light: string, dark: string) => string;
|
|
51
|
+
};
|
|
52
|
+
export type RNStyle = ViewStyle & TextStyle & ImageStyle & {
|
|
53
|
+
accentColor?: string;
|
|
54
|
+
fill?: string;
|
|
55
|
+
};
|
|
56
|
+
export type RNStylesProps = 'style' | 'contentContainerStyle' | 'imageStyle' | 'ListFooterComponentStyle' | 'ListHeaderComponentStyle' | 'columnWrapperStyle';
|
|
57
|
+
export type RNClassNameProps = GetClassName<RNStylesProps>;
|
|
58
|
+
type GetClassName<T extends string> = T extends `${infer S}Style` ? `${S}ClassName` : 'className';
|
|
59
|
+
export type UniwindComponentProps = {
|
|
60
|
+
[K in RNStylesProps]?: StyleProp<RNStyle>;
|
|
61
|
+
} & {
|
|
62
|
+
[K in RNClassNameProps]?: string;
|
|
63
|
+
};
|
|
64
|
+
declare global {
|
|
65
|
+
var __uniwindThemes__: ReadonlyArray<string> | undefined;
|
|
66
|
+
}
|
|
67
|
+
export type ComponentState = {
|
|
68
|
+
isPressed?: boolean;
|
|
69
|
+
isDisabled?: boolean;
|
|
70
|
+
isFocused?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type CSSVariables = Record<string, string | number>;
|
|
73
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare class CSSListenerBuilder {
|
|
2
|
+
private classNameMediaQueryListeners;
|
|
3
|
+
private listeners;
|
|
4
|
+
private registeredRules;
|
|
5
|
+
private processedStyleSheets;
|
|
6
|
+
private pendingInitialization;
|
|
7
|
+
constructor();
|
|
8
|
+
subscribeToClassName(classNames: string, listener: VoidFunction): () => void;
|
|
9
|
+
private scheduleInitialization;
|
|
10
|
+
private cancelPendingInitialization;
|
|
11
|
+
private initialize;
|
|
12
|
+
private isStyleRule;
|
|
13
|
+
private isMediaRule;
|
|
14
|
+
private collectParentMediaQueries;
|
|
15
|
+
private addMediaQueriesDeep;
|
|
16
|
+
private addMediaQuery;
|
|
17
|
+
}
|
|
18
|
+
export declare const CSSListener: CSSListenerBuilder;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { StyleDependency } from "../../types.js";
|
|
2
|
+
import { UniwindListener } from "../listener.js";
|
|
3
|
+
class CSSListenerBuilder {
|
|
4
|
+
classNameMediaQueryListeners = /* @__PURE__ */ new Map();
|
|
5
|
+
listeners = /* @__PURE__ */ new Map();
|
|
6
|
+
registeredRules = /* @__PURE__ */ new Map();
|
|
7
|
+
processedStyleSheets = /* @__PURE__ */ new WeakSet();
|
|
8
|
+
pendingInitialization = void 0;
|
|
9
|
+
constructor() {
|
|
10
|
+
if (typeof document === "undefined") {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const observer = new MutationObserver((mutations) => {
|
|
14
|
+
for (const mutation of mutations) {
|
|
15
|
+
if (mutation.type === "childList") {
|
|
16
|
+
this.scheduleInitialization();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
this.initialize();
|
|
21
|
+
observer.observe(document.head, {
|
|
22
|
+
childList: true,
|
|
23
|
+
subtree: false,
|
|
24
|
+
attributes: true,
|
|
25
|
+
attributeFilter: ["disabled", "media", "title", "href", "rel"]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
subscribeToClassName(classNames, listener) {
|
|
29
|
+
const disposables = [];
|
|
30
|
+
classNames.split(" ").forEach((className) => {
|
|
31
|
+
const mediaQuery = this.classNameMediaQueryListeners.get(className);
|
|
32
|
+
if (!mediaQuery) {
|
|
33
|
+
return () => {
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const listeners = this.listeners.get(mediaQuery);
|
|
37
|
+
listeners?.add(listener);
|
|
38
|
+
disposables.push(() => listeners?.delete(listener));
|
|
39
|
+
});
|
|
40
|
+
const disposeThemeListener = UniwindListener.subscribe(listener, [StyleDependency.Theme]);
|
|
41
|
+
return () => {
|
|
42
|
+
disposables.forEach((disposable) => disposable());
|
|
43
|
+
disposeThemeListener();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
scheduleInitialization() {
|
|
47
|
+
this.cancelPendingInitialization();
|
|
48
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
49
|
+
this.pendingInitialization = requestIdleCallback(() => {
|
|
50
|
+
this.initialize();
|
|
51
|
+
}, { timeout: 50 });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.pendingInitialization = setTimeout(() => {
|
|
55
|
+
this.initialize();
|
|
56
|
+
}, 50);
|
|
57
|
+
}
|
|
58
|
+
cancelPendingInitialization() {
|
|
59
|
+
if (this.pendingInitialization !== void 0) {
|
|
60
|
+
if (typeof cancelIdleCallback !== "undefined") {
|
|
61
|
+
cancelIdleCallback(this.pendingInitialization);
|
|
62
|
+
} else {
|
|
63
|
+
clearTimeout(this.pendingInitialization);
|
|
64
|
+
}
|
|
65
|
+
this.pendingInitialization = void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
initialize() {
|
|
69
|
+
this.pendingInitialization = void 0;
|
|
70
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
71
|
+
if (this.processedStyleSheets.has(sheet)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
let rules;
|
|
75
|
+
try {
|
|
76
|
+
rules = sheet.cssRules;
|
|
77
|
+
} catch {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (!rules) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
this.processedStyleSheets.add(sheet);
|
|
84
|
+
this.addMediaQueriesDeep(rules);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
isStyleRule(rule) {
|
|
88
|
+
return rule.constructor.name === "CSSStyleRule";
|
|
89
|
+
}
|
|
90
|
+
isMediaRule(rule) {
|
|
91
|
+
return rule.constructor.name === "CSSMediaRule";
|
|
92
|
+
}
|
|
93
|
+
collectParentMediaQueries(rule, acc = []) {
|
|
94
|
+
const { parentRule } = rule;
|
|
95
|
+
if (!parentRule) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
if (this.isMediaRule(parentRule)) {
|
|
99
|
+
acc.push(parentRule);
|
|
100
|
+
}
|
|
101
|
+
const result = this.collectParentMediaQueries(parentRule, acc);
|
|
102
|
+
acc.push(...result);
|
|
103
|
+
return Array.from(new Set(acc));
|
|
104
|
+
}
|
|
105
|
+
addMediaQueriesDeep(rules) {
|
|
106
|
+
for (const rule of Array.from(rules)) {
|
|
107
|
+
if (this.isStyleRule(rule)) {
|
|
108
|
+
const mediaQueries = this.collectParentMediaQueries(rule);
|
|
109
|
+
if (mediaQueries.length > 0) {
|
|
110
|
+
this.addMediaQuery(mediaQueries, rule.selectorText);
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if ("cssRules" in rule && rule.cssRules instanceof CSSRuleList) {
|
|
115
|
+
this.addMediaQueriesDeep(rule.cssRules);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
addMediaQuery(mediaQueries, className) {
|
|
121
|
+
const rules = mediaQueries.map((mediaQuery) => mediaQuery.conditionText).sort().join(" and ");
|
|
122
|
+
const parsedClassName = className.replace(".", "").replace("\\", "");
|
|
123
|
+
const cachedMediaQueryList = this.registeredRules.get(rules);
|
|
124
|
+
if (cachedMediaQueryList) {
|
|
125
|
+
this.classNameMediaQueryListeners.set(parsedClassName, cachedMediaQueryList);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const mediaQueryList = window.matchMedia(rules);
|
|
129
|
+
this.registeredRules.set(rules, mediaQueryList);
|
|
130
|
+
this.listeners.set(mediaQueryList, /* @__PURE__ */ new Set());
|
|
131
|
+
this.classNameMediaQueryListeners.set(parsedClassName, mediaQueryList);
|
|
132
|
+
mediaQueryList.addEventListener("change", () => {
|
|
133
|
+
this.listeners.get(mediaQueryList).forEach((listener) => listener());
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export const CSSListener = new CSSListenerBuilder();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatColor: (color: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { formatHex, formatHex8, parse } from "culori";
|
|
2
|
+
export const formatColor = (color) => {
|
|
3
|
+
const parsedColor = parse(color);
|
|
4
|
+
if (!parsedColor) {
|
|
5
|
+
return color;
|
|
6
|
+
}
|
|
7
|
+
return parsedColor.alpha !== void 0 && parsedColor.alpha !== 1 ? formatHex8(parsedColor) : formatHex(parsedColor);
|
|
8
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { parseCSSValue } from "./parseCSSValue.js";
|
|
2
|
+
const dummy = typeof document !== "undefined" ? Object.assign(document.createElement("div"), {
|
|
3
|
+
style: "display: none"
|
|
4
|
+
}) : null;
|
|
5
|
+
if (dummy) {
|
|
6
|
+
document.body.appendChild(dummy);
|
|
7
|
+
}
|
|
8
|
+
const getComputedStyles = () => {
|
|
9
|
+
if (!dummy) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
const computedStyles = window.getComputedStyle(dummy);
|
|
13
|
+
const styles = {};
|
|
14
|
+
for (let i = 0; i < computedStyles.length; i++) {
|
|
15
|
+
const prop = computedStyles[i];
|
|
16
|
+
styles[prop] = computedStyles.getPropertyValue(prop);
|
|
17
|
+
}
|
|
18
|
+
return styles;
|
|
19
|
+
};
|
|
20
|
+
const initialStyles = typeof document !== "undefined" ? getComputedStyles() : {};
|
|
21
|
+
const getObjectDifference = (obj1, obj2) => {
|
|
22
|
+
const diff = {};
|
|
23
|
+
const keys = Object.keys(obj2);
|
|
24
|
+
keys.forEach((key) => {
|
|
25
|
+
if (obj2[key] !== obj1[key]) {
|
|
26
|
+
diff[key] = obj2[key];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return diff;
|
|
30
|
+
};
|
|
31
|
+
export const getWebStyles = (className) => {
|
|
32
|
+
if (className === void 0) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
if (!dummy) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
dummy.className = className;
|
|
39
|
+
const computedStyles = getObjectDifference(initialStyles, getComputedStyles());
|
|
40
|
+
return Object.fromEntries(
|
|
41
|
+
Object.entries(computedStyles).map(([key, value]) => {
|
|
42
|
+
const parsedKey = key[0] === "-" ? key : key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
43
|
+
return [
|
|
44
|
+
parsedKey,
|
|
45
|
+
parseCSSValue(value)
|
|
46
|
+
];
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
};
|