taro-uno-ui 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/app.config.d.ts +38 -0
- package/dist/app.d.ts +6 -0
- package/dist/components/basic/Button/Button.d.ts +6 -0
- package/dist/components/basic/Button/Button.styles.d.ts +2 -0
- package/dist/components/basic/Button/Button.types.d.ts +74 -0
- package/dist/components/basic/Button/index.d.ts +4 -0
- package/dist/components/basic/Divider/Divider.d.ts +6 -0
- package/dist/components/basic/Divider/Divider.styles.d.ts +87 -0
- package/dist/components/basic/Divider/Divider.types.d.ts +242 -0
- package/dist/components/basic/Divider/index.d.ts +6 -0
- package/dist/components/basic/Icon/Icon.d.ts +5 -0
- package/dist/components/basic/Icon/Icon.data.d.ts +29 -0
- package/dist/components/basic/Icon/Icon.styles.d.ts +61 -0
- package/dist/components/basic/Icon/Icon.types.d.ts +199 -0
- package/dist/components/basic/Icon/IconManager.d.ts +120 -0
- package/dist/components/basic/Icon/index.d.ts +6 -0
- package/dist/components/basic/Text/Text.d.ts +7 -0
- package/dist/components/basic/Text/Text.styles.d.ts +67 -0
- package/dist/components/basic/Text/Text.types.d.ts +274 -0
- package/dist/components/basic/Text/index.d.ts +5 -0
- package/dist/components/basic/Typography/Typography.d.ts +8 -0
- package/dist/components/basic/Typography/Typography.styles.d.ts +83 -0
- package/dist/components/basic/Typography/Typography.types.d.ts +245 -0
- package/dist/components/basic/Typography/index.d.ts +3 -0
- package/dist/components/basic/Video/Video.d.ts +7 -0
- package/dist/components/basic/Video/Video.styles.d.ts +212 -0
- package/dist/components/basic/Video/Video.types.d.ts +447 -0
- package/dist/components/basic/Video/index.d.ts +10 -0
- package/dist/components/basic/index.d.ts +217 -0
- package/dist/components/common/ErrorBoundary.d.ts +19 -0
- package/dist/components/common/LazyComponent.d.ts +78 -0
- package/dist/components/common/ResponsiveContainer.d.ts +23 -0
- package/dist/components/common/ResponsiveGrid.d.ts +44 -0
- package/dist/components/common/SecurityProvider.d.ts +15 -0
- package/dist/components/common/ThemeProvider.d.ts +17 -0
- package/dist/components/common/VirtualList.d.ts +89 -0
- package/dist/components/common/index.d.ts +17 -0
- package/dist/components/display/Avatar/Avatar.d.ts +3 -0
- package/dist/components/display/Avatar/Avatar.styles.d.ts +2 -0
- package/dist/components/display/Avatar/Avatar.types.d.ts +37 -0
- package/dist/components/display/Avatar/index.d.ts +3 -0
- package/dist/components/display/Badge/Badge.d.ts +3 -0
- package/dist/components/display/Badge/Badge.types.d.ts +27 -0
- package/dist/components/display/Badge/index.d.ts +2 -0
- package/dist/components/display/Calendar/Calendar.d.ts +5 -0
- package/dist/components/display/Calendar/Calendar.styles.d.ts +2 -0
- package/dist/components/display/Calendar/Calendar.types.d.ts +87 -0
- package/dist/components/display/Calendar/index.d.ts +3 -0
- package/dist/components/display/Card/Card.d.ts +3 -0
- package/dist/components/display/Card/Card.styles.d.ts +1 -0
- package/dist/components/display/Card/Card.types.d.ts +52 -0
- package/dist/components/display/Card/index.d.ts +3 -0
- package/dist/components/display/Carousel/Carousel.d.ts +5 -0
- package/dist/components/display/Carousel/Carousel.styles.d.ts +2 -0
- package/dist/components/display/Carousel/Carousel.types.d.ts +55 -0
- package/dist/components/display/Carousel/index.d.ts +3 -0
- package/dist/components/display/List/List.d.ts +4 -0
- package/dist/components/display/List/List.styles.d.ts +1 -0
- package/dist/components/display/List/List.types.d.ts +64 -0
- package/dist/components/display/List/index.d.ts +3 -0
- package/dist/components/display/Rate/Rate.d.ts +6 -0
- package/dist/components/display/Rate/Rate.styles.d.ts +100 -0
- package/dist/components/display/Rate/Rate.types.d.ts +105 -0
- package/dist/components/display/Rate/index.d.ts +17 -0
- package/dist/components/display/Table/Table.d.ts +7 -0
- package/dist/components/display/Table/Table.styles.d.ts +84 -0
- package/dist/components/display/Table/Table.types.d.ts +251 -0
- package/dist/components/display/Table/index.d.ts +4 -0
- package/dist/components/display/Tag/Tag.d.ts +5 -0
- package/dist/components/display/Tag/Tag.styles.d.ts +2 -0
- package/dist/components/display/Tag/Tag.types.d.ts +47 -0
- package/dist/components/display/Tag/index.d.ts +3 -0
- package/dist/components/display/Timeline/Timeline.d.ts +16 -0
- package/dist/components/display/Timeline/Timeline.styles.d.ts +2 -0
- package/dist/components/display/Timeline/Timeline.types.d.ts +53 -0
- package/dist/components/display/Timeline/index.d.ts +3 -0
- package/dist/components/display/index.d.ts +67 -0
- package/dist/components/feedback/Loading/Loading.d.ts +4 -0
- package/dist/components/feedback/Loading/Loading.styles.d.ts +2 -0
- package/dist/components/feedback/Loading/Loading.types.d.ts +29 -0
- package/dist/components/feedback/Loading/index.d.ts +4 -0
- package/dist/components/feedback/Message/Message.d.ts +4 -0
- package/dist/components/feedback/Message/Message.styles.d.ts +34 -0
- package/dist/components/feedback/Message/Message.types.d.ts +33 -0
- package/dist/components/feedback/Message/index.d.ts +4 -0
- package/dist/components/feedback/Modal/Modal.d.ts +8 -0
- package/dist/components/feedback/Modal/Modal.styles.d.ts +18 -0
- package/dist/components/feedback/Modal/Modal.types.d.ts +143 -0
- package/dist/components/feedback/Modal/index.d.ts +3 -0
- package/dist/components/feedback/Notification/Notification.d.ts +4 -0
- package/dist/components/feedback/Notification/Notification.styles.d.ts +88 -0
- package/dist/components/feedback/Notification/Notification.types.d.ts +279 -0
- package/dist/components/feedback/Notification/NotificationManager.d.ts +4 -0
- package/dist/components/feedback/Notification/index.d.ts +25 -0
- package/dist/components/feedback/Progress/Progress.d.ts +4 -0
- package/dist/components/feedback/Progress/Progress.styles.d.ts +261 -0
- package/dist/components/feedback/Progress/Progress.test.simple.d.ts +2 -0
- package/dist/components/feedback/Progress/Progress.types.d.ts +147 -0
- package/dist/components/feedback/Progress/index.d.ts +3 -0
- package/dist/components/feedback/Progress/utils/animation.d.ts +55 -0
- package/dist/components/feedback/Progress/utils/index.d.ts +2 -0
- package/dist/components/feedback/Progress/utils/progress-calculator.d.ts +75 -0
- package/dist/components/feedback/Result/Result.d.ts +7 -0
- package/dist/components/feedback/Result/Result.styles.d.ts +2 -0
- package/dist/components/feedback/Result/Result.types.d.ts +66 -0
- package/dist/components/feedback/Result/index.d.ts +3 -0
- package/dist/components/feedback/Toast/Toast.d.ts +7 -0
- package/dist/components/feedback/Toast/Toast.styles.d.ts +14 -0
- package/dist/components/feedback/Toast/Toast.types.d.ts +81 -0
- package/dist/components/feedback/Toast/index.d.ts +3 -0
- package/dist/components/feedback/Tooltip/Tooltip.d.ts +4 -0
- package/dist/components/feedback/Tooltip/Tooltip.examples.d.ts +6 -0
- package/dist/components/feedback/Tooltip/Tooltip.styles.d.ts +78 -0
- package/dist/components/feedback/Tooltip/Tooltip.types.d.ts +130 -0
- package/dist/components/feedback/Tooltip/index.d.ts +3 -0
- package/dist/components/feedback/index.d.ts +71 -0
- package/dist/components/form/Cascader/Cascader.d.ts +7 -0
- package/dist/components/form/Cascader/Cascader.styles.d.ts +107 -0
- package/dist/components/form/Cascader/Cascader.types.d.ts +418 -0
- package/dist/components/form/Cascader/hooks/index.d.ts +3 -0
- package/dist/components/form/Cascader/hooks/useCascaderFieldNames.d.ts +12 -0
- package/dist/components/form/Cascader/hooks/useCascaderOptions.d.ts +15 -0
- package/dist/components/form/Cascader/hooks/useCascaderState.d.ts +23 -0
- package/dist/components/form/Cascader/index.d.ts +6 -0
- package/dist/components/form/Cascader/utils/formatDisplayValue.d.ts +9 -0
- package/dist/components/form/Cascader/utils/index.d.ts +1 -0
- package/dist/components/form/Checkbox/Checkbox.d.ts +6 -0
- package/dist/components/form/Checkbox/Checkbox.styles.d.ts +111 -0
- package/dist/components/form/Checkbox/Checkbox.types.d.ts +473 -0
- package/dist/components/form/Checkbox/CheckboxGroup.d.ts +6 -0
- package/dist/components/form/Checkbox/index.d.ts +8 -0
- package/dist/components/form/DatePicker/DatePicker.d.ts +6 -0
- package/dist/components/form/DatePicker/DatePicker.styles.d.ts +99 -0
- package/dist/components/form/DatePicker/DatePicker.types.d.ts +236 -0
- package/dist/components/form/DatePicker/index.d.ts +3 -0
- package/dist/components/form/Form/Form.d.ts +8 -0
- package/dist/components/form/Form/Form.styles.d.ts +84 -0
- package/dist/components/form/Form/Form.types.d.ts +416 -0
- package/dist/components/form/Form/index.d.ts +9 -0
- package/dist/components/form/Form/useFormLogic.d.ts +22 -0
- package/dist/components/form/Input/Input.d.ts +6 -0
- package/dist/components/form/Input/Input.styles.d.ts +61 -0
- package/dist/components/form/Input/Input.types.d.ts +294 -0
- package/dist/components/form/Input/index.d.ts +8 -0
- package/dist/components/form/Input/useInputLogic.d.ts +35 -0
- package/dist/components/form/InputNumber/InputNumber.d.ts +6 -0
- package/dist/components/form/InputNumber/InputNumber.styles.d.ts +120 -0
- package/dist/components/form/InputNumber/InputNumber.types.d.ts +303 -0
- package/dist/components/form/InputNumber/components/InputNumberClearButton.d.ts +10 -0
- package/dist/components/form/InputNumber/components/InputNumberControls.d.ts +11 -0
- package/dist/components/form/InputNumber/components/index.d.ts +2 -0
- package/dist/components/form/InputNumber/hooks/index.d.ts +4 -0
- package/dist/components/form/InputNumber/hooks/useInputNumberState.d.ts +38 -0
- package/dist/components/form/InputNumber/hooks/useInputNumberValidation.d.ts +12 -0
- package/dist/components/form/InputNumber/index.d.ts +5 -0
- package/dist/components/form/Radio/Radio.d.ts +6 -0
- package/dist/components/form/Radio/Radio.styles.d.ts +80 -0
- package/dist/components/form/Radio/Radio.types.d.ts +415 -0
- package/dist/components/form/Radio/index.d.ts +8 -0
- package/dist/components/form/Select/Select.d.ts +6 -0
- package/dist/components/form/Select/Select.styles.d.ts +71 -0
- package/dist/components/form/Select/Select.types.d.ts +418 -0
- package/dist/components/form/Select/index.d.ts +8 -0
- package/dist/components/form/Slider/Slider.d.ts +7 -0
- package/dist/components/form/Slider/Slider.styles.d.ts +2 -0
- package/dist/components/form/Slider/Slider.types.d.ts +85 -0
- package/dist/components/form/Slider/index.d.ts +3 -0
- package/dist/components/form/Switch/Switch.d.ts +10 -0
- package/dist/components/form/Switch/Switch.styles.d.ts +154 -0
- package/dist/components/form/Switch/Switch.types.d.ts +351 -0
- package/dist/components/form/Switch/index.d.ts +7 -0
- package/dist/components/form/Textarea/Textarea.d.ts +6 -0
- package/dist/components/form/Textarea/Textarea.styles.d.ts +66 -0
- package/dist/components/form/Textarea/Textarea.types.d.ts +348 -0
- package/dist/components/form/Textarea/index.d.ts +7 -0
- package/dist/components/form/TimePicker/TimePicker.d.ts +6 -0
- package/dist/components/form/TimePicker/TimePicker.styles.d.ts +104 -0
- package/dist/components/form/TimePicker/TimePicker.types.d.ts +385 -0
- package/dist/components/form/TimePicker/index.d.ts +4 -0
- package/dist/components/form/Transfer/Transfer.d.ts +7 -0
- package/dist/components/form/Transfer/Transfer.styles.d.ts +106 -0
- package/dist/components/form/Transfer/Transfer.types.d.ts +384 -0
- package/dist/components/form/Transfer/components/TransferItem.d.ts +23 -0
- package/dist/components/form/Transfer/components/TransferList.d.ts +55 -0
- package/dist/components/form/Transfer/components/TransferOperations.d.ts +21 -0
- package/dist/components/form/Transfer/components/TransferPagination.d.ts +19 -0
- package/dist/components/form/Transfer/components/TransferSearch.d.ts +21 -0
- package/dist/components/form/Transfer/components/index.d.ts +6 -0
- package/dist/components/form/Transfer/hooks/index.d.ts +3 -0
- package/dist/components/form/Transfer/hooks/useTransferData.d.ts +41 -0
- package/dist/components/form/Transfer/hooks/useTransferState.d.ts +21 -0
- package/dist/components/form/Transfer/index.d.ts +9 -0
- package/dist/components/form/Upload/Upload.d.ts +7 -0
- package/dist/components/form/Upload/Upload.styles.d.ts +2 -0
- package/dist/components/form/Upload/Upload.types.d.ts +143 -0
- package/dist/components/form/Upload/index.d.ts +3 -0
- package/dist/components/form/index.d.ts +126 -0
- package/dist/components/index.d.ts +122 -0
- package/dist/components/layout/Affix/Affix.d.ts +4 -0
- package/dist/components/layout/Affix/Affix.styles.d.ts +1669 -0
- package/dist/components/layout/Affix/Affix.types.d.ts +25 -0
- package/dist/components/layout/Affix/index.d.ts +3 -0
- package/dist/components/layout/Col/Col.d.ts +6 -0
- package/dist/components/layout/Col/Col.styles.d.ts +52 -0
- package/dist/components/layout/Col/Col.types.d.ts +54 -0
- package/dist/components/layout/Col/index.d.ts +3 -0
- package/dist/components/layout/Container/Container.d.ts +6 -0
- package/dist/components/layout/Container/Container.styles.d.ts +41 -0
- package/dist/components/layout/Container/Container.types.d.ts +59 -0
- package/dist/components/layout/Container/index.d.ts +3 -0
- package/dist/components/layout/Grid/Grid.d.ts +6 -0
- package/dist/components/layout/Grid/Grid.styles.d.ts +60 -0
- package/dist/components/layout/Grid/Grid.types.d.ts +68 -0
- package/dist/components/layout/Grid/index.d.ts +3 -0
- package/dist/components/layout/Layout/Content.d.ts +4 -0
- package/dist/components/layout/Layout/Footer.d.ts +4 -0
- package/dist/components/layout/Layout/Header.d.ts +4 -0
- package/dist/components/layout/Layout/Layout.d.ts +4 -0
- package/dist/components/layout/Layout/Layout.styles.d.ts +3366 -0
- package/dist/components/layout/Layout/Layout.types.d.ts +48 -0
- package/dist/components/layout/Layout/Sider.d.ts +4 -0
- package/dist/components/layout/Layout/index.d.ts +8 -0
- package/dist/components/layout/Row/Row.d.ts +6 -0
- package/dist/components/layout/Row/Row.styles.d.ts +55 -0
- package/dist/components/layout/Row/Row.types.d.ts +51 -0
- package/dist/components/layout/Row/index.d.ts +3 -0
- package/dist/components/layout/Space/Space.d.ts +6 -0
- package/dist/components/layout/Space/Space.styles.d.ts +69 -0
- package/dist/components/layout/Space/Space.types.d.ts +84 -0
- package/dist/components/layout/Space/index.d.ts +3 -0
- package/dist/components/layout/index.d.ts +39 -0
- package/dist/components/navigation/Menu/Menu.constants.d.ts +59 -0
- package/dist/components/navigation/Menu/Menu.d.ts +10 -0
- package/dist/components/navigation/Menu/Menu.stories.d.ts +157 -0
- package/dist/components/navigation/Menu/Menu.styles.d.ts +143 -0
- package/dist/components/navigation/Menu/Menu.types.d.ts +210 -0
- package/dist/components/navigation/Menu/Menu.utils.d.ts +54 -0
- package/dist/components/navigation/Menu/MenuItem.d.ts +32 -0
- package/dist/components/navigation/Menu/SubMenu.d.ts +41 -0
- package/dist/components/navigation/Menu/index.d.ts +54 -0
- package/dist/components/navigation/NavBar/NavBar.d.ts +7 -0
- package/dist/components/navigation/NavBar/NavBar.styles.d.ts +114 -0
- package/dist/components/navigation/NavBar/NavBar.types.d.ts +50 -0
- package/dist/components/navigation/NavBar/index.d.ts +3 -0
- package/dist/components/navigation/Pagination/Pagination.d.ts +6 -0
- package/dist/components/navigation/Pagination/Pagination.styles.d.ts +55 -0
- package/dist/components/navigation/Pagination/Pagination.types.d.ts +77 -0
- package/dist/components/navigation/Pagination/index.d.ts +15 -0
- package/dist/components/navigation/Steps/Step.d.ts +4 -0
- package/dist/components/navigation/Steps/Steps.d.ts +4 -0
- package/dist/components/navigation/Steps/Steps.styles.d.ts +6716 -0
- package/dist/components/navigation/Steps/Steps.types.d.ts +41 -0
- package/dist/components/navigation/Steps/index.d.ts +3 -0
- package/dist/components/navigation/Tabs/Tabs.d.ts +6 -0
- package/dist/components/navigation/Tabs/Tabs.styles.d.ts +60 -0
- package/dist/components/navigation/Tabs/Tabs.types.d.ts +107 -0
- package/dist/components/navigation/Tabs/index.d.ts +3 -0
- package/dist/components/navigation/index.d.ts +35 -0
- package/dist/constants/index.d.ts +624 -0
- package/dist/hooks/index.d.ts +28 -0
- package/dist/hooks/types.d.ts +7 -0
- package/dist/hooks/useAsync.d.ts +17 -0
- package/dist/hooks/useClickOutside.d.ts +19 -0
- package/dist/hooks/useCounter.d.ts +36 -0
- package/dist/hooks/useDebounce.d.ts +31 -0
- package/dist/hooks/useDeepCompareEffect.d.ts +22 -0
- package/dist/hooks/useEventHandling.d.ts +81 -0
- package/dist/hooks/useEventListener.d.ts +19 -0
- package/dist/hooks/useLifecycle.d.ts +66 -0
- package/dist/hooks/useMediaQuery.d.ts +22 -0
- package/dist/hooks/useMutation.d.ts +47 -0
- package/dist/hooks/usePerformance.d.ts +73 -0
- package/dist/hooks/usePerformanceMonitor.d.ts +66 -0
- package/dist/hooks/usePlatform.d.ts +20 -0
- package/dist/hooks/usePrevious.d.ts +14 -0
- package/dist/hooks/useRequest.d.ts +32 -0
- package/dist/hooks/useStateManagement.d.ts +62 -0
- package/dist/hooks/useStorage.d.ts +27 -0
- package/dist/hooks/useStyle.d.ts +127 -0
- package/dist/hooks/useTheme.d.ts +58 -0
- package/dist/hooks/useToggle.d.ts +28 -0
- package/dist/hooks/useVirtualScroll.d.ts +42 -0
- package/dist/index.d.ts +271 -0
- package/dist/js/{index-DffLRSro.js → index-CDFsvu80.js} +15369 -10741
- package/dist/js/index-CDFsvu80.js.map +1 -0
- package/dist/js/index-DFdcksbe.js.map +1 -1
- package/dist/js/index-DXRIkWX1.js.map +1 -1
- package/dist/js/{index-6NJ3A1Dn.js → index-JffnTUrv.js} +15430 -10801
- package/dist/js/index-JffnTUrv.js.map +1 -0
- package/dist/platform/index.d.ts +172 -0
- package/dist/providers/AppProvider.d.ts +34 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/theme/ThemeProvider.d.ts +34 -0
- package/dist/theme/ThemeProvider.types.d.ts +21 -0
- package/dist/theme/animations.d.ts +96 -0
- package/dist/theme/defaults.d.ts +6 -0
- package/dist/theme/design-system.d.ts +400 -0
- package/dist/theme/design-tokens.d.ts +459 -0
- package/dist/theme/index.d.ts +187 -0
- package/dist/theme/responsive.d.ts +63 -0
- package/dist/theme/styles.d.ts +65 -0
- package/dist/theme/tokens/colors.d.ts +72 -0
- package/dist/theme/tokens/effects.d.ts +122 -0
- package/dist/theme/tokens/index.d.ts +94 -0
- package/dist/theme/tokens/spacing.d.ts +65 -0
- package/dist/theme/tokens/typography.d.ts +73 -0
- package/dist/theme/types.d.ts +153 -0
- package/dist/theme/useThemeUtils.d.ts +21 -0
- package/dist/theme/utils.d.ts +255 -0
- package/dist/theme/variables.d.ts +170 -0
- package/dist/types/accessibility.d.ts +46 -0
- package/dist/types/button.d.ts +285 -0
- package/dist/types/component-props.d.ts +109 -0
- package/dist/types/index.d.ts +343 -0
- package/dist/types/standardized-components.d.ts +263 -0
- package/dist/types/utils.d.ts +190 -0
- package/dist/utils/abort-controller.d.ts +19 -0
- package/dist/utils/cache.d.ts +28 -0
- package/dist/utils/createNamespace.d.ts +9 -0
- package/dist/utils/environment.d.ts +26 -0
- package/dist/utils/error-handler.d.ts +37 -0
- package/dist/utils/errorLogger.d.ts +72 -0
- package/dist/utils/formatUtils.d.ts +93 -0
- package/dist/utils/http/error-codes.d.ts +131 -0
- package/dist/utils/http/http-client.d.ts +53 -0
- package/dist/utils/http/request-cache.d.ts +65 -0
- package/dist/utils/http/request.d.ts +280 -0
- package/dist/utils/http/taro-adapter.d.ts +4 -0
- package/dist/utils/http/types.d.ts +351 -0
- package/dist/utils/http/web-adapter.d.ts +4 -0
- package/dist/utils/index.d.ts +46 -0
- package/dist/utils/inputValidator.d.ts +74 -0
- package/dist/utils/performance/performance.d.ts +167 -0
- package/dist/utils/responsiveUtils.d.ts +148 -0
- package/dist/utils/rtl-support.d.ts +78 -0
- package/dist/utils/security/api-security.d.ts +82 -0
- package/dist/utils/security/xss-protection.d.ts +20 -0
- package/dist/utils/securityHeaders.d.ts +74 -0
- package/dist/utils/typeHelpers.d.ts +1 -0
- package/dist/utils/types/dataProcessing.d.ts +111 -0
- package/dist/utils/types/typeHelpers.d.ts +50 -0
- package/dist/utils/xssProtection.d.ts +90 -0
- package/package.json +14 -10
- package/src/components/basic/Button/Button.tsx +53 -13
- package/src/components/basic/Button/Button.types.ts +45 -9
- package/src/components/basic/Divider/Divider.tsx +60 -29
- package/src/components/basic/Icon/Icon.data.ts +474 -0
- package/src/components/basic/Icon/Icon.test.tsx +2 -2
- package/src/components/basic/Icon/Icon.tsx +48 -35
- package/src/components/basic/Icon/IconManager.ts +229 -0
- package/src/components/basic/Text/Text.styles.ts +3 -3
- package/src/components/basic/Text/Text.types.ts +14 -4
- package/src/components/basic/Typography/Typography.styles.ts +10 -9
- package/src/components/basic/Typography/Typography.tsx +15 -13
- package/src/components/basic/Typography/Typography.types.ts +41 -41
- package/src/components/basic/Typography/index.tsx +1 -1
- package/src/components/basic/Video/Video.styles.ts +777 -0
- package/src/components/basic/Video/Video.test.tsx +490 -0
- package/src/components/basic/Video/Video.tsx +1468 -0
- package/src/components/basic/Video/Video.types.ts +500 -0
- package/src/components/basic/Video/index.tsx +26 -0
- package/src/components/basic/index.tsx +13 -15
- package/src/components/common/ErrorBoundary.tsx +1 -1
- package/src/components/common/LazyComponent.tsx +9 -8
- package/src/components/common/SecurityProvider.tsx +2 -14
- package/src/components/common/ThemeProvider.tsx +43 -56
- package/src/components/common/VirtualList.tsx +187 -205
- package/src/components/common/index.tsx +25 -0
- package/src/components/display/Avatar/Avatar.styles.ts +1 -1
- package/src/components/display/Avatar/Avatar.tsx +6 -19
- package/src/components/display/Avatar/Avatar.types.ts +1 -1
- package/src/components/display/Avatar/index.ts +1 -1
- package/src/components/display/Badge/Badge.tsx +3 -16
- package/src/components/display/Badge/Badge.types.ts +1 -1
- package/src/components/display/Badge/index.ts +1 -1
- package/src/components/display/Calendar/Calendar.styles.ts +36 -36
- package/src/components/display/Calendar/Calendar.test.tsx +27 -15
- package/src/components/display/Calendar/Calendar.tsx +56 -35
- package/src/components/display/Calendar/Calendar.types.ts +1 -1
- package/src/components/display/Calendar/index.ts +1 -1
- package/src/components/display/Card/Card.styles.ts +2 -2
- package/src/components/display/Card/Card.test.tsx +6 -4
- package/src/components/display/Card/Card.tsx +1 -1
- package/src/components/display/Card/Card.types.ts +4 -4
- package/src/components/display/Card/index.ts +1 -1
- package/src/components/display/Carousel/Carousel.styles.ts +31 -31
- package/src/components/display/Carousel/Carousel.tsx +34 -39
- package/src/components/display/Carousel/Carousel.types.ts +1 -1
- package/src/components/display/Carousel/index.ts +1 -1
- package/src/components/display/List/List.styles.ts +3 -3
- package/src/components/display/List/List.tsx +0 -1
- package/src/components/display/List/index.ts +1 -1
- package/src/components/display/Rate/Rate.styles.ts +5 -17
- package/src/components/display/Rate/Rate.tsx +6 -14
- package/src/components/display/Rate/Rate.types.ts +4 -3
- package/src/components/display/Rate/index.ts +3 -11
- package/src/components/display/Table/Table.test.tsx +2 -0
- package/src/components/display/Table/Table.tsx +3 -7
- package/src/components/display/Table/Table.types.ts +3 -2
- package/src/components/display/Tag/Tag.styles.ts +31 -31
- package/src/components/display/Tag/Tag.tsx +9 -26
- package/src/components/display/Tag/Tag.types.ts +1 -1
- package/src/components/display/Tag/index.ts +1 -1
- package/src/components/display/Timeline/Timeline.styles.ts +32 -32
- package/src/components/display/Timeline/Timeline.tsx +23 -42
- package/src/components/display/Timeline/Timeline.types.ts +1 -1
- package/src/components/display/Timeline/index.ts +1 -1
- package/src/components/display/index.tsx +33 -29
- package/src/components/feedback/Loading/Loading.tsx +6 -1
- package/src/components/feedback/Loading/index.ts +2 -5
- package/src/components/feedback/Message/Message.styles.ts +3 -3
- package/src/components/feedback/Message/index.ts +2 -5
- package/src/components/feedback/Modal/Modal.styles.ts +1 -1
- package/src/components/feedback/Modal/Modal.tsx +9 -31
- package/src/components/feedback/Modal/Modal.types.ts +12 -2
- package/src/components/feedback/Notification/Notification.styles.ts +49 -39
- package/src/components/feedback/Notification/Notification.test.tsx +1 -1
- package/src/components/feedback/Notification/Notification.tsx +97 -120
- package/src/components/feedback/Notification/Notification.types.ts +11 -8
- package/src/components/feedback/Notification/NotificationManager.tsx +135 -106
- package/src/components/feedback/Notification/index.ts +10 -3
- package/src/components/feedback/Notification/index.tsx +16 -26
- package/src/components/feedback/Progress/Progress.styles.ts +23 -14
- package/src/components/feedback/Progress/Progress.tsx +93 -113
- package/src/components/feedback/Progress/Progress.types.ts +1 -1
- package/src/components/feedback/Progress/index.ts +1 -1
- package/src/components/feedback/Progress/utils/animation.ts +12 -23
- package/src/components/feedback/Progress/utils/index.ts +2 -2
- package/src/components/feedback/Progress/utils/progress-calculator.ts +14 -32
- package/src/components/feedback/Result/Result.styles.ts +29 -29
- package/src/components/feedback/Result/Result.tsx +8 -20
- package/src/components/feedback/Result/Result.types.ts +7 -7
- package/src/components/feedback/Result/index.tsx +1 -1
- package/src/components/feedback/Toast/Toast.styles.ts +1 -1
- package/src/components/feedback/Toast/Toast.tsx +25 -13
- package/src/components/feedback/Tooltip/Tooltip.examples.tsx +21 -44
- package/src/components/feedback/Tooltip/Tooltip.styles.ts +16 -22
- package/src/components/feedback/Tooltip/Tooltip.test.tsx +1 -1
- package/src/components/feedback/Tooltip/Tooltip.tsx +65 -46
- package/src/components/feedback/Tooltip/Tooltip.types.ts +14 -20
- package/src/components/feedback/Tooltip/index.ts +1 -1
- package/src/components/feedback/Tooltip/index.tsx +12 -24
- package/src/components/feedback/index.tsx +54 -42
- package/src/components/form/Cascader/Cascader.styles.ts +2 -2
- package/src/components/form/Cascader/Cascader.tsx +84 -88
- package/src/components/form/Cascader/Cascader.types.ts +49 -50
- package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +11 -8
- package/src/components/form/Cascader/hooks/useCascaderOptions.ts +73 -55
- package/src/components/form/Cascader/hooks/useCascaderState.ts +31 -25
- package/src/components/form/Cascader/index.ts +1 -1
- package/src/components/form/Cascader/utils/formatDisplayValue.ts +4 -4
- package/src/components/form/Checkbox/Checkbox.styles.ts +83 -84
- package/src/components/form/Checkbox/Checkbox.tsx +2 -9
- package/src/components/form/Checkbox/CheckboxGroup.tsx +7 -7
- package/src/components/form/DatePicker/DatePicker.test.tsx +1 -1
- package/src/components/form/DatePicker/DatePicker.tsx +91 -75
- package/src/components/form/DatePicker/DatePicker.types.ts +4 -1
- package/src/components/form/Form/Form.tsx +66 -504
- package/src/components/form/Form/Form.types.ts +16 -1
- package/src/components/form/Form/useFormLogic.ts +497 -0
- package/src/components/form/Input/Input.styles.ts +8 -1
- package/src/components/form/Input/Input.tsx +55 -291
- package/src/components/form/Input/Input.types.ts +13 -1
- package/src/components/form/Input/useInputLogic.test.ts +82 -0
- package/src/components/form/Input/useInputLogic.ts +260 -0
- package/src/components/form/InputNumber/InputNumber.styles.ts +76 -25
- package/src/components/form/InputNumber/InputNumber.tsx +53 -21
- package/src/components/form/InputNumber/InputNumber.types.ts +21 -3
- package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +3 -11
- package/src/components/form/InputNumber/components/InputNumberControls.tsx +3 -12
- package/src/components/form/InputNumber/hooks/index.ts +1 -1
- package/src/components/form/InputNumber/hooks/useInputNumberState.ts +7 -9
- package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +18 -17
- package/src/components/form/InputNumber/index.ts +7 -7
- package/src/components/form/Radio/Radio.styles.ts +1 -8
- package/src/components/form/Radio/Radio.tsx +3 -9
- package/src/components/form/Radio/Radio.types.ts +5 -1
- package/src/components/form/Select/Select.styles.ts +5 -1
- package/src/components/form/Select/Select.tsx +15 -15
- package/src/components/form/Select/Select.types.ts +2 -1
- package/src/components/form/Slider/Slider.styles.ts +13 -13
- package/src/components/form/Slider/Slider.tsx +19 -33
- package/src/components/form/Slider/Slider.types.ts +14 -12
- package/src/components/form/Slider/index.tsx +2 -9
- package/src/components/form/Switch/Switch.styles.ts +1 -7
- package/src/components/form/Switch/Switch.tsx +7 -13
- package/src/components/form/Textarea/Textarea.styles.ts +4 -4
- package/src/components/form/Textarea/Textarea.tsx +7 -1
- package/src/components/form/Textarea/Textarea.types.ts +4 -1
- package/src/components/form/TimePicker/TimePicker.styles.ts +8 -12
- package/src/components/form/TimePicker/TimePicker.tsx +122 -100
- package/src/components/form/TimePicker/TimePicker.types.ts +2 -2
- package/src/components/form/TimePicker/index.ts +1 -1
- package/src/components/form/Transfer/Transfer.styles.ts +3 -15
- package/src/components/form/Transfer/Transfer.tsx +146 -134
- package/src/components/form/Transfer/Transfer.types.ts +34 -26
- package/src/components/form/Transfer/components/TransferItem.tsx +55 -62
- package/src/components/form/Transfer/components/TransferList.tsx +212 -199
- package/src/components/form/Transfer/components/TransferOperations.tsx +52 -55
- package/src/components/form/Transfer/components/TransferPagination.tsx +115 -111
- package/src/components/form/Transfer/components/TransferSearch.tsx +52 -55
- package/src/components/form/Transfer/hooks/useTransferData.ts +91 -81
- package/src/components/form/Transfer/hooks/useTransferState.ts +22 -16
- package/src/components/form/Transfer/index.ts +2 -8
- package/src/components/form/Upload/Upload.styles.ts +21 -21
- package/src/components/form/Upload/Upload.tsx +189 -142
- package/src/components/form/Upload/Upload.types.ts +31 -31
- package/src/components/form/Upload/index.tsx +1 -1
- package/src/components/form/index.tsx +60 -29
- package/src/components/index.tsx +0 -1
- package/src/components/layout/Affix/Affix.styles.ts +16 -11
- package/src/components/layout/Affix/Affix.tsx +67 -75
- package/src/components/layout/Affix/Affix.types.ts +18 -18
- package/src/components/layout/Affix/index.tsx +1 -1
- package/src/components/layout/Col/Col.styles.ts +17 -17
- package/src/components/layout/Col/Col.test.tsx +7 -5
- package/src/components/layout/Col/Col.tsx +3 -21
- package/src/components/layout/Col/Col.types.ts +1 -1
- package/src/components/layout/Container/Container.styles.ts +3 -1
- package/src/components/layout/Container/Container.tsx +2 -11
- package/src/components/layout/Grid/Grid.tsx +3 -53
- package/src/components/layout/Layout/Content.tsx +24 -32
- package/src/components/layout/Layout/Footer.tsx +24 -32
- package/src/components/layout/Layout/Header.tsx +24 -32
- package/src/components/layout/Layout/Layout.styles.ts +17 -17
- package/src/components/layout/Layout/Layout.tsx +14 -25
- package/src/components/layout/Layout/Layout.types.ts +29 -29
- package/src/components/layout/Layout/Sider.tsx +44 -56
- package/src/components/layout/Layout/index.tsx +16 -2
- package/src/components/layout/Row/Row.tsx +15 -43
- package/src/components/layout/Space/Space.tsx +3 -11
- package/src/components/layout/Space/Space.types.ts +1 -1
- package/src/components/layout/index.tsx +29 -19
- package/src/components/navigation/Menu/Menu.constants.ts +69 -0
- package/src/components/navigation/Menu/Menu.stories.tsx +107 -0
- package/src/components/navigation/Menu/Menu.styles.ts +25 -37
- package/src/components/navigation/Menu/Menu.tsx +8 -11
- package/src/components/navigation/Menu/Menu.types.ts +2 -2
- package/src/components/navigation/Menu/Menu.utils.ts +17 -17
- package/src/components/navigation/Menu/MenuItem.tsx +9 -11
- package/src/components/navigation/Menu/SubMenu.tsx +8 -6
- package/src/components/navigation/Menu/index.tsx +4 -69
- package/src/components/navigation/NavBar/NavBar.styles.ts +1 -1
- package/src/components/navigation/NavBar/NavBar.tsx +7 -10
- package/src/components/navigation/NavBar/NavBar.types.ts +3 -3
- package/src/components/navigation/NavBar/index.tsx +1 -1
- package/src/components/navigation/Pagination/Pagination.test.tsx +2 -3
- package/src/components/navigation/Pagination/Pagination.tsx +3 -3
- package/src/components/navigation/Pagination/Pagination.types.ts +3 -2
- package/src/components/navigation/Pagination/index.ts +9 -3
- package/src/components/navigation/Steps/Step.tsx +24 -44
- package/src/components/navigation/Steps/Steps.styles.ts +28 -13
- package/src/components/navigation/Steps/Steps.test.tsx +2 -0
- package/src/components/navigation/Steps/Steps.tsx +88 -89
- package/src/components/navigation/Steps/Steps.types.ts +30 -30
- package/src/components/navigation/Steps/index.tsx +1 -1
- package/src/components/navigation/Tabs/Tabs.test.tsx +3 -2
- package/src/components/navigation/Tabs/Tabs.types.ts +4 -3
- package/src/components/navigation/index.tsx +21 -16
- package/src/constants/index.ts +1 -1
- package/src/hooks/index.ts +52 -102
- package/src/hooks/types.ts +4 -5
- package/src/hooks/useAsync.ts +46 -47
- package/src/hooks/useClickOutside.ts +52 -0
- package/src/hooks/useCounter.ts +87 -0
- package/src/hooks/useDebounce.ts +150 -0
- package/src/hooks/useDeepCompareEffect.ts +88 -0
- package/src/hooks/useEventListener.ts +77 -0
- package/src/hooks/useMediaQuery.ts +75 -0
- package/src/hooks/useMutation.ts +233 -0
- package/src/hooks/usePerformance.ts +1 -64
- package/src/hooks/usePlatform.ts +3 -1
- package/src/hooks/usePrevious.ts +25 -0
- package/src/hooks/useRequest.ts +12 -7
- package/src/hooks/useStateManagement.ts +1 -1
- package/src/hooks/useStorage.ts +169 -0
- package/src/hooks/useStyle.ts +8 -2
- package/src/hooks/useToggle.ts +54 -0
- package/src/index.ts +34 -9
- package/src/theme/ThemeProvider.tsx +3 -7
- package/src/theme/ThemeProvider.types.ts +1 -1
- package/src/theme/defaults.ts +1 -1
- package/src/theme/design-system.ts +2 -2
- package/src/theme/design-tokens.ts +85 -99
- package/src/theme/generated/dark-theme.scss +1 -1
- package/src/theme/generated/tokens.scss +82 -18
- package/src/theme/index.ts +8 -29
- package/src/theme/responsive.tsx +36 -34
- package/src/theme/styles.ts +1 -1
- package/src/theme/useThemeUtils.ts +43 -43
- package/src/theme/utils.ts +32 -32
- package/src/theme/variables.ts +70 -51
- package/src/types/accessibility.ts +36 -37
- package/src/types/button.ts +25 -27
- package/src/types/component-props.ts +6 -1
- package/src/types/glob.d.ts +4 -0
- package/src/types/index.ts +2 -2
- package/src/types/standardized-components.ts +9 -3
- package/src/types/utils.ts +13 -23
- package/src/utils/__tests__/responsiveUtils.test.ts +5 -4
- package/src/utils/abort-controller.ts +48 -0
- package/src/utils/cache.ts +2 -6
- package/src/utils/createNamespace.ts +4 -4
- package/src/utils/environment.ts +26 -6
- package/src/utils/error-handler.ts +2 -2
- package/src/utils/errorLogger.ts +16 -20
- package/src/utils/formatUtils.ts +38 -70
- package/src/utils/http/error-codes.ts +314 -0
- package/src/utils/http/http-client.test.ts +63 -0
- package/src/utils/{network → http}/http-client.ts +45 -35
- package/src/utils/http/request-cache.ts +127 -0
- package/src/utils/http/request.ts +954 -0
- package/src/utils/http/taro-adapter.test.ts +74 -0
- package/src/utils/http/taro-adapter.ts +24 -0
- package/src/utils/http/types.ts +414 -0
- package/src/utils/http/web-adapter.ts +33 -0
- package/src/utils/index.ts +5 -8
- package/src/utils/inputValidator.ts +17 -14
- package/src/utils/performance/performance.ts +60 -71
- package/src/utils/responsiveUtils.ts +7 -16
- package/src/utils/rtl-support.ts +29 -19
- package/src/utils/security/api-security.ts +47 -39
- package/src/utils/securityHeaders.ts +61 -67
- package/src/utils/typeHelpers.ts +10 -10
- package/src/utils/types/dataProcessing.ts +93 -92
- package/src/utils/types/typeHelpers.ts +31 -21
- package/src/utils/xssProtection.ts +96 -48
- package/dist/js/index-6NJ3A1Dn.js.map +0 -1
- package/dist/js/index-DffLRSro.js.map +0 -1
- package/src/components/form/Input/Input.enhanced.tsx +0 -732
- package/src/components/navigation/Menu/__tests__/Menu.test.tsx +0 -687
- package/src/components/navigation/Tree/Tree.styles.ts +0 -553
- package/src/components/navigation/Tree/Tree.test.basic.tsx +0 -7
- package/src/components/navigation/Tree/Tree.test.functional.tsx +0 -496
- package/src/components/navigation/Tree/Tree.test.import.check.tsx +0 -6
- package/src/components/navigation/Tree/Tree.test.import.tsx +0 -6
- package/src/components/navigation/Tree/Tree.test.minimal.tsx +0 -5
- package/src/components/navigation/Tree/Tree.test.simple.tsx +0 -30
- package/src/components/navigation/Tree/Tree.test.tsx +0 -908
- package/src/components/navigation/Tree/Tree.test.working.tsx +0 -673
- package/src/components/navigation/Tree/Tree.tsx +0 -600
- package/src/components/navigation/Tree/Tree.types.ts +0 -909
- package/src/components/navigation/Tree/Tree.utils.ts +0 -452
- package/src/components/navigation/Tree/index.ts +0 -33
- package/src/components/navigation/Tree/index.tsx +0 -23
- package/src/utils/network/http-client.test.ts +0 -18
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用工具类型定义
|
|
3
|
+
* 提供类型安全的工具函数和类型守卫
|
|
4
|
+
*/
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
/** 可选类型 */
|
|
7
|
+
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
|
+
/** 必选类型 */
|
|
9
|
+
export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
10
|
+
/** 深度可选类型 */
|
|
11
|
+
export type DeepOptional<T> = {
|
|
12
|
+
[P in keyof T]?: T[P] extends object ? DeepOptional<T[P]> : T[P];
|
|
13
|
+
};
|
|
14
|
+
/** 深度必选类型 */
|
|
15
|
+
export type DeepRequired<T> = {
|
|
16
|
+
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
|
|
17
|
+
};
|
|
18
|
+
/** 深度只读类型 */
|
|
19
|
+
export type DeepReadonly<T> = {
|
|
20
|
+
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
21
|
+
};
|
|
22
|
+
/** 深度可写类型 */
|
|
23
|
+
export type DeepWriteable<T> = {
|
|
24
|
+
-readonly [P in keyof T]: T[P] extends object ? DeepWriteable<T[P]> : T[P];
|
|
25
|
+
};
|
|
26
|
+
/** 递归排除类型 */
|
|
27
|
+
export type RecursiveExclude<T, E> = T extends object ? {
|
|
28
|
+
[P in keyof T as T[P] extends E ? never : P]: RecursiveExclude<T[P], E>;
|
|
29
|
+
} : T;
|
|
30
|
+
/** 递归选择类型 */
|
|
31
|
+
export type RecursivePick<T, K extends string> = T extends object ? {
|
|
32
|
+
[P in keyof T as P extends K ? P : never]: RecursivePick<T[P], K>;
|
|
33
|
+
} : T;
|
|
34
|
+
/** 提取Promise返回类型 */
|
|
35
|
+
export type PromiseType<T> = T extends Promise<infer U> ? U : never;
|
|
36
|
+
/** 提取函数参数类型 */
|
|
37
|
+
export type FunctionArgs<T> = T extends (...args: infer A) => any ? A : never;
|
|
38
|
+
/** 提取函数返回类型 */
|
|
39
|
+
export type FunctionReturn<T> = T extends (...args: any) => infer R ? R : never;
|
|
40
|
+
/** 提取React组件Props类型 */
|
|
41
|
+
export type ComponentProps<T> = T extends React.ComponentType<infer P> ? P : never;
|
|
42
|
+
/** 提取React组件Ref类型 */
|
|
43
|
+
export type ComponentRef<T> = T extends React.Ref<infer R> ? R : never;
|
|
44
|
+
/** 过滤掉undefined和null的类型 */
|
|
45
|
+
export type NonNullable<T> = T extends null | undefined ? never : T;
|
|
46
|
+
/** 过滤掉falsy值的类型 */
|
|
47
|
+
export type Truthy<T> = T extends false | 0 | '' | null | undefined ? never : T;
|
|
48
|
+
/** 首字母大写 */
|
|
49
|
+
export type Capitalize<S extends string> = S extends `${infer First}${infer Rest}` ? `${Uppercase<First>}${Rest}` : S;
|
|
50
|
+
/** 首字母小写 */
|
|
51
|
+
export type Uncapitalize<S extends string> = S extends `${infer First}${infer Rest}` ? `${Lowercase<First>}${Rest}` : S;
|
|
52
|
+
/** 转换为连字符格式 */
|
|
53
|
+
export type KebabCase<S> = S extends `${infer First}${infer Rest}` ? Rest extends Uncapitalize<Rest> ? `${Lowercase<First>}${KebabCase<Rest>}` : `${Lowercase<First>}-${KebabCase<Rest>}` : S;
|
|
54
|
+
/** 转换为驼峰格式 */
|
|
55
|
+
export type CamelCase<S> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<CamelCase<Rest>>}` : S;
|
|
56
|
+
/** 合并两个对象类型 */
|
|
57
|
+
export type Merge<T, U> = Omit<T, keyof U> & U;
|
|
58
|
+
/** 深度合并两个对象类型 */
|
|
59
|
+
export type DeepMerge<T, U> = T extends object ? U extends object ? {
|
|
60
|
+
[K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? DeepMerge<T[K], U[K]> : T[K] : K extends keyof U ? U[K] : never;
|
|
61
|
+
} : T : U;
|
|
62
|
+
/** 选择对象中的部分属性 */
|
|
63
|
+
export type PickPartial<T, K extends keyof T> = Pick<T, K> & Partial<T>;
|
|
64
|
+
/** 选择对象中的必选属性 */
|
|
65
|
+
export type PickRequired<T, K extends keyof T> = Pick<T, K> & Required<Pick<T, K>>;
|
|
66
|
+
/** 数组元素类型 */
|
|
67
|
+
export type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
|
|
68
|
+
/** 过滤数组中的特定类型 */
|
|
69
|
+
export type FilterArray<T, U> = T extends [infer First, ...infer Rest] ? First extends U ? [First, ...FilterArray<Rest, U>] : FilterArray<Rest, U> : [];
|
|
70
|
+
/** 可选参数函数类型 */
|
|
71
|
+
export type OptionalArgs<T extends (...args: any) => any> = (...args: Partial<FunctionArgs<T>> & []) => FunctionReturn<T>;
|
|
72
|
+
/** 柯里化函数类型 */
|
|
73
|
+
export type Curried<T> = T extends (...args: infer A) => infer R ? A extends [infer First, ...infer Rest] ? (arg: First) => Curried<(...args: Rest) => R> : R : never;
|
|
74
|
+
/** 防抖函数类型 */
|
|
75
|
+
export type Debounced<T extends (...args: any) => any> = {
|
|
76
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
77
|
+
cancel: () => void;
|
|
78
|
+
flush: () => ReturnType<T> | undefined;
|
|
79
|
+
};
|
|
80
|
+
/** 节流函数类型 */
|
|
81
|
+
export type Throttled<T extends (...args: any) => any> = {
|
|
82
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
83
|
+
cancel: () => void;
|
|
84
|
+
};
|
|
85
|
+
/** 类型守卫:检查是否为字符串 */
|
|
86
|
+
export declare function isString(value: unknown): value is string;
|
|
87
|
+
/** 类型守卫:检查是否为数字 */
|
|
88
|
+
export declare function isNumber(value: unknown): value is number;
|
|
89
|
+
/** 类型守卫:检查是否为布尔值 */
|
|
90
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
91
|
+
/** 类型守卫:检查是否为数组 */
|
|
92
|
+
export declare function isArray<T>(value: unknown): value is T[];
|
|
93
|
+
/** 类型守卫:检查是否为对象 */
|
|
94
|
+
export declare function isObject<T extends object>(value: unknown): value is T;
|
|
95
|
+
/** 类型守卫:检查是否为函数 */
|
|
96
|
+
export declare function isFunction<T extends (...args: any) => any>(value: unknown): value is T;
|
|
97
|
+
/** 类型守卫:检查是否为Promise */
|
|
98
|
+
export declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
99
|
+
/** 类型守卫:检查是否为React元素 */
|
|
100
|
+
export declare function isReactElement(value: unknown): value is React.ReactElement;
|
|
101
|
+
/** 类型守卫:检查是否为React组件 */
|
|
102
|
+
export declare function isReactComponent<T extends React.ComponentType<any>>(value: unknown): value is T;
|
|
103
|
+
/** 类型守卫:检查是否为undefined */
|
|
104
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
105
|
+
/** 类型守卫:检查是否为null */
|
|
106
|
+
export declare function isNull(value: unknown): value is null;
|
|
107
|
+
/** 类型守卫:检查是否为空值 */
|
|
108
|
+
export declare function isEmpty(value: unknown): value is null | undefined | '' | 0 | false;
|
|
109
|
+
/** 类型守卫:检查是否为非空值 */
|
|
110
|
+
export declare function isNotEmpty<T>(value: T | null | undefined): value is T;
|
|
111
|
+
/** 验证结果类型 */
|
|
112
|
+
export type ValidationResult<T> = {
|
|
113
|
+
success: true;
|
|
114
|
+
data: T;
|
|
115
|
+
} | {
|
|
116
|
+
success: false;
|
|
117
|
+
error: string;
|
|
118
|
+
};
|
|
119
|
+
/** 验证函数类型 */
|
|
120
|
+
export type Validator<T> = (value: unknown) => ValidationResult<T>;
|
|
121
|
+
/** 创建验证器 */
|
|
122
|
+
export declare function createValidator<T>(validate: (value: unknown) => value is T, errorMessage?: string): Validator<T>;
|
|
123
|
+
/** 通用事件处理器类型 */
|
|
124
|
+
export type EventHandler<T = any> = (event: T) => void;
|
|
125
|
+
/** 阻止默认行为的事件处理器 */
|
|
126
|
+
export type PreventDefaultHandler<T = any> = (event: T) => void;
|
|
127
|
+
/** 停止传播的事件处理器 */
|
|
128
|
+
export type StopPropagationHandler<T = any> = (event: T) => void;
|
|
129
|
+
/** 创建阻止默认行为的事件处理器 */
|
|
130
|
+
export declare function createPreventDefaultHandler<T extends {
|
|
131
|
+
preventDefault: () => void;
|
|
132
|
+
}>(handler: EventHandler<T>): PreventDefaultHandler<T>;
|
|
133
|
+
/** 创建停止传播的事件处理器 */
|
|
134
|
+
export declare function createStopPropagationHandler<T extends {
|
|
135
|
+
stopPropagation: () => void;
|
|
136
|
+
}>(handler: EventHandler<T>): StopPropagationHandler<T>;
|
|
137
|
+
/** CSS属性类型 */
|
|
138
|
+
export type CSSProperties = React.CSSProperties;
|
|
139
|
+
/** 样式对象类型 */
|
|
140
|
+
export type StyleObject = CSSProperties;
|
|
141
|
+
/** 类名类型 */
|
|
142
|
+
export type ClassName = string | string[] | {
|
|
143
|
+
[key: string]: boolean;
|
|
144
|
+
} | undefined;
|
|
145
|
+
/** 合并类名 */
|
|
146
|
+
export declare function classNames(...classes: ClassName[]): string;
|
|
147
|
+
/** 合并样式对象 */
|
|
148
|
+
export declare function mergeStyles(...styles: (StyleObject | undefined)[]): StyleObject;
|
|
149
|
+
/** 异步状态类型 */
|
|
150
|
+
export type AsyncState<T> = {
|
|
151
|
+
status: 'idle';
|
|
152
|
+
} | {
|
|
153
|
+
status: 'loading';
|
|
154
|
+
} | {
|
|
155
|
+
status: 'success';
|
|
156
|
+
data: T;
|
|
157
|
+
} | {
|
|
158
|
+
status: 'error';
|
|
159
|
+
error: string;
|
|
160
|
+
};
|
|
161
|
+
/** 异步操作类型 */
|
|
162
|
+
export type AsyncOperation<T> = Promise<T> & {
|
|
163
|
+
cancel: () => void;
|
|
164
|
+
};
|
|
165
|
+
/** 创建可取消的Promise */
|
|
166
|
+
export declare function createCancellablePromise<T>(promise: Promise<T>): AsyncOperation<T>;
|
|
167
|
+
/** 通用键值对类型 */
|
|
168
|
+
export type KeyValuePair<K = string, V = any> = [K, V];
|
|
169
|
+
/** 通用记录类型 */
|
|
170
|
+
export type RecordType<K extends string, V> = Record<K, V>;
|
|
171
|
+
/** 通用映射类型 */
|
|
172
|
+
export type MapType<K, V> = Map<K, V>;
|
|
173
|
+
/** 通用集合类型 */
|
|
174
|
+
export type SetType<T> = Set<T>;
|
|
175
|
+
/** 类型安全的Object.keys */
|
|
176
|
+
export declare function keys<T extends object>(obj: T): (keyof T)[];
|
|
177
|
+
/** 类型安全的Object.values */
|
|
178
|
+
export declare function values<T extends object>(obj: T): T[keyof T][];
|
|
179
|
+
/** 类型安全的Object.entries */
|
|
180
|
+
export declare function entries<T extends object>(obj: T): [keyof T, T[keyof T]][];
|
|
181
|
+
/** 类型安全的Object.fromEntries */
|
|
182
|
+
export declare function fromEntries<K extends string, V>(entries: [K, V][]): Record<K, V>;
|
|
183
|
+
/** 推断数组元素类型 */
|
|
184
|
+
export type InferArray<T> = T extends (infer U)[] ? U : never;
|
|
185
|
+
/** 推断Promise返回类型 */
|
|
186
|
+
export type InferPromise<T> = T extends Promise<infer U> ? U : never;
|
|
187
|
+
/** 推断函数参数类型 */
|
|
188
|
+
export type InferArgs<T> = T extends (...args: infer A) => any ? A : never;
|
|
189
|
+
/** 推断函数返回类型 */
|
|
190
|
+
export type InferReturn<T> = T extends (...args: any) => infer R ? R : never;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface AbortSignal {
|
|
2
|
+
aborted: boolean;
|
|
3
|
+
onabort?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export interface CompatibleAbortController {
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
abort: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 创建兼容的 AbortController
|
|
11
|
+
* 在支持原生 AbortController 的环境中使用原生实现
|
|
12
|
+
* 在小程序等环境中使用模拟实现
|
|
13
|
+
*/
|
|
14
|
+
export declare function createAbortController(): CompatibleAbortController;
|
|
15
|
+
/**
|
|
16
|
+
* 判断是否支持原生 AbortController
|
|
17
|
+
*/
|
|
18
|
+
export declare function isAbortControllerSupported(): boolean;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 简单的数据缓存工具
|
|
3
|
+
*/
|
|
4
|
+
interface CacheOptions {
|
|
5
|
+
ttl?: number;
|
|
6
|
+
retries?: number;
|
|
7
|
+
}
|
|
8
|
+
declare class DataCache {
|
|
9
|
+
private cache;
|
|
10
|
+
/**
|
|
11
|
+
* 获取缓存数据或执行获取函数
|
|
12
|
+
*/
|
|
13
|
+
fetch<T>(key: string, fetcher: () => Promise<T>, options?: CacheOptions): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* 使缓存失效
|
|
16
|
+
*/
|
|
17
|
+
invalidate(key: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* 清空所有缓存
|
|
20
|
+
*/
|
|
21
|
+
clear(): void;
|
|
22
|
+
/**
|
|
23
|
+
* 获取缓存大小
|
|
24
|
+
*/
|
|
25
|
+
size(): number;
|
|
26
|
+
}
|
|
27
|
+
export declare const dataFetcher: DataCache;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Platform } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Detect whether code executes in a browser-like environment.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isBrowserEnvironment: () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Detect whether Taro runtime is available (mini-program / native bridge).
|
|
8
|
+
*/
|
|
9
|
+
export declare const isTaroEnvironment: () => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the current platform in a resilient manner.
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolvePlatform: () => Platform | "unknown";
|
|
14
|
+
/**
|
|
15
|
+
* Safe local storage wrapper guarding non-browser runtimes and incomplete localStorage implementations.
|
|
16
|
+
*/
|
|
17
|
+
export declare const safeLocalStorage: {
|
|
18
|
+
getItem(key: string): string | null;
|
|
19
|
+
setItem(key: string, value: string): void;
|
|
20
|
+
removeItem(key: string): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Guarded matchMedia helper for SSR / mini-program runtimes.
|
|
25
|
+
*/
|
|
26
|
+
export declare const safeMatchMedia: (query: string) => MediaQueryList | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 简单的错误处理工具
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ErrorType {
|
|
5
|
+
NETWORK = "NETWORK",
|
|
6
|
+
VALIDATION = "VALIDATION",
|
|
7
|
+
AUTHORIZATION = "AUTHORIZATION",
|
|
8
|
+
SERVER = "SERVER",
|
|
9
|
+
UNKNOWN = "UNKNOWN"
|
|
10
|
+
}
|
|
11
|
+
export declare enum ErrorSeverity {
|
|
12
|
+
LOW = "LOW",
|
|
13
|
+
MEDIUM = "MEDIUM",
|
|
14
|
+
HIGH = "HIGH",
|
|
15
|
+
CRITICAL = "CRITICAL"
|
|
16
|
+
}
|
|
17
|
+
export interface AppError extends Error {
|
|
18
|
+
type: ErrorType;
|
|
19
|
+
severity: ErrorSeverity;
|
|
20
|
+
code?: string;
|
|
21
|
+
details?: unknown;
|
|
22
|
+
}
|
|
23
|
+
declare class ErrorHandler {
|
|
24
|
+
private static instance;
|
|
25
|
+
private constructor();
|
|
26
|
+
static getInstance(): ErrorHandler;
|
|
27
|
+
createError(message: string, type?: ErrorType, severity?: ErrorSeverity, code?: string, details?: unknown): AppError;
|
|
28
|
+
createNetworkError(message: string, code?: string): AppError;
|
|
29
|
+
createValidationError(message: string, code?: string): AppError;
|
|
30
|
+
createAuthorizationError(message: string, code?: string): AppError;
|
|
31
|
+
createServerError(message: string, code?: string): AppError;
|
|
32
|
+
handleError(error: Error | AppError): void;
|
|
33
|
+
private isAppError;
|
|
34
|
+
}
|
|
35
|
+
export declare const ErrorHandlingManager: typeof ErrorHandler;
|
|
36
|
+
export declare const errorHandler: ErrorHandler;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 错误日志记录工具
|
|
3
|
+
* 提供统一的错误记录和上报功能
|
|
4
|
+
*/
|
|
5
|
+
interface ErrorLog {
|
|
6
|
+
timestamp: string;
|
|
7
|
+
message: string;
|
|
8
|
+
stack?: string | undefined;
|
|
9
|
+
componentStack?: string | null | undefined;
|
|
10
|
+
type: 'error' | 'warning' | 'info';
|
|
11
|
+
userAgent?: string | undefined;
|
|
12
|
+
url?: string | undefined;
|
|
13
|
+
userId?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare class ErrorLogger {
|
|
16
|
+
private logs;
|
|
17
|
+
private maxLogs;
|
|
18
|
+
/**
|
|
19
|
+
* 记录错误
|
|
20
|
+
* @param error 错误对象
|
|
21
|
+
* @param errorInfo React错误信息
|
|
22
|
+
* @param type 日志类型
|
|
23
|
+
*/
|
|
24
|
+
log(error: Error, errorInfo?: React.ErrorInfo, type?: ErrorLog['type']): void;
|
|
25
|
+
/**
|
|
26
|
+
* 记录普通消息
|
|
27
|
+
* @param message 消息内容
|
|
28
|
+
* @param type 日志类型
|
|
29
|
+
*/
|
|
30
|
+
logMessage(message: string, type?: ErrorLog['type']): void;
|
|
31
|
+
/**
|
|
32
|
+
* 添加日志到本地存储
|
|
33
|
+
* @param log 日志对象
|
|
34
|
+
*/
|
|
35
|
+
private addLog;
|
|
36
|
+
/**
|
|
37
|
+
* 保存日志到本地存储
|
|
38
|
+
*/
|
|
39
|
+
private saveToLocalStorage;
|
|
40
|
+
/**
|
|
41
|
+
* 从本地存储加载日志
|
|
42
|
+
*/
|
|
43
|
+
private loadFromLocalStorage;
|
|
44
|
+
/**
|
|
45
|
+
* 上报错误到服务器
|
|
46
|
+
* @param log 日志对象
|
|
47
|
+
*/
|
|
48
|
+
private reportToServer;
|
|
49
|
+
/**
|
|
50
|
+
* 获取用户ID(如果有)
|
|
51
|
+
*/
|
|
52
|
+
private getUserId;
|
|
53
|
+
/**
|
|
54
|
+
* 获取所有日志
|
|
55
|
+
*/
|
|
56
|
+
getLogs(): ErrorLog[];
|
|
57
|
+
/**
|
|
58
|
+
* 清除所有日志
|
|
59
|
+
*/
|
|
60
|
+
clearLogs(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 初始化错误日志记录器
|
|
63
|
+
*/
|
|
64
|
+
init(): void;
|
|
65
|
+
}
|
|
66
|
+
declare const errorLogger: ErrorLogger;
|
|
67
|
+
export declare const logError: (error: Error, errorInfo?: React.ErrorInfo) => void;
|
|
68
|
+
export declare const logWarning: (message: string) => void;
|
|
69
|
+
export declare const logInfo: (message: string) => void;
|
|
70
|
+
export declare const getErrorLogs: () => ErrorLog[];
|
|
71
|
+
export declare const clearErrorLogs: () => void;
|
|
72
|
+
export default errorLogger;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化工具函数库
|
|
3
|
+
* 提供通用的格式化逻辑,包括日期、时间、货币、数字等格式化
|
|
4
|
+
*/
|
|
5
|
+
interface DateFormatOptions {
|
|
6
|
+
format?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
timezone?: string;
|
|
9
|
+
}
|
|
10
|
+
/** 日期时间格式化工具类 */
|
|
11
|
+
export declare class DateTimeFormatUtils {
|
|
12
|
+
/** 格式化日期 */
|
|
13
|
+
static formatDate(date: Date | string | number, options?: DateFormatOptions): string;
|
|
14
|
+
/** 相对时间格式化 */
|
|
15
|
+
static formatRelativeTime(date: Date | string | number, locale?: string): string;
|
|
16
|
+
/** 获取时间段描述 */
|
|
17
|
+
static getTimeOfDay(hours: number): string;
|
|
18
|
+
/** 格式化时间段 */
|
|
19
|
+
static formatTimeRange(start: Date | string, end: Date | string): string;
|
|
20
|
+
/** 获取星期几 */
|
|
21
|
+
static getWeekday(date: Date | string | number, locale?: string): string;
|
|
22
|
+
/** 检查是否为今天 */
|
|
23
|
+
static isToday(date: Date | string | number): boolean;
|
|
24
|
+
/** 检查是否为昨天 */
|
|
25
|
+
static isYesterday(date: Date | string | number): boolean;
|
|
26
|
+
/** 检查是否为明天 */
|
|
27
|
+
static isTomorrow(date: Date | string | number): boolean;
|
|
28
|
+
}
|
|
29
|
+
interface NumberFormatOptions {
|
|
30
|
+
locale?: string;
|
|
31
|
+
style?: 'decimal' | 'currency' | 'percent' | 'unit';
|
|
32
|
+
currency?: string;
|
|
33
|
+
minimumFractionDigits?: number;
|
|
34
|
+
maximumFractionDigits?: number;
|
|
35
|
+
minimumIntegerDigits?: number;
|
|
36
|
+
useGrouping?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** 数字格式化工具类 */
|
|
39
|
+
export declare class NumberFormatUtils {
|
|
40
|
+
/** 格式化数字 */
|
|
41
|
+
static formatNumber(num: number, options?: NumberFormatOptions): string;
|
|
42
|
+
/** 格式化货币 */
|
|
43
|
+
static formatCurrency(amount: number, currency?: string, locale?: string): string;
|
|
44
|
+
/** 格式化百分比 */
|
|
45
|
+
static formatPercent(value: number, decimals?: number, locale?: string): string;
|
|
46
|
+
/** 格式化文件大小 */
|
|
47
|
+
static formatFileSize(bytes: number, decimals?: number, locale?: string): string;
|
|
48
|
+
/** 格式化数字缩写 */
|
|
49
|
+
static formatNumberAbbreviation(num: number, decimals?: number, locale?: string): string;
|
|
50
|
+
/** 格式化序数 */
|
|
51
|
+
static formatOrdinal(num: number, locale?: string): string;
|
|
52
|
+
/** 格式化科学计数法 */
|
|
53
|
+
static formatScientific(num: number, precision?: number): string;
|
|
54
|
+
/** 格式化罗马数字 */
|
|
55
|
+
static formatRoman(num: number): string;
|
|
56
|
+
}
|
|
57
|
+
/** 字符串格式化工具类 */
|
|
58
|
+
export declare class StringFormatUtils {
|
|
59
|
+
/** 首字母大写 */
|
|
60
|
+
static capitalize(str: string): string;
|
|
61
|
+
/** 驼峰命名转下划线命名 */
|
|
62
|
+
static camelToSnake(str: string): string;
|
|
63
|
+
/** 下划线命名转驼峰命名 */
|
|
64
|
+
static snakeToCamel(str: string): string;
|
|
65
|
+
/** 中划线命名转驼峰命名 */
|
|
66
|
+
static kebabToCamel(str: string): string;
|
|
67
|
+
/** 驼峰命名转中划线命名 */
|
|
68
|
+
static camelToKebab(str: string): string;
|
|
69
|
+
/** 格式化手机号 */
|
|
70
|
+
static formatPhone(phone: string, separator?: string): string;
|
|
71
|
+
/** 格式化身份证号 */
|
|
72
|
+
static formatIdCard(idCard: string): string;
|
|
73
|
+
/** 格式化银行卡号 */
|
|
74
|
+
static formatBankCard(cardNumber: string, separator?: string): string;
|
|
75
|
+
/** 截断字符串 */
|
|
76
|
+
static truncate(str: string, length: number, suffix?: string): string;
|
|
77
|
+
/** 高亮关键词 */
|
|
78
|
+
static highlightKeywords(text: string, keywords: string[], highlightClass?: string): string;
|
|
79
|
+
/** 移除HTML标签 */
|
|
80
|
+
static stripHtml(html: string): string;
|
|
81
|
+
/** 转义HTML特殊字符 */
|
|
82
|
+
static escapeHtml(text: string): string;
|
|
83
|
+
/** 反转义HTML特殊字符 */
|
|
84
|
+
static unescapeHtml(html: string): string;
|
|
85
|
+
/** 生成UUID */
|
|
86
|
+
static generateUUID(): string;
|
|
87
|
+
/** 格式化模板字符串 */
|
|
88
|
+
static template(template: string, data: Record<string, any>, delimiter?: string): string;
|
|
89
|
+
}
|
|
90
|
+
export declare const dateTimeFormat: typeof DateTimeFormatUtils;
|
|
91
|
+
export declare const numberFormat: typeof NumberFormatUtils;
|
|
92
|
+
export declare const stringFormat: typeof StringFormatUtils;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一错误码规范
|
|
3
|
+
* 提供完整的错误码定义和错误信息映射
|
|
4
|
+
*/
|
|
5
|
+
/** 错误码类型 */
|
|
6
|
+
export declare enum ErrorCode {
|
|
7
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
8
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
9
|
+
CANCEL_ERROR = "CANCEL_ERROR",
|
|
10
|
+
INVALID_URL = "INVALID_URL",
|
|
11
|
+
INSECURE_URL = "INSECURE_URL",
|
|
12
|
+
HTTP_400 = "HTTP_400",
|
|
13
|
+
HTTP_401 = "HTTP_401",
|
|
14
|
+
HTTP_403 = "HTTP_403",
|
|
15
|
+
HTTP_404 = "HTTP_404",
|
|
16
|
+
HTTP_405 = "HTTP_405",
|
|
17
|
+
HTTP_408 = "HTTP_408",
|
|
18
|
+
HTTP_409 = "HTTP_409",
|
|
19
|
+
HTTP_410 = "HTTP_410",
|
|
20
|
+
HTTP_422 = "HTTP_422",
|
|
21
|
+
HTTP_429 = "HTTP_429",
|
|
22
|
+
HTTP_500 = "HTTP_500",
|
|
23
|
+
HTTP_501 = "HTTP_501",
|
|
24
|
+
HTTP_502 = "HTTP_502",
|
|
25
|
+
HTTP_503 = "HTTP_503",
|
|
26
|
+
HTTP_504 = "HTTP_504",
|
|
27
|
+
HTTP_505 = "HTTP_505",
|
|
28
|
+
BUSINESS_ERROR = "BUSINESS_ERROR",
|
|
29
|
+
INVALID_PARAMS = "INVALID_PARAMS",
|
|
30
|
+
INVALID_REQUEST = "INVALID_REQUEST",
|
|
31
|
+
DATA_NOT_FOUND = "DATA_NOT_FOUND",
|
|
32
|
+
DATA_CONFLICT = "DATA_CONFLICT",
|
|
33
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
34
|
+
USER_NOT_LOGGED_IN = "USER_NOT_LOGGED_IN",
|
|
35
|
+
USER_SESSION_EXPIRED = "USER_SESSION_EXPIRED",
|
|
36
|
+
USER_TOKEN_INVALID = "USER_TOKEN_INVALID",
|
|
37
|
+
INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
|
|
38
|
+
SYSTEM_ERROR = "SYSTEM_ERROR",
|
|
39
|
+
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
|
|
40
|
+
DATABASE_ERROR = "DATABASE_ERROR",
|
|
41
|
+
CACHE_ERROR = "CACHE_ERROR",
|
|
42
|
+
SECURITY_ERROR = "SECURITY_ERROR",
|
|
43
|
+
XSS_ATTACK = "XSS_ATTACK",
|
|
44
|
+
CSRF_ATTACK = "CSRF_ATTACK",
|
|
45
|
+
SQL_INJECTION = "SQL_INJECTION",
|
|
46
|
+
INVALID_SIGNATURE = "INVALID_SIGNATURE",
|
|
47
|
+
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
48
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
49
|
+
UNEXPECTED_ERROR = "UNEXPECTED_ERROR",
|
|
50
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
51
|
+
FEATURE_DISABLED = "FEATURE_DISABLED"
|
|
52
|
+
}
|
|
53
|
+
/** 错误信息映射 */
|
|
54
|
+
export declare const ERROR_MESSAGES: Record<ErrorCode, string>;
|
|
55
|
+
/** 错误严重程度 */
|
|
56
|
+
export declare enum ErrorSeverity {
|
|
57
|
+
LOW = "LOW",
|
|
58
|
+
MEDIUM = "MEDIUM",
|
|
59
|
+
HIGH = "HIGH",
|
|
60
|
+
CRITICAL = "CRITICAL"
|
|
61
|
+
}
|
|
62
|
+
/** 错误严重程度映射 */
|
|
63
|
+
export declare const ERROR_SEVERITY: Record<ErrorCode, ErrorSeverity>;
|
|
64
|
+
/** 错误码工具函数 */
|
|
65
|
+
export declare const ErrorCodeUtils: {
|
|
66
|
+
/**
|
|
67
|
+
* 根据HTTP状态码获取对应的错误码
|
|
68
|
+
*/
|
|
69
|
+
fromHttpStatus(statusCode: number): ErrorCode;
|
|
70
|
+
/**
|
|
71
|
+
* 获取错误信息
|
|
72
|
+
*/
|
|
73
|
+
getErrorMessage(code: ErrorCode, customMessage?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* 获取错误严重程度
|
|
76
|
+
*/
|
|
77
|
+
getSeverity(code: ErrorCode): ErrorSeverity;
|
|
78
|
+
/**
|
|
79
|
+
* 检查错误是否为网络错误
|
|
80
|
+
*/
|
|
81
|
+
isNetworkError(code: ErrorCode): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* 检查错误是否为认证错误
|
|
84
|
+
*/
|
|
85
|
+
isAuthError(code: ErrorCode): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 检查错误是否为系统错误
|
|
88
|
+
*/
|
|
89
|
+
isSystemError(code: ErrorCode): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* 检查错误是否为业务错误
|
|
92
|
+
*/
|
|
93
|
+
isBusinessError(code: ErrorCode): boolean;
|
|
94
|
+
};
|
|
95
|
+
declare const _default: {
|
|
96
|
+
ErrorCode: typeof ErrorCode;
|
|
97
|
+
ERROR_MESSAGES: Record<ErrorCode, string>;
|
|
98
|
+
ErrorSeverity: typeof ErrorSeverity;
|
|
99
|
+
ERROR_SEVERITY: Record<ErrorCode, ErrorSeverity>;
|
|
100
|
+
ErrorCodeUtils: {
|
|
101
|
+
/**
|
|
102
|
+
* 根据HTTP状态码获取对应的错误码
|
|
103
|
+
*/
|
|
104
|
+
fromHttpStatus(statusCode: number): ErrorCode;
|
|
105
|
+
/**
|
|
106
|
+
* 获取错误信息
|
|
107
|
+
*/
|
|
108
|
+
getErrorMessage(code: ErrorCode, customMessage?: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* 获取错误严重程度
|
|
111
|
+
*/
|
|
112
|
+
getSeverity(code: ErrorCode): ErrorSeverity;
|
|
113
|
+
/**
|
|
114
|
+
* 检查错误是否为网络错误
|
|
115
|
+
*/
|
|
116
|
+
isNetworkError(code: ErrorCode): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* 检查错误是否为认证错误
|
|
119
|
+
*/
|
|
120
|
+
isAuthError(code: ErrorCode): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* 检查错误是否为系统错误
|
|
123
|
+
*/
|
|
124
|
+
isSystemError(code: ErrorCode): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* 检查错误是否为业务错误
|
|
127
|
+
*/
|
|
128
|
+
isBusinessError(code: ErrorCode): boolean;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IRequestAdapter } from './types';
|
|
2
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
3
|
+
export interface RequestOptions {
|
|
4
|
+
method?: HttpMethod;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
params?: Record<string, any>;
|
|
7
|
+
data?: any;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
retries?: number;
|
|
10
|
+
retryDelay?: number;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HttpClientConfig {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
adapter?: IRequestAdapter;
|
|
17
|
+
}
|
|
18
|
+
interface RequestConfig {
|
|
19
|
+
method: HttpMethod;
|
|
20
|
+
url: string;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
data?: any;
|
|
23
|
+
}
|
|
24
|
+
interface ResponseData {
|
|
25
|
+
status: number;
|
|
26
|
+
ok: boolean;
|
|
27
|
+
headers: Headers | Record<string, string>;
|
|
28
|
+
data: any;
|
|
29
|
+
}
|
|
30
|
+
type RequestInterceptor = (_config: RequestConfig) => RequestConfig;
|
|
31
|
+
type ResponseInterceptor = (_response: ResponseData) => ResponseData;
|
|
32
|
+
export declare class HttpClient {
|
|
33
|
+
private baseUrl;
|
|
34
|
+
private defaultHeaders;
|
|
35
|
+
private errorManager;
|
|
36
|
+
private security;
|
|
37
|
+
private requestInterceptors;
|
|
38
|
+
private responseInterceptors;
|
|
39
|
+
private adapter;
|
|
40
|
+
constructor(config?: HttpClientConfig);
|
|
41
|
+
private getDefaultAdapter;
|
|
42
|
+
addRequestInterceptor(interceptor: RequestInterceptor): void;
|
|
43
|
+
addResponseInterceptor(interceptor: ResponseInterceptor): void;
|
|
44
|
+
request<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
45
|
+
get<T>(url: string, options?: Omit<RequestOptions, 'method' | 'data'>): Promise<T>;
|
|
46
|
+
post<T>(url: string, data?: any, options?: Omit<RequestOptions, 'method' | 'data'>): Promise<T>;
|
|
47
|
+
put<T>(url: string, data?: any, options?: Omit<RequestOptions, 'method' | 'data'>): Promise<T>;
|
|
48
|
+
patch<T>(url: string, data?: any, options?: Omit<RequestOptions, 'method' | 'data'>): Promise<T>;
|
|
49
|
+
delete<T>(url: string, options?: Omit<RequestOptions, 'method' | 'data'>): Promise<T>;
|
|
50
|
+
private buildUrl;
|
|
51
|
+
}
|
|
52
|
+
export declare const httpClient: HttpClient;
|
|
53
|
+
export default HttpClient;
|