@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,17 +1,21 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, forwardRef, isValidElement, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { useTaoDirection, useTaoInternalConfig } from "../../provider/tao-context.js";
|
|
5
|
+
import { TaoPortalScope } from "../../provider/tao-portal-scope.js";
|
|
5
6
|
import { cx } from "../../utils/semantic.js";
|
|
6
7
|
import { CloseIcon } from "../select/select-icons.js";
|
|
7
8
|
import { Spinner } from "../spinner/spinner.js";
|
|
9
|
+
import "../../theme/control.css";
|
|
8
10
|
import "./mentions.css";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
function MentionsOption(_props) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
11
14
|
function getMentions(value = '', { prefix = '@', split = ' ' } = {}) {
|
|
12
|
-
const prefixes = Array.isArray(prefix) ? prefix : [
|
|
15
|
+
const prefixes = (Array.isArray(prefix) ? prefix : [
|
|
13
16
|
prefix
|
|
14
|
-
];
|
|
17
|
+
]).filter(Boolean).sort((a, b)=>b.length - a.length);
|
|
18
|
+
if (!prefixes.length) return [];
|
|
15
19
|
const tokens = ' ' === split ? value.split(/\s+/u) : value.split(split);
|
|
16
20
|
return tokens.flatMap((text)=>{
|
|
17
21
|
const match = prefixes.find((candidate)=>text.startsWith(candidate));
|
|
@@ -23,9 +27,40 @@ function getMentions(value = '', { prefix = '@', split = ' ' } = {}) {
|
|
|
23
27
|
] : [];
|
|
24
28
|
});
|
|
25
29
|
}
|
|
30
|
+
function findActiveTrigger(text, caret, prefixes, split) {
|
|
31
|
+
const before = text.slice(0, caret);
|
|
32
|
+
let best = null;
|
|
33
|
+
for (const p of prefixes){
|
|
34
|
+
if (!p) continue;
|
|
35
|
+
const idx = before.lastIndexOf(p);
|
|
36
|
+
if (-1 === idx) continue;
|
|
37
|
+
if (idx > 0) {
|
|
38
|
+
const prevChar = before[idx - 1];
|
|
39
|
+
const validBoundary = ' ' === split ? /\s/.test(prevChar) : prevChar === split || /\s/.test(prevChar);
|
|
40
|
+
if (!validBoundary) continue;
|
|
41
|
+
}
|
|
42
|
+
const query = before.slice(idx + p.length);
|
|
43
|
+
if (!(split && query.includes(split))) {
|
|
44
|
+
if (!/\s/.test(query)) {
|
|
45
|
+
if (!best || idx > best.location || idx === best.location && p.length > best.prefix.length) best = {
|
|
46
|
+
prefix: p,
|
|
47
|
+
location: idx,
|
|
48
|
+
query
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return best;
|
|
54
|
+
}
|
|
55
|
+
function defaultFilterOption(input, option) {
|
|
56
|
+
if (!input) return true;
|
|
57
|
+
const q = input.toLowerCase();
|
|
58
|
+
const labelText = 'string' == typeof option.label ? option.label : '';
|
|
59
|
+
return option.value.toLowerCase().includes(q) || labelText.toLowerCase().includes(q);
|
|
60
|
+
}
|
|
26
61
|
const MentionsComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
27
62
|
const config = useTaoInternalConfig();
|
|
28
|
-
const { size: sizeProp = config.size, disabled = config.disabled, variant = config.variant, status, loading = false, prefixCls = 'tao-mentions', className, rootClassName, style, classNames, styles, allowClear, options, children, filterOption, notFoundContent = config.locale.noResults, popupClassName, popupRender, value, ...
|
|
63
|
+
const { size: sizeProp = config.size, disabled = config.disabled, variant = config.variant, status, loading = false, prefixCls = 'tao-mentions', className, rootClassName, style, classNames, styles, allowClear, options, children, prefix = '@', split = ' ', filterOption, validateSearch, notFoundContent = config.locale.noResults, popupClassName, popupRender, getPopupContainer, value, defaultValue = '', onChange, onSelect, onSearch, onClear, onKeyDown, onKeyDownCapture, onKeyUp, onBlur, readOnly, direction: directionProp, autoSize: _autoSize, placement: _placement, ...textareaRest } = props;
|
|
29
64
|
const size = 'middle' === sizeProp ? 'medium' : sizeProp;
|
|
30
65
|
const resolvedProps = {
|
|
31
66
|
...props,
|
|
@@ -39,23 +74,174 @@ const MentionsComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
39
74
|
const semanticStyles = 'function' == typeof styles ? styles({
|
|
40
75
|
props: resolvedProps
|
|
41
76
|
}) : styles;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
const [direction, directionRef] = useTaoDirection(directionProp);
|
|
78
|
+
const controlled = 'value' in props;
|
|
79
|
+
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
80
|
+
const currentValue = controlled ? value ?? '' : innerValue;
|
|
81
|
+
const [measuring, setMeasuring] = useState(null);
|
|
82
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
83
|
+
const composingRef = useRef(false);
|
|
84
|
+
const rootRef = useRef(null);
|
|
85
|
+
const textareaRef = useRef(null);
|
|
86
|
+
useImperativeHandle(ref, ()=>({
|
|
87
|
+
focus: ()=>textareaRef.current?.focus(),
|
|
88
|
+
blur: ()=>textareaRef.current?.blur(),
|
|
89
|
+
get textarea () {
|
|
90
|
+
return textareaRef.current;
|
|
91
|
+
},
|
|
92
|
+
get nativeElement () {
|
|
93
|
+
return rootRef.current;
|
|
94
|
+
}
|
|
95
|
+
}), []);
|
|
96
|
+
const prefixes = useMemo(()=>(Array.isArray(prefix) ? prefix : [
|
|
97
|
+
prefix
|
|
98
|
+
]).filter(Boolean), [
|
|
99
|
+
prefix
|
|
100
|
+
]);
|
|
101
|
+
const mergedOptions = useMemo(()=>{
|
|
102
|
+
if (loading) return [
|
|
103
|
+
{
|
|
104
|
+
value: '__tao_loading__',
|
|
105
|
+
disabled: true,
|
|
106
|
+
label: /*#__PURE__*/ jsx(Spinner, {
|
|
107
|
+
size: "small"
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
|
+
if (void 0 !== options) return options;
|
|
112
|
+
const legacy = [];
|
|
113
|
+
Children.forEach(children, (child)=>{
|
|
114
|
+
if (/*#__PURE__*/ isValidElement(child)) legacy.push({
|
|
115
|
+
value: child.props.value ?? '',
|
|
116
|
+
label: child.props.children ?? child.props.value,
|
|
117
|
+
disabled: child.props.disabled,
|
|
118
|
+
className: child.props.className,
|
|
119
|
+
style: child.props.style
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return legacy;
|
|
123
|
+
}, [
|
|
124
|
+
children,
|
|
125
|
+
loading,
|
|
126
|
+
options
|
|
127
|
+
]);
|
|
128
|
+
const visibleOptions = useMemo(()=>{
|
|
129
|
+
if (!measuring) return [];
|
|
130
|
+
if (loading) return mergedOptions;
|
|
131
|
+
if (false === filterOption) return mergedOptions;
|
|
132
|
+
const fn = 'function' == typeof filterOption ? filterOption : defaultFilterOption;
|
|
133
|
+
return mergedOptions.filter((opt)=>fn(measuring.query, opt));
|
|
134
|
+
}, [
|
|
135
|
+
filterOption,
|
|
136
|
+
loading,
|
|
137
|
+
measuring,
|
|
138
|
+
mergedOptions
|
|
139
|
+
]);
|
|
140
|
+
const firstEnabledIndex = useMemo(()=>visibleOptions.findIndex((o)=>!o.disabled), [
|
|
141
|
+
visibleOptions
|
|
142
|
+
]);
|
|
143
|
+
const effectiveActiveIndex = activeIndex >= 0 && activeIndex < visibleOptions.length && !visibleOptions[activeIndex]?.disabled ? activeIndex : firstEnabledIndex;
|
|
144
|
+
const commitValue = (next)=>{
|
|
145
|
+
if (!controlled) setInnerValue(next);
|
|
146
|
+
onChange?.(next);
|
|
147
|
+
};
|
|
148
|
+
const syncMeasure = (text, caret)=>{
|
|
149
|
+
const hit = findActiveTrigger(text, caret, prefixes, split);
|
|
150
|
+
if (hit && (!validateSearch || validateSearch(hit.query, props))) {
|
|
151
|
+
setMeasuring(hit);
|
|
152
|
+
setActiveIndex(0);
|
|
153
|
+
onSearch?.(hit.query, hit.prefix);
|
|
154
|
+
} else setMeasuring(null);
|
|
155
|
+
};
|
|
156
|
+
const selectOption = (option)=>{
|
|
157
|
+
if (!measuring || option.disabled || loading) return;
|
|
158
|
+
const before = currentValue.slice(0, measuring.location);
|
|
159
|
+
const afterStart = measuring.location + measuring.prefix.length + measuring.query.length;
|
|
160
|
+
const after = currentValue.slice(afterStart);
|
|
161
|
+
const inserted = `${measuring.prefix}${option.value}${split}`;
|
|
162
|
+
const next = `${before}${inserted}${after}`;
|
|
163
|
+
const nextCaret = before.length + inserted.length;
|
|
164
|
+
commitValue(next);
|
|
165
|
+
onSelect?.(option, measuring.prefix);
|
|
166
|
+
setMeasuring(null);
|
|
167
|
+
requestAnimationFrame(()=>{
|
|
168
|
+
textareaRef.current?.setSelectionRange(nextCaret, nextCaret);
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
const moveActive = (delta)=>{
|
|
172
|
+
if (!visibleOptions.length) return;
|
|
173
|
+
const len = visibleOptions.length;
|
|
174
|
+
let next = effectiveActiveIndex < 0 ? 0 : effectiveActiveIndex;
|
|
175
|
+
for(let i = 0; i < len; i += 1){
|
|
176
|
+
next = (next + delta + len) % len;
|
|
177
|
+
if (!visibleOptions[next]?.disabled) return void setActiveIndex(next);
|
|
54
178
|
}
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
179
|
+
};
|
|
180
|
+
const handleKeyDown = (event)=>{
|
|
181
|
+
const isComposing = composingRef.current || event.nativeEvent.isComposing || 229 === event.keyCode;
|
|
182
|
+
if (measuring && !isComposing) {
|
|
183
|
+
if ('ArrowDown' === event.key || 40 === event.keyCode) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
moveActive(1);
|
|
186
|
+
onKeyDown?.(event);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if ('ArrowUp' === event.key || 38 === event.keyCode) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
moveActive(-1);
|
|
192
|
+
onKeyDown?.(event);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if ('Enter' === event.key || 13 === event.keyCode) {
|
|
196
|
+
const chosen = visibleOptions[effectiveActiveIndex];
|
|
197
|
+
if (chosen && !chosen.disabled && !loading) {
|
|
198
|
+
event.preventDefault();
|
|
199
|
+
selectOption(chosen);
|
|
200
|
+
}
|
|
201
|
+
onKeyDown?.(event);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if ('Escape' === event.key || 27 === event.keyCode) {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
setMeasuring(null);
|
|
207
|
+
onKeyDown?.(event);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
onKeyDown?.(event);
|
|
212
|
+
};
|
|
213
|
+
const showClear = Boolean(allowClear) && !readOnly && !disabled;
|
|
214
|
+
const clearIcon = 'object' == typeof allowClear && void 0 !== allowClear.clearIcon ? allowClear.clearIcon : /*#__PURE__*/ jsx(CloseIcon, {});
|
|
215
|
+
const menuNode = /*#__PURE__*/ jsx("ul", {
|
|
216
|
+
role: "menu",
|
|
217
|
+
className: `${prefixCls}-menu`,
|
|
218
|
+
children: visibleOptions.length > 0 ? visibleOptions.map((option, index)=>{
|
|
219
|
+
const active = index === effectiveActiveIndex && !option.disabled;
|
|
220
|
+
return /*#__PURE__*/ jsx("li", {
|
|
221
|
+
role: "menuitem",
|
|
222
|
+
"aria-disabled": option.disabled || void 0,
|
|
223
|
+
className: cx(`${prefixCls}-menu-item`, active && `${prefixCls}-menu-item-active`, option.disabled && `${prefixCls}-menu-item-disabled`, option.className),
|
|
224
|
+
style: option.style,
|
|
225
|
+
onMouseDown: (event)=>event.preventDefault(),
|
|
226
|
+
onMouseEnter: ()=>{
|
|
227
|
+
if (!option.disabled) setActiveIndex(index);
|
|
228
|
+
},
|
|
229
|
+
onClick: ()=>selectOption(option),
|
|
230
|
+
children: option.label ?? option.value
|
|
231
|
+
}, option.key ?? option.value);
|
|
232
|
+
}) : /*#__PURE__*/ jsx("li", {
|
|
233
|
+
role: "menuitem",
|
|
234
|
+
"aria-disabled": "true",
|
|
235
|
+
className: `${prefixCls}-menu-item ${prefixCls}-menu-item-disabled`,
|
|
236
|
+
children: notFoundContent
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
const popupHost = "u" > typeof document ? getPopupContainer?.() ?? document.body : null;
|
|
240
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
241
|
+
ref: (el)=>{
|
|
242
|
+
rootRef.current = el;
|
|
243
|
+
directionRef(el);
|
|
244
|
+
},
|
|
59
245
|
"data-tao-mentions": "",
|
|
60
246
|
"data-tao-control": "",
|
|
61
247
|
"data-tao-size": size,
|
|
@@ -69,61 +255,91 @@ const MentionsComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
69
255
|
...semanticStyles?.root,
|
|
70
256
|
...style
|
|
71
257
|
},
|
|
72
|
-
children:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
258
|
+
children: [
|
|
259
|
+
/*#__PURE__*/ jsxs("div", {
|
|
260
|
+
className: cx(prefixCls, showClear && `${prefixCls}-has-suffix`),
|
|
261
|
+
children: [
|
|
262
|
+
/*#__PURE__*/ jsx("textarea", {
|
|
263
|
+
...textareaRest,
|
|
264
|
+
ref: textareaRef,
|
|
265
|
+
dir: direction,
|
|
266
|
+
disabled: disabled,
|
|
267
|
+
readOnly: readOnly,
|
|
268
|
+
"aria-invalid": 'error' === status ? true : props['aria-invalid'],
|
|
269
|
+
value: currentValue,
|
|
270
|
+
className: cx(classes?.textarea),
|
|
271
|
+
style: {
|
|
272
|
+
resize: style?.resize,
|
|
273
|
+
...semanticStyles?.textarea
|
|
274
|
+
},
|
|
275
|
+
onCompositionStart: (event)=>{
|
|
276
|
+
composingRef.current = true;
|
|
277
|
+
props.onCompositionStart?.(event);
|
|
278
|
+
},
|
|
279
|
+
onCompositionEnd: (event)=>{
|
|
280
|
+
composingRef.current = false;
|
|
281
|
+
props.onCompositionEnd?.(event);
|
|
282
|
+
},
|
|
283
|
+
onChange: (event)=>{
|
|
284
|
+
const next = event.target.value;
|
|
285
|
+
commitValue(next);
|
|
286
|
+
const caret = event.target.selectionStart ?? next.length;
|
|
287
|
+
syncMeasure(next, caret);
|
|
288
|
+
},
|
|
289
|
+
onKeyDownCapture: onKeyDownCapture,
|
|
290
|
+
onKeyDown: handleKeyDown,
|
|
291
|
+
onKeyUp: (event)=>{
|
|
292
|
+
onKeyUp?.(event);
|
|
293
|
+
if ('ArrowDown' === event.key || 'ArrowUp' === event.key || 'Enter' === event.key || 'Escape' === event.key) return;
|
|
294
|
+
const target = event.currentTarget;
|
|
295
|
+
syncMeasure(target.value, target.selectionStart ?? target.value.length);
|
|
296
|
+
},
|
|
297
|
+
onBlur: (event)=>{
|
|
298
|
+
setMeasuring(null);
|
|
299
|
+
onBlur?.(event);
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
showClear && /*#__PURE__*/ jsx("span", {
|
|
303
|
+
className: cx(`${prefixCls}-suffix`, classes?.suffix),
|
|
304
|
+
style: semanticStyles?.suffix,
|
|
305
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
306
|
+
type: "button",
|
|
307
|
+
"aria-label": config.locale.clear,
|
|
308
|
+
className: cx(`${prefixCls}-clear-icon`, !currentValue && `${prefixCls}-clear-icon-hidden`),
|
|
309
|
+
onMouseDown: (event)=>event.preventDefault(),
|
|
310
|
+
onClick: ()=>{
|
|
311
|
+
commitValue('');
|
|
312
|
+
setMeasuring(null);
|
|
313
|
+
onClear?.();
|
|
314
|
+
},
|
|
315
|
+
children: clearIcon
|
|
316
|
+
})
|
|
118
317
|
})
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
318
|
+
]
|
|
319
|
+
}),
|
|
320
|
+
measuring && popupHost && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(TaoPortalScope, {
|
|
321
|
+
asChild: true,
|
|
322
|
+
direction: direction,
|
|
323
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
324
|
+
"data-tao-mentions-popup": "",
|
|
325
|
+
"data-tao-size": size,
|
|
326
|
+
className: cx(classes?.popup, popupClassName, rootClassName),
|
|
327
|
+
style: {
|
|
328
|
+
...config.tokenStyle,
|
|
329
|
+
position: 'absolute',
|
|
330
|
+
maxWidth: 'calc(100vw - 16px)',
|
|
331
|
+
zIndex: 'var(--tao-z-index-popup)',
|
|
332
|
+
...semanticStyles?.popup
|
|
333
|
+
},
|
|
334
|
+
children: popupRender ? popupRender(menuNode) : menuNode
|
|
335
|
+
})
|
|
336
|
+
}), popupHost)
|
|
337
|
+
]
|
|
122
338
|
});
|
|
123
339
|
});
|
|
124
340
|
MentionsComponent.displayName = 'Mentions';
|
|
125
341
|
const Mentions = Object.assign(MentionsComponent, {
|
|
126
|
-
Option:
|
|
342
|
+
Option: MentionsOption,
|
|
127
343
|
getMentions: getMentions
|
|
128
344
|
});
|
|
129
345
|
export { Mentions };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from 'react';
|
|
2
|
+
import type { TaoSize } from '../../provider/tao-context.js';
|
|
3
|
+
import type { TaoDirection } from '../../provider/tao-provider.js';
|
|
2
4
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
3
5
|
import './menu.css';
|
|
4
6
|
export type MenuSemanticPart = 'root' | 'content' | 'item' | 'itemIcon' | 'itemLabel' | 'itemExtra' | 'divider' | 'groupLabel' | 'subTrigger' | 'subContent';
|
|
@@ -67,6 +69,8 @@ export interface MenuPrimitives {
|
|
|
67
69
|
}
|
|
68
70
|
export interface RenderCtx {
|
|
69
71
|
P: MenuPrimitives;
|
|
72
|
+
size?: TaoSize;
|
|
73
|
+
direction?: TaoDirection;
|
|
70
74
|
classNames?: SemanticClassNames<MenuSemanticPart>;
|
|
71
75
|
styles?: SemanticStyles<MenuSemanticPart>;
|
|
72
76
|
/** Fire item.onClick + menu.onClick for a plain action item. */
|
|
@@ -76,6 +80,7 @@ export interface RenderCtx {
|
|
|
76
80
|
multiple: boolean;
|
|
77
81
|
selectable: boolean;
|
|
78
82
|
onToggle: (key: string) => void;
|
|
83
|
+
onRadioChange: (key: string) => void;
|
|
79
84
|
}
|
|
80
85
|
export declare function renderMenuItems(items: MenuItem[], ctx: RenderCtx): ReactNode;
|
|
81
86
|
/**
|
|
@@ -85,6 +90,8 @@ export declare function renderMenuItems(items: MenuItem[], ctx: RenderCtx): Reac
|
|
|
85
90
|
* and ContextMenu.
|
|
86
91
|
*/
|
|
87
92
|
export declare function useMenuController(menu: MenuProps, P: MenuPrimitives, semantic: {
|
|
93
|
+
size?: TaoSize;
|
|
94
|
+
direction?: TaoDirection;
|
|
88
95
|
classNames?: SemanticClassNames<MenuSemanticPart>;
|
|
89
96
|
styles?: SemanticStyles<MenuSemanticPart>;
|
|
90
97
|
}): {
|