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,117 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export const LoadingStyles: Record<string, CSSProperties | Record<string, CSSProperties>> = {
|
|
4
|
+
base: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
gap: 8,
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
size: {
|
|
13
|
+
xs: { fontSize: '12px' },
|
|
14
|
+
sm: { fontSize: '14px' },
|
|
15
|
+
default: { fontSize: '16px' },
|
|
16
|
+
lg: { fontSize: '18px' },
|
|
17
|
+
xl: { fontSize: '20px' },
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
spinner: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
width: 32,
|
|
23
|
+
height: 32,
|
|
24
|
+
border: '4px solid #e5e7eb',
|
|
25
|
+
borderTop: '4px solid #3b82f6',
|
|
26
|
+
borderRadius: '50%',
|
|
27
|
+
animation: 'spin 1s linear infinite',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
spinnerSize: {
|
|
31
|
+
xs: { width: 16, height: 16, borderWidth: 2 },
|
|
32
|
+
sm: { width: 24, height: 24, borderWidth: 3 },
|
|
33
|
+
default: { width: 32, height: 32, borderWidth: 4 },
|
|
34
|
+
lg: { width: 48, height: 48, borderWidth: 4 },
|
|
35
|
+
xl: { width: 64, height: 64, borderWidth: 6 },
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
spinnerInner: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
top: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
right: 0,
|
|
43
|
+
bottom: 0,
|
|
44
|
+
borderRadius: '50%',
|
|
45
|
+
animation: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
dots: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
gap: 4,
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
dot: {
|
|
54
|
+
width: 8,
|
|
55
|
+
height: 8,
|
|
56
|
+
backgroundColor: '#3b82f6',
|
|
57
|
+
borderRadius: '50%',
|
|
58
|
+
animation: 'bounce 1.5s ease-in-out infinite',
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
dotSize: {
|
|
62
|
+
xs: { width: 4, height: 4 },
|
|
63
|
+
sm: { width: 6, height: 6 },
|
|
64
|
+
default: { width: 8, height: 8 },
|
|
65
|
+
lg: { width: 12, height: 12 },
|
|
66
|
+
xl: { width: 16, height: 16 },
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
pulseContainer: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
pulse: {
|
|
76
|
+
width: 32,
|
|
77
|
+
height: 32,
|
|
78
|
+
backgroundColor: '#3b82f6',
|
|
79
|
+
borderRadius: '50%',
|
|
80
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
pulseSize: {
|
|
84
|
+
xs: { width: 16, height: 16 },
|
|
85
|
+
sm: { width: 24, height: 24 },
|
|
86
|
+
default: { width: 32, height: 32 },
|
|
87
|
+
lg: { width: 48, height: 48 },
|
|
88
|
+
xl: { width: 64, height: 64 },
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
bars: {
|
|
92
|
+
display: 'flex',
|
|
93
|
+
gap: 4,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
bar: {
|
|
97
|
+
width: 4,
|
|
98
|
+
height: 32,
|
|
99
|
+
backgroundColor: '#3b82f6',
|
|
100
|
+
borderRadius: 2,
|
|
101
|
+
animation: 'pulse 1.5s ease-in-out infinite',
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
barSize: {
|
|
105
|
+
xs: { width: 2, height: 16 },
|
|
106
|
+
sm: { width: 4, height: 24 },
|
|
107
|
+
default: { width: 4, height: 32 },
|
|
108
|
+
lg: { width: 8, height: 48 },
|
|
109
|
+
xl: { width: 12, height: 64 },
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
text: {
|
|
113
|
+
fontSize: 14,
|
|
114
|
+
color: '#6b7280',
|
|
115
|
+
marginTop: 8,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading Component Test
|
|
3
|
+
* 测试加载指示器组件的各种功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
7
|
+
import { render, screen, fireEvent, act } from '@testing-library/react'
|
|
8
|
+
import { Loading } from './Loading'
|
|
9
|
+
import { createTestProps, renderComponent, testAssertions } from '@/utils/test-utils'
|
|
10
|
+
|
|
11
|
+
describe('Loading Component', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
vi.clearAllMocks()
|
|
14
|
+
vi.useFakeTimers()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.clearAllMocks()
|
|
19
|
+
vi.useRealTimers()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe('Rendering', () => {
|
|
23
|
+
it('should render loading with default props', () => {
|
|
24
|
+
const props = createTestProps({})
|
|
25
|
+
const { container } = renderComponent(Loading, props)
|
|
26
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should render loading with custom className', () => {
|
|
30
|
+
const props = createTestProps({
|
|
31
|
+
className: 'custom-loading'
|
|
32
|
+
})
|
|
33
|
+
const { container } = renderComponent(Loading, props)
|
|
34
|
+
expect(container.firstChild).toHaveClass('custom-loading')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should render loading with custom style', () => {
|
|
38
|
+
const props = createTestProps({
|
|
39
|
+
style: { backgroundColor: 'red' }
|
|
40
|
+
})
|
|
41
|
+
const { container } = renderComponent(Loading, props)
|
|
42
|
+
expect(container.firstChild).toHaveStyle('background-color: red')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should not render initially when delay > 0', () => {
|
|
46
|
+
const props = createTestProps({
|
|
47
|
+
delay: 1000
|
|
48
|
+
})
|
|
49
|
+
const { container } = renderComponent(Loading, props)
|
|
50
|
+
expect(container.firstChild).toBeNull()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should render after delay when delay > 0', () => {
|
|
54
|
+
const props = createTestProps({
|
|
55
|
+
delay: 1000
|
|
56
|
+
})
|
|
57
|
+
const { container } = renderComponent(Loading, props)
|
|
58
|
+
|
|
59
|
+
expect(container.firstChild).toBeNull()
|
|
60
|
+
|
|
61
|
+
act(() => {
|
|
62
|
+
vi.advanceTimersByTime(1000)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('Types', () => {
|
|
70
|
+
it('should render spinner type by default', () => {
|
|
71
|
+
const props = createTestProps({})
|
|
72
|
+
const { container } = renderComponent(Loading, props)
|
|
73
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should render spinner type explicitly', () => {
|
|
77
|
+
const props = createTestProps({
|
|
78
|
+
type: 'spinner'
|
|
79
|
+
})
|
|
80
|
+
const { container } = renderComponent(Loading, props)
|
|
81
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should render dots type', () => {
|
|
85
|
+
const props = createTestProps({
|
|
86
|
+
type: 'dots'
|
|
87
|
+
})
|
|
88
|
+
const { container } = renderComponent(Loading, props)
|
|
89
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('should render pulse type', () => {
|
|
93
|
+
const props = createTestProps({
|
|
94
|
+
type: 'pulse'
|
|
95
|
+
})
|
|
96
|
+
const { container } = renderComponent(Loading, props)
|
|
97
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('should render bars type', () => {
|
|
101
|
+
const props = createTestProps({
|
|
102
|
+
type: 'bars'
|
|
103
|
+
})
|
|
104
|
+
const { container } = renderComponent(Loading, props)
|
|
105
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('should fallback to spinner for unknown type', () => {
|
|
109
|
+
const props = createTestProps({
|
|
110
|
+
type: 'unknown' as any
|
|
111
|
+
})
|
|
112
|
+
const { container } = renderComponent(Loading, props)
|
|
113
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
describe('Sizes', () => {
|
|
118
|
+
const sizes = ['small', 'default', 'large']
|
|
119
|
+
|
|
120
|
+
sizes.forEach(size => {
|
|
121
|
+
it(`should render ${size} size`, () => {
|
|
122
|
+
const props = createTestProps({
|
|
123
|
+
size: size as any
|
|
124
|
+
})
|
|
125
|
+
const { container } = renderComponent(Loading, props)
|
|
126
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
127
|
+
expect(container.firstChild).toHaveClass(`taro-uno-loading--${size}`)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
describe('Text Support', () => {
|
|
133
|
+
it('should render without text by default', () => {
|
|
134
|
+
const props = createTestProps({})
|
|
135
|
+
const { container } = renderComponent(Loading, props)
|
|
136
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
137
|
+
expect(container.querySelector('text')).toBeNull()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('should render with text', () => {
|
|
141
|
+
const props = createTestProps({
|
|
142
|
+
text: 'Loading...'
|
|
143
|
+
})
|
|
144
|
+
const { container } = renderComponent(Loading, props)
|
|
145
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
146
|
+
expect(container).toHaveTextContent('Loading...')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should render with empty text', () => {
|
|
150
|
+
const props = createTestProps({
|
|
151
|
+
text: ''
|
|
152
|
+
})
|
|
153
|
+
const { container } = renderComponent(Loading, props)
|
|
154
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
155
|
+
expect(container.querySelector('text')).toBeInTheDocument()
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('should render with long text', () => {
|
|
159
|
+
const longText = 'A'.repeat(100)
|
|
160
|
+
const props = createTestProps({
|
|
161
|
+
text: longText
|
|
162
|
+
})
|
|
163
|
+
const { container } = renderComponent(Loading, props)
|
|
164
|
+
expect(container).toHaveTextContent(longText)
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
describe('Delay Feature', () => {
|
|
169
|
+
it('should show immediately with delay=0', () => {
|
|
170
|
+
const props = createTestProps({
|
|
171
|
+
delay: 0
|
|
172
|
+
})
|
|
173
|
+
const { container } = renderComponent(Loading, props)
|
|
174
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('should delay showing with delay>0', () => {
|
|
178
|
+
const props = createTestProps({
|
|
179
|
+
delay: 500
|
|
180
|
+
})
|
|
181
|
+
const { container } = renderComponent(Loading, props)
|
|
182
|
+
|
|
183
|
+
expect(container.firstChild).toBeNull()
|
|
184
|
+
|
|
185
|
+
act(() => {
|
|
186
|
+
vi.advanceTimersByTime(499)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
expect(container.firstChild).toBeNull()
|
|
190
|
+
|
|
191
|
+
act(() => {
|
|
192
|
+
vi.advanceTimersByTime(1)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('should clear timer on unmount', () => {
|
|
199
|
+
const clearTimeoutSpy = vi.spyOn(global, 'clearTimeout')
|
|
200
|
+
const props = createTestProps({
|
|
201
|
+
delay: 1000
|
|
202
|
+
})
|
|
203
|
+
const { container, unmount } = renderComponent(Loading, props)
|
|
204
|
+
|
|
205
|
+
unmount()
|
|
206
|
+
|
|
207
|
+
expect(clearTimeoutSpy).toHaveBeenCalled()
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
describe('Ref Methods', () => {
|
|
212
|
+
it('should provide ref methods', () => {
|
|
213
|
+
const ref = vi.fn()
|
|
214
|
+
const props = createTestProps({})
|
|
215
|
+
|
|
216
|
+
renderComponent(Loading, { ...props, ref })
|
|
217
|
+
|
|
218
|
+
expect(ref).toHaveBeenCalled()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('should allow programmatic show/hide via ref', () => {
|
|
222
|
+
const mockRef = {
|
|
223
|
+
getElement: vi.fn(),
|
|
224
|
+
show: vi.fn(),
|
|
225
|
+
hide: vi.fn(),
|
|
226
|
+
} as any
|
|
227
|
+
|
|
228
|
+
const props = createTestProps({})
|
|
229
|
+
renderComponent(Loading, { ...props, ref: mockRef })
|
|
230
|
+
|
|
231
|
+
mockRef.show()
|
|
232
|
+
mockRef.hide()
|
|
233
|
+
|
|
234
|
+
expect(mockRef.show).toHaveBeenCalled()
|
|
235
|
+
expect(mockRef.hide).toHaveBeenCalled()
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('should control visibility via ref methods', () => {
|
|
239
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
240
|
+
delay: 1000
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
expect(container.firstChild).toBeNull()
|
|
244
|
+
|
|
245
|
+
// Mock ref with show method
|
|
246
|
+
const mockRef = {
|
|
247
|
+
show: vi.fn(() => {
|
|
248
|
+
rerender(<Loading delay={0} />)
|
|
249
|
+
}),
|
|
250
|
+
hide: vi.fn(() => {
|
|
251
|
+
rerender(<Loading delay={999999} />)
|
|
252
|
+
}),
|
|
253
|
+
} as any
|
|
254
|
+
|
|
255
|
+
rerender(<Loading delay={1000} ref={mockRef} />)
|
|
256
|
+
|
|
257
|
+
mockRef.show()
|
|
258
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
259
|
+
|
|
260
|
+
mockRef.hide()
|
|
261
|
+
expect(container.firstChild).toBeNull()
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
describe('Accessibility', () => {
|
|
266
|
+
it('should have proper ARIA attributes', () => {
|
|
267
|
+
const props = createTestProps({
|
|
268
|
+
text: 'Loading content'
|
|
269
|
+
})
|
|
270
|
+
const { container } = renderComponent(Loading, props)
|
|
271
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
it('should be accessible with screen readers', () => {
|
|
275
|
+
const props = createTestProps({
|
|
276
|
+
text: 'Loading content'
|
|
277
|
+
})
|
|
278
|
+
const { container } = renderComponent(Loading, props)
|
|
279
|
+
const loading = container.firstChild as HTMLElement
|
|
280
|
+
|
|
281
|
+
expect(loading).toBeInTheDocument()
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
describe('Performance', () => {
|
|
286
|
+
it('should render efficiently', () => {
|
|
287
|
+
const props = createTestProps({})
|
|
288
|
+
const startTime = performance.now()
|
|
289
|
+
|
|
290
|
+
const { container } = renderComponent(Loading, props)
|
|
291
|
+
|
|
292
|
+
const endTime = performance.now()
|
|
293
|
+
expect(endTime - startTime).toBeLessThan(50)
|
|
294
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
it('should handle multiple renders efficiently', () => {
|
|
298
|
+
const props = createTestProps({})
|
|
299
|
+
let renderCount = 0
|
|
300
|
+
|
|
301
|
+
const TestComponent = () => {
|
|
302
|
+
renderCount++
|
|
303
|
+
return <Loading {...props} />
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const { rerender } = renderComponent(TestComponent, {})
|
|
307
|
+
rerender(<TestComponent />)
|
|
308
|
+
|
|
309
|
+
expect(renderCount).toBeLessThan(5)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('should handle complex animations efficiently', () => {
|
|
313
|
+
const props = createTestProps({
|
|
314
|
+
type: 'bars',
|
|
315
|
+
size: 'large'
|
|
316
|
+
})
|
|
317
|
+
const startTime = performance.now()
|
|
318
|
+
|
|
319
|
+
const { container } = renderComponent(Loading, props)
|
|
320
|
+
|
|
321
|
+
const endTime = performance.now()
|
|
322
|
+
expect(endTime - startTime).toBeLessThan(50)
|
|
323
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
324
|
+
})
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
describe('Edge Cases', () => {
|
|
328
|
+
it('should handle negative delay', () => {
|
|
329
|
+
const props = createTestProps({
|
|
330
|
+
delay: -100
|
|
331
|
+
})
|
|
332
|
+
const { container } = renderComponent(Loading, props)
|
|
333
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
it('should handle zero delay', () => {
|
|
337
|
+
const props = createTestProps({
|
|
338
|
+
delay: 0
|
|
339
|
+
})
|
|
340
|
+
const { container } = renderComponent(Loading, props)
|
|
341
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it('should handle very large delay', () => {
|
|
345
|
+
const props = createTestProps({
|
|
346
|
+
delay: 999999
|
|
347
|
+
})
|
|
348
|
+
const { container } = renderComponent(Loading, props)
|
|
349
|
+
expect(container.firstChild).toBeNull()
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
it('should handle delay change', () => {
|
|
353
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
354
|
+
delay: 1000
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
expect(container.firstChild).toBeNull()
|
|
358
|
+
|
|
359
|
+
rerender(<Loading delay={0} />)
|
|
360
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('should handle type change', () => {
|
|
364
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
365
|
+
type: 'spinner'
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
369
|
+
|
|
370
|
+
rerender(<Loading type="dots" />)
|
|
371
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
372
|
+
|
|
373
|
+
rerender(<Loading type="pulse" />)
|
|
374
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
375
|
+
|
|
376
|
+
rerender(<Loading type="bars" />)
|
|
377
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
it('should handle size change', () => {
|
|
381
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
382
|
+
size: 'small'
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
expect(container.firstChild).toHaveClass('taro-uno-loading--small')
|
|
386
|
+
|
|
387
|
+
rerender(<Loading size="default" />)
|
|
388
|
+
expect(container.firstChild).toHaveClass('taro-uno-loading--default')
|
|
389
|
+
|
|
390
|
+
rerender(<Loading size="large" />)
|
|
391
|
+
expect(container.firstChild).toHaveClass('taro-uno-loading--large')
|
|
392
|
+
})
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
describe('Animation Handling', () => {
|
|
396
|
+
it('should handle spinner animation', () => {
|
|
397
|
+
const props = createTestProps({
|
|
398
|
+
type: 'spinner'
|
|
399
|
+
})
|
|
400
|
+
const { container } = renderComponent(Loading, props)
|
|
401
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
it('should handle dots animation delays', () => {
|
|
405
|
+
const props = createTestProps({
|
|
406
|
+
type: 'dots'
|
|
407
|
+
})
|
|
408
|
+
const { container } = renderComponent(Loading, props)
|
|
409
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
it('should handle bars animation delays', () => {
|
|
413
|
+
const props = createTestProps({
|
|
414
|
+
type: 'bars'
|
|
415
|
+
})
|
|
416
|
+
const { container } = renderComponent(Loading, props)
|
|
417
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
418
|
+
})
|
|
419
|
+
|
|
420
|
+
it('should handle pulse animation', () => {
|
|
421
|
+
const props = createTestProps({
|
|
422
|
+
type: 'pulse'
|
|
423
|
+
})
|
|
424
|
+
const { container } = renderComponent(Loading, props)
|
|
425
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
describe('State Management', () => {
|
|
430
|
+
it('should maintain visibility state correctly', () => {
|
|
431
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
432
|
+
delay: 500
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
expect(container.firstChild).toBeNull()
|
|
436
|
+
|
|
437
|
+
act(() => {
|
|
438
|
+
vi.advanceTimersByTime(500)
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
442
|
+
|
|
443
|
+
// Change delay back to large value
|
|
444
|
+
rerender(<Loading delay={999999} />)
|
|
445
|
+
expect(container.firstChild).toBeNull()
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
it('should reset timer when delay changes', () => {
|
|
449
|
+
const { container, rerender } = renderComponent(Loading, {
|
|
450
|
+
delay: 1000
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
act(() => {
|
|
454
|
+
vi.advanceTimersByTime(500)
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
expect(container.firstChild).toBeNull()
|
|
458
|
+
|
|
459
|
+
// Change delay to 0
|
|
460
|
+
rerender(<Loading delay={0} />)
|
|
461
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
describe('CSS Classes', () => {
|
|
466
|
+
it('should have correct BEM classes', () => {
|
|
467
|
+
const props = createTestProps({
|
|
468
|
+
size: 'medium'
|
|
469
|
+
})
|
|
470
|
+
const { container } = renderComponent(Loading, props)
|
|
471
|
+
const loading = container.firstChild as HTMLElement
|
|
472
|
+
|
|
473
|
+
expect(loading).toHaveClass('taro-uno-loading')
|
|
474
|
+
expect(loading).toHaveClass('taro-uno-loading--default')
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
it('should handle custom className correctly', () => {
|
|
478
|
+
const props = createTestProps({
|
|
479
|
+
className: 'my-loading'
|
|
480
|
+
})
|
|
481
|
+
const { container } = renderComponent(Loading, props)
|
|
482
|
+
const loading = container.firstChild as HTMLElement
|
|
483
|
+
|
|
484
|
+
expect(loading).toHaveClass('taro-uno-loading')
|
|
485
|
+
expect(loading).toHaveClass('my-loading')
|
|
486
|
+
})
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
describe('Responsive Design', () => {
|
|
490
|
+
it('should handle different viewport sizes', () => {
|
|
491
|
+
const props = createTestProps({
|
|
492
|
+
size: 'default'
|
|
493
|
+
})
|
|
494
|
+
const { container } = renderComponent(Loading, props)
|
|
495
|
+
|
|
496
|
+
// Test different viewport sizes
|
|
497
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
498
|
+
writable: true,
|
|
499
|
+
configurable: true,
|
|
500
|
+
value: 320,
|
|
501
|
+
})
|
|
502
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
503
|
+
|
|
504
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
505
|
+
writable: true,
|
|
506
|
+
configurable: true,
|
|
507
|
+
value: 1920,
|
|
508
|
+
})
|
|
509
|
+
expect(container.firstChild).toBeInTheDocument()
|
|
510
|
+
})
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
describe('Memory Management', () => {
|
|
514
|
+
it('should clean up timers properly', () => {
|
|
515
|
+
const clearTimeoutSpy = vi.spyOn(global, 'clearTimeout')
|
|
516
|
+
const { unmount } = renderComponent(Loading, {
|
|
517
|
+
delay: 1000
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
unmount()
|
|
521
|
+
expect(clearTimeoutSpy).toHaveBeenCalled()
|
|
522
|
+
})
|
|
523
|
+
|
|
524
|
+
it('should handle rapid unmount', () => {
|
|
525
|
+
const { unmount } = renderComponent(Loading, {
|
|
526
|
+
delay: 1000
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
// Rapid mount/unmount
|
|
530
|
+
unmount()
|
|
531
|
+
expect(true).toBe(true) // Should not crash
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
})
|