pxd 0.1.2 → 0.1.4
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/dist/components/_internal/calendar-day.vue +19 -19
- package/dist/components/_internal/dismiss-container.d.vue.ts +1 -1
- package/dist/components/_internal/dismiss-container.vue +20 -20
- package/dist/components/_internal/loading-mask.vue +9 -1
- package/dist/components/_internal/mention-editor.vue +3 -3
- package/dist/components/_internal/popover-arrow.d.vue.ts +1 -1
- package/dist/components/_internal/popover-arrow.vue +1 -1
- package/dist/components/{steps → _internal}/step-item.d.vue.ts +1 -1
- package/dist/components/{steps → _internal}/step-item.vue +2 -2
- package/dist/components/_internal/tree-node.d.vue.ts +23 -20
- package/dist/components/_internal/tree-node.vue +68 -51
- package/dist/components/active-graph/index.d.vue.ts +2 -2
- package/dist/components/active-graph/index.vue +1 -1
- package/dist/components/approval-card/index.d.vue.ts +1 -1
- package/dist/components/approval-card/index.vue +34 -17
- package/dist/components/approval-card/types.d.ts +1 -1
- package/dist/components/avatar/index.vue +2 -2
- package/dist/components/backtop/index.d.vue.ts +3 -3
- package/dist/components/backtop/index.vue +17 -17
- package/dist/components/backtop/types.d.ts +1 -1
- package/dist/components/badge/index.d.vue.ts +3 -3
- package/dist/components/badge/index.vue +45 -45
- package/dist/components/badge/types.d.ts +1 -1
- package/dist/components/book/types.d.ts +1 -1
- package/dist/components/border-beam/index.vue +1 -1
- package/dist/components/border-beam/types.d.ts +1 -1
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.vue +6 -6
- package/dist/components/bubble-group/index.d.vue.ts +4 -4
- package/dist/components/button/index.d.vue.ts +4 -4
- package/dist/components/button/index.vue +18 -17
- package/dist/components/button/types.d.ts +2 -2
- package/dist/components/button-group/types.d.ts +2 -2
- package/dist/components/calendar/index.d.vue.ts +2 -2
- package/dist/components/calendar/index.vue +10 -10
- package/dist/components/calendar/types.d.ts +1 -1
- package/dist/components/card/index.vue +2 -2
- package/dist/components/card/types.d.ts +1 -1
- package/dist/components/carousel/index.d.vue.ts +6 -7
- package/dist/components/carousel/index.vue +23 -18
- package/dist/components/carousel/types.d.ts +1 -2
- package/dist/components/checkbox/index.vue +2 -2
- package/dist/components/checkbox/types.d.ts +1 -1
- package/dist/components/checkbox-group/index.d.vue.ts +2 -2
- package/dist/components/checkbox-group/types.d.ts +1 -1
- package/dist/components/chip/index.d.vue.ts +1 -1
- package/dist/components/chip/types.d.ts +1 -1
- package/dist/components/choicebox/index.d.vue.ts +3 -3
- package/dist/components/choicebox/types.d.ts +1 -1
- package/dist/components/choicebox-item/index.vue +10 -10
- package/dist/components/choicebox-item/types.d.ts +1 -1
- package/dist/components/code-block/index.d.vue.ts +22 -0
- package/dist/components/code-block/index.vue +166 -0
- package/dist/components/code-block/types.d.ts +14 -0
- package/dist/components/collapse/index.vue +2 -2
- package/dist/components/collapse-group/index.vue +1 -1
- package/dist/components/collapse-group/types.d.ts +1 -1
- package/dist/components/command-menu/index.d.vue.ts +4 -4
- package/dist/components/command-menu/index.vue +11 -5
- package/dist/components/config-provider/index.d.vue.ts +44 -5
- package/dist/components/config-provider/types.d.ts +2 -1
- package/dist/components/confirm-popover/index.d.vue.ts +38 -0
- package/dist/components/confirm-popover/index.vue +203 -0
- package/dist/components/confirm-popover/types.d.ts +25 -0
- package/dist/components/copy-button/index.d.vue.ts +2 -6
- package/dist/components/copy-button/index.vue +4 -10
- package/dist/components/dash-line/index.d.vue.ts +1 -1
- package/dist/components/dash-line/index.vue +8 -8
- package/dist/components/dash-line/types.d.ts +1 -1
- package/dist/components/date-picker/index.d.vue.ts +1 -1
- package/dist/components/date-picker/index.vue +4 -4
- package/dist/components/date-picker/types.d.ts +1 -1
- package/dist/components/description/index.vue +1 -1
- package/dist/components/drawer/index.d.vue.ts +10 -10
- package/dist/components/drawer/index.vue +36 -27
- package/dist/components/drawer/types.d.ts +2 -2
- package/dist/components/effort-slider/index.vue +12 -18
- package/dist/components/effort-slider/types.d.ts +1 -1
- package/dist/components/ellipsis-text/index.d.vue.ts +2 -2
- package/dist/components/ellipsis-text/index.vue +76 -76
- package/dist/components/error/index.vue +2 -2
- package/dist/components/error/types.d.ts +1 -1
- package/dist/components/fader/index.vue +2 -2
- package/dist/components/fader/types.d.ts +1 -1
- package/dist/components/gauge/index.vue +2 -2
- package/dist/components/gauge/types.d.ts +1 -1
- package/dist/components/grid/types.d.ts +1 -1
- package/dist/components/grid-item/types.d.ts +1 -1
- package/dist/components/hint/index.d.vue.ts +32 -0
- package/dist/components/hint/index.vue +239 -0
- package/dist/components/hint/types.d.ts +17 -0
- package/dist/components/hold-button/index.d.vue.ts +4 -4
- package/dist/components/hold-button/index.vue +10 -10
- package/dist/components/image-preview/index.d.vue.ts +38 -0
- package/dist/components/image-preview/index.vue +351 -0
- package/dist/components/image-preview/types.d.ts +18 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +6 -0
- package/dist/components/input/index.d.vue.ts +1 -1
- package/dist/components/input/index.vue +19 -11
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/intersection-observer/index.vue +3 -3
- package/dist/components/kbd/index.vue +3 -3
- package/dist/components/kbd/types.d.ts +1 -1
- package/dist/components/link-button/index.d.vue.ts +5 -5
- package/dist/components/list/index.d.vue.ts +4 -4
- package/dist/components/list/index.vue +126 -47
- package/dist/components/list/types.d.ts +1 -1
- package/dist/components/list-group/index.vue +7 -1
- package/dist/components/list-group/types.d.ts +1 -1
- package/dist/components/list-item/index.d.vue.ts +2 -2
- package/dist/components/list-item/index.vue +42 -11
- package/dist/components/loading-bar/index.vue +5 -5
- package/dist/components/marching-ants/index.d.vue.ts +2 -2
- package/dist/components/marching-ants/index.vue +56 -56
- package/dist/components/marching-ants/types.d.ts +1 -1
- package/dist/components/marquee/index.d.vue.ts +6 -6
- package/dist/components/marquee/index.vue +22 -18
- package/dist/components/marquee/types.d.ts +1 -1
- package/dist/components/material/index.d.vue.ts +3 -3
- package/dist/components/mention/index.d.vue.ts +4 -4
- package/dist/components/mention/index.vue +68 -68
- package/dist/components/menu/index.d.vue.ts +4 -4
- package/dist/components/menu/index.vue +10 -10
- package/dist/components/menu/types.d.ts +1 -1
- package/dist/components/message/index.d.vue.ts +1 -1
- package/dist/components/message/index.vue +20 -26
- package/dist/components/message/types.d.ts +1 -1
- package/dist/components/message-item/index.vue +2 -6
- package/dist/components/modal/index.d.vue.ts +9 -9
- package/dist/components/modal/index.vue +32 -23
- package/dist/components/modal/types.d.ts +2 -2
- package/dist/components/noise-background/types.d.ts +1 -1
- package/dist/components/note/index.vue +7 -3
- package/dist/components/note/types.d.ts +2 -1
- package/dist/components/number-input/index.d.vue.ts +11 -6
- package/dist/components/number-input/index.vue +61 -20
- package/dist/components/number-input/types.d.ts +2 -1
- package/dist/components/overlay/index.d.vue.ts +2 -4
- package/dist/components/overlay/index.vue +12 -70
- package/dist/components/overlay/types.d.ts +1 -4
- package/dist/components/page-number/index.vue +30 -29
- package/dist/components/page-number/types.d.ts +1 -1
- package/dist/components/pagination/index.vue +4 -4
- package/dist/components/pin-input/index.vue +11 -7
- package/dist/components/pin-input/types.d.ts +1 -1
- package/dist/components/popover/index.vue +72 -39
- package/dist/components/popover/types.d.ts +4 -1
- package/dist/components/progress/index.d.vue.ts +2 -2
- package/dist/components/progress/index.vue +12 -12
- package/dist/components/progress/types.d.ts +1 -1
- package/dist/components/project-banner/index.vue +22 -9
- package/dist/components/project-banner/types.d.ts +1 -1
- package/dist/components/questionnaire/index.vue +15 -15
- package/dist/components/radio/index.vue +1 -1
- package/dist/components/radio/types.d.ts +1 -1
- package/dist/components/radio-group/index.d.vue.ts +2 -2
- package/dist/components/radio-group/types.d.ts +1 -1
- package/dist/components/rating/index.vue +28 -28
- package/dist/components/rating/types.d.ts +1 -1
- package/dist/components/resizable/index.d.vue.ts +6 -0
- package/dist/components/resizable/index.vue +320 -236
- package/dist/components/resizable/types.d.ts +8 -10
- package/dist/components/reveal/index.d.vue.ts +3 -3
- package/dist/components/reveal/index.vue +4 -4
- package/dist/components/reveal/types.d.ts +1 -1
- package/dist/components/rolling-number/index.d.vue.ts +2 -2
- package/dist/components/rolling-number/index.vue +15 -15
- package/dist/components/scalable-text/index.vue +9 -9
- package/dist/components/scroll-text/index.d.vue.ts +3 -3
- package/dist/components/scroll-text/index.vue +6 -6
- package/dist/components/scroll-text/types.d.ts +1 -1
- package/dist/components/scrollable/types.d.ts +2 -1
- package/dist/components/search-input/index.d.vue.ts +5 -5
- package/dist/components/search-input/index.vue +2 -1
- package/dist/components/select/index.d.vue.ts +12 -9
- package/dist/components/select/index.vue +167 -42
- package/dist/components/select/types.d.ts +3 -1
- package/dist/components/separator/index.d.vue.ts +1 -1
- package/dist/components/separator/types.d.ts +1 -1
- package/dist/components/skeleton/index.vue +11 -11
- package/dist/components/skeleton/types.d.ts +1 -1
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue +1 -1
- package/dist/components/slider/types.d.ts +1 -1
- package/dist/components/snippet/index.d.vue.ts +3 -3
- package/dist/components/snippet/index.vue +7 -5
- package/dist/components/snippet/types.d.ts +1 -1
- package/dist/components/spinner/index.vue +5 -1
- package/dist/components/spinner-dots/index.d.vue.ts +1 -1
- package/dist/components/split-button/index.d.vue.ts +5 -5
- package/dist/components/split-button/types.d.ts +1 -1
- package/dist/components/stack/index.d.vue.ts +3 -3
- package/dist/components/stack/index.vue +28 -29
- package/dist/components/stack/types.d.ts +1 -1
- package/dist/components/status-dot/types.d.ts +1 -1
- package/dist/components/steps/index.d.vue.ts +2 -2
- package/dist/components/steps/index.vue +6 -6
- package/dist/components/steps/types.d.ts +1 -1
- package/dist/components/stick-to-bottom/types.d.ts +1 -1
- package/dist/components/swipe-cell/index.d.vue.ts +6 -6
- package/dist/components/swipe-cell/index.vue +64 -64
- package/dist/components/swipe-cell/types.d.ts +2 -1
- package/dist/components/switch/index.vue +2 -2
- package/dist/components/switch/types.d.ts +1 -1
- package/dist/components/switch-item/index.vue +1 -1
- package/dist/components/switch-item/types.d.ts +1 -1
- package/dist/components/tabs/index.d.vue.ts +1 -1
- package/dist/components/tabs/index.vue +49 -52
- package/dist/components/tabs/types.d.ts +1 -1
- package/dist/components/teleport/index.vue +22 -24
- package/dist/components/text/index.d.vue.ts +3 -3
- package/dist/components/text/index.vue +11 -11
- package/dist/components/text/types.d.ts +1 -1
- package/dist/components/textarea/index.vue +2 -1
- package/dist/components/textarea/types.d.ts +1 -1
- package/dist/components/theme-switcher/index.d.vue.ts +3 -2
- package/dist/components/theme-switcher/index.vue +15 -7
- package/dist/components/theme-switcher/types.d.ts +2 -2
- package/dist/components/time-ago/index.d.vue.ts +6 -0
- package/dist/components/time-ago/index.vue +143 -0
- package/dist/components/time-ago/types.d.ts +4 -0
- package/dist/components/time-picker/index.d.vue.ts +1 -1
- package/dist/components/time-picker/index.vue +11 -11
- package/dist/components/time-picker/types.d.ts +1 -1
- package/dist/components/toc/index.d.vue.ts +2 -2
- package/dist/components/toc/index.vue +1 -1
- package/dist/components/todo-list/index.d.vue.ts +5 -5
- package/dist/components/todo-list/index.vue +15 -15
- package/dist/components/todo-list/types.d.ts +1 -1
- package/dist/components/toggle/index.vue +4 -4
- package/dist/components/toggle/types.d.ts +1 -1
- package/dist/components/toggle-button/index.vue +24 -15
- package/dist/components/toggle-button/types.d.ts +4 -3
- package/dist/components/toggle-button-group/index.d.vue.ts +3 -3
- package/dist/components/toggle-button-group/index.vue +3 -2
- package/dist/components/toggle-button-group/types.d.ts +4 -4
- package/dist/components/tool-call/index.vue +5 -5
- package/dist/components/tooltip/index.d.vue.ts +4 -5
- package/dist/components/tooltip/index.vue +4 -49
- package/dist/components/tooltip/types.d.ts +3 -7
- package/dist/components/tour/index.d.vue.ts +33 -0
- package/dist/components/tour/index.vue +302 -0
- package/dist/components/tour/types.d.ts +29 -0
- package/dist/components/tree/index.d.vue.ts +33 -34
- package/dist/components/tree/index.vue +385 -293
- package/dist/components/tree/types.d.ts +42 -13
- package/dist/components/virtual-list/index.d.vue.ts +4 -4
- package/dist/composables/_internal/use-code-highlight.d.ts +12 -0
- package/dist/composables/_internal/use-code-highlight.js +47 -0
- package/dist/composables/_internal/use-list-keyboard-controller.js +9 -10
- package/dist/composables/_internal/use-list-rows.d.ts +4 -0
- package/dist/composables/_internal/use-list-rows.js +12 -4
- package/dist/composables/_internal/use-list-selection.d.ts +1 -1
- package/dist/composables/_internal/use-lock-scroll.d.ts +8 -1
- package/dist/composables/_internal/use-lock-scroll.js +39 -35
- package/dist/composables/_internal/use-mention-editor.js +1 -1
- package/dist/composables/_internal/use-message-group.d.ts +22 -0
- package/dist/composables/_internal/use-message-group.js +143 -0
- package/dist/composables/_internal/use-overlay-dialog.js +1 -3
- package/dist/composables/_internal/use-overlay-manager.d.ts +4 -2
- package/dist/composables/_internal/use-overlay-manager.js +53 -10
- package/dist/composables/_internal/use-popover-responsive.js +9 -12
- package/dist/composables/_internal/use-swipe-gesture.d.ts +2 -2
- package/dist/composables/_internal/use-swipe-gesture.js +5 -4
- package/dist/composables/_internal/use-tailwind-variant.js +1 -1
- package/dist/composables/_internal/use-tour-target.d.ts +29 -0
- package/dist/composables/_internal/use-tour-target.js +201 -0
- package/dist/composables/_internal/use-tree.d.ts +103 -0
- package/dist/composables/_internal/use-tree.js +676 -0
- package/dist/composables/_internal/use-word-limit.d.ts +1 -1
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-color-scheme.d.ts +1 -1
- package/dist/composables/use-color-scheme.js +7 -6
- package/dist/composables/use-delay-destroy.d.ts +1 -1
- package/dist/composables/use-document-hidden.d.ts +1 -1
- 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.d.ts +3 -1
- package/dist/composables/use-media-query.js +33 -51
- package/dist/composables/{_internal/use-motion-reduce.js → use-motion-reduce.js} +2 -2
- 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 +3 -7
- package/dist/composables/use-repeat-action.d.ts +1 -1
- package/dist/composables/use-repeat-action.js +3 -3
- package/dist/composables/use-resize-observer.d.ts +1 -1
- package/dist/composables/use-resize-observer.js +1 -1
- package/dist/composables/use-view-transition.js +1 -0
- package/dist/composables/use-virtual-list.d.ts +1 -1
- package/dist/constants/size.d.ts +1 -0
- package/dist/constants/size.js +7 -6
- package/dist/constants/tooltip-variants.d.ts +28 -0
- package/dist/constants/tooltip-variants.js +27 -0
- package/dist/contexts/avatar.js +1 -1
- package/dist/contexts/breadcrumb.js +1 -1
- package/dist/contexts/button.js +1 -1
- package/dist/contexts/checkbox.js +1 -1
- package/dist/contexts/choicebox.js +1 -1
- package/dist/contexts/collapse.js +1 -1
- package/dist/contexts/config-provider.js +1 -1
- package/dist/contexts/list.js +1 -1
- package/dist/contexts/radio.js +1 -1
- package/dist/contexts/switch.js +1 -1
- package/dist/contexts/toggle-button.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/locales/en-us.d.ts +39 -0
- package/dist/locales/en-us.js +24 -0
- package/dist/locales/zh-cn.d.ts +39 -0
- package/dist/locales/zh-cn.js +24 -0
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +55 -37
- package/dist/utils/_internal/cn-tables.d.ts +27 -0
- package/dist/utils/_internal/cn-tables.js +131 -0
- package/dist/utils/{context.js → _internal/context.js} +1 -1
- package/dist/utils/{observer.d.ts → _internal/observer.d.ts} +1 -1
- package/dist/utils/{observer.js → _internal/observer.js} +4 -4
- package/dist/{components/swipe-cell/instances.d.ts → utils/_internal/swipe-cell-instances.d.ts} +1 -1
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/event.d.ts +2 -1
- package/dist/utils/event.js +3 -0
- package/package.json +29 -51
- package/volar.d.ts +6 -0
- package/dist/components/message/composables/use-group-expand.d.ts +0 -13
- package/dist/components/message/composables/use-group-expand.js +0 -50
- package/dist/components/message/composables/use-message-timer.d.ts +0 -9
- package/dist/components/message/composables/use-message-timer.js +0 -62
- package/dist/components/message/composables/use-promise-message.d.ts +0 -4
- package/dist/components/message/composables/use-promise-message.js +0 -49
- package/dist/components/resizable/utils.d.ts +0 -4
- package/dist/components/resizable/utils.js +0 -10
- package/dist/composables/_internal/use-tree-drag.d.ts +0 -23
- package/dist/composables/_internal/use-tree-drag.js +0 -196
- package/dist/composables/_internal/use-tree-move.d.ts +0 -20
- package/dist/composables/_internal/use-tree-move.js +0 -96
- package/dist/composables/_internal/use-tree-rows.d.ts +0 -46
- package/dist/composables/_internal/use-tree-rows.js +0 -101
- package/dist/composables/_internal/use-tree-selection.d.ts +0 -22
- package/dist/composables/_internal/use-tree-selection.js +0 -87
- package/dist/styles/source.css +0 -675
- package/dist/types/shared/index.d.ts +0 -2
- /package/dist/composables/{_internal/use-motion-reduce.d.ts → use-motion-reduce.d.ts} +0 -0
- /package/dist/utils/{context.d.ts → _internal/context.d.ts} +0 -0
- /package/dist/utils/{mention-html.d.ts → _internal/mention-html.d.ts} +0 -0
- /package/dist/utils/{mention-html.js → _internal/mention-html.js} +0 -0
- /package/dist/{components/swipe-cell/instances.js → utils/_internal/swipe-cell-instances.js} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, shallowRef, watch } from "vue";
|
|
2
|
+
import { computed, onMounted, shallowRef, watch } from "vue";
|
|
3
3
|
import { useModelValue } from "../../composables/_internal/use-model-value.js";
|
|
4
|
+
import { useResizeObserver } from "../../composables/use-resize-observer.js";
|
|
4
5
|
import { throttleByRaf } from "../../utils/event.js";
|
|
6
|
+
import { clampValue } from "../../utils/format.js";
|
|
5
7
|
import { getUniqueId } from "../../utils/helper.js";
|
|
6
8
|
import { isNil } from "../../utils/is.js";
|
|
7
|
-
import { clamp, PERCENT_TOTAL, roundSize, toPair } from "./utils";
|
|
8
9
|
defineOptions({
|
|
9
10
|
name: "PResizable",
|
|
10
11
|
inheritAttrs: false,
|
|
@@ -19,11 +20,31 @@ const props = defineProps({
|
|
|
19
20
|
required: false,
|
|
20
21
|
default: "horizontal"
|
|
21
22
|
},
|
|
23
|
+
unit: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: false,
|
|
26
|
+
default: "percent"
|
|
27
|
+
},
|
|
28
|
+
reverse: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
required: false,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
22
33
|
minSize: {
|
|
23
34
|
type: Array,
|
|
24
35
|
required: false,
|
|
25
36
|
default: () => [0, 0]
|
|
26
37
|
},
|
|
38
|
+
collapsed: {
|
|
39
|
+
type: [Boolean, null],
|
|
40
|
+
required: false,
|
|
41
|
+
default: null
|
|
42
|
+
},
|
|
43
|
+
dblclickAction: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: false,
|
|
46
|
+
default: "reset"
|
|
47
|
+
},
|
|
27
48
|
handle: {
|
|
28
49
|
type: Boolean,
|
|
29
50
|
required: false,
|
|
@@ -48,313 +69,382 @@ const props = defineProps({
|
|
|
48
69
|
const emits = defineEmits([
|
|
49
70
|
"change",
|
|
50
71
|
"reset",
|
|
72
|
+
"update:collapsed",
|
|
51
73
|
"update:modelValue"
|
|
52
74
|
]);
|
|
75
|
+
const PERCENT_TOTAL = 100;
|
|
76
|
+
const KEYBOARD_STEP = 1;
|
|
77
|
+
const KEYBOARD_STEP_LARGE = 10;
|
|
78
|
+
const UNFOLD_DISTANCE = 10;
|
|
53
79
|
const uid = getUniqueId("pxd-resizable");
|
|
80
|
+
const leadingId = `${uid}-leading`;
|
|
81
|
+
const trailingId = `${uid}-trailing`;
|
|
82
|
+
let drag = null;
|
|
83
|
+
const flushResize = throttleByRaf(flushPointer);
|
|
54
84
|
const containerRef = shallowRef();
|
|
55
85
|
const handleRef = shallowRef();
|
|
56
|
-
const
|
|
57
|
-
const isControlled = computed(() => !isNil(props.modelValue));
|
|
86
|
+
const containerSize = shallowRef(0);
|
|
58
87
|
const innerSizes = shallowRef(toPair(props.defaultValue));
|
|
59
|
-
const
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
const innerCollapsed = shallowRef(false);
|
|
89
|
+
/** Pointer position in `unit` during a drag; unclamped so a leftward overshoot is not swallowed. */
|
|
90
|
+
const dragPointer = shallowRef(null);
|
|
91
|
+
const dragCollapsed = shallowRef(false);
|
|
92
|
+
/** Leading size to restore when a folded panel is expanded without dragging. */
|
|
93
|
+
const foldedFrom = shallowRef(null);
|
|
94
|
+
const isControlled = computed(() => !isNil(props.modelValue));
|
|
95
|
+
const isPixel = computed(() => props.unit === "px");
|
|
96
|
+
/** `reverse` only means anything where a panel fills the rest, i.e. under `px`. */
|
|
97
|
+
const isReversed = computed(() => isPixel.value && props.reverse);
|
|
98
|
+
/** Percent sizes are measured against 100; pixel sizes fill the measured container. */
|
|
99
|
+
const totalSize = computed(() => isPixel.value ? containerSize.value : PERCENT_TOTAL);
|
|
100
|
+
/** Under `px` only the pinned panel's size comes from the caller. */
|
|
101
|
+
const sizes = computed(() => {
|
|
102
|
+
const [leading, trailing] = toPair(isControlled.value ? props.modelValue : innerSizes.value);
|
|
103
|
+
const total = totalSize.value;
|
|
104
|
+
if (isReversed.value) {
|
|
105
|
+
return [Math.max(total - trailing, 0), trailing];
|
|
106
|
+
}
|
|
107
|
+
return isPixel.value ? [leading, Math.max(total - leading, 0)] : [leading, trailing];
|
|
108
|
+
});
|
|
65
109
|
const bounds = computed(() => {
|
|
66
110
|
const [leading, trailing] = toPair(props.minSize);
|
|
67
|
-
|
|
111
|
+
const total = totalSize.value;
|
|
112
|
+
if (total <= 0) {
|
|
113
|
+
return {
|
|
114
|
+
min: sizes.value[0],
|
|
115
|
+
max: sizes.value[0]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (leading + trailing > total) {
|
|
68
119
|
return {
|
|
69
120
|
min: 0,
|
|
70
|
-
max:
|
|
121
|
+
max: total
|
|
71
122
|
};
|
|
72
123
|
}
|
|
73
124
|
return {
|
|
74
125
|
min: leading,
|
|
75
|
-
max:
|
|
126
|
+
max: total - trailing
|
|
76
127
|
};
|
|
77
128
|
});
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
129
|
+
const collapsed = computed(() => dragPointer.value === null ? props.collapsed ?? innerCollapsed.value : dragCollapsed.value);
|
|
130
|
+
/** The bound the divider parks against while folded. */
|
|
131
|
+
const foldedLeading = computed(() => isReversed.value ? bounds.value.max : bounds.value.min);
|
|
132
|
+
/** Half of the pinned floor; a panel without a floor has nothing to fold past. */
|
|
133
|
+
const foldThreshold = computed(() => (isReversed.value ? totalSize.value - bounds.value.max : bounds.value.min) / 2);
|
|
134
|
+
const renderedSizes = computed(() => {
|
|
135
|
+
if (collapsed.value) {
|
|
136
|
+
return foldedPair();
|
|
137
|
+
}
|
|
138
|
+
if (dragPointer.value === null) {
|
|
139
|
+
return sizes.value;
|
|
140
|
+
}
|
|
141
|
+
const { min, max } = bounds.value;
|
|
142
|
+
const pointer = isReversed.value ? Math.min(dragPointer.value, max) : Math.max(dragPointer.value, min);
|
|
143
|
+
return pairFrom(pointer);
|
|
90
144
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
145
|
+
/** The pair the panel slots are handed, updated only when a change settles. */
|
|
146
|
+
const settledSizes = shallowRef(renderedSizes.value);
|
|
147
|
+
const unitSuffix = computed(() => isPixel.value ? "px" : "%");
|
|
148
|
+
/** An empty panel puts the divider on a container edge, where a line is just residue. */
|
|
149
|
+
const isFlush = computed(() => renderedSizes.value[0] <= 0 || renderedSizes.value[1] <= 0);
|
|
150
|
+
const ariaValueNow = computed(() => roundSize(renderedSizes.value[0]));
|
|
151
|
+
const ariaValueText = computed(() => `${ariaValueNow.value}${unitSuffix.value}`);
|
|
152
|
+
/** Folded, the divider is out of the tab order and cannot move, so it exposes no value range. */
|
|
153
|
+
const separatorRange = computed(() => collapsed.value ? {} : {
|
|
154
|
+
"aria-valuenow": ariaValueNow.value,
|
|
155
|
+
"aria-valuemin": bounds.value.min,
|
|
156
|
+
"aria-valuemax": bounds.value.max,
|
|
157
|
+
"aria-valuetext": ariaValueText.value
|
|
158
|
+
});
|
|
159
|
+
const modelValue = useModelValue(props, emits, { withChange: false });
|
|
160
|
+
useResizeObserver(containerRef, syncContainerSize);
|
|
161
|
+
function roundSize(value) {
|
|
162
|
+
return Math.round(value * 100) / 100;
|
|
163
|
+
}
|
|
164
|
+
/** Pixel distance as the group's `unit`. */
|
|
165
|
+
function toUnit(px) {
|
|
166
|
+
if (isPixel.value) {
|
|
167
|
+
return px;
|
|
96
168
|
}
|
|
169
|
+
return containerSize.value > 0 ? px / containerSize.value * PERCENT_TOTAL : 0;
|
|
170
|
+
}
|
|
171
|
+
function toPair(value) {
|
|
172
|
+
return [value?.[0] ?? 0, value?.[1] ?? 0];
|
|
173
|
+
}
|
|
174
|
+
function pairFrom(leading) {
|
|
175
|
+
const next = roundSize(leading);
|
|
176
|
+
return [next, roundSize(Math.max(totalSize.value - next, 0))];
|
|
177
|
+
}
|
|
178
|
+
function foldedPair() {
|
|
179
|
+
const total = roundSize(totalSize.value);
|
|
180
|
+
return isReversed.value ? [total, 0] : [0, total];
|
|
181
|
+
}
|
|
182
|
+
function writeSizes(next) {
|
|
97
183
|
if (!isControlled.value) {
|
|
98
|
-
innerSizes.value =
|
|
184
|
+
innerSizes.value = next;
|
|
99
185
|
}
|
|
100
|
-
modelValue.value =
|
|
101
|
-
return true;
|
|
186
|
+
modelValue.value = next;
|
|
102
187
|
}
|
|
103
|
-
function
|
|
104
|
-
const [
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const applied = clamp(deltaPercent, min - leading, max - leading);
|
|
109
|
-
if (applied === 0) {
|
|
188
|
+
function setSizes([leading, trailing]) {
|
|
189
|
+
const [currentLeading, currentTrailing] = sizes.value;
|
|
190
|
+
const nextLeading = roundSize(leading);
|
|
191
|
+
const next = isPixel.value ? pairFrom(nextLeading) : [nextLeading, roundSize(trailing)];
|
|
192
|
+
if (next[0] === currentLeading && next[1] === currentTrailing) {
|
|
110
193
|
return false;
|
|
111
194
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const newLeading = roundSize(leading + applied);
|
|
115
|
-
return setSizes([newLeading, roundSize(leading + trailing - newLeading)]);
|
|
195
|
+
writeSizes(next);
|
|
196
|
+
return true;
|
|
116
197
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*/
|
|
122
|
-
function applyDelta(deltaPercent) {
|
|
123
|
-
const changed = resize(deltaPercent);
|
|
124
|
-
if (changed && collapsed.value) {
|
|
125
|
-
collapsed.value = false;
|
|
126
|
-
expandedPair = null;
|
|
198
|
+
function foldLeading(from) {
|
|
199
|
+
foldedFrom.value = from;
|
|
200
|
+
if (isNil(props.collapsed)) {
|
|
201
|
+
innerCollapsed.value = true;
|
|
127
202
|
}
|
|
128
|
-
|
|
203
|
+
emits("update:collapsed", true);
|
|
204
|
+
return setSizes(foldedPair());
|
|
129
205
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
|
|
206
|
+
function clearFold(wasCollapsed) {
|
|
207
|
+
foldedFrom.value = null;
|
|
208
|
+
if (isNil(props.collapsed)) {
|
|
209
|
+
innerCollapsed.value = false;
|
|
134
210
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return false;
|
|
211
|
+
if (wasCollapsed) {
|
|
212
|
+
emits("update:collapsed", false);
|
|
138
213
|
}
|
|
139
|
-
return applyDelta(delta / containerSize * PERCENT_TOTAL);
|
|
140
214
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
215
|
+
function expandLeading() {
|
|
216
|
+
const wasCollapsed = collapsed.value;
|
|
217
|
+
const { min, max } = bounds.value;
|
|
218
|
+
const changed = setSizes(pairFrom(clampValue(foldedFrom.value ?? sizes.value[0], min, max)));
|
|
219
|
+
clearFold(wasCollapsed);
|
|
220
|
+
return changed;
|
|
143
221
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
222
|
+
function reset() {
|
|
223
|
+
const wasCollapsed = collapsed.value;
|
|
224
|
+
const { min, max } = bounds.value;
|
|
225
|
+
const configured = toPair(props.defaultValue);
|
|
226
|
+
const target = isReversed.value ? totalSize.value - configured[1] : configured[0];
|
|
227
|
+
const next = pairFrom(clampValue(target, min, max));
|
|
228
|
+
const changed = setSizes(next);
|
|
229
|
+
clearFold(wasCollapsed);
|
|
230
|
+
if (!changed && !wasCollapsed) {
|
|
146
231
|
return;
|
|
147
232
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const restore = expandedPair ?? initialPair ?? [leading, trailing];
|
|
151
|
-
expandedPair = null;
|
|
152
|
-
collapsed.value = false;
|
|
153
|
-
if (setSizes([restore[0], restore[1]])) {
|
|
154
|
-
commitChange();
|
|
155
|
-
}
|
|
156
|
-
return;
|
|
233
|
+
if (!changed) {
|
|
234
|
+
writeSizes(next);
|
|
157
235
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
commitChange();
|
|
236
|
+
emits("reset", next);
|
|
237
|
+
}
|
|
238
|
+
function toggleFold() {
|
|
239
|
+
const changed = collapsed.value ? expandLeading() : foldLeading(sizes.value[0]);
|
|
240
|
+
if (changed) {
|
|
241
|
+
emits("change", sizes.value.slice());
|
|
165
242
|
}
|
|
166
243
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
244
|
+
function applyDelta(delta) {
|
|
245
|
+
const [leading, trailing] = sizes.value;
|
|
246
|
+
const { min, max } = bounds.value;
|
|
247
|
+
const applied = clampValue(delta, min - leading, max - leading);
|
|
248
|
+
if (applied === 0) {
|
|
249
|
+
return false;
|
|
173
250
|
}
|
|
251
|
+
const nextLeading = roundSize(leading + applied);
|
|
252
|
+
return setSizes([nextLeading, roundSize(leading + trailing - nextLeading)]);
|
|
174
253
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
254
|
+
function syncContainerSize() {
|
|
255
|
+
const container = containerRef.value;
|
|
256
|
+
if (!container) {
|
|
257
|
+
containerSize.value = 0;
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
containerSize.value = props.direction === "horizontal" ? container.offsetWidth : container.offsetHeight;
|
|
181
261
|
}
|
|
182
|
-
|
|
183
|
-
|
|
262
|
+
function flushPointer() {
|
|
263
|
+
const current = dragPointer.value;
|
|
264
|
+
if (!drag || current === null || drag.delta === 0) {
|
|
184
265
|
return;
|
|
185
266
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
190
|
-
// The capture target is the handle itself, never `event.target`: a child element
|
|
191
|
-
// can be swapped mid-drag, which would both throw on release and strand the drag.
|
|
192
|
-
// Holding the capture also keeps the drag alive when the pointer leaves the window.
|
|
193
|
-
function releaseCapture() {
|
|
194
|
-
const id = activePointerId;
|
|
195
|
-
const el = handleRef.value;
|
|
196
|
-
activePointerId = null;
|
|
197
|
-
if (!el || id === null) {
|
|
267
|
+
const step = toUnit(drag.delta);
|
|
268
|
+
drag.delta = 0;
|
|
269
|
+
if (step === 0) {
|
|
198
270
|
return;
|
|
199
271
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
272
|
+
const { min, max } = bounds.value;
|
|
273
|
+
const next = roundSize(current + step);
|
|
274
|
+
const pointer = isReversed.value ? Math.max(next, min) : Math.min(next, max);
|
|
275
|
+
if (pointer === current) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
dragPointer.value = pointer;
|
|
279
|
+
const threshold = foldThreshold.value;
|
|
280
|
+
const folded = threshold > 0 && (isReversed.value ? totalSize.value - pointer <= threshold : pointer <= threshold);
|
|
281
|
+
if (folded !== dragCollapsed.value) {
|
|
282
|
+
dragCollapsed.value = folded;
|
|
283
|
+
foldedFrom.value = folded ? foldedLeading.value : null;
|
|
284
|
+
emits("update:collapsed", folded);
|
|
285
|
+
}
|
|
286
|
+
modelValue.value = renderedSizes.value.slice();
|
|
287
|
+
}
|
|
288
|
+
function axisOf(event) {
|
|
289
|
+
return props.direction === "horizontal" ? event.clientX : event.clientY;
|
|
203
290
|
}
|
|
204
291
|
function resetDragging() {
|
|
205
|
-
|
|
206
|
-
accumulated = 0;
|
|
207
|
-
resized = false;
|
|
292
|
+
const pointerId = drag?.pointerId;
|
|
208
293
|
flushResize.cancel();
|
|
209
|
-
|
|
294
|
+
drag = null;
|
|
295
|
+
dragPointer.value = null;
|
|
296
|
+
dragCollapsed.value = false;
|
|
297
|
+
try {
|
|
298
|
+
if (pointerId !== undefined) {
|
|
299
|
+
handleRef.value?.releasePointerCapture(pointerId);
|
|
300
|
+
}
|
|
301
|
+
} catch {}
|
|
210
302
|
}
|
|
211
303
|
function handlePointerDown(event) {
|
|
212
304
|
if (props.disabled) {
|
|
213
305
|
return;
|
|
214
306
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
307
|
+
syncContainerSize();
|
|
308
|
+
const startCollapsed = collapsed.value;
|
|
309
|
+
const [startLeading, startTrailing] = renderedSizes.value;
|
|
310
|
+
const { min, max } = bounds.value;
|
|
311
|
+
const boundary = isReversed.value ? totalSize.value - foldThreshold.value : foldThreshold.value;
|
|
312
|
+
const deadZone = toUnit(UNFOLD_DISTANCE);
|
|
313
|
+
const collapsedPointer = isReversed.value ? boundary + deadZone : boundary - deadZone;
|
|
314
|
+
drag = {
|
|
315
|
+
pointerId: event.pointerId,
|
|
316
|
+
position: axisOf(event),
|
|
317
|
+
delta: 0,
|
|
318
|
+
start: [startLeading, startTrailing],
|
|
319
|
+
startCollapsed
|
|
320
|
+
};
|
|
321
|
+
// A collapsed handle parks one dead zone short of the boundary, so opening it takes a real drag.
|
|
322
|
+
dragPointer.value = startCollapsed ? Math.max(collapsedPointer, 0) : clampValue(sizes.value[0], min, max);
|
|
323
|
+
dragCollapsed.value = startCollapsed;
|
|
219
324
|
try {
|
|
220
325
|
handleRef.value?.setPointerCapture(event.pointerId);
|
|
221
326
|
} catch {}
|
|
222
327
|
}
|
|
223
328
|
function handlePointerMove(event) {
|
|
224
|
-
if (event.pointerId !==
|
|
329
|
+
if (!drag || event.pointerId !== drag.pointerId) {
|
|
225
330
|
return;
|
|
226
331
|
}
|
|
227
332
|
event.preventDefault();
|
|
228
333
|
const position = axisOf(event);
|
|
229
|
-
|
|
230
|
-
|
|
334
|
+
drag.delta += position - drag.position;
|
|
335
|
+
drag.position = position;
|
|
231
336
|
flushResize();
|
|
232
337
|
}
|
|
233
|
-
function
|
|
234
|
-
if (
|
|
338
|
+
function finishDrag(reportChange) {
|
|
339
|
+
if (!drag || dragPointer.value === null) {
|
|
235
340
|
return;
|
|
236
341
|
}
|
|
237
342
|
flushResize.cancel();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
343
|
+
flushPointer();
|
|
344
|
+
const { start, startCollapsed } = drag;
|
|
345
|
+
const folded = dragCollapsed.value;
|
|
346
|
+
const [leading, trailing] = renderedSizes.value;
|
|
347
|
+
const changed = folded !== startCollapsed || leading !== start[0] || trailing !== start[1];
|
|
348
|
+
const settled = folded ? foldedPair() : [leading, trailing];
|
|
244
349
|
resetDragging();
|
|
245
|
-
if (
|
|
246
|
-
|
|
350
|
+
if (!changed) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
foldedFrom.value = folded ? foldedLeading.value : null;
|
|
354
|
+
if (isNil(props.collapsed)) {
|
|
355
|
+
innerCollapsed.value = folded;
|
|
356
|
+
}
|
|
357
|
+
setSizes(settled);
|
|
358
|
+
if (reportChange) {
|
|
359
|
+
emits("change", settled);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function handlePointerUp(event) {
|
|
363
|
+
if (drag && event.pointerId === drag.pointerId) {
|
|
364
|
+
finishDrag(true);
|
|
247
365
|
}
|
|
248
366
|
}
|
|
249
367
|
function handlePointerCancel(event) {
|
|
250
|
-
if (event.pointerId
|
|
251
|
-
|
|
368
|
+
if (drag && event.pointerId === drag.pointerId) {
|
|
369
|
+
finishDrag(false);
|
|
252
370
|
}
|
|
253
|
-
resetDragging();
|
|
254
371
|
}
|
|
255
372
|
function handleLostCapture() {
|
|
256
|
-
if (
|
|
373
|
+
if (drag) {
|
|
374
|
+
finishDrag(false);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function handleDblclick() {
|
|
378
|
+
if (props.disabled) {
|
|
257
379
|
return;
|
|
258
380
|
}
|
|
259
|
-
|
|
381
|
+
if (props.dblclickAction === "fold") {
|
|
382
|
+
toggleFold();
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
reset();
|
|
260
386
|
}
|
|
261
|
-
const KEYBOARD_STEP = 1;
|
|
262
|
-
const KEYBOARD_STEP_LARGE = 10;
|
|
263
387
|
function handleKeydown(event) {
|
|
264
388
|
if (props.disabled) {
|
|
265
389
|
return;
|
|
266
390
|
}
|
|
267
|
-
const step = event.shiftKey ? KEYBOARD_STEP_LARGE : KEYBOARD_STEP;
|
|
268
391
|
const horizontal = props.direction === "horizontal";
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
delta = bounds.value.max - position.value;
|
|
278
|
-
}
|
|
279
|
-
if (delta === null) {
|
|
392
|
+
const back = horizontal ? "ArrowLeft" : "ArrowUp";
|
|
393
|
+
const forward = horizontal ? "ArrowRight" : "ArrowDown";
|
|
394
|
+
if (![
|
|
395
|
+
back,
|
|
396
|
+
forward,
|
|
397
|
+
"Home",
|
|
398
|
+
"End"
|
|
399
|
+
].includes(event.key)) {
|
|
280
400
|
return;
|
|
281
401
|
}
|
|
282
402
|
event.preventDefault();
|
|
283
|
-
|
|
284
|
-
|
|
403
|
+
const wasCollapsed = collapsed.value;
|
|
404
|
+
if (wasCollapsed) {
|
|
405
|
+
expandLeading();
|
|
285
406
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function warn(message) {
|
|
294
|
-
if (import.meta.env?.DEV) {
|
|
295
|
-
console.warn(`[pxd] PResizable: ${message}`);
|
|
407
|
+
const step = event.shiftKey ? KEYBOARD_STEP_LARGE : KEYBOARD_STEP;
|
|
408
|
+
const leading = sizes.value[0];
|
|
409
|
+
let delta = event.key === back ? -step : step;
|
|
410
|
+
if (event.key === "Home") {
|
|
411
|
+
delta = bounds.value.min - leading;
|
|
412
|
+
} else if (event.key === "End") {
|
|
413
|
+
delta = bounds.value.max - leading;
|
|
296
414
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const total = roundSize(value[0] + value[1]);
|
|
300
|
-
if (Math.abs(total - PERCENT_TOTAL) > .01) {
|
|
301
|
-
warn(`${name} adds up to ${total}% instead of ${PERCENT_TOTAL}%; the panels keep the sizes they were given.`);
|
|
415
|
+
if (applyDelta(delta) || wasCollapsed) {
|
|
416
|
+
emits("change", sizes.value.slice());
|
|
302
417
|
}
|
|
303
418
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
props.modelValue,
|
|
309
|
-
props.minSize,
|
|
310
|
-
props.defaultValue
|
|
311
|
-
], () => {
|
|
312
|
-
if (!import.meta.env?.DEV) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const mins = toPair(props.minSize);
|
|
316
|
-
if (props.minSize.length !== 2) {
|
|
317
|
-
warnLength("min-size", props.minSize);
|
|
419
|
+
/** Only the pinned panel of a pixel group gets a basis; the other one fills. */
|
|
420
|
+
function panelStyle(index) {
|
|
421
|
+
if (isPixel.value && index === (isReversed.value ? 0 : 1)) {
|
|
422
|
+
return {};
|
|
318
423
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
424
|
+
return { flexBasis: `${renderedSizes.value[index]}${unitSuffix.value}` };
|
|
425
|
+
}
|
|
426
|
+
/** A panel clipped to nothing is gone for focus and AT, not just for the eye. */
|
|
427
|
+
function isPanelEmpty(index) {
|
|
428
|
+
return renderedSizes.value[index] <= 0 || undefined;
|
|
429
|
+
}
|
|
430
|
+
watch(renderedSizes, (value) => {
|
|
431
|
+
if (dragPointer.value === null) {
|
|
432
|
+
settledSizes.value = value;
|
|
323
433
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (value.length !== 2) {
|
|
329
|
-
warnLength(name, value);
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
warnSum(name, [value[0], value[1]]);
|
|
434
|
+
});
|
|
435
|
+
watch(() => props.collapsed, (next, prev) => {
|
|
436
|
+
if (isNil(props.collapsed) || dragPointer.value !== null) {
|
|
437
|
+
return;
|
|
333
438
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (
|
|
337
|
-
|
|
439
|
+
if (next === true && sizes.value[0] !== 0) {
|
|
440
|
+
foldLeading(sizes.value[0]);
|
|
441
|
+
} else if (prev === true) {
|
|
442
|
+
expandLeading();
|
|
338
443
|
}
|
|
339
|
-
}, {
|
|
340
|
-
immediate: true,
|
|
341
|
-
flush: "post"
|
|
342
444
|
});
|
|
343
|
-
|
|
344
|
-
const ariaValueNow = computed(() => roundSize(position.value));
|
|
345
|
-
// A bare number is announced as "30" - no unit, and nothing about the fold.
|
|
346
|
-
// valuetext is the only place a separator can put either, since it has no
|
|
347
|
-
// aria-expanded to lean on.
|
|
348
|
-
const ariaValueText = computed(() => collapsed.value ? `${ariaValueNow.value}%, folded` : `${ariaValueNow.value}%`);
|
|
349
|
-
function panelStyle(index) {
|
|
350
|
-
return {
|
|
351
|
-
flexBasis: `${sizes.value[index]}%`,
|
|
352
|
-
flexGrow: 0,
|
|
353
|
-
flexShrink: 1
|
|
354
|
-
};
|
|
355
|
-
}
|
|
445
|
+
onMounted(syncContainerSize);
|
|
356
446
|
defineExpose({
|
|
357
|
-
getPanelSizes: () =>
|
|
447
|
+
getPanelSizes: () => renderedSizes.value.slice(),
|
|
358
448
|
reset
|
|
359
449
|
});
|
|
360
450
|
</script>
|
|
@@ -364,6 +454,8 @@ defineExpose({
|
|
|
364
454
|
data-resizable
|
|
365
455
|
ref="containerRef"
|
|
366
456
|
:data-orientation="direction"
|
|
457
|
+
:data-unit="unit"
|
|
458
|
+
:data-reverse="reverse || void 0"
|
|
367
459
|
class="pxd-resizable flex size-full max-w-full flex-row overflow-hidden data-[orientation=vertical]:flex-col"
|
|
368
460
|
v-bind="$attrs"
|
|
369
461
|
>
|
|
@@ -371,53 +463,45 @@ defineExpose({
|
|
|
371
463
|
:id="leadingId"
|
|
372
464
|
class="pxd-resizable-panel min-w-0 min-h-0 overflow-hidden"
|
|
373
465
|
:style="panelStyle(0)"
|
|
466
|
+
:inert="isPanelEmpty(0)"
|
|
374
467
|
>
|
|
375
|
-
<slot name="leading" :size="
|
|
468
|
+
<slot name="leading" :size="settledSizes[0]" />
|
|
376
469
|
</div>
|
|
377
470
|
|
|
378
|
-
<!--
|
|
379
|
-
A *focusable* separator is a widget, and only that flavour may carry
|
|
380
|
-
aria-valuenow / aria-valuemin / aria-valuemax - which is why it takes a
|
|
381
|
-
tabindex and the key handler below, not just a pointer drag. aria-expanded
|
|
382
|
-
is not a separator state at any focusability: it marks control over
|
|
383
|
-
visibility, and folding a panel never hides it. The fold therefore rides
|
|
384
|
-
on aria-valuetext.
|
|
385
|
-
-->
|
|
386
471
|
<div
|
|
387
472
|
ref="handleRef"
|
|
388
473
|
role="separator"
|
|
389
|
-
:tabindex="disabled ? -1 : 0"
|
|
474
|
+
:tabindex="disabled || collapsed ? -1 : 0"
|
|
390
475
|
aria-label="Resize the panels"
|
|
391
476
|
:aria-orientation="direction"
|
|
392
|
-
|
|
393
|
-
:aria-valuemin="bounds.min"
|
|
394
|
-
:aria-valuemax="bounds.max"
|
|
395
|
-
:aria-valuetext="ariaValueText"
|
|
477
|
+
v-bind="separatorRange"
|
|
396
478
|
:aria-controls="`${leadingId} ${trailingId}`"
|
|
397
479
|
:aria-disabled="disabled || void 0"
|
|
398
480
|
:data-collapsed="collapsed || void 0"
|
|
481
|
+
:data-flush="isFlush || void 0"
|
|
399
482
|
:data-handler="handle"
|
|
400
483
|
:data-orientation="direction"
|
|
401
|
-
class="pxd-resizable-handle relative shrink-0 touch-none
|
|
402
|
-
@pointerdown
|
|
484
|
+
class="pxd-resizable-handle relative shrink-0 touch-none self-focus-ring select-none hover:after:delay-200 aria-disabled:cursor-default after:motion-safe:transition-colors"
|
|
485
|
+
@pointerdown="handlePointerDown"
|
|
403
486
|
@pointermove="handlePointerMove"
|
|
404
487
|
@pointerup="handlePointerUp"
|
|
405
488
|
@pointercancel="handlePointerCancel"
|
|
406
489
|
@lostpointercapture="handleLostCapture"
|
|
407
490
|
@keydown="handleKeydown"
|
|
408
|
-
@dblclick.prevent.stop="
|
|
491
|
+
@dblclick.prevent.stop="handleDblclick"
|
|
409
492
|
/>
|
|
410
493
|
|
|
411
494
|
<div
|
|
412
495
|
:id="trailingId"
|
|
413
496
|
class="pxd-resizable-panel min-w-0 min-h-0 overflow-hidden"
|
|
414
497
|
:style="panelStyle(1)"
|
|
498
|
+
:inert="isPanelEmpty(1)"
|
|
415
499
|
>
|
|
416
|
-
<slot name="trailing" :size="
|
|
500
|
+
<slot name="trailing" :size="settledSizes[1]" />
|
|
417
501
|
</div>
|
|
418
502
|
</div>
|
|
419
503
|
</template>
|
|
420
504
|
|
|
421
505
|
<style>
|
|
422
|
-
.pxd-resizable-handle[data-handler=true]:before{background-color:var(--color-gray-300);border-radius:.5rem;content:"";left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:1}.pxd-resizable-handle
|
|
506
|
+
.pxd-resizable-panel{flex-grow:0;flex-shrink:1}.pxd-resizable-panel[inert]{visibility:hidden}.pxd-resizable[data-unit=px] .pxd-resizable-panel:first-child{flex-shrink:0}.pxd-resizable[data-unit=px] .pxd-resizable-panel:last-child{flex-basis:0;flex-grow:1}.pxd-resizable[data-unit=px][data-reverse] .pxd-resizable-panel:first-child{flex-basis:0;flex-grow:1;flex-shrink:1}.pxd-resizable[data-unit=px][data-reverse] .pxd-resizable-panel:last-child{flex-grow:0;flex-shrink:0}.pxd-resizable-handle[data-handler=true]:before{background-color:var(--color-gray-300);border-radius:.5rem;content:"";left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:1}.pxd-resizable-handle:after{background-color:transparent;content:"";position:absolute}.pxd-resizable-handle:hover:after{background-color:var(--color-primary)}.pxd-resizable-handle[data-orientation=horizontal]{background-color:var(--color-gray-300);cursor:col-resize;height:100%;margin-right:-1px;width:1px}.pxd-resizable-handle[data-orientation=horizontal]:before{height:1.5rem;width:.375rem}.pxd-resizable-handle[data-orientation=horizontal]:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:.25rem}.pxd-resizable-handle[data-orientation=vertical]{background-color:var(--color-gray-300);cursor:row-resize;height:1px;margin-bottom:-1px;width:100%}.pxd-resizable-handle[data-orientation=vertical]:before{height:.375rem;width:1.5rem}.pxd-resizable-handle[data-orientation=vertical]:after{height:.25rem;left:0;top:50%;transform:translateY(-50%);width:100%}.pxd-resizable-handle[data-collapsed=true],.pxd-resizable-handle[data-flush=true]{background-color:transparent}.pxd-resizable-handle[data-collapsed=true]:before{opacity:.4}
|
|
423
507
|
</style>
|