taro-uno-ui 1.0.1 → 1.0.2
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 +67 -30
- package/dist/js/{index-CDFsvu80.js → index-QpKiGsEQ.js} +39026 -28023
- package/dist/js/index-QpKiGsEQ.js.map +1 -0
- package/dist/js/{index-JffnTUrv.js → index-nnTHNhwl.js} +38743 -27720
- package/dist/js/index-nnTHNhwl.js.map +1 -0
- package/package.json +4 -4
- package/dist/js/index-CDFsvu80.js.map +0 -1
- package/dist/js/index-DFdcksbe.js +0 -1165
- package/dist/js/index-DFdcksbe.js.map +0 -1
- package/dist/js/index-DXRIkWX1.js +0 -1148
- package/dist/js/index-DXRIkWX1.js.map +0 -1
- package/dist/js/index-JffnTUrv.js.map +0 -1
- package/dist/utils/http/request.d.ts +0 -280
- package/src/app.config.ts +0 -55
- package/src/app.scss +0 -508
- package/src/app.tsx +0 -44
- package/src/components/basic/Button/Button.styles.ts +0 -130
- package/src/components/basic/Button/Button.test.tsx +0 -154
- package/src/components/basic/Button/Button.tsx +0 -133
- package/src/components/basic/Button/Button.types.ts +0 -81
- package/src/components/basic/Button/index.tsx +0 -6
- package/src/components/basic/Divider/Divider.styles.ts +0 -488
- package/src/components/basic/Divider/Divider.test.tsx +0 -551
- package/src/components/basic/Divider/Divider.tsx +0 -392
- package/src/components/basic/Divider/Divider.types.ts +0 -261
- package/src/components/basic/Divider/index.tsx +0 -25
- package/src/components/basic/Icon/Icon.data.ts +0 -474
- package/src/components/basic/Icon/Icon.styles.ts +0 -359
- package/src/components/basic/Icon/Icon.test.tsx +0 -357
- package/src/components/basic/Icon/Icon.tsx +0 -167
- package/src/components/basic/Icon/Icon.types.ts +0 -210
- package/src/components/basic/Icon/IconManager.ts +0 -229
- package/src/components/basic/Icon/index.tsx +0 -22
- package/src/components/basic/Text/Text.styles.ts +0 -500
- package/src/components/basic/Text/Text.test.tsx +0 -299
- package/src/components/basic/Text/Text.tsx +0 -340
- package/src/components/basic/Text/Text.types.ts +0 -329
- package/src/components/basic/Text/index.tsx +0 -27
- package/src/components/basic/Typography/Typography.styles.ts +0 -347
- package/src/components/basic/Typography/Typography.tsx +0 -207
- package/src/components/basic/Typography/Typography.types.ts +0 -296
- package/src/components/basic/Typography/index.tsx +0 -14
- package/src/components/basic/Video/Video.styles.ts +0 -777
- package/src/components/basic/Video/Video.test.tsx +0 -490
- package/src/components/basic/Video/Video.tsx +0 -1468
- package/src/components/basic/Video/Video.types.ts +0 -500
- package/src/components/basic/Video/index.tsx +0 -26
- package/src/components/basic/index.tsx +0 -300
- package/src/components/common/ErrorBoundary.tsx +0 -87
- package/src/components/common/LazyComponent.tsx +0 -247
- package/src/components/common/ResponsiveContainer.tsx +0 -93
- package/src/components/common/ResponsiveGrid.tsx +0 -183
- package/src/components/common/SecurityProvider.tsx +0 -98
- package/src/components/common/ThemeProvider.tsx +0 -115
- package/src/components/common/VirtualList.tsx +0 -350
- package/src/components/common/__tests__/ErrorBoundary.test.tsx +0 -249
- package/src/components/common/index.tsx +0 -32
- package/src/components/display/Avatar/Avatar.styles.ts +0 -62
- package/src/components/display/Avatar/Avatar.test.tsx +0 -390
- package/src/components/display/Avatar/Avatar.tsx +0 -66
- package/src/components/display/Avatar/Avatar.types.ts +0 -40
- package/src/components/display/Avatar/index.ts +0 -3
- package/src/components/display/Badge/Badge.tsx +0 -29
- package/src/components/display/Badge/Badge.types.ts +0 -29
- package/src/components/display/Badge/index.ts +0 -2
- package/src/components/display/Calendar/Calendar.styles.ts +0 -255
- package/src/components/display/Calendar/Calendar.test.tsx +0 -42
- package/src/components/display/Calendar/Calendar.tsx +0 -358
- package/src/components/display/Calendar/Calendar.types.ts +0 -91
- package/src/components/display/Calendar/index.ts +0 -3
- package/src/components/display/Card/Card.styles.ts +0 -89
- package/src/components/display/Card/Card.test.tsx +0 -182
- package/src/components/display/Card/Card.tsx +0 -135
- package/src/components/display/Card/Card.types.ts +0 -55
- package/src/components/display/Card/index.ts +0 -3
- package/src/components/display/Carousel/Carousel.styles.ts +0 -206
- package/src/components/display/Carousel/Carousel.tsx +0 -290
- package/src/components/display/Carousel/Carousel.types.ts +0 -57
- package/src/components/display/Carousel/index.ts +0 -3
- package/src/components/display/List/List.styles.ts +0 -79
- package/src/components/display/List/List.tsx +0 -114
- package/src/components/display/List/List.types.ts +0 -68
- package/src/components/display/List/index.ts +0 -3
- package/src/components/display/Rate/Rate.styles.ts +0 -254
- package/src/components/display/Rate/Rate.tsx +0 -324
- package/src/components/display/Rate/Rate.types.ts +0 -112
- package/src/components/display/Rate/index.ts +0 -20
- package/src/components/display/Table/Table.styles.ts +0 -269
- package/src/components/display/Table/Table.test.tsx +0 -345
- package/src/components/display/Table/Table.tsx +0 -426
- package/src/components/display/Table/Table.types.ts +0 -256
- package/src/components/display/Table/index.tsx +0 -16
- package/src/components/display/Tag/Tag.styles.ts +0 -197
- package/src/components/display/Tag/Tag.test.tsx +0 -541
- package/src/components/display/Tag/Tag.tsx +0 -139
- package/src/components/display/Tag/Tag.types.ts +0 -49
- package/src/components/display/Tag/index.ts +0 -3
- package/src/components/display/Timeline/Timeline.styles.ts +0 -211
- package/src/components/display/Timeline/Timeline.tsx +0 -220
- package/src/components/display/Timeline/Timeline.types.ts +0 -56
- package/src/components/display/Timeline/index.ts +0 -3
- package/src/components/display/index.tsx +0 -147
- package/src/components/feedback/Loading/Loading.styles.ts +0 -117
- package/src/components/feedback/Loading/Loading.test.tsx +0 -534
- package/src/components/feedback/Loading/Loading.tsx +0 -132
- package/src/components/feedback/Loading/Loading.types.ts +0 -33
- package/src/components/feedback/Loading/index.ts +0 -6
- package/src/components/feedback/Message/Message.styles.ts +0 -41
- package/src/components/feedback/Message/Message.test.tsx +0 -234
- package/src/components/feedback/Message/Message.tsx +0 -96
- package/src/components/feedback/Message/Message.types.ts +0 -37
- package/src/components/feedback/Message/index.ts +0 -6
- package/src/components/feedback/Modal/Modal.styles.ts +0 -21
- package/src/components/feedback/Modal/Modal.test.tsx +0 -11
- package/src/components/feedback/Modal/Modal.tsx +0 -269
- package/src/components/feedback/Modal/Modal.types.ts +0 -151
- package/src/components/feedback/Modal/index.tsx +0 -11
- package/src/components/feedback/Notification/Notification.styles.ts +0 -453
- package/src/components/feedback/Notification/Notification.test.tsx +0 -401
- package/src/components/feedback/Notification/Notification.tsx +0 -347
- package/src/components/feedback/Notification/Notification.types.ts +0 -339
- package/src/components/feedback/Notification/NotificationManager.tsx +0 -405
- package/src/components/feedback/Notification/index.ts +0 -40
- package/src/components/feedback/Notification/index.tsx +0 -154
- package/src/components/feedback/Progress/Progress.styles.ts +0 -469
- package/src/components/feedback/Progress/Progress.test.simple.tsx +0 -14
- package/src/components/feedback/Progress/Progress.test.tsx +0 -312
- package/src/components/feedback/Progress/Progress.tsx +0 -488
- package/src/components/feedback/Progress/Progress.types.ts +0 -163
- package/src/components/feedback/Progress/index.ts +0 -3
- package/src/components/feedback/Progress/index.tsx +0 -38
- package/src/components/feedback/Progress/utils/animation.ts +0 -193
- package/src/components/feedback/Progress/utils/index.ts +0 -26
- package/src/components/feedback/Progress/utils/progress-calculator.ts +0 -199
- package/src/components/feedback/Result/Result.styles.ts +0 -139
- package/src/components/feedback/Result/Result.tsx +0 -221
- package/src/components/feedback/Result/Result.types.ts +0 -128
- package/src/components/feedback/Result/index.tsx +0 -3
- package/src/components/feedback/Toast/Toast.styles.ts +0 -17
- package/src/components/feedback/Toast/Toast.test.tsx +0 -10
- package/src/components/feedback/Toast/Toast.tsx +0 -384
- package/src/components/feedback/Toast/Toast.types.ts +0 -86
- package/src/components/feedback/Toast/index.tsx +0 -3
- package/src/components/feedback/Tooltip/Tooltip.examples.tsx +0 -435
- package/src/components/feedback/Tooltip/Tooltip.styles.ts +0 -340
- package/src/components/feedback/Tooltip/Tooltip.test.tsx +0 -446
- package/src/components/feedback/Tooltip/Tooltip.tsx +0 -302
- package/src/components/feedback/Tooltip/Tooltip.types.ts +0 -166
- package/src/components/feedback/Tooltip/index.ts +0 -3
- package/src/components/feedback/Tooltip/index.tsx +0 -246
- package/src/components/feedback/index.tsx +0 -176
- package/src/components/form/Cascader/Cascader.styles.ts +0 -526
- package/src/components/form/Cascader/Cascader.test.tsx +0 -77
- package/src/components/form/Cascader/Cascader.tsx +0 -581
- package/src/components/form/Cascader/Cascader.types.ts +0 -581
- package/src/components/form/Cascader/hooks/index.ts +0 -3
- package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +0 -19
- package/src/components/form/Cascader/hooks/useCascaderOptions.ts +0 -127
- package/src/components/form/Cascader/hooks/useCascaderState.ts +0 -139
- package/src/components/form/Cascader/index.ts +0 -25
- package/src/components/form/Cascader/utils/formatDisplayValue.ts +0 -19
- package/src/components/form/Cascader/utils/index.ts +0 -1
- package/src/components/form/Checkbox/Checkbox.styles.ts +0 -607
- package/src/components/form/Checkbox/Checkbox.test.tsx +0 -1140
- package/src/components/form/Checkbox/Checkbox.tsx +0 -489
- package/src/components/form/Checkbox/Checkbox.types.ts +0 -472
- package/src/components/form/Checkbox/CheckboxGroup.tsx +0 -444
- package/src/components/form/Checkbox/index.tsx +0 -27
- package/src/components/form/DatePicker/DatePicker.styles.ts +0 -393
- package/src/components/form/DatePicker/DatePicker.test.tsx +0 -407
- package/src/components/form/DatePicker/DatePicker.tsx +0 -376
- package/src/components/form/DatePicker/DatePicker.types.ts +0 -250
- package/src/components/form/DatePicker/index.tsx +0 -15
- package/src/components/form/Form/Form.styles.ts +0 -357
- package/src/components/form/Form/Form.test.tsx +0 -122
- package/src/components/form/Form/Form.tsx +0 -257
- package/src/components/form/Form/Form.types.ts +0 -422
- package/src/components/form/Form/index.tsx +0 -31
- package/src/components/form/Form/useFormLogic.ts +0 -497
- package/src/components/form/Input/Input.styles.ts +0 -445
- package/src/components/form/Input/Input.test.tsx +0 -494
- package/src/components/form/Input/Input.tsx +0 -305
- package/src/components/form/Input/Input.types.ts +0 -297
- package/src/components/form/Input/index.tsx +0 -26
- package/src/components/form/Input/useInputLogic.test.ts +0 -82
- package/src/components/form/Input/useInputLogic.ts +0 -260
- package/src/components/form/InputNumber/InputNumber.styles.ts +0 -716
- package/src/components/form/InputNumber/InputNumber.tsx +0 -402
- package/src/components/form/InputNumber/InputNumber.types.ts +0 -336
- package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +0 -24
- package/src/components/form/InputNumber/components/InputNumberControls.tsx +0 -33
- package/src/components/form/InputNumber/components/index.ts +0 -2
- package/src/components/form/InputNumber/hooks/index.ts +0 -4
- package/src/components/form/InputNumber/hooks/useInputNumberState.ts +0 -313
- package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +0 -148
- package/src/components/form/InputNumber/index.ts +0 -25
- package/src/components/form/Radio/Radio.styles.ts +0 -451
- package/src/components/form/Radio/Radio.test.tsx +0 -547
- package/src/components/form/Radio/Radio.tsx +0 -277
- package/src/components/form/Radio/Radio.types.ts +0 -414
- package/src/components/form/Radio/index.tsx +0 -21
- package/src/components/form/Select/Select.styles.ts +0 -518
- package/src/components/form/Select/Select.test.tsx +0 -648
- package/src/components/form/Select/Select.tsx +0 -474
- package/src/components/form/Select/Select.types.ts +0 -429
- package/src/components/form/Select/index.tsx +0 -30
- package/src/components/form/Slider/Slider.styles.ts +0 -139
- package/src/components/form/Slider/Slider.test.tsx +0 -553
- package/src/components/form/Slider/Slider.tsx +0 -312
- package/src/components/form/Slider/Slider.types.ts +0 -110
- package/src/components/form/Slider/index.tsx +0 -3
- package/src/components/form/Switch/Switch.styles.ts +0 -534
- package/src/components/form/Switch/Switch.test.tsx +0 -345
- package/src/components/form/Switch/Switch.tsx +0 -458
- package/src/components/form/Switch/Switch.types.ts +0 -386
- package/src/components/form/Switch/index.tsx +0 -26
- package/src/components/form/Textarea/Textarea.styles.ts +0 -592
- package/src/components/form/Textarea/Textarea.test.tsx +0 -1075
- package/src/components/form/Textarea/Textarea.tsx +0 -608
- package/src/components/form/Textarea/Textarea.types.ts +0 -374
- package/src/components/form/Textarea/index.tsx +0 -26
- package/src/components/form/TimePicker/TimePicker.styles.ts +0 -434
- package/src/components/form/TimePicker/TimePicker.test.tsx +0 -306
- package/src/components/form/TimePicker/TimePicker.tsx +0 -250
- package/src/components/form/TimePicker/TimePicker.types.ts +0 -385
- package/src/components/form/TimePicker/index.ts +0 -21
- package/src/components/form/Transfer/Transfer.styles.ts +0 -490
- package/src/components/form/Transfer/Transfer.test.tsx +0 -316
- package/src/components/form/Transfer/Transfer.tsx +0 -414
- package/src/components/form/Transfer/Transfer.types.ts +0 -565
- package/src/components/form/Transfer/components/TransferItem.tsx +0 -94
- package/src/components/form/Transfer/components/TransferList.tsx +0 -298
- package/src/components/form/Transfer/components/TransferOperations.tsx +0 -81
- package/src/components/form/Transfer/components/TransferPagination.tsx +0 -139
- package/src/components/form/Transfer/components/TransferSearch.tsx +0 -85
- package/src/components/form/Transfer/components/index.ts +0 -6
- package/src/components/form/Transfer/hooks/index.ts +0 -3
- package/src/components/form/Transfer/hooks/useTransferData.ts +0 -202
- package/src/components/form/Transfer/hooks/useTransferState.ts +0 -120
- package/src/components/form/Transfer/index.ts +0 -27
- package/src/components/form/Upload/Upload.styles.ts +0 -145
- package/src/components/form/Upload/Upload.test.tsx +0 -10
- package/src/components/form/Upload/Upload.tsx +0 -498
- package/src/components/form/Upload/Upload.types.ts +0 -200
- package/src/components/form/Upload/index.tsx +0 -12
- package/src/components/form/index.tsx +0 -152
- package/src/components/index.tsx +0 -145
- package/src/components/layout/Affix/Affix.styles.ts +0 -42
- package/src/components/layout/Affix/Affix.test.tsx +0 -10
- package/src/components/layout/Affix/Affix.tsx +0 -83
- package/src/components/layout/Affix/Affix.types.ts +0 -29
- package/src/components/layout/Affix/index.tsx +0 -3
- package/src/components/layout/Col/Col.styles.ts +0 -185
- package/src/components/layout/Col/Col.test.tsx +0 -537
- package/src/components/layout/Col/Col.tsx +0 -97
- package/src/components/layout/Col/Col.types.ts +0 -59
- package/src/components/layout/Col/index.tsx +0 -3
- package/src/components/layout/Container/Container.styles.ts +0 -163
- package/src/components/layout/Container/Container.test.tsx +0 -380
- package/src/components/layout/Container/Container.tsx +0 -123
- package/src/components/layout/Container/Container.types.ts +0 -63
- package/src/components/layout/Container/index.tsx +0 -3
- package/src/components/layout/Grid/Grid.styles.ts +0 -183
- package/src/components/layout/Grid/Grid.test.tsx +0 -637
- package/src/components/layout/Grid/Grid.tsx +0 -123
- package/src/components/layout/Grid/Grid.types.ts +0 -78
- package/src/components/layout/Grid/index.tsx +0 -3
- package/src/components/layout/Layout/Content.tsx +0 -30
- package/src/components/layout/Layout/Footer.tsx +0 -30
- package/src/components/layout/Layout/Header.tsx +0 -30
- package/src/components/layout/Layout/Layout.styles.ts +0 -84
- package/src/components/layout/Layout/Layout.test.tsx +0 -10
- package/src/components/layout/Layout/Layout.tsx +0 -28
- package/src/components/layout/Layout/Layout.types.ts +0 -58
- package/src/components/layout/Layout/Sider.tsx +0 -44
- package/src/components/layout/Layout/index.tsx +0 -22
- package/src/components/layout/Row/Row.styles.ts +0 -159
- package/src/components/layout/Row/Row.test.tsx +0 -467
- package/src/components/layout/Row/Row.tsx +0 -111
- package/src/components/layout/Row/Row.types.ts +0 -60
- package/src/components/layout/Row/index.tsx +0 -3
- package/src/components/layout/Space/Space.styles.ts +0 -255
- package/src/components/layout/Space/Space.test.tsx +0 -682
- package/src/components/layout/Space/Space.tsx +0 -203
- package/src/components/layout/Space/Space.types.ts +0 -92
- package/src/components/layout/Space/index.tsx +0 -12
- package/src/components/layout/index.tsx +0 -78
- package/src/components/navigation/Menu/Menu.constants.ts +0 -69
- package/src/components/navigation/Menu/Menu.stories.tsx +0 -107
- package/src/components/navigation/Menu/Menu.styles.ts +0 -767
- package/src/components/navigation/Menu/Menu.tsx +0 -352
- package/src/components/navigation/Menu/Menu.types.ts +0 -231
- package/src/components/navigation/Menu/Menu.utils.ts +0 -187
- package/src/components/navigation/Menu/MenuItem.tsx +0 -124
- package/src/components/navigation/Menu/SubMenu.tsx +0 -150
- package/src/components/navigation/Menu/index.tsx +0 -59
- package/src/components/navigation/NavBar/NavBar.styles.ts +0 -129
- package/src/components/navigation/NavBar/NavBar.test.tsx +0 -287
- package/src/components/navigation/NavBar/NavBar.tsx +0 -228
- package/src/components/navigation/NavBar/NavBar.types.ts +0 -54
- package/src/components/navigation/NavBar/index.tsx +0 -3
- package/src/components/navigation/Pagination/Pagination.styles.ts +0 -187
- package/src/components/navigation/Pagination/Pagination.test.tsx +0 -672
- package/src/components/navigation/Pagination/Pagination.tsx +0 -395
- package/src/components/navigation/Pagination/Pagination.types.ts +0 -87
- package/src/components/navigation/Pagination/index.ts +0 -24
- package/src/components/navigation/Pagination/index.tsx +0 -9
- package/src/components/navigation/Steps/Step.tsx +0 -36
- package/src/components/navigation/Steps/Steps.styles.ts +0 -169
- package/src/components/navigation/Steps/Steps.test.tsx +0 -14
- package/src/components/navigation/Steps/Steps.tsx +0 -112
- package/src/components/navigation/Steps/Steps.types.ts +0 -47
- package/src/components/navigation/Steps/index.tsx +0 -3
- package/src/components/navigation/Tabs/Tabs.styles.ts +0 -199
- package/src/components/navigation/Tabs/Tabs.test.tsx +0 -662
- package/src/components/navigation/Tabs/Tabs.tsx +0 -253
- package/src/components/navigation/Tabs/Tabs.types.ts +0 -115
- package/src/components/navigation/Tabs/index.tsx +0 -3
- package/src/components/navigation/index.tsx +0 -88
- package/src/constants/index.ts +0 -785
- package/src/hooks/index.ts +0 -60
- package/src/hooks/types.ts +0 -9
- package/src/hooks/useAsync.ts +0 -64
- package/src/hooks/useClickOutside.ts +0 -52
- package/src/hooks/useCounter.ts +0 -87
- package/src/hooks/useDebounce.ts +0 -150
- package/src/hooks/useDeepCompareEffect.ts +0 -88
- package/src/hooks/useEventHandling.ts +0 -444
- package/src/hooks/useEventListener.ts +0 -77
- package/src/hooks/useLifecycle.ts +0 -399
- package/src/hooks/useMediaQuery.ts +0 -75
- package/src/hooks/useMutation.ts +0 -233
- package/src/hooks/usePerformance.ts +0 -378
- package/src/hooks/usePerformanceMonitor.ts +0 -348
- package/src/hooks/usePlatform.ts +0 -64
- package/src/hooks/usePrevious.ts +0 -25
- package/src/hooks/useRequest.test.ts +0 -11
- package/src/hooks/useRequest.ts +0 -140
- package/src/hooks/useStateManagement.ts +0 -300
- package/src/hooks/useStorage.ts +0 -169
- package/src/hooks/useStyle.ts +0 -543
- package/src/hooks/useTheme.ts +0 -347
- package/src/hooks/useToggle.ts +0 -54
- package/src/hooks/useVirtualScroll.ts +0 -331
- package/src/index.ts +0 -323
- package/src/platform/index.ts +0 -1188
- package/src/providers/AppProvider.test.tsx +0 -63
- package/src/providers/AppProvider.tsx +0 -155
- package/src/providers/index.ts +0 -1
- package/src/theme/ThemeProvider.tsx +0 -279
- package/src/theme/ThemeProvider.types.ts +0 -26
- package/src/theme/animations.tsx +0 -660
- package/src/theme/defaults.ts +0 -188
- package/src/theme/design-system.ts +0 -562
- package/src/theme/design-tokens.ts +0 -1122
- package/src/theme/generated/dark-theme.scss +0 -120
- package/src/theme/generated/tokens.css +0 -441
- package/src/theme/generated/tokens.scss +0 -384
- package/src/theme/index.ts +0 -99
- package/src/theme/responsive.tsx +0 -195
- package/src/theme/styles/mixins.scss +0 -612
- package/src/theme/styles/variables.scss +0 -295
- package/src/theme/styles.ts +0 -403
- package/src/theme/tokens/colors.ts +0 -256
- package/src/theme/tokens/effects.ts +0 -260
- package/src/theme/tokens/index.ts +0 -217
- package/src/theme/tokens/spacing.ts +0 -137
- package/src/theme/tokens/typography.ts +0 -186
- package/src/theme/types.ts +0 -188
- package/src/theme/useThemeUtils.ts +0 -313
- package/src/theme/utils.ts +0 -501
- package/src/theme/variables.ts +0 -602
- package/src/types/accessibility.ts +0 -50
- package/src/types/button.ts +0 -560
- package/src/types/component-props.ts +0 -322
- package/src/types/env.d.ts +0 -20
- package/src/types/glob.d.ts +0 -4
- package/src/types/index.ts +0 -427
- package/src/types/modules.d.ts +0 -40
- package/src/types/standardized-components.ts +0 -550
- package/src/types/taro-adapter.d.ts +0 -174
- package/src/types/taro-components.d.ts +0 -73
- package/src/types/utils.ts +0 -400
- package/src/utils/__tests__/inputValidator.test.ts +0 -338
- package/src/utils/__tests__/responsiveUtils.test.ts +0 -311
- package/src/utils/__tests__/xssProtection.test.ts +0 -268
- package/src/utils/abort-controller.ts +0 -48
- package/src/utils/cache.ts +0 -79
- package/src/utils/createNamespace.ts +0 -24
- package/src/utils/environment.ts +0 -115
- package/src/utils/error-handler.ts +0 -88
- package/src/utils/errorLogger.ts +0 -193
- package/src/utils/formatUtils.ts +0 -412
- package/src/utils/http/error-codes.ts +0 -314
- package/src/utils/http/http-client.test.ts +0 -63
- package/src/utils/http/http-client.ts +0 -161
- package/src/utils/http/request-cache.ts +0 -127
- package/src/utils/http/request.ts +0 -954
- package/src/utils/http/taro-adapter.test.ts +0 -74
- package/src/utils/http/taro-adapter.ts +0 -24
- package/src/utils/http/types.ts +0 -414
- package/src/utils/http/web-adapter.ts +0 -33
- package/src/utils/index.ts +0 -112
- package/src/utils/inputValidator.ts +0 -264
- package/src/utils/performance/performance.ts +0 -839
- package/src/utils/responsiveUtils.ts +0 -348
- package/src/utils/rtl-support.ts +0 -354
- package/src/utils/security/api-security.ts +0 -394
- package/src/utils/security/xss-protection.ts +0 -69
- package/src/utils/securityHeaders.ts +0 -308
- package/src/utils/typeHelpers.ts +0 -16
- package/src/utils/types/dataProcessing.ts +0 -544
- package/src/utils/types/typeHelpers.ts +0 -197
- package/src/utils/xssProtection.ts +0 -468
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import type { ContainerProps } from './Container.types';
|
|
2
|
-
import type { Size, CSSUnit } from '../../../types';
|
|
3
|
-
|
|
4
|
-
/** Container组件样式管理器 */
|
|
5
|
-
export const containerStyles = {
|
|
6
|
-
/** 尺寸映射表 */
|
|
7
|
-
SIZE_MAP: {
|
|
8
|
-
small: 320,
|
|
9
|
-
medium: 768,
|
|
10
|
-
large: 1024,
|
|
11
|
-
default: 1200,
|
|
12
|
-
full: '100%',
|
|
13
|
-
fluid: '100%',
|
|
14
|
-
} as const,
|
|
15
|
-
|
|
16
|
-
/** 对齐方式映射表 */
|
|
17
|
-
ALIGN_MAP: {
|
|
18
|
-
start: 'flex-start',
|
|
19
|
-
center: 'center',
|
|
20
|
-
end: 'flex-end',
|
|
21
|
-
stretch: 'stretch',
|
|
22
|
-
} as const,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 解析尺寸值
|
|
26
|
-
*/
|
|
27
|
-
parseSize: (size: Size | number | `${number}${CSSUnit}`): number | string => {
|
|
28
|
-
if (typeof size === 'number') {
|
|
29
|
-
return `${size}px`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (typeof size === 'string') {
|
|
33
|
-
if (size in containerStyles.SIZE_MAP) {
|
|
34
|
-
return containerStyles.SIZE_MAP[size as keyof typeof containerStyles.SIZE_MAP];
|
|
35
|
-
}
|
|
36
|
-
return size;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return `${containerStyles.SIZE_MAP.default}px`;
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 获取基础样式
|
|
44
|
-
*/
|
|
45
|
-
getBaseStyle: (props: ContainerProps): React.CSSProperties => {
|
|
46
|
-
const {
|
|
47
|
-
size = 'default',
|
|
48
|
-
maxWidth,
|
|
49
|
-
padding = 'medium',
|
|
50
|
-
margin = 'medium',
|
|
51
|
-
align = 'stretch',
|
|
52
|
-
center = false,
|
|
53
|
-
scrollable = false,
|
|
54
|
-
scrollDirection = 'vertical',
|
|
55
|
-
style = {},
|
|
56
|
-
} = props;
|
|
57
|
-
|
|
58
|
-
// 计算宽度
|
|
59
|
-
const width = size === 'fluid' ? '100%' : size === 'full' ? '100%' : containerStyles['parseSize'](size);
|
|
60
|
-
|
|
61
|
-
// 计算最大宽度
|
|
62
|
-
const finalMaxWidth =
|
|
63
|
-
maxWidth !== undefined
|
|
64
|
-
? typeof maxWidth === 'number'
|
|
65
|
-
? `${maxWidth}px`
|
|
66
|
-
: containerStyles['parseSize'](maxWidth as Size)
|
|
67
|
-
: size === 'fluid'
|
|
68
|
-
? 'none'
|
|
69
|
-
: containerStyles.SIZE_MAP[size as keyof typeof containerStyles.SIZE_MAP];
|
|
70
|
-
|
|
71
|
-
// 计算内边距
|
|
72
|
-
const paddingValue =
|
|
73
|
-
typeof padding === 'number'
|
|
74
|
-
? `${padding}px`
|
|
75
|
-
: typeof padding === 'string' && padding in containerStyles.SIZE_MAP
|
|
76
|
-
? `${containerStyles.SIZE_MAP[padding as keyof typeof containerStyles.SIZE_MAP]}px`
|
|
77
|
-
: containerStyles['parseSize'](padding);
|
|
78
|
-
|
|
79
|
-
// 计算外边距
|
|
80
|
-
const marginValue =
|
|
81
|
-
typeof margin === 'number'
|
|
82
|
-
? `${margin}px`
|
|
83
|
-
: typeof margin === 'string' && margin in containerStyles.SIZE_MAP
|
|
84
|
-
? `${containerStyles.SIZE_MAP[margin as keyof typeof containerStyles.SIZE_MAP]}px`
|
|
85
|
-
: containerStyles['parseSize'](margin);
|
|
86
|
-
|
|
87
|
-
// 计算对齐方式
|
|
88
|
-
const justifyContent = center ? 'center' : containerStyles['ALIGN_MAP'][align] || 'stretch';
|
|
89
|
-
|
|
90
|
-
// 计算滚动样式
|
|
91
|
-
const overflow = scrollable
|
|
92
|
-
? {
|
|
93
|
-
overflowX: (scrollDirection === 'horizontal' || scrollDirection === 'both' ? 'auto' : 'hidden') as any,
|
|
94
|
-
overflowY: (scrollDirection === 'vertical' || scrollDirection === 'both' ? 'auto' : 'hidden') as any,
|
|
95
|
-
}
|
|
96
|
-
: {
|
|
97
|
-
overflow: 'visible' as any,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
width,
|
|
102
|
-
maxWidth: finalMaxWidth,
|
|
103
|
-
padding: paddingValue,
|
|
104
|
-
margin: center ? '0 auto' : marginValue,
|
|
105
|
-
display: 'flex',
|
|
106
|
-
flexDirection: 'column',
|
|
107
|
-
justifyContent,
|
|
108
|
-
alignItems: center ? 'center' : undefined,
|
|
109
|
-
boxSizing: 'border-box',
|
|
110
|
-
...overflow,
|
|
111
|
-
...style,
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 获取类名
|
|
117
|
-
*/
|
|
118
|
-
getClassName: (props: ContainerProps): string => {
|
|
119
|
-
const { size = 'default', align = 'stretch', center = false, scrollable = false, className = '' } = props;
|
|
120
|
-
|
|
121
|
-
const baseClass = 'taro-uno-container';
|
|
122
|
-
const sizeClass = `${baseClass}--${size}`;
|
|
123
|
-
const alignClass = `${baseClass}--${align}`;
|
|
124
|
-
const centerClass = center ? `${baseClass}--center` : '';
|
|
125
|
-
const scrollableClass = scrollable ? `${baseClass}--scrollable` : '';
|
|
126
|
-
|
|
127
|
-
return [baseClass, sizeClass, alignClass, centerClass, scrollableClass, className].filter(Boolean).join(' ');
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 获取响应式样式
|
|
132
|
-
*/
|
|
133
|
-
getResponsiveStyle: (responsive: ContainerProps['responsive']): React.CSSProperties => {
|
|
134
|
-
if (!responsive) return {};
|
|
135
|
-
|
|
136
|
-
const responsiveStyle: React.CSSProperties = {};
|
|
137
|
-
|
|
138
|
-
Object.entries(responsive).forEach(([_breakpoint, props]) => {
|
|
139
|
-
if (props) {
|
|
140
|
-
// 这里需要配合CSS-in-JS库来处理响应式样式
|
|
141
|
-
// 暂时返回空对象
|
|
142
|
-
// Breakpoint value: containerStyles['getBreakpointValue'](breakpoint)
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
return responsiveStyle;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 获取断点值
|
|
151
|
-
*/
|
|
152
|
-
getBreakpointValue: (breakpoint: string): number => {
|
|
153
|
-
const breakpoints = {
|
|
154
|
-
xs: 0,
|
|
155
|
-
sm: 640,
|
|
156
|
-
md: 768,
|
|
157
|
-
lg: 1024,
|
|
158
|
-
xl: 1280,
|
|
159
|
-
xxl: 1536,
|
|
160
|
-
};
|
|
161
|
-
return breakpoints[breakpoint as keyof typeof breakpoints] || 0;
|
|
162
|
-
},
|
|
163
|
-
};
|
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render, screen, fireEvent, act } from '@testing-library/react'
|
|
3
|
-
import { Container } from '../Container'
|
|
4
|
-
import type { ContainerProps, ContainerRef } from '../Container.types'
|
|
5
|
-
|
|
6
|
-
// Mock Taro components
|
|
7
|
-
vi.mock('@tarojs/components', () => ({
|
|
8
|
-
View: 'div'
|
|
9
|
-
}))
|
|
10
|
-
|
|
11
|
-
// Mock styles
|
|
12
|
-
vi.mock('../Container.styles', () => ({
|
|
13
|
-
containerStyles: {
|
|
14
|
-
SIZE_MAP: {
|
|
15
|
-
small: 320,
|
|
16
|
-
medium: 768,
|
|
17
|
-
large: 1024,
|
|
18
|
-
default: 1200,
|
|
19
|
-
full: '100%',
|
|
20
|
-
fluid: '100%'
|
|
21
|
-
},
|
|
22
|
-
ALIGN_MAP: {
|
|
23
|
-
start: 'flex-start',
|
|
24
|
-
center: 'center',
|
|
25
|
-
end: 'flex-end',
|
|
26
|
-
stretch: 'stretch'
|
|
27
|
-
},
|
|
28
|
-
parseSize: (size: any) => {
|
|
29
|
-
if (typeof size === 'number') return `${size}px`
|
|
30
|
-
const sizeMap = { small: 320, medium: 768, large: 1024, default: 1200, full: '100%', fluid: '100%' }
|
|
31
|
-
if (typeof size === 'string' && size in sizeMap) {
|
|
32
|
-
return sizeMap[size as keyof typeof sizeMap]
|
|
33
|
-
}
|
|
34
|
-
return size || '1200px'
|
|
35
|
-
},
|
|
36
|
-
getBaseStyle: (props: any) => ({
|
|
37
|
-
maxWidth: props.maxWidth || 1200,
|
|
38
|
-
padding: '16px',
|
|
39
|
-
margin: '16px',
|
|
40
|
-
display: 'flex',
|
|
41
|
-
alignItems: props.center ? 'center' : 'stretch',
|
|
42
|
-
overflow: props.scrollable ? 'auto' : 'visible'
|
|
43
|
-
}),
|
|
44
|
-
getResponsiveStyle: (responsive: any) => responsive ? { '@media (max-width: 768px)': { maxWidth: '100%' } } : {},
|
|
45
|
-
getClassName: (props: any) => `taro-uno-container taro-uno-container--${props.size} taro-uno-container--${props.align} ${props.className || ''}`
|
|
46
|
-
}
|
|
47
|
-
}))
|
|
48
|
-
|
|
49
|
-
describe('Container Component', () => {
|
|
50
|
-
const mockRef = React.createRef<ContainerRef>()
|
|
51
|
-
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
vi.clearAllMocks()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
describe('Rendering', () => {
|
|
57
|
-
it('renders container with default props', () => {
|
|
58
|
-
render(<Container data-testid="container">Test Content</Container>)
|
|
59
|
-
const container = screen.getByTestId('container')
|
|
60
|
-
expect(container).toBeInTheDocument()
|
|
61
|
-
expect(container).toHaveTextContent('Test Content')
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('renders container with custom size', () => {
|
|
65
|
-
render(<Container size="large" data-testid="container">Large Container</Container>)
|
|
66
|
-
const container = screen.getByTestId('container')
|
|
67
|
-
expect(container).toBeInTheDocument()
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('renders container with custom maxWidth', () => {
|
|
71
|
-
render(<Container maxWidth={800} data-testid="container">Custom Width</Container>)
|
|
72
|
-
const container = screen.getByTestId('container')
|
|
73
|
-
expect(container).toBeInTheDocument()
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('renders container with center alignment', () => {
|
|
77
|
-
render(<Container center data-testid="container">Centered</Container>)
|
|
78
|
-
const container = screen.getByTestId('container')
|
|
79
|
-
expect(container).toBeInTheDocument()
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('renders container with scrollable content', () => {
|
|
83
|
-
render(<Container scrollable data-testid="container">Scrollable</Container>)
|
|
84
|
-
const container = screen.getByTestId('container')
|
|
85
|
-
expect(container).toBeInTheDocument()
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('renders container with custom className', () => {
|
|
89
|
-
render(<Container className="custom-container" data-testid="container">Custom Class</Container>)
|
|
90
|
-
const container = screen.getByTestId('container')
|
|
91
|
-
expect(container).toBeInTheDocument()
|
|
92
|
-
expect(container).toHaveClass('custom-container')
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('renders container with responsive props', () => {
|
|
96
|
-
render(<Container responsive={{ xs: { size: 'small' } }} data-testid="container">Responsive</Container>)
|
|
97
|
-
const container = screen.getByTestId('container')
|
|
98
|
-
expect(container).toBeInTheDocument()
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('renders empty container', () => {
|
|
102
|
-
render(<Container data-testid="container" />)
|
|
103
|
-
const container = screen.getByTestId('container')
|
|
104
|
-
expect(container).toBeInTheDocument()
|
|
105
|
-
expect(container).toBeEmptyDOMElement()
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('renders container with multiple children', () => {
|
|
109
|
-
render(
|
|
110
|
-
<Container data-testid="container">
|
|
111
|
-
<div>Child 1</div>
|
|
112
|
-
<div>Child 2</div>
|
|
113
|
-
<div>Child 3</div>
|
|
114
|
-
</Container>
|
|
115
|
-
)
|
|
116
|
-
const container = screen.getByTestId('container')
|
|
117
|
-
expect(container).toBeInTheDocument()
|
|
118
|
-
expect(container.children).toHaveLength(3)
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
describe('Event Handling', () => {
|
|
123
|
-
it('handles click events', () => {
|
|
124
|
-
const handleClick = vi.fn()
|
|
125
|
-
render(<Container onClick={handleClick} data-testid="container">Clickable</Container>)
|
|
126
|
-
const container = screen.getByTestId('container')
|
|
127
|
-
fireEvent.click(container)
|
|
128
|
-
expect(handleClick).toHaveBeenCalledTimes(1)
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it('handles scroll events', () => {
|
|
132
|
-
const handleScroll = vi.fn()
|
|
133
|
-
render(<Container onScroll={handleScroll} data-testid="container">Scrollable</Container>)
|
|
134
|
-
const container = screen.getByTestId('container')
|
|
135
|
-
fireEvent.scroll(container)
|
|
136
|
-
expect(handleScroll).toHaveBeenCalledTimes(1)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
it('handles multiple event handlers', () => {
|
|
140
|
-
const handleClick = vi.fn()
|
|
141
|
-
const handleScroll = vi.fn()
|
|
142
|
-
render(
|
|
143
|
-
<Container onClick={handleClick} onScroll={handleScroll} data-testid="container">
|
|
144
|
-
Events
|
|
145
|
-
</Container>
|
|
146
|
-
)
|
|
147
|
-
const container = screen.getByTestId('container')
|
|
148
|
-
fireEvent.click(container)
|
|
149
|
-
fireEvent.scroll(container)
|
|
150
|
-
expect(handleClick).toHaveBeenCalledTimes(1)
|
|
151
|
-
expect(handleScroll).toHaveBeenCalledTimes(1)
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
describe('Props Updates', () => {
|
|
156
|
-
it('updates size prop correctly', () => {
|
|
157
|
-
const { rerender } = render(<Container size="small" data-testid="container">Size Test</Container>)
|
|
158
|
-
const container = screen.getByTestId('container')
|
|
159
|
-
rerender(<Container size="large" data-testid="container">Size Test</Container>)
|
|
160
|
-
expect(container).toBeInTheDocument()
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('updates align prop correctly', () => {
|
|
164
|
-
const { rerender } = render(<Container align="start" data-testid="container">Align Test</Container>)
|
|
165
|
-
const container = screen.getByTestId('container')
|
|
166
|
-
rerender(<Container align="center" data-testid="container">Align Test</Container>)
|
|
167
|
-
expect(container).toBeInTheDocument()
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('updates center prop correctly', () => {
|
|
171
|
-
const { rerender } = render(<Container center={false} data-testid="container">Center Test</Container>)
|
|
172
|
-
const container = screen.getByTestId('container')
|
|
173
|
-
rerender(<Container center={true} data-testid="container">Center Test</Container>)
|
|
174
|
-
expect(container).toBeInTheDocument()
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('updates scrollable prop correctly', () => {
|
|
178
|
-
const { rerender } = render(<Container scrollable={false} data-testid="container">Scroll Test</Container>)
|
|
179
|
-
const container = screen.getByTestId('container')
|
|
180
|
-
rerender(<Container scrollable={true} data-testid="container">Scroll Test</Container>)
|
|
181
|
-
expect(container).toBeInTheDocument()
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('updates scrollDirection prop correctly', () => {
|
|
185
|
-
const { rerender } = render(<Container scrollDirection="vertical" data-testid="container">Direction Test</Container>)
|
|
186
|
-
const container = screen.getByTestId('container')
|
|
187
|
-
rerender(<Container scrollDirection="horizontal" data-testid="container">Direction Test</Container>)
|
|
188
|
-
expect(container).toBeInTheDocument()
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
describe('Ref API', () => {
|
|
193
|
-
it('exposes ref methods correctly', () => {
|
|
194
|
-
render(<Container ref={mockRef} data-testid="container">Ref Test</Container>)
|
|
195
|
-
|
|
196
|
-
act(() => {
|
|
197
|
-
if (mockRef.current) {
|
|
198
|
-
expect(mockRef.current.getSize()).toBe('default')
|
|
199
|
-
expect(mockRef.current.getAlign()).toBe('stretch')
|
|
200
|
-
expect(mockRef.current.getMaxWidth()).toBe(1200)
|
|
201
|
-
}
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
it('sets size via ref method', () => {
|
|
206
|
-
render(<Container ref={mockRef} data-testid="container">Ref Size Test</Container>)
|
|
207
|
-
|
|
208
|
-
act(() => {
|
|
209
|
-
if (mockRef.current) {
|
|
210
|
-
expect(() => mockRef.current.setSize('large')).not.toThrow()
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('sets align via ref method', () => {
|
|
216
|
-
render(<Container ref={mockRef} data-testid="container">Ref Align Test</Container>)
|
|
217
|
-
|
|
218
|
-
act(() => {
|
|
219
|
-
if (mockRef.current) {
|
|
220
|
-
expect(() => mockRef.current.setAlign('center')).not.toThrow()
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
it('sets maxWidth via ref method', () => {
|
|
226
|
-
render(<Container ref={mockRef} data-testid="container">Ref MaxWidth Test</Container>)
|
|
227
|
-
|
|
228
|
-
act(() => {
|
|
229
|
-
if (mockRef.current) {
|
|
230
|
-
expect(() => mockRef.current.setMaxWidth(800)).not.toThrow()
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
it('calls scrollIntoView via ref method', () => {
|
|
236
|
-
render(<Container ref={mockRef} data-testid="container">Ref Scroll Test</Container>)
|
|
237
|
-
|
|
238
|
-
act(() => {
|
|
239
|
-
if (mockRef.current) {
|
|
240
|
-
// In mock environment, scrollIntoView might not be available
|
|
241
|
-
// So we test that the method exists and can be called
|
|
242
|
-
expect(typeof mockRef.current.scrollIntoView).toBe('function')
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('provides element access via ref', () => {
|
|
248
|
-
render(<Container ref={mockRef} data-testid="container">Ref Element Test</Container>)
|
|
249
|
-
|
|
250
|
-
act(() => {
|
|
251
|
-
if (mockRef.current) {
|
|
252
|
-
expect(mockRef.current.element).toBeDefined()
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
})
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
describe('Accessibility', () => {
|
|
259
|
-
it('has proper role attribute', () => {
|
|
260
|
-
render(<Container role="main" data-testid="container">Accessible</Container>)
|
|
261
|
-
const container = screen.getByTestId('container')
|
|
262
|
-
expect(container).toHaveAttribute('role', 'main')
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
it('supports aria-label', () => {
|
|
266
|
-
render(<Container aria-label="Main container" data-testid="container">Labeled</Container>)
|
|
267
|
-
const container = screen.getByTestId('container')
|
|
268
|
-
expect(container).toHaveAttribute('aria-label', 'Main container')
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
it('supports aria-labelledby', () => {
|
|
272
|
-
render(<Container aria-labelledby="container-title" data-testid="container">Labelled By</Container>)
|
|
273
|
-
const container = screen.getByTestId('container')
|
|
274
|
-
expect(container).toHaveAttribute('aria-labelledby', 'container-title')
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
it('supports tabIndex for keyboard navigation', () => {
|
|
278
|
-
render(<Container tabIndex={0} data-testid="container">Tabbable</Container>)
|
|
279
|
-
const container = screen.getByTestId('container')
|
|
280
|
-
expect(container).toHaveAttribute('tabindex', '0')
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
it('supports data attributes', () => {
|
|
284
|
-
render(<Container data-testid="container" data-custom="value">Data Attr</Container>)
|
|
285
|
-
const container = screen.getByTestId('container')
|
|
286
|
-
expect(container).toHaveAttribute('data-custom', 'value')
|
|
287
|
-
})
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
describe('Edge Cases', () => {
|
|
291
|
-
it('handles invalid size prop gracefully', () => {
|
|
292
|
-
render(<Container size="invalid" as any data-testid="container">Invalid Size</Container>)
|
|
293
|
-
expect(screen.getByTestId('container')).toBeInTheDocument()
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
it('handles invalid align prop gracefully', () => {
|
|
297
|
-
render(<Container align="invalid" as any data-testid="container">Invalid Align</Container>)
|
|
298
|
-
expect(screen.getByTestId('container')).toBeInTheDocument()
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
it('handles zero maxWidth', () => {
|
|
302
|
-
render(<Container maxWidth={0} data-testid="container">Zero Width</Container>)
|
|
303
|
-
const container = screen.getByTestId('container')
|
|
304
|
-
expect(container).toBeInTheDocument()
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
it('handles negative maxWidth gracefully', () => {
|
|
308
|
-
const { container } = render(<Container maxWidth={-100} data-testid="container">Negative Width</Container>)
|
|
309
|
-
expect(screen.getByTestId('container')).toBeInTheDocument()
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
it('handles very large maxWidth', () => {
|
|
313
|
-
render(<Container maxWidth={999999} data-testid="container">Large Width</Container>)
|
|
314
|
-
const container = screen.getByTestId('container')
|
|
315
|
-
expect(container).toBeInTheDocument()
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
it('handles undefined children', () => {
|
|
319
|
-
render(<Container data-testid="container">{undefined}</Container>)
|
|
320
|
-
const container = screen.getByTestId('container')
|
|
321
|
-
expect(container).toBeInTheDocument()
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
it('handles null children', () => {
|
|
325
|
-
render(<Container data-testid="container">{null}</Container>)
|
|
326
|
-
const container = screen.getByTestId('container')
|
|
327
|
-
expect(container).toBeInTheDocument()
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
it('handles boolean children', () => {
|
|
331
|
-
render(<Container data-testid="container">{true}</Container>)
|
|
332
|
-
const container = screen.getByTestId('container')
|
|
333
|
-
expect(container).toBeInTheDocument()
|
|
334
|
-
})
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
describe('Responsive Behavior', () => {
|
|
338
|
-
it('applies responsive styles correctly', () => {
|
|
339
|
-
const responsiveProps = {
|
|
340
|
-
xs: { size: 'small' },
|
|
341
|
-
sm: { size: 'medium' },
|
|
342
|
-
md: { size: 'large' }
|
|
343
|
-
}
|
|
344
|
-
render(<Container responsive={responsiveProps} data-testid="container">Responsive</Container>)
|
|
345
|
-
const container = screen.getByTestId('container')
|
|
346
|
-
expect(container).toBeInTheDocument()
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
it('handles empty responsive object', () => {
|
|
350
|
-
render(<Container responsive={{}} data-testid="container">Empty Responsive</Container>)
|
|
351
|
-
const container = screen.getByTestId('container')
|
|
352
|
-
expect(container).toBeInTheDocument()
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
it('handles partial responsive object', () => {
|
|
356
|
-
render(<Container responsive={{ xs: { size: 'small' } }} data-testid="container">Partial Responsive</Container>)
|
|
357
|
-
const container = screen.getByTestId('container')
|
|
358
|
-
expect(container).toBeInTheDocument()
|
|
359
|
-
})
|
|
360
|
-
})
|
|
361
|
-
|
|
362
|
-
describe('Performance', () => {
|
|
363
|
-
it('renders efficiently with many children', () => {
|
|
364
|
-
const children = Array.from({ length: 100 }, (_, i) => <div key={i}>Child {i}</div>)
|
|
365
|
-
const { container } = render(<Container data-testid="container">{children}</Container>)
|
|
366
|
-
expect(screen.getByTestId('container')).toBeInTheDocument()
|
|
367
|
-
expect(screen.getByTestId('container').children).toHaveLength(100)
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
it('handles frequent prop updates efficiently', () => {
|
|
371
|
-
const { rerender } = render(<Container size="small" data-testid="container">Performance</Container>)
|
|
372
|
-
|
|
373
|
-
for (let i = 0; i < 10; i++) {
|
|
374
|
-
rerender(<Container size={i % 2 === 0 ? 'small' : 'large'} data-testid="container">Performance</Container>)
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
expect(screen.getByTestId('container')).toBeInTheDocument()
|
|
378
|
-
})
|
|
379
|
-
})
|
|
380
|
-
})
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useRef, useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import { View } from '@tarojs/components';
|
|
3
|
-
import { containerStyles } from './Container.styles';
|
|
4
|
-
import type { ContainerProps, ContainerRef, ContainerSize, ContainerAlign } from './Container.types';
|
|
5
|
-
|
|
6
|
-
/** Container组件 */
|
|
7
|
-
export const ContainerComponent = forwardRef<ContainerRef, ContainerProps>((props, ref) => {
|
|
8
|
-
const {
|
|
9
|
-
children,
|
|
10
|
-
size = 'default',
|
|
11
|
-
maxWidth,
|
|
12
|
-
padding = 'medium',
|
|
13
|
-
margin = 'medium',
|
|
14
|
-
align = 'stretch',
|
|
15
|
-
center = false,
|
|
16
|
-
scrollable = false,
|
|
17
|
-
scrollDirection = 'vertical',
|
|
18
|
-
className,
|
|
19
|
-
style,
|
|
20
|
-
onClick,
|
|
21
|
-
} = props;
|
|
22
|
-
|
|
23
|
-
const containerRef = useRef<any>(null);
|
|
24
|
-
const [internalSize, setInternalSize] = useState<ContainerSize>(size);
|
|
25
|
-
const [internalAlign, setInternalAlign] = useState<ContainerAlign>(align);
|
|
26
|
-
const [internalCenter, setInternalCenter] = useState(center);
|
|
27
|
-
const [internalScrollable, setInternalScrollable] = useState(scrollable);
|
|
28
|
-
const [internalScrollDirection, setInternalScrollDirection] = useState(scrollDirection);
|
|
29
|
-
|
|
30
|
-
// 更新内部状态
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setInternalSize(size);
|
|
33
|
-
}, [size]);
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
setInternalAlign(align);
|
|
37
|
-
}, [align]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
setInternalCenter(center);
|
|
41
|
-
}, [center]);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setInternalScrollable(scrollable);
|
|
45
|
-
}, [scrollable]);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
setInternalScrollDirection(scrollDirection);
|
|
49
|
-
}, [scrollDirection]);
|
|
50
|
-
|
|
51
|
-
// 处理点击事件
|
|
52
|
-
const handleClick = useCallback(
|
|
53
|
-
(event: any) => {
|
|
54
|
-
onClick?.(event);
|
|
55
|
-
},
|
|
56
|
-
[onClick],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// 计算样式
|
|
60
|
-
const containerStyle = containerStyles['getBaseStyle']({
|
|
61
|
-
size: internalSize,
|
|
62
|
-
maxWidth,
|
|
63
|
-
padding,
|
|
64
|
-
margin,
|
|
65
|
-
align: internalAlign,
|
|
66
|
-
center: internalCenter,
|
|
67
|
-
scrollable: internalScrollable,
|
|
68
|
-
scrollDirection: internalScrollDirection,
|
|
69
|
-
style: style || {},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// 计算类名
|
|
73
|
-
const containerClassName = containerStyles['getClassName']({
|
|
74
|
-
size: internalSize,
|
|
75
|
-
align: internalAlign,
|
|
76
|
-
center: internalCenter,
|
|
77
|
-
scrollable: internalScrollable,
|
|
78
|
-
className: className || '',
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// 暴露给外部的引用方法
|
|
82
|
-
React.useImperativeHandle(
|
|
83
|
-
ref,
|
|
84
|
-
() => ({
|
|
85
|
-
element: containerRef.current,
|
|
86
|
-
getSize: () => internalSize,
|
|
87
|
-
getAlign: () => internalAlign,
|
|
88
|
-
getMaxWidth: () => maxWidth || containerStyles.SIZE_MAP[internalSize as keyof typeof containerStyles.SIZE_MAP],
|
|
89
|
-
setSize: (newSize: ContainerSize) => {
|
|
90
|
-
setInternalSize(newSize);
|
|
91
|
-
},
|
|
92
|
-
setAlign: (newAlign: ContainerAlign) => {
|
|
93
|
-
setInternalAlign(newAlign);
|
|
94
|
-
},
|
|
95
|
-
setMaxWidth: (newMaxWidth: number | string) => {
|
|
96
|
-
if (containerRef.current) {
|
|
97
|
-
containerRef.current.style.maxWidth = typeof newMaxWidth === 'number' ? `${newMaxWidth}px` : newMaxWidth;
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
scrollIntoView: (options?: ScrollIntoViewOptions) => {
|
|
101
|
-
containerRef.current?.scrollIntoView(options);
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
[internalSize, internalAlign, maxWidth],
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<View
|
|
109
|
-
ref={containerRef}
|
|
110
|
-
className={containerClassName}
|
|
111
|
-
style={{ ...containerStyle, ...style }}
|
|
112
|
-
onClick={handleClick}
|
|
113
|
-
>
|
|
114
|
-
{children}
|
|
115
|
-
</View>
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
/** Container组件显示名称 */
|
|
120
|
-
ContainerComponent.displayName = 'Container';
|
|
121
|
-
|
|
122
|
-
/** 导出Container组件 */
|
|
123
|
-
export const Container = ContainerComponent;
|