react-native-system-ui 1.0.1 → 1.0.3
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 +44 -24
- package/dist/cjs/components/action-sheet/ActionSheet.js +1 -297
- package/dist/cjs/components/action-sheet/index.js +1 -16
- package/dist/cjs/components/action-sheet/tokens.js +1 -133
- package/dist/cjs/components/area/Area.js +1 -127
- package/dist/cjs/components/area/index.js +1 -9
- package/dist/cjs/components/area/tokens.js +1 -14
- package/dist/cjs/components/avatar/Avatar.js +1 -125
- package/dist/cjs/components/avatar/index.js +1 -18
- package/dist/cjs/components/avatar/tokens.js +1 -56
- package/dist/cjs/components/badge/Badge.js +1 -166
- package/dist/cjs/components/badge/index.js +1 -8
- package/dist/cjs/components/badge/tokens.js +1 -81
- package/dist/cjs/components/button/Button.js +1 -203
- package/dist/cjs/components/button/ButtonContext.js +1 -12
- package/dist/cjs/components/button/ButtonGroup.js +1 -65
- package/dist/cjs/components/button/index.js +1 -12
- package/dist/cjs/components/button/tokens.js +1 -176
- package/dist/cjs/components/calendar/Calendar.js +1 -452
- package/dist/cjs/components/calendar/index.js +1 -9
- package/dist/cjs/components/calendar/tokens.js +1 -129
- package/dist/cjs/components/cascader/Cascader.js +1 -481
- package/dist/cjs/components/cascader/index.js +1 -15
- package/dist/cjs/components/cascader/tokens.js +1 -138
- package/dist/cjs/components/cascader/useCascaderExtend.js +1 -39
- package/dist/cjs/components/cell/Cell.js +1 -181
- package/dist/cjs/components/cell/CellContext.js +1 -19
- package/dist/cjs/components/cell/CellGroup.js +1 -100
- package/dist/cjs/components/cell/index.js +1 -19
- package/dist/cjs/components/cell/tokens.js +1 -173
- package/dist/cjs/components/checkbox/Checkbox.js +1 -251
- package/dist/cjs/components/checkbox/CheckboxContext.js +1 -12
- package/dist/cjs/components/checkbox/CheckboxGroup.js +1 -148
- package/dist/cjs/components/checkbox/index.js +1 -16
- package/dist/cjs/components/checkbox/tokens.js +1 -97
- package/dist/cjs/components/circle/Circle.js +1 -212
- package/dist/cjs/components/circle/index.js +1 -9
- package/dist/cjs/components/circle/tokens.js +1 -55
- package/dist/cjs/components/collapse/Collapse.js +1 -311
- package/dist/cjs/components/collapse/index.js +1 -8
- package/dist/cjs/components/collapse/tokens.js +1 -81
- package/dist/cjs/components/config-provider/ConfigProvider.js +1 -44
- package/dist/cjs/components/config-provider/DirectionContext.js +1 -15
- package/dist/cjs/components/config-provider/LocaleContext.js +1 -16
- package/dist/cjs/components/config-provider/index.js +1 -40
- package/dist/cjs/components/config-provider/locale/en-US.js +1 -112
- package/dist/cjs/components/config-provider/locale/zh-CN.js +1 -112
- package/dist/cjs/components/config-provider/tokens.js +1 -11
- package/dist/cjs/components/config-provider/useDirection.js +1 -16
- package/dist/cjs/components/config-provider/useLocale.js +1 -16
- package/dist/cjs/components/count-down/CountDown.js +1 -88
- package/dist/cjs/components/count-down/index.js +1 -15
- package/dist/cjs/components/count-down/tokens.js +1 -34
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +1 -319
- package/dist/cjs/components/datetime-picker/index.js +1 -9
- package/dist/cjs/components/datetime-picker/tokens.js +1 -22
- package/dist/cjs/components/dialog/Dialog.js +1 -433
- package/dist/cjs/components/dialog/imperative.js +1 -199
- package/dist/cjs/components/dialog/index.js +1 -23
- package/dist/cjs/components/dialog/tokens.js +1 -64
- package/dist/cjs/components/divider/Divider.js +1 -126
- package/dist/cjs/components/divider/index.js +1 -8
- package/dist/cjs/components/divider/tokens.js +1 -62
- package/dist/cjs/components/empty/Empty.js +1 -125
- package/dist/cjs/components/empty/index.js +1 -8
- package/dist/cjs/components/empty/tokens.js +1 -55
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +1 -74
- package/dist/cjs/components/error-boundary/index.js +1 -19
- package/dist/cjs/components/field/Field.js +1 -565
- package/dist/cjs/components/field/index.js +1 -29
- package/dist/cjs/components/field/tokens.js +1 -150
- package/dist/cjs/components/flex/Flex.js +1 -85
- package/dist/cjs/components/flex/FlexContext.js +1 -12
- package/dist/cjs/components/flex/FlexItem.js +1 -95
- package/dist/cjs/components/flex/index.js +1 -19
- package/dist/cjs/components/flex/tokens.js +1 -21
- package/dist/cjs/components/form/Form.js +1 -340
- package/dist/cjs/components/form/FormContext.js +1 -12
- package/dist/cjs/components/form/FormItem.js +1 -151
- package/dist/cjs/components/form/FormList.js +1 -95
- package/dist/cjs/components/form/index.js +1 -50
- package/dist/cjs/components/form/tokens.js +1 -14
- package/dist/cjs/components/form/utils.js +1 -56
- package/dist/cjs/components/grid/Grid.js +1 -118
- package/dist/cjs/components/grid/GridContext.js +1 -12
- package/dist/cjs/components/grid/GridItem.js +1 -158
- package/dist/cjs/components/grid/index.js +1 -12
- package/dist/cjs/components/grid/tokens.js +1 -105
- package/dist/cjs/components/image/Image.js +1 -263
- package/dist/cjs/components/image/index.js +1 -16
- package/dist/cjs/components/image/tokens.js +1 -66
- package/dist/cjs/components/image-preview/ImagePreview.js +1 -398
- package/dist/cjs/components/image-preview/imperative.js +1 -72
- package/dist/cjs/components/image-preview/index.js +1 -17
- package/dist/cjs/components/image-preview/tokens.js +1 -43
- package/dist/cjs/components/index.js +1 -769
- package/dist/cjs/components/input/Input.js +1 -122
- package/dist/cjs/components/input/index.js +1 -15
- package/dist/cjs/components/input/tokens.js +1 -22
- package/dist/cjs/components/loading/Loading.js +1 -76
- package/dist/cjs/components/loading/index.js +1 -8
- package/dist/cjs/components/loading/tokens.js +1 -32
- package/dist/cjs/components/nav-bar/NavBar.js +1 -196
- package/dist/cjs/components/nav-bar/index.js +1 -16
- package/dist/cjs/components/nav-bar/tokens.js +1 -90
- package/dist/cjs/components/notice-bar/NoticeBar.js +1 -369
- package/dist/cjs/components/notice-bar/index.js +1 -8
- package/dist/cjs/components/notice-bar/tokens.js +1 -39
- package/dist/cjs/components/notify/Notify.js +1 -262
- package/dist/cjs/components/notify/imperative.js +1 -145
- package/dist/cjs/components/notify/index.js +1 -10
- package/dist/cjs/components/notify/tokens.js +1 -74
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +1 -487
- package/dist/cjs/components/number-keyboard/index.js +1 -15
- package/dist/cjs/components/number-keyboard/tokens.js +1 -59
- package/dist/cjs/components/overlay/Overlay.js +1 -81
- package/dist/cjs/components/overlay/index.js +1 -28
- package/dist/cjs/components/overlay/tokens.js +1 -13
- package/dist/cjs/components/password-input/PasswordInput.js +1 -346
- package/dist/cjs/components/password-input/index.js +1 -13
- package/dist/cjs/components/password-input/tokens.js +1 -53
- package/dist/cjs/components/picker/Picker.js +1 -1056
- package/dist/cjs/components/picker/index.js +1 -15
- package/dist/cjs/components/picker/tokens.js +1 -53
- package/dist/cjs/components/popup/Popup.js +1 -518
- package/dist/cjs/components/popup/index.js +1 -15
- package/dist/cjs/components/popup/tokens.js +1 -62
- package/dist/cjs/components/portal/Portal.js +1 -50
- package/dist/cjs/components/portal/PortalContext.js +1 -15
- package/dist/cjs/components/portal/PortalHost.js +1 -253
- package/dist/cjs/components/portal/index.js +1 -25
- package/dist/cjs/components/portal/tokens.js +1 -11
- package/dist/cjs/components/progress/Progress.js +1 -216
- package/dist/cjs/components/progress/index.js +1 -14
- package/dist/cjs/components/progress/tokens.js +1 -52
- package/dist/cjs/components/radio/Radio.js +1 -245
- package/dist/cjs/components/radio/RadioContext.js +1 -12
- package/dist/cjs/components/radio/RadioGroup.js +1 -113
- package/dist/cjs/components/radio/index.js +1 -16
- package/dist/cjs/components/radio/tokens.js +1 -92
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +1 -59
- package/dist/cjs/components/safe-area-view/index.js +1 -12
- package/dist/cjs/components/safe-area-view/tokens.js +1 -11
- package/dist/cjs/components/search/Search.js +1 -215
- package/dist/cjs/components/search/index.js +1 -15
- package/dist/cjs/components/search/tokens.js +1 -54
- package/dist/cjs/components/selector/Selector.js +1 -185
- package/dist/cjs/components/selector/index.js +1 -15
- package/dist/cjs/components/selector/tokens.js +1 -100
- package/dist/cjs/components/share-sheet/ShareSheet.js +1 -286
- package/dist/cjs/components/share-sheet/index.js +1 -16
- package/dist/cjs/components/share-sheet/tokens.js +1 -55
- package/dist/cjs/components/sidebar/Sidebar.js +1 -103
- package/dist/cjs/components/sidebar/SidebarContext.js +1 -17
- package/dist/cjs/components/sidebar/SidebarItem.js +1 -103
- package/dist/cjs/components/sidebar/index.js +1 -26
- package/dist/cjs/components/sidebar/tokens.js +1 -93
- package/dist/cjs/components/skeleton/Skeleton.js +1 -162
- package/dist/cjs/components/skeleton/index.js +1 -22
- package/dist/cjs/components/skeleton/tokens.js +1 -39
- package/dist/cjs/components/slider/Slider.js +1 -633
- package/dist/cjs/components/slider/index.js +1 -8
- package/dist/cjs/components/slider/tokens.js +1 -37
- package/dist/cjs/components/space/Space.js +1 -134
- package/dist/cjs/components/space/index.js +1 -18
- package/dist/cjs/components/space/tokens.js +1 -39
- package/dist/cjs/components/stepper/Stepper.js +1 -484
- package/dist/cjs/components/stepper/index.js +1 -15
- package/dist/cjs/components/stepper/tokens.js +1 -60
- package/dist/cjs/components/swiper/Swiper.js +1 -364
- package/dist/cjs/components/swiper/SwiperItem.js +1 -12
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +1 -106
- package/dist/cjs/components/swiper/index.js +1 -40
- package/dist/cjs/components/swiper/tokens.js +1 -18
- package/dist/cjs/components/switch/Switch.js +1 -102
- package/dist/cjs/components/switch/index.js +1 -15
- package/dist/cjs/components/switch/tokens.js +1 -31
- package/dist/cjs/components/tabbar/Tabbar.js +1 -149
- package/dist/cjs/components/tabbar/TabbarContext.js +1 -17
- package/dist/cjs/components/tabbar/TabbarItem.js +1 -153
- package/dist/cjs/components/tabbar/index.js +1 -25
- package/dist/cjs/components/tabbar/tokens.js +1 -41
- package/dist/cjs/components/tabs/Tabs.js +1 -860
- package/dist/cjs/components/tabs/index.js +1 -25
- package/dist/cjs/components/tabs/tokens.js +1 -111
- package/dist/cjs/components/tag/Tag.js +1 -130
- package/dist/cjs/components/tag/index.js +1 -8
- package/dist/cjs/components/tag/tokens.js +1 -104
- package/dist/cjs/components/toast/Toast.js +1 -303
- package/dist/cjs/components/toast/imperative.js +1 -144
- package/dist/cjs/components/toast/index.js +1 -10
- package/dist/cjs/components/toast/tokens.js +1 -43
- package/dist/cjs/components/typography/Typography.js +1 -181
- package/dist/cjs/components/typography/index.js +1 -9
- package/dist/cjs/components/typography/tokens.js +1 -88
- package/dist/cjs/components/water-mark/WaterMark.js +1 -172
- package/dist/cjs/components/water-mark/index.js +1 -22
- package/dist/cjs/components/water-mark/tokens.js +1 -54
- package/dist/cjs/design-system/Text.js +1 -38
- package/dist/cjs/design-system/ThemeContext.js +1 -19
- package/dist/cjs/design-system/ThemeProvider.js +1 -31
- package/dist/cjs/design-system/createComponentTokensHook.js +1 -28
- package/dist/cjs/design-system/index.js +1 -66
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -9
- package/dist/cjs/design-system/presets.js +1 -146
- package/dist/cjs/design-system/tokens.js +1 -135
- package/dist/cjs/design-system/useTheme.js +1 -16
- package/dist/cjs/hooks/animation/index.js +1 -25
- package/dist/cjs/hooks/animation/useAnimatedTransition.js +1 -72
- package/dist/cjs/hooks/animation/useReducedMotion.js +1 -75
- package/dist/cjs/hooks/aria/index.js +1 -49
- package/dist/cjs/hooks/aria/useAriaListBox.js +1 -50
- package/dist/cjs/hooks/aria/useAriaOverlay.js +1 -50
- package/dist/cjs/hooks/aria/useAriaPress.js +1 -94
- package/dist/cjs/hooks/aria/useAriaToggle.js +1 -41
- package/dist/cjs/hooks/gesture/index.js +1 -16
- package/dist/cjs/hooks/gesture/useGestureScroll.js +1 -129
- package/dist/cjs/hooks/index.js +1 -96
- package/dist/cjs/hooks/overlay/OverlayStackStore.js +1 -106
- package/dist/cjs/hooks/overlay/index.js +1 -27
- package/dist/cjs/hooks/overlay/useOverlayStack.js +1 -53
- package/dist/cjs/hooks/useControllableValue.js +1 -41
- package/dist/cjs/hooks/useCountDown.js +1 -99
- package/dist/cjs/hooks/useHairline.js +1 -46
- package/dist/cjs/hooks/useSafeAreaPadding.js +1 -38
- package/dist/cjs/index.js +1 -104
- package/dist/cjs/nativewind.js +1 -0
- package/dist/cjs/platform/animation.js +1 -22
- package/dist/cjs/platform/history.js +1 -14
- package/dist/cjs/platform/index.js +1 -60
- package/dist/cjs/platform/measure.js +1 -39
- package/dist/cjs/platform/runtime.js +1 -19
- package/dist/cjs/platform/scrollLock.js +1 -24
- package/dist/cjs/utils/array.js +1 -12
- package/dist/cjs/utils/color.js +1 -33
- package/dist/cjs/utils/compare.js +1 -21
- package/dist/cjs/utils/createPlatformShadow.js +1 -52
- package/dist/cjs/utils/date.js +1 -45
- package/dist/cjs/utils/deepMerge.js +1 -27
- package/dist/cjs/utils/hairline.js +1 -107
- package/dist/cjs/utils/index.js +1 -148
- package/dist/cjs/utils/number.js +1 -65
- package/dist/cjs/utils/promise.js +1 -9
- package/dist/cjs/utils/render.js +1 -21
- package/dist/cjs/utils/rtl.js +1 -25
- package/dist/cjs/utils/string.js +1 -22
- package/dist/cjs/utils/validate.js +1 -39
- package/dist/es/components/action-sheet/ActionSheet.js +1 -271
- package/dist/es/components/action-sheet/index.js +1 -3
- package/dist/es/components/action-sheet/tokens.js +1 -126
- package/dist/es/components/area/Area.js +1 -113
- package/dist/es/components/area/index.js +1 -2
- package/dist/es/components/area/tokens.js +1 -8
- package/dist/es/components/avatar/Avatar.js +1 -106
- package/dist/es/components/avatar/index.js +1 -1
- package/dist/es/components/avatar/tokens.js +1 -49
- package/dist/es/components/badge/Badge.js +1 -147
- package/dist/es/components/badge/index.js +1 -2
- package/dist/es/components/badge/tokens.js +1 -75
- package/dist/es/components/button/Button.js +1 -184
- package/dist/es/components/button/ButtonContext.js +1 -1
- package/dist/es/components/button/ButtonGroup.js +1 -46
- package/dist/es/components/button/index.js +1 -7
- package/dist/es/components/button/tokens.js +1 -170
- package/dist/es/components/calendar/Calendar.js +1 -432
- package/dist/es/components/calendar/index.js +1 -2
- package/dist/es/components/calendar/tokens.js +1 -122
- package/dist/es/components/cascader/Cascader.js +1 -455
- package/dist/es/components/cascader/index.js +1 -3
- package/dist/es/components/cascader/tokens.js +1 -131
- package/dist/es/components/cascader/useCascaderExtend.js +1 -32
- package/dist/es/components/cell/Cell.js +1 -156
- package/dist/es/components/cell/CellContext.js +1 -6
- package/dist/es/components/cell/CellGroup.js +1 -81
- package/dist/es/components/cell/index.js +1 -8
- package/dist/es/components/cell/tokens.js +1 -160
- package/dist/es/components/checkbox/Checkbox.js +1 -220
- package/dist/es/components/checkbox/CheckboxContext.js +1 -1
- package/dist/es/components/checkbox/CheckboxGroup.js +1 -117
- package/dist/es/components/checkbox/index.js +1 -5
- package/dist/es/components/checkbox/tokens.js +1 -85
- package/dist/es/components/circle/Circle.js +1 -187
- package/dist/es/components/circle/index.js +1 -2
- package/dist/es/components/circle/tokens.js +1 -48
- package/dist/es/components/collapse/Collapse.js +1 -286
- package/dist/es/components/collapse/index.js +1 -2
- package/dist/es/components/collapse/tokens.js +1 -74
- package/dist/es/components/config-provider/ConfigProvider.js +1 -25
- package/dist/es/components/config-provider/DirectionContext.js +1 -2
- package/dist/es/components/config-provider/LocaleContext.js +1 -3
- package/dist/es/components/config-provider/index.js +1 -5
- package/dist/es/components/config-provider/locale/en-US.js +1 -106
- package/dist/es/components/config-provider/locale/zh-CN.js +1 -106
- package/dist/es/components/config-provider/tokens.js +1 -5
- package/dist/es/components/config-provider/useDirection.js +1 -3
- package/dist/es/components/config-provider/useLocale.js +1 -3
- package/dist/es/components/count-down/CountDown.js +1 -69
- package/dist/es/components/count-down/index.js +1 -3
- package/dist/es/components/count-down/tokens.js +1 -27
- package/dist/es/components/datetime-picker/DatetimePicker.js +1 -305
- package/dist/es/components/datetime-picker/index.js +1 -2
- package/dist/es/components/datetime-picker/tokens.js +1 -16
- package/dist/es/components/dialog/Dialog.js +1 -407
- package/dist/es/components/dialog/imperative.js +1 -185
- package/dist/es/components/dialog/index.js +1 -17
- package/dist/es/components/dialog/tokens.js +1 -57
- package/dist/es/components/divider/Divider.js +1 -107
- package/dist/es/components/divider/index.js +1 -2
- package/dist/es/components/divider/tokens.js +1 -55
- package/dist/es/components/empty/Empty.js +1 -100
- package/dist/es/components/empty/index.js +1 -2
- package/dist/es/components/empty/tokens.js +1 -48
- package/dist/es/components/error-boundary/ErrorBoundary.js +1 -62
- package/dist/es/components/error-boundary/index.js +1 -1
- package/dist/es/components/field/Field.js +1 -539
- package/dist/es/components/field/index.js +1 -6
- package/dist/es/components/field/tokens.js +1 -138
- package/dist/es/components/flex/Flex.js +1 -66
- package/dist/es/components/flex/FlexContext.js +1 -1
- package/dist/es/components/flex/FlexItem.js +1 -76
- package/dist/es/components/flex/index.js +1 -8
- package/dist/es/components/flex/tokens.js +1 -15
- package/dist/es/components/form/Form.js +1 -319
- package/dist/es/components/form/FormContext.js +1 -1
- package/dist/es/components/form/FormItem.js +1 -138
- package/dist/es/components/form/FormList.js +1 -81
- package/dist/es/components/form/index.js +1 -13
- package/dist/es/components/form/tokens.js +1 -8
- package/dist/es/components/form/utils.js +1 -45
- package/dist/es/components/grid/Grid.js +1 -99
- package/dist/es/components/grid/GridContext.js +1 -1
- package/dist/es/components/grid/GridItem.js +1 -138
- package/dist/es/components/grid/index.js +1 -6
- package/dist/es/components/grid/tokens.js +1 -98
- package/dist/es/components/image/Image.js +1 -238
- package/dist/es/components/image/index.js +1 -3
- package/dist/es/components/image/tokens.js +1 -60
- package/dist/es/components/image-preview/ImagePreview.js +1 -378
- package/dist/es/components/image-preview/imperative.js +1 -58
- package/dist/es/components/image-preview/index.js +1 -11
- package/dist/es/components/image-preview/tokens.js +1 -37
- package/dist/es/components/index.js +1 -110
- package/dist/es/components/input/Input.js +1 -109
- package/dist/es/components/input/index.js +1 -3
- package/dist/es/components/input/tokens.js +1 -16
- package/dist/es/components/loading/Loading.js +1 -57
- package/dist/es/components/loading/index.js +1 -2
- package/dist/es/components/loading/tokens.js +1 -25
- package/dist/es/components/nav-bar/NavBar.js +1 -171
- package/dist/es/components/nav-bar/index.js +1 -3
- package/dist/es/components/nav-bar/tokens.js +1 -83
- package/dist/es/components/notice-bar/NoticeBar.js +1 -344
- package/dist/es/components/notice-bar/index.js +1 -2
- package/dist/es/components/notice-bar/tokens.js +1 -32
- package/dist/es/components/notify/Notify.js +1 -242
- package/dist/es/components/notify/imperative.js +1 -131
- package/dist/es/components/notify/index.js +1 -5
- package/dist/es/components/notify/tokens.js +1 -67
- package/dist/es/components/number-keyboard/NumberKeyboard.js +1 -467
- package/dist/es/components/number-keyboard/index.js +1 -3
- package/dist/es/components/number-keyboard/tokens.js +1 -53
- package/dist/es/components/overlay/Overlay.js +1 -50
- package/dist/es/components/overlay/index.js +1 -4
- package/dist/es/components/overlay/tokens.js +1 -7
- package/dist/es/components/password-input/PasswordInput.js +1 -327
- package/dist/es/components/password-input/index.js +1 -1
- package/dist/es/components/password-input/tokens.js +1 -41
- package/dist/es/components/picker/Picker.js +1 -1031
- package/dist/es/components/picker/index.js +1 -3
- package/dist/es/components/picker/tokens.js +1 -47
- package/dist/es/components/popup/Popup.js +1 -492
- package/dist/es/components/popup/index.js +1 -3
- package/dist/es/components/popup/tokens.js +1 -55
- package/dist/es/components/portal/Portal.js +1 -37
- package/dist/es/components/portal/PortalContext.js +1 -2
- package/dist/es/components/portal/PortalHost.js +1 -234
- package/dist/es/components/portal/index.js +1 -3
- package/dist/es/components/portal/tokens.js +1 -5
- package/dist/es/components/progress/Progress.js +1 -196
- package/dist/es/components/progress/index.js +1 -3
- package/dist/es/components/progress/tokens.js +1 -45
- package/dist/es/components/radio/Radio.js +1 -214
- package/dist/es/components/radio/RadioContext.js +1 -1
- package/dist/es/components/radio/RadioGroup.js +1 -82
- package/dist/es/components/radio/index.js +1 -5
- package/dist/es/components/radio/tokens.js +1 -80
- package/dist/es/components/safe-area-view/SafeAreaView.js +1 -40
- package/dist/es/components/safe-area-view/index.js +1 -1
- package/dist/es/components/safe-area-view/tokens.js +1 -5
- package/dist/es/components/search/Search.js +1 -189
- package/dist/es/components/search/index.js +1 -3
- package/dist/es/components/search/tokens.js +1 -48
- package/dist/es/components/selector/Selector.js +1 -166
- package/dist/es/components/selector/index.js +1 -3
- package/dist/es/components/selector/tokens.js +1 -88
- package/dist/es/components/share-sheet/ShareSheet.js +1 -266
- package/dist/es/components/share-sheet/index.js +1 -3
- package/dist/es/components/share-sheet/tokens.js +1 -49
- package/dist/es/components/sidebar/Sidebar.js +1 -84
- package/dist/es/components/sidebar/SidebarContext.js +1 -3
- package/dist/es/components/sidebar/SidebarItem.js +1 -84
- package/dist/es/components/sidebar/index.js +1 -8
- package/dist/es/components/sidebar/tokens.js +1 -80
- package/dist/es/components/skeleton/Skeleton.js +1 -143
- package/dist/es/components/skeleton/index.js +1 -4
- package/dist/es/components/skeleton/tokens.js +1 -33
- package/dist/es/components/slider/Slider.js +1 -596
- package/dist/es/components/slider/index.js +1 -2
- package/dist/es/components/slider/tokens.js +1 -31
- package/dist/es/components/space/Space.js +1 -115
- package/dist/es/components/space/index.js +1 -2
- package/dist/es/components/space/tokens.js +1 -32
- package/dist/es/components/stepper/Stepper.js +1 -465
- package/dist/es/components/stepper/index.js +1 -3
- package/dist/es/components/stepper/tokens.js +1 -54
- package/dist/es/components/swiper/Swiper.js +1 -344
- package/dist/es/components/swiper/SwiperItem.js +1 -1
- package/dist/es/components/swiper/SwiperPagIndicator.js +1 -87
- package/dist/es/components/swiper/index.js +1 -10
- package/dist/es/components/swiper/tokens.js +1 -12
- package/dist/es/components/switch/Switch.js +1 -83
- package/dist/es/components/switch/index.js +1 -3
- package/dist/es/components/switch/tokens.js +1 -25
- package/dist/es/components/tabbar/Tabbar.js +1 -130
- package/dist/es/components/tabbar/TabbarContext.js +1 -3
- package/dist/es/components/tabbar/TabbarItem.js +1 -133
- package/dist/es/components/tabbar/index.js +1 -7
- package/dist/es/components/tabbar/tokens.js +1 -35
- package/dist/es/components/tabs/Tabs.js +1 -841
- package/dist/es/components/tabs/index.js +1 -7
- package/dist/es/components/tabs/tokens.js +1 -105
- package/dist/es/components/tag/Tag.js +1 -105
- package/dist/es/components/tag/index.js +1 -2
- package/dist/es/components/tag/tokens.js +1 -97
- package/dist/es/components/toast/Toast.js +1 -277
- package/dist/es/components/toast/imperative.js +1 -130
- package/dist/es/components/toast/index.js +1 -5
- package/dist/es/components/toast/tokens.js +1 -36
- package/dist/es/components/typography/Typography.js +1 -162
- package/dist/es/components/typography/index.js +1 -2
- package/dist/es/components/typography/tokens.js +1 -82
- package/dist/es/components/water-mark/WaterMark.js +1 -153
- package/dist/es/components/water-mark/index.js +1 -4
- package/dist/es/components/water-mark/tokens.js +1 -42
- package/dist/es/design-system/Text.js +1 -19
- package/dist/es/design-system/ThemeContext.js +1 -6
- package/dist/es/design-system/ThemeProvider.js +1 -17
- package/dist/es/design-system/createComponentTokensHook.js +1 -15
- package/dist/es/design-system/index.js +1 -7
- package/dist/es/design-system/mergeTokensOverride.js +1 -2
- package/dist/es/design-system/presets.js +1 -139
- package/dist/es/design-system/tokens.js +1 -128
- package/dist/es/design-system/useTheme.js +1 -3
- package/dist/es/hooks/animation/index.js +1 -2
- package/dist/es/hooks/animation/useAnimatedTransition.js +1 -53
- package/dist/es/hooks/animation/useReducedMotion.js +1 -54
- package/dist/es/hooks/aria/index.js +1 -5
- package/dist/es/hooks/aria/useAriaListBox.js +1 -25
- package/dist/es/hooks/aria/useAriaOverlay.js +1 -25
- package/dist/es/hooks/aria/useAriaPress.js +1 -57
- package/dist/es/hooks/aria/useAriaToggle.js +1 -16
- package/dist/es/hooks/gesture/index.js +1 -2
- package/dist/es/hooks/gesture/useGestureScroll.js +1 -110
- package/dist/es/hooks/index.js +1 -8
- package/dist/es/hooks/overlay/OverlayStackStore.js +1 -93
- package/dist/es/hooks/overlay/index.js +1 -3
- package/dist/es/hooks/overlay/useOverlayStack.js +1 -40
- package/dist/es/hooks/useControllableValue.js +1 -29
- package/dist/es/hooks/useCountDown.js +1 -87
- package/dist/es/hooks/useHairline.js +1 -26
- package/dist/es/hooks/useSafeAreaPadding.js +1 -20
- package/dist/es/index.js +1 -11
- package/dist/es/nativewind.js +1 -0
- package/dist/es/platform/animation.js +1 -10
- package/dist/es/platform/history.js +1 -7
- package/dist/es/platform/index.js +1 -6
- package/dist/es/platform/measure.js +1 -32
- package/dist/es/platform/runtime.js +1 -4
- package/dist/es/platform/scrollLock.js +1 -16
- package/dist/es/types.js +1 -1
- package/dist/es/utils/array.js +1 -5
- package/dist/es/utils/color.js +1 -25
- package/dist/es/utils/compare.js +1 -13
- package/dist/es/utils/createPlatformShadow.js +1 -39
- package/dist/es/utils/date.js +1 -33
- package/dist/es/utils/deepMerge.js +1 -21
- package/dist/es/utils/hairline.js +1 -93
- package/dist/es/utils/index.js +1 -14
- package/dist/es/utils/number.js +1 -48
- package/dist/es/utils/promise.js +1 -2
- package/dist/es/utils/render.js +1 -7
- package/dist/es/utils/rtl.js +1 -17
- package/dist/es/utils/string.js +1 -13
- package/dist/es/utils/validate.js +1 -14
- package/dist/types/nativewind.d.ts +4 -0
- package/package.json +15 -3
|
@@ -1,138 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createComponentTokensHook } from '../../design-system';
|
|
3
|
-
const fieldLayout = StyleSheet.create({
|
|
4
|
-
body: {
|
|
5
|
-
flexDirection: 'row',
|
|
6
|
-
alignItems: 'center'
|
|
7
|
-
},
|
|
8
|
-
controlWrapper: {
|
|
9
|
-
flex: 1,
|
|
10
|
-
flexDirection: 'row',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
minWidth: 0
|
|
13
|
-
},
|
|
14
|
-
input: {
|
|
15
|
-
flex: 1,
|
|
16
|
-
minWidth: 0,
|
|
17
|
-
padding: 0,
|
|
18
|
-
margin: 0,
|
|
19
|
-
borderWidth: 0,
|
|
20
|
-
outlineStyle: 'solid',
|
|
21
|
-
outlineWidth: 0,
|
|
22
|
-
outlineColor: 'transparent',
|
|
23
|
-
backgroundColor: 'transparent',
|
|
24
|
-
includeFontPadding: false,
|
|
25
|
-
textAlignVertical: 'center'
|
|
26
|
-
},
|
|
27
|
-
textarea: {
|
|
28
|
-
flex: 1,
|
|
29
|
-
padding: 0,
|
|
30
|
-
margin: 0,
|
|
31
|
-
borderWidth: 0,
|
|
32
|
-
outlineStyle: 'solid',
|
|
33
|
-
outlineWidth: 0,
|
|
34
|
-
outlineColor: 'transparent',
|
|
35
|
-
backgroundColor: 'transparent',
|
|
36
|
-
textAlignVertical: 'top'
|
|
37
|
-
},
|
|
38
|
-
children: {
|
|
39
|
-
justifyContent: 'center'
|
|
40
|
-
},
|
|
41
|
-
leftIcon: {
|
|
42
|
-
justifyContent: 'center',
|
|
43
|
-
alignItems: 'center'
|
|
44
|
-
},
|
|
45
|
-
rightIcon: {
|
|
46
|
-
justifyContent: 'center',
|
|
47
|
-
alignItems: 'center'
|
|
48
|
-
},
|
|
49
|
-
prefix: {
|
|
50
|
-
justifyContent: 'center'
|
|
51
|
-
},
|
|
52
|
-
suffix: {
|
|
53
|
-
justifyContent: 'center'
|
|
54
|
-
},
|
|
55
|
-
affixText: {
|
|
56
|
-
includeFontPadding: false
|
|
57
|
-
},
|
|
58
|
-
clearIcon: {
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
alignItems: 'center'
|
|
61
|
-
},
|
|
62
|
-
labelWrapper: {
|
|
63
|
-
flexDirection: 'row',
|
|
64
|
-
alignItems: 'center',
|
|
65
|
-
flexShrink: 0,
|
|
66
|
-
flexGrow: 0,
|
|
67
|
-
minWidth: 0
|
|
68
|
-
},
|
|
69
|
-
labelRow: {
|
|
70
|
-
flexDirection: 'row',
|
|
71
|
-
alignItems: 'center',
|
|
72
|
-
minWidth: 0
|
|
73
|
-
},
|
|
74
|
-
tooltip: {
|
|
75
|
-
justifyContent: 'center',
|
|
76
|
-
alignItems: 'center'
|
|
77
|
-
},
|
|
78
|
-
message: {},
|
|
79
|
-
wordLimit: {}
|
|
80
|
-
});
|
|
81
|
-
const createFieldTokens = foundations => {
|
|
82
|
-
const {
|
|
83
|
-
palette,
|
|
84
|
-
spacing,
|
|
85
|
-
fontSize
|
|
86
|
-
} = foundations;
|
|
87
|
-
return {
|
|
88
|
-
layout: fieldLayout,
|
|
89
|
-
defaults: {
|
|
90
|
-
labelWidth: 72,
|
|
91
|
-
labelAlign: 'left',
|
|
92
|
-
inputAlign: 'left',
|
|
93
|
-
controlAlign: 'left',
|
|
94
|
-
clearTrigger: 'focus',
|
|
95
|
-
formatTrigger: 'onChange',
|
|
96
|
-
rows: 2,
|
|
97
|
-
textareaLineHeight: 20
|
|
98
|
-
},
|
|
99
|
-
colors: {
|
|
100
|
-
label: palette.default[700],
|
|
101
|
-
input: palette.default[800],
|
|
102
|
-
placeholder: palette.default[300] ?? '#c8c9cc',
|
|
103
|
-
error: palette.danger[500],
|
|
104
|
-
disabled: palette.default[500],
|
|
105
|
-
intro: palette.default[600],
|
|
106
|
-
tooltip: palette.default[500],
|
|
107
|
-
clear: palette.default[500],
|
|
108
|
-
rightIcon: palette.default[500],
|
|
109
|
-
wordLimit: palette.default[600] ?? '#646566'
|
|
110
|
-
},
|
|
111
|
-
spacing: {
|
|
112
|
-
labelGap: spacing.none,
|
|
113
|
-
leftIconGap: spacing.xs,
|
|
114
|
-
rightIconGap: spacing.sm * 1,
|
|
115
|
-
prefixGap: spacing.sm * 1,
|
|
116
|
-
suffixGap: spacing.sm * 1,
|
|
117
|
-
messageMarginTop: spacing.none,
|
|
118
|
-
introMarginTop: spacing.none,
|
|
119
|
-
wordLimitMarginTop: spacing.none
|
|
120
|
-
},
|
|
121
|
-
typography: {
|
|
122
|
-
labelSize: fontSize.sm,
|
|
123
|
-
inputSize: fontSize.sm,
|
|
124
|
-
inputLineHeight: 24,
|
|
125
|
-
placeholderSize: fontSize.sm,
|
|
126
|
-
messageSize: 12,
|
|
127
|
-
introSize: 12,
|
|
128
|
-
wordLimitSize: fontSize.xs
|
|
129
|
-
},
|
|
130
|
-
sizes: {
|
|
131
|
-
icon: 16,
|
|
132
|
-
clearIcon: 16,
|
|
133
|
-
textareaMinHeight: 60,
|
|
134
|
-
controlMinHeight: 24
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
export const useFieldTokens = createComponentTokensHook('field', createFieldTokens);
|
|
1
|
+
import{StyleSheet}from"react-native";import{createComponentTokensHook}from"../../design-system";const fieldLayout=StyleSheet.create({body:{flexDirection:"row",alignItems:"center"},controlWrapper:{flex:1,flexDirection:"row",alignItems:"center",minWidth:0},input:{flex:1,minWidth:0,padding:0,margin:0,borderWidth:0,outlineStyle:"solid",outlineWidth:0,outlineColor:"transparent",backgroundColor:"transparent",includeFontPadding:!1,textAlignVertical:"center"},textarea:{flex:1,padding:0,margin:0,borderWidth:0,outlineStyle:"solid",outlineWidth:0,outlineColor:"transparent",backgroundColor:"transparent",textAlignVertical:"top"},children:{justifyContent:"center"},leftIcon:{justifyContent:"center",alignItems:"center"},rightIcon:{justifyContent:"center",alignItems:"center"},prefix:{justifyContent:"center"},suffix:{justifyContent:"center"},affixText:{includeFontPadding:!1},clearIcon:{justifyContent:"center",alignItems:"center"},labelWrapper:{flexDirection:"row",alignItems:"center",flexShrink:0,flexGrow:0,minWidth:0},labelRow:{flexDirection:"row",alignItems:"center",minWidth:0},tooltip:{justifyContent:"center",alignItems:"center"},message:{},wordLimit:{}}),createFieldTokens=e=>{const{palette:t,spacing:n,fontSize:i}=e;return{layout:fieldLayout,defaults:{labelWidth:72,labelAlign:"left",inputAlign:"left",controlAlign:"left",clearTrigger:"focus",formatTrigger:"onChange",rows:2,textareaLineHeight:20},colors:{label:t.default[700],input:t.default[800],placeholder:t.default[300]??"#c8c9cc",error:t.danger[500],disabled:t.default[500],intro:t.default[600],tooltip:t.default[500],clear:t.default[500],rightIcon:t.default[500],wordLimit:t.default[600]??"#646566"},spacing:{labelGap:n.none,leftIconGap:n.xs,rightIconGap:1*n.sm,prefixGap:1*n.sm,suffixGap:1*n.sm,messageMarginTop:n.none,introMarginTop:n.none,wordLimitMarginTop:n.none},typography:{labelSize:i.sm,inputSize:i.sm,inputLineHeight:24,placeholderSize:i.sm,messageSize:12,introSize:12,wordLimitSize:i.xs},sizes:{icon:16,clearIcon:16,textareaMinHeight:60,controlMinHeight:24}}};export const useFieldTokens=createComponentTokensHook("field",createFieldTokens);
|
|
@@ -1,66 +1 @@
|
|
|
1
|
-
import React, { useMemo }
|
|
2
|
-
import { Platform, View } from 'react-native';
|
|
3
|
-
import { useFlexTokens } from './tokens';
|
|
4
|
-
export const FlexContext = /*#__PURE__*/React.createContext({
|
|
5
|
-
horizontalGap: 0,
|
|
6
|
-
verticalGap: 0,
|
|
7
|
-
columns: 24
|
|
8
|
-
});
|
|
9
|
-
const alignMap = {
|
|
10
|
-
start: 'flex-start',
|
|
11
|
-
center: 'center',
|
|
12
|
-
end: 'flex-end',
|
|
13
|
-
baseline: 'baseline',
|
|
14
|
-
stretch: 'stretch'
|
|
15
|
-
};
|
|
16
|
-
const justifyMap = {
|
|
17
|
-
start: 'flex-start',
|
|
18
|
-
end: 'flex-end',
|
|
19
|
-
center: 'center',
|
|
20
|
-
around: 'space-around',
|
|
21
|
-
between: 'space-between'
|
|
22
|
-
};
|
|
23
|
-
const FlexImpl = props => {
|
|
24
|
-
const {
|
|
25
|
-
tokensOverride,
|
|
26
|
-
children,
|
|
27
|
-
direction: dirP,
|
|
28
|
-
wrap: wrapP,
|
|
29
|
-
gutter: gutP,
|
|
30
|
-
align: alignP,
|
|
31
|
-
justify: justP,
|
|
32
|
-
style,
|
|
33
|
-
columns: colP
|
|
34
|
-
} = props;
|
|
35
|
-
const tokens = useFlexTokens(tokensOverride);
|
|
36
|
-
const dir = dirP ?? tokens.defaults.direction;
|
|
37
|
-
const wrap = wrapP ?? tokens.defaults.wrap;
|
|
38
|
-
const gut = gutP ?? tokens.defaults.gutter;
|
|
39
|
-
const align = alignP ?? tokens.defaults.align;
|
|
40
|
-
const just = justP ?? tokens.defaults.justify;
|
|
41
|
-
const cols = Math.max(1, colP ?? tokens.defaults.columns);
|
|
42
|
-
const [hR, vR] = Array.isArray(gut) ? gut : [gut, 0];
|
|
43
|
-
const hG = Math.max(0, hR ?? 0);
|
|
44
|
-
const vG = Math.max(0, vR ?? 0);
|
|
45
|
-
const web = Platform.OS === 'web';
|
|
46
|
-
const ctx = useMemo(() => ({
|
|
47
|
-
horizontalGap: hG,
|
|
48
|
-
verticalGap: vG,
|
|
49
|
-
columns: cols
|
|
50
|
-
}), [hG, vG, cols]);
|
|
51
|
-
return /*#__PURE__*/React.createElement(FlexContext.Provider, {
|
|
52
|
-
value: ctx
|
|
53
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
54
|
-
style: [tokens.layout.container, {
|
|
55
|
-
flexDirection: dir,
|
|
56
|
-
flexWrap: wrap,
|
|
57
|
-
alignItems: alignMap[align],
|
|
58
|
-
justifyContent: justifyMap[just],
|
|
59
|
-
marginHorizontal: !web && hG ? -hG / 2 : undefined,
|
|
60
|
-
marginVertical: !web && vG ? -vG / 2 : undefined,
|
|
61
|
-
columnGap: web ? hG : undefined,
|
|
62
|
-
rowGap: web ? vG : undefined
|
|
63
|
-
}, style]
|
|
64
|
-
}, children));
|
|
65
|
-
};
|
|
66
|
-
export const Flex = /*#__PURE__*/React.memo(FlexImpl);
|
|
1
|
+
import React,{useMemo}from"react";import{Platform,View}from"react-native";import{useFlexTokens}from"./tokens";export const FlexContext=React.createContext({horizontalGap:0,verticalGap:0,columns:24});const alignMap={start:"flex-start",center:"center",end:"flex-end",baseline:"baseline",stretch:"stretch"},justifyMap={start:"flex-start",end:"flex-end",center:"center",around:"space-around",between:"space-between"},FlexImpl=e=>{const{tokensOverride:t,children:a,direction:r,wrap:n,gutter:o,align:l,justify:i,style:s,columns:c}=e,m=useFlexTokens(t),u=r??m.defaults.direction,f=n??m.defaults.wrap,p=o??m.defaults.gutter,d=l??m.defaults.align,x=i??m.defaults.justify,v=Math.max(1,c??m.defaults.columns),[y,g]=Array.isArray(p)?p:[p,0],M=Math.max(0,y??0),h=Math.max(0,g??0),w="web"===Platform.OS,F=useMemo(()=>({horizontalGap:M,verticalGap:h,columns:v}),[M,h,v]);return React.createElement(FlexContext.Provider,{value:F},React.createElement(View,{style:[m.layout.container,{flexDirection:u,flexWrap:f,alignItems:alignMap[d],justifyContent:justifyMap[x],marginHorizontal:!w&&M?-M/2:void 0,marginVertical:!w&&h?-h/2:void 0,columnGap:w?M:void 0,rowGap:w?h:void 0},s]},a))};export const Flex=React.memo(FlexImpl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{FlexContext}from"./Flex";
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
import React, { useContext }
|
|
2
|
-
import { Platform, View } from 'react-native';
|
|
3
|
-
import { FlexContext } from './FlexContext';
|
|
4
|
-
import { isNumber } from '../../utils';
|
|
5
|
-
const parseFlex = v => {
|
|
6
|
-
if (isNumber(v)) return {
|
|
7
|
-
flex: v
|
|
8
|
-
};
|
|
9
|
-
if (!v) return undefined;
|
|
10
|
-
const str = v.trim();
|
|
11
|
-
if (!str) return undefined;
|
|
12
|
-
if (str === 'auto') return {
|
|
13
|
-
flexGrow: 1,
|
|
14
|
-
flexShrink: 1,
|
|
15
|
-
flexBasis: 'auto'
|
|
16
|
-
};
|
|
17
|
-
if (str === 'none') return {
|
|
18
|
-
flexGrow: 0,
|
|
19
|
-
flexShrink: 0,
|
|
20
|
-
flexBasis: 'auto'
|
|
21
|
-
};
|
|
22
|
-
const num = Number(str);
|
|
23
|
-
if (isNumber(num)) return {
|
|
24
|
-
flex: num
|
|
25
|
-
};
|
|
26
|
-
const parts = str.split(/\s+/);
|
|
27
|
-
if (parts.length >= 2) {
|
|
28
|
-
const [grow, shrink] = parts.map(Number);
|
|
29
|
-
if (isNumber(grow) && isNumber(shrink)) {
|
|
30
|
-
const basisStr = parts.slice(2).join(' ');
|
|
31
|
-
let flexBasis;
|
|
32
|
-
if (basisStr === 'auto') flexBasis = 'auto';else if (basisStr) {
|
|
33
|
-
const pxMatch = basisStr.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
34
|
-
const basisNum = pxMatch ? Number(pxMatch[1]) : Number(basisStr);
|
|
35
|
-
if (isNumber(basisNum)) flexBasis = basisNum;
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
flexGrow: grow,
|
|
39
|
-
flexShrink: shrink,
|
|
40
|
-
flexBasis
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return undefined;
|
|
45
|
-
};
|
|
46
|
-
const FlexItemImpl = ({
|
|
47
|
-
span,
|
|
48
|
-
flex,
|
|
49
|
-
style: s,
|
|
50
|
-
children: c
|
|
51
|
-
}) => {
|
|
52
|
-
const {
|
|
53
|
-
horizontalGap: hg,
|
|
54
|
-
verticalGap: vg,
|
|
55
|
-
columns: cols
|
|
56
|
-
} = useContext(FlexContext);
|
|
57
|
-
const sg = Platform.OS === 'web';
|
|
58
|
-
if (isNumber(span) && span <= 0) return null;
|
|
59
|
-
const ws = {};
|
|
60
|
-
if (isNumber(span)) {
|
|
61
|
-
const sc = Math.max(1, cols);
|
|
62
|
-
const p = Math.min(Math.max(span, 0), sc) / sc;
|
|
63
|
-
ws.width = `${p * 100}%`;
|
|
64
|
-
ws.flexGrow = 0;
|
|
65
|
-
ws.flexShrink = 0;
|
|
66
|
-
}
|
|
67
|
-
;
|
|
68
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
69
|
-
style: [sg ? null : {
|
|
70
|
-
paddingHorizontal: hg / 2,
|
|
71
|
-
paddingVertical: vg / 2
|
|
72
|
-
}, ws, parseFlex(flex), s]
|
|
73
|
-
}, c);
|
|
74
|
-
};
|
|
75
|
-
export const FlexItem = /*#__PURE__*/React.memo(FlexItemImpl);
|
|
76
|
-
FlexItem.displayName = 'FlexItem';
|
|
1
|
+
import React,{useContext}from"react";import{Platform,View}from"react-native";import{FlexContext}from"./FlexContext";import{isNumber}from"../../utils";const parseFlex=e=>{if(isNumber(e))return{flex:e};if(!e)return;const t=e.trim();if(!t)return;if("auto"===t)return{flexGrow:1,flexShrink:1,flexBasis:"auto"};if("none"===t)return{flexGrow:0,flexShrink:0,flexBasis:"auto"};const r=Number(t);if(isNumber(r))return{flex:r};const i=t.split(/\s+/);if(i.length>=2){const[e,t]=i.map(Number);if(isNumber(e)&&isNumber(t)){const r=i.slice(2).join(" ");let l;if("auto"===r)l="auto";else if(r){const e=r.match(/^(-?\d+(?:\.\d+)?)px$/),t=Number(e?e[1]:r);isNumber(t)&&(l=t)}return{flexGrow:e,flexShrink:t,flexBasis:l}}}},FlexItemImpl=({span:e,flex:t,style:r,children:i})=>{const{horizontalGap:l,verticalGap:n,columns:o}=useContext(FlexContext),m="web"===Platform.OS;if(isNumber(e)&&e<=0)return null;const s={};if(isNumber(e)){const t=Math.max(1,o),r=Math.min(Math.max(e,0),t)/t;s.width=100*r+"%",s.flexGrow=0,s.flexShrink=0}return React.createElement(View,{style:[m?null:{paddingHorizontal:l/2,paddingVertical:n/2},s,parseFlex(t),r]},i)};export const FlexItem=React.memo(FlexItemImpl);FlexItem.displayName="FlexItem";
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FlexItem } from './FlexItem';
|
|
3
|
-
const Flex = Object.assign(FlexBase, {
|
|
4
|
-
Item: FlexItem
|
|
5
|
-
});
|
|
6
|
-
export default Flex;
|
|
7
|
-
export { Flex };
|
|
8
|
-
export { FlexItem };
|
|
1
|
+
import{Flex as FlexBase}from"./Flex";import{FlexItem}from"./FlexItem";const Flex=Object.assign(FlexBase,{Item:FlexItem});export default Flex;export{Flex};export{FlexItem};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const createFlexTokens = _foundations => ({
|
|
3
|
-
defaults: {
|
|
4
|
-
direction: 'row',
|
|
5
|
-
wrap: 'nowrap',
|
|
6
|
-
gutter: 0,
|
|
7
|
-
align: 'start',
|
|
8
|
-
justify: 'start',
|
|
9
|
-
columns: 24
|
|
10
|
-
},
|
|
11
|
-
layout: {
|
|
12
|
-
container: {}
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
export const useFlexTokens = createComponentTokensHook('flex', createFlexTokens);
|
|
1
|
+
import{createComponentTokensHook}from"../../design-system";const createFlexTokens=e=>({defaults:{direction:"row",wrap:"nowrap",gutter:0,align:"start",justify:"start",columns:24},layout:{container:{}}});export const useFlexTokens=createComponentTokensHook("flex",createFlexTokens);
|
|
@@ -1,319 +1 @@
|
|
|
1
|
-
function _extends()
|
|
2
|
-
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { View } from 'react-native';
|
|
4
|
-
import { shallowEqualObject } from '../../utils';
|
|
5
|
-
import { isPromiseLike } from '../../utils/promise';
|
|
6
|
-
import { isNumber, isString, isText } from '../../utils/validate';
|
|
7
|
-
import { FORM_ALL_FIELDS_KEY, getValueByName, normalizeTrigger, serializeNamePath, setValueByName } from './utils';
|
|
8
|
-
import { useLocale } from '../config-provider/useLocale';
|
|
9
|
-
export const FormContext = /*#__PURE__*/React.createContext(null);
|
|
10
|
-
const runRuleValidation = (rule, value, values, fallbackMsg) => {
|
|
11
|
-
const msg = rule.message ?? fallbackMsg ?? 'Validation failed';
|
|
12
|
-
const empty = value == null || value === '' || Array.isArray(value) && value.length === 0;
|
|
13
|
-
if (rule.required && (empty || rule.whitespace && isString(value) && value.trim().length === 0)) return msg;
|
|
14
|
-
if (empty) return null;
|
|
15
|
-
if (rule.pattern && isString(value) && !rule.pattern.test(value)) return msg;
|
|
16
|
-
if (rule.len !== undefined || rule.min !== undefined || rule.max !== undefined) {
|
|
17
|
-
const len = isNumber(value) ? value : isString(value) || Array.isArray(value) ? value.length : 0;
|
|
18
|
-
if (rule.len !== undefined && len !== rule.len) return msg;
|
|
19
|
-
if (rule.min !== undefined && len < rule.min) return msg;
|
|
20
|
-
if (rule.max !== undefined && len > rule.max) return msg;
|
|
21
|
-
}
|
|
22
|
-
if (!rule.validator) return null;
|
|
23
|
-
const handleResult = r => isString(r) ? r : r === false ? msg : null;
|
|
24
|
-
const res = rule.validator(value, values);
|
|
25
|
-
return isPromiseLike(res) ? res.then(handleResult) : handleResult(res);
|
|
26
|
-
};
|
|
27
|
-
const InternalFormImpl = (props, ref) => {
|
|
28
|
-
const {
|
|
29
|
-
initialValues,
|
|
30
|
-
colon,
|
|
31
|
-
labelWidth,
|
|
32
|
-
showValidateMessage = true,
|
|
33
|
-
onValuesChange,
|
|
34
|
-
onFinish,
|
|
35
|
-
style,
|
|
36
|
-
footer,
|
|
37
|
-
children,
|
|
38
|
-
...rest
|
|
39
|
-
} = props;
|
|
40
|
-
const locale = useLocale();
|
|
41
|
-
const defaultValuesRef = useRef({}),
|
|
42
|
-
errorsRef = useRef({}),
|
|
43
|
-
lastInitialValuesRef = useRef(initialValues ?? defaultValuesRef.current),
|
|
44
|
-
fieldsRef = useRef({}),
|
|
45
|
-
dependencyGraphRef = useRef(new Map()),
|
|
46
|
-
valuesRef = useRef(initialValues ?? defaultValuesRef.current),
|
|
47
|
-
validationSeqRef = useRef({}),
|
|
48
|
-
subscribersRef = useRef(new Set()),
|
|
49
|
-
onValuesChangeRef = useRef(onValuesChange),
|
|
50
|
-
onFinishRef = useRef(onFinish);
|
|
51
|
-
onValuesChangeRef.current = onValuesChange;
|
|
52
|
-
onFinishRef.current = onFinish;
|
|
53
|
-
const mergedInitialValues = initialValues ?? defaultValuesRef.current;
|
|
54
|
-
const [, setVersion] = useState(0);
|
|
55
|
-
const notify = useCallback((changedValues, newValues) => {
|
|
56
|
-
subscribersRef.current.forEach(l => l(changedValues, newValues));
|
|
57
|
-
}, []);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (shallowEqualObject(lastInitialValuesRef.current, mergedInitialValues)) return;
|
|
60
|
-
lastInitialValuesRef.current = mergedInitialValues;
|
|
61
|
-
valuesRef.current = mergedInitialValues;
|
|
62
|
-
errorsRef.current = {};
|
|
63
|
-
setVersion(v => v + 1);
|
|
64
|
-
notify({
|
|
65
|
-
[FORM_ALL_FIELDS_KEY]: true
|
|
66
|
-
}, mergedInitialValues);
|
|
67
|
-
}, [mergedInitialValues, notify]);
|
|
68
|
-
const setFieldErrors = useCallback((name, newErrors) => {
|
|
69
|
-
const key = serializeNamePath(name);
|
|
70
|
-
const prevE = errorsRef.current[key];
|
|
71
|
-
if (!newErrors.length) {
|
|
72
|
-
if (!prevE) return;
|
|
73
|
-
const cl = {
|
|
74
|
-
...errorsRef.current
|
|
75
|
-
};
|
|
76
|
-
delete cl[key];
|
|
77
|
-
errorsRef.current = cl;
|
|
78
|
-
notify({
|
|
79
|
-
[key]: getValueByName(valuesRef.current, name)
|
|
80
|
-
}, valuesRef.current);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (prevE?.[0] === newErrors[0] && prevE.length === newErrors.length) return;
|
|
84
|
-
errorsRef.current = {
|
|
85
|
-
...errorsRef.current,
|
|
86
|
-
[key]: newErrors
|
|
87
|
-
};
|
|
88
|
-
notify({
|
|
89
|
-
[key]: getValueByName(valuesRef.current, name)
|
|
90
|
-
}, valuesRef.current);
|
|
91
|
-
}, [notify]);
|
|
92
|
-
const registerField = useCallback((name, opts) => {
|
|
93
|
-
const key = serializeNamePath(name);
|
|
94
|
-
const prev = fieldsRef.current[key];
|
|
95
|
-
if (prev?.dependencies?.length) {
|
|
96
|
-
for (const dep of prev.dependencies) {
|
|
97
|
-
const dk = serializeNamePath(dep);
|
|
98
|
-
const s = dependencyGraphRef.current.get(dk);
|
|
99
|
-
if (!s) continue;
|
|
100
|
-
s.delete(key);
|
|
101
|
-
if (!s.size) dependencyGraphRef.current.delete(dk);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
fieldsRef.current[key] = {
|
|
105
|
-
...opts,
|
|
106
|
-
name
|
|
107
|
-
};
|
|
108
|
-
if (opts.dependencies?.length) {
|
|
109
|
-
for (const dep of opts.dependencies) {
|
|
110
|
-
const dk = serializeNamePath(dep);
|
|
111
|
-
const s = dependencyGraphRef.current.get(dk);
|
|
112
|
-
if (s) s.add(key);else dependencyGraphRef.current.set(dk, new Set([key]));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (opts.initialValue !== undefined) {
|
|
116
|
-
const exInit = getValueByName(lastInitialValuesRef.current, name);
|
|
117
|
-
if (exInit === undefined) lastInitialValuesRef.current = setValueByName(lastInitialValuesRef.current, name, opts.initialValue);
|
|
118
|
-
const exState = getValueByName(valuesRef.current, name);
|
|
119
|
-
if (exState === undefined) {
|
|
120
|
-
const next = setValueByName(valuesRef.current, name, opts.initialValue);
|
|
121
|
-
valuesRef.current = next;
|
|
122
|
-
notify({
|
|
123
|
-
[key]: opts.initialValue
|
|
124
|
-
}, next);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return () => {
|
|
128
|
-
const cur = fieldsRef.current[key];
|
|
129
|
-
delete fieldsRef.current[key];
|
|
130
|
-
if (cur?.dependencies?.length) {
|
|
131
|
-
for (const dep of cur.dependencies) {
|
|
132
|
-
const dk = serializeNamePath(dep);
|
|
133
|
-
const s = dependencyGraphRef.current.get(dk);
|
|
134
|
-
if (!s) continue;
|
|
135
|
-
s.delete(key);
|
|
136
|
-
if (!s.size) dependencyGraphRef.current.delete(dk);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
;
|
|
140
|
-
setFieldErrors(name, []);
|
|
141
|
-
};
|
|
142
|
-
}, [notify, setFieldErrors]);
|
|
143
|
-
const localeRef = useRef(locale);
|
|
144
|
-
localeRef.current = locale;
|
|
145
|
-
const validateField = useCallback(async (name, trigger, valueOverride, valuesOverride) => {
|
|
146
|
-
const key = serializeNamePath(name);
|
|
147
|
-
const seq = (validationSeqRef.current[key] ?? 0) + 1;
|
|
148
|
-
validationSeqRef.current[key] = seq;
|
|
149
|
-
const fOpts = fieldsRef.current[key];
|
|
150
|
-
const fRules = fOpts?.rules ?? [];
|
|
151
|
-
if (!fRules.length) {
|
|
152
|
-
setFieldErrors(name, []);
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
let appRules = trigger ? fRules.filter(r => {
|
|
156
|
-
const rt = r.validateTrigger ?? fOpts.validateTrigger;
|
|
157
|
-
return !rt || normalizeTrigger(rt).includes(trigger);
|
|
158
|
-
}) : fRules;
|
|
159
|
-
if (!appRules.length) {
|
|
160
|
-
if (!errorsRef.current[key]?.length) return true;
|
|
161
|
-
appRules = fRules;
|
|
162
|
-
}
|
|
163
|
-
const curVals = valuesOverride ?? valuesRef.current;
|
|
164
|
-
const val = valueOverride ?? getValueByName(curVals, name);
|
|
165
|
-
const fbMsg = localeRef.current?.vanForm?.validationFailed;
|
|
166
|
-
for (const rule of appRules) {
|
|
167
|
-
const result = runRuleValidation(rule, val, curVals, fbMsg);
|
|
168
|
-
const err = isPromiseLike(result) ? await result : result;
|
|
169
|
-
if (validationSeqRef.current[key] !== seq) return true;
|
|
170
|
-
if (err) {
|
|
171
|
-
setFieldErrors(name, [err]);
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (validationSeqRef.current[key] !== seq) return true;
|
|
176
|
-
setFieldErrors(name, []);
|
|
177
|
-
return true;
|
|
178
|
-
}, [setFieldErrors]);
|
|
179
|
-
const validateFields = useCallback(async names => {
|
|
180
|
-
const fNames = names ?? Object.values(fieldsRef.current).map(it => it.name);
|
|
181
|
-
const results = await Promise.all(fNames.map(n => validateField(n)));
|
|
182
|
-
if (results.some(r => !r)) throw errorsRef.current;
|
|
183
|
-
return valuesRef.current;
|
|
184
|
-
}, [validateField]);
|
|
185
|
-
const validateWithDependencies = useCallback((key, name, trigger, val, vals) => {
|
|
186
|
-
validateField(name, trigger, val, vals);
|
|
187
|
-
const deps = dependencyGraphRef.current.get(key);
|
|
188
|
-
if (deps?.size) {
|
|
189
|
-
for (const dk of deps) {
|
|
190
|
-
const m = fieldsRef.current[dk];
|
|
191
|
-
if (m) validateField(m.name, trigger, getValueByName(vals, m.name), vals);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}, [validateField]);
|
|
195
|
-
const setFieldValue = useCallback((name, val, trigger) => {
|
|
196
|
-
const nKey = serializeNamePath(name);
|
|
197
|
-
const prev = valuesRef.current;
|
|
198
|
-
if (getValueByName(prev, name) === val) return;
|
|
199
|
-
const next = setValueByName(prev, name, val);
|
|
200
|
-
valuesRef.current = next;
|
|
201
|
-
onValuesChangeRef.current?.(next, nKey, val);
|
|
202
|
-
validateWithDependencies(nKey, name, trigger, val, next);
|
|
203
|
-
notify({
|
|
204
|
-
[nKey]: val
|
|
205
|
-
}, next);
|
|
206
|
-
}, [notify, validateWithDependencies]);
|
|
207
|
-
const formApi = useMemo(() => ({
|
|
208
|
-
submit: async () => {
|
|
209
|
-
try {
|
|
210
|
-
const res = await validateFields();
|
|
211
|
-
onFinishRef.current?.(res);
|
|
212
|
-
return res;
|
|
213
|
-
} catch {
|
|
214
|
-
return undefined;
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
getFieldsValue: () => valuesRef.current,
|
|
218
|
-
setFieldsValue: (next, opts) => {
|
|
219
|
-
const sV = opts?.validate ?? false;
|
|
220
|
-
const prev = valuesRef.current;
|
|
221
|
-
let m = prev;
|
|
222
|
-
const ch = {};
|
|
223
|
-
Object.keys(next).forEach(k => {
|
|
224
|
-
const nv = next[k];
|
|
225
|
-
if (getValueByName(m, k) === nv) return;
|
|
226
|
-
ch[k] = nv;
|
|
227
|
-
m = setValueByName(m, k, nv);
|
|
228
|
-
onValuesChangeRef.current?.(m, k, nv);
|
|
229
|
-
if (sV) validateWithDependencies(k, k, undefined, nv, m);
|
|
230
|
-
});
|
|
231
|
-
if (m === prev) return;
|
|
232
|
-
valuesRef.current = m;
|
|
233
|
-
notify(ch, m);
|
|
234
|
-
},
|
|
235
|
-
resetFields: () => {
|
|
236
|
-
let n = lastInitialValuesRef.current;
|
|
237
|
-
Object.values(fieldsRef.current).forEach(mem => {
|
|
238
|
-
if (mem.initialValue === undefined) return;
|
|
239
|
-
if (getValueByName(n, mem.name) !== undefined) return;
|
|
240
|
-
n = setValueByName(n, mem.name, mem.initialValue);
|
|
241
|
-
});
|
|
242
|
-
valuesRef.current = n;
|
|
243
|
-
errorsRef.current = {};
|
|
244
|
-
notify({
|
|
245
|
-
[FORM_ALL_FIELDS_KEY]: true
|
|
246
|
-
}, n);
|
|
247
|
-
},
|
|
248
|
-
validateFields,
|
|
249
|
-
getFieldError: name => errorsRef.current[serializeNamePath(name)] ?? []
|
|
250
|
-
}), [validateFields, validateWithDependencies, notify]);
|
|
251
|
-
useImperativeHandle(ref, () => formApi, [formApi]);
|
|
252
|
-
const ctxVal = useMemo(() => ({
|
|
253
|
-
getFieldValue: name => getValueByName(valuesRef.current, name),
|
|
254
|
-
setFieldValue,
|
|
255
|
-
registerField,
|
|
256
|
-
getFieldError: name => errorsRef.current[serializeNamePath(name)],
|
|
257
|
-
validateField: (name, trigger) => validateField(name, trigger),
|
|
258
|
-
getFieldsValue: () => valuesRef.current,
|
|
259
|
-
subscribe: listener => {
|
|
260
|
-
subscribersRef.current.add(listener);
|
|
261
|
-
return () => subscribersRef.current.delete(listener);
|
|
262
|
-
},
|
|
263
|
-
form: formApi,
|
|
264
|
-
colon,
|
|
265
|
-
labelWidth,
|
|
266
|
-
showValidateMessage
|
|
267
|
-
}), [setFieldValue, registerField, validateField, formApi, colon, labelWidth, showValidateMessage]);
|
|
268
|
-
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
269
|
-
value: ctxVal
|
|
270
|
-
}, /*#__PURE__*/React.createElement(View, _extends({
|
|
271
|
-
style: style
|
|
272
|
-
}, rest), children, footer));
|
|
273
|
-
};
|
|
274
|
-
const InternalFormRef = /*#__PURE__*/React.forwardRef(InternalFormImpl);
|
|
275
|
-
const InternalForm = /*#__PURE__*/React.memo(InternalFormRef);
|
|
276
|
-
export const useWatch = (name, formRef) => {
|
|
277
|
-
const ctx = useContext(FormContext);
|
|
278
|
-
const nPaths = name === undefined ? undefined : !Array.isArray(name) ? [name] : name.length && isText(name[0]) ? [name] : name;
|
|
279
|
-
const getValue = useCallback(allValues => {
|
|
280
|
-
const src = allValues ?? ctx?.getFieldsValue?.() ?? formRef?.current?.getFieldsValue?.() ?? {};
|
|
281
|
-
if (!nPaths) return src;
|
|
282
|
-
if (nPaths.length === 1) return getValueByName(src, nPaths[0]);
|
|
283
|
-
const picked = {};
|
|
284
|
-
for (const k of nPaths) picked[serializeNamePath(k)] = getValueByName(src, k);
|
|
285
|
-
return picked;
|
|
286
|
-
}, [ctx, formRef, nPaths]);
|
|
287
|
-
const [val, setVal] = useState(() => getValue());
|
|
288
|
-
useEffect(() => {
|
|
289
|
-
if (!ctx?.subscribe) return undefined;
|
|
290
|
-
return ctx.subscribe((ch, all) => {
|
|
291
|
-
if (FORM_ALL_FIELDS_KEY in ch) {
|
|
292
|
-
setVal(getValue(all));
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
;
|
|
296
|
-
if (!nPaths || nPaths.some(k => serializeNamePath(k) in ch)) setVal(getValue(all));
|
|
297
|
-
});
|
|
298
|
-
}, [ctx, getValue, nPaths]);
|
|
299
|
-
useEffect(() => {
|
|
300
|
-
setVal(getValue());
|
|
301
|
-
}, [getValue]);
|
|
302
|
-
return val;
|
|
303
|
-
};
|
|
304
|
-
export const FormSubscribe = ({
|
|
305
|
-
to,
|
|
306
|
-
children
|
|
307
|
-
}) => {
|
|
308
|
-
const ctx = useContext(FormContext);
|
|
309
|
-
const [chVals, setChVals] = useState({});
|
|
310
|
-
useEffect(() => {
|
|
311
|
-
if (!ctx?.subscribe) return undefined;
|
|
312
|
-
return ctx.subscribe(n => {
|
|
313
|
-
if (to && !(FORM_ALL_FIELDS_KEY in n) && !Object.keys(n).some(k => to.includes(k))) return;
|
|
314
|
-
setChVals(n);
|
|
315
|
-
});
|
|
316
|
-
}, [ctx, to]);
|
|
317
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children(chVals, ctx?.form || null));
|
|
318
|
-
};
|
|
319
|
-
export default InternalForm;
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}import React,{useCallback,useContext,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{View}from"react-native";import{shallowEqualObject,renderTextOrNode}from"../../utils";import{isPromiseLike}from"../../utils/promise";import{isNumber,isString,isText}from"../../utils/validate";import{FORM_ALL_FIELDS_KEY,getValueByName,normalizeTrigger,serializeNamePath,setValueByName}from"./utils";import{useLocale}from"../config-provider/useLocale";export const FormContext=React.createContext(null);const runRuleValidation=(e,t,r,n)=>{const a=e.message??n??"Validation failed",i=null==t||""===t||Array.isArray(t)&&0===t.length;if(e.required&&(i||e.whitespace&&isString(t)&&0===t.trim().length))return a;if(i)return null;if(e.pattern&&isString(t)&&!e.pattern.test(t))return a;if(void 0!==e.len||void 0!==e.min||void 0!==e.max){const r=isNumber(t)?t:isString(t)||Array.isArray(t)?t.length:0;if(void 0!==e.len&&r!==e.len)return a;if(void 0!==e.min&&r<e.min)return a;if(void 0!==e.max&&r>e.max)return a}if(!e.validator)return null;const u=e=>isString(e)?e:!1===e?a:null,s=e.validator(t,r);return isPromiseLike(s)?s.then(u):u(s)},InternalFormImpl=(e,t)=>{const{initialValues:r,colon:n,labelWidth:a,showValidateMessage:i=!0,onValuesChange:u,onFinish:s,style:l,footer:c,children:o,...m}=e,d=useLocale(),f=useRef({}),g=useRef({}),h=useRef(r??f.current),V=useRef({}),F=useRef(new Map),v=useRef(r??f.current),b=useRef({}),y=useRef(new Set),N=useRef(u),p=useRef(s);N.current=u,p.current=s;const R=r??f.current,[,E]=useState(0),x=useCallback((e,t)=>{y.current.forEach(r=>r(e,t))},[]);useEffect(()=>{shallowEqualObject(h.current,R)||(h.current=R,v.current=R,g.current={},E(e=>e+1),x({[FORM_ALL_FIELDS_KEY]:!0},R))},[R,x]);const L=useCallback((e,t)=>{const r=serializeNamePath(e),n=g.current[r];if(!t.length){if(!n)return;const t={...g.current};return delete t[r],g.current=t,void x({[r]:getValueByName(v.current,e)},v.current)}n?.[0]===t[0]&&n.length===t.length||(g.current={...g.current,[r]:t},x({[r]:getValueByName(v.current,e)},v.current))},[x]),B=useCallback((e,t)=>{const r=serializeNamePath(e),n=V.current[r];if(n?.dependencies?.length)for(const e of n.dependencies){const t=serializeNamePath(e),n=F.current.get(t);n&&(n.delete(r),n.size||F.current.delete(t))}if(V.current[r]={...t,name:e},t.dependencies?.length)for(const e of t.dependencies){const t=serializeNamePath(e),n=F.current.get(t);n?n.add(r):F.current.set(t,new Set([r]))}if(void 0!==t.initialValue){void 0===getValueByName(h.current,e)&&(h.current=setValueByName(h.current,e,t.initialValue));if(void 0===getValueByName(v.current,e)){const n=setValueByName(v.current,e,t.initialValue);v.current=n,x({[r]:t.initialValue},n)}}return()=>{const t=V.current[r];if(delete V.current[r],t?.dependencies?.length)for(const e of t.dependencies){const t=serializeNamePath(e),n=F.current.get(t);n&&(n.delete(r),n.size||F.current.delete(t))}L(e,[])}},[x,L]),_=useRef(d);_.current=d;const C=useCallback(async(e,t,r,n)=>{const a=serializeNamePath(e),i=(b.current[a]??0)+1;b.current[a]=i;const u=V.current[a],s=u?.rules??[];if(!s.length)return L(e,[]),!0;let l=t?s.filter(e=>{const r=e.validateTrigger??u.validateTrigger;return!r||normalizeTrigger(r).includes(t)}):s;if(!l.length){if(!g.current[a]?.length)return!0;l=s}const c=n??v.current,o=r??getValueByName(c,e),m=_.current?.vanForm?.validationFailed;for(const t of l){const r=runRuleValidation(t,o,c,m),n=isPromiseLike(r)?await r:r;if(b.current[a]!==i)return!0;if(n)return L(e,[n]),!1}return b.current[a]!==i||L(e,[]),!0},[L]),P=useCallback(async e=>{const t=e??Object.values(V.current).map(e=>e.name);if((await Promise.all(t.map(e=>C(e)))).some(e=>!e))throw g.current;return v.current},[C]),z=useCallback((e,t,r,n,a)=>{C(t,r,n,a);const i=F.current.get(e);if(i?.size)for(const e of i){const t=V.current[e];t&&C(t.name,r,getValueByName(a,t.name),a)}},[C]),S=useCallback((e,t,r)=>{const n=serializeNamePath(e),a=v.current;if(getValueByName(a,e)===t)return;const i=setValueByName(a,e,t);v.current=i,N.current?.(i,n,t),z(n,e,r,t,i),x({[n]:t},i)},[x,z]),w=useMemo(()=>({submit:async()=>{try{const e=await P();return p.current?.(e),e}catch{return}},getFieldsValue:()=>v.current,setFieldsValue:(e,t)=>{const r=t?.validate??!1,n=v.current;let a=n;const i={};Object.keys(e).forEach(t=>{const n=e[t];getValueByName(a,t)!==n&&(i[t]=n,a=setValueByName(a,t,n),N.current?.(a,t,n),r&&z(t,t,void 0,n,a))}),a!==n&&(v.current=a,x(i,a))},resetFields:()=>{let e=h.current;Object.values(V.current).forEach(t=>{void 0!==t.initialValue&&void 0===getValueByName(e,t.name)&&(e=setValueByName(e,t.name,t.initialValue))}),v.current=e,g.current={},x({[FORM_ALL_FIELDS_KEY]:!0},e)},validateFields:P,getFieldError:e=>g.current[serializeNamePath(e)]??[]}),[P,z,x]);useImperativeHandle(t,()=>w,[w]);const O=useMemo(()=>({getFieldValue:e=>getValueByName(v.current,e),setFieldValue:S,registerField:B,getFieldError:e=>g.current[serializeNamePath(e)],validateField:(e,t)=>C(e,t),getFieldsValue:()=>v.current,subscribe:e=>(y.current.add(e),()=>y.current.delete(e)),form:w,colon:n,labelWidth:a,showValidateMessage:i}),[S,B,C,w,n,a,i]);return React.createElement(FormContext.Provider,{value:O},React.createElement(View,_extends({style:l},m),o,isText(c)?renderTextOrNode(c,[]):c))},InternalFormRef=React.forwardRef(InternalFormImpl),InternalForm=React.memo(InternalFormRef);export const useWatch=(e,t)=>{const r=useContext(FormContext),n=void 0===e?void 0:Array.isArray(e)?e.length&&isText(e[0])?[e]:e:[e],a=useCallback(e=>{const a=e??r?.getFieldsValue?.()??t?.current?.getFieldsValue?.()??{};if(!n)return a;if(1===n.length)return getValueByName(a,n[0]);const i={};for(const e of n)i[serializeNamePath(e)]=getValueByName(a,e);return i},[r,t,n]),[i,u]=useState(()=>a());return useEffect(()=>{if(r?.subscribe)return r.subscribe((e,t)=>{FORM_ALL_FIELDS_KEY in e?u(a(t)):n&&!n.some(t=>serializeNamePath(t)in e)||u(a(t))})},[r,a,n]),useEffect(()=>{u(a())},[a]),i};export const FormSubscribe=({to:e,children:t})=>{const r=useContext(FormContext),[n,a]=useState({});return useEffect(()=>{if(r?.subscribe)return r.subscribe(t=>{(!e||FORM_ALL_FIELDS_KEY in t||Object.keys(t).some(t=>e.includes(t)))&&a(t)})},[r,e]),React.createElement(React.Fragment,null,t(n,r?.form||null))};export default InternalForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{FormContext}from"./Form";
|