@unicom-cloud/ui 0.8.43 → 0.8.45
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/Affix.js +54 -51
- package/Alert.js +46 -43
- package/Anchor.js +5 -4
- package/AutoComplete.js +60 -55
- package/Avatar.js +10 -155
- package/BackTop.js +41 -38
- package/Badge.js +63 -93
- package/Breadcrumb.js +63 -118
- package/Button.js +105 -109
- package/Calendar.js +139 -536
- package/Card.js +65 -101
- package/Carousel.js +169 -270
- package/Cascader.js +9 -8
- package/Checkbox.js +4 -3
- package/Collapse.js +4 -3
- package/ColorPicker.js +95 -546
- package/Comment.js +14 -12
- package/ConfigProvider.js +6 -5
- package/Copy.js +33 -31
- package/DatePicker.js +35 -1993
- package/Descriptions.js +30 -28
- package/Divider.js +8 -6
- package/Draggable.js +28 -85
- package/Drawer.js +5 -4
- package/Dropdown.js +107 -167
- package/Empty.js +28 -8
- package/Form.js +30 -1418
- package/Grid.js +13 -248
- package/Icon.js +19 -45
- package/IconHover.js +39 -6
- package/Image.js +3 -3
- package/Input.js +4 -4
- package/InputNumber.js +213 -17
- package/InputTag.js +5 -4
- package/Layout.js +35 -48
- package/Link.js +16 -14
- package/List.js +191 -228
- package/Loading.js +18 -17
- package/Mentions.js +99 -115
- package/Menu.js +8 -7
- package/Message.js +147 -10
- package/Modal.js +5 -4
- package/Notice.js +196 -13
- package/Notification.js +136 -11
- package/NotificationBase.js +5 -4
- package/OverflowEllipsis.js +48 -71
- package/PageHeader.js +52 -52
- package/Pagination.js +12 -11
- package/Picker.js +6 -4
- package/Popconfirm.js +47 -44
- package/Popover.js +25 -23
- package/Portal.js +12 -32
- package/Progress.js +65 -328
- package/Radio.js +6 -5
- package/Rate.js +48 -45
- package/ResizeBox.js +127 -505
- package/Result.js +60 -1417
- package/Select.js +9 -8
- package/SelectView.js +49 -328
- package/Skeleton.js +41 -78
- package/Slider.js +228 -702
- package/Space.js +53 -57
- package/Spin.js +57 -72
- package/Statistic.js +84 -153
- package/Steps.js +64 -123
- package/SuspenseFallbackTest.js +4 -3
- package/Switch.js +41 -38
- package/Table.js +20 -1999
- package/Tabs.js +9 -8
- package/Tag.js +24 -21
- package/TimePicker.js +19 -272
- package/Timeline.js +4 -3
- package/Tooltip.js +79 -72
- package/Transfer.js +138 -402
- package/Tree.js +5 -4
- package/TreeSelect.js +8 -7
- package/Trigger.js +407 -571
- package/Typography.js +11 -721
- package/Upload.js +9 -8
- package/VerificationCode.js +6 -5
- package/Version.js +1 -1
- package/VirtualList.js +4 -3
- package/Watermark.js +3 -2
- package/anchor/Anchor.js +193 -0
- package/anchor/Link.js +54 -0
- package/anchor/context.js +14 -0
- package/anchor/util.js +41 -0
- package/avatar/Avatar.js +85 -0
- package/avatar/Group.js +84 -0
- package/avatar/context.js +5 -0
- package/badge/Count.js +35 -0
- package/breadcrumb/Item.js +67 -0
- package/button/Group.js +15 -0
- package/calendar/Month.js +142 -0
- package/calendar/WeekList.js +24 -0
- package/calendar/Year.js +75 -0
- package/calendar/header/Panel.js +57 -0
- package/calendar/header/index.js +118 -0
- package/calendar/hook/useCellClassName.js +41 -0
- package/card/Grid.js +27 -0
- package/card/Meta.js +32 -0
- package/carousel/Arrow.js +57 -0
- package/carousel/Indicator.js +68 -0
- package/cascader/Cascader.js +300 -0
- package/cascader/base/node.js +142 -0
- package/cascader/base/store.js +93 -0
- package/cascader/hook/useRefCurrent.js +12 -0
- package/cascader/panel/List.js +275 -0
- package/cascader/panel/Option.js +35 -0
- package/cascader/panel/Search.js +171 -0
- package/cascader/util.js +66 -0
- package/checkbox/Checkbox.js +111 -0
- package/checkbox/Group.js +97 -0
- package/checkbox/useCheckbox.js +45 -0
- package/collapse/Collapse.js +90 -0
- package/collapse/Item.js +165 -0
- package/color-picker/ControlBar.js +64 -0
- package/color-picker/InputAlpha.js +24 -0
- package/color-picker/InputHex.js +59 -0
- package/color-picker/InputRgb.js +66 -0
- package/color-picker/Palette.js +36 -0
- package/color-picker/Panel.js +165 -0
- package/color-picker/colors.js +37 -0
- package/color-picker/hooks/useColorPicker.js +63 -0
- package/color-picker/hooks/useControlBlock.js +40 -0
- package/config-provider/ConfigProvider.js +94 -0
- package/config-provider/context.js +24 -0
- package/date-picker/Picker.js +399 -0
- package/date-picker/PickerRange.js +568 -0
- package/date-picker/context.js +5 -0
- package/date-picker/hook/useCellClassName.js +58 -0
- package/date-picker/panel/Body.js +78 -0
- package/date-picker/panel/Footer.js +71 -0
- package/date-picker/panel/Header.js +74 -0
- package/date-picker/panel/Shortcut.js +45 -0
- package/date-picker/panel/WeekList.js +19 -0
- package/date-picker/panel/date/index.js +194 -0
- package/date-picker/panel/month/index.js +113 -0
- package/date-picker/panel/quarter/index.js +93 -0
- package/date-picker/panel/range/index.js +251 -0
- package/date-picker/panel/week/index.js +35 -0
- package/date-picker/panel/year/index.js +74 -0
- package/date-picker/util.js +69 -0
- package/draggable/Item.js +66 -0
- package/drawer/Drawer.js +226 -0
- package/dropdown/Button.js +91 -0
- package/form/Control.js +264 -0
- package/form/Form.js +156 -0
- package/form/FormItem.js +241 -0
- package/form/FormLabel.js +54 -0
- package/form/FormList.js +96 -0
- package/form/FormProvider.js +48 -0
- package/form/IconSymbol.js +20 -0
- package/form/context.js +43 -0
- package/form/hook/useContext.js +32 -0
- package/form/hook/useState.js +31 -0
- package/form/hook/useWatch.js +36 -0
- package/form/interface.js +11 -0
- package/form/promisify.js +23 -0
- package/form/store.js +354 -0
- package/form/useForm.js +53 -0
- package/form/util.js +72 -0
- package/grid/Col.js +87 -0
- package/grid/Row.js +88 -0
- package/grid/context.js +9 -0
- package/grid/grid-item.js +77 -0
- package/grid/grid.js +104 -0
- package/grid/hook/useResponsiveState.js +38 -0
- package/grid/util.js +51 -0
- package/{chunk/I4RV9SKZ.js → hooks/factory/createHTMLMediaHook.js} +35 -43
- package/hooks/index.js +246 -4
- package/{chunk/BdYAMaw9.js → hooks/misc/hookState.js} +1 -1
- package/hooks/misc/parseTimeRanges.js +12 -0
- package/{chunk/TXCrI0jN.js → hooks/misc/util.js} +6 -6
- package/hooks/use-watermark/utils.js +8 -0
- package/hooks/use-watermark.js +71 -76
- package/hooks/useAudio.js +3 -3
- package/hooks/useBeforeUnload.js +2 -2
- package/hooks/useClickAway.js +10 -10
- package/hooks/useCounter.js +1 -1
- package/hooks/useCreation.js +2 -4
- package/hooks/useDrop.js +12 -12
- package/hooks/useDropArea.js +5 -5
- package/hooks/useEvent.js +6 -6
- package/hooks/useEventListener.js +2 -4
- package/hooks/useFavicon.js +1 -2
- package/hooks/useFullscreen.js +11 -13
- package/hooks/useGetSet.js +5 -5
- package/hooks/useHash.js +6 -6
- package/hooks/useHover.js +6 -6
- package/hooks/useHoverDirty.js +7 -7
- package/hooks/useIdle.js +17 -17
- package/hooks/useIsomorphicLayoutEffect2.js +3 -3
- package/hooks/useKey.js +5 -5
- package/hooks/useList.js +1 -1
- package/hooks/useLocalStorage.js +2 -3
- package/hooks/useLocation.js +1 -1
- package/hooks/useLockBodyScroll.js +13 -14
- package/hooks/useLongPress.js +7 -7
- package/hooks/useMeasure.js +3 -3
- package/hooks/useMedia.js +4 -4
- package/hooks/useMediaDevices.js +10 -10
- package/hooks/useMotion.js +11 -11
- package/hooks/useMouse.js +9 -9
- package/hooks/useMouseWheel.js +7 -7
- package/hooks/useNetworkState.js +7 -7
- package/hooks/useOrientation.js +10 -11
- package/hooks/useOverrideRef.js +14 -0
- package/hooks/usePageLeave.js +4 -4
- package/hooks/usePermission.js +9 -9
- package/hooks/usePersistCallback.js +15 -0
- package/hooks/useScroll.js +6 -6
- package/hooks/useScrolling.js +7 -7
- package/hooks/useSearchParam.js +5 -5
- package/hooks/useSessionStorage.js +9 -9
- package/hooks/useSize.js +1 -1
- package/hooks/useSlider.js +6 -6
- package/hooks/useStartTyping.js +4 -4
- package/hooks/useStateList.js +4 -5
- package/hooks/useStateWithHistory.js +1 -1
- package/hooks/useTimeout.js +1 -2
- package/hooks/useVibrate.js +5 -5
- package/hooks/useVideo.js +3 -3
- package/hooks/useWindowScroll.js +13 -13
- package/hooks/useWindowSize.js +6 -6
- package/icon/addFromIconFontCn.js +33 -0
- package/image/Image.js +189 -0
- package/image/ImageFooter.js +45 -0
- package/image/ImagePreview.js +473 -0
- package/image/ImagePreviewArrow.js +40 -0
- package/image/ImagePreviewGroup.js +125 -0
- package/image/ImagePreviewToolbar.js +98 -0
- package/image/TriggerForToolbar.js +10 -0
- package/image/previewGroupContext.js +17 -0
- package/image/util/getFixTranslate.js +7 -0
- package/image/util/getScale.js +72 -0
- package/image/util/hook/useImageStatus.js +16 -0
- package/image/util/hook/useShowFooter.js +7 -0
- package/index.js +440 -395
- package/input/Group.js +20 -0
- package/input/Input.js +185 -0
- package/input/InputElement.js +233 -0
- package/input/Number.js +4 -0
- package/input/Password.js +72 -0
- package/input/Search.js +80 -0
- package/input/Tag.js +7 -0
- package/input/Textarea.js +168 -0
- package/input/autoSizeTextAreaHeight.js +65 -0
- package/input/useComposition.js +39 -0
- package/input-number/decimal.js +154 -0
- package/input-number/useSelectionRange.js +26 -0
- package/input-number/util.js +57 -0
- package/input-tag/InputTag.js +381 -0
- package/layout/Content.js +15 -0
- package/layout/Footer.js +15 -0
- package/layout/Header.js +15 -0
- package/{chunk/B9asjXwm.js → layout/Sider.js} +23 -22
- package/list/Item.js +46 -0
- package/list/Meta.js +21 -0
- package/loading/style/index.module.less.js +4 -0
- package/locale/de-DE.js +1 -1
- package/mentions/util.js +26 -0
- package/menu/Indent.js +17 -0
- package/menu/Item.js +125 -0
- package/menu/ItemGroup.js +39 -0
- package/menu/Menu.js +181 -0
- package/menu/OverflowWrap.js +85 -0
- package/menu/context.js +5 -0
- package/menu/sub-menu/Inline.js +111 -0
- package/menu/sub-menu/Pop.js +126 -0
- package/menu/sub-menu/index.js +17 -0
- package/menu/util.js +80 -0
- package/message/useMessage.js +53 -0
- package/modal/Confirm.js +98 -0
- package/modal/Modal.js +419 -0
- package/modal/config.js +25 -0
- package/modal/use-modal/Hook.js +55 -0
- package/modal/use-modal/index.js +68 -0
- package/notification/useNotification.js +55 -0
- package/overflow-ellipsis/OverflowItem.js +34 -0
- package/package.json +27 -1
- package/pagination/PageItem.js +121 -0
- package/pagination/PageJumper.js +64 -0
- package/pagination/PageOption.js +55 -0
- package/pagination/Pagination.js +245 -0
- package/picker/Input.js +124 -0
- package/picker/InputRange.js +155 -0
- package/portal/Portal.js +25 -0
- package/progress/CircleProgress.js +117 -0
- package/progress/LineProgess.js +103 -0
- package/progress/StepProgress.js +74 -0
- package/radio/Group.js +91 -0
- package/radio/Radio.js +90 -0
- package/resize-box/ResizeTrigger.js +78 -0
- package/resize-box/Split.js +132 -0
- package/resize-box/SplitGroup.js +204 -0
- package/result/403.js +695 -0
- package/result/404.js +513 -0
- package/result/500.js +166 -0
- package/select/OptGroup.js +20 -0
- package/select/Option.js +97 -0
- package/select/Select.js +544 -0
- package/select/util.js +140 -0
- package/select-view/Core.js +309 -0
- package/skeleton/Image.js +24 -0
- package/skeleton/Text.js +27 -0
- package/slider/Button.js +159 -0
- package/slider/Dot.js +43 -0
- package/slider/Input.js +75 -0
- package/slider/Mark.js +28 -0
- package/slider/Tick.js +44 -0
- package/slider/hook/useInterval.js +73 -0
- package/slider/hook/useLegalValue.js +70 -0
- package/slider/util.js +63 -0
- package/space/toArray.js +11 -0
- package/spin/DotLoading.js +26 -0
- package/statistic/Countdown.js +57 -0
- package/statistic/util.js +33 -0
- package/steps/Step.js +68 -0
- package/style.css +1 -1
- package/table/ColGroup.js +59 -0
- package/table/Table.js +634 -0
- package/table/constant.js +5 -0
- package/table/hook/useColumns.js +141 -0
- package/table/hook/useComponent.js +64 -0
- package/table/hook/useExpand.js +36 -0
- package/table/hook/useRowSelection.js +92 -0
- package/table/hook/useSorter.js +54 -0
- package/table/hook/useStickyClassNames.js +30 -0
- package/table/hook/useStickyOffsets.js +30 -0
- package/table/summary/Cell.js +10 -0
- package/table/summary/Row.js +26 -0
- package/table/summary/context.js +5 -0
- package/table/summary/index.js +10 -0
- package/table/tbody/Td.js +160 -0
- package/table/tbody/Tr.js +168 -0
- package/table/tbody/index.js +156 -0
- package/table/tfoot/index.js +16 -0
- package/table/thead/Column.js +250 -0
- package/table/thead/index.js +131 -0
- package/table/util.js +121 -0
- package/tabs/Tab.js +170 -0
- package/tabs/TabContent.js +54 -0
- package/tabs/TabPane.js +26 -0
- package/tabs/hook/useDomSize.js +17 -0
- package/tabs/hook/useHeaderScroll.js +64 -0
- package/tabs/tab-header/DropdownIcon.js +71 -0
- package/tabs/tab-header/TabInk.js +65 -0
- package/tabs/tab-header/TabNavIcon.js +65 -0
- package/tabs/tab-header/TabTitle.js +78 -0
- package/tabs/tab-header/index.js +335 -0
- package/tabs/util.js +22 -0
- package/time-picker/Picker.js +221 -0
- package/time-picker/RangePicker.js +56 -0
- package/time-picker/TimeColumn.js +65 -0
- package/time-picker/TimePicker.js +242 -0
- package/time-picker/context.js +5 -0
- package/time-picker/util.js +43 -0
- package/timeline/Item.js +94 -0
- package/timeline/Timeline.js +80 -0
- package/transfer/Item.js +107 -0
- package/transfer/List.js +192 -0
- package/tree/Animation.js +104 -0
- package/tree/Context.js +5 -0
- package/tree/Node.js +215 -0
- package/tree/NodeList.js +84 -0
- package/tree/Tree.js +549 -0
- package/tree/util.js +76 -0
- package/tree-select/List.js +127 -0
- package/tree-select/Select.js +260 -0
- package/tree-select/hook/useKeyCache.js +56 -0
- package/tree-select/hook/useStateValue.js +98 -0
- package/tree-select/hook/useTreeData.js +13 -0
- package/tree-select/interface.js +13 -0
- package/tree-select/util.js +9 -0
- package/trigger/Portal.js +14 -0
- package/trigger/getPopupStyle.js +190 -0
- package/types/badge/Count.d.ts +2 -1
- package/types/badge/index.d.ts +2 -2
- package/types/button/index.d.ts +2 -2
- package/types/carousel/index.d.ts +1 -1
- package/types/color-picker/colors.d.ts +1 -1
- package/types/color-picker/style/index.d.ts +1 -1
- package/types/drawer/Drawer.d.ts +1 -1
- package/types/dropdown/interface.d.ts +1 -0
- package/types/grid/index.d.ts +1 -0
- package/types/hooks/index.d.ts +122 -0
- package/types/hooks/use-verification-code/interface.d.ts +1 -1
- package/types/hooks/useAsync.d.ts +1 -1
- package/types/hooks/useDropArea.d.ts +1 -0
- package/types/hooks/useOverrideRef.d.ts +5 -0
- package/types/hooks/usePersistCallback.d.ts +1 -0
- package/types/hooks/useUpsert.d.ts +1 -1
- package/types/icon-hover/index.d.ts +5 -3
- package/types/index.d.ts +4 -120
- package/types/input-tag/InputTag.d.ts +1 -1
- package/types/input-tag/interface.d.ts +1 -1
- package/types/link/interface.d.ts +1 -1
- package/types/list/index.d.ts +1 -1
- package/types/modal/interface.d.ts +1 -0
- package/types/notice/index.d.ts +3 -0
- package/types/notification/index.d.ts +1 -1
- package/types/page-header/index.d.ts +1 -1
- package/types/select/Select.d.ts +1 -1
- package/types/select-view/Core.d.ts +3 -2
- package/types/select-view/index.d.ts +1 -0
- package/types/statistic/index.d.ts +1 -1
- package/types/switch/index.d.ts +1 -1
- package/types/switch/interface.d.ts +1 -1
- package/types/table/interface.d.ts +2 -1
- package/types/tooltip/index.d.ts +1 -1
- package/types/trigger/index.d.ts +12 -8
- package/types/trigger/interface.d.ts +1 -0
- package/types/typography/Base.d.ts +8 -7
- package/types/typography/EditContent.d.ts +3 -2
- package/types/typography/Paragraph.d.ts +2 -5
- package/types/typography/Text.d.ts +1 -5
- package/types/typography/Title.d.ts +2 -5
- package/types/upload/TriggerNode.d.ts +5 -3
- package/types/upload/list/PictureItem.d.ts +3 -3
- package/types/upload/list/TextItem.d.ts +3 -3
- package/types/utils/CSSTransition.d.ts +2 -0
- package/types/utils/constant.d.ts +1 -1
- package/types/utils/is.d.ts +4 -0
- package/types/utils/reactDOM.d.ts +3 -1
- package/types/utils/warning.d.ts +1 -1
- package/types/version/index.d.ts +1 -1
- package/typography/Base.js +184 -0
- package/typography/EditContent.js +49 -0
- package/typography/Ellipsis.js +293 -0
- package/typography/Operations.js +78 -0
- package/typography/Paragraph.js +26 -0
- package/typography/Text.js +11 -0
- package/typography/Title.js +12 -0
- package/typography/Typography.js +15 -0
- package/typography/useCssEllipsis.js +37 -0
- package/typography/useEllipsis.js +150 -0
- package/upload/TriggerNode.js +118 -0
- package/upload/Upload.js +205 -0
- package/upload/Uploader.js +205 -0
- package/upload/interface.js +9 -0
- package/upload/list/PictureItem.js +91 -0
- package/upload/list/TextItem.js +99 -0
- package/upload/list/UploadProgress.js +97 -0
- package/upload/list/index.js +120 -0
- package/upload/request.js +51 -0
- package/upload/util.js +61 -0
- package/utils/CSSTransition.js +27 -0
- package/utils/contextHolder.js +29 -4
- package/utils/getHighlightText.js +1 -2
- package/utils/is.js +81 -68
- package/utils/reactDOM.js +33 -22
- package/utils/style.js +1 -2
- package/utils/warning.js +7 -3
- package/verification-code/VerificationCode.js +83 -0
- package/virtual-list/Filler.js +31 -0
- package/virtual-list/VirtualList.js +378 -0
- package/virtual-list/util/algorithm.js +32 -0
- package/virtual-list/util/item.js +99 -0
- package/{chunk/BCEX3Acw.js → watermark/Watermark.js} +13 -11
- package/chunk/B1P8u7kB.js +0 -798
- package/chunk/B2ufZjjd.js +0 -1000
- package/chunk/B7QOJqps.js +0 -162
- package/chunk/BBz3S3zo.js +0 -966
- package/chunk/BGzBxiWE.js +0 -517
- package/chunk/BNRfcEHj.js +0 -984
- package/chunk/BSs6uXmc.js +0 -946
- package/chunk/BTjUAV8T.js +0 -277
- package/chunk/BYQeEcKe.js +0 -375
- package/chunk/Ba4UXIST.js +0 -605
- package/chunk/BfaXVcik.js +0 -271
- package/chunk/Bs11tCU6.js +0 -240
- package/chunk/C7FC7dzS.js +0 -516
- package/chunk/CLzbve11.js +0 -694
- package/chunk/CN4zXU4b.js +0 -877
- package/chunk/CYTPZUHD.js +0 -769
- package/chunk/CcCo_dK0.js +0 -335
- package/chunk/CoCXcpQd.js +0 -261
- package/chunk/D4yH4UKK.js +0 -80
- package/chunk/DiSLYN2-.js +0 -167
- package/chunk/Dr0iXIXO.js +0 -736
- package/chunk/G3-2uJao.js +0 -229
- package/chunk/RnTpOC5-.js +0 -1
- package/chunk/Z-mtdHUQ.js +0 -226
- package/chunk/ZISxNnaR.js +0 -165
- package/chunk/aPJXnDSb.js +0 -450
- package/chunk/i605JRmI.js +0 -232
- package/chunk/l0sNRNKZ.js +0 -1
- package/types/form/FormItemTip.d.ts +0 -8
- /package/{chunk/C6Kfwj0f.js → loading/style/index.less.js} +0 -0
- /package/{chunk/DP2rzg_V.js → suspense-fallback-test/style/index.less.js} +0 -0
- /package/types/{Popover → popover}/index.d.ts +0 -0
- /package/types/{Popover → popover}/interface.d.ts +0 -0
- /package/types/{Popover → popover}/style/index.d.ts +0 -0
- /package/{chunk/K6Dvbx-E.js → virtual-list/style/index.less.js} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import p from "lodash/isEqualWith";
|
|
2
|
+
import { useContext as F, useRef as m, useCallback as x, useState as C, useEffect as g } from "react";
|
|
3
|
+
import R from "../../utils/warning.js";
|
|
4
|
+
import { FormContext as b } from "../context.js";
|
|
5
|
+
const v = (s, l) => {
|
|
6
|
+
const S = F(b), t = l || S.store, u = m(s);
|
|
7
|
+
u.current = s;
|
|
8
|
+
const c = x(() => {
|
|
9
|
+
const e = u.current, o = t.getFieldsState([e]);
|
|
10
|
+
return o == null ? void 0 : o[e];
|
|
11
|
+
}, []), [f, d] = C(c), i = m(f);
|
|
12
|
+
return g(() => {
|
|
13
|
+
var a;
|
|
14
|
+
if (!t) {
|
|
15
|
+
R(!0, "formInstance is not available");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { registerStateWatcher: e } = ((a = t == null ? void 0 : t.getInnerMethods) == null ? void 0 : a.call(t, !0)) ?? {}, o = () => {
|
|
19
|
+
const n = c();
|
|
20
|
+
p(i.current, n) || (d(n), i.current = n);
|
|
21
|
+
};
|
|
22
|
+
o();
|
|
23
|
+
const r = e == null ? void 0 : e(o);
|
|
24
|
+
return () => {
|
|
25
|
+
r == null || r();
|
|
26
|
+
};
|
|
27
|
+
}, []), f;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
v as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import g from "lodash/get";
|
|
2
|
+
import x from "lodash/isArray";
|
|
3
|
+
import v from "lodash/isString";
|
|
4
|
+
import { useContext as w, useState as y, useRef as p, useEffect as C } from "react";
|
|
5
|
+
import { FormContext as F } from "../context.js";
|
|
6
|
+
import R from "../../utils/warning.js";
|
|
7
|
+
const M = (r, V) => {
|
|
8
|
+
const S = w(F), t = V || S.store, [s, d] = y(() => {
|
|
9
|
+
const e = t == null ? void 0 : t.getFieldsValue([].concat(r));
|
|
10
|
+
return v(r) ? g(e, r) : e;
|
|
11
|
+
}), i = p(r);
|
|
12
|
+
i.current = r;
|
|
13
|
+
const a = p(JSON.stringify(s));
|
|
14
|
+
return C(() => {
|
|
15
|
+
var f;
|
|
16
|
+
if (!t) {
|
|
17
|
+
R(!0, "formInstance is not available");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { registerWatcher: e } = ((f = t == null ? void 0 : t.getInnerMethods) == null ? void 0 : f.call(t, !0)) ?? {}, c = () => {
|
|
21
|
+
const n = i.current, l = t.getFieldsValue([].concat(n));
|
|
22
|
+
let u = l;
|
|
23
|
+
x(n) || (u = g(l, n));
|
|
24
|
+
const m = JSON.stringify(u);
|
|
25
|
+
a.current !== m && (d(u), a.current = m);
|
|
26
|
+
};
|
|
27
|
+
c();
|
|
28
|
+
const o = e == null ? void 0 : e(c);
|
|
29
|
+
return () => {
|
|
30
|
+
o == null || o();
|
|
31
|
+
};
|
|
32
|
+
}, []), s;
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
M as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const s = {
|
|
2
|
+
error: "error",
|
|
3
|
+
success: "success",
|
|
4
|
+
warning: "warning",
|
|
5
|
+
validating: "validating"
|
|
6
|
+
};
|
|
7
|
+
var n = /* @__PURE__ */ ((r) => (r.init = "init", r.error = "error", r.success = "success", r.submitting = "submitting", r))(n || {});
|
|
8
|
+
export {
|
|
9
|
+
n as SubmitStatus,
|
|
10
|
+
s as VALIDATE_STATUS
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var s = (e, r, t) => r in e ? u(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var n = (e, r, t) => s(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
class p extends Error {
|
|
5
|
+
constructor(t) {
|
|
6
|
+
super("form validate error, get errors by error.errors");
|
|
7
|
+
n(this, "errors", {});
|
|
8
|
+
this.errors = t;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function a(e) {
|
|
12
|
+
return Object.defineProperty(
|
|
13
|
+
(...r) => typeof r[r.length - 1] == "function" ? e.apply(this, r) : new Promise((t, i) => (r[r.length] = (o, l) => {
|
|
14
|
+
if (o) return i(new p(o));
|
|
15
|
+
t(l);
|
|
16
|
+
}, r.length++, e.apply(this, r))),
|
|
17
|
+
"name",
|
|
18
|
+
{ value: e.name }
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
a as default
|
|
23
|
+
};
|
package/form/store.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var k = (F, t, e) => t in F ? j(F, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : F[t] = e;
|
|
3
|
+
var r = (F, t, e) => k(F, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import g from "lodash/get";
|
|
5
|
+
import R from "lodash/has";
|
|
6
|
+
import c from "lodash/isArray";
|
|
7
|
+
import v from "lodash/isFunction";
|
|
8
|
+
import E from "lodash/isPlainObject";
|
|
9
|
+
import _ from "lodash/merge";
|
|
10
|
+
import w from "lodash/omit";
|
|
11
|
+
import L from "lodash/setWith";
|
|
12
|
+
import { isExist as I } from "../utils/is.js";
|
|
13
|
+
import { SubmitStatus as d } from "./interface.js";
|
|
14
|
+
import B from "./promisify.js";
|
|
15
|
+
import { iterativelyGetKeys as T, cloneDeep as m, set as n } from "./util.js";
|
|
16
|
+
class X {
|
|
17
|
+
constructor() {
|
|
18
|
+
// 表示的 Form 的提交状态而非单个字段的提交状态。
|
|
19
|
+
// 只有在触发表单 reset(原生 reset,而非当前的 resetFields) 时,才会回到 init 状态(目前没有支持 form.reset,所以没有这块逻辑)
|
|
20
|
+
r(this, "submitStatus", d.init);
|
|
21
|
+
r(this, "registerFields", []);
|
|
22
|
+
// 所有 form item value 的变动,都会通知这里注册到的 watcher
|
|
23
|
+
r(this, "registerWatchers", []);
|
|
24
|
+
// 所有 form item 内部 errors, validating, touched 状态的变化,都会通知这里注册到的 watcher
|
|
25
|
+
// TODO: 合并 registerWatchers
|
|
26
|
+
r(this, "registerStateWatchers", []);
|
|
27
|
+
// 所有 form 整体 的变动,都会通知这里注册到的 watcher
|
|
28
|
+
r(this, "registerFormWatchers", []);
|
|
29
|
+
// 和formControl 的 touched属性不一样。 只要被改过的字段,这里就会存储。并且不会跟随formControl被卸载而清除。
|
|
30
|
+
// reset 的时候清除
|
|
31
|
+
r(this, "touchedFields", {});
|
|
32
|
+
r(this, "store", {});
|
|
33
|
+
r(this, "initialValues", {});
|
|
34
|
+
r(this, "callbacks", {});
|
|
35
|
+
// 告知 form 状态改变,进行状态收集
|
|
36
|
+
r(this, "innerCollectFormState", () => {
|
|
37
|
+
this.notifyStateWatchers();
|
|
38
|
+
});
|
|
39
|
+
r(this, "innerSetCallbacks", (t) => {
|
|
40
|
+
this.callbacks = t;
|
|
41
|
+
});
|
|
42
|
+
r(this, "registerFormWatcher", (t) => (this.registerFormWatchers.push(t), () => {
|
|
43
|
+
this.registerFormWatchers = this.registerFormWatchers.filter(
|
|
44
|
+
(e) => e !== t
|
|
45
|
+
);
|
|
46
|
+
}));
|
|
47
|
+
r(this, "registerStateWatcher", (t) => (this.registerStateWatchers.push(t), () => {
|
|
48
|
+
this.registerStateWatchers = this.registerStateWatchers.filter(
|
|
49
|
+
(e) => e !== t
|
|
50
|
+
);
|
|
51
|
+
}));
|
|
52
|
+
r(this, "registerWatcher", (t) => (this.registerWatchers.push(t), () => {
|
|
53
|
+
this.registerWatchers = this.registerWatchers.filter((e) => e !== t);
|
|
54
|
+
}));
|
|
55
|
+
// 收集所有control字段,并在组件卸载时移除
|
|
56
|
+
r(this, "registerField", (t) => (this.registerFields.push(t), this.notifyWatchers(), () => {
|
|
57
|
+
this.registerFields = this.registerFields.filter((e) => e !== t), this.notifyWatchers();
|
|
58
|
+
}));
|
|
59
|
+
// hasField为true时,只返回传入field属性的control实例
|
|
60
|
+
// isFormList 目前只在校验时需要包含
|
|
61
|
+
// TODO formlist 实现缺陷,待优化
|
|
62
|
+
r(this, "getRegisteredFields", (t, e) => t ? this.registerFields.filter(
|
|
63
|
+
(i) => {
|
|
64
|
+
var s;
|
|
65
|
+
return i.hasFieldProps() && ((e == null ? void 0 : e.containFormList) || !((s = i.props) != null && s.isFormList));
|
|
66
|
+
}
|
|
67
|
+
) : this.registerFields);
|
|
68
|
+
// 获取props.field === field 的control组件。
|
|
69
|
+
r(this, "getRegisteredField", (t) => this.registerFields.filter((e) => e.props.field === t)[0]);
|
|
70
|
+
// 通知所有的FormItem进行更新。
|
|
71
|
+
// setFieldValue: 外部调用setFieldsValue (setFieldValue等)方法触发更新
|
|
72
|
+
// innerSetValue: 控件例如Input,通过onChange事件触发的更新
|
|
73
|
+
// reset:重置
|
|
74
|
+
r(this, "notify", (t, e) => {
|
|
75
|
+
(t === "setFieldValue" || t === "innerSetValue" && !e.ignore) && this._pushTouchField(
|
|
76
|
+
e.changeValues ? T(e.changeValues) : this._getIterativelyKeysByField(e.field)
|
|
77
|
+
), this.registerFields.forEach((i) => {
|
|
78
|
+
var s;
|
|
79
|
+
(s = i == null ? void 0 : i.onStoreChange) == null || s.call(i, t, {
|
|
80
|
+
...e,
|
|
81
|
+
current: this.store
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
r(this, "innerSetInitialValues", (t) => {
|
|
86
|
+
t && (this.initialValues = _(this.initialValues, m(t)), Object.keys(t).forEach((e) => {
|
|
87
|
+
n(this.store, e, t[e]);
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
r(this, "innerSetInitialValue", (t, e) => {
|
|
91
|
+
t && (this.initialValues[t] = e, this._inTouchFields(t) || n(this.store, t, g(this.initialValues, t)));
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* 内部使用,更新value,会同时触发onChange 和 onValuesChange
|
|
96
|
+
* @options.isFormList 强制更新field对应的组件包括其子组件,form
|
|
97
|
+
*/
|
|
98
|
+
r(this, "innerSetFieldValue", (t, e, i) => {
|
|
99
|
+
if (!t) return;
|
|
100
|
+
const s = this.getFields();
|
|
101
|
+
n(this.store, t, e), this.triggerValuesChange({
|
|
102
|
+
[t]: e
|
|
103
|
+
}), this.triggerTouchChange({ [t]: e }), this.notify("innerSetValue", {
|
|
104
|
+
prev: s,
|
|
105
|
+
field: t,
|
|
106
|
+
...i,
|
|
107
|
+
changeValues: { [t]: e }
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
// 内部使用
|
|
111
|
+
r(this, "innerGetStore", () => this.store);
|
|
112
|
+
// 目前返回提交状态,后续统一维护 errors,warnings 后,这里可进行拓展
|
|
113
|
+
r(this, "innerGetStoreStatus", () => ({
|
|
114
|
+
submitStatus: this.submitStatus
|
|
115
|
+
}));
|
|
116
|
+
// 内部使用,返回原始对象,注入到组件的 value 都从这里获取值,cloneDeep 后的值每次引用地址是不同的
|
|
117
|
+
r(this, "innerGetFieldValue", (t) => g(this.store, t));
|
|
118
|
+
// 获取所有被操作过的字段
|
|
119
|
+
r(this, "getTouchedFields", () => this.getRegisteredFields(!0).filter((t) => t.isTouched()).map((t) => t.props.field));
|
|
120
|
+
// 外部调用设置表单字段值
|
|
121
|
+
r(this, "setFieldValue", (t, e) => {
|
|
122
|
+
t && this.setFields({
|
|
123
|
+
[t]: { value: e }
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
// 外部调用,设置多个表单控件的值
|
|
127
|
+
r(this, "setFieldsValue", (t) => {
|
|
128
|
+
if (E(t)) {
|
|
129
|
+
const e = Object.keys(t), i = {};
|
|
130
|
+
e.forEach((s) => {
|
|
131
|
+
i[s] = {
|
|
132
|
+
value: t[s]
|
|
133
|
+
};
|
|
134
|
+
}), this.setFields(i);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
// 外部调用,设置多个表单控件的值,以及 error,touch 信息。
|
|
138
|
+
r(this, "setFields", (t) => {
|
|
139
|
+
const e = Object.keys(t), i = {};
|
|
140
|
+
e.forEach((s) => {
|
|
141
|
+
const h = t[s], a = this.getFields();
|
|
142
|
+
if (h) {
|
|
143
|
+
const o = {};
|
|
144
|
+
"error" in h && (o.errors = h.error), "warning" in h && (o.warnings = h.warning), "touched" in h && (o.touched = h.touched), "value" in h && (n(this.store, s, h.value), i[s] = h.value), this.notify("setFieldValue", {
|
|
145
|
+
data: o,
|
|
146
|
+
prev: a,
|
|
147
|
+
field: s,
|
|
148
|
+
changeValues: { [s]: h.value }
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}), this.triggerValuesChange(i);
|
|
152
|
+
});
|
|
153
|
+
r(this, "getFieldValue", (t) => m(g(this.store, t)));
|
|
154
|
+
// 获取单个字段的错误信息。
|
|
155
|
+
r(this, "getFieldError", (t) => {
|
|
156
|
+
const e = this.getRegisteredField(t);
|
|
157
|
+
return e ? e.getErrors() : null;
|
|
158
|
+
});
|
|
159
|
+
// 获取传入字段/全部的错误信息
|
|
160
|
+
r(this, "getFieldsError", (t) => {
|
|
161
|
+
const e = {};
|
|
162
|
+
return c(t) ? t.map((i) => {
|
|
163
|
+
const s = this.getFieldError(i);
|
|
164
|
+
s && (e[i] = s);
|
|
165
|
+
}) : this.getRegisteredFields(!0, { containFormList: !0 }).forEach(
|
|
166
|
+
(i) => {
|
|
167
|
+
i.getErrors() && (e[i.props.field] = i.getErrors());
|
|
168
|
+
}
|
|
169
|
+
), e;
|
|
170
|
+
});
|
|
171
|
+
r(this, "getFields", () => m(this.store));
|
|
172
|
+
r(this, "getFieldsValue", (t) => {
|
|
173
|
+
const e = {};
|
|
174
|
+
return c(t) ? (t.forEach((i) => {
|
|
175
|
+
n(e, i, this.getFieldValue(i));
|
|
176
|
+
}), e) : (this.getRegisteredFields(!0).forEach(({ props: { field: i } }) => {
|
|
177
|
+
const s = g(this.store, i);
|
|
178
|
+
n(e, i, s);
|
|
179
|
+
}), e);
|
|
180
|
+
});
|
|
181
|
+
r(this, "getInitialValues", () => this.initialValues);
|
|
182
|
+
r(this, "setInitialValues", (t) => {
|
|
183
|
+
this.innerSetInitialValues(t), this.setFieldsValue(t);
|
|
184
|
+
});
|
|
185
|
+
r(this, "setInitialValue", (t, e) => {
|
|
186
|
+
this.innerSetInitialValue(t, e), this.setFieldValue(t, e);
|
|
187
|
+
});
|
|
188
|
+
r(this, "resetFields", (t) => {
|
|
189
|
+
const e = this.getFields(), i = I(t) && !c(t) ? [t] : t;
|
|
190
|
+
let s = {};
|
|
191
|
+
if (i && c(i))
|
|
192
|
+
i.forEach((a) => {
|
|
193
|
+
n(
|
|
194
|
+
this.store,
|
|
195
|
+
a,
|
|
196
|
+
this.initialValues[a]
|
|
197
|
+
), s[a] = g(this.store, a);
|
|
198
|
+
}), this.triggerValuesChange(s), this.notify("reset", { prev: e, field: i }), this._popTouchField(i);
|
|
199
|
+
else {
|
|
200
|
+
const a = {};
|
|
201
|
+
s = this.getFields(), Object.keys(this.initialValues).forEach((o) => {
|
|
202
|
+
n(a, o, this.initialValues[o]);
|
|
203
|
+
}), this.store = a, this.getRegisteredFields(!0).forEach((o) => {
|
|
204
|
+
const p = o.props.field;
|
|
205
|
+
n(s, p, g(this.store, p));
|
|
206
|
+
}), this.triggerValuesChange(s), this._popTouchField(), this.notify("reset", {
|
|
207
|
+
prev: e,
|
|
208
|
+
field: Object.keys(s)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const { onReset: h } = this.callbacks;
|
|
212
|
+
h == null || h(s);
|
|
213
|
+
});
|
|
214
|
+
r(this, "validate", B(
|
|
215
|
+
(t, e, i) => {
|
|
216
|
+
const s = this.getRegisteredFields(!0, {
|
|
217
|
+
containFormList: !0
|
|
218
|
+
}), h = c(t) && t.length ? s.filter(
|
|
219
|
+
(u) => t.indexOf(u.props.field) > -1
|
|
220
|
+
) : s, a = E(t) ? t : E(e) ? e : {}, o = v(t) ? t : v(e) ? e : i || (() => {
|
|
221
|
+
}), p = h.map(
|
|
222
|
+
(u) => a != null && a.validateOnly ? u.validateFieldOnly() : u.validateField()
|
|
223
|
+
), S = (u) => {
|
|
224
|
+
if (!(a != null && a.validateOnly)) {
|
|
225
|
+
const { onValidateFail: l } = this.callbacks;
|
|
226
|
+
l == null || l(u);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
Promise.all(p).then((u) => {
|
|
230
|
+
let l = {};
|
|
231
|
+
const V = {};
|
|
232
|
+
u.map((f) => {
|
|
233
|
+
var b;
|
|
234
|
+
f.error && (l = { ...l, ...f.error });
|
|
235
|
+
const W = this.getRegisteredField(f.field);
|
|
236
|
+
(b = W == null ? void 0 : W.props) != null && b.isFormList || n(V, f.field, f.value);
|
|
237
|
+
});
|
|
238
|
+
let y;
|
|
239
|
+
return Object.keys(l).length ? (S == null || S(l), y = o == null ? void 0 : o(l, m(V))) : y = o == null ? void 0 : o(null, m(V)), y;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
));
|
|
243
|
+
r(this, "toggleSubmitStatus", (t) => {
|
|
244
|
+
this.submitStatus = t, this.innerCollectFormState(), this.notifyFormWatcher();
|
|
245
|
+
});
|
|
246
|
+
r(this, "submit", () => (this.toggleSubmitStatus(d.submitting), this.validate((t, e) => {
|
|
247
|
+
let i;
|
|
248
|
+
const { onSubmit: s, onSubmitFailed: h } = this.callbacks;
|
|
249
|
+
!t && s && (i = s(e)), t && h && (i = h(t)), i && i.then ? i.then((a) => (this.toggleSubmitStatus(d.success), a)).catch((a) => (this.toggleSubmitStatus(d.error), Promise.reject(a))) : this.toggleSubmitStatus(
|
|
250
|
+
t ? d.error : d.success
|
|
251
|
+
);
|
|
252
|
+
})));
|
|
253
|
+
r(this, "getFieldsState", (t) => {
|
|
254
|
+
const e = {}, i = (s) => {
|
|
255
|
+
if (!s)
|
|
256
|
+
return null;
|
|
257
|
+
const h = s.getErrors();
|
|
258
|
+
return {
|
|
259
|
+
errors: h ? [h] : [],
|
|
260
|
+
warnings: s.getWarnings(),
|
|
261
|
+
validateStatus: s.getValidateStatus(),
|
|
262
|
+
isSubmitting: this.submitStatus === d.submitting,
|
|
263
|
+
isTouched: s.isTouched(),
|
|
264
|
+
value: this.getFieldValue(s.props.field)
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
return c(t) ? (t.forEach((s) => {
|
|
268
|
+
e[s] = i(this.getRegisteredField(s));
|
|
269
|
+
}), e) : (this.getRegisteredFields(!0).forEach((s) => {
|
|
270
|
+
e[s.props.field] = i(s);
|
|
271
|
+
}), e);
|
|
272
|
+
});
|
|
273
|
+
r(this, "clearFields", (t) => {
|
|
274
|
+
const e = this.getFields(), i = I(t) && !c(t) ? [t] : t;
|
|
275
|
+
if (i && c(i)) {
|
|
276
|
+
const s = {};
|
|
277
|
+
i.forEach((h) => {
|
|
278
|
+
n(this.store, h, void 0), s[h] = g(this.store, h);
|
|
279
|
+
}), this.triggerValuesChange(s), this.notify("setFieldValue", {
|
|
280
|
+
prev: e,
|
|
281
|
+
field: i,
|
|
282
|
+
data: {
|
|
283
|
+
errors: null,
|
|
284
|
+
warnings: null
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
} else {
|
|
288
|
+
const s = {};
|
|
289
|
+
this.store = {}, this.getRegisteredFields(!0).forEach((h) => {
|
|
290
|
+
const a = h.props.field;
|
|
291
|
+
n(s, a, void 0);
|
|
292
|
+
}), this.triggerValuesChange(s), this.notify("setFieldValue", {
|
|
293
|
+
prev: e,
|
|
294
|
+
field: Object.keys(s),
|
|
295
|
+
data: {
|
|
296
|
+
errors: null,
|
|
297
|
+
warnings: null
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
notifyWatchers() {
|
|
304
|
+
this.registerWatchers.forEach((t) => {
|
|
305
|
+
t();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
// 注册监听全局状态的 watcher
|
|
309
|
+
notifyFormWatcher() {
|
|
310
|
+
this.registerFormWatchers.forEach((t) => {
|
|
311
|
+
t();
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
notifyStateWatchers() {
|
|
315
|
+
this.registerStateWatchers.forEach((t) => {
|
|
316
|
+
t();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
triggerValuesChange(t) {
|
|
320
|
+
if (t && Object.keys(t).length) {
|
|
321
|
+
const { onValuesChange: e } = this.callbacks;
|
|
322
|
+
e == null || e(t, this.getFields());
|
|
323
|
+
}
|
|
324
|
+
this.notifyWatchers();
|
|
325
|
+
}
|
|
326
|
+
triggerTouchChange(t) {
|
|
327
|
+
if (t && Object.keys(t).length) {
|
|
328
|
+
const { onChange: e } = this.callbacks;
|
|
329
|
+
e == null || e(t, this.getFields());
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
_getIterativelyKeysByField(t) {
|
|
333
|
+
if (!t)
|
|
334
|
+
return [];
|
|
335
|
+
const i = [].concat(t).map((s) => T(n({}, s, void 0))).reduce((s, h) => s.concat(h), []);
|
|
336
|
+
return [t, ...i];
|
|
337
|
+
}
|
|
338
|
+
_inTouchFields(t) {
|
|
339
|
+
return this._getIterativelyKeysByField(t).some((i) => R(this.touchedFields, i));
|
|
340
|
+
}
|
|
341
|
+
_popTouchField(t) {
|
|
342
|
+
t === void 0 && (this.touchedFields = {});
|
|
343
|
+
const e = this._getIterativelyKeysByField(t);
|
|
344
|
+
this.touchedFields = w(this.touchedFields, e);
|
|
345
|
+
}
|
|
346
|
+
_pushTouchField(t) {
|
|
347
|
+
[].concat(t).forEach((e) => {
|
|
348
|
+
L(this.touchedFields, e, void 0, Object);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
export {
|
|
353
|
+
X as default
|
|
354
|
+
};
|
package/form/useForm.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useRef as r } from "react";
|
|
2
|
+
import s from "./store.js";
|
|
3
|
+
function a() {
|
|
4
|
+
const e = new s();
|
|
5
|
+
return {
|
|
6
|
+
getFieldsValue: e.getFieldsValue,
|
|
7
|
+
getFieldValue: e.getFieldValue,
|
|
8
|
+
getFieldError: e.getFieldError,
|
|
9
|
+
getFieldsError: e.getFieldsError,
|
|
10
|
+
getTouchedFields: e.getTouchedFields,
|
|
11
|
+
getFields: e.getFields,
|
|
12
|
+
getInitialValues: e.getInitialValues,
|
|
13
|
+
setInitialValues: e.setInitialValues,
|
|
14
|
+
setInitialValue: e.setInitialValue,
|
|
15
|
+
setFieldValue: e.setFieldValue,
|
|
16
|
+
setFieldsValue: e.setFieldsValue,
|
|
17
|
+
setFields: e.setFields,
|
|
18
|
+
resetFields: e.resetFields,
|
|
19
|
+
clearFields: e.clearFields,
|
|
20
|
+
submit: e.submit,
|
|
21
|
+
validate: e.validate,
|
|
22
|
+
scrollToField: () => {
|
|
23
|
+
},
|
|
24
|
+
getFieldsState: e.getFieldsState,
|
|
25
|
+
getInnerMethods: (t) => {
|
|
26
|
+
const i = {};
|
|
27
|
+
return t && [
|
|
28
|
+
"registerField",
|
|
29
|
+
"registerWatcher",
|
|
30
|
+
"registerStateWatcher",
|
|
31
|
+
"registerFormWatcher",
|
|
32
|
+
"innerSetInitialValues",
|
|
33
|
+
"innerSetInitialValue",
|
|
34
|
+
"innerSetCallbacks",
|
|
35
|
+
"innerSetFieldValue",
|
|
36
|
+
"innerGetStore",
|
|
37
|
+
"innerGetStoreStatus",
|
|
38
|
+
"innerGetFieldValue",
|
|
39
|
+
"innerCollectFormState"
|
|
40
|
+
].map((l) => {
|
|
41
|
+
i[l] = e[l];
|
|
42
|
+
}), i;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function u(e) {
|
|
47
|
+
const t = r(e);
|
|
48
|
+
return t.current || (e ? t.current = e : t.current = a()), [t.current];
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
u as default,
|
|
52
|
+
a as getFormInstance
|
|
53
|
+
};
|
package/form/util.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Schema as l } from "@unicom-cloud/utils/validate";
|
|
2
|
+
import h from "lodash/cloneDeepWith";
|
|
3
|
+
import g from "lodash/has";
|
|
4
|
+
import y from "lodash/isArray";
|
|
5
|
+
import v from "lodash/isFunction";
|
|
6
|
+
import d from "lodash/isPlainObject";
|
|
7
|
+
import S from "lodash/set";
|
|
8
|
+
import E from "lodash/setWith";
|
|
9
|
+
import w from "react";
|
|
10
|
+
function O(t) {
|
|
11
|
+
return h(t, (n) => {
|
|
12
|
+
if (!d(n) && !y(n))
|
|
13
|
+
return n;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const x = (t, n) => h(t, (e) => {
|
|
17
|
+
if (v(e))
|
|
18
|
+
return (s) => e(s, n);
|
|
19
|
+
});
|
|
20
|
+
function A(t, n, e) {
|
|
21
|
+
return S(t, n, O(e)), t;
|
|
22
|
+
}
|
|
23
|
+
function G(t, n = "") {
|
|
24
|
+
const e = /* @__PURE__ */ new Set(), s = (r, c = "") => r ? e.has(r) ? [] : (e.add(r), Object.keys(r).map((i) => (d(r[i]) || y(r[i])) && Object.keys(r[i]).length && !w.isValidElement(r[i]) ? s(r[i], `${c + i}.`) : c + i).flat()) : [];
|
|
25
|
+
return s(t, n);
|
|
26
|
+
}
|
|
27
|
+
function L(t) {
|
|
28
|
+
var n;
|
|
29
|
+
return ((n = t == null ? void 0 : t.constructor) == null ? void 0 : n.name) === "SyntheticEvent" || (t == null ? void 0 : t.nativeEvent) instanceof Event;
|
|
30
|
+
}
|
|
31
|
+
async function R(t, n, e, s) {
|
|
32
|
+
const r = [...e || []];
|
|
33
|
+
let c = 0;
|
|
34
|
+
return new Promise(async (i) => {
|
|
35
|
+
const a = [], f = async (u) => {
|
|
36
|
+
const p = () => c < r.length - 1 ? (c++, f(r[c])) : i({ error: null, warning: a });
|
|
37
|
+
if (!u)
|
|
38
|
+
return p();
|
|
39
|
+
const o = { ...u };
|
|
40
|
+
!o.type && !o.validator && (o.type = "string"), new l({ [t]: [o] }, {
|
|
41
|
+
ignoreEmptyString: !0,
|
|
42
|
+
validateMessages: s
|
|
43
|
+
}).validate({ [t]: n }, (m) => {
|
|
44
|
+
if (m)
|
|
45
|
+
if (u.validateLevel === "warning")
|
|
46
|
+
a.push(m[t].message);
|
|
47
|
+
else
|
|
48
|
+
return i({
|
|
49
|
+
error: m,
|
|
50
|
+
warning: a
|
|
51
|
+
});
|
|
52
|
+
return p();
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
f(r[c]);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function U(t, n) {
|
|
59
|
+
const e = E({}, t, void 0, Object);
|
|
60
|
+
return n.some((s) => g(e, s));
|
|
61
|
+
}
|
|
62
|
+
const X = "_input";
|
|
63
|
+
export {
|
|
64
|
+
X as ID_SUFFIX,
|
|
65
|
+
O as cloneDeep,
|
|
66
|
+
x as formatValidateMsg,
|
|
67
|
+
U as isFieldMatch,
|
|
68
|
+
L as isSyntheticEvent,
|
|
69
|
+
G as iterativelyGetKeys,
|
|
70
|
+
R as schemaValidate,
|
|
71
|
+
A as set
|
|
72
|
+
};
|
package/grid/Col.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import H from "lodash/isNumber";
|
|
3
|
+
import T from "lodash/isPlainObject";
|
|
4
|
+
import { forwardRef as q, useContext as S, useMemo as C } from "react";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import "../config-provider/ConfigProvider.js";
|
|
7
|
+
import D from "../hooks/useMergeProps.js";
|
|
8
|
+
import I from "@unicom-cloud/utils/class-name";
|
|
9
|
+
import { RowContext as J } from "./context.js";
|
|
10
|
+
import { ConfigContext as K } from "../config-provider/context.js";
|
|
11
|
+
const Q = {
|
|
12
|
+
span: 24
|
|
13
|
+
};
|
|
14
|
+
function v(n) {
|
|
15
|
+
return typeof n == "string" && /\d+[px|%|em|rem|]{1}/.test(n) ? `0 0 ${n}` : n;
|
|
16
|
+
}
|
|
17
|
+
function U(n, w) {
|
|
18
|
+
const { getPrefixCls: A, componentConfig: f, rtl: G } = S(K), L = D(
|
|
19
|
+
n,
|
|
20
|
+
Q,
|
|
21
|
+
f == null ? void 0 : f["Grid.Col"]
|
|
22
|
+
), { gutter: p, div: $ } = S(J), {
|
|
23
|
+
className: M,
|
|
24
|
+
style: N,
|
|
25
|
+
children: O,
|
|
26
|
+
span: V,
|
|
27
|
+
offset: a,
|
|
28
|
+
order: u,
|
|
29
|
+
pull: c,
|
|
30
|
+
push: m,
|
|
31
|
+
xs: x,
|
|
32
|
+
sm: g,
|
|
33
|
+
md: y,
|
|
34
|
+
lg: h,
|
|
35
|
+
xl: P,
|
|
36
|
+
xxl: b,
|
|
37
|
+
xxxl: j,
|
|
38
|
+
flex: e,
|
|
39
|
+
...k
|
|
40
|
+
} = L;
|
|
41
|
+
function z(r, o) {
|
|
42
|
+
const R = { xs: x, sm: g, md: y, lg: h, xl: P, xxl: b, xxxl: j };
|
|
43
|
+
return Object.keys(R).forEach((i) => {
|
|
44
|
+
const t = R[i];
|
|
45
|
+
H(t) ? t >= 0 && (o[`${r}-${i}-${t}`] = !0) : T(t) && (o[`${r}-${i}-${t.span}`] = t.span, o[`${r}-${i}-offset-${t.offset}`] = t.offset, o[`${r}-${i}-order-${t.order}`] = t.order, o[`${r}-${i}-pull-${t.pull}`] = t.pull, o[`${r}-${i}-push-${t.push}`] = t.push);
|
|
46
|
+
}), o;
|
|
47
|
+
}
|
|
48
|
+
const s = A("col");
|
|
49
|
+
let d = {
|
|
50
|
+
[`${s}`]: !$,
|
|
51
|
+
[`${s}-order-${u}`]: u,
|
|
52
|
+
[`${s}-${V}`]: !$ && !x && !g && !y && !h && !P && !b && !j,
|
|
53
|
+
[`${s}-offset-${a}`]: a,
|
|
54
|
+
[`${s}-pull-${c}`]: c,
|
|
55
|
+
[`${s}-push-${m}`]: m,
|
|
56
|
+
[`${s}-rtl`]: G
|
|
57
|
+
};
|
|
58
|
+
d = z(s, d);
|
|
59
|
+
const B = I(e ? s : d, M), l = {};
|
|
60
|
+
if (Array.isArray(p) && !$) {
|
|
61
|
+
const r = p[0] && p[0] / 2 || 0, o = p[1] && p[1] / 2 || 0;
|
|
62
|
+
r && (l.paddingLeft = r, l.paddingRight = r), o && (l.paddingTop = o, l.paddingBottom = o);
|
|
63
|
+
}
|
|
64
|
+
const E = C(
|
|
65
|
+
() => v(e) ? { flex: v(e) } : {},
|
|
66
|
+
[e]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ F(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
ref: w,
|
|
72
|
+
...k,
|
|
73
|
+
style: {
|
|
74
|
+
...N,
|
|
75
|
+
...l,
|
|
76
|
+
...E
|
|
77
|
+
},
|
|
78
|
+
className: B,
|
|
79
|
+
children: O
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const W = q(U);
|
|
84
|
+
W.displayName = "Col";
|
|
85
|
+
export {
|
|
86
|
+
W as default
|
|
87
|
+
};
|