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,376 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useState, useCallback } from 'react';
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
import type {
|
|
4
|
+
NotificationManagerProps,
|
|
5
|
+
NotificationManagerRef,
|
|
6
|
+
NotificationItem,
|
|
7
|
+
NotificationPlacement
|
|
8
|
+
} from './Notification.types';
|
|
9
|
+
import { Notification } from './Notification';
|
|
10
|
+
import { notificationStyleHelpers } from './Notification.styles';
|
|
11
|
+
import { cn, platform } from '../../../utils';
|
|
12
|
+
import { useTheme } from '../../../theme/ThemeProvider';
|
|
13
|
+
import { DEFAULT_NOTIFICATION_CONFIG, NotificationUtils } from './Notification.types';
|
|
14
|
+
|
|
15
|
+
// 通知项内部接口
|
|
16
|
+
interface InternalNotificationItem extends NotificationItem {
|
|
17
|
+
/** 堆叠索引 */
|
|
18
|
+
stackIndex: number;
|
|
19
|
+
/** 是否正在关闭 */
|
|
20
|
+
isClosing: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const NotificationManager = forwardRef<NotificationManagerRef, NotificationManagerProps>((props, ref) => {
|
|
24
|
+
const {
|
|
25
|
+
maxCount = DEFAULT_NOTIFICATION_CONFIG.defaultMaxCount,
|
|
26
|
+
defaultPlacement = DEFAULT_NOTIFICATION_CONFIG.defaultPlacement,
|
|
27
|
+
defaultDuration = DEFAULT_NOTIFICATION_CONFIG.defaultDuration,
|
|
28
|
+
defaultAnimation = DEFAULT_NOTIFICATION_CONFIG.defaultAnimation,
|
|
29
|
+
stack = DEFAULT_NOTIFICATION_CONFIG.defaultStack,
|
|
30
|
+
containerStyle,
|
|
31
|
+
containerClassName,
|
|
32
|
+
onEnter,
|
|
33
|
+
onLeave,
|
|
34
|
+
onAllClose,
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
// Ignore unused props for future implementation
|
|
38
|
+
void props.stackMaxCount;
|
|
39
|
+
void props.allowDrag;
|
|
40
|
+
void props.dragThreshold;
|
|
41
|
+
void props.showGroup;
|
|
42
|
+
void props.groupInterval;
|
|
43
|
+
void props.style;
|
|
44
|
+
void props.className;
|
|
45
|
+
|
|
46
|
+
const theme = useTheme();
|
|
47
|
+
const [notifications, setNotifications] = useState<InternalNotificationItem[]>([]);
|
|
48
|
+
const [history, setHistory] = useState<NotificationItem[]>([]);
|
|
49
|
+
const [_isAllPaused, setIsAllPaused] = useState(false);
|
|
50
|
+
const notificationRefs = useRef<Map<string, { current: any }>>(new Map());
|
|
51
|
+
|
|
52
|
+
// 添加通知
|
|
53
|
+
const addNotification = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt'>): string => {
|
|
54
|
+
const key = NotificationUtils.generateKey();
|
|
55
|
+
const newNotification: InternalNotificationItem = {
|
|
56
|
+
...config,
|
|
57
|
+
key,
|
|
58
|
+
createdAt: Date.now(),
|
|
59
|
+
placement: config.placement || defaultPlacement,
|
|
60
|
+
duration: config.duration ?? defaultDuration,
|
|
61
|
+
animation: config.animation || defaultAnimation,
|
|
62
|
+
stackIndex: 0,
|
|
63
|
+
isClosing: false,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
setNotifications(prev => {
|
|
67
|
+
// 检查是否超过最大数量
|
|
68
|
+
let updatedNotifications = [...prev, newNotification];
|
|
69
|
+
|
|
70
|
+
if (updatedNotifications.length > maxCount) {
|
|
71
|
+
// 移除最早的通知
|
|
72
|
+
const removed = updatedNotifications.shift();
|
|
73
|
+
if (removed) {
|
|
74
|
+
// 添加到历史记录
|
|
75
|
+
setHistory(prevHistory => [...prevHistory.slice(-DEFAULT_NOTIFICATION_CONFIG.maxHistoryCount!), removed]);
|
|
76
|
+
onLeave?.(removed.key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 更新堆叠索引
|
|
81
|
+
return updateStackIndices(updatedNotifications);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
onEnter?.(key);
|
|
85
|
+
return key;
|
|
86
|
+
}, [maxCount, defaultPlacement, defaultDuration, defaultAnimation, onEnter, onLeave]);
|
|
87
|
+
|
|
88
|
+
// 更新堆叠索引
|
|
89
|
+
const updateStackIndices = useCallback((notificationsList: InternalNotificationItem[]): InternalNotificationItem[] => {
|
|
90
|
+
if (!stack) return notificationsList;
|
|
91
|
+
|
|
92
|
+
return notificationsList.map((notification, index) => ({
|
|
93
|
+
...notification,
|
|
94
|
+
stackIndex: index,
|
|
95
|
+
}));
|
|
96
|
+
}, [stack]);
|
|
97
|
+
|
|
98
|
+
// 关闭通知
|
|
99
|
+
const closeNotification = useCallback((key: string) => {
|
|
100
|
+
setNotifications(prev => {
|
|
101
|
+
const notificationIndex = prev.findIndex(n => n.key === key);
|
|
102
|
+
if (notificationIndex === -1) return prev;
|
|
103
|
+
|
|
104
|
+
const notification = prev[notificationIndex];
|
|
105
|
+
const updatedNotifications = prev.filter((_, index) => index !== notificationIndex);
|
|
106
|
+
|
|
107
|
+
// 添加到历史记录
|
|
108
|
+
setHistory(prevHistory => [...prevHistory.slice(-DEFAULT_NOTIFICATION_CONFIG.maxHistoryCount!), notification as NotificationItem]);
|
|
109
|
+
|
|
110
|
+
// 更新堆叠索引
|
|
111
|
+
return updateStackIndices(updatedNotifications);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
onLeave?.(key);
|
|
115
|
+
}, [onLeave, updateStackIndices]);
|
|
116
|
+
|
|
117
|
+
// 关闭所有通知
|
|
118
|
+
const closeAllNotifications = useCallback(() => {
|
|
119
|
+
setNotifications(prev => {
|
|
120
|
+
// 添加到历史记录
|
|
121
|
+
setHistory(prevHistory => [
|
|
122
|
+
...prevHistory.slice(-DEFAULT_NOTIFICATION_CONFIG.maxHistoryCount!),
|
|
123
|
+
...prev
|
|
124
|
+
]);
|
|
125
|
+
|
|
126
|
+
const firstKey = prev[0]?.key;
|
|
127
|
+
if (firstKey) {
|
|
128
|
+
onLeave?.(firstKey);
|
|
129
|
+
}
|
|
130
|
+
onAllClose?.();
|
|
131
|
+
|
|
132
|
+
return [];
|
|
133
|
+
});
|
|
134
|
+
}, [onLeave, onAllClose]);
|
|
135
|
+
|
|
136
|
+
// 更新通知
|
|
137
|
+
const updateNotification = useCallback((key: string, config: Partial<NotificationItem>) => {
|
|
138
|
+
setNotifications(prev => {
|
|
139
|
+
return prev.map(notification => {
|
|
140
|
+
if (notification.key === key) {
|
|
141
|
+
return {
|
|
142
|
+
...notification,
|
|
143
|
+
...config,
|
|
144
|
+
// 保留原始创建时间和键
|
|
145
|
+
key: notification.key,
|
|
146
|
+
createdAt: notification.createdAt,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return notification;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}, []);
|
|
153
|
+
|
|
154
|
+
// 显示通知
|
|
155
|
+
const open = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt'>) => {
|
|
156
|
+
return addNotification(config);
|
|
157
|
+
}, [addNotification]);
|
|
158
|
+
|
|
159
|
+
// 显示成功通知
|
|
160
|
+
const success = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => {
|
|
161
|
+
return open({ ...config, type: 'success' });
|
|
162
|
+
}, [open]);
|
|
163
|
+
|
|
164
|
+
// 显示信息通知
|
|
165
|
+
const info = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => {
|
|
166
|
+
return open({ ...config, type: 'info' });
|
|
167
|
+
}, [open]);
|
|
168
|
+
|
|
169
|
+
// 显示警告通知
|
|
170
|
+
const warning = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => {
|
|
171
|
+
return open({ ...config, type: 'warning' });
|
|
172
|
+
}, [open]);
|
|
173
|
+
|
|
174
|
+
// 显示错误通知
|
|
175
|
+
const error = useCallback((config: Omit<NotificationItem, 'key' | 'createdAt' | 'type'>) => {
|
|
176
|
+
return open({ ...config, type: 'error' });
|
|
177
|
+
}, [open]);
|
|
178
|
+
|
|
179
|
+
// 关闭指定通知
|
|
180
|
+
const close = useCallback((key: string) => {
|
|
181
|
+
closeNotification(key);
|
|
182
|
+
}, [closeNotification]);
|
|
183
|
+
|
|
184
|
+
// 关闭所有通知
|
|
185
|
+
const destroyAll = useCallback(() => {
|
|
186
|
+
closeAllNotifications();
|
|
187
|
+
}, [closeAllNotifications]);
|
|
188
|
+
|
|
189
|
+
// 获取所有通知
|
|
190
|
+
const getNotifications = useCallback(() => {
|
|
191
|
+
return notifications.map(({ isClosing, stackIndex, ...rest }) => rest);
|
|
192
|
+
}, [notifications]);
|
|
193
|
+
|
|
194
|
+
// 获取通知数量
|
|
195
|
+
const getCount = useCallback(() => {
|
|
196
|
+
return notifications.length;
|
|
197
|
+
}, [notifications]);
|
|
198
|
+
|
|
199
|
+
// 设置最大数量
|
|
200
|
+
const setMaxCount = useCallback((_count: number) => {
|
|
201
|
+
// 这里可以更新状态,但由于maxCount是prop,实际应该通过props更新
|
|
202
|
+
console.warn('setMaxCount should be controlled by props');
|
|
203
|
+
}, []);
|
|
204
|
+
|
|
205
|
+
// 设置默认位置
|
|
206
|
+
const setDefaultPlacement = useCallback((_placement: NotificationPlacement) => {
|
|
207
|
+
// 这里可以更新状态,但由于defaultPlacement是prop,实际应该通过props更新
|
|
208
|
+
console.warn('setDefaultPlacement should be controlled by props');
|
|
209
|
+
}, []);
|
|
210
|
+
|
|
211
|
+
// 设置默认时长
|
|
212
|
+
const setDefaultDuration = useCallback((_duration: number) => {
|
|
213
|
+
// 这里可以更新状态,但由于defaultDuration是prop,实际应该通过props更新
|
|
214
|
+
console.warn('setDefaultDuration should be controlled by props');
|
|
215
|
+
}, []);
|
|
216
|
+
|
|
217
|
+
// 暂停所有通知自动关闭
|
|
218
|
+
const pauseAll = useCallback(() => {
|
|
219
|
+
setIsAllPaused(true);
|
|
220
|
+
notificationRefs.current.forEach(refObject => {
|
|
221
|
+
if (refObject?.current?.pauseProgress) {
|
|
222
|
+
refObject.current.pauseProgress();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}, []);
|
|
226
|
+
|
|
227
|
+
// 恢复所有通知自动关闭
|
|
228
|
+
const resumeAll = useCallback(() => {
|
|
229
|
+
setIsAllPaused(false);
|
|
230
|
+
notificationRefs.current.forEach(ref => {
|
|
231
|
+
if (ref?.current?.resumeProgress) {
|
|
232
|
+
ref.current.resumeProgress();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}, []);
|
|
236
|
+
|
|
237
|
+
// 清空历史记录
|
|
238
|
+
const clearHistory = useCallback(() => {
|
|
239
|
+
setHistory([]);
|
|
240
|
+
}, []);
|
|
241
|
+
|
|
242
|
+
// 获取通知历史
|
|
243
|
+
const getHistory = useCallback(() => {
|
|
244
|
+
return [...history];
|
|
245
|
+
}, [history]);
|
|
246
|
+
|
|
247
|
+
// 暴露方法给ref
|
|
248
|
+
React.useImperativeHandle(ref, () => ({
|
|
249
|
+
open,
|
|
250
|
+
success,
|
|
251
|
+
info,
|
|
252
|
+
warning,
|
|
253
|
+
error,
|
|
254
|
+
close,
|
|
255
|
+
destroyAll,
|
|
256
|
+
update: updateNotification,
|
|
257
|
+
getNotifications,
|
|
258
|
+
getCount,
|
|
259
|
+
setMaxCount,
|
|
260
|
+
setDefaultPlacement,
|
|
261
|
+
setDefaultDuration,
|
|
262
|
+
pauseAll,
|
|
263
|
+
resumeAll,
|
|
264
|
+
clearHistory,
|
|
265
|
+
getHistory,
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
// 处理通知关闭
|
|
269
|
+
const handleNotificationClose = useCallback((key: string) => {
|
|
270
|
+
closeNotification(key);
|
|
271
|
+
}, [closeNotification]);
|
|
272
|
+
|
|
273
|
+
// 处理通知点击
|
|
274
|
+
const handleNotificationClick = useCallback((key: string) => {
|
|
275
|
+
const notification = notifications.find(n => n.key === key);
|
|
276
|
+
if (notification?.onClick) {
|
|
277
|
+
notification.onClick();
|
|
278
|
+
}
|
|
279
|
+
}, [notifications]);
|
|
280
|
+
|
|
281
|
+
// 获取容器样式
|
|
282
|
+
const getContainerStyle = () => {
|
|
283
|
+
return {
|
|
284
|
+
...notificationStyleHelpers.getContainerStyle({ theme, isMobile: platform.isMobile() }),
|
|
285
|
+
...containerStyle,
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// 获取容器类名
|
|
290
|
+
const getContainerClassName = () => {
|
|
291
|
+
return cn(
|
|
292
|
+
'taro-uno-notification-container',
|
|
293
|
+
containerClassName
|
|
294
|
+
);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
// 按位置分组通知
|
|
299
|
+
const renderNotificationsByPlacement = () => {
|
|
300
|
+
const notificationsByPlacement: Record<NotificationPlacement, InternalNotificationItem[]> = {
|
|
301
|
+
topRight: [],
|
|
302
|
+
topLeft: [],
|
|
303
|
+
bottomRight: [],
|
|
304
|
+
bottomLeft: [],
|
|
305
|
+
top: [],
|
|
306
|
+
bottom: [],
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// 按位置分组
|
|
310
|
+
notifications.forEach(notification => {
|
|
311
|
+
const placement = notification.placement || defaultPlacement;
|
|
312
|
+
notificationsByPlacement[placement].push(notification);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// 渲染每个位置的通知
|
|
316
|
+
return Object.entries(notificationsByPlacement).map(([placement, placementNotifications]) => {
|
|
317
|
+
if (placementNotifications.length === 0) return null;
|
|
318
|
+
|
|
319
|
+
const sortedNotifications = NotificationUtils.sortNotifications(placementNotifications);
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<View
|
|
323
|
+
key={placement}
|
|
324
|
+
className={`taro-uno-notification-placement-${placement}`}
|
|
325
|
+
style={{
|
|
326
|
+
position: 'absolute',
|
|
327
|
+
pointerEvents: 'none',
|
|
328
|
+
...getPlacementStyle(placement as NotificationPlacement),
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
{sortedNotifications.map((notification) => {
|
|
332
|
+
const { key, ...notificationConfig } = notification;
|
|
333
|
+
// Future implementation might use these properties
|
|
334
|
+
void (notification as any).isClosing;
|
|
335
|
+
void (notification as any).stackIndex;
|
|
336
|
+
|
|
337
|
+
return (
|
|
338
|
+
<Notification
|
|
339
|
+
key={key}
|
|
340
|
+
ref={(ref) => {
|
|
341
|
+
if (ref) {
|
|
342
|
+
notificationRefs.current.set(key, { current: ref });
|
|
343
|
+
} else {
|
|
344
|
+
notificationRefs.current.delete(key);
|
|
345
|
+
}
|
|
346
|
+
}}
|
|
347
|
+
{...notificationConfig}
|
|
348
|
+
onClose={() => handleNotificationClose(key)}
|
|
349
|
+
onClick={() => handleNotificationClick(key)}
|
|
350
|
+
/>
|
|
351
|
+
);
|
|
352
|
+
})}
|
|
353
|
+
</View>
|
|
354
|
+
);
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// 获取位置样式
|
|
359
|
+
const getPlacementStyle = (placement: NotificationPlacement) => {
|
|
360
|
+
const placementStyleData = notificationStyleHelpers.getPlacementStyle(placement, { theme, isMobile: platform.isMobile() });
|
|
361
|
+
return placementStyleData.container;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<View
|
|
366
|
+
className={getContainerClassName()}
|
|
367
|
+
style={getContainerStyle()}
|
|
368
|
+
>
|
|
369
|
+
{renderNotificationsByPlacement()}
|
|
370
|
+
</View>
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
NotificationManager.displayName = 'NotificationManager';
|
|
375
|
+
|
|
376
|
+
export default NotificationManager;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { Notification } from './Notification';
|
|
2
|
+
export { default as NotificationManager } from './NotificationManager';
|
|
3
|
+
|
|
4
|
+
// Simple notification singleton for direct usage
|
|
5
|
+
class NotificationSingleton {
|
|
6
|
+
open = (_config: any) => {
|
|
7
|
+
console.warn('Notification singleton called. Please render <NotificationManager /> in your app for full functionality.');
|
|
8
|
+
return 'notification-key';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
success = (config: any) => this.open({ ...config, type: 'success' });
|
|
12
|
+
info = (config: any) => this.open({ ...config, type: 'info' });
|
|
13
|
+
warning = (config: any) => this.open({ ...config, type: 'warning' });
|
|
14
|
+
error = (config: any) => this.open({ ...config, type: 'error' });
|
|
15
|
+
close = (_key: string) => {};
|
|
16
|
+
destroyAll = () => {};
|
|
17
|
+
update = (_key: string, _config: any) => {};
|
|
18
|
+
getNotifications = () => [];
|
|
19
|
+
getCount = () => 0;
|
|
20
|
+
setMaxCount = (_count: number) => {};
|
|
21
|
+
setDefaultPlacement = (_placement: any) => {};
|
|
22
|
+
setDefaultDuration = (_duration: number) => {};
|
|
23
|
+
pauseAll = () => {};
|
|
24
|
+
resumeAll = () => {};
|
|
25
|
+
clearHistory = () => {};
|
|
26
|
+
getHistory = () => [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const notification = new NotificationSingleton();
|
|
30
|
+
export type { NotificationProps, NotificationRef, NotificationManagerProps, NotificationPlacement } from './Notification.types';
|
|
31
|
+
export { notificationStyles } from './Notification.styles';
|
|
32
|
+
|
|
33
|
+
export default Notification;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification 通知提醒组件
|
|
3
|
+
* 提供全局通知提醒功能,支持多种类型、位置、动画效果
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 导出主要组件
|
|
7
|
+
export { Notification } from './Notification';
|
|
8
|
+
export { default as NotificationManager } from './NotificationManager';
|
|
9
|
+
|
|
10
|
+
// 导出类型定义
|
|
11
|
+
export type {
|
|
12
|
+
NotificationType,
|
|
13
|
+
NotificationPlacement,
|
|
14
|
+
NotificationAnimation,
|
|
15
|
+
NotificationItem,
|
|
16
|
+
NotificationProps,
|
|
17
|
+
NotificationManagerProps,
|
|
18
|
+
NotificationRef,
|
|
19
|
+
NotificationUtils,
|
|
20
|
+
} from './Notification.types';
|
|
21
|
+
|
|
22
|
+
// 导出默认配置
|
|
23
|
+
export { DEFAULT_NOTIFICATION_CONFIG } from './Notification.types';
|
|
24
|
+
|
|
25
|
+
// 导出样式系统
|
|
26
|
+
export {
|
|
27
|
+
notificationStyles,
|
|
28
|
+
notificationStyleHelpers,
|
|
29
|
+
notificationStyleConfig,
|
|
30
|
+
notificationStylesCompat,
|
|
31
|
+
notificationStylesLegacy,
|
|
32
|
+
} from './Notification.styles';
|
|
33
|
+
|
|
34
|
+
// 导出工具函数
|
|
35
|
+
export { NotificationUtils } from './Notification.types';
|
|
36
|
+
|
|
37
|
+
// 创建全局通知管理器实例
|
|
38
|
+
import type { NotificationManagerRef } from './Notification.types';
|
|
39
|
+
|
|
40
|
+
// 全局通知管理器引用
|
|
41
|
+
let globalNotificationRef: NotificationManagerRef | null = null;
|
|
42
|
+
|
|
43
|
+
// 设置全局通知管理器
|
|
44
|
+
export const setGlobalNotificationRef = (ref: NotificationManagerRef | null) => {
|
|
45
|
+
globalNotificationRef = ref;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// 获取全局通知管理器
|
|
49
|
+
export const getGlobalNotificationRef = (): NotificationManagerRef | null => {
|
|
50
|
+
return globalNotificationRef;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// 全局通知方法
|
|
54
|
+
export const notification = {
|
|
55
|
+
// 显示通知
|
|
56
|
+
open: (config: Parameters<NotificationManagerRef['open']>[0]) => {
|
|
57
|
+
return globalNotificationRef?.open(config) || '';
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
// 显示成功通知
|
|
61
|
+
success: (config: Parameters<NotificationManagerRef['success']>[0]) => {
|
|
62
|
+
return globalNotificationRef?.success(config) || '';
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// 显示信息通知
|
|
66
|
+
info: (config: Parameters<NotificationManagerRef['info']>[0]) => {
|
|
67
|
+
return globalNotificationRef?.info(config) || '';
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// 显示警告通知
|
|
71
|
+
warning: (config: Parameters<NotificationManagerRef['warning']>[0]) => {
|
|
72
|
+
return globalNotificationRef?.warning(config) || '';
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// 显示错误通知
|
|
76
|
+
error: (config: Parameters<NotificationManagerRef['error']>[0]) => {
|
|
77
|
+
return globalNotificationRef?.error(config) || '';
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// 关闭通知
|
|
81
|
+
close: (key: string) => {
|
|
82
|
+
globalNotificationRef?.close(key);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
// 关闭所有通知
|
|
86
|
+
destroyAll: () => {
|
|
87
|
+
globalNotificationRef?.destroyAll();
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// 更新通知
|
|
91
|
+
update: (key: string, config: Parameters<NotificationManagerRef['update']>[1]) => {
|
|
92
|
+
globalNotificationRef?.update(key, config);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// 获取所有通知
|
|
96
|
+
getNotifications: () => {
|
|
97
|
+
return globalNotificationRef?.getNotifications() || [];
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// 获取通知数量
|
|
101
|
+
getCount: () => {
|
|
102
|
+
return globalNotificationRef?.getCount() || 0;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// 暂停所有通知
|
|
106
|
+
pauseAll: () => {
|
|
107
|
+
globalNotificationRef?.pauseAll();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// 恢复所有通知
|
|
111
|
+
resumeAll: () => {
|
|
112
|
+
globalNotificationRef?.resumeAll();
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
// 清空历史记录
|
|
116
|
+
clearHistory: () => {
|
|
117
|
+
globalNotificationRef?.clearHistory();
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// 获取通知历史
|
|
121
|
+
getHistory: () => {
|
|
122
|
+
return globalNotificationRef?.getHistory() || [];
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// 便捷方法
|
|
127
|
+
export const {
|
|
128
|
+
success,
|
|
129
|
+
info,
|
|
130
|
+
warning,
|
|
131
|
+
error,
|
|
132
|
+
destroyAll,
|
|
133
|
+
pauseAll,
|
|
134
|
+
resumeAll,
|
|
135
|
+
} = notification;
|
|
136
|
+
|
|
137
|
+
// 默认导出
|
|
138
|
+
export default Notification;
|
|
139
|
+
|
|
140
|
+
// 导出类型工具
|
|
141
|
+
export type {
|
|
142
|
+
// 通知类型
|
|
143
|
+
NotificationType as Type,
|
|
144
|
+
NotificationPlacement as Placement,
|
|
145
|
+
NotificationAnimation as Animation,
|
|
146
|
+
|
|
147
|
+
// 通知接口
|
|
148
|
+
NotificationItem as Item,
|
|
149
|
+
NotificationProps as Props,
|
|
150
|
+
NotificationManagerProps as ManagerProps,
|
|
151
|
+
NotificationRef as Ref,
|
|
152
|
+
NotificationManagerRef as ManagerRef,
|
|
153
|
+
} from './Notification.types';
|
|
154
|
+
|
|
155
|
+
// 导出全局通知对象
|
|
156
|
+
export { notification };
|
|
157
|
+
|
|
158
|
+
// 组件 displayName
|
|
159
|
+
if (typeof Notification !== 'undefined') {
|
|
160
|
+
(Notification as any).displayName = 'Notification';
|
|
161
|
+
}
|
|
162
|
+
if (typeof NotificationManager !== 'undefined') {
|
|
163
|
+
(NotificationManager as any).displayName = 'NotificationManager';
|
|
164
|
+
}
|