@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
package/dist/locales/zh-CN.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
import zh_CN from "@rc-component/picker/locale/zh_CN";
|
|
2
1
|
import "dayjs/locale/zh-cn";
|
|
2
|
+
import zh_CN from "@rc-component/picker/locale/zh_CN";
|
|
3
3
|
import { createFormMessages, createItemCount, createLocale } from "./create-locale.js";
|
|
4
|
-
const zhCN = createLocale({
|
|
4
|
+
const zhCN = /*#__PURE__*/ createLocale({
|
|
5
5
|
locale: 'zh_CN',
|
|
6
6
|
numberLocale: 'zh-CN',
|
|
7
7
|
dayjsLocale: 'zh-cn',
|
|
8
8
|
weekStartsOn: 1,
|
|
9
|
+
weekdays: [
|
|
10
|
+
'一',
|
|
11
|
+
'二',
|
|
12
|
+
'三',
|
|
13
|
+
'四',
|
|
14
|
+
'五',
|
|
15
|
+
'六',
|
|
16
|
+
'日'
|
|
17
|
+
],
|
|
18
|
+
months: [
|
|
19
|
+
'1月',
|
|
20
|
+
'2月',
|
|
21
|
+
'3月',
|
|
22
|
+
'4月',
|
|
23
|
+
'5月',
|
|
24
|
+
'6月',
|
|
25
|
+
'7月',
|
|
26
|
+
'8月',
|
|
27
|
+
'9月',
|
|
28
|
+
'10月',
|
|
29
|
+
'11月',
|
|
30
|
+
'12月'
|
|
31
|
+
],
|
|
9
32
|
pickerLocale: zh_CN,
|
|
10
33
|
select: '选择',
|
|
11
34
|
searchPlaceholder: '搜索…',
|
package/dist/locales/zh-TW.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
import zh_TW from "@rc-component/picker/locale/zh_TW";
|
|
2
1
|
import "dayjs/locale/zh-tw";
|
|
2
|
+
import zh_TW from "@rc-component/picker/locale/zh_TW";
|
|
3
3
|
import { createFormMessages, createItemCount, createLocale } from "./create-locale.js";
|
|
4
|
-
const zhTW = createLocale({
|
|
4
|
+
const zhTW = /*#__PURE__*/ createLocale({
|
|
5
5
|
locale: 'zh_TW',
|
|
6
6
|
numberLocale: 'zh-TW',
|
|
7
7
|
dayjsLocale: 'zh-tw',
|
|
8
8
|
weekStartsOn: 0,
|
|
9
|
+
weekdays: [
|
|
10
|
+
'一',
|
|
11
|
+
'二',
|
|
12
|
+
'三',
|
|
13
|
+
'四',
|
|
14
|
+
'五',
|
|
15
|
+
'六',
|
|
16
|
+
'日'
|
|
17
|
+
],
|
|
18
|
+
months: [
|
|
19
|
+
'1月',
|
|
20
|
+
'2月',
|
|
21
|
+
'3月',
|
|
22
|
+
'4月',
|
|
23
|
+
'5月',
|
|
24
|
+
'6月',
|
|
25
|
+
'7月',
|
|
26
|
+
'8月',
|
|
27
|
+
'9月',
|
|
28
|
+
'10月',
|
|
29
|
+
'11月',
|
|
30
|
+
'12月'
|
|
31
|
+
],
|
|
9
32
|
pickerLocale: zh_TW,
|
|
10
33
|
select: '選擇',
|
|
11
34
|
searchPlaceholder: '搜尋…',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
2
|
import { useNumberInput } from "./use-number-input.js";
|
|
4
3
|
const HOOK_KEYS = [
|
|
5
4
|
'locale',
|
|
@@ -17,87 +16,31 @@ const HOOK_KEYS = [
|
|
|
17
16
|
'max'
|
|
18
17
|
];
|
|
19
18
|
function HeadlessInputNumber(props) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let prefix;
|
|
26
|
-
let suffix;
|
|
27
|
-
if ($[0] !== props) {
|
|
28
|
-
const { prefix: t0, suffix: t1, containerClassName: t2, className: t3, ...rest } = props;
|
|
29
|
-
prefix = t0;
|
|
30
|
-
suffix = t1;
|
|
31
|
-
containerClassName = t2;
|
|
32
|
-
className = t3;
|
|
33
|
-
hookOpts = {};
|
|
34
|
-
nativeAttrs = {};
|
|
35
|
-
for (const [key, val] of Object.entries(rest))if (HOOK_KEYS.includes(key)) hookOpts[key] = val;
|
|
36
|
-
else nativeAttrs[key] = val;
|
|
37
|
-
$[0] = props;
|
|
38
|
-
$[1] = className;
|
|
39
|
-
$[2] = containerClassName;
|
|
40
|
-
$[3] = hookOpts;
|
|
41
|
-
$[4] = nativeAttrs;
|
|
42
|
-
$[5] = prefix;
|
|
43
|
-
$[6] = suffix;
|
|
44
|
-
} else {
|
|
45
|
-
className = $[1];
|
|
46
|
-
containerClassName = $[2];
|
|
47
|
-
hookOpts = $[3];
|
|
48
|
-
nativeAttrs = $[4];
|
|
49
|
-
prefix = $[5];
|
|
50
|
-
suffix = $[6];
|
|
51
|
-
}
|
|
19
|
+
const { prefix, suffix, containerClassName, className, ...rest } = props;
|
|
20
|
+
const hookOpts = {};
|
|
21
|
+
const nativeAttrs = {};
|
|
22
|
+
for (const [key, val] of Object.entries(rest))if (HOOK_KEYS.includes(key)) hookOpts[key] = val;
|
|
23
|
+
else nativeAttrs[key] = val;
|
|
52
24
|
const { inputProps } = useNumberInput(hookOpts);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
$[12] = t1;
|
|
73
|
-
} else t1 = $[12];
|
|
74
|
-
let t2;
|
|
75
|
-
if ($[13] !== suffix) {
|
|
76
|
-
t2 = void 0 !== suffix && /*#__PURE__*/ jsx("span", {
|
|
77
|
-
"data-tao-suffix": "",
|
|
78
|
-
children: suffix
|
|
79
|
-
});
|
|
80
|
-
$[13] = suffix;
|
|
81
|
-
$[14] = t2;
|
|
82
|
-
} else t2 = $[14];
|
|
83
|
-
let t3;
|
|
84
|
-
if ($[15] !== containerClassName || $[16] !== t0 || $[17] !== t1 || $[18] !== t2) {
|
|
85
|
-
t3 = /*#__PURE__*/ jsxs("span", {
|
|
86
|
-
className: containerClassName,
|
|
87
|
-
"data-tao-number-input": "",
|
|
88
|
-
children: [
|
|
89
|
-
t0,
|
|
90
|
-
t1,
|
|
91
|
-
t2
|
|
92
|
-
]
|
|
93
|
-
});
|
|
94
|
-
$[15] = containerClassName;
|
|
95
|
-
$[16] = t0;
|
|
96
|
-
$[17] = t1;
|
|
97
|
-
$[18] = t2;
|
|
98
|
-
$[19] = t3;
|
|
99
|
-
} else t3 = $[19];
|
|
100
|
-
return t3;
|
|
25
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
26
|
+
className: containerClassName,
|
|
27
|
+
"data-tao-number-input": "",
|
|
28
|
+
children: [
|
|
29
|
+
void 0 !== prefix && /*#__PURE__*/ jsx("span", {
|
|
30
|
+
"data-tao-prefix": "",
|
|
31
|
+
children: prefix
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ jsx("input", {
|
|
34
|
+
...nativeAttrs,
|
|
35
|
+
...inputProps,
|
|
36
|
+
className: className
|
|
37
|
+
}),
|
|
38
|
+
void 0 !== suffix && /*#__PURE__*/ jsx("span", {
|
|
39
|
+
"data-tao-suffix": "",
|
|
40
|
+
children: suffix
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
101
44
|
}
|
|
102
45
|
const NumberInput = HeadlessInputNumber;
|
|
103
46
|
export { HeadlessInputNumber, NumberInput };
|
|
@@ -6,9 +6,10 @@ import { resolveNumberFormat } from "./locale.js";
|
|
|
6
6
|
import { fromPercent, toPercent } from "./percentage.js";
|
|
7
7
|
import { clampToRange, isValidCanonical, stripDisallowedSign, toCanonical } from "./validate.js";
|
|
8
8
|
function useNumberInput(opts) {
|
|
9
|
-
const { value: externalValue, defaultValue, onChange, onBlur, locale: localeProp, decimalSeparator, thousandsSeparator: thousandsSeparatorProp, decimalPlaces = 2, padDecimalsOnBlur: padMode = 'never', isPercentage = false, allowNegative = false, min, max } = opts;
|
|
9
|
+
const { value: externalValue, defaultValue, onChange, onBlur, locale: localeProp, decimalSeparator, thousandsSeparator: thousandsSeparatorProp, decimalPlaces = 2, padDecimalsOnBlur: padMode = 'never', isPercentage = false, allowNegative = false, min, max, disabled: disabledProp } = opts;
|
|
10
10
|
const value = 'number' == typeof externalValue ? toCanonical(externalValue) : externalValue;
|
|
11
11
|
const config = useTaoConfig();
|
|
12
|
+
const disabled = disabledProp ?? config.disabled;
|
|
12
13
|
const locale = localeProp ?? config.locale.numberLocale;
|
|
13
14
|
const fmtOpts = useMemo(()=>resolveNumberFormat(locale, {
|
|
14
15
|
decimalSeparator,
|
|
@@ -42,23 +43,23 @@ function useNumberInput(opts) {
|
|
|
42
43
|
if (buffer.format === fmtOpts && buffer.isPercentage === isPercentage) return;
|
|
43
44
|
const previousCanonical = parse(buffer.display, buffer.format);
|
|
44
45
|
const useExternalValue = isValueControlled && !isFocusedRef.current;
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
if (!useExternalValue && previousCanonical.endsWith('.') && !
|
|
48
|
-
const
|
|
46
|
+
const actual = useExternalValue ? value ?? '' : buffer.isPercentage ? fromPercent(previousCanonical) : previousCanonical;
|
|
47
|
+
let canonical = isPercentage ? toPercent(actual) : actual;
|
|
48
|
+
if (!useExternalValue && previousCanonical.endsWith('.') && !canonical.includes('.')) canonical += '.';
|
|
49
|
+
const display = format(canonical, fmtOpts);
|
|
49
50
|
const input = inputRef.current;
|
|
50
|
-
if (isFocusedRef.current && input &&
|
|
51
|
+
if (isFocusedRef.current && input && display !== buffer.display) {
|
|
51
52
|
const beforeCount = countAnchored(buffer.display, buffer.display.length, buffer.format.thousandsSeparator);
|
|
52
|
-
const afterCount = countAnchored(
|
|
53
|
-
const mapCursor = (position)=>findCursorAt(
|
|
53
|
+
const afterCount = countAnchored(display, display.length, thousandsSeparator);
|
|
54
|
+
const mapCursor = (position)=>findCursorAt(display, afterCount - beforeCount + countAnchored(buffer.display, position, buffer.format.thousandsSeparator), thousandsSeparator);
|
|
54
55
|
pendingCursorRef.current = {
|
|
55
|
-
display
|
|
56
|
+
display,
|
|
56
57
|
start: mapCursor(input.selectionStart ?? buffer.display.length),
|
|
57
58
|
end: mapCursor(input.selectionEnd ?? buffer.display.length)
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
setBuffer({
|
|
61
|
-
display
|
|
62
|
+
display,
|
|
62
63
|
format: fmtOpts,
|
|
63
64
|
isPercentage
|
|
64
65
|
});
|
|
@@ -73,8 +74,8 @@ function useNumberInput(opts) {
|
|
|
73
74
|
useEffect(()=>{
|
|
74
75
|
if (!isValueControlled) return;
|
|
75
76
|
if (isFocusedRef.current) return;
|
|
76
|
-
const
|
|
77
|
-
if (displayBuffer !==
|
|
77
|
+
const display = canonicalToDisplay(value ?? '');
|
|
78
|
+
if (displayBuffer !== display) setDisplayBuffer(display);
|
|
78
79
|
}, [
|
|
79
80
|
value,
|
|
80
81
|
isValueControlled
|
|
@@ -111,13 +112,14 @@ function useNumberInput(opts) {
|
|
|
111
112
|
displayBuffer
|
|
112
113
|
]);
|
|
113
114
|
const handleChange = (e)=>{
|
|
115
|
+
if (disabled) return;
|
|
114
116
|
const raw = e.target.value;
|
|
115
117
|
const cursor = e.target.selectionStart ?? raw.length;
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!isValidCanonical(
|
|
120
|
-
const newDisplay = format(
|
|
118
|
+
let canonical = parse(raw, fmtOpts);
|
|
119
|
+
canonical = stripDisallowedSign(canonical, allowNegative);
|
|
120
|
+
canonical = truncateDecimals(canonical, decimalPlaces);
|
|
121
|
+
if (!isValidCanonical(canonical)) return;
|
|
122
|
+
const newDisplay = format(canonical, fmtOpts);
|
|
121
123
|
const cursorPosition = reposition({
|
|
122
124
|
before: raw,
|
|
123
125
|
beforeCursor: cursor,
|
|
@@ -130,51 +132,53 @@ function useNumberInput(opts) {
|
|
|
130
132
|
end: cursorPosition
|
|
131
133
|
};
|
|
132
134
|
setDisplayBuffer(newDisplay);
|
|
133
|
-
const
|
|
134
|
-
onChange?.(
|
|
135
|
+
const actual = isPercentage ? fromPercent(canonical) : canonical;
|
|
136
|
+
onChange?.(actual);
|
|
135
137
|
};
|
|
136
138
|
const commit = ()=>{
|
|
137
|
-
const
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
const beforeClamp = isPercentage ? fromPercent(
|
|
139
|
+
const raw = isValueControlled ? canonicalToDisplay(value ?? '') : inputRef.current?.value ?? displayBuffer;
|
|
140
|
+
let canonical = truncateDecimals(parse(raw, fmtOpts), decimalPlaces);
|
|
141
|
+
canonical = padOnBlur(canonical, decimalPlaces, padMode);
|
|
142
|
+
const beforeClamp = isPercentage ? fromPercent(canonical) : canonical;
|
|
141
143
|
const bounded = clampToRange(beforeClamp, min, max);
|
|
142
|
-
const
|
|
143
|
-
const canonicalAfter = isPercentage ? toPercent(
|
|
144
|
-
const
|
|
145
|
-
setDisplayBuffer(
|
|
146
|
-
return
|
|
144
|
+
const actual = !isPercentage && decimalPlaces > 0 && bounded !== beforeClamp ? padOnBlur(bounded, decimalPlaces, padMode) : bounded;
|
|
145
|
+
const canonicalAfter = isPercentage ? toPercent(actual) : actual;
|
|
146
|
+
const newDisplay = format(canonicalAfter, fmtOpts);
|
|
147
|
+
setDisplayBuffer(newDisplay);
|
|
148
|
+
return actual;
|
|
147
149
|
};
|
|
148
150
|
const handleBlur = ()=>{
|
|
149
151
|
isFocusedRef.current = false;
|
|
152
|
+
if (disabled) return;
|
|
150
153
|
const previous = isValueControlled ? value ?? '' : derivedActual;
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
onBlur?.(
|
|
154
|
+
const actual = commit();
|
|
155
|
+
if (actual !== previous) onChange?.(actual);
|
|
156
|
+
onBlur?.(actual);
|
|
154
157
|
};
|
|
155
158
|
const handleFocus = ()=>{
|
|
159
|
+
if (disabled) return;
|
|
156
160
|
isFocusedRef.current = true;
|
|
157
161
|
};
|
|
158
|
-
const handleKeyDown = (
|
|
159
|
-
if (
|
|
160
|
-
if ('Enter' ===
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
162
|
+
const handleKeyDown = (e)=>{
|
|
163
|
+
if (disabled || e.nativeEvent.isComposing || 229 === e.keyCode) return;
|
|
164
|
+
if ('Enter' === e.key) {
|
|
165
|
+
const previous = isValueControlled ? value ?? '' : derivedActual;
|
|
166
|
+
const actual = commit();
|
|
167
|
+
if (actual !== previous) onChange?.(actual);
|
|
164
168
|
return;
|
|
165
169
|
}
|
|
166
|
-
if ('Backspace' !==
|
|
170
|
+
if ('Backspace' !== e.key) return;
|
|
167
171
|
const el = inputRef.current;
|
|
168
172
|
if (!el) return;
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
const beforeSeparator =
|
|
173
|
+
const cursor = el.selectionStart ?? 0;
|
|
174
|
+
if (cursor > 0 && el.selectionEnd === cursor && isThousandSepBeforeCursor(displayBuffer, cursor, thousandsSeparator)) {
|
|
175
|
+
const beforeSeparator = cursor - thousandsSeparator.length;
|
|
172
176
|
el.setSelectionRange(beforeSeparator, beforeSeparator);
|
|
173
177
|
}
|
|
174
178
|
};
|
|
175
179
|
const derivedActual = useMemo(()=>{
|
|
176
|
-
const
|
|
177
|
-
return buffer.isPercentage ? fromPercent(
|
|
180
|
+
const canonical = parse(buffer.display, buffer.format);
|
|
181
|
+
return buffer.isPercentage ? fromPercent(canonical) : canonical;
|
|
178
182
|
}, [
|
|
179
183
|
buffer
|
|
180
184
|
]);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TaoLocale } from '../locales/types.js';
|
|
2
|
+
import '../theme/theme.css';
|
|
3
|
+
import type { ResolvedTaoLocale } from './merge-locale.js';
|
|
4
|
+
export type TaoThemeMode = 'light' | 'dark';
|
|
5
|
+
export type TaoSize = 'small' | 'medium' | 'large';
|
|
6
|
+
export type TaoVariant = 'outlined' | 'filled' | 'borderless';
|
|
7
|
+
export type TaoStatus = 'error' | 'warning';
|
|
8
|
+
export type TaoDirection = 'ltr' | 'rtl';
|
|
9
|
+
export interface TaoConfig {
|
|
10
|
+
direction?: TaoDirection;
|
|
11
|
+
locale: TaoLocale;
|
|
12
|
+
size: TaoSize;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
variant: TaoVariant;
|
|
15
|
+
/** Resolved 明暗模式,portal 浮层用它重建 data-tao-theme。 */
|
|
16
|
+
mode: TaoThemeMode;
|
|
17
|
+
/** Resolved 紧凑密度,portal 浮层用它重建 data-tao-density。 */
|
|
18
|
+
compact: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface TaoConfigContextValue extends TaoConfig {
|
|
21
|
+
locale: ResolvedTaoLocale;
|
|
22
|
+
/**
|
|
23
|
+
* Merged CSS custom-property overrides from this provider and all ancestors.
|
|
24
|
+
* Carried through context so portaled layers (Modal/Drawer/Select dropdown…)
|
|
25
|
+
* — which render outside the provider's DOM subtree — can re-apply the theme.
|
|
26
|
+
*/
|
|
27
|
+
tokenStyle: Record<string, string>;
|
|
28
|
+
/** Caller-provided tokens, excluding generated defaults used to isolate a scope. */
|
|
29
|
+
tokenOverrides: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export declare const TaoConfigContext: import("react").Context<TaoConfigContextValue>;
|
|
32
|
+
export declare function useTaoConfig(): TaoConfig & {
|
|
33
|
+
locale: ResolvedTaoLocale;
|
|
34
|
+
};
|
|
35
|
+
/** Internal component access for token propagation through third-party portals. */
|
|
36
|
+
export declare function useTaoInternalConfig(): TaoConfigContextValue;
|
|
37
|
+
/** Resolve DOM inheritance at a component's source, before it creates portals. */
|
|
38
|
+
export declare function useTaoDirection(explicit?: TaoDirection | 'auto', source?: 'parent' | 'self'): readonly [TaoDirection, import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createContext, useContext, useLayoutEffect, useMemo, useState } from "react";
|
|
2
|
+
import { enUS } from "../locales/en-US.js";
|
|
3
|
+
import "../theme/theme.css";
|
|
4
|
+
import { getComposedParent } from "../utils/composed-parent.js";
|
|
5
|
+
const TaoConfigContext = createContext({
|
|
6
|
+
size: 'medium',
|
|
7
|
+
disabled: false,
|
|
8
|
+
variant: 'outlined',
|
|
9
|
+
mode: 'light',
|
|
10
|
+
compact: false,
|
|
11
|
+
tokenStyle: {},
|
|
12
|
+
tokenOverrides: {},
|
|
13
|
+
locale: enUS
|
|
14
|
+
});
|
|
15
|
+
function useTaoConfig() {
|
|
16
|
+
const { size, disabled, variant, mode, compact, locale, direction } = useContext(TaoConfigContext);
|
|
17
|
+
return useMemo(()=>({
|
|
18
|
+
size,
|
|
19
|
+
disabled,
|
|
20
|
+
variant,
|
|
21
|
+
mode,
|
|
22
|
+
compact,
|
|
23
|
+
locale,
|
|
24
|
+
direction
|
|
25
|
+
}), [
|
|
26
|
+
size,
|
|
27
|
+
disabled,
|
|
28
|
+
variant,
|
|
29
|
+
mode,
|
|
30
|
+
compact,
|
|
31
|
+
locale,
|
|
32
|
+
direction
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
function useTaoInternalConfig() {
|
|
36
|
+
return useContext(TaoConfigContext);
|
|
37
|
+
}
|
|
38
|
+
function useTaoDirection(explicit, source = 'parent') {
|
|
39
|
+
const { direction: contextDirection } = useContext(TaoConfigContext);
|
|
40
|
+
const [element, setElement] = useState(null);
|
|
41
|
+
const [inherited, setInherited] = useState();
|
|
42
|
+
useLayoutEffect(()=>{
|
|
43
|
+
if (explicit && 'auto' !== explicit || !element) return;
|
|
44
|
+
const target = 'self' === source || 'auto' === explicit ? element : getComposedParent(element);
|
|
45
|
+
if (!target) return;
|
|
46
|
+
const update = ()=>{
|
|
47
|
+
let resolved;
|
|
48
|
+
for(let ancestor = target; ancestor; ancestor = getComposedParent(ancestor)){
|
|
49
|
+
const inlineDir = ancestor.style?.direction;
|
|
50
|
+
if ('rtl' === inlineDir || 'ltr' === inlineDir) {
|
|
51
|
+
resolved = inlineDir;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
const attrDir = ancestor.getAttribute('dir');
|
|
55
|
+
if ('rtl' === attrDir || 'ltr' === attrDir) {
|
|
56
|
+
resolved = attrDir;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const computed = getComputedStyle(target).direction;
|
|
61
|
+
const value = resolved ?? ('rtl' === computed ? 'rtl' : contextDirection ?? 'ltr');
|
|
62
|
+
setInherited('rtl' === value ? 'rtl' : 'ltr');
|
|
63
|
+
for(let ancestor = target; ancestor; ancestor = getComposedParent(ancestor)){
|
|
64
|
+
const auto = 'auto' === ancestor.getAttribute('dir');
|
|
65
|
+
observer.observe(ancestor, {
|
|
66
|
+
attributes: true,
|
|
67
|
+
attributeFilter: [
|
|
68
|
+
'dir',
|
|
69
|
+
'style',
|
|
70
|
+
'class'
|
|
71
|
+
],
|
|
72
|
+
childList: auto,
|
|
73
|
+
characterData: auto,
|
|
74
|
+
subtree: auto
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const observer = new MutationObserver(update);
|
|
79
|
+
update();
|
|
80
|
+
return ()=>observer.disconnect();
|
|
81
|
+
}, [
|
|
82
|
+
element,
|
|
83
|
+
explicit,
|
|
84
|
+
contextDirection,
|
|
85
|
+
source
|
|
86
|
+
]);
|
|
87
|
+
return [
|
|
88
|
+
('auto' === explicit ? void 0 : explicit) ?? inherited ?? contextDirection ?? 'ltr',
|
|
89
|
+
setElement
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
export { TaoConfigContext, useTaoConfig, useTaoDirection, useTaoInternalConfig };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type TaoDirection } from './tao-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Re-establishes the theme token scope inside a portal. Floating components
|
|
5
|
+
* portal their popup to document.body, escaping the `[data-tao-provider]`
|
|
6
|
+
* element that carries custom token overrides; wrapping the portal content in
|
|
7
|
+
* this component re-applies those overrides so colors/sizes stay consistent.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TaoPortalScope: import("react").ForwardRefExoticComponent<{
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
direction?: TaoDirection;
|
|
14
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { forwardRef, useMemo } from "react";
|
|
4
|
+
import { TaoConfigContext, useTaoInternalConfig } from "./tao-context.js";
|
|
5
|
+
const tao_portal_scope_TaoPortalScope = /*#__PURE__*/ forwardRef(function({ children, style, asChild, direction: directionProp }, ref) {
|
|
6
|
+
const config = useTaoInternalConfig();
|
|
7
|
+
const { tokenStyle, mode, compact } = config;
|
|
8
|
+
const direction = directionProp ?? config.direction;
|
|
9
|
+
const portalConfig = useMemo(()=>({
|
|
10
|
+
...config,
|
|
11
|
+
direction
|
|
12
|
+
}), [
|
|
13
|
+
config,
|
|
14
|
+
direction
|
|
15
|
+
]);
|
|
16
|
+
const themeAttr = 'light' === mode ? void 0 : {
|
|
17
|
+
'data-tao-theme': mode
|
|
18
|
+
};
|
|
19
|
+
const densityAttr = compact ? {
|
|
20
|
+
'data-tao-density': 'compact'
|
|
21
|
+
} : void 0;
|
|
22
|
+
if (asChild) return /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
|
|
23
|
+
value: portalConfig,
|
|
24
|
+
children: /*#__PURE__*/ jsx(Slot, {
|
|
25
|
+
ref: ref,
|
|
26
|
+
dir: direction,
|
|
27
|
+
"data-tao-provider": "",
|
|
28
|
+
...themeAttr,
|
|
29
|
+
...densityAttr,
|
|
30
|
+
style: {
|
|
31
|
+
...tokenStyle,
|
|
32
|
+
...style
|
|
33
|
+
},
|
|
34
|
+
children: children
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
return /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
|
|
38
|
+
value: portalConfig,
|
|
39
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
40
|
+
ref: ref,
|
|
41
|
+
dir: direction,
|
|
42
|
+
"data-tao-provider": "",
|
|
43
|
+
...themeAttr,
|
|
44
|
+
...densityAttr,
|
|
45
|
+
style: {
|
|
46
|
+
display: 'contents',
|
|
47
|
+
...tokenStyle,
|
|
48
|
+
...style
|
|
49
|
+
},
|
|
50
|
+
children: children
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
export { tao_portal_scope_TaoPortalScope as TaoPortalScope };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import '../theme/theme.css';
|
|
2
3
|
import { type TaoTokenName } from '../theme/tokens.js';
|
|
3
|
-
import {
|
|
4
|
-
import { type
|
|
4
|
+
import type { TaoLocale } from './locale.js';
|
|
5
|
+
import { type TaoDirection, type TaoSize, type TaoThemeMode, type TaoVariant } from './tao-context.js';
|
|
5
6
|
export { enUS, type TaoLocale, zhCN } from './locale.js';
|
|
7
|
+
export { type TaoConfig, type TaoDirection, type TaoSize, type TaoStatus, type TaoThemeMode, type TaoVariant, useTaoConfig, useTaoDirection, useTaoInternalConfig, } from './tao-context.js';
|
|
8
|
+
export { TaoPortalScope } from './tao-portal-scope.js';
|
|
6
9
|
export interface TaoSeedToken {
|
|
7
10
|
colorPrimary?: string;
|
|
8
11
|
colorSuccess?: string;
|
|
@@ -23,7 +26,6 @@ export interface TaoSeedToken {
|
|
|
23
26
|
zIndexBase?: number;
|
|
24
27
|
zIndexPopupBase?: number;
|
|
25
28
|
}
|
|
26
|
-
export type TaoThemeMode = 'light' | 'dark';
|
|
27
29
|
export interface ButtonComponentToken {
|
|
28
30
|
fontWeight?: CSSProperties['fontWeight'];
|
|
29
31
|
borderRadius?: number;
|
|
@@ -92,39 +94,6 @@ export interface TaoThemeConfig {
|
|
|
92
94
|
components?: TaoComponentTokenMap;
|
|
93
95
|
inherit?: boolean;
|
|
94
96
|
}
|
|
95
|
-
export type TaoSize = 'small' | 'medium' | 'large';
|
|
96
|
-
export type TaoVariant = 'outlined' | 'filled' | 'borderless';
|
|
97
|
-
export type TaoStatus = 'error' | 'warning';
|
|
98
|
-
export type TaoDirection = 'ltr' | 'rtl';
|
|
99
|
-
export interface TaoConfig {
|
|
100
|
-
direction?: TaoDirection;
|
|
101
|
-
locale: TaoLocale;
|
|
102
|
-
size: TaoSize;
|
|
103
|
-
disabled: boolean;
|
|
104
|
-
variant: TaoVariant;
|
|
105
|
-
/** Resolved 明暗模式,portal 浮层用它重建 data-tao-theme。 */
|
|
106
|
-
mode: TaoThemeMode;
|
|
107
|
-
/** Resolved 紧凑密度,portal 浮层用它重建 data-tao-density。 */
|
|
108
|
-
compact: boolean;
|
|
109
|
-
}
|
|
110
|
-
interface TaoConfigContextValue extends TaoConfig {
|
|
111
|
-
locale: ResolvedTaoLocale;
|
|
112
|
-
/**
|
|
113
|
-
* Merged CSS custom-property overrides from this provider and all ancestors.
|
|
114
|
-
* Carried through context so portaled layers (Modal/Drawer/Select dropdown…)
|
|
115
|
-
* — which render outside the provider's DOM subtree — can re-apply the theme.
|
|
116
|
-
*/
|
|
117
|
-
tokenStyle: Record<string, string>;
|
|
118
|
-
/** Caller-provided tokens, excluding generated defaults used to isolate a scope. */
|
|
119
|
-
tokenOverrides: Record<string, string>;
|
|
120
|
-
}
|
|
121
|
-
export declare function useTaoConfig(): TaoConfig & {
|
|
122
|
-
locale: ResolvedTaoLocale;
|
|
123
|
-
};
|
|
124
|
-
/** Internal component access for token propagation through third-party portals. */
|
|
125
|
-
export declare function useTaoInternalConfig(): TaoConfigContextValue;
|
|
126
|
-
/** Resolve DOM inheritance at a component's source, before it creates portals. */
|
|
127
|
-
export declare function useTaoDirection(explicit?: TaoDirection | 'auto', source?: 'parent' | 'self'): readonly [TaoDirection, import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>];
|
|
128
97
|
/**
|
|
129
98
|
* antd `theme.useToken` counterpart, zero-runtime edition: returns every
|
|
130
99
|
* design token as a `var(--tao-*)` reference string, so custom components can
|
|
@@ -139,25 +108,6 @@ export declare function useTaoDirection(explicit?: TaoDirection | 'auto', source
|
|
|
139
108
|
export declare function useTaoToken(): {
|
|
140
109
|
token: Record<TaoTokenName, string>;
|
|
141
110
|
};
|
|
142
|
-
/**
|
|
143
|
-
* Re-establishes the theme token scope inside a portal. Floating components
|
|
144
|
-
* portal their popup to document.body, escaping the `[data-tao-provider]`
|
|
145
|
-
* element that carries custom token overrides; wrapping the portal content in
|
|
146
|
-
* this component re-applies those overrides so colors/sizes stay consistent.
|
|
147
|
-
*
|
|
148
|
-
* With `asChild`, merges the tokens onto the immediate child (via Radix Slot)
|
|
149
|
-
* instead of adding a wrapper div. Prefer `asChild` inside portals whose Radix
|
|
150
|
-
* primitive does NOT Presence-gate its Portal (notably `@radix-ui/react-select`
|
|
151
|
-
* — see `SelectPortal` in `node_modules/@radix-ui/react-select`): the wrapper
|
|
152
|
-
* div would otherwise render even while the popup is closed, leaving a ghost
|
|
153
|
-
* `<div data-tao-provider>` in the body for every mounted-but-closed Select.
|
|
154
|
-
*/
|
|
155
|
-
export declare const TaoPortalScope: import("react").ForwardRefExoticComponent<{
|
|
156
|
-
children: ReactNode;
|
|
157
|
-
style?: CSSProperties;
|
|
158
|
-
asChild?: boolean;
|
|
159
|
-
direction?: TaoDirection;
|
|
160
|
-
} & import("react").RefAttributes<HTMLElement>>;
|
|
161
111
|
export interface TaoProviderProps {
|
|
162
112
|
/** Text and interaction direction. Defaults to the surrounding DOM direction. */
|
|
163
113
|
direction?: TaoDirection;
|