taro-uno-ui 0.9.0-beta
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 +100 -0
- package/README.md +273 -0
- package/dist/js/index-6NJ3A1Dn.js +26535 -0
- package/dist/js/index-6NJ3A1Dn.js.map +1 -0
- package/dist/js/index-DFdcksbe.js +1165 -0
- package/dist/js/index-DFdcksbe.js.map +1 -0
- package/dist/js/index-DXRIkWX1.js +1148 -0
- package/dist/js/index-DXRIkWX1.js.map +1 -0
- package/dist/js/index-DffLRSro.js +26519 -0
- package/dist/js/index-DffLRSro.js.map +1 -0
- package/package.json +119 -0
- package/src/app.config.ts +55 -0
- package/src/app.scss +508 -0
- package/src/app.tsx +44 -0
- package/src/components/basic/Button/Button.styles.ts +130 -0
- package/src/components/basic/Button/Button.test.tsx +154 -0
- package/src/components/basic/Button/Button.tsx +93 -0
- package/src/components/basic/Button/Button.types.ts +45 -0
- package/src/components/basic/Button/index.tsx +6 -0
- package/src/components/basic/Divider/Divider.styles.ts +488 -0
- package/src/components/basic/Divider/Divider.test.tsx +551 -0
- package/src/components/basic/Divider/Divider.tsx +361 -0
- package/src/components/basic/Divider/Divider.types.ts +261 -0
- package/src/components/basic/Divider/index.tsx +25 -0
- package/src/components/basic/Icon/Icon.styles.ts +359 -0
- package/src/components/basic/Icon/Icon.test.tsx +357 -0
- package/src/components/basic/Icon/Icon.tsx +154 -0
- package/src/components/basic/Icon/Icon.types.ts +210 -0
- package/src/components/basic/Icon/index.tsx +22 -0
- package/src/components/basic/Text/Text.styles.ts +500 -0
- package/src/components/basic/Text/Text.test.tsx +299 -0
- package/src/components/basic/Text/Text.tsx +340 -0
- package/src/components/basic/Text/Text.types.ts +319 -0
- package/src/components/basic/Text/index.tsx +27 -0
- package/src/components/basic/Typography/Typography.styles.ts +346 -0
- package/src/components/basic/Typography/Typography.tsx +205 -0
- package/src/components/basic/Typography/Typography.types.ts +296 -0
- package/src/components/basic/Typography/index.tsx +14 -0
- package/src/components/basic/index.tsx +302 -0
- package/src/components/common/ErrorBoundary.tsx +87 -0
- package/src/components/common/LazyComponent.tsx +246 -0
- package/src/components/common/ResponsiveContainer.tsx +93 -0
- package/src/components/common/ResponsiveGrid.tsx +183 -0
- package/src/components/common/SecurityProvider.tsx +110 -0
- package/src/components/common/ThemeProvider.tsx +128 -0
- package/src/components/common/VirtualList.tsx +368 -0
- package/src/components/common/__tests__/ErrorBoundary.test.tsx +249 -0
- package/src/components/common/index.tsx +7 -0
- package/src/components/display/Avatar/Avatar.styles.ts +62 -0
- package/src/components/display/Avatar/Avatar.test.tsx +390 -0
- package/src/components/display/Avatar/Avatar.tsx +79 -0
- package/src/components/display/Avatar/Avatar.types.ts +40 -0
- package/src/components/display/Avatar/index.ts +3 -0
- package/src/components/display/Badge/Badge.tsx +42 -0
- package/src/components/display/Badge/Badge.types.ts +29 -0
- package/src/components/display/Badge/index.ts +2 -0
- package/src/components/display/Calendar/Calendar.styles.ts +255 -0
- package/src/components/display/Calendar/Calendar.test.tsx +30 -0
- package/src/components/display/Calendar/Calendar.tsx +337 -0
- package/src/components/display/Calendar/Calendar.types.ts +91 -0
- package/src/components/display/Calendar/index.ts +3 -0
- package/src/components/display/Card/Card.styles.ts +89 -0
- package/src/components/display/Card/Card.test.tsx +180 -0
- package/src/components/display/Card/Card.tsx +135 -0
- package/src/components/display/Card/Card.types.ts +55 -0
- package/src/components/display/Card/index.ts +3 -0
- package/src/components/display/Carousel/Carousel.styles.ts +206 -0
- package/src/components/display/Carousel/Carousel.tsx +295 -0
- package/src/components/display/Carousel/Carousel.types.ts +57 -0
- package/src/components/display/Carousel/index.ts +3 -0
- package/src/components/display/List/List.styles.ts +79 -0
- package/src/components/display/List/List.tsx +115 -0
- package/src/components/display/List/List.types.ts +68 -0
- package/src/components/display/List/index.ts +3 -0
- package/src/components/display/Rate/Rate.styles.ts +266 -0
- package/src/components/display/Rate/Rate.tsx +332 -0
- package/src/components/display/Rate/Rate.types.ts +111 -0
- package/src/components/display/Rate/index.ts +28 -0
- package/src/components/display/Table/Table.styles.ts +269 -0
- package/src/components/display/Table/Table.test.tsx +343 -0
- package/src/components/display/Table/Table.tsx +430 -0
- package/src/components/display/Table/Table.types.ts +255 -0
- package/src/components/display/Table/index.tsx +16 -0
- package/src/components/display/Tag/Tag.styles.ts +197 -0
- package/src/components/display/Tag/Tag.test.tsx +541 -0
- package/src/components/display/Tag/Tag.tsx +156 -0
- package/src/components/display/Tag/Tag.types.ts +49 -0
- package/src/components/display/Tag/index.ts +3 -0
- package/src/components/display/Timeline/Timeline.styles.ts +211 -0
- package/src/components/display/Timeline/Timeline.tsx +239 -0
- package/src/components/display/Timeline/Timeline.types.ts +56 -0
- package/src/components/display/Timeline/index.ts +3 -0
- package/src/components/display/index.tsx +143 -0
- package/src/components/feedback/Loading/Loading.styles.ts +117 -0
- package/src/components/feedback/Loading/Loading.test.tsx +534 -0
- package/src/components/feedback/Loading/Loading.tsx +127 -0
- package/src/components/feedback/Loading/Loading.types.ts +33 -0
- package/src/components/feedback/Loading/index.ts +9 -0
- package/src/components/feedback/Message/Message.styles.ts +41 -0
- package/src/components/feedback/Message/Message.test.tsx +234 -0
- package/src/components/feedback/Message/Message.tsx +96 -0
- package/src/components/feedback/Message/Message.types.ts +37 -0
- package/src/components/feedback/Message/index.ts +9 -0
- package/src/components/feedback/Modal/Modal.styles.ts +21 -0
- package/src/components/feedback/Modal/Modal.test.tsx +11 -0
- package/src/components/feedback/Modal/Modal.tsx +291 -0
- package/src/components/feedback/Modal/Modal.types.ts +141 -0
- package/src/components/feedback/Modal/index.tsx +11 -0
- package/src/components/feedback/Notification/Notification.styles.ts +443 -0
- package/src/components/feedback/Notification/Notification.test.tsx +401 -0
- package/src/components/feedback/Notification/Notification.tsx +370 -0
- package/src/components/feedback/Notification/Notification.types.ts +336 -0
- package/src/components/feedback/Notification/NotificationManager.tsx +376 -0
- package/src/components/feedback/Notification/index.ts +33 -0
- package/src/components/feedback/Notification/index.tsx +164 -0
- package/src/components/feedback/Progress/Progress.styles.ts +460 -0
- package/src/components/feedback/Progress/Progress.test.simple.tsx +14 -0
- package/src/components/feedback/Progress/Progress.test.tsx +312 -0
- package/src/components/feedback/Progress/Progress.tsx +508 -0
- package/src/components/feedback/Progress/Progress.types.ts +163 -0
- package/src/components/feedback/Progress/index.ts +3 -0
- package/src/components/feedback/Progress/index.tsx +38 -0
- package/src/components/feedback/Progress/utils/animation.ts +204 -0
- package/src/components/feedback/Progress/utils/index.ts +26 -0
- package/src/components/feedback/Progress/utils/progress-calculator.ts +217 -0
- package/src/components/feedback/Result/Result.styles.ts +139 -0
- package/src/components/feedback/Result/Result.tsx +233 -0
- package/src/components/feedback/Result/Result.types.ts +128 -0
- package/src/components/feedback/Result/index.tsx +3 -0
- package/src/components/feedback/Toast/Toast.styles.ts +17 -0
- package/src/components/feedback/Toast/Toast.test.tsx +10 -0
- package/src/components/feedback/Toast/Toast.tsx +372 -0
- package/src/components/feedback/Toast/Toast.types.ts +86 -0
- package/src/components/feedback/Toast/index.tsx +3 -0
- package/src/components/feedback/Tooltip/Tooltip.examples.tsx +458 -0
- package/src/components/feedback/Tooltip/Tooltip.styles.ts +346 -0
- package/src/components/feedback/Tooltip/Tooltip.test.tsx +446 -0
- package/src/components/feedback/Tooltip/Tooltip.tsx +283 -0
- package/src/components/feedback/Tooltip/Tooltip.types.ts +172 -0
- package/src/components/feedback/Tooltip/index.ts +3 -0
- package/src/components/feedback/Tooltip/index.tsx +258 -0
- package/src/components/feedback/index.tsx +164 -0
- package/src/components/form/Cascader/Cascader.styles.ts +526 -0
- package/src/components/form/Cascader/Cascader.test.tsx +77 -0
- package/src/components/form/Cascader/Cascader.tsx +585 -0
- package/src/components/form/Cascader/Cascader.types.ts +582 -0
- package/src/components/form/Cascader/hooks/index.ts +3 -0
- package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +16 -0
- package/src/components/form/Cascader/hooks/useCascaderOptions.ts +109 -0
- package/src/components/form/Cascader/hooks/useCascaderState.ts +133 -0
- package/src/components/form/Cascader/index.ts +25 -0
- package/src/components/form/Cascader/utils/formatDisplayValue.ts +19 -0
- package/src/components/form/Cascader/utils/index.ts +1 -0
- package/src/components/form/Checkbox/Checkbox.styles.ts +608 -0
- package/src/components/form/Checkbox/Checkbox.test.tsx +1140 -0
- package/src/components/form/Checkbox/Checkbox.tsx +496 -0
- package/src/components/form/Checkbox/Checkbox.types.ts +472 -0
- package/src/components/form/Checkbox/CheckboxGroup.tsx +444 -0
- package/src/components/form/Checkbox/index.tsx +27 -0
- package/src/components/form/DatePicker/DatePicker.styles.ts +393 -0
- package/src/components/form/DatePicker/DatePicker.test.tsx +407 -0
- package/src/components/form/DatePicker/DatePicker.tsx +360 -0
- package/src/components/form/DatePicker/DatePicker.types.ts +247 -0
- package/src/components/form/DatePicker/index.tsx +15 -0
- package/src/components/form/Form/Form.styles.ts +357 -0
- package/src/components/form/Form/Form.test.tsx +122 -0
- package/src/components/form/Form/Form.tsx +695 -0
- package/src/components/form/Form/Form.types.ts +407 -0
- package/src/components/form/Form/index.tsx +31 -0
- package/src/components/form/Input/Input.enhanced.tsx +732 -0
- package/src/components/form/Input/Input.styles.ts +438 -0
- package/src/components/form/Input/Input.test.tsx +494 -0
- package/src/components/form/Input/Input.tsx +541 -0
- package/src/components/form/Input/Input.types.ts +285 -0
- package/src/components/form/Input/index.tsx +26 -0
- package/src/components/form/InputNumber/InputNumber.styles.ts +665 -0
- package/src/components/form/InputNumber/InputNumber.tsx +370 -0
- package/src/components/form/InputNumber/InputNumber.types.ts +318 -0
- package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +32 -0
- package/src/components/form/InputNumber/components/InputNumberControls.tsx +42 -0
- package/src/components/form/InputNumber/components/index.ts +2 -0
- package/src/components/form/InputNumber/hooks/index.ts +4 -0
- package/src/components/form/InputNumber/hooks/useInputNumberState.ts +315 -0
- package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +147 -0
- package/src/components/form/InputNumber/index.ts +25 -0
- package/src/components/form/Radio/Radio.styles.ts +458 -0
- package/src/components/form/Radio/Radio.test.tsx +547 -0
- package/src/components/form/Radio/Radio.tsx +283 -0
- package/src/components/form/Radio/Radio.types.ts +410 -0
- package/src/components/form/Radio/index.tsx +21 -0
- package/src/components/form/Select/Select.styles.ts +514 -0
- package/src/components/form/Select/Select.test.tsx +648 -0
- package/src/components/form/Select/Select.tsx +474 -0
- package/src/components/form/Select/Select.types.ts +428 -0
- package/src/components/form/Select/index.tsx +30 -0
- package/src/components/form/Slider/Slider.styles.ts +139 -0
- package/src/components/form/Slider/Slider.test.tsx +553 -0
- package/src/components/form/Slider/Slider.tsx +326 -0
- package/src/components/form/Slider/Slider.types.ts +108 -0
- package/src/components/form/Slider/index.tsx +10 -0
- package/src/components/form/Switch/Switch.styles.ts +540 -0
- package/src/components/form/Switch/Switch.test.tsx +345 -0
- package/src/components/form/Switch/Switch.tsx +464 -0
- package/src/components/form/Switch/Switch.types.ts +386 -0
- package/src/components/form/Switch/index.tsx +26 -0
- package/src/components/form/Textarea/Textarea.styles.ts +592 -0
- package/src/components/form/Textarea/Textarea.test.tsx +1075 -0
- package/src/components/form/Textarea/Textarea.tsx +602 -0
- package/src/components/form/Textarea/Textarea.types.ts +371 -0
- package/src/components/form/Textarea/index.tsx +26 -0
- package/src/components/form/TimePicker/TimePicker.styles.ts +438 -0
- package/src/components/form/TimePicker/TimePicker.test.tsx +306 -0
- package/src/components/form/TimePicker/TimePicker.tsx +228 -0
- package/src/components/form/TimePicker/TimePicker.types.ts +385 -0
- package/src/components/form/TimePicker/index.ts +21 -0
- package/src/components/form/Transfer/Transfer.styles.ts +502 -0
- package/src/components/form/Transfer/Transfer.test.tsx +316 -0
- package/src/components/form/Transfer/Transfer.tsx +402 -0
- package/src/components/form/Transfer/Transfer.types.ts +557 -0
- package/src/components/form/Transfer/components/TransferItem.tsx +101 -0
- package/src/components/form/Transfer/components/TransferList.tsx +285 -0
- package/src/components/form/Transfer/components/TransferOperations.tsx +84 -0
- package/src/components/form/Transfer/components/TransferPagination.tsx +135 -0
- package/src/components/form/Transfer/components/TransferSearch.tsx +88 -0
- package/src/components/form/Transfer/components/index.ts +6 -0
- package/src/components/form/Transfer/hooks/index.ts +3 -0
- package/src/components/form/Transfer/hooks/useTransferData.ts +192 -0
- package/src/components/form/Transfer/hooks/useTransferState.ts +114 -0
- package/src/components/form/Transfer/index.ts +33 -0
- package/src/components/form/Upload/Upload.styles.ts +145 -0
- package/src/components/form/Upload/Upload.test.tsx +10 -0
- package/src/components/form/Upload/Upload.tsx +451 -0
- package/src/components/form/Upload/Upload.types.ts +200 -0
- package/src/components/form/Upload/index.tsx +12 -0
- package/src/components/form/index.tsx +121 -0
- package/src/components/index.tsx +146 -0
- package/src/components/layout/Affix/Affix.styles.ts +37 -0
- package/src/components/layout/Affix/Affix.test.tsx +10 -0
- package/src/components/layout/Affix/Affix.tsx +91 -0
- package/src/components/layout/Affix/Affix.types.ts +29 -0
- package/src/components/layout/Affix/index.tsx +3 -0
- package/src/components/layout/Col/Col.styles.ts +185 -0
- package/src/components/layout/Col/Col.test.tsx +535 -0
- package/src/components/layout/Col/Col.tsx +115 -0
- package/src/components/layout/Col/Col.types.ts +59 -0
- package/src/components/layout/Col/index.tsx +3 -0
- package/src/components/layout/Container/Container.styles.ts +161 -0
- package/src/components/layout/Container/Container.test.tsx +380 -0
- package/src/components/layout/Container/Container.tsx +132 -0
- package/src/components/layout/Container/Container.types.ts +63 -0
- package/src/components/layout/Container/index.tsx +3 -0
- package/src/components/layout/Grid/Grid.styles.ts +183 -0
- package/src/components/layout/Grid/Grid.test.tsx +637 -0
- package/src/components/layout/Grid/Grid.tsx +173 -0
- package/src/components/layout/Grid/Grid.types.ts +78 -0
- package/src/components/layout/Grid/index.tsx +3 -0
- package/src/components/layout/Layout/Content.tsx +38 -0
- package/src/components/layout/Layout/Footer.tsx +38 -0
- package/src/components/layout/Layout/Header.tsx +38 -0
- package/src/components/layout/Layout/Layout.styles.ts +84 -0
- package/src/components/layout/Layout/Layout.test.tsx +10 -0
- package/src/components/layout/Layout/Layout.tsx +39 -0
- package/src/components/layout/Layout/Layout.types.ts +58 -0
- package/src/components/layout/Layout/Sider.tsx +56 -0
- package/src/components/layout/Layout/index.tsx +8 -0
- package/src/components/layout/Row/Row.styles.ts +159 -0
- package/src/components/layout/Row/Row.test.tsx +467 -0
- package/src/components/layout/Row/Row.tsx +139 -0
- package/src/components/layout/Row/Row.types.ts +60 -0
- package/src/components/layout/Row/index.tsx +3 -0
- package/src/components/layout/Space/Space.styles.ts +255 -0
- package/src/components/layout/Space/Space.test.tsx +682 -0
- package/src/components/layout/Space/Space.tsx +211 -0
- package/src/components/layout/Space/Space.types.ts +92 -0
- package/src/components/layout/Space/index.tsx +12 -0
- package/src/components/layout/index.tsx +68 -0
- package/src/components/navigation/Menu/Menu.styles.ts +779 -0
- package/src/components/navigation/Menu/Menu.tsx +355 -0
- package/src/components/navigation/Menu/Menu.types.ts +231 -0
- package/src/components/navigation/Menu/Menu.utils.ts +187 -0
- package/src/components/navigation/Menu/MenuItem.tsx +126 -0
- package/src/components/navigation/Menu/SubMenu.tsx +148 -0
- package/src/components/navigation/Menu/__tests__/Menu.test.tsx +687 -0
- package/src/components/navigation/Menu/index.tsx +124 -0
- package/src/components/navigation/NavBar/NavBar.styles.ts +129 -0
- package/src/components/navigation/NavBar/NavBar.test.tsx +287 -0
- package/src/components/navigation/NavBar/NavBar.tsx +231 -0
- package/src/components/navigation/NavBar/NavBar.types.ts +54 -0
- package/src/components/navigation/NavBar/index.tsx +3 -0
- package/src/components/navigation/Pagination/Pagination.styles.ts +187 -0
- package/src/components/navigation/Pagination/Pagination.test.tsx +673 -0
- package/src/components/navigation/Pagination/Pagination.tsx +395 -0
- package/src/components/navigation/Pagination/Pagination.types.ts +86 -0
- package/src/components/navigation/Pagination/index.ts +18 -0
- package/src/components/navigation/Pagination/index.tsx +9 -0
- package/src/components/navigation/Steps/Step.tsx +56 -0
- package/src/components/navigation/Steps/Steps.styles.ts +154 -0
- package/src/components/navigation/Steps/Steps.test.tsx +12 -0
- package/src/components/navigation/Steps/Steps.tsx +113 -0
- package/src/components/navigation/Steps/Steps.types.ts +47 -0
- package/src/components/navigation/Steps/index.tsx +3 -0
- package/src/components/navigation/Tabs/Tabs.styles.ts +199 -0
- package/src/components/navigation/Tabs/Tabs.test.tsx +661 -0
- package/src/components/navigation/Tabs/Tabs.tsx +253 -0
- package/src/components/navigation/Tabs/Tabs.types.ts +114 -0
- package/src/components/navigation/Tabs/index.tsx +3 -0
- package/src/components/navigation/Tree/Tree.styles.ts +553 -0
- package/src/components/navigation/Tree/Tree.test.basic.tsx +7 -0
- package/src/components/navigation/Tree/Tree.test.functional.tsx +496 -0
- package/src/components/navigation/Tree/Tree.test.import.check.tsx +6 -0
- package/src/components/navigation/Tree/Tree.test.import.tsx +6 -0
- package/src/components/navigation/Tree/Tree.test.minimal.tsx +5 -0
- package/src/components/navigation/Tree/Tree.test.simple.tsx +30 -0
- package/src/components/navigation/Tree/Tree.test.tsx +908 -0
- package/src/components/navigation/Tree/Tree.test.working.tsx +673 -0
- package/src/components/navigation/Tree/Tree.tsx +600 -0
- package/src/components/navigation/Tree/Tree.types.ts +909 -0
- package/src/components/navigation/Tree/Tree.utils.ts +452 -0
- package/src/components/navigation/Tree/index.ts +33 -0
- package/src/components/navigation/Tree/index.tsx +23 -0
- package/src/components/navigation/index.tsx +83 -0
- package/src/constants/index.ts +785 -0
- package/src/hooks/index.ts +110 -0
- package/src/hooks/types.ts +10 -0
- package/src/hooks/useAsync.ts +65 -0
- package/src/hooks/useEventHandling.ts +444 -0
- package/src/hooks/useLifecycle.ts +399 -0
- package/src/hooks/usePerformance.ts +441 -0
- package/src/hooks/usePerformanceMonitor.ts +348 -0
- package/src/hooks/usePlatform.ts +62 -0
- package/src/hooks/useRequest.test.ts +11 -0
- package/src/hooks/useRequest.ts +135 -0
- package/src/hooks/useStateManagement.ts +300 -0
- package/src/hooks/useStyle.ts +537 -0
- package/src/hooks/useTheme.ts +347 -0
- package/src/hooks/useVirtualScroll.ts +331 -0
- package/src/index.ts +298 -0
- package/src/platform/index.ts +1188 -0
- package/src/providers/AppProvider.test.tsx +63 -0
- package/src/providers/AppProvider.tsx +155 -0
- package/src/providers/index.ts +1 -0
- package/src/theme/ThemeProvider.tsx +283 -0
- package/src/theme/ThemeProvider.types.ts +26 -0
- package/src/theme/animations.tsx +660 -0
- package/src/theme/defaults.ts +188 -0
- package/src/theme/design-system.ts +562 -0
- package/src/theme/design-tokens.ts +1136 -0
- package/src/theme/generated/dark-theme.scss +120 -0
- package/src/theme/generated/tokens.css +441 -0
- package/src/theme/generated/tokens.scss +320 -0
- package/src/theme/index.ts +120 -0
- package/src/theme/responsive.tsx +193 -0
- package/src/theme/styles/mixins.scss +612 -0
- package/src/theme/styles/variables.scss +295 -0
- package/src/theme/styles.ts +403 -0
- package/src/theme/tokens/colors.ts +256 -0
- package/src/theme/tokens/effects.ts +260 -0
- package/src/theme/tokens/index.ts +217 -0
- package/src/theme/tokens/spacing.ts +137 -0
- package/src/theme/tokens/typography.ts +186 -0
- package/src/theme/types.ts +188 -0
- package/src/theme/useThemeUtils.ts +313 -0
- package/src/theme/utils.ts +501 -0
- package/src/theme/variables.ts +583 -0
- package/src/types/accessibility.ts +51 -0
- package/src/types/button.ts +562 -0
- package/src/types/component-props.ts +317 -0
- package/src/types/env.d.ts +20 -0
- package/src/types/index.ts +427 -0
- package/src/types/modules.d.ts +40 -0
- package/src/types/standardized-components.ts +544 -0
- package/src/types/taro-adapter.d.ts +174 -0
- package/src/types/taro-components.d.ts +73 -0
- package/src/types/utils.ts +410 -0
- package/src/utils/__tests__/inputValidator.test.ts +338 -0
- package/src/utils/__tests__/responsiveUtils.test.ts +310 -0
- package/src/utils/__tests__/xssProtection.test.ts +268 -0
- package/src/utils/cache.ts +83 -0
- package/src/utils/createNamespace.ts +24 -0
- package/src/utils/environment.ts +95 -0
- package/src/utils/error-handler.ts +88 -0
- package/src/utils/errorLogger.ts +197 -0
- package/src/utils/formatUtils.ts +444 -0
- package/src/utils/index.ts +115 -0
- package/src/utils/inputValidator.ts +261 -0
- package/src/utils/network/http-client.test.ts +18 -0
- package/src/utils/network/http-client.ts +151 -0
- package/src/utils/performance/performance.ts +850 -0
- package/src/utils/responsiveUtils.ts +357 -0
- package/src/utils/rtl-support.ts +344 -0
- package/src/utils/security/api-security.ts +386 -0
- package/src/utils/security/xss-protection.ts +69 -0
- package/src/utils/securityHeaders.ts +314 -0
- package/src/utils/typeHelpers.ts +16 -0
- package/src/utils/types/dataProcessing.ts +543 -0
- package/src/utils/types/typeHelpers.ts +187 -0
- package/src/utils/xssProtection.ts +420 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taro-Uno UI 样式变量
|
|
3
|
+
* 定义全局样式变量和常量
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ==================== 颜色变量 ====================
|
|
7
|
+
|
|
8
|
+
// 主色调
|
|
9
|
+
$primary-color: #0ea5e9;
|
|
10
|
+
$secondary-color: #6b7280;
|
|
11
|
+
$success-color: #22c55e;
|
|
12
|
+
$warning-color: #f59e0b;
|
|
13
|
+
$error-color: #ef4444;
|
|
14
|
+
$info-color: #3b82f6;
|
|
15
|
+
|
|
16
|
+
// 文本颜色
|
|
17
|
+
$text-color: #111827;
|
|
18
|
+
$text-color-secondary: #6b7280;
|
|
19
|
+
$text-color-disabled: #9ca3af;
|
|
20
|
+
$text-color-inverse: #ffffff;
|
|
21
|
+
|
|
22
|
+
// 背景颜色
|
|
23
|
+
$background-color: #ffffff;
|
|
24
|
+
$background-card: #ffffff;
|
|
25
|
+
$background-input: #f9fafb;
|
|
26
|
+
$background-mask: rgba(0, 0, 0, 0.5);
|
|
27
|
+
|
|
28
|
+
// 边框颜色
|
|
29
|
+
$border-color: #e5e7eb;
|
|
30
|
+
$border-color-light: #f3f4f6;
|
|
31
|
+
$border-color-focus: #0ea5e9;
|
|
32
|
+
|
|
33
|
+
// 阴影颜色
|
|
34
|
+
$shadow-color: rgba(0, 0, 0, 0.1);
|
|
35
|
+
$shadow-color-light: rgba(0, 0, 0, 0.05);
|
|
36
|
+
|
|
37
|
+
// 特殊颜色
|
|
38
|
+
$brand-color: #0ea5e9;
|
|
39
|
+
$accent-color: #f59e0b;
|
|
40
|
+
$link-color: #0ea5e9;
|
|
41
|
+
$divider-color: #e5e7eb;
|
|
42
|
+
|
|
43
|
+
// ==================== 间距变量 ====================
|
|
44
|
+
|
|
45
|
+
// 基础间距
|
|
46
|
+
$spacing-xs: 4px;
|
|
47
|
+
$spacing-sm: 8px;
|
|
48
|
+
$spacing-md: 16px;
|
|
49
|
+
$spacing-lg: 24px;
|
|
50
|
+
$spacing-xl: 32px;
|
|
51
|
+
$spacing-xxl: 48px;
|
|
52
|
+
|
|
53
|
+
// 组件间距
|
|
54
|
+
$padding: $spacing-md;
|
|
55
|
+
$margin: $spacing-md;
|
|
56
|
+
$gap: $spacing-md;
|
|
57
|
+
|
|
58
|
+
// ==================== 字体变量 ====================
|
|
59
|
+
|
|
60
|
+
// 字体族
|
|
61
|
+
$font-family-sans:
|
|
62
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
|
|
63
|
+
'Helvetica Neue', sans-serif;
|
|
64
|
+
$font-family-serif: 'Georgia', 'Cambria', 'Times New Roman', 'Times', serif;
|
|
65
|
+
$font-family-mono: 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
|
|
66
|
+
$font-family-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', sans-serif;
|
|
67
|
+
|
|
68
|
+
// 字体大小
|
|
69
|
+
$font-size-xs: 20px;
|
|
70
|
+
$font-size-sm: 24px;
|
|
71
|
+
$font-size-base: 28px;
|
|
72
|
+
$font-size-lg: 32px;
|
|
73
|
+
$font-size-xl: 36px;
|
|
74
|
+
$font-size-2xl: 40px;
|
|
75
|
+
$font-size-3xl: 48px;
|
|
76
|
+
$font-size-4xl: 56px;
|
|
77
|
+
$font-size-5xl: 64px;
|
|
78
|
+
|
|
79
|
+
// 字体粗细
|
|
80
|
+
$font-weight-light: 300;
|
|
81
|
+
$font-weight-normal: 400;
|
|
82
|
+
$font-weight-medium: 500;
|
|
83
|
+
$font-weight-semibold: 600;
|
|
84
|
+
$font-weight-bold: 700;
|
|
85
|
+
|
|
86
|
+
// 行高
|
|
87
|
+
$line-height-tight: 1.25;
|
|
88
|
+
$line-height-normal: 1.5;
|
|
89
|
+
$line-height-relaxed: 1.75;
|
|
90
|
+
$line-height-loose: 2;
|
|
91
|
+
|
|
92
|
+
// 字母间距
|
|
93
|
+
$letter-spacing-tight: -0.025em;
|
|
94
|
+
$letter-spacing-normal: 0;
|
|
95
|
+
$letter-spacing-wide: 0.025em;
|
|
96
|
+
|
|
97
|
+
// ==================== 边框圆角变量 ====================
|
|
98
|
+
|
|
99
|
+
$border-radius-none: 0;
|
|
100
|
+
$border-radius-sm: 4px;
|
|
101
|
+
$border-radius-md: 8px;
|
|
102
|
+
$border-radius-lg: 12px;
|
|
103
|
+
$border-radius-xl: 16px;
|
|
104
|
+
$border-radius-full: 9999px;
|
|
105
|
+
$border-radius-circle: 50%;
|
|
106
|
+
|
|
107
|
+
// ==================== 阴影变量 ====================
|
|
108
|
+
|
|
109
|
+
$shadow-none: none;
|
|
110
|
+
$shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
111
|
+
$shadow-md:
|
|
112
|
+
0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
|
113
|
+
0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
114
|
+
$shadow-lg:
|
|
115
|
+
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
|
116
|
+
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
117
|
+
$shadow-xl:
|
|
118
|
+
0 20px 25px -5px rgba(0, 0, 0, 0.1),
|
|
119
|
+
0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
120
|
+
$shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
121
|
+
$shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
|
|
122
|
+
|
|
123
|
+
// ==================== 动画变量 ====================
|
|
124
|
+
|
|
125
|
+
// 动画时长
|
|
126
|
+
$animation-duration-fast: 150ms;
|
|
127
|
+
$animation-duration-normal: 300ms;
|
|
128
|
+
$animation-duration-slow: 500ms;
|
|
129
|
+
|
|
130
|
+
// 动画缓动函数
|
|
131
|
+
$animation-easing-linear: linear;
|
|
132
|
+
$animation-easing-ease: ease;
|
|
133
|
+
$animation-easing-ease-in: ease-in;
|
|
134
|
+
$animation-easing-ease-out: ease-out;
|
|
135
|
+
$animation-easing-ease-in-out: ease-in-out;
|
|
136
|
+
|
|
137
|
+
// ==================== 断点变量 ====================
|
|
138
|
+
|
|
139
|
+
$breakpoint-xs: 0;
|
|
140
|
+
$breakpoint-sm: 640px;
|
|
141
|
+
$breakpoint-md: 768px;
|
|
142
|
+
$breakpoint-lg: 1024px;
|
|
143
|
+
$breakpoint-xl: 1280px;
|
|
144
|
+
$breakpoint-xxl: 1536px;
|
|
145
|
+
|
|
146
|
+
// ==================== 组件变量 ====================
|
|
147
|
+
|
|
148
|
+
// 按钮变量
|
|
149
|
+
$button-height-xs: 56px;
|
|
150
|
+
$button-height-sm: 64px;
|
|
151
|
+
$button-height-md: 72px;
|
|
152
|
+
$button-height-lg: 80px;
|
|
153
|
+
$button-height-xl: 88px;
|
|
154
|
+
|
|
155
|
+
$button-font-size-xs: 20px;
|
|
156
|
+
$button-font-size-sm: 24px;
|
|
157
|
+
$button-font-size-md: 28px;
|
|
158
|
+
$button-font-size-lg: 32px;
|
|
159
|
+
$button-font-size-xl: 36px;
|
|
160
|
+
|
|
161
|
+
$button-padding-xs: 8px 16px;
|
|
162
|
+
$button-padding-sm: 12px 20px;
|
|
163
|
+
$button-padding-md: 16px 24px;
|
|
164
|
+
$button-padding-lg: 20px 32px;
|
|
165
|
+
$button-padding-xl: 24px 40px;
|
|
166
|
+
|
|
167
|
+
$button-border-radius-xs: 4px;
|
|
168
|
+
$button-border-radius-sm: 6px;
|
|
169
|
+
$button-border-radius-md: 8px;
|
|
170
|
+
$button-border-radius-lg: 10px;
|
|
171
|
+
$button-border-radius-xl: 12px;
|
|
172
|
+
|
|
173
|
+
// 输入框变量
|
|
174
|
+
$input-height: 72px;
|
|
175
|
+
$input-padding: 16px;
|
|
176
|
+
$input-border-width: 1px;
|
|
177
|
+
$input-border-radius: 8px;
|
|
178
|
+
$input-font-size: 28px;
|
|
179
|
+
|
|
180
|
+
// 卡片变量
|
|
181
|
+
$card-padding: 24px;
|
|
182
|
+
$card-border-radius: 12px;
|
|
183
|
+
$card-shadow: $shadow-md;
|
|
184
|
+
$card-background: $background-card;
|
|
185
|
+
|
|
186
|
+
// ==================== Z-index 变量 ====================
|
|
187
|
+
|
|
188
|
+
$z-index-dropdown: 1000;
|
|
189
|
+
$z-index-sticky: 1020;
|
|
190
|
+
$z-index-fixed: 1030;
|
|
191
|
+
$z-index-modal: 1040;
|
|
192
|
+
$z-index-popover: 1050;
|
|
193
|
+
$z-index-tooltip: 1060;
|
|
194
|
+
|
|
195
|
+
// ==================== 过渡变量 ====================
|
|
196
|
+
|
|
197
|
+
$transition-base: all 300ms ease-in-out;
|
|
198
|
+
$transition-fast: all 150ms ease-in-out;
|
|
199
|
+
$transition-slow: all 500ms ease-in-out;
|
|
200
|
+
|
|
201
|
+
// ==================== CSS 自定义属性 ====================
|
|
202
|
+
|
|
203
|
+
:root {
|
|
204
|
+
// 颜色
|
|
205
|
+
--primary-color: #{$primary-color};
|
|
206
|
+
--secondary-color: #{$secondary-color};
|
|
207
|
+
--success-color: #{$success-color};
|
|
208
|
+
--warning-color: #{$warning-color};
|
|
209
|
+
--error-color: #{$error-color};
|
|
210
|
+
--info-color: #{$info-color};
|
|
211
|
+
|
|
212
|
+
--text-color: #{$text-color};
|
|
213
|
+
--text-color-secondary: #{$text-color-secondary};
|
|
214
|
+
--text-color-disabled: #{$text-color-disabled};
|
|
215
|
+
--text-color-inverse: #{$text-color-inverse};
|
|
216
|
+
|
|
217
|
+
--background-color: #{$background-color};
|
|
218
|
+
--background-card: #{$background-card};
|
|
219
|
+
--background-input: #{$background-input};
|
|
220
|
+
--background-mask: #{$background-mask};
|
|
221
|
+
|
|
222
|
+
--border-color: #{$border-color};
|
|
223
|
+
--border-color-light: #{$border-color-light};
|
|
224
|
+
--border-color-focus: #{$border-color-focus};
|
|
225
|
+
|
|
226
|
+
--shadow-color: #{$shadow-color};
|
|
227
|
+
--shadow-color-light: #{$shadow-color-light};
|
|
228
|
+
|
|
229
|
+
--brand-color: #{$brand-color};
|
|
230
|
+
--accent-color: #{$accent-color};
|
|
231
|
+
--link-color: #{$link-color};
|
|
232
|
+
--divider-color: #{$divider-color};
|
|
233
|
+
|
|
234
|
+
// 间距
|
|
235
|
+
--spacing-xs: #{$spacing-xs};
|
|
236
|
+
--spacing-sm: #{$spacing-sm};
|
|
237
|
+
--spacing-md: #{$spacing-md};
|
|
238
|
+
--spacing-lg: #{$spacing-lg};
|
|
239
|
+
--spacing-xl: #{$spacing-xl};
|
|
240
|
+
--spacing-xxl: #{$spacing-xxl};
|
|
241
|
+
|
|
242
|
+
// 字体
|
|
243
|
+
--font-size-xs: #{$font-size-xs};
|
|
244
|
+
--font-size-sm: #{$font-size-sm};
|
|
245
|
+
--font-size-base: #{$font-size-base};
|
|
246
|
+
--font-size-lg: #{$font-size-lg};
|
|
247
|
+
--font-size-xl: #{$font-size-xl};
|
|
248
|
+
--font-size-2xl: #{$font-size-2xl};
|
|
249
|
+
--font-size-3xl: #{$font-size-3xl};
|
|
250
|
+
--font-size-4xl: #{$font-size-4xl};
|
|
251
|
+
--font-size-5xl: #{$font-size-5xl};
|
|
252
|
+
|
|
253
|
+
// 边框圆角
|
|
254
|
+
--border-radius-sm: #{$border-radius-sm};
|
|
255
|
+
--border-radius-md: #{$border-radius-md};
|
|
256
|
+
--border-radius-lg: #{$border-radius-lg};
|
|
257
|
+
--border-radius-xl: #{$border-radius-xl};
|
|
258
|
+
|
|
259
|
+
// 阴影
|
|
260
|
+
--shadow-sm: #{$shadow-sm};
|
|
261
|
+
--shadow-md: #{$shadow-md};
|
|
262
|
+
--shadow-lg: #{$shadow-lg};
|
|
263
|
+
--shadow-xl: #{$shadow-xl};
|
|
264
|
+
|
|
265
|
+
// 动画
|
|
266
|
+
--animation-duration-fast: #{$animation-duration-fast};
|
|
267
|
+
--animation-duration-normal: #{$animation-duration-normal};
|
|
268
|
+
--animation-duration-slow: #{$animation-duration-slow};
|
|
269
|
+
|
|
270
|
+
// 过渡
|
|
271
|
+
--transition-base: #{$transition-base};
|
|
272
|
+
--transition-fast: #{$transition-fast};
|
|
273
|
+
--transition-slow: #{$transition-slow};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 暗色主题
|
|
277
|
+
[data-theme='dark'] {
|
|
278
|
+
--text-color: #f9fafb;
|
|
279
|
+
--text-color-secondary: #d1d5db;
|
|
280
|
+
--text-color-disabled: #6b7280;
|
|
281
|
+
--text-color-inverse: #111827;
|
|
282
|
+
|
|
283
|
+
--background-color: #111827;
|
|
284
|
+
--background-card: #1f2937;
|
|
285
|
+
--background-input: #374151;
|
|
286
|
+
--background-mask: rgba(0, 0, 0, 0.8);
|
|
287
|
+
|
|
288
|
+
--border-color: #374151;
|
|
289
|
+
--border-color-light: #4b5563;
|
|
290
|
+
|
|
291
|
+
--shadow-color: rgba(0, 0, 0, 0.3);
|
|
292
|
+
--shadow-color-light: rgba(0, 0, 0, 0.1);
|
|
293
|
+
|
|
294
|
+
--divider-color: #374151;
|
|
295
|
+
}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { ThemeConfig } from './types';
|
|
2
|
+
|
|
3
|
+
// 样式工具类型定义
|
|
4
|
+
export interface StyleUtils {
|
|
5
|
+
// 间距工具
|
|
6
|
+
spacing: {
|
|
7
|
+
px: (value: number) => string;
|
|
8
|
+
rem: (value: number) => string;
|
|
9
|
+
em: (value: number) => string;
|
|
10
|
+
get: (key: keyof ThemeConfig['spacing']) => string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// 颜色工具
|
|
14
|
+
colors: {
|
|
15
|
+
get: (key: keyof ThemeConfig['colors']) => string;
|
|
16
|
+
opacity: (color: string, opacity: number) => string;
|
|
17
|
+
lighten: (color: string, amount: number) => string;
|
|
18
|
+
darken: (color: string, amount: number) => string;
|
|
19
|
+
mix: (color1: string, color2: string, weight: number) => string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 字体工具
|
|
23
|
+
typography: {
|
|
24
|
+
get: (key: keyof ThemeConfig['typography']) => string;
|
|
25
|
+
responsive: (key: keyof ThemeConfig['typography']['fontSize']) => string;
|
|
26
|
+
family: (type: keyof ThemeConfig['typography']['fontFamily']) => string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// 布局工具
|
|
30
|
+
layout: {
|
|
31
|
+
flex: (direction?: 'row' | 'column', align?: string, justify?: string) => string;
|
|
32
|
+
grid: (columns: number, gap?: number) => string;
|
|
33
|
+
position: (type: 'relative' | 'absolute' | 'fixed' | 'sticky', top?: number, left?: number) => string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// 响应式工具
|
|
37
|
+
responsive: {
|
|
38
|
+
mobile: (styles: string) => string;
|
|
39
|
+
tablet: (styles: string) => string;
|
|
40
|
+
desktop: (styles: string) => string;
|
|
41
|
+
custom: (breakpoint: number, styles: string) => string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// 动画工具
|
|
45
|
+
animation: {
|
|
46
|
+
get: (key: keyof ThemeConfig['animation']['keyframes']) => string;
|
|
47
|
+
transition: (properties: string[], duration?: string, easing?: string) => string;
|
|
48
|
+
transform: (transforms: string[]) => string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// 阴影工具
|
|
52
|
+
shadow: {
|
|
53
|
+
get: (key: keyof ThemeConfig['shadow']) => string;
|
|
54
|
+
custom: (x: number, y: number, blur: number, color: string) => string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// 边框工具
|
|
58
|
+
border: {
|
|
59
|
+
radius: (key: keyof ThemeConfig['borderRadius']) => string;
|
|
60
|
+
width: (width: number, style?: string, color?: string) => string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Z-index工具
|
|
64
|
+
zIndex: {
|
|
65
|
+
get: (key: keyof typeof zIndexLevels) => string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Z-index层级定义
|
|
70
|
+
const zIndexLevels = {
|
|
71
|
+
modal: 1000,
|
|
72
|
+
drawer: 900,
|
|
73
|
+
popover: 800,
|
|
74
|
+
tooltip: 700,
|
|
75
|
+
dropdown: 600,
|
|
76
|
+
sticky: 500,
|
|
77
|
+
header: 400,
|
|
78
|
+
footer: 300,
|
|
79
|
+
default: 100,
|
|
80
|
+
below: -1,
|
|
81
|
+
} as const;
|
|
82
|
+
|
|
83
|
+
// 颜色工具函数
|
|
84
|
+
const colorUtils = {
|
|
85
|
+
// 将颜色转换为RGB
|
|
86
|
+
hexToRgb: (hex: string): { r: number; g: number; b: number } | null => {
|
|
87
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
88
|
+
return result
|
|
89
|
+
? {
|
|
90
|
+
r: parseInt(result[1] || '0', 16),
|
|
91
|
+
g: parseInt(result[2] || '0', 16),
|
|
92
|
+
b: parseInt(result[3] || '0', 16),
|
|
93
|
+
}
|
|
94
|
+
: null;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// 将RGB转换为HEX
|
|
98
|
+
rgbToHex: (r: number, g: number, b: number): string => {
|
|
99
|
+
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// 颜色透明度处理
|
|
103
|
+
addOpacity: (hex: string, opacity: number): string => {
|
|
104
|
+
const rgb = colorUtils.hexToRgb(hex);
|
|
105
|
+
if (!rgb) return hex;
|
|
106
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
// 颜色变亮
|
|
110
|
+
lighten: (hex: string, amount: number): string => {
|
|
111
|
+
const rgb = colorUtils.hexToRgb(hex);
|
|
112
|
+
if (!rgb) return hex;
|
|
113
|
+
|
|
114
|
+
const r = Math.min(255, Math.floor(rgb.r + (255 - rgb.r) * amount));
|
|
115
|
+
const g = Math.min(255, Math.floor(rgb.g + (255 - rgb.g) * amount));
|
|
116
|
+
const b = Math.min(255, Math.floor(rgb.b + (255 - rgb.b) * amount));
|
|
117
|
+
|
|
118
|
+
return colorUtils.rgbToHex(r, g, b);
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// 颜色变暗
|
|
122
|
+
darken: (hex: string, amount: number): string => {
|
|
123
|
+
const rgb = colorUtils.hexToRgb(hex);
|
|
124
|
+
if (!rgb) return hex;
|
|
125
|
+
|
|
126
|
+
const r = Math.max(0, Math.floor(rgb.r * (1 - amount)));
|
|
127
|
+
const g = Math.max(0, Math.floor(rgb.g * (1 - amount)));
|
|
128
|
+
const b = Math.max(0, Math.floor(rgb.b * (1 - amount)));
|
|
129
|
+
|
|
130
|
+
return colorUtils.rgbToHex(r, g, b);
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// 颜色混合
|
|
134
|
+
mix: (color1: string, color2: string, weight: number): string => {
|
|
135
|
+
const rgb1 = colorUtils.hexToRgb(color1);
|
|
136
|
+
const rgb2 = colorUtils.hexToRgb(color2);
|
|
137
|
+
|
|
138
|
+
if (!rgb1 || !rgb2) return color1;
|
|
139
|
+
|
|
140
|
+
const w = weight / 100;
|
|
141
|
+
const r = Math.round(rgb1.r * (1 - w) + rgb2.r * w);
|
|
142
|
+
const g = Math.round(rgb1.g * (1 - w) + rgb2.g * w);
|
|
143
|
+
const b = Math.round(rgb1.b * (1 - w) + rgb2.b * w);
|
|
144
|
+
|
|
145
|
+
return colorUtils.rgbToHex(r, g, b);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// 创建样式工具实例
|
|
150
|
+
export const createStyleUtils = (theme: ThemeConfig): StyleUtils => {
|
|
151
|
+
const spacing = {
|
|
152
|
+
px: (value: number): string => `${value}px`,
|
|
153
|
+
rem: (value: number): string => `${value / 16}rem`,
|
|
154
|
+
em: (value: number): string => `${value}em`,
|
|
155
|
+
get: (key: keyof ThemeConfig['spacing']): string => {
|
|
156
|
+
const value = (theme.spacing as any)[key];
|
|
157
|
+
if (typeof value === 'number') return `${value}px`;
|
|
158
|
+
if (key === 'breakpoints' && typeof value === 'object') {
|
|
159
|
+
return JSON.stringify(value);
|
|
160
|
+
}
|
|
161
|
+
return String(value);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const colors = {
|
|
166
|
+
get: (key: keyof ThemeConfig['colors']): string => theme.colors[key],
|
|
167
|
+
opacity: (color: string, opacity: number): string => colorUtils.addOpacity(color, opacity),
|
|
168
|
+
lighten: (color: string, amount: number): string => colorUtils.lighten(color, amount),
|
|
169
|
+
darken: (color: string, amount: number): string => colorUtils.darken(color, amount),
|
|
170
|
+
mix: (color1: string, color2: string, weight: number): string => colorUtils.mix(color1, color2, weight),
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const typography = {
|
|
174
|
+
get: (key: keyof ThemeConfig['typography']): string => {
|
|
175
|
+
const value = (theme.typography as any)[key];
|
|
176
|
+
if (typeof value === 'number') return `${value}px`;
|
|
177
|
+
if (Array.isArray(value)) return value.join(', ');
|
|
178
|
+
return String(value);
|
|
179
|
+
},
|
|
180
|
+
responsive: (key: keyof ThemeConfig['typography']['fontSize']): string => {
|
|
181
|
+
const fontSize = theme.typography.fontSize[key];
|
|
182
|
+
const baseSize = theme.typography.fontSize.base;
|
|
183
|
+
|
|
184
|
+
return `
|
|
185
|
+
font-size: ${fontSize}px;
|
|
186
|
+
@media (max-width: ${theme.spacing.breakpoints.md}px) {
|
|
187
|
+
font-size: ${Math.max(fontSize - 4, baseSize)}px;
|
|
188
|
+
}
|
|
189
|
+
@media (max-width: ${theme.spacing.breakpoints.sm}px) {
|
|
190
|
+
font-size: ${Math.max(fontSize - 8, baseSize - 4)}px;
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
},
|
|
194
|
+
family: (type: keyof ThemeConfig['typography']['fontFamily']): string => {
|
|
195
|
+
return theme.typography.fontFamily[type].join(', ');
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const layout = {
|
|
200
|
+
flex: (direction: 'row' | 'column' = 'row', align?: string, justify?: string): string => {
|
|
201
|
+
const styles = ['display: flex'];
|
|
202
|
+
if (direction === 'column') styles.push('flex-direction: column');
|
|
203
|
+
if (align) styles.push(`align-items: ${align}`);
|
|
204
|
+
if (justify) styles.push(`justify-content: ${justify}`);
|
|
205
|
+
return styles.join('; ');
|
|
206
|
+
},
|
|
207
|
+
grid: (columns: number, gap: number = theme.spacing.gap): string => {
|
|
208
|
+
return `
|
|
209
|
+
display: grid;
|
|
210
|
+
grid-template-columns: repeat(${columns}, 1fr);
|
|
211
|
+
gap: ${gap}px;
|
|
212
|
+
`;
|
|
213
|
+
},
|
|
214
|
+
position: (type: 'relative' | 'absolute' | 'fixed' | 'sticky', top?: number, left?: number): string => {
|
|
215
|
+
const styles = [`position: ${type}`];
|
|
216
|
+
if (top !== undefined) styles.push(`top: ${top}px`);
|
|
217
|
+
if (left !== undefined) styles.push(`left: ${left}px`);
|
|
218
|
+
return styles.join('; ');
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const responsive = {
|
|
223
|
+
mobile: (styles: string): string => {
|
|
224
|
+
return `@media (max-width: ${theme.spacing.breakpoints.sm}px) { ${styles} }`;
|
|
225
|
+
},
|
|
226
|
+
tablet: (styles: string): string => {
|
|
227
|
+
return `@media (min-width: ${theme.spacing.breakpoints.sm}px) and (max-width: ${theme.spacing.breakpoints.lg}px) { ${styles} }`;
|
|
228
|
+
},
|
|
229
|
+
desktop: (styles: string): string => {
|
|
230
|
+
return `@media (min-width: ${theme.spacing.breakpoints.lg}px) { ${styles} }`;
|
|
231
|
+
},
|
|
232
|
+
custom: (breakpoint: number, styles: string): string => {
|
|
233
|
+
return `@media (max-width: ${breakpoint}px) { ${styles} }`;
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const animation = {
|
|
238
|
+
get: (key: keyof ThemeConfig['animation']['keyframes']): string => {
|
|
239
|
+
return theme.animation.keyframes[key];
|
|
240
|
+
},
|
|
241
|
+
transition: (
|
|
242
|
+
properties: string[],
|
|
243
|
+
duration: string = theme.animation.duration.normal,
|
|
244
|
+
easing: string = theme.animation.easing.ease,
|
|
245
|
+
): string => {
|
|
246
|
+
return `transition: ${properties.join(', ')} ${duration} ${easing}`;
|
|
247
|
+
},
|
|
248
|
+
transform: (transforms: string[]): string => {
|
|
249
|
+
return `transform: ${transforms.join(' ')}`;
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const shadow = {
|
|
254
|
+
get: (key: keyof ThemeConfig['shadow']): string => {
|
|
255
|
+
return theme.shadow[key];
|
|
256
|
+
},
|
|
257
|
+
custom: (x: number, y: number, blur: number, color: string): string => {
|
|
258
|
+
return `${x}px ${y}px ${blur}px ${color}`;
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const border = {
|
|
263
|
+
radius: (key: keyof ThemeConfig['borderRadius']): string => {
|
|
264
|
+
const value = theme.borderRadius[key];
|
|
265
|
+
return typeof value === 'number' ? `${value}px` : String(value);
|
|
266
|
+
},
|
|
267
|
+
width: (width: number, style: string = 'solid', color: string = theme.colors.border): string => {
|
|
268
|
+
return `${width}px ${style} ${color}`;
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const zIndex = {
|
|
273
|
+
get: (key: keyof typeof zIndexLevels): string => {
|
|
274
|
+
return String(zIndexLevels[key]);
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
spacing,
|
|
280
|
+
colors,
|
|
281
|
+
typography,
|
|
282
|
+
layout,
|
|
283
|
+
responsive,
|
|
284
|
+
animation,
|
|
285
|
+
shadow,
|
|
286
|
+
border,
|
|
287
|
+
zIndex,
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// 样式生成器 - 生成基础的CSS变量
|
|
292
|
+
export const generateStyles = (theme: ThemeConfig): string => {
|
|
293
|
+
const utils = createStyleUtils(theme);
|
|
294
|
+
|
|
295
|
+
return `
|
|
296
|
+
/* 主题变量 */
|
|
297
|
+
:root {
|
|
298
|
+
--primary-color: ${theme.colors.primary};
|
|
299
|
+
--secondary-color: ${theme.colors.secondary};
|
|
300
|
+
--success-color: ${theme.colors.success};
|
|
301
|
+
--warning-color: ${theme.colors.warning};
|
|
302
|
+
--error-color: ${theme.colors.error};
|
|
303
|
+
--info-color: ${theme.colors.info};
|
|
304
|
+
--text-color: ${theme.colors.text};
|
|
305
|
+
--text-color-secondary: ${theme.colors.textSecondary};
|
|
306
|
+
--text-color-disabled: ${theme.colors.textDisabled};
|
|
307
|
+
--text-color-inverse: ${theme.colors.textInverse};
|
|
308
|
+
--background-color: ${theme.colors.background};
|
|
309
|
+
--background-card: ${theme.colors.backgroundCard};
|
|
310
|
+
--background-input: ${theme.colors.backgroundInput};
|
|
311
|
+
--background-mask: ${theme.colors.backgroundMask};
|
|
312
|
+
--border-color: ${theme.colors.border};
|
|
313
|
+
--border-light: ${theme.colors.borderLight};
|
|
314
|
+
--border-focus: ${theme.colors.borderFocus};
|
|
315
|
+
--shadow-color: ${theme.colors.shadow};
|
|
316
|
+
--shadow-light: ${theme.colors.shadowLight};
|
|
317
|
+
--brand-color: ${theme.colors.brand};
|
|
318
|
+
--accent-color: ${theme.colors.accent};
|
|
319
|
+
--link-color: ${theme.colors.link};
|
|
320
|
+
--divider-color: ${theme.colors.divider};
|
|
321
|
+
|
|
322
|
+
/* 间距变量 */
|
|
323
|
+
--spacing-xs: ${utils.spacing.get('xs')};
|
|
324
|
+
--spacing-sm: ${utils.spacing.get('sm')};
|
|
325
|
+
--spacing-md: ${utils.spacing.get('md')};
|
|
326
|
+
--spacing-lg: ${utils.spacing.get('lg')};
|
|
327
|
+
--spacing-xl: ${utils.spacing.get('xl')};
|
|
328
|
+
--spacing-xxl: ${utils.spacing.get('xxl')};
|
|
329
|
+
|
|
330
|
+
/* 字体变量 */
|
|
331
|
+
--font-size-xs: ${theme.typography.fontSize.xs}px;
|
|
332
|
+
--font-size-sm: ${theme.typography.fontSize.sm}px;
|
|
333
|
+
--font-size-base: ${theme.typography.fontSize.base}px;
|
|
334
|
+
--font-size-lg: ${theme.typography.fontSize.lg}px;
|
|
335
|
+
--font-size-xl: ${theme.typography.fontSize.xl}px;
|
|
336
|
+
--font-size-2xl: ${theme.typography.fontSize['2xl']}px;
|
|
337
|
+
--font-size-3xl: ${theme.typography.fontSize['3xl']}px;
|
|
338
|
+
--font-size-4xl: ${theme.typography.fontSize['4xl']}px;
|
|
339
|
+
--font-size-5xl: ${theme.typography.fontSize['5xl']}px;
|
|
340
|
+
|
|
341
|
+
/* 圆角变量 */
|
|
342
|
+
--radius-none: ${utils.border.radius('none')};
|
|
343
|
+
--radius-sm: ${utils.border.radius('sm')};
|
|
344
|
+
--radius-md: ${utils.border.radius('md')};
|
|
345
|
+
--radius-lg: ${utils.border.radius('lg')};
|
|
346
|
+
--radius-xl: ${utils.border.radius('xl')};
|
|
347
|
+
--radius-full: ${utils.border.radius('full')};
|
|
348
|
+
|
|
349
|
+
/* 阴影变量 */
|
|
350
|
+
--shadow-none: ${utils.shadow.get('none')};
|
|
351
|
+
--shadow-sm: ${utils.shadow.get('sm')};
|
|
352
|
+
--shadow-md: ${utils.shadow.get('md')};
|
|
353
|
+
--shadow-lg: ${utils.shadow.get('lg')};
|
|
354
|
+
--shadow-xl: ${utils.shadow.get('xl')};
|
|
355
|
+
--shadow-2xl: ${utils.shadow.get('2xl')};
|
|
356
|
+
|
|
357
|
+
/* 动画变量 */
|
|
358
|
+
--duration-fast: ${theme.animation.duration.fast};
|
|
359
|
+
--duration-normal: ${theme.animation.duration.normal};
|
|
360
|
+
--duration-slow: ${theme.animation.duration.slow};
|
|
361
|
+
|
|
362
|
+
--easing-linear: ${theme.animation.easing.linear};
|
|
363
|
+
--easing-ease: ${theme.animation.easing.ease};
|
|
364
|
+
--easing-ease-in: ${theme.animation.easing.easeIn};
|
|
365
|
+
--easing-ease-out: ${theme.animation.easing.easeOut};
|
|
366
|
+
--easing-ease-in-out: ${theme.animation.easing.easeInOut};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* 暗色主题 */
|
|
370
|
+
[data-theme="dark"] {
|
|
371
|
+
--text-color: ${theme.colors.text};
|
|
372
|
+
--text-color-secondary: ${theme.colors.textSecondary};
|
|
373
|
+
--text-color-disabled: ${theme.colors.textDisabled};
|
|
374
|
+
--text-color-inverse: ${theme.colors.textInverse};
|
|
375
|
+
--background-color: ${theme.colors.background};
|
|
376
|
+
--background-card: ${theme.colors.backgroundCard};
|
|
377
|
+
--background-input: ${theme.colors.backgroundInput};
|
|
378
|
+
--background-mask: ${theme.colors.backgroundMask};
|
|
379
|
+
--border-color: ${theme.colors.border};
|
|
380
|
+
--border-light: ${theme.colors.borderLight};
|
|
381
|
+
--shadow-color: ${theme.colors.shadow};
|
|
382
|
+
--shadow-light: ${theme.colors.shadowLight};
|
|
383
|
+
--divider-color: ${theme.colors.divider};
|
|
384
|
+
}
|
|
385
|
+
`;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// 创建样式函数(用于组件样式)
|
|
389
|
+
export const createStyles = (styles: Record<string, any>) => {
|
|
390
|
+
return styles;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// 默认样式工具导出(延迟初始化,避免循环导入)
|
|
394
|
+
let _defaultStyleUtils: StyleUtils | null = null;
|
|
395
|
+
export const styleUtils = (theme?: ThemeConfig): StyleUtils => {
|
|
396
|
+
if (!theme && !_defaultStyleUtils) {
|
|
397
|
+
const { defaultTheme } = require('./defaults');
|
|
398
|
+
_defaultStyleUtils = createStyleUtils(defaultTheme);
|
|
399
|
+
}
|
|
400
|
+
return theme ? createStyleUtils(theme) : (_defaultStyleUtils!);
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export default createStyleUtils;
|