pxd 0.2.0 → 0.3.1
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 +31 -9
- package/dist/agent/allow.d.ts +23 -0
- package/dist/agent/allow.js +98 -0
- package/dist/agent/callers.d.ts +3 -0
- package/dist/agent/callers.js +1 -0
- package/dist/agent/describe.d.ts +14 -0
- package/dist/agent/describe.js +176 -0
- package/dist/agent/history.d.ts +42 -0
- package/dist/agent/history.js +93 -0
- package/dist/agent/index.d.ts +24 -0
- package/dist/agent/index.js +119 -0
- package/dist/agent/items.d.ts +21 -0
- package/dist/agent/items.js +52 -0
- package/dist/agent/label.d.ts +2 -0
- package/dist/agent/label.js +67 -0
- package/dist/agent/marks.d.ts +9 -0
- package/dist/agent/marks.js +45 -0
- package/dist/agent/observe.d.ts +13 -0
- package/dist/agent/observe.js +18 -0
- package/dist/agent/press.d.ts +8 -0
- package/dist/agent/press.js +82 -0
- package/dist/agent/query.d.ts +22 -0
- package/dist/agent/query.js +190 -0
- package/dist/agent/register.d.ts +10 -0
- package/dist/agent/register.js +33 -0
- package/dist/agent/registry.d.ts +42 -0
- package/dist/agent/registry.js +265 -0
- package/dist/agent/report.d.ts +4 -0
- package/dist/agent/report.js +59 -0
- package/dist/agent/run.d.ts +33 -0
- package/dist/agent/run.js +232 -0
- package/dist/agent/stage.d.ts +29 -0
- package/dist/agent/stage.js +39 -0
- package/dist/agent/testing.d.ts +35 -0
- package/dist/agent/testing.js +70 -0
- package/dist/agent/tools.d.ts +2 -0
- package/dist/agent/tools.js +78 -0
- package/dist/agent/types.d.ts +201 -0
- package/dist/agent/types.js +0 -0
- package/dist/agent/values.d.ts +20 -0
- package/dist/agent/values.js +155 -0
- package/dist/components/_internal/calendar-day.d.vue.ts +3 -2
- package/dist/components/_internal/calendar-day.vue +22 -21
- package/dist/components/{teleport/index.d.vue.ts → _internal/client-teleport.d.vue.ts} +6 -4
- package/dist/components/_internal/client-teleport.vue +29 -0
- package/dist/components/_internal/dismiss-container.vue +4 -3
- package/dist/components/_internal/mention-editor.d.vue.ts +13 -4
- package/dist/components/_internal/mention-editor.vue +34 -15
- package/dist/components/_internal/popover-arrow.d.vue.ts +1 -7
- package/dist/components/_internal/popover-arrow.vue +4 -12
- package/dist/components/_internal/popover-trigger.d.vue.ts +22 -0
- package/dist/components/_internal/popover-trigger.vue +60 -0
- package/dist/components/_internal/step-item.vue +1 -1
- package/dist/components/_internal/tree-node.vue +5 -1
- package/dist/components/active-graph/index.d.vue.ts +2 -2
- package/dist/components/active-graph/index.vue +25 -5
- package/dist/components/active-graph/types.d.ts +5 -1
- package/dist/components/approval-card/index.vue +34 -18
- package/dist/components/approval-card/types.d.ts +1 -1
- package/dist/components/avatar/index.vue +16 -8
- package/dist/components/avatar/types.d.ts +2 -2
- package/dist/components/avatar-group/index.d.vue.ts +1 -1
- package/dist/components/avatar-group/index.vue +11 -7
- package/dist/components/avatar-group/types.d.ts +2 -2
- package/dist/components/backtop/index.vue +4 -4
- package/dist/components/badge/index.vue +20 -8
- package/dist/components/book/index.d.vue.ts +1 -1
- package/dist/components/book/index.vue +5 -5
- package/dist/components/book/types.d.ts +1 -1
- package/dist/components/border-beam/index.d.vue.ts +1 -1
- package/dist/components/border-beam/index.vue +6 -7
- package/dist/components/border-beam/types.d.ts +1 -1
- package/dist/components/breadcrumb/index.vue +5 -1
- package/dist/components/breadcrumb-item/index.vue +3 -3
- package/dist/components/breadcrumb-item/types.d.ts +1 -1
- package/dist/components/browser/index.vue +5 -10
- package/dist/components/bubble/index.vue +2 -2
- package/dist/components/bubble/types.d.ts +2 -0
- package/dist/components/bubble-group/index.d.vue.ts +3 -1
- package/dist/components/bubble-group/index.vue +15 -13
- package/dist/components/bubble-group/types.d.ts +1 -0
- package/dist/components/button/index.d.vue.ts +1 -1
- package/dist/components/button/index.vue +41 -33
- package/dist/components/button/types.d.ts +4 -4
- package/dist/components/button-group/types.d.ts +1 -1
- package/dist/components/calendar/index.d.vue.ts +3 -3
- package/dist/components/calendar/index.vue +51 -17
- package/dist/components/calendar/types.d.ts +3 -6
- package/dist/components/card/index.d.vue.ts +1 -1
- package/dist/components/carousel/index.d.vue.ts +7 -7
- package/dist/components/carousel/index.vue +252 -125
- package/dist/components/carousel/types.d.ts +14 -3
- package/dist/components/checkbox/index.d.vue.ts +5 -5
- package/dist/components/checkbox/index.vue +40 -14
- package/dist/components/checkbox/types.d.ts +6 -3
- package/dist/components/checkbox-group/index.d.vue.ts +4 -4
- package/dist/components/checkbox-group/index.vue +45 -6
- package/dist/components/checkbox-group/types.d.ts +9 -2
- package/dist/components/checkerboard/index.vue +2 -2
- package/dist/components/checkerboard/types.d.ts +1 -1
- package/dist/components/chip/index.vue +5 -3
- package/dist/components/chip/types.d.ts +1 -1
- package/dist/components/choicebox/index.d.vue.ts +4 -4
- package/dist/components/choicebox/index.vue +27 -7
- package/dist/components/choicebox/types.d.ts +7 -2
- package/dist/components/choicebox-item/index.vue +15 -13
- package/dist/components/code-block/index.d.vue.ts +1 -2
- package/dist/components/code-block/index.vue +57 -40
- package/dist/components/code-block/types.d.ts +3 -4
- package/dist/components/collapse/index.d.vue.ts +1 -1
- package/dist/components/collapse/index.vue +23 -6
- package/dist/components/collapse/types.d.ts +1 -1
- package/dist/components/color-selector/index.d.vue.ts +2 -2
- package/dist/components/color-selector/index.vue +35 -21
- package/dist/components/color-selector/types.d.ts +7 -2
- package/dist/components/command-menu/index.d.vue.ts +11 -6
- package/dist/components/command-menu/index.vue +52 -24
- package/dist/components/command-menu/types.d.ts +10 -2
- package/dist/components/config-provider/index.d.vue.ts +27 -5
- package/dist/components/confirm-popover/index.d.vue.ts +3 -3
- package/dist/components/confirm-popover/index.vue +22 -22
- package/dist/components/confirm-popover/types.d.ts +2 -2
- package/dist/components/context-usage/index.vue +30 -15
- package/dist/components/copy-button/index.d.vue.ts +5 -1
- package/dist/components/copy-button/index.vue +31 -12
- package/dist/components/copy-button/types.d.ts +1 -1
- package/dist/components/countdown/index.d.vue.ts +2 -3
- package/dist/components/countdown/index.vue +30 -15
- package/dist/components/countdown/types.d.ts +43 -3
- package/dist/components/date-picker/index.d.vue.ts +3 -4
- package/dist/components/date-picker/index.vue +57 -36
- package/dist/components/date-picker/types.d.ts +9 -3
- package/dist/components/description/index.d.vue.ts +1 -1
- package/dist/components/description/index.vue +3 -3
- package/dist/components/description/types.d.ts +1 -1
- package/dist/components/drawer/index.d.vue.ts +11 -8
- package/dist/components/drawer/index.vue +146 -116
- package/dist/components/drawer/types.d.ts +12 -7
- package/dist/components/effort-slider/index.d.vue.ts +2 -2
- package/dist/components/effort-slider/index.vue +89 -72
- package/dist/components/effort-slider/types.d.ts +4 -1
- package/dist/components/ellipsis-text/index.d.vue.ts +1 -1
- package/dist/components/ellipsis-text/index.vue +15 -24
- package/dist/components/ellipsis-text/types.d.ts +1 -1
- package/dist/components/empty-state/index.d.vue.ts +1 -1
- package/dist/components/empty-state/index.vue +3 -3
- package/dist/components/empty-state/types.d.ts +1 -1
- package/dist/components/{error → error-info}/index.d.vue.ts +2 -2
- package/dist/components/{error → error-info}/index.vue +18 -13
- package/dist/components/{error → error-info}/types.d.ts +3 -3
- package/dist/components/fader/index.d.vue.ts +1 -1
- package/dist/components/fader/index.vue +12 -11
- package/dist/components/fader/types.d.ts +1 -1
- package/dist/components/feedback-bar/index.vue +3 -3
- package/dist/components/form/index.d.vue.ts +56 -0
- package/dist/components/form/index.vue +237 -0
- package/dist/components/form/types.d.ts +32 -0
- package/dist/components/form-item/index.d.vue.ts +48 -0
- package/dist/components/form-item/index.vue +391 -0
- package/dist/components/form-item/types.d.ts +20 -0
- package/dist/components/gauge/index.vue +10 -5
- package/dist/components/grid/index.vue +4 -5
- package/dist/components/grid-item/index.vue +6 -15
- package/dist/components/hint/index.vue +0 -1
- package/dist/components/hold-button/index.d.vue.ts +2 -2
- package/dist/components/hold-button/index.vue +44 -71
- package/dist/components/image-compare/index.d.vue.ts +17 -0
- package/dist/components/image-compare/index.vue +205 -0
- package/dist/components/image-cropper/index.d.vue.ts +55 -0
- package/dist/components/image-cropper/index.vue +1200 -0
- package/dist/components/image-cropper/types.d.ts +80 -0
- package/dist/components/image-generate/index.d.vue.ts +27 -0
- package/dist/components/image-generate/index.vue +143 -0
- package/dist/components/image-generate/types.d.ts +13 -0
- package/dist/components/image-preview/index.d.vue.ts +3 -3
- package/dist/components/image-preview/index.vue +88 -73
- package/dist/components/image-preview/types.d.ts +3 -4
- package/dist/components/index.d.ts +11 -4
- package/dist/components/index.js +6 -2
- package/dist/components/input/index.d.vue.ts +6 -5
- package/dist/components/input/index.vue +98 -40
- package/dist/components/input/types.d.ts +9 -3
- package/dist/components/intersection-observer/index.d.vue.ts +1 -1
- package/dist/components/intersection-observer/index.vue +14 -9
- package/dist/components/intersection-observer/types.d.ts +1 -1
- package/dist/components/kbd/index.vue +6 -6
- package/dist/components/kbd/types.d.ts +1 -1
- package/dist/components/link-button/index.d.vue.ts +1 -1
- package/dist/components/link-button/index.vue +34 -27
- package/dist/components/link-button/types.d.ts +0 -1
- package/dist/components/list/index.d.vue.ts +10 -2
- package/dist/components/list/index.vue +72 -8
- package/dist/components/list/types.d.ts +10 -1
- package/dist/components/list-group/types.d.ts +0 -2
- package/dist/components/list-item/index.d.vue.ts +1 -1
- package/dist/components/list-item/index.vue +7 -3
- package/dist/components/loading-bar/index.d.vue.ts +2 -1
- package/dist/components/loading-bar/index.vue +20 -110
- package/dist/components/loading-bar/types.d.ts +1 -1
- package/dist/components/loading-dots/index.vue +4 -11
- package/dist/components/loading-mask/index.d.vue.ts +1 -1
- package/dist/components/loading-mask/index.vue +1 -1
- package/dist/components/loading-mask/types.d.ts +2 -0
- package/dist/components/marching-ants/index.vue +15 -9
- package/dist/components/marquee/index.d.vue.ts +2 -2
- package/dist/components/marquee/index.vue +8 -8
- package/dist/components/marquee/types.d.ts +2 -2
- package/dist/components/material/index.d.vue.ts +1 -1
- package/dist/components/mention/index.d.vue.ts +5 -4
- package/dist/components/mention/index.vue +63 -26
- package/dist/components/mention/types.d.ts +5 -1
- package/dist/components/menu/index.d.vue.ts +2 -3
- package/dist/components/menu/index.vue +43 -18
- package/dist/components/menu/types.d.ts +4 -2
- package/dist/components/message/index.d.vue.ts +7 -7
- package/dist/components/message/index.vue +35 -18
- package/dist/components/message/types.d.ts +1 -1
- package/dist/components/message-item/index.d.vue.ts +3 -1
- package/dist/components/message-item/index.vue +44 -21
- package/dist/components/message-item/types.d.ts +2 -1
- package/dist/components/modal/index.d.vue.ts +10 -7
- package/dist/components/modal/index.vue +143 -97
- package/dist/components/modal/types.d.ts +10 -5
- package/dist/components/more-button/index.d.vue.ts +6 -6
- package/dist/components/more-button/index.vue +24 -10
- package/dist/components/more-button/types.d.ts +9 -2
- package/dist/components/note/index.d.vue.ts +1 -1
- package/dist/components/note/index.vue +12 -15
- package/dist/components/note/types.d.ts +2 -1
- package/dist/components/number-input/index.d.vue.ts +5 -5
- package/dist/components/number-input/index.vue +115 -49
- package/dist/components/number-input/types.d.ts +7 -2
- package/dist/components/overlay/index.d.vue.ts +2 -1
- package/dist/components/overlay/index.vue +18 -30
- package/dist/components/overlay/types.d.ts +2 -1
- package/dist/components/page-number/index.vue +42 -19
- package/dist/components/page-number/types.d.ts +1 -1
- package/dist/components/pagination/index.vue +12 -5
- package/dist/components/pin-input/index.d.vue.ts +3 -3
- package/dist/components/pin-input/index.vue +64 -37
- package/dist/components/pin-input/types.d.ts +19 -10
- package/dist/components/placeholder/index.d.vue.ts +3 -1
- package/dist/components/placeholder/index.vue +7 -5
- package/dist/components/placeholder/types.d.ts +3 -1
- package/dist/components/popover/index.d.vue.ts +64 -0
- package/dist/components/popover/index.vue +224 -525
- package/dist/components/popover/types.d.ts +11 -6
- package/dist/components/progress/index.d.vue.ts +1 -1
- package/dist/components/progress/index.vue +44 -37
- package/dist/components/progress/types.d.ts +2 -1
- package/dist/components/questionnaire/index.vue +115 -22
- package/dist/components/questionnaire/types.d.ts +1 -1
- package/dist/components/radial-burst/index.vue +2 -2
- package/dist/components/radial-burst/types.d.ts +1 -1
- package/dist/components/radio/index.d.vue.ts +4 -4
- package/dist/components/radio/index.vue +25 -11
- package/dist/components/radio/types.d.ts +7 -2
- package/dist/components/radio-group/index.d.vue.ts +4 -4
- package/dist/components/radio-group/index.vue +45 -8
- package/dist/components/radio-group/types.d.ts +9 -2
- package/dist/components/rating/index.d.vue.ts +2 -2
- package/dist/components/rating/index.vue +63 -23
- package/dist/components/rating/types.d.ts +7 -2
- package/dist/components/reactions/index.d.vue.ts +3 -3
- package/dist/components/reactions/index.vue +20 -10
- package/dist/components/reactions/types.d.ts +5 -3
- package/dist/components/reasoning/index.vue +10 -9
- package/dist/components/reasoning/types.d.ts +1 -1
- package/dist/components/resizable/index.d.vue.ts +6 -6
- package/dist/components/resizable/index.vue +23 -10
- package/dist/components/resizable/types.d.ts +7 -1
- package/dist/components/reveal/index.d.vue.ts +3 -3
- package/dist/components/reveal/index.vue +7 -15
- package/dist/components/reveal/types.d.ts +2 -2
- package/dist/components/rolling-number/index.vue +11 -8
- package/dist/components/scroll-progress/index.d.vue.ts +2 -2
- package/dist/components/scroll-progress/index.vue +40 -34
- package/dist/components/scroll-progress/types.d.ts +4 -1
- package/dist/components/scroll-text/index.vue +1 -1
- package/dist/components/scrollable/index.vue +8 -8
- package/dist/components/scrollable/types.d.ts +2 -2
- package/dist/components/search-input/index.d.vue.ts +21 -14
- package/dist/components/search-input/index.vue +57 -9
- package/dist/components/search-input/types.d.ts +7 -1
- package/dist/components/select/index.d.vue.ts +7 -2
- package/dist/components/select/index.vue +267 -116
- package/dist/components/select/types.d.ts +14 -6
- package/dist/components/separator/index.vue +1 -1
- package/dist/components/shimmer-text/index.d.vue.ts +1 -1
- package/dist/components/shimmer-text/index.vue +7 -7
- package/dist/components/shimmer-text/types.d.ts +1 -1
- package/dist/components/skeleton/index.d.vue.ts +1 -1
- package/dist/components/skeleton/index.vue +2 -2
- package/dist/components/slider/index.d.vue.ts +5 -5
- package/dist/components/slider/index.vue +137 -101
- package/dist/components/slider/types.d.ts +9 -2
- package/dist/components/snippet/index.vue +6 -6
- package/dist/components/spinner/index.vue +14 -10
- package/dist/components/spinner-dots/index.d.vue.ts +1 -1
- package/dist/components/spinner-dots/index.vue +1 -1
- package/dist/components/split-button/index.d.vue.ts +2 -2
- package/dist/components/split-button/index.vue +18 -14
- package/dist/components/split-button/types.d.ts +6 -3
- package/dist/components/stack/index.d.vue.ts +2 -2
- package/dist/components/stack/index.vue +2 -5
- package/dist/components/stack/types.d.ts +3 -2
- package/dist/components/status-dot/index.d.vue.ts +2 -2
- package/dist/components/status-dot/index.vue +14 -21
- package/dist/components/status-dot/types.d.ts +3 -2
- package/dist/components/steps/index.d.vue.ts +3 -3
- package/dist/components/steps/index.vue +21 -14
- package/dist/components/steps/types.d.ts +5 -2
- package/dist/components/stick-to-bottom/index.d.vue.ts +3 -2
- package/dist/components/stick-to-bottom/index.vue +40 -3
- package/dist/components/stick-to-bottom/types.d.ts +9 -2
- package/dist/components/swipe-cell/index.d.vue.ts +4 -4
- package/dist/components/swipe-cell/index.vue +37 -14
- package/dist/components/swipe-cell/types.d.ts +2 -10
- package/dist/components/switch/index.d.vue.ts +4 -4
- package/dist/components/switch/index.vue +48 -13
- package/dist/components/switch/types.d.ts +9 -2
- package/dist/components/switch-item/index.d.vue.ts +7 -1
- package/dist/components/switch-item/index.vue +15 -12
- package/dist/components/switch-item/types.d.ts +10 -1
- package/dist/components/tabs/index.d.vue.ts +4 -4
- package/dist/components/tabs/index.vue +58 -25
- package/dist/components/tabs/tab-slot.d.ts +3 -4
- package/dist/components/tabs/types.d.ts +5 -2
- package/dist/components/text/index.d.vue.ts +2 -1
- package/dist/components/text/index.vue +14 -8
- package/dist/components/text/types.d.ts +5 -3
- package/dist/components/textarea/index.d.vue.ts +6 -6
- package/dist/components/textarea/index.vue +67 -26
- package/dist/components/textarea/types.d.ts +10 -3
- package/dist/components/theme-switcher/index.vue +6 -4
- package/dist/components/time-picker/index.d.vue.ts +3 -4
- package/dist/components/time-picker/index.vue +71 -51
- package/dist/components/time-picker/types.d.ts +9 -3
- package/dist/components/timeline/index.vue +1 -1
- package/dist/components/timeline-item/index.d.vue.ts +3 -2
- package/dist/components/timeline-item/index.vue +19 -14
- package/dist/components/timeline-item/types.d.ts +5 -5
- package/dist/components/toc/index.d.vue.ts +1 -1
- package/dist/components/toc/index.vue +19 -7
- package/dist/components/todo-list/index.d.vue.ts +20 -20
- package/dist/components/todo-list/index.vue +38 -32
- package/dist/components/todo-list/types.d.ts +24 -30
- package/dist/components/toggle/index.d.vue.ts +4 -4
- package/dist/components/toggle/index.vue +47 -19
- package/dist/components/toggle/types.d.ts +7 -2
- package/dist/components/toggle-button/index.d.vue.ts +5 -5
- package/dist/components/toggle-button/index.vue +44 -24
- package/dist/components/toggle-button/types.d.ts +9 -5
- package/dist/components/toggle-button-group/index.d.vue.ts +4 -4
- package/dist/components/toggle-button-group/index.vue +19 -6
- package/dist/components/toggle-button-group/types.d.ts +7 -3
- package/dist/components/tool-call/index.vue +12 -12
- package/dist/components/tool-call/types.d.ts +1 -1
- package/dist/components/tooltip/index.d.vue.ts +2 -2
- package/dist/components/tooltip/index.vue +4 -3
- package/dist/components/tour/index.d.vue.ts +3 -3
- package/dist/components/tour/index.vue +48 -30
- package/dist/components/tour/types.d.ts +5 -2
- package/dist/components/tree/index.d.vue.ts +7 -2
- package/dist/components/tree/index.vue +55 -15
- package/dist/components/tree/types.d.ts +6 -1
- package/dist/components/virtual-list/index.d.vue.ts +6 -4
- package/dist/components/virtual-list/index.vue +37 -11
- package/dist/components/virtual-list/types.d.ts +2 -2
- package/dist/composables/_internal/use-agent-change.d.ts +3 -0
- package/dist/composables/_internal/use-agent-change.js +11 -0
- package/dist/composables/_internal/use-agent-node.d.ts +6 -0
- package/dist/composables/_internal/use-agent-node.js +21 -0
- package/dist/composables/_internal/use-change-details.d.ts +12 -0
- package/dist/composables/_internal/use-change-details.js +107 -0
- package/dist/composables/_internal/use-code-highlight.d.ts +7 -4
- package/dist/composables/_internal/use-code-highlight.js +39 -16
- package/dist/composables/_internal/use-dialog-layer.d.ts +25 -0
- package/dist/composables/_internal/use-dialog-layer.js +197 -0
- package/dist/composables/_internal/use-field-attrs.d.ts +4 -0
- package/dist/composables/_internal/use-field-attrs.js +33 -0
- package/dist/composables/_internal/use-focus-trap.d.ts +4 -3
- package/dist/composables/_internal/use-focus-trap.js +24 -15
- package/dist/composables/_internal/use-form-control.d.ts +22 -0
- package/dist/composables/_internal/use-form-control.js +14 -0
- package/dist/composables/_internal/use-forward-ref-expose.d.ts +1 -1
- package/dist/composables/_internal/use-forward-ref-expose.js +1 -1
- package/dist/composables/_internal/use-list-keyboard-controller.d.ts +1 -1
- package/dist/composables/_internal/use-list-keyboard-controller.js +1 -1
- package/dist/composables/_internal/use-list-navigation.d.ts +1 -2
- package/dist/composables/_internal/use-list-navigation.js +1 -2
- package/dist/composables/_internal/use-list-rows.d.ts +0 -2
- package/dist/composables/_internal/use-list-rows.js +0 -17
- package/dist/composables/_internal/use-list-search.d.ts +5 -2
- package/dist/composables/_internal/use-list-search.js +3 -4
- package/dist/composables/_internal/use-list-selection.d.ts +9 -8
- package/dist/composables/_internal/use-list-selection.js +22 -13
- package/dist/composables/_internal/use-loading-bar-progress.d.ts +21 -0
- package/dist/composables/_internal/use-loading-bar-progress.js +112 -0
- package/dist/composables/_internal/use-mention-editor.d.ts +5 -1
- package/dist/composables/_internal/use-mention-editor.js +83 -3
- package/dist/composables/_internal/use-mention-suggest.js +2 -1
- package/dist/composables/_internal/use-message-group.d.ts +2 -1
- package/dist/composables/_internal/use-message-group.js +52 -22
- package/dist/composables/_internal/use-model-commit.d.ts +7 -0
- package/dist/composables/_internal/use-model-commit.js +23 -0
- package/dist/composables/_internal/use-model-ref.d.ts +16 -0
- package/dist/composables/_internal/use-model-ref.js +14 -0
- package/dist/composables/_internal/use-model-value.d.ts +6 -14
- package/dist/composables/_internal/use-model-value.js +25 -10
- package/dist/composables/_internal/use-overlay-manager.d.ts +7 -14
- package/dist/composables/_internal/use-overlay-manager.js +32 -23
- package/dist/composables/_internal/use-popup-engine.d.ts +72 -0
- package/dist/composables/_internal/use-popup-engine.js +642 -0
- package/dist/composables/_internal/use-remote-search.d.ts +5 -2
- package/dist/composables/_internal/use-remote-search.js +17 -4
- package/dist/composables/_internal/use-selected-list-item.d.ts +1 -1
- package/dist/composables/_internal/use-selected-list-item.js +1 -2
- package/dist/composables/_internal/use-swipe-dismiss.d.ts +16 -0
- package/dist/composables/_internal/use-swipe-dismiss.js +193 -0
- package/dist/composables/_internal/use-swipe-gesture.d.ts +3 -1
- package/dist/composables/_internal/use-swipe-gesture.js +11 -6
- package/dist/composables/_internal/use-top-layer.d.ts +11 -0
- package/dist/composables/_internal/use-top-layer.js +30 -0
- package/dist/composables/_internal/use-tour-target.d.ts +1 -1
- package/dist/composables/_internal/use-tour-target.js +1 -2
- package/dist/composables/_internal/use-tree.d.ts +6 -2
- package/dist/composables/_internal/use-tree.js +3 -4
- package/dist/composables/_internal/use-word-limit.d.ts +1 -2
- package/dist/composables/_internal/use-word-limit.js +1 -2
- package/dist/composables/index.d.ts +4 -0
- package/dist/composables/index.js +4 -0
- package/dist/composables/use-color-scheme.js +1 -1
- package/dist/composables/use-countdown.d.ts +22 -15
- package/dist/composables/use-countdown.js +34 -29
- package/dist/composables/use-deferred-value.d.ts +1 -2
- package/dist/composables/use-deferred-value.js +1 -2
- package/dist/composables/use-delay-change.d.ts +1 -2
- package/dist/composables/use-delay-change.js +1 -2
- package/dist/composables/use-delay-destroy.d.ts +2 -2
- package/dist/composables/use-delay-destroy.js +23 -12
- package/dist/composables/use-details-collapse.d.ts +14 -0
- package/dist/composables/use-details-collapse.js +94 -0
- package/dist/composables/use-form-item.d.ts +2 -0
- package/dist/composables/use-form-item.js +4 -0
- package/dist/composables/use-form.d.ts +2 -0
- package/dist/composables/use-form.js +349 -0
- package/dist/composables/use-hold.d.ts +22 -0
- package/dist/composables/use-hold.js +109 -0
- package/dist/composables/use-intersection-observer.d.ts +1 -1
- package/dist/composables/use-intersection-observer.js +1 -1
- package/dist/composables/use-media-query.js +8 -3
- package/dist/composables/use-message.d.ts +3 -3
- package/dist/composables/use-message.js +3 -3
- package/dist/composables/use-mutation-observer.d.ts +1 -1
- package/dist/composables/use-mutation-observer.js +1 -1
- package/dist/composables/use-outside-click.d.ts +2 -1
- package/dist/composables/use-outside-click.js +1 -2
- package/dist/composables/use-repeat-action.d.ts +2 -1
- package/dist/composables/use-repeat-action.js +1 -2
- package/dist/composables/use-resize-observer.d.ts +1 -1
- package/dist/composables/use-scrollspy.d.ts +1 -2
- package/dist/composables/use-scrollspy.js +1 -2
- package/dist/composables/use-stick-to-bottom.d.ts +2 -2
- package/dist/composables/use-stick-to-bottom.js +9 -10
- package/dist/composables/use-view-transition.js +3 -8
- package/dist/composables/use-virtual-list.d.ts +2 -2
- package/dist/composables/use-virtual-list.js +7 -3
- package/dist/constants/focus.d.ts +1 -0
- package/dist/constants/focus.js +9 -0
- package/dist/constants/popover-panel.d.ts +1 -0
- package/dist/constants/popover-panel.js +1 -0
- package/dist/constants/size.d.ts +7 -0
- package/dist/constants/size.js +7 -0
- package/dist/constants/variant-colors.d.ts +7 -0
- package/dist/constants/variant-colors.js +7 -0
- package/dist/contexts/checkbox.d.ts +1 -0
- package/dist/contexts/choicebox.d.ts +1 -0
- package/dist/contexts/form.d.ts +3 -0
- package/dist/contexts/form.js +6 -0
- package/dist/contexts/radio.d.ts +1 -0
- package/dist/contexts/switch.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/locales/en-us.d.ts +26 -0
- package/dist/locales/en-us.js +27 -1
- package/dist/locales/zh-cn.d.ts +26 -0
- package/dist/locales/zh-cn.js +27 -1
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +38 -56
- package/dist/types/components/button.d.ts +3 -0
- package/dist/types/shared/change.d.ts +23 -0
- package/dist/types/shared/change.js +0 -0
- package/dist/types/shared/form.d.ts +109 -0
- package/dist/types/shared/form.js +0 -0
- package/dist/types/shared/props.d.ts +6 -1
- package/dist/types/shared/utils.d.ts +1 -5
- package/dist/utils/_internal/form-path.d.ts +6 -0
- package/dist/utils/_internal/form-path.js +42 -0
- package/dist/utils/_internal/image-cropper.d.ts +43 -0
- package/dist/utils/_internal/image-cropper.js +320 -0
- package/dist/utils/_internal/observer.d.ts +1 -2
- package/dist/utils/_internal/observer.js +1 -2
- package/dist/utils/_internal/promise.d.ts +5 -0
- package/dist/utils/_internal/promise.js +12 -0
- package/dist/utils/_internal/slider.d.ts +8 -0
- package/dist/utils/_internal/slider.js +15 -0
- package/dist/utils/dom.d.ts +1 -7
- package/dist/utils/dom.js +42 -25
- package/dist/utils/helper.d.ts +1 -9
- package/dist/utils/helper.js +1 -16
- package/dist/utils/is.d.ts +0 -2
- package/dist/utils/is.js +4 -10
- package/dist/utils/mention-html.d.ts +49 -2
- package/dist/utils/mention-html.js +211 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +28 -14
- package/volar.d.ts +6 -2
- package/dist/components/teleport/index.vue +0 -96
- package/dist/components/teleport/types.d.ts +0 -9
- package/dist/composables/_internal/use-details-collapse.d.ts +0 -8
- package/dist/composables/_internal/use-details-collapse.js +0 -93
- package/dist/composables/_internal/use-overlay-dialog.d.ts +0 -25
- package/dist/composables/_internal/use-overlay-dialog.js +0 -23
- package/dist/composables/_internal/use-popover-responsive.d.ts +0 -10
- package/dist/composables/_internal/use-popover-responsive.js +0 -18
- package/dist/utils/_internal/mention-html.d.ts +0 -66
- package/dist/utils/_internal/mention-html.js +0 -176
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { computed, nextTick, onScopeDispose, ref, shallowRef, toRaw, toValue, watch } from "vue";
|
|
2
|
+
import { formatPath, getPath, matchesPath, setPath } from "../utils/_internal/form-path.js";
|
|
3
|
+
const DEFAULT_VALIDATE_ON = ["blur", "change"];
|
|
4
|
+
const DEFAULT_DEBOUNCE = 300;
|
|
5
|
+
function clone(value) {
|
|
6
|
+
return structuredClone(toRaw(value));
|
|
7
|
+
}
|
|
8
|
+
function issuesToErrors(issues) {
|
|
9
|
+
return issues.map((issue) => ({
|
|
10
|
+
name: (issue.path ?? []).map((segment) => typeof segment === "object" ? segment.key : segment).join("."),
|
|
11
|
+
message: issue.message
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function dedupe(list) {
|
|
15
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16
|
+
return list.filter((error) => {
|
|
17
|
+
const key = `${formatPath(error.name)}\0${error.message}`;
|
|
18
|
+
if (seen.has(key)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
seen.add(key);
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function useForm(options) {
|
|
26
|
+
const validateOn = options.validateOn ?? DEFAULT_VALIDATE_ON;
|
|
27
|
+
const debounce = options.debounce ?? DEFAULT_DEBOUNCE;
|
|
28
|
+
const errors = ref([]);
|
|
29
|
+
const isValidating = ref(false);
|
|
30
|
+
const isDirty = ref(false);
|
|
31
|
+
const isSubmitted = ref(false);
|
|
32
|
+
const output = shallowRef();
|
|
33
|
+
const hasOutput = ref(false);
|
|
34
|
+
const touched = ref([]);
|
|
35
|
+
const itemNames = ref([]);
|
|
36
|
+
const items = /* @__PURE__ */ new Map();
|
|
37
|
+
const lastRunByName = /* @__PURE__ */ new Map();
|
|
38
|
+
let initial = clone(
|
|
39
|
+
options.initialValues == null ? toValue(options.model) : toValue(options.initialValues)
|
|
40
|
+
);
|
|
41
|
+
let sequence = 0;
|
|
42
|
+
let epoch = 0;
|
|
43
|
+
let outputRun = 0;
|
|
44
|
+
let pending = 0;
|
|
45
|
+
let timer;
|
|
46
|
+
let isResetting = false;
|
|
47
|
+
let isSettingInitial = false;
|
|
48
|
+
let submitPromise;
|
|
49
|
+
const fieldErrors = computed(() => {
|
|
50
|
+
const map = {};
|
|
51
|
+
for (const error of errors.value) {
|
|
52
|
+
const key = formatPath(error.name);
|
|
53
|
+
if (!map[key]) {
|
|
54
|
+
map[key] = [];
|
|
55
|
+
}
|
|
56
|
+
map[key].push(error.message);
|
|
57
|
+
}
|
|
58
|
+
return map;
|
|
59
|
+
});
|
|
60
|
+
const isValid = computed(() => errors.value.length === 0);
|
|
61
|
+
const unmatchedErrors = computed(
|
|
62
|
+
() => errors.value.filter((error) => !itemNames.value.includes(formatPath(error.name)))
|
|
63
|
+
);
|
|
64
|
+
function notifyValidate(payload) {
|
|
65
|
+
options.onValidate?.(payload);
|
|
66
|
+
}
|
|
67
|
+
function clearTimer() {
|
|
68
|
+
if (timer) {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
timer = void 0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function schedule() {
|
|
74
|
+
clearTimer();
|
|
75
|
+
timer = setTimeout(() => {
|
|
76
|
+
void validate();
|
|
77
|
+
}, debounce);
|
|
78
|
+
}
|
|
79
|
+
function markTouched(name) {
|
|
80
|
+
const key = formatPath(name);
|
|
81
|
+
if (!touched.value.includes(key)) {
|
|
82
|
+
touched.value = [...touched.value, key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function isTouched(name) {
|
|
86
|
+
return touched.value.includes(formatPath(name));
|
|
87
|
+
}
|
|
88
|
+
function getFieldErrors(name) {
|
|
89
|
+
return fieldErrors.value[formatPath(name)] ?? [];
|
|
90
|
+
}
|
|
91
|
+
function registerItem(item) {
|
|
92
|
+
const key = formatPath(item.name);
|
|
93
|
+
items.set(key, item);
|
|
94
|
+
if (!itemNames.value.includes(key)) {
|
|
95
|
+
itemNames.value = [...itemNames.value, key];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function unregisterItem(name) {
|
|
99
|
+
const key = formatPath(name);
|
|
100
|
+
items.delete(key);
|
|
101
|
+
itemNames.value = itemNames.value.filter((entry) => entry !== key);
|
|
102
|
+
clearErrors(key);
|
|
103
|
+
}
|
|
104
|
+
function applyErrors(next, runId, names, runEpoch) {
|
|
105
|
+
if (runEpoch !== epoch) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const scope = new Set(
|
|
109
|
+
names ?? [
|
|
110
|
+
...items.keys(),
|
|
111
|
+
...lastRunByName.keys(),
|
|
112
|
+
...next.map((error) => formatPath(error.name))
|
|
113
|
+
]
|
|
114
|
+
);
|
|
115
|
+
const owned = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const key of scope) {
|
|
117
|
+
if (runId >= (lastRunByName.get(key) ?? 0)) {
|
|
118
|
+
lastRunByName.set(key, runId);
|
|
119
|
+
owned.add(key);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const fresh = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const error of next) {
|
|
124
|
+
const key = formatPath(error.name);
|
|
125
|
+
if (!owned.has(key)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const list = fresh.get(key) ?? [];
|
|
129
|
+
list.push(error);
|
|
130
|
+
fresh.set(key, list);
|
|
131
|
+
}
|
|
132
|
+
errors.value = [
|
|
133
|
+
...errors.value.filter((error) => !owned.has(formatPath(error.name))),
|
|
134
|
+
...[...fresh.values()].flat()
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
async function runSchema(target, runId, runEpoch) {
|
|
138
|
+
const schema = options.schema == null ? void 0 : toValue(options.schema);
|
|
139
|
+
if (!schema) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const result = await schema["~standard"].validate(toValue(options.model));
|
|
143
|
+
if (result.issues) {
|
|
144
|
+
target.push(...issuesToErrors(result.issues));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (runEpoch === epoch && runId >= outputRun) {
|
|
148
|
+
output.value = result.value;
|
|
149
|
+
hasOutput.value = true;
|
|
150
|
+
outputRun = runId;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function runCustom(target) {
|
|
154
|
+
if (!options.validate) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
target.push(...await options.validate(toValue(options.model)));
|
|
158
|
+
}
|
|
159
|
+
async function runFieldRules(name, target) {
|
|
160
|
+
const registration = items.get(name);
|
|
161
|
+
const schema = registration?.rules == null ? void 0 : toValue(registration.rules);
|
|
162
|
+
if (!schema) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const result = await schema["~standard"].validate(getPath(toValue(options.model), name));
|
|
166
|
+
if (result.issues) {
|
|
167
|
+
target.push(...issuesToErrors(result.issues).map((error) => ({ ...error, name })));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async function validateAll() {
|
|
171
|
+
const runId = ++sequence;
|
|
172
|
+
const runEpoch = epoch;
|
|
173
|
+
pending++;
|
|
174
|
+
isValidating.value = true;
|
|
175
|
+
try {
|
|
176
|
+
const next = [];
|
|
177
|
+
await runSchema(next, runId, runEpoch);
|
|
178
|
+
await runCustom(next);
|
|
179
|
+
for (const [name, registration] of items) {
|
|
180
|
+
if (registration.rules) {
|
|
181
|
+
await runFieldRules(name, next);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
applyErrors(dedupe(next), runId, void 0, runEpoch);
|
|
185
|
+
if (runEpoch !== epoch) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
notifyValidate({ valid: errors.value.length === 0, errors: [...errors.value] });
|
|
189
|
+
return errors.value.length === 0;
|
|
190
|
+
} finally {
|
|
191
|
+
pending--;
|
|
192
|
+
isValidating.value = pending > 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function validateField(name) {
|
|
196
|
+
const key = formatPath(name);
|
|
197
|
+
const runId = ++sequence;
|
|
198
|
+
const runEpoch = epoch;
|
|
199
|
+
pending++;
|
|
200
|
+
isValidating.value = true;
|
|
201
|
+
try {
|
|
202
|
+
const next = [];
|
|
203
|
+
const registration = items.get(key);
|
|
204
|
+
const fieldSchema = registration?.rules == null ? void 0 : toValue(registration.rules);
|
|
205
|
+
if (fieldSchema) {
|
|
206
|
+
await runFieldRules(key, next);
|
|
207
|
+
}
|
|
208
|
+
await runSchema(next, runId, runEpoch);
|
|
209
|
+
await runCustom(next);
|
|
210
|
+
const filtered = next.filter((error) => matchesPath(error.name, key));
|
|
211
|
+
const scope = [key, ...filtered.map((error) => formatPath(error.name))];
|
|
212
|
+
applyErrors(dedupe(filtered), runId, [...new Set(scope)], runEpoch);
|
|
213
|
+
if (runEpoch !== epoch) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
const valid = errors.value.every((error) => !matchesPath(error.name, key));
|
|
217
|
+
notifyValidate({ name: key, valid, errors: [...errors.value] });
|
|
218
|
+
return valid;
|
|
219
|
+
} finally {
|
|
220
|
+
pending--;
|
|
221
|
+
isValidating.value = pending > 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function validate(...names) {
|
|
225
|
+
if (!names.length) {
|
|
226
|
+
return validateAll();
|
|
227
|
+
}
|
|
228
|
+
if (names.length === 1) {
|
|
229
|
+
return validateField(names[0]);
|
|
230
|
+
}
|
|
231
|
+
return Promise.all(names.map((name) => validateField(name))).then(
|
|
232
|
+
(results) => results.every(Boolean)
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function submit() {
|
|
236
|
+
if (!submitPromise) {
|
|
237
|
+
submitPromise = runSubmit().finally(() => {
|
|
238
|
+
submitPromise = void 0;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return submitPromise;
|
|
242
|
+
}
|
|
243
|
+
async function runSubmit() {
|
|
244
|
+
isSubmitted.value = true;
|
|
245
|
+
clearTimer();
|
|
246
|
+
const valid = await validateAll();
|
|
247
|
+
if (!valid) {
|
|
248
|
+
return { valid: false, errors: [...errors.value] };
|
|
249
|
+
}
|
|
250
|
+
const data = hasOutput.value ? output.value : clone(toValue(options.model));
|
|
251
|
+
return { valid: true, data, errors: [] };
|
|
252
|
+
}
|
|
253
|
+
function reset(name) {
|
|
254
|
+
epoch++;
|
|
255
|
+
outputRun = 0;
|
|
256
|
+
output.value = void 0;
|
|
257
|
+
hasOutput.value = false;
|
|
258
|
+
isResetting = true;
|
|
259
|
+
const model = toValue(options.model);
|
|
260
|
+
if (name == null) {
|
|
261
|
+
const snapshot = clone(initial);
|
|
262
|
+
for (const key of Object.keys(model)) {
|
|
263
|
+
delete model[key];
|
|
264
|
+
}
|
|
265
|
+
Object.assign(model, snapshot);
|
|
266
|
+
touched.value = [];
|
|
267
|
+
errors.value = [];
|
|
268
|
+
isSubmitted.value = false;
|
|
269
|
+
isDirty.value = false;
|
|
270
|
+
} else {
|
|
271
|
+
const key = formatPath(name);
|
|
272
|
+
setPath(model, name, clone(getPath(initial, name)));
|
|
273
|
+
touched.value = touched.value.filter((entry) => !matchesPath(entry, key));
|
|
274
|
+
errors.value = errors.value.filter((error) => !matchesPath(error.name, key));
|
|
275
|
+
}
|
|
276
|
+
void nextTick(() => {
|
|
277
|
+
isResetting = false;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function setInitialValues(values) {
|
|
281
|
+
isSettingInitial = true;
|
|
282
|
+
initial = clone(values ?? toValue(options.model));
|
|
283
|
+
isDirty.value = false;
|
|
284
|
+
void nextTick(() => {
|
|
285
|
+
isSettingInitial = false;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function setErrors(next) {
|
|
289
|
+
epoch++;
|
|
290
|
+
const normalized = dedupe(next.map((error) => ({ ...error, name: formatPath(error.name) })));
|
|
291
|
+
errors.value = normalized;
|
|
292
|
+
for (const error of normalized) {
|
|
293
|
+
markTouched(error.name);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function clearErrors(name) {
|
|
297
|
+
epoch++;
|
|
298
|
+
if (name == null) {
|
|
299
|
+
errors.value = [];
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const key = formatPath(name);
|
|
303
|
+
errors.value = errors.value.filter((error) => !matchesPath(error.name, key));
|
|
304
|
+
}
|
|
305
|
+
watch(
|
|
306
|
+
() => toValue(options.model),
|
|
307
|
+
() => {
|
|
308
|
+
if (isResetting) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
isDirty.value = !isSettingInitial;
|
|
312
|
+
if (validateOn.includes("change")) {
|
|
313
|
+
schedule();
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
{ deep: true }
|
|
317
|
+
);
|
|
318
|
+
watch(
|
|
319
|
+
() => options.schema == null ? void 0 : toValue(options.schema),
|
|
320
|
+
() => {
|
|
321
|
+
epoch++;
|
|
322
|
+
outputRun = 0;
|
|
323
|
+
errors.value = [];
|
|
324
|
+
output.value = void 0;
|
|
325
|
+
hasOutput.value = false;
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
onScopeDispose(clearTimer);
|
|
329
|
+
return {
|
|
330
|
+
errors,
|
|
331
|
+
unmatchedErrors,
|
|
332
|
+
isValidating,
|
|
333
|
+
isValid,
|
|
334
|
+
isDirty,
|
|
335
|
+
isSubmitted,
|
|
336
|
+
validate,
|
|
337
|
+
validateField,
|
|
338
|
+
submit,
|
|
339
|
+
reset,
|
|
340
|
+
setInitialValues,
|
|
341
|
+
setErrors,
|
|
342
|
+
clearErrors,
|
|
343
|
+
getFieldErrors,
|
|
344
|
+
isTouched,
|
|
345
|
+
markTouched,
|
|
346
|
+
registerItem,
|
|
347
|
+
unregisterItem
|
|
348
|
+
};
|
|
349
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export type HoldStatus = 'idle' | 'loading' | 'confirmed' | 'canceled';
|
|
3
|
+
export interface HoldOptions {
|
|
4
|
+
/** Hold duration in milliseconds. @default 2000 */
|
|
5
|
+
duration?: MaybeRefOrGetter<number | undefined>;
|
|
6
|
+
/** @default true */
|
|
7
|
+
enabled?: MaybeRefOrGetter<boolean | undefined>;
|
|
8
|
+
/** Called once the hold reaches the duration. */
|
|
9
|
+
onConfirm?: () => void;
|
|
10
|
+
/** Called when the hold ends before it reaches the duration. */
|
|
11
|
+
onCancel?: (progress: number) => void;
|
|
12
|
+
}
|
|
13
|
+
interface Results {
|
|
14
|
+
status: Readonly<Ref<HoldStatus>>;
|
|
15
|
+
progress: Readonly<Ref<number>>;
|
|
16
|
+
start: () => void;
|
|
17
|
+
pause: () => void;
|
|
18
|
+
resume: () => void;
|
|
19
|
+
stop: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function useHold(options?: HoldOptions): Results;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { onScopeDispose, shallowRef, toValue } from "vue";
|
|
2
|
+
import { caf, off, on, raf } from "../utils/event.js";
|
|
3
|
+
import { isServer } from "../utils/is.js";
|
|
4
|
+
const DEFAULT_DURATION = 2e3;
|
|
5
|
+
const HIDDEN_TICK = 50;
|
|
6
|
+
export function useHold(options = {}) {
|
|
7
|
+
const status = shallowRef("idle");
|
|
8
|
+
const progress = shallowRef(0);
|
|
9
|
+
let frameId = 0;
|
|
10
|
+
let timer;
|
|
11
|
+
let held = 0;
|
|
12
|
+
let lastFrameAt = 0;
|
|
13
|
+
const isEnabled = () => toValue(options.enabled) ?? true;
|
|
14
|
+
function getDuration() {
|
|
15
|
+
const duration = toValue(options.duration);
|
|
16
|
+
return duration && duration > 0 ? duration : DEFAULT_DURATION;
|
|
17
|
+
}
|
|
18
|
+
function stopProgress() {
|
|
19
|
+
if (frameId) {
|
|
20
|
+
caf(frameId);
|
|
21
|
+
frameId = 0;
|
|
22
|
+
}
|
|
23
|
+
if (timer) {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
timer = void 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function scheduleProgress() {
|
|
29
|
+
if (!isServer() && document.hidden) {
|
|
30
|
+
timer = setTimeout(updateProgress, HIDDEN_TICK);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
frameId = raf(updateProgress);
|
|
34
|
+
}
|
|
35
|
+
function startProgress() {
|
|
36
|
+
lastFrameAt = Date.now();
|
|
37
|
+
if (!frameId && !timer) {
|
|
38
|
+
scheduleProgress();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function updateProgress() {
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
const duration = getDuration();
|
|
44
|
+
frameId = 0;
|
|
45
|
+
timer = void 0;
|
|
46
|
+
held += now - lastFrameAt;
|
|
47
|
+
lastFrameAt = now;
|
|
48
|
+
if (held >= duration) {
|
|
49
|
+
progress.value = 1;
|
|
50
|
+
status.value = "confirmed";
|
|
51
|
+
options.onConfirm?.();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
progress.value = held / duration;
|
|
55
|
+
scheduleProgress();
|
|
56
|
+
}
|
|
57
|
+
function onVisibilityChange() {
|
|
58
|
+
if (status.value !== "loading") {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
stopProgress();
|
|
62
|
+
scheduleProgress();
|
|
63
|
+
}
|
|
64
|
+
function start() {
|
|
65
|
+
if (!isEnabled()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
held = 0;
|
|
69
|
+
progress.value = 0;
|
|
70
|
+
status.value = "loading";
|
|
71
|
+
startProgress();
|
|
72
|
+
}
|
|
73
|
+
function pause() {
|
|
74
|
+
if (status.value !== "loading") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
stopProgress();
|
|
78
|
+
status.value = "canceled";
|
|
79
|
+
}
|
|
80
|
+
function resume() {
|
|
81
|
+
if (status.value !== "canceled") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
status.value = "loading";
|
|
85
|
+
startProgress();
|
|
86
|
+
}
|
|
87
|
+
function stop() {
|
|
88
|
+
const heldProgress = progress.value;
|
|
89
|
+
const wasActive = status.value !== "idle";
|
|
90
|
+
const confirmed = status.value === "confirmed";
|
|
91
|
+
stopProgress();
|
|
92
|
+
held = 0;
|
|
93
|
+
progress.value = 0;
|
|
94
|
+
status.value = "idle";
|
|
95
|
+
if (wasActive && !confirmed) {
|
|
96
|
+
options.onCancel?.(heldProgress);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!isServer()) {
|
|
100
|
+
on(document, "visibilitychange", onVisibilityChange);
|
|
101
|
+
}
|
|
102
|
+
onScopeDispose(() => {
|
|
103
|
+
stopProgress();
|
|
104
|
+
if (!isServer()) {
|
|
105
|
+
off(document, "visibilitychange", onVisibilityChange);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return { status, progress, start, pause, resume, stop };
|
|
109
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from '../types/shared/utils';
|
|
2
1
|
import type { ObserverResults, TargetRef } from '../utils/_internal/observer.js';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
3
|
export declare const useIntersectionObserver: (target: TargetRef, callback: (items: Array<{
|
|
4
4
|
entry: IntersectionObserverEntry;
|
|
5
5
|
target: HTMLElement;
|
|
@@ -16,7 +16,7 @@ function normalize(options) {
|
|
|
16
16
|
if (!options) {
|
|
17
17
|
return "null|0px|0";
|
|
18
18
|
}
|
|
19
|
-
const threshold = Array.isArray(options.threshold) ?
|
|
19
|
+
const threshold = Array.isArray(options.threshold) ? options.threshold.toSorted((a, b) => a - b).join(",") : String(options.threshold ?? 0);
|
|
20
20
|
return `${getRootId(options.root)}|${options.rootMargin ?? "0px"}|${threshold}`;
|
|
21
21
|
}
|
|
22
22
|
const spec = {
|
|
@@ -16,7 +16,7 @@ export const PRESET_MEDIA_QUERIES = {
|
|
|
16
16
|
XL_UP: "(width >= 80rem)",
|
|
17
17
|
XXL_UP: "(width >= 96rem)"
|
|
18
18
|
};
|
|
19
|
-
const CACHED_QUERIES =
|
|
19
|
+
const CACHED_QUERIES = /* @__PURE__ */ new Map();
|
|
20
20
|
function createEntry(condition) {
|
|
21
21
|
const query = window.matchMedia(condition);
|
|
22
22
|
const matches = shallowRef(query.matches);
|
|
@@ -38,7 +38,12 @@ export function useMediaQuery(condition, callback) {
|
|
|
38
38
|
if (isServer()) {
|
|
39
39
|
return shallowRef(false);
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
let cached = CACHED_QUERIES.get(condition);
|
|
42
|
+
if (!cached) {
|
|
43
|
+
cached = createEntry(condition);
|
|
44
|
+
CACHED_QUERIES.set(condition, cached);
|
|
45
|
+
}
|
|
46
|
+
const entry = cached;
|
|
42
47
|
const handler = callback ? () => callback(entry.query) : null;
|
|
43
48
|
entry.count++;
|
|
44
49
|
if (handler) {
|
|
@@ -52,7 +57,7 @@ export function useMediaQuery(condition, callback) {
|
|
|
52
57
|
return;
|
|
53
58
|
}
|
|
54
59
|
entry.unbind();
|
|
55
|
-
delete
|
|
60
|
+
CACHED_QUERIES.delete(condition);
|
|
56
61
|
});
|
|
57
62
|
return entry.matches;
|
|
58
63
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ButtonVariant } from '../types/components/button';
|
|
2
2
|
import type { ComponentClass } from '../types/shared/props';
|
|
3
3
|
import type { VNode } from 'vue';
|
|
4
4
|
type MessageContent = string | VNode;
|
|
5
5
|
type PromiseMessageHandler = MessageContent | ((data: unknown) => MessageContent);
|
|
6
6
|
interface Action {
|
|
7
7
|
label?: string;
|
|
8
|
-
variant?:
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
9
|
onClick?: () => void;
|
|
10
10
|
}
|
|
11
11
|
interface Options {
|
|
12
12
|
id?: string | number;
|
|
13
|
-
|
|
13
|
+
variant?: 'info' | 'success' | 'warning' | 'error' | 'loading' | '' | false | undefined;
|
|
14
14
|
class?: ComponentClass;
|
|
15
15
|
group?: string;
|
|
16
16
|
action?: Action;
|
|
@@ -20,9 +20,9 @@ export const useMessage = ((msg, options) => {
|
|
|
20
20
|
);
|
|
21
21
|
});
|
|
22
22
|
const shortcutTypes = ["info", "error", "loading", "warning", "success"];
|
|
23
|
-
shortcutTypes.forEach((
|
|
24
|
-
useMessage[
|
|
25
|
-
useMessage(msg, { ...options,
|
|
23
|
+
shortcutTypes.forEach((variant) => {
|
|
24
|
+
useMessage[variant] = (msg, options) => {
|
|
25
|
+
useMessage(msg, { ...options, variant });
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
28
|
export function closeMessage(group, id) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from '../types/shared/utils';
|
|
2
1
|
import type { ObserverResults, TargetRef } from '../utils/_internal/observer.js';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
3
|
export declare const useMutationObserver: (target: TargetRef, callback: (items: Array<{
|
|
4
4
|
entry: MutationRecord;
|
|
5
5
|
target: HTMLElement;
|
|
@@ -4,7 +4,7 @@ function normalize(options) {
|
|
|
4
4
|
if (!options) {
|
|
5
5
|
return "";
|
|
6
6
|
}
|
|
7
|
-
const filter = options.attributeFilter ?
|
|
7
|
+
const filter = options.attributeFilter ? options.attributeFilter.toSorted().join(",") : "";
|
|
8
8
|
return [
|
|
9
9
|
options.attributes ?? false,
|
|
10
10
|
filter,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { MaybeElementRef
|
|
1
|
+
import type { MaybeElementRef } from '../types/shared/utils';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
2
3
|
interface Options<E extends Event = PointerEvent> {
|
|
3
4
|
allowList?: MaybeElementRef<HTMLElement>[];
|
|
4
5
|
eventName?: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { onScopeDispose, watch } from "vue";
|
|
1
|
+
import { onScopeDispose, watch, toValue } from "vue";
|
|
2
2
|
import { cachedOff, cachedOn } from "../utils/event.js";
|
|
3
|
-
import { toValue } from "../utils/helper.js";
|
|
4
3
|
import { isServer } from "../utils/is.js";
|
|
5
4
|
export function useOutsideClick(container, options = {}) {
|
|
6
5
|
function onClick(ev) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from '../types/shared/utils';
|
|
2
1
|
import type { ObserverResults, TargetRef } from '../utils/_internal/observer.js';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
3
|
export declare const useResizeObserver: (target: TargetRef, callback: (items: Array<{
|
|
4
4
|
entry: ResizeObserverEntry;
|
|
5
5
|
target: HTMLElement;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from '
|
|
2
|
-
import type { ShallowRef } from 'vue';
|
|
1
|
+
import type { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
2
|
export interface UseScrollspyOptions {
|
|
4
3
|
/** Scrollable container. @default window */
|
|
5
4
|
scrollTarget?: MaybeRefOrGetter<Window | HTMLElement | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, onMounted, onScopeDispose, shallowRef, watch } from "vue";
|
|
1
|
+
import { computed, onMounted, onScopeDispose, shallowRef, watch, toValue } from "vue";
|
|
2
2
|
import {
|
|
3
3
|
getScrollElement,
|
|
4
4
|
getScrollListener,
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
isViewportScroll
|
|
7
7
|
} from "../utils/dom.js";
|
|
8
8
|
import { off, on, scheduleByRaf } from "../utils/event.js";
|
|
9
|
-
import { toValue } from "../utils/helper.js";
|
|
10
9
|
import { isServer } from "../utils/is.js";
|
|
11
10
|
import { useResizeObserver } from "./use-resize-observer.js";
|
|
12
11
|
const BOTTOM_TOLERANCE = 2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Nullable
|
|
2
|
-
import type { ShallowRef } from 'vue';
|
|
1
|
+
import type { Nullable } from '../types/shared/utils';
|
|
2
|
+
import type { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
3
|
export interface UseStickToBottomOptions {
|
|
4
4
|
threshold?: MaybeRefOrGetter<number>;
|
|
5
5
|
enabled?: MaybeRefOrGetter<boolean>;
|