@rockshin/tao-ui 0.0.59 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/component-manifest.json +1 -1
- package/dist/components/affix/affix.css +1 -1
- package/dist/components/affix/affix.d.ts +1 -0
- package/dist/components/affix/affix.js +18 -17
- package/dist/components/alert/alert.css +123 -119
- package/dist/components/alert/alert.js +78 -188
- package/dist/components/app/app-modals.js +49 -98
- package/dist/components/app/app-notices.d.ts +2 -2
- package/dist/components/app/app-notices.js +294 -243
- package/dist/components/app/app-types.d.ts +6 -3
- package/dist/components/app/app.css +185 -183
- package/dist/components/app/app.js +1 -1
- package/dist/components/auto-complete/auto-complete.css +30 -28
- package/dist/components/auto-complete/auto-complete.d.ts +3 -1
- package/dist/components/auto-complete/auto-complete.js +2 -1
- package/dist/components/badge/badge.js +42 -127
- package/dist/components/border-beam/border-beam.css +1 -1
- package/dist/components/border-beam/border-beam.d.ts +1 -0
- package/dist/components/border-beam/border-beam.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.css +123 -120
- package/dist/components/breadcrumb/breadcrumb.js +160 -265
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +52 -151
- package/dist/components/calendar/calendar.js +28 -27
- package/dist/components/card/card-tabs.d.ts +56 -5
- package/dist/components/card/card-tabs.js +214 -468
- package/dist/components/card/card.d.ts +1 -2
- package/dist/components/card/card.js +64 -226
- package/dist/components/carousel/carousel.css +1 -1
- package/dist/components/carousel/carousel.d.ts +59 -4
- package/dist/components/carousel/carousel.js +299 -243
- package/dist/components/cascader/cascader.css +186 -184
- package/dist/components/cascader/cascader.d.ts +3 -1
- package/dist/components/cascader/cascader.js +29 -34
- package/dist/components/checkbox/checkbox.css +93 -90
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +171 -499
- package/dist/components/collapse/collapse-panels.js +145 -400
- package/dist/components/collapse/collapse.css +172 -170
- package/dist/components/collapse/collapse.d.ts +1 -1
- package/dist/components/collapse/collapse.js +62 -181
- package/dist/components/color-picker/color-picker.css +1 -1
- package/dist/components/color-picker/color-picker.js +418 -981
- package/dist/components/context-menu/context-menu.css +4 -4
- package/dist/components/context-menu/context-menu.d.ts +3 -1
- package/dist/components/context-menu/context-menu.js +54 -135
- package/dist/components/date-picker/calendar/calendar-grid.js +41 -41
- package/dist/components/date-picker/calendar/calendar-header.js +171 -337
- package/dist/components/date-picker/calendar/month-grid.js +33 -103
- package/dist/components/date-picker/calendar/time-panel.js +84 -209
- package/dist/components/date-picker/calendar/year-grid.js +36 -105
- package/dist/components/date-picker/date-localization.js +1 -1
- package/dist/components/date-picker/date-picker.css +599 -642
- package/dist/components/date-picker/date-picker.d.ts +2 -1
- package/dist/components/date-picker/date-picker.js +96 -105
- package/dist/components/date-picker/presets.js +12 -37
- package/dist/components/date-picker/range-picker.d.ts +2 -1
- package/dist/components/date-picker/range-picker.js +222 -255
- package/dist/components/date-picker/types.d.ts +2 -1
- package/dist/components/descriptions/descriptions.css +1 -1
- package/dist/components/descriptions/descriptions.js +30 -39
- package/dist/components/drawer/drawer.css +202 -200
- package/dist/components/drawer/drawer.js +28 -34
- package/dist/components/dropdown/dropdown-core.d.ts +32 -0
- package/dist/components/dropdown/dropdown-core.js +156 -0
- package/dist/components/dropdown/dropdown.css +38 -36
- package/dist/components/dropdown/dropdown.d.ts +4 -30
- package/dist/components/dropdown/dropdown.js +91 -271
- package/dist/components/empty/empty.css +30 -28
- package/dist/components/empty/empty.js +81 -236
- package/dist/components/float-button/float-button.css +1 -1
- package/dist/components/float-button/float-button.js +38 -48
- package/dist/components/form/field-control.js +2 -3
- package/dist/components/form/form-item.js +67 -129
- package/dist/components/form/form.css +36 -34
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.js +29 -100
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/form/use-form.js +48 -66
- package/dist/components/form-actions/form-actions.d.ts +1 -0
- package/dist/components/form-actions/form-actions.js +10 -36
- package/dist/components/form-field/form-field-view.d.ts +1 -0
- package/dist/components/form-field/form-field-view.js +81 -288
- package/dist/components/form-field/form-field.js +13 -31
- package/dist/components/form-field/form.css +74 -72
- package/dist/components/form-section/form-section.d.ts +1 -0
- package/dist/components/form-section/form-section.js +38 -91
- package/dist/components/image/image-icons.js +16 -31
- package/dist/components/image/image.css +1 -1
- package/dist/components/image/image.js +298 -911
- package/dist/components/input/base-input.d.ts +3 -1
- package/dist/components/input/base-input.js +8 -7
- package/dist/components/input/input-shared.css +62 -60
- package/dist/components/input/input-shared.d.ts +1 -1
- package/dist/components/input/input-shared.js +56 -100
- package/dist/components/input/input.css +222 -220
- package/dist/components/input/otp.d.ts +2 -1
- package/dist/components/input/otp.js +143 -324
- package/dist/components/input/password.js +12 -67
- package/dist/components/input/search.js +13 -13
- package/dist/components/input-number/input-number.d.ts +4 -2
- package/dist/components/input-number/input-number.js +30 -137
- package/dist/components/list/list-pagination.css +107 -105
- package/dist/components/list/list-pagination.d.ts +56 -5
- package/dist/components/list/list-pagination.js +249 -316
- package/dist/components/list/list.css +179 -177
- package/dist/components/list/list.js +170 -604
- package/dist/components/listy/listy.css +55 -53
- package/dist/components/listy/listy.d.ts +43 -4
- package/dist/components/listy/listy.js +198 -216
- package/dist/components/masonry/masonry.css +1 -1
- package/dist/components/masonry/masonry.d.ts +1 -0
- package/dist/components/masonry/masonry.js +90 -244
- package/dist/components/mentions/mentions.css +153 -151
- package/dist/components/mentions/mentions.d.ts +53 -11
- package/dist/components/mentions/mentions.js +291 -75
- package/dist/components/menu/menu-render.d.ts +7 -0
- package/dist/components/menu/menu-render.js +156 -302
- package/dist/components/menu/menu.css +142 -140
- package/dist/components/modal/confirm-dialog.js +19 -24
- package/dist/components/modal/modal.css +165 -162
- package/dist/components/modal/modal.js +285 -731
- package/dist/components/modal/use-modal.js +25 -25
- package/dist/components/pagination/pagination.css +134 -131
- package/dist/components/pagination/pagination.d.ts +4 -3
- package/dist/components/pagination/pagination.js +138 -281
- package/dist/components/popconfirm/popconfirm.css +38 -36
- package/dist/components/popconfirm/popconfirm.js +105 -288
- package/dist/components/popover/popover.css +89 -87
- package/dist/components/popover/popover.js +189 -469
- package/dist/components/progress/progress.css +153 -151
- package/dist/components/progress/progress.js +34 -43
- package/dist/components/qr-code/qr-code.css +36 -34
- package/dist/components/qr-code/qr-code.js +83 -277
- package/dist/components/radio/radio.css +95 -92
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +114 -376
- package/dist/components/rate/rate.css +80 -78
- package/dist/components/rate/rate.d.ts +34 -6
- package/dist/components/rate/rate.js +160 -244
- package/dist/components/result/result.css +59 -57
- package/dist/components/result/result.d.ts +1 -0
- package/dist/components/result/result.js +118 -291
- package/dist/components/scroll-area/scroll-area.css +160 -148
- package/dist/components/scroll-area/scroll-area.js +284 -488
- package/dist/components/segmented/segmented.css +1 -1
- package/dist/components/segmented/segmented.js +59 -58
- package/dist/components/select/mobile-select.css +166 -164
- package/dist/components/select/mobile-select.js +48 -131
- package/dist/components/select/select-icons.js +59 -128
- package/dist/components/select/select-model.js +1 -1
- package/dist/components/select/select-searchable-list.js +19 -19
- package/dist/components/select/select-tags.js +70 -156
- package/dist/components/select/select-types.d.ts +2 -1
- package/dist/components/select/select.css +509 -506
- package/dist/components/select/select.d.ts +1 -0
- package/dist/components/select/select.js +67 -65
- package/dist/components/select/use-select-selection.js +181 -261
- package/dist/components/skeleton/skeleton.css +105 -103
- package/dist/components/skeleton/skeleton.js +140 -399
- package/dist/components/slider/slider.css +160 -158
- package/dist/components/slider/slider.d.ts +45 -6
- package/dist/components/slider/slider.js +359 -74
- package/dist/components/sonner/index.d.ts +1 -1
- package/dist/components/sonner/sonner.css +190 -182
- package/dist/components/sonner/sonner.js +12 -11
- package/dist/components/spinner/spinner.css +80 -76
- package/dist/components/spinner/spinner.d.ts +1 -1
- package/dist/components/spinner/spinner.js +75 -219
- package/dist/components/splitter/splitter.css +157 -154
- package/dist/components/splitter/splitter.js +271 -448
- package/dist/components/statistic/statistic.css +1 -1
- package/dist/components/statistic/statistic.js +121 -406
- package/dist/components/status-icon/status-icon.js +14 -26
- package/dist/components/steps/steps-icons.js +63 -100
- package/dist/components/steps/steps.css +817 -807
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/steps/steps.js +38 -94
- package/dist/components/steps/use-display-steps.js +21 -54
- package/dist/components/switch/switch-touch.css +17 -15
- package/dist/components/switch/switch.css +192 -190
- package/dist/components/switch/switch.js +63 -196
- package/dist/components/table/table-filter.d.ts +3 -1
- package/dist/components/table/table-filter.js +72 -133
- package/dist/components/table/table-icons.js +77 -152
- package/dist/components/table/table-summary.js +30 -77
- package/dist/components/table/table-types.d.ts +2 -1
- package/dist/components/table/table.css +468 -465
- package/dist/components/table/table.js +86 -84
- package/dist/components/table/use-table-data.js +137 -248
- package/dist/components/tabs/tabs.css +123 -120
- package/dist/components/tabs/tabs.d.ts +4 -3
- package/dist/components/tabs/tabs.js +157 -322
- package/dist/components/tag/tag.css +231 -221
- package/dist/components/tag/tag.js +110 -248
- package/dist/components/textarea/textarea.css +2 -1
- package/dist/components/textarea/textarea.d.ts +3 -1
- package/dist/components/textarea/textarea.js +16 -15
- package/dist/components/time-picker/time-picker.d.ts +1 -0
- package/dist/components/time-picker/time-picker.js +91 -221
- package/dist/components/timeline/timeline.css +1 -1
- package/dist/components/timeline/timeline.js +17 -17
- package/dist/components/tooltip/tooltip.css +79 -77
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +111 -263
- package/dist/components/tour/tour.css +1 -1
- package/dist/components/tour/tour.d.ts +59 -6
- package/dist/components/tour/tour.js +343 -622
- package/dist/components/transfer/transfer-list.js +19 -19
- package/dist/components/transfer/transfer-parts.js +63 -139
- package/dist/components/transfer/transfer.css +192 -190
- package/dist/components/transfer/transfer.js +57 -56
- package/dist/components/tree/tree-check.js +25 -32
- package/dist/components/tree/tree-keyboard.js +1 -1
- package/dist/components/tree/tree.css +204 -200
- package/dist/components/tree/tree.js +139 -277
- package/dist/components/tree-select/select-engine.css +200 -197
- package/dist/components/tree-select/select-engine.js +11 -38
- package/dist/components/tree-select/tree-select.css +21 -19
- package/dist/components/tree-select/tree-select.d.ts +3 -1
- package/dist/components/tree-select/tree-select.js +12 -10
- package/dist/components/upload/upload.js +193 -308
- package/dist/components/watermark/watermark-context.js +8 -14
- package/dist/components/watermark/watermark.css +1 -1
- package/dist/components/watermark/watermark.js +209 -400
- package/dist/docs/components/stack.doc.js +1 -1
- package/dist/docs/components/table.doc.js +1 -1
- package/dist/entries/affix.d.ts +0 -2
- package/dist/entries/affix.js +0 -2
- package/dist/entries/alert.d.ts +0 -2
- package/dist/entries/alert.js +0 -2
- package/dist/entries/app.d.ts +0 -2
- package/dist/entries/app.js +0 -2
- package/dist/entries/auto-complete.d.ts +0 -2
- package/dist/entries/auto-complete.js +0 -2
- package/dist/entries/avatar.d.ts +0 -2
- package/dist/entries/avatar.js +0 -2
- package/dist/entries/badge.d.ts +0 -2
- package/dist/entries/badge.js +0 -2
- package/dist/entries/border-beam.d.ts +0 -2
- package/dist/entries/border-beam.js +0 -2
- package/dist/entries/breadcrumb.d.ts +0 -2
- package/dist/entries/breadcrumb.js +0 -2
- package/dist/entries/button.d.ts +0 -2
- package/dist/entries/button.js +0 -2
- package/dist/entries/calendar.d.ts +0 -2
- package/dist/entries/calendar.js +0 -2
- package/dist/entries/card.d.ts +0 -2
- package/dist/entries/card.js +0 -2
- package/dist/entries/carousel.d.ts +0 -2
- package/dist/entries/carousel.js +0 -2
- package/dist/entries/cascader.d.ts +0 -2
- package/dist/entries/cascader.js +0 -2
- package/dist/entries/checkbox.d.ts +0 -2
- package/dist/entries/checkbox.js +0 -2
- package/dist/entries/collapse.d.ts +0 -2
- package/dist/entries/collapse.js +0 -2
- package/dist/entries/color-picker.d.ts +0 -2
- package/dist/entries/color-picker.js +0 -2
- package/dist/entries/context-menu.d.ts +0 -2
- package/dist/entries/context-menu.js +0 -2
- package/dist/entries/date-picker.d.ts +0 -2
- package/dist/entries/date-picker.js +0 -2
- package/dist/entries/descriptions.d.ts +0 -2
- package/dist/entries/descriptions.js +0 -2
- package/dist/entries/divider.d.ts +0 -2
- package/dist/entries/divider.js +0 -2
- package/dist/entries/drawer.d.ts +0 -2
- package/dist/entries/drawer.js +0 -2
- package/dist/entries/dropdown.d.ts +0 -2
- package/dist/entries/dropdown.js +0 -2
- package/dist/entries/empty.d.ts +0 -2
- package/dist/entries/empty.js +0 -2
- package/dist/entries/float-button.d.ts +0 -2
- package/dist/entries/float-button.js +0 -2
- package/dist/entries/form-actions.d.ts +0 -2
- package/dist/entries/form-actions.js +0 -2
- package/dist/entries/form-field.d.ts +0 -2
- package/dist/entries/form-field.js +0 -2
- package/dist/entries/form-layout.d.ts +0 -2
- package/dist/entries/form-layout.js +0 -2
- package/dist/entries/form-section.d.ts +0 -2
- package/dist/entries/form-section.js +0 -2
- package/dist/entries/form.d.ts +1 -3
- package/dist/entries/form.js +0 -2
- package/dist/entries/image.d.ts +0 -2
- package/dist/entries/image.js +0 -2
- package/dist/entries/input-number.d.ts +0 -2
- package/dist/entries/input-number.js +0 -2
- package/dist/entries/input.d.ts +1 -3
- package/dist/entries/input.js +0 -2
- package/dist/entries/list.d.ts +0 -2
- package/dist/entries/list.js +0 -2
- package/dist/entries/listy.d.ts +0 -2
- package/dist/entries/listy.js +0 -2
- package/dist/entries/masonry.d.ts +0 -2
- package/dist/entries/masonry.js +0 -2
- package/dist/entries/mentions.d.ts +0 -2
- package/dist/entries/mentions.js +0 -2
- package/dist/entries/modal.d.ts +0 -2
- package/dist/entries/modal.js +0 -2
- package/dist/entries/number-input.d.ts +0 -2
- package/dist/entries/number-input.js +0 -2
- package/dist/entries/pagination.d.ts +0 -2
- package/dist/entries/pagination.js +0 -2
- package/dist/entries/popconfirm.d.ts +0 -2
- package/dist/entries/popconfirm.js +0 -2
- package/dist/entries/popover.d.ts +0 -2
- package/dist/entries/popover.js +0 -2
- package/dist/entries/progress.d.ts +0 -2
- package/dist/entries/progress.js +0 -2
- package/dist/entries/provider.d.ts +1 -3
- package/dist/entries/provider.js +1 -3
- package/dist/entries/qr-code.d.ts +0 -2
- package/dist/entries/qr-code.js +0 -2
- package/dist/entries/radio.d.ts +0 -2
- package/dist/entries/radio.js +0 -2
- package/dist/entries/range-picker.d.ts +0 -2
- package/dist/entries/range-picker.js +0 -2
- package/dist/entries/rate.d.ts +0 -2
- package/dist/entries/rate.js +0 -2
- package/dist/entries/result.d.ts +0 -2
- package/dist/entries/result.js +0 -2
- package/dist/entries/scroll-area.d.ts +0 -2
- package/dist/entries/scroll-area.js +0 -2
- package/dist/entries/segmented.d.ts +0 -2
- package/dist/entries/segmented.js +0 -2
- package/dist/entries/select.d.ts +0 -2
- package/dist/entries/select.js +0 -2
- package/dist/entries/skeleton.d.ts +0 -2
- package/dist/entries/skeleton.js +0 -2
- package/dist/entries/slider.d.ts +0 -2
- package/dist/entries/slider.js +0 -2
- package/dist/entries/sonner.d.ts +0 -2
- package/dist/entries/sonner.js +0 -2
- package/dist/entries/spinner.d.ts +0 -2
- package/dist/entries/spinner.js +0 -2
- package/dist/entries/splitter.d.ts +0 -2
- package/dist/entries/splitter.js +0 -2
- package/dist/entries/stack.d.ts +0 -2
- package/dist/entries/stack.js +0 -2
- package/dist/entries/statistic.d.ts +0 -2
- package/dist/entries/statistic.js +0 -2
- package/dist/entries/steps.d.ts +0 -2
- package/dist/entries/steps.js +0 -2
- package/dist/entries/switch.d.ts +0 -2
- package/dist/entries/switch.js +0 -2
- package/dist/entries/table.d.ts +0 -2
- package/dist/entries/table.js +0 -2
- package/dist/entries/tabs.d.ts +0 -2
- package/dist/entries/tabs.js +0 -2
- package/dist/entries/tag.d.ts +0 -2
- package/dist/entries/tag.js +0 -2
- package/dist/entries/textarea.d.ts +0 -2
- package/dist/entries/textarea.js +0 -2
- package/dist/entries/time-picker.d.ts +0 -2
- package/dist/entries/time-picker.js +0 -2
- package/dist/entries/timeline.d.ts +0 -2
- package/dist/entries/timeline.js +0 -2
- package/dist/entries/tooltip.d.ts +0 -2
- package/dist/entries/tooltip.js +0 -2
- package/dist/entries/tour.d.ts +0 -2
- package/dist/entries/tour.js +0 -2
- package/dist/entries/transfer.d.ts +0 -2
- package/dist/entries/transfer.js +0 -2
- package/dist/entries/tree-select.d.ts +0 -2
- package/dist/entries/tree-select.js +0 -2
- package/dist/entries/tree.d.ts +0 -2
- package/dist/entries/tree.js +0 -2
- package/dist/entries/upload.d.ts +0 -2
- package/dist/entries/upload.js +0 -2
- package/dist/entries/watermark.d.ts +0 -2
- package/dist/entries/watermark.js +0 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +2 -4
- package/dist/layouts/form-layout/form-layout.d.ts +1 -0
- package/dist/layouts/form-layout/form-layout.js +10 -36
- package/dist/layouts/stack/layout.css +46 -44
- package/dist/layouts/stack/stack.d.ts +1 -0
- package/dist/layouts/stack/stack.js +16 -69
- package/dist/locales/ar-EG.js +25 -2
- package/dist/locales/create-locale.d.ts +1 -2
- package/dist/locales/create-locale.js +0 -28
- package/dist/locales/de-DE.js +25 -2
- package/dist/locales/en-US.js +24 -1
- package/dist/locales/es-ES.js +25 -2
- package/dist/locales/fr-FR.js +25 -2
- package/dist/locales/hi-IN.js +25 -2
- package/dist/locales/id-ID.js +25 -2
- package/dist/locales/index.d.ts +10 -10
- package/dist/locales/index.js +9 -9
- package/dist/locales/it-IT.js +25 -2
- package/dist/locales/ja-JP.js +25 -2
- package/dist/locales/ko-KR.js +25 -2
- package/dist/locales/pt-BR.js +25 -2
- package/dist/locales/ru-RU.js +25 -2
- package/dist/locales/th-TH.js +25 -2
- package/dist/locales/tr-TR.js +25 -2
- package/dist/locales/vi-VN.js +25 -2
- package/dist/locales/zh-CN.js +25 -2
- package/dist/locales/zh-TW.js +25 -2
- package/dist/number-input/number-input.js +24 -81
- package/dist/number-input/use-number-input.d.ts +1 -0
- package/dist/number-input/use-number-input.js +47 -43
- package/dist/provider/locale.d.ts +1 -1
- package/dist/provider/tao-context.d.ts +38 -0
- package/dist/provider/tao-context.js +92 -0
- package/dist/provider/tao-portal-scope.d.ts +14 -0
- package/dist/provider/tao-portal-scope.js +54 -0
- package/dist/provider/tao-provider.d.ts +5 -55
- package/dist/provider/tao-provider.js +94 -364
- package/dist/theme/control.css +106 -122
- package/dist/theme/theme.css +4 -2
- package/dist/utils/dialog-content.js +55 -210
- package/dist/utils/overlay.js +15 -30
- package/dist/utils/rc-compat.d.ts +13 -0
- package/dist/utils/rc-compat.js +48 -0
- package/dist/utils/refs.js +5 -19
- package/package.json +10 -16
|
@@ -1,116 +1,95 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
2
|
import { Field } from "@rc-component/form";
|
|
4
|
-
import { Fragment, cloneElement, createContext, isValidElement, useContext, useId, useState } from "react";
|
|
3
|
+
import { Fragment, cloneElement, createContext, isValidElement, useCallback, useContext, useId, useMemo, useState } from "react";
|
|
5
4
|
import { FormFieldView } from "../form-field/form-field-view.js";
|
|
6
5
|
import { FieldControl } from "./field-control.js";
|
|
7
6
|
import { useFormLayout } from "./form-context.js";
|
|
8
7
|
const NoStyleFeedbackContext = /*#__PURE__*/ createContext(null);
|
|
9
|
-
function FormItem(
|
|
10
|
-
const $ = c(29);
|
|
11
|
-
const { name, label, required, rules, help, extra, validateStatus, initialValue, valuePropName, getValueFromEvent, trigger, validateTrigger, noStyle, dependencies, shouldUpdate, normalize, preserve, messageVariables, validateFirst, htmlFor, className, style, classNames, styles, children, ...shellProps } = t0;
|
|
8
|
+
function FormItem({ name, label, required, rules, help, extra, validateStatus, initialValue, valuePropName, getValueFromEvent, trigger, validateTrigger, noStyle, dependencies, shouldUpdate, normalize, preserve, messageVariables, validateFirst, htmlFor, className, style, classNames, styles, children, ...shellProps }) {
|
|
12
9
|
const { layout, form: formInstance } = useFormLayout();
|
|
13
10
|
const parentFeedback = useContext(NoStyleFeedbackContext);
|
|
14
11
|
const feedbackId = `${useId()}-nostyle-error`;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
delete next[id];
|
|
34
|
-
return next;
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
$[1] = t2;
|
|
38
|
-
} else t2 = $[1];
|
|
39
|
-
const report = t2;
|
|
40
|
-
const t3 = null == help;
|
|
41
|
-
let t4;
|
|
42
|
-
if ($[2] !== t3) {
|
|
43
|
-
t4 = {
|
|
44
|
-
visible: t3,
|
|
12
|
+
const [nestedErrors, setNestedErrors] = useState({});
|
|
13
|
+
const report = useCallback((id, errors)=>{
|
|
14
|
+
setNestedErrors((current)=>{
|
|
15
|
+
if (!errors.length && !current[id]) return current;
|
|
16
|
+
if (errors.length) return {
|
|
17
|
+
...current,
|
|
18
|
+
[id]: errors
|
|
19
|
+
};
|
|
20
|
+
const next = {
|
|
21
|
+
...current
|
|
22
|
+
};
|
|
23
|
+
delete next[id];
|
|
24
|
+
return next;
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
const feedback = useMemo(()=>({
|
|
28
|
+
visible: null == help,
|
|
45
29
|
report
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const feedback = t4;
|
|
30
|
+
}), [
|
|
31
|
+
help,
|
|
32
|
+
report
|
|
33
|
+
]);
|
|
51
34
|
const renderShell = (content, meta, control)=>{
|
|
52
35
|
const requiredMark = required ?? rules?.some((rule)=>{
|
|
53
|
-
const entity =
|
|
36
|
+
const entity = 'function' == typeof rule ? formInstance && rule(formInstance) : rule;
|
|
54
37
|
return !!entity?.required && !entity.warningOnly;
|
|
55
38
|
}) ?? false;
|
|
56
|
-
const status = validateStatus ?? (meta?.errors.length ?
|
|
39
|
+
const status = validateStatus ?? (meta?.errors.length ? 'error' : meta?.warnings.length ? 'warning' : void 0);
|
|
57
40
|
const message = help ?? meta?.errors[0] ?? meta?.warnings[0];
|
|
58
41
|
const showAsStatus = null != message && null != status;
|
|
59
42
|
const errorSlot = showAsStatus ? message : void 0;
|
|
60
43
|
const descriptionSlot = showAsStatus ? void 0 : message;
|
|
61
44
|
let controlProps = control ?? void 0;
|
|
62
|
-
const valueProp = valuePropName ??
|
|
45
|
+
const valueProp = valuePropName ?? 'value';
|
|
63
46
|
const element = /*#__PURE__*/ isValidElement(content) && content.type !== Fragment ? content : void 0;
|
|
64
|
-
if (status && element &&
|
|
47
|
+
if (status && element && 'string' != typeof element.type && null == element.props.status && null == element.props.error) controlProps = {
|
|
65
48
|
...controlProps,
|
|
66
49
|
status
|
|
67
50
|
};
|
|
68
|
-
if (controlProps &&
|
|
51
|
+
if (controlProps && 'checked' === valuePropName && 'checked' in controlProps && (void 0 === controlProps.checked || null === controlProps.checked && element?.type === 'input')) controlProps = {
|
|
69
52
|
...controlProps,
|
|
70
53
|
checked: false
|
|
71
54
|
};
|
|
72
|
-
if (controlProps &&
|
|
73
|
-
if (element?.type ===
|
|
55
|
+
if (controlProps && 'value' === valueProp && null == controlProps.value) {
|
|
56
|
+
if (element?.type === 'select') controlProps = {
|
|
74
57
|
...controlProps,
|
|
75
|
-
value: element.props.multiple ? [] :
|
|
58
|
+
value: element.props.multiple ? [] : ''
|
|
76
59
|
};
|
|
77
|
-
else if (element?.type ===
|
|
60
|
+
else if (element?.type === 'input' || element?.type === 'textarea') controlProps = {
|
|
78
61
|
...controlProps,
|
|
79
|
-
value:
|
|
62
|
+
value: ''
|
|
80
63
|
};
|
|
81
64
|
}
|
|
82
65
|
if (controlProps && element) for (const [prop, handler] of Object.entries(controlProps)){
|
|
83
66
|
const childHandler = element.props[prop];
|
|
84
|
-
if (prop !== valueProp &&
|
|
67
|
+
if (prop !== valueProp && 'function' == typeof handler && 'function' == typeof childHandler) controlProps = {
|
|
85
68
|
...controlProps,
|
|
86
|
-
[prop]:
|
|
87
|
-
const args = t5;
|
|
69
|
+
[prop]: 'function' == typeof children ? childHandler : (...args)=>{
|
|
88
70
|
handler(...args);
|
|
89
71
|
childHandler(...args);
|
|
90
72
|
}
|
|
91
73
|
};
|
|
92
74
|
}
|
|
93
75
|
const collect = control?.onChange;
|
|
94
|
-
const valueChange = (trigger ??
|
|
76
|
+
const valueChange = (trigger ?? 'onChange') === 'onChange' && 'value' === valueProp && 'function' == typeof collect ? {
|
|
95
77
|
onChange: controlProps?.onChange,
|
|
96
78
|
collect: (value)=>collect(value)
|
|
97
79
|
} : null;
|
|
98
80
|
if (noStyle) {
|
|
99
81
|
if (!element) return content;
|
|
100
|
-
const inherited = Object.fromEntries(Object.entries(shellProps).filter((
|
|
101
|
-
|
|
102
|
-
return null == element.props[key] && !("aria-labelledby" === key && element.props["aria-label"]);
|
|
103
|
-
}));
|
|
104
|
-
const errors_0 = meta?.errors ?? [];
|
|
82
|
+
const inherited = Object.fromEntries(Object.entries(shellProps).filter(([key])=>null == element.props[key] && !('aria-labelledby' === key && element.props['aria-label'])));
|
|
83
|
+
const errors = meta?.errors ?? [];
|
|
105
84
|
const describedBy = [
|
|
106
|
-
element.props[
|
|
107
|
-
parentFeedback?.visible &&
|
|
108
|
-
].filter(Boolean).join(
|
|
85
|
+
element.props['aria-describedby'] ?? inherited['aria-describedby'],
|
|
86
|
+
parentFeedback?.visible && errors.length ? feedbackId : void 0
|
|
87
|
+
].filter(Boolean).join(' ');
|
|
109
88
|
const child = /*#__PURE__*/ cloneElement(element, {
|
|
110
89
|
...inherited,
|
|
111
90
|
...controlProps,
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
'aria-describedby': describedBy || void 0,
|
|
92
|
+
'aria-invalid': errors.length > 0 ? true : element.props['aria-invalid'] ?? inherited['aria-invalid']
|
|
114
93
|
});
|
|
115
94
|
return null != name && meta ? /*#__PURE__*/ jsx(FieldControl, {
|
|
116
95
|
name: meta.name,
|
|
@@ -128,16 +107,16 @@ function FormItem(t0) {
|
|
|
128
107
|
required: requiredMark,
|
|
129
108
|
error: errorSlot,
|
|
130
109
|
nestedErrors: null == help ? nestedErrors : void 0,
|
|
131
|
-
invalid:
|
|
132
|
-
warning:
|
|
110
|
+
invalid: 'error' === status,
|
|
111
|
+
warning: 'warning' === status,
|
|
133
112
|
description: descriptionSlot,
|
|
134
113
|
extra: extra,
|
|
135
114
|
layout: layout,
|
|
136
115
|
controlProps: controlProps,
|
|
137
|
-
renderControl: null != name && meta ? (
|
|
116
|
+
renderControl: null != name && meta ? (child)=>/*#__PURE__*/ jsx(FieldControl, {
|
|
138
117
|
name: meta.name,
|
|
139
118
|
valueChange: valueChange,
|
|
140
|
-
children:
|
|
119
|
+
children: child
|
|
141
120
|
}) : void 0,
|
|
142
121
|
className: className,
|
|
143
122
|
style: style,
|
|
@@ -148,66 +127,25 @@ function FormItem(t0) {
|
|
|
148
127
|
});
|
|
149
128
|
};
|
|
150
129
|
if (null == name && null == dependencies && null == shouldUpdate) return renderShell(children, void 0, null);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
$[10] = name;
|
|
172
|
-
$[11] = renderShell;
|
|
173
|
-
$[12] = t9;
|
|
174
|
-
} else t9 = $[12];
|
|
175
|
-
let t10;
|
|
176
|
-
if ($[13] !== dependencies || $[14] !== getValueFromEvent || $[15] !== initialValue || $[16] !== messageVariables || $[17] !== normalize || $[18] !== preserve || $[19] !== rules || $[20] !== shouldUpdate || $[21] !== t7 || $[22] !== t8 || $[23] !== t9 || $[24] !== trigger || $[25] !== validateFirst || $[26] !== validateTrigger || $[27] !== valuePropName) {
|
|
177
|
-
t10 = /*#__PURE__*/ jsx(Field, {
|
|
178
|
-
name: t7,
|
|
179
|
-
rules: rules,
|
|
180
|
-
initialValue: initialValue,
|
|
181
|
-
valuePropName: valuePropName,
|
|
182
|
-
getValueFromEvent: getValueFromEvent,
|
|
183
|
-
trigger: trigger,
|
|
184
|
-
validateTrigger: validateTrigger,
|
|
185
|
-
dependencies: dependencies,
|
|
186
|
-
shouldUpdate: shouldUpdate,
|
|
187
|
-
normalize: normalize,
|
|
188
|
-
preserve: preserve,
|
|
189
|
-
messageVariables: messageVariables,
|
|
190
|
-
validateFirst: validateFirst,
|
|
191
|
-
onMetaChange: t8,
|
|
192
|
-
children: t9
|
|
193
|
-
});
|
|
194
|
-
$[13] = dependencies;
|
|
195
|
-
$[14] = getValueFromEvent;
|
|
196
|
-
$[15] = initialValue;
|
|
197
|
-
$[16] = messageVariables;
|
|
198
|
-
$[17] = normalize;
|
|
199
|
-
$[18] = preserve;
|
|
200
|
-
$[19] = rules;
|
|
201
|
-
$[20] = shouldUpdate;
|
|
202
|
-
$[21] = t7;
|
|
203
|
-
$[22] = t8;
|
|
204
|
-
$[23] = t9;
|
|
205
|
-
$[24] = trigger;
|
|
206
|
-
$[25] = validateFirst;
|
|
207
|
-
$[26] = validateTrigger;
|
|
208
|
-
$[27] = valuePropName;
|
|
209
|
-
$[28] = t10;
|
|
210
|
-
} else t10 = $[28];
|
|
211
|
-
return t10;
|
|
130
|
+
return /*#__PURE__*/ jsx(Field, {
|
|
131
|
+
name: name ?? void 0,
|
|
132
|
+
rules: rules,
|
|
133
|
+
initialValue: initialValue,
|
|
134
|
+
valuePropName: valuePropName,
|
|
135
|
+
getValueFromEvent: getValueFromEvent,
|
|
136
|
+
trigger: trigger,
|
|
137
|
+
validateTrigger: validateTrigger,
|
|
138
|
+
dependencies: dependencies,
|
|
139
|
+
shouldUpdate: shouldUpdate,
|
|
140
|
+
normalize: normalize,
|
|
141
|
+
preserve: preserve,
|
|
142
|
+
messageVariables: messageVariables,
|
|
143
|
+
validateFirst: validateFirst,
|
|
144
|
+
onMetaChange: noStyle && parentFeedback ? ({ errors, destroy })=>parentFeedback.report(feedbackId, destroy ? [] : errors) : void 0,
|
|
145
|
+
children: (control, meta)=>{
|
|
146
|
+
const content = 'function' == typeof children ? children(control, meta, formInstance) : children;
|
|
147
|
+
return renderShell(content, meta, null != name ? control : null);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
212
150
|
}
|
|
213
151
|
export { FormItem };
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
@layer components {
|
|
2
|
+
[data-tao-form] > [data-tao-form-item] {
|
|
3
|
+
margin-block-end: var(--tao-form-field-item-gap, var(--tao-padding-md));
|
|
4
|
+
}
|
|
4
5
|
|
|
5
|
-
[data-tao-form] > [data-tao-form-item][data-tao-form-feedback] {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
[data-tao-form] > [data-tao-form-item][data-tao-form-feedback] {
|
|
7
|
+
margin-block-end: var(--tao-form-field-item-gap, var(--tao-size-unit));
|
|
8
|
+
}
|
|
8
9
|
|
|
9
|
-
[data-tao-form-message] {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
10
|
+
[data-tao-form-message] {
|
|
11
|
+
min-block-size: 1lh;
|
|
12
|
+
font-size: var(--tao-form-field-error-font-size, var(--tao-font-size-xs));
|
|
13
|
+
margin-block-start: var(--tao-padding-xxs);
|
|
14
|
+
line-height: max(18px, 1.25em);
|
|
15
|
+
}
|
|
15
16
|
|
|
16
|
-
[data-tao-form-message] > [data-tao-form-error], [data-tao-form-message] > [data-tao-form-description] {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
[data-tao-form-message] > [data-tao-form-error], [data-tao-form-message] > [data-tao-form-description] {
|
|
18
|
+
line-height: inherit;
|
|
19
|
+
margin-block: 0;
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
[data-tao-form-field][data-tao-layout="horizontal"] {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
[data-tao-form-field][data-tao-layout="horizontal"] {
|
|
23
|
+
align-items: flex-start;
|
|
24
|
+
gap: var(--tao-padding-sm);
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-label] {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
28
|
+
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-label] {
|
|
29
|
+
text-align: end;
|
|
30
|
+
flex: 0 0 160px;
|
|
31
|
+
margin-block-end: 0;
|
|
32
|
+
padding-block-start: calc((
|
|
33
|
+
var(--tao-control-height) -
|
|
34
|
+
var(--tao-form-field-label-font-size, var(--tao-font-size-sm)) *
|
|
35
|
+
var(--tao-line-height-sm)
|
|
36
|
+
) /
|
|
37
|
+
2);
|
|
38
|
+
}
|
|
38
39
|
|
|
39
|
-
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-control] {
|
|
40
|
-
|
|
40
|
+
[data-tao-form-field][data-tao-layout="horizontal"] [data-tao-form-control] {
|
|
41
|
+
flex: 1;
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { List, type FormProps as RcFormProps, useWatch } from '@rc-component/form';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import { type TaoSize } from '../../provider/tao-
|
|
3
|
+
import { type TaoSize } from '../../provider/tao-context.js';
|
|
4
4
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
5
5
|
import { FormItem, type FormItemProps } from './form-item.js';
|
|
6
6
|
import { type FormInstance, useForm } from './use-form.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
2
|
import _rc_component_form, { FormProvider, List, useWatch } from "@rc-component/form";
|
|
4
|
-
import { forwardRef, useContext } from "react";
|
|
5
3
|
import FormContext from "@rc-component/form/es/FormContext";
|
|
6
|
-
import {
|
|
4
|
+
import { forwardRef, useContext, useMemo } from "react";
|
|
7
5
|
import { mergeValidateMessages } from "../../provider/merge-locale.js";
|
|
6
|
+
import { useTaoConfig } from "../../provider/tao-context.js";
|
|
7
|
+
import { TaoProvider } from "../../provider/tao-provider.js";
|
|
8
8
|
import { cx } from "../../utils/semantic.js";
|
|
9
9
|
import { FormLayoutContext } from "./form-context.js";
|
|
10
10
|
import { FormItem } from "./form-item.js";
|
|
@@ -12,109 +12,38 @@ import { getFieldRegistry, useForm } from "./use-form.js";
|
|
|
12
12
|
import "./form.css";
|
|
13
13
|
import { interopDefault } from "../../utils/interop-default.js";
|
|
14
14
|
const RcFormComponent = /*#__PURE__*/ interopDefault(_rc_component_form);
|
|
15
|
-
function FormInner(
|
|
16
|
-
const $ = c(31);
|
|
17
|
-
const { layout: t1, size, disabled, children, className, style, classNames, styles, form, ...rcProps } = t0;
|
|
18
|
-
const layout = void 0 === t1 ? "vertical" : t1;
|
|
15
|
+
function FormInner({ layout = 'vertical', size, disabled, children, className, style, classNames, styles, form, ...rcProps }, ref) {
|
|
19
16
|
const { locale } = useTaoConfig();
|
|
20
|
-
|
|
21
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
-
t2 = interopDefault(FormContext);
|
|
23
|
-
$[0] = t2;
|
|
24
|
-
} else t2 = $[0];
|
|
25
|
-
const formContext = useContext(t2);
|
|
17
|
+
const formContext = useContext(interopDefault(FormContext));
|
|
26
18
|
const [instance] = useForm(form);
|
|
27
|
-
const
|
|
28
|
-
let t4;
|
|
29
|
-
if ($[1] !== instance) {
|
|
30
|
-
t4 = getFieldRegistry(instance);
|
|
31
|
-
$[1] = instance;
|
|
32
|
-
$[2] = t4;
|
|
33
|
-
} else t4 = $[2];
|
|
34
|
-
let t5;
|
|
35
|
-
if ($[3] !== layout || $[4] !== t3 || $[5] !== t4) {
|
|
36
|
-
t5 = {
|
|
19
|
+
const layoutValue = useMemo(()=>({
|
|
37
20
|
layout,
|
|
38
|
-
form: t3,
|
|
39
|
-
fields: t4
|
|
40
|
-
};
|
|
41
|
-
$[3] = layout;
|
|
42
|
-
$[4] = t3;
|
|
43
|
-
$[5] = t4;
|
|
44
|
-
$[6] = t5;
|
|
45
|
-
} else t5 = $[6];
|
|
46
|
-
const layoutValue = t5;
|
|
47
|
-
const t6 = FormLayoutContext;
|
|
48
|
-
const T0 = TaoProvider;
|
|
49
|
-
const T1 = RcFormComponent;
|
|
50
|
-
const t7 = "";
|
|
51
|
-
const t8 = classNames?.root;
|
|
52
|
-
let t9;
|
|
53
|
-
if ($[7] !== className || $[8] !== t8) {
|
|
54
|
-
t9 = cx(t8, className);
|
|
55
|
-
$[7] = className;
|
|
56
|
-
$[8] = t8;
|
|
57
|
-
$[9] = t9;
|
|
58
|
-
} else t9 = $[9];
|
|
59
|
-
const t10 = styles?.root;
|
|
60
|
-
let t11;
|
|
61
|
-
if ($[10] !== style || $[11] !== t10) {
|
|
62
|
-
t11 = {
|
|
63
|
-
...t10,
|
|
64
|
-
...style
|
|
65
|
-
};
|
|
66
|
-
$[10] = style;
|
|
67
|
-
$[11] = t10;
|
|
68
|
-
$[12] = t11;
|
|
69
|
-
} else t11 = $[12];
|
|
70
|
-
const t12 = mergeValidateMessages(mergeValidateMessages(locale.form, formContext.validateMessages), rcProps.validateMessages);
|
|
71
|
-
let t13;
|
|
72
|
-
if ($[13] !== T1 || $[14] !== children || $[15] !== instance || $[16] !== rcProps || $[17] !== ref || $[18] !== t11 || $[19] !== t12 || $[20] !== t9) {
|
|
73
|
-
t13 = /*#__PURE__*/ jsx(T1, {
|
|
74
|
-
"data-tao-form": t7,
|
|
75
|
-
ref: ref,
|
|
76
|
-
className: t9,
|
|
77
|
-
style: t11,
|
|
78
|
-
...rcProps,
|
|
79
|
-
validateMessages: t12,
|
|
80
21
|
form: instance,
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
$[19] = t12;
|
|
90
|
-
$[20] = t9;
|
|
91
|
-
$[21] = t13;
|
|
92
|
-
} else t13 = $[21];
|
|
93
|
-
let t14;
|
|
94
|
-
if ($[22] !== T0 || $[23] !== disabled || $[24] !== size || $[25] !== t13) {
|
|
95
|
-
t14 = /*#__PURE__*/ jsx(T0, {
|
|
22
|
+
fields: getFieldRegistry(instance)
|
|
23
|
+
}), [
|
|
24
|
+
layout,
|
|
25
|
+
instance
|
|
26
|
+
]);
|
|
27
|
+
return /*#__PURE__*/ jsx(FormLayoutContext.Provider, {
|
|
28
|
+
value: layoutValue,
|
|
29
|
+
children: /*#__PURE__*/ jsx(TaoProvider, {
|
|
96
30
|
size: size,
|
|
97
31
|
disabled: disabled,
|
|
98
|
-
children:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
$[28] = t14;
|
|
114
|
-
$[29] = t6.Provider;
|
|
115
|
-
$[30] = t15;
|
|
116
|
-
} else t15 = $[30];
|
|
117
|
-
return t15;
|
|
32
|
+
children: /*#__PURE__*/ jsx(RcFormComponent, {
|
|
33
|
+
"data-tao-form": "",
|
|
34
|
+
ref: ref,
|
|
35
|
+
className: cx(classNames?.root, className),
|
|
36
|
+
style: {
|
|
37
|
+
...styles?.root,
|
|
38
|
+
...style
|
|
39
|
+
},
|
|
40
|
+
...rcProps,
|
|
41
|
+
validateMessages: mergeValidateMessages(mergeValidateMessages(locale.form, formContext.validateMessages), rcProps.validateMessages),
|
|
42
|
+
form: instance,
|
|
43
|
+
children: children
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
});
|
|
118
47
|
}
|
|
119
48
|
const ForwardedForm = /*#__PURE__*/ forwardRef(FormInner);
|
|
120
49
|
function useFormInstance() {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Form, type FormProps, type FormSemanticPart } from './form.js';
|
|
2
|
-
export type { FormInstance, FormScrollOptions } from './use-form.js';
|
|
3
2
|
export type { FormItemChildren, FormItemProps, FormItemSemanticPart, FormItemValidateStatus, } from './form-item.js';
|
|
3
|
+
export type { FormInstance, FormScrollOptions } from './use-form.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { c } from "react-compiler-runtime";
|
|
2
1
|
import { useForm } from "@rc-component/form";
|
|
3
|
-
import {
|
|
4
|
-
import { getDOM } from "@rc-component/util/es/Dom/findDOMNode";
|
|
2
|
+
import { useMemo } from "react";
|
|
5
3
|
import scroll_into_view_if_needed from "scroll-into-view-if-needed";
|
|
4
|
+
import { getDOM, isEqual } from "../../utils/rc-compat.js";
|
|
6
5
|
const use_form_scroll = scroll_into_view_if_needed;
|
|
7
6
|
const VALIDATION_STATE_KEYS = [
|
|
8
7
|
'errors',
|
|
@@ -20,71 +19,54 @@ function fieldKey(name) {
|
|
|
20
19
|
]);
|
|
21
20
|
}
|
|
22
21
|
function use_form_useForm(form) {
|
|
23
|
-
const $ = c(4);
|
|
24
22
|
const [rcForm] = useForm(form);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
23
|
+
const wrapped = useMemo(()=>{
|
|
24
|
+
if (form) return form;
|
|
25
|
+
const fields = new Map();
|
|
26
|
+
const instance = {
|
|
27
|
+
...rcForm,
|
|
28
|
+
setFields (nextFields) {
|
|
29
|
+
const stale = nextFields.filter((field)=>'value' in field && VALIDATION_STATE_KEYS.every((key)=>!(key in field)) && !isEqual(field.value, rcForm.getFieldValue(field.name)));
|
|
30
|
+
rcForm.setFields(stale.length ? [
|
|
31
|
+
...stale.map((field)=>({
|
|
32
|
+
name: field.name,
|
|
33
|
+
errors: [],
|
|
34
|
+
warnings: []
|
|
35
|
+
})),
|
|
36
|
+
...nextFields
|
|
37
|
+
] : nextFields);
|
|
38
|
+
},
|
|
39
|
+
scrollToField (name, options = {}) {
|
|
40
|
+
const targets = fields.get(fieldKey(name));
|
|
41
|
+
const target = targets && Array.from(targets).at(-1);
|
|
42
|
+
if (!target) return;
|
|
43
|
+
const node = getDOM(target.instance) ?? document.getElementById(target.id);
|
|
44
|
+
if (!node) return;
|
|
45
|
+
const { focus, ...scrollOptions } = options;
|
|
46
|
+
use_form_scroll(node, {
|
|
47
|
+
scrollMode: 'if-needed',
|
|
48
|
+
block: 'nearest',
|
|
49
|
+
...scrollOptions
|
|
50
|
+
});
|
|
51
|
+
if (focus) {
|
|
52
|
+
const control = target.instance;
|
|
53
|
+
if ('function' == typeof control?.focus) control.focus({
|
|
54
|
+
preventScroll: true
|
|
55
|
+
});
|
|
56
|
+
else node.focus({
|
|
57
|
+
preventScroll: true
|
|
55
58
|
});
|
|
56
|
-
if (focus) {
|
|
57
|
-
const control = target.instance;
|
|
58
|
-
if ("function" == typeof control?.focus) control.focus({
|
|
59
|
-
preventScroll: true
|
|
60
|
-
});
|
|
61
|
-
else node.focus({
|
|
62
|
-
preventScroll: true
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
59
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
wrapped
|
|
78
|
-
];
|
|
79
|
-
$[2] = wrapped;
|
|
80
|
-
$[3] = t1;
|
|
81
|
-
} else t1 = $[3];
|
|
82
|
-
return t1;
|
|
83
|
-
}
|
|
84
|
-
function _temp(field_0) {
|
|
85
|
-
return {
|
|
86
|
-
name: field_0.name,
|
|
87
|
-
errors: []
|
|
88
|
-
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
fieldRegistries.set(instance, fields);
|
|
63
|
+
return instance;
|
|
64
|
+
}, [
|
|
65
|
+
form,
|
|
66
|
+
rcForm
|
|
67
|
+
]);
|
|
68
|
+
return [
|
|
69
|
+
wrapped
|
|
70
|
+
];
|
|
89
71
|
}
|
|
90
72
|
export { fieldKey, getFieldRegistry, use_form_useForm as useForm };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
3
|
+
import '../../theme/theme.css';
|
|
3
4
|
import '../form-field/form.css';
|
|
4
5
|
export type FormActionsSemanticPart = 'root';
|
|
5
6
|
export interface FormActionsProps {
|