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,562 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button组件专用类型定义
|
|
3
|
+
* 提供类型安全的Button组件相关类型和工具函数
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import type { ITouchEvent } from '@tarojs/components';
|
|
8
|
+
import {
|
|
9
|
+
Validator,
|
|
10
|
+
createValidator,
|
|
11
|
+
isString,
|
|
12
|
+
isNumber,
|
|
13
|
+
isBoolean,
|
|
14
|
+
isFunction,
|
|
15
|
+
isReactElement,
|
|
16
|
+
classNames,
|
|
17
|
+
} from './utils';
|
|
18
|
+
|
|
19
|
+
// ==================== Button基础类型 ====================
|
|
20
|
+
|
|
21
|
+
/** 按钮尺寸类型 */
|
|
22
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
23
|
+
|
|
24
|
+
/** 按钮类型 */
|
|
25
|
+
export type ButtonType = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info';
|
|
26
|
+
|
|
27
|
+
/** 按钮变体 */
|
|
28
|
+
export type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'text';
|
|
29
|
+
|
|
30
|
+
/** 按钮形状 */
|
|
31
|
+
export type ButtonShape = 'default' | 'rounded' | 'circle' | 'square';
|
|
32
|
+
|
|
33
|
+
/** 按钮状态 */
|
|
34
|
+
export type ButtonStatus = 'normal' | 'loading' | 'disabled' | 'active';
|
|
35
|
+
|
|
36
|
+
/** 按钮图标位置 */
|
|
37
|
+
export type ButtonIconPosition = 'left' | 'right';
|
|
38
|
+
|
|
39
|
+
/** 按钮原生属性类型 */
|
|
40
|
+
export type ButtonNativeProps = Omit<
|
|
41
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
42
|
+
'size' | 'type' | 'onClick'
|
|
43
|
+
>;
|
|
44
|
+
|
|
45
|
+
// ==================== Button属性类型 ====================
|
|
46
|
+
|
|
47
|
+
/** 按钮组件属性接口 */
|
|
48
|
+
export interface ButtonProps extends ButtonNativeProps {
|
|
49
|
+
/** 按钮内容 */
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/** 按钮尺寸 */
|
|
52
|
+
size?: ButtonSize;
|
|
53
|
+
/** 按钮类型 */
|
|
54
|
+
type?: ButtonType;
|
|
55
|
+
/** 按钮变体 */
|
|
56
|
+
variant?: ButtonVariant;
|
|
57
|
+
/** 按钮形状 */
|
|
58
|
+
shape?: ButtonShape;
|
|
59
|
+
/** 按钮状态 */
|
|
60
|
+
status?: ButtonStatus;
|
|
61
|
+
/** 是否块级显示 */
|
|
62
|
+
block?: boolean;
|
|
63
|
+
/** 是否危险操作 */
|
|
64
|
+
danger?: boolean;
|
|
65
|
+
/** 是否显示加载状态 */
|
|
66
|
+
loading?: boolean;
|
|
67
|
+
/** 是否禁用 */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** 图标 */
|
|
70
|
+
icon?: ReactNode;
|
|
71
|
+
/** 图标位置 */
|
|
72
|
+
iconPosition?: ButtonIconPosition;
|
|
73
|
+
/** 自定义样式类名 */
|
|
74
|
+
className?: string;
|
|
75
|
+
/** 点击事件处理函数 */
|
|
76
|
+
onClick?: (event: ITouchEvent) => void;
|
|
77
|
+
/** 按下事件处理函数 */
|
|
78
|
+
onPressIn?: (event: ITouchEvent) => void;
|
|
79
|
+
/** 按起事件处理函数 */
|
|
80
|
+
onPressOut?: (event: ITouchEvent) => void;
|
|
81
|
+
/** 长按事件处理函数 */
|
|
82
|
+
onLongPress?: (event: ITouchEvent) => void;
|
|
83
|
+
/** 自定义按钮样式 */
|
|
84
|
+
style?: React.CSSProperties;
|
|
85
|
+
/** 加载状态文字 */
|
|
86
|
+
loadingText?: string;
|
|
87
|
+
/** 是否显示涟漪效果 */
|
|
88
|
+
ripple?: boolean;
|
|
89
|
+
/** 是否显示阴影 */
|
|
90
|
+
shadow?: boolean;
|
|
91
|
+
/** 是否有边框 */
|
|
92
|
+
bordered?: boolean;
|
|
93
|
+
/** 按钮组中的索引位置 */
|
|
94
|
+
groupIndex?: number;
|
|
95
|
+
/** 按钮组中的总数 */
|
|
96
|
+
groupSize?: number;
|
|
97
|
+
/** 自定义主题颜色 */
|
|
98
|
+
color?: string;
|
|
99
|
+
/** 背景颜色 */
|
|
100
|
+
backgroundColor?: string;
|
|
101
|
+
/** 文字颜色 */
|
|
102
|
+
textColor?: string;
|
|
103
|
+
/** 边框颜色 */
|
|
104
|
+
borderColor?: string;
|
|
105
|
+
/** 动画持续时间 */
|
|
106
|
+
animationDuration?: number;
|
|
107
|
+
/** 是否启用无障碍访问 */
|
|
108
|
+
accessible?: boolean;
|
|
109
|
+
/** 无障碍标签 */
|
|
110
|
+
accessibilityLabel?: string;
|
|
111
|
+
/** 无障碍角色 */
|
|
112
|
+
accessibilityRole?: string;
|
|
113
|
+
/** 无障碍状态 */
|
|
114
|
+
accessibilityState?: {
|
|
115
|
+
disabled?: boolean;
|
|
116
|
+
selected?: boolean;
|
|
117
|
+
busy?: boolean;
|
|
118
|
+
expanded?: boolean;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ==================== Button引用类型 ====================
|
|
123
|
+
|
|
124
|
+
/** 按钮组件引用类型 */
|
|
125
|
+
export interface ButtonRef {
|
|
126
|
+
/** 按钮元素 */
|
|
127
|
+
element: HTMLButtonElement | null;
|
|
128
|
+
/** 触发点击事件 */
|
|
129
|
+
click: () => void;
|
|
130
|
+
/** 设置禁用状态 */
|
|
131
|
+
setDisabled: (disabled: boolean) => void;
|
|
132
|
+
/** 设置加载状态 */
|
|
133
|
+
setLoading: (loading: boolean) => void;
|
|
134
|
+
/** 获取按钮状态 */
|
|
135
|
+
getStatus: () => ButtonStatus;
|
|
136
|
+
/** 获取按钮尺寸 */
|
|
137
|
+
getSize: () => ButtonSize;
|
|
138
|
+
/** 获取按钮类型 */
|
|
139
|
+
getType: () => ButtonType;
|
|
140
|
+
/** 获取按钮变体 */
|
|
141
|
+
getVariant: () => ButtonVariant;
|
|
142
|
+
/** 获取按钮形状 */
|
|
143
|
+
getShape: () => ButtonShape;
|
|
144
|
+
/** 聚焦按钮 */
|
|
145
|
+
focus: () => void;
|
|
146
|
+
/** 失焦按钮 */
|
|
147
|
+
blur: () => void;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ==================== Button组类型 ====================
|
|
151
|
+
|
|
152
|
+
/** 按钮组属性接口 */
|
|
153
|
+
export interface ButtonGroupProps {
|
|
154
|
+
/** 按钮组内容 */
|
|
155
|
+
children: ReactNode;
|
|
156
|
+
/** 按钮组尺寸 */
|
|
157
|
+
size?: ButtonSize;
|
|
158
|
+
/** 按钮组类型 */
|
|
159
|
+
type?: ButtonType;
|
|
160
|
+
/** 按钮组变体 */
|
|
161
|
+
variant?: ButtonVariant;
|
|
162
|
+
/** 按钮组形状 */
|
|
163
|
+
shape?: ButtonShape;
|
|
164
|
+
/** 按钮组状态 */
|
|
165
|
+
status?: ButtonStatus;
|
|
166
|
+
/** 按钮组是否块级显示 */
|
|
167
|
+
block?: boolean;
|
|
168
|
+
/** 按钮组是否危险操作 */
|
|
169
|
+
danger?: boolean;
|
|
170
|
+
/** 按钮组是否显示阴影 */
|
|
171
|
+
shadow?: boolean;
|
|
172
|
+
/** 按钮组是否有边框 */
|
|
173
|
+
bordered?: boolean;
|
|
174
|
+
/** 按钮组间距 */
|
|
175
|
+
spacing?: number;
|
|
176
|
+
/** 按钮组是否垂直排列 */
|
|
177
|
+
vertical?: boolean;
|
|
178
|
+
/** 按钮组自定义样式类名 */
|
|
179
|
+
className?: string;
|
|
180
|
+
/** 按钮组自定义样式 */
|
|
181
|
+
style?: React.CSSProperties;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ==================== Button样式类型 ====================
|
|
185
|
+
|
|
186
|
+
/** 按钮尺寸样式映射 */
|
|
187
|
+
export interface ButtonSizeStyle {
|
|
188
|
+
fontSize: number;
|
|
189
|
+
padding: string;
|
|
190
|
+
height: number;
|
|
191
|
+
borderRadius: number;
|
|
192
|
+
minWidth?: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** 按钮类型颜色映射 */
|
|
196
|
+
export interface ButtonTypeColors {
|
|
197
|
+
backgroundColor: string;
|
|
198
|
+
textColor: string;
|
|
199
|
+
borderColor: string;
|
|
200
|
+
hoverBackgroundColor?: string;
|
|
201
|
+
hoverTextColor?: string;
|
|
202
|
+
hoverBorderColor?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 按钮变体样式映射 */
|
|
206
|
+
export interface ButtonVariantStyle {
|
|
207
|
+
backgroundColor: string;
|
|
208
|
+
textColor: string;
|
|
209
|
+
borderColor: string;
|
|
210
|
+
borderWidth: number;
|
|
211
|
+
hoverBackgroundColor?: string;
|
|
212
|
+
hoverTextColor?: string;
|
|
213
|
+
hoverBorderColor?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 按钮形状样式映射 */
|
|
217
|
+
export interface ButtonShapeStyle {
|
|
218
|
+
borderRadius: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** 按钮状态样式映射 */
|
|
222
|
+
export interface ButtonStatusStyle {
|
|
223
|
+
opacity: number;
|
|
224
|
+
cursor: string;
|
|
225
|
+
pointerEvents: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** 按钮阴影样式映射 */
|
|
229
|
+
export interface ButtonShadowStyle {
|
|
230
|
+
default: string;
|
|
231
|
+
hover: string;
|
|
232
|
+
active: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ==================== Button工具函数类型 ====================
|
|
236
|
+
|
|
237
|
+
/** 按钮工具函数接口 */
|
|
238
|
+
export interface ButtonUtils {
|
|
239
|
+
/** 获取按钮样式类名 */
|
|
240
|
+
getButtonClassName: (props: Partial<ButtonProps>) => string;
|
|
241
|
+
/** 获取按钮样式对象 */
|
|
242
|
+
getButtonStyle: (props: Partial<ButtonProps>) => React.CSSProperties;
|
|
243
|
+
/** 获取按钮尺寸映射 */
|
|
244
|
+
getSizeMap: () => Record<ButtonSize, ButtonSizeStyle>;
|
|
245
|
+
/** 获取按钮类型映射 */
|
|
246
|
+
getTypeMap: () => Record<ButtonType, ButtonTypeColors>;
|
|
247
|
+
/** 获取按钮变体映射 */
|
|
248
|
+
getVariantMap: () => Record<ButtonVariant, ButtonVariantStyle>;
|
|
249
|
+
/** 获取按钮形状映射 */
|
|
250
|
+
getShapeMap: () => Record<ButtonShape, ButtonShapeStyle>;
|
|
251
|
+
/** 获取按钮状态映射 */
|
|
252
|
+
getStatusMap: () => Record<ButtonStatus, ButtonStatusStyle>;
|
|
253
|
+
/** 获取按钮阴影映射 */
|
|
254
|
+
getShadowMap: () => ButtonShadowStyle;
|
|
255
|
+
/** 验证按钮属性 */
|
|
256
|
+
validateButtonProps: (props: ButtonProps) => boolean;
|
|
257
|
+
/** 格式化按钮尺寸 */
|
|
258
|
+
formatButtonSize: (size: ButtonSize) => string;
|
|
259
|
+
/** 格式化按钮类型 */
|
|
260
|
+
formatButtonType: (type: ButtonType) => string;
|
|
261
|
+
/** 格式化按钮变体 */
|
|
262
|
+
formatButtonVariant: (variant: ButtonVariant) => string;
|
|
263
|
+
/** 格式化按钮形状 */
|
|
264
|
+
formatButtonShape: (shape: ButtonShape) => string;
|
|
265
|
+
/** 格式化按钮状态 */
|
|
266
|
+
formatButtonStatus: (status: ButtonStatus) => string;
|
|
267
|
+
/** 计算按钮最终状态 */
|
|
268
|
+
calculateFinalStatus: (props: Partial<ButtonProps>) => ButtonStatus;
|
|
269
|
+
/** 生成按钮组样式 */
|
|
270
|
+
getGroupStyle: (props: Partial<ButtonGroupProps>) => React.CSSProperties;
|
|
271
|
+
/** 生成按钮组内按钮样式 */
|
|
272
|
+
getGroupItemStyle: (props: {
|
|
273
|
+
index: number;
|
|
274
|
+
total: number;
|
|
275
|
+
shape?: ButtonShape;
|
|
276
|
+
vertical?: boolean;
|
|
277
|
+
}) => React.CSSProperties;
|
|
278
|
+
/** 生成涟漪效果样式 */
|
|
279
|
+
getRippleStyle: (x: number, y: number, size: number) => React.CSSProperties;
|
|
280
|
+
/** 生成加载动画样式 */
|
|
281
|
+
getLoadingStyle: (size: ButtonSize) => React.CSSProperties;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ==================== Button验证器 ====================
|
|
285
|
+
|
|
286
|
+
/** 按钮尺寸验证器 */
|
|
287
|
+
export const buttonSizeValidator: Validator<ButtonSize> = createValidator(
|
|
288
|
+
(value): value is ButtonSize => ['xs', 'sm', 'md', 'lg', 'xl'].includes(value as ButtonSize),
|
|
289
|
+
'Invalid button size. Must be one of: xs, sm, md, lg, xl'
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
/** 按钮类型验证器 */
|
|
293
|
+
export const buttonTypeValidator: Validator<ButtonType> = createValidator(
|
|
294
|
+
(value): value is ButtonType => ['default', 'primary', 'secondary', 'success', 'warning', 'error', 'info'].includes(value as ButtonType),
|
|
295
|
+
'Invalid button type. Must be one of: default, primary, secondary, success, warning, error, info'
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
/** 按钮变体验证器 */
|
|
299
|
+
export const buttonVariantValidator: Validator<ButtonVariant> = createValidator(
|
|
300
|
+
(value): value is ButtonVariant => ['solid', 'outline', 'ghost', 'text'].includes(value as ButtonVariant),
|
|
301
|
+
'Invalid button variant. Must be one of: solid, outline, ghost, text'
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
/** 按钮形状验证器 */
|
|
305
|
+
export const buttonShapeValidator: Validator<ButtonShape> = createValidator(
|
|
306
|
+
(value): value is ButtonShape => ['default', 'rounded', 'circle', 'square'].includes(value as ButtonShape),
|
|
307
|
+
'Invalid button shape. Must be one of: default, rounded, circle, square'
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
/** 按钮状态验证器 */
|
|
311
|
+
export const buttonStatusValidator: Validator<ButtonStatus> = createValidator(
|
|
312
|
+
(value): value is ButtonStatus => ['normal', 'loading', 'disabled', 'active'].includes(value as ButtonStatus),
|
|
313
|
+
'Invalid button status. Must be one of: normal, loading, disabled, active'
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
/** 按钮图标位置验证器 */
|
|
317
|
+
export const buttonIconPositionValidator: Validator<ButtonIconPosition> = createValidator(
|
|
318
|
+
(value): value is ButtonIconPosition => ['left', 'right'].includes(value as ButtonIconPosition),
|
|
319
|
+
'Invalid button icon position. Must be one of: left, right'
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
// ==================== Button类型守卫 ====================
|
|
323
|
+
|
|
324
|
+
/** 检查是否为有效的按钮尺寸 */
|
|
325
|
+
export function isValidButtonSize(value: unknown): value is ButtonSize {
|
|
326
|
+
return buttonSizeValidator(value).success;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** 检查是否为有效的按钮类型 */
|
|
330
|
+
export function isValidButtonType(value: unknown): value is ButtonType {
|
|
331
|
+
return buttonTypeValidator(value).success;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** 检查是否为有效的按钮变体 */
|
|
335
|
+
export function isValidButtonVariant(value: unknown): value is ButtonVariant {
|
|
336
|
+
return buttonVariantValidator(value).success;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** 检查是否为有效的按钮形状 */
|
|
340
|
+
export function isValidButtonShape(value: unknown): value is ButtonShape {
|
|
341
|
+
return buttonShapeValidator(value).success;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** 检查是否为有效的按钮状态 */
|
|
345
|
+
export function isValidButtonStatus(value: unknown): value is ButtonStatus {
|
|
346
|
+
return buttonStatusValidator(value).success;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** 检查是否为有效的按钮图标位置 */
|
|
350
|
+
export function isValidButtonIconPosition(value: unknown): value is ButtonIconPosition {
|
|
351
|
+
return buttonIconPositionValidator(value).success;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** 检查是否为有效的按钮属性 */
|
|
355
|
+
export function isValidButtonProps(props: unknown): props is ButtonProps {
|
|
356
|
+
if (!props || typeof props !== 'object') return false;
|
|
357
|
+
|
|
358
|
+
const obj = props as Record<string, unknown>;
|
|
359
|
+
|
|
360
|
+
// 验证基本属性类型
|
|
361
|
+
if (obj['size'] !== undefined && !isValidButtonSize(obj['size'])) return false;
|
|
362
|
+
if (obj['type'] !== undefined && !isValidButtonType(obj['type'])) return false;
|
|
363
|
+
if (obj['variant'] !== undefined && !isValidButtonVariant(obj['variant'])) return false;
|
|
364
|
+
if (obj['shape'] !== undefined && !isValidButtonShape(obj['shape'])) return false;
|
|
365
|
+
if (obj['status'] !== undefined && !isValidButtonStatus(obj['status'])) return false;
|
|
366
|
+
if (obj['iconPosition'] !== undefined && !isValidButtonIconPosition(obj['iconPosition'])) return false;
|
|
367
|
+
|
|
368
|
+
// 验证布尔值属性
|
|
369
|
+
const booleanProps = ['block', 'danger', 'loading', 'disabled', 'ripple', 'shadow', 'bordered'];
|
|
370
|
+
for (const prop of booleanProps) {
|
|
371
|
+
if (obj[prop] !== undefined && !isBoolean(obj[prop])) return false;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// 验证字符串属性
|
|
375
|
+
const stringProps = ['className', 'loadingText', 'color', 'backgroundColor', 'textColor', 'borderColor'];
|
|
376
|
+
for (const prop of stringProps) {
|
|
377
|
+
if (obj[prop] !== undefined && !isString(obj[prop])) return false;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// 验证数字属性
|
|
381
|
+
const numberProps = ['animationDuration', 'groupIndex', 'groupSize'];
|
|
382
|
+
for (const prop of numberProps) {
|
|
383
|
+
if (obj[prop] !== undefined && !isNumber(obj[prop])) return false;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// 验证函数属性
|
|
387
|
+
const functionProps = ['onClick', 'onPressIn', 'onPressOut', 'onLongPress'];
|
|
388
|
+
for (const prop of functionProps) {
|
|
389
|
+
if (obj[prop] !== undefined && !isFunction(obj[prop])) return false;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 验证React元素属性
|
|
393
|
+
if (obj['icon'] !== undefined && !isReactElement(obj['icon']) && !isString(obj['icon'])) return false;
|
|
394
|
+
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// ==================== Button默认值 ====================
|
|
399
|
+
|
|
400
|
+
/** 按钮默认属性 */
|
|
401
|
+
export const defaultButtonProps: Partial<ButtonProps> = {
|
|
402
|
+
children: undefined,
|
|
403
|
+
size: 'md',
|
|
404
|
+
type: 'default',
|
|
405
|
+
variant: 'solid',
|
|
406
|
+
shape: 'default',
|
|
407
|
+
status: 'normal',
|
|
408
|
+
block: false,
|
|
409
|
+
danger: false,
|
|
410
|
+
loading: false,
|
|
411
|
+
disabled: false,
|
|
412
|
+
icon: undefined,
|
|
413
|
+
iconPosition: 'left',
|
|
414
|
+
className: '',
|
|
415
|
+
onClick: undefined,
|
|
416
|
+
onPressIn: undefined,
|
|
417
|
+
onPressOut: undefined,
|
|
418
|
+
onLongPress: undefined,
|
|
419
|
+
style: {},
|
|
420
|
+
loadingText: '加载中...',
|
|
421
|
+
ripple: false,
|
|
422
|
+
shadow: false,
|
|
423
|
+
bordered: true,
|
|
424
|
+
groupIndex: undefined,
|
|
425
|
+
groupSize: undefined,
|
|
426
|
+
color: undefined,
|
|
427
|
+
backgroundColor: undefined,
|
|
428
|
+
textColor: undefined,
|
|
429
|
+
borderColor: undefined,
|
|
430
|
+
animationDuration: 300,
|
|
431
|
+
accessible: true,
|
|
432
|
+
accessibilityLabel: '',
|
|
433
|
+
accessibilityRole: 'button',
|
|
434
|
+
accessibilityState: {
|
|
435
|
+
disabled: false,
|
|
436
|
+
selected: false,
|
|
437
|
+
busy: false,
|
|
438
|
+
expanded: false,
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// ==================== Button工具函数 ====================
|
|
443
|
+
|
|
444
|
+
/** 创建按钮类名 */
|
|
445
|
+
export function createButtonClassName(props: Partial<ButtonProps>): string {
|
|
446
|
+
const {
|
|
447
|
+
size = defaultButtonProps.size,
|
|
448
|
+
type = defaultButtonProps.type,
|
|
449
|
+
variant = defaultButtonProps.variant,
|
|
450
|
+
shape = defaultButtonProps.shape,
|
|
451
|
+
block = defaultButtonProps.block,
|
|
452
|
+
danger = defaultButtonProps.danger,
|
|
453
|
+
loading = defaultButtonProps.loading,
|
|
454
|
+
disabled = defaultButtonProps.disabled,
|
|
455
|
+
shadow = defaultButtonProps.shadow,
|
|
456
|
+
bordered = defaultButtonProps.bordered,
|
|
457
|
+
className = defaultButtonProps.className,
|
|
458
|
+
} = props;
|
|
459
|
+
|
|
460
|
+
const finalStatus = calculateFinalStatus(props);
|
|
461
|
+
|
|
462
|
+
const baseClasses = [
|
|
463
|
+
'taro-uno-button',
|
|
464
|
+
`taro-uno-button--${size}`,
|
|
465
|
+
`taro-uno-button--${type}`,
|
|
466
|
+
`taro-uno-button--${variant}`,
|
|
467
|
+
`taro-uno-button--${shape}`,
|
|
468
|
+
`taro-uno-button--${finalStatus}`,
|
|
469
|
+
].filter(Boolean);
|
|
470
|
+
|
|
471
|
+
const conditionalClasses = {
|
|
472
|
+
'taro-uno-button--block': !!block,
|
|
473
|
+
'taro-uno-button--danger': !!danger,
|
|
474
|
+
'taro-uno-button--loading': !!loading,
|
|
475
|
+
'taro-uno-button--disabled': !!disabled,
|
|
476
|
+
'taro-uno-button--shadow': !!shadow,
|
|
477
|
+
'taro-uno-button--bordered': !!bordered,
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
return classNames(
|
|
481
|
+
...baseClasses,
|
|
482
|
+
conditionalClasses,
|
|
483
|
+
className
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** 计算按钮最终状态 */
|
|
488
|
+
export function calculateFinalStatus(props: Partial<ButtonProps>): ButtonStatus {
|
|
489
|
+
const { loading = defaultButtonProps.loading, disabled = defaultButtonProps.disabled, status = defaultButtonProps.status } = props;
|
|
490
|
+
|
|
491
|
+
if (loading) return 'loading';
|
|
492
|
+
if (disabled) return 'disabled';
|
|
493
|
+
return status || 'normal';
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** 验证按钮属性 */
|
|
497
|
+
export function validateButtonProps(props: ButtonProps): boolean {
|
|
498
|
+
return isValidButtonProps(props);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** 格式化按钮尺寸 */
|
|
502
|
+
export function formatButtonSize(size: ButtonSize): string {
|
|
503
|
+
const sizeMap: Record<ButtonSize, string> = {
|
|
504
|
+
xs: '极小',
|
|
505
|
+
sm: '小',
|
|
506
|
+
md: '中',
|
|
507
|
+
lg: '大',
|
|
508
|
+
xl: '极大',
|
|
509
|
+
};
|
|
510
|
+
return sizeMap[size];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** 格式化按钮类型 */
|
|
514
|
+
export function formatButtonType(type: ButtonType): string {
|
|
515
|
+
const typeMap: Record<ButtonType, string> = {
|
|
516
|
+
default: '默认',
|
|
517
|
+
primary: '主要',
|
|
518
|
+
secondary: '次要',
|
|
519
|
+
success: '成功',
|
|
520
|
+
warning: '警告',
|
|
521
|
+
error: '错误',
|
|
522
|
+
info: '信息',
|
|
523
|
+
};
|
|
524
|
+
return typeMap[type];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** 格式化按钮变体 */
|
|
528
|
+
export function formatButtonVariant(variant: ButtonVariant): string {
|
|
529
|
+
const variantMap: Record<ButtonVariant, string> = {
|
|
530
|
+
solid: '实心',
|
|
531
|
+
outline: '轮廓',
|
|
532
|
+
ghost: '幽灵',
|
|
533
|
+
text: '文字',
|
|
534
|
+
};
|
|
535
|
+
return variantMap[variant];
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** 格式化按钮形状 */
|
|
539
|
+
export function formatButtonShape(shape: ButtonShape): string {
|
|
540
|
+
const shapeMap: Record<ButtonShape, string> = {
|
|
541
|
+
default: '默认',
|
|
542
|
+
rounded: '圆角',
|
|
543
|
+
circle: '圆形',
|
|
544
|
+
square: '方形',
|
|
545
|
+
};
|
|
546
|
+
return shapeMap[shape];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** 格式化按钮状态 */
|
|
550
|
+
export function formatButtonStatus(status: ButtonStatus): string {
|
|
551
|
+
const statusMap: Record<ButtonStatus, string> = {
|
|
552
|
+
normal: '正常',
|
|
553
|
+
loading: '加载中',
|
|
554
|
+
disabled: '禁用',
|
|
555
|
+
active: '激活',
|
|
556
|
+
};
|
|
557
|
+
return statusMap[status];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ==================== 导出 ====================
|
|
561
|
+
|
|
562
|
+
export * from './index';
|