akar 2.0.10 → 2.0.11
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/Collection/Collection.cjs +2 -1
- package/dist/Collection/Collection.cjs.map +1 -1
- package/dist/Collection/Collection.js +2 -1
- package/dist/Collection/Collection.js.map +1 -1
- package/dist/Drawer/DrawerClose.cjs +48 -0
- package/dist/Drawer/DrawerClose.cjs.map +1 -0
- package/dist/Drawer/DrawerClose.js +42 -0
- package/dist/Drawer/DrawerClose.js.map +1 -0
- package/dist/Drawer/DrawerContent.cjs +139 -0
- package/dist/Drawer/DrawerContent.cjs.map +1 -0
- package/dist/Drawer/DrawerContent.js +133 -0
- package/dist/Drawer/DrawerContent.js.map +1 -0
- package/dist/Drawer/DrawerContentImpl.cjs +298 -0
- package/dist/Drawer/DrawerContentImpl.cjs.map +1 -0
- package/dist/Drawer/DrawerContentImpl.js +292 -0
- package/dist/Drawer/DrawerContentImpl.js.map +1 -0
- package/dist/Drawer/DrawerDescription.cjs +45 -0
- package/dist/Drawer/DrawerDescription.cjs.map +1 -0
- package/dist/Drawer/DrawerDescription.js +39 -0
- package/dist/Drawer/DrawerDescription.js.map +1 -0
- package/dist/Drawer/DrawerHandle.cjs +48 -0
- package/dist/Drawer/DrawerHandle.cjs.map +1 -0
- package/dist/Drawer/DrawerHandle.js +42 -0
- package/dist/Drawer/DrawerHandle.js.map +1 -0
- package/dist/Drawer/DrawerIndent.cjs +78 -0
- package/dist/Drawer/DrawerIndent.cjs.map +1 -0
- package/dist/Drawer/DrawerIndent.js +72 -0
- package/dist/Drawer/DrawerIndent.js.map +1 -0
- package/dist/Drawer/DrawerIndentBackground.cjs +49 -0
- package/dist/Drawer/DrawerIndentBackground.cjs.map +1 -0
- package/dist/Drawer/DrawerIndentBackground.js +43 -0
- package/dist/Drawer/DrawerIndentBackground.js.map +1 -0
- package/dist/Drawer/DrawerOverlay.cjs +66 -0
- package/dist/Drawer/DrawerOverlay.cjs.map +1 -0
- package/dist/Drawer/DrawerOverlay.js +60 -0
- package/dist/Drawer/DrawerOverlay.js.map +1 -0
- package/dist/Drawer/DrawerOverlayImpl.cjs +69 -0
- package/dist/Drawer/DrawerOverlayImpl.cjs.map +1 -0
- package/dist/Drawer/DrawerOverlayImpl.js +63 -0
- package/dist/Drawer/DrawerOverlayImpl.js.map +1 -0
- package/dist/Drawer/DrawerPortal.cjs +47 -0
- package/dist/Drawer/DrawerPortal.cjs.map +1 -0
- package/dist/Drawer/DrawerPortal.js +41 -0
- package/dist/Drawer/DrawerPortal.js.map +1 -0
- package/dist/Drawer/DrawerProvider.cjs +82 -0
- package/dist/Drawer/DrawerProvider.cjs.map +1 -0
- package/dist/Drawer/DrawerProvider.js +70 -0
- package/dist/Drawer/DrawerProvider.js.map +1 -0
- package/dist/Drawer/DrawerRoot.cjs +197 -0
- package/dist/Drawer/DrawerRoot.cjs.map +1 -0
- package/dist/Drawer/DrawerRoot.js +185 -0
- package/dist/Drawer/DrawerRoot.js.map +1 -0
- package/dist/Drawer/DrawerSwipeArea.cjs +87 -0
- package/dist/Drawer/DrawerSwipeArea.cjs.map +1 -0
- package/dist/Drawer/DrawerSwipeArea.js +81 -0
- package/dist/Drawer/DrawerSwipeArea.js.map +1 -0
- package/dist/Drawer/DrawerTitle.cjs +45 -0
- package/dist/Drawer/DrawerTitle.cjs.map +1 -0
- package/dist/Drawer/DrawerTitle.js +39 -0
- package/dist/Drawer/DrawerTitle.js.map +1 -0
- package/dist/Drawer/DrawerTrigger.cjs +64 -0
- package/dist/Drawer/DrawerTrigger.cjs.map +1 -0
- package/dist/Drawer/DrawerTrigger.js +58 -0
- package/dist/Drawer/DrawerTrigger.js.map +1 -0
- package/dist/Drawer/DrawerViewport.cjs +49 -0
- package/dist/Drawer/DrawerViewport.cjs.map +1 -0
- package/dist/Drawer/DrawerViewport.js +43 -0
- package/dist/Drawer/DrawerViewport.js.map +1 -0
- package/dist/Drawer/utils.cjs +185 -0
- package/dist/Drawer/utils.cjs.map +1 -0
- package/dist/Drawer/utils.js +149 -0
- package/dist/Drawer/utils.js.map +1 -0
- package/dist/Rating/RatingItem.cjs +66 -0
- package/dist/Rating/RatingItem.cjs.map +1 -0
- package/dist/Rating/RatingItem.js +54 -0
- package/dist/Rating/RatingItem.js.map +1 -0
- package/dist/Rating/RatingItemIndicator.cjs +89 -0
- package/dist/Rating/RatingItemIndicator.cjs.map +1 -0
- package/dist/Rating/RatingItemIndicator.js +83 -0
- package/dist/Rating/RatingItemIndicator.js.map +1 -0
- package/dist/Rating/RatingRoot.cjs +136 -0
- package/dist/Rating/RatingRoot.cjs.map +1 -0
- package/dist/Rating/RatingRoot.js +124 -0
- package/dist/Rating/RatingRoot.js.map +1 -0
- package/dist/composables/useDrawerSnapPoints.cjs +130 -0
- package/dist/composables/useDrawerSnapPoints.cjs.map +1 -0
- package/dist/composables/useDrawerSnapPoints.js +124 -0
- package/dist/composables/useDrawerSnapPoints.js.map +1 -0
- package/dist/composables/useSwipeDismiss.cjs +401 -0
- package/dist/composables/useSwipeDismiss.cjs.map +1 -0
- package/dist/composables/useSwipeDismiss.js +395 -0
- package/dist/composables/useSwipeDismiss.js.map +1 -0
- package/dist/constant/components.cjs +5 -0
- package/dist/constant/components.cjs.map +1 -1
- package/dist/constant/components.js +5 -0
- package/dist/constant/components.js.map +1 -1
- package/dist/constant.d.cts +1 -0
- package/dist/constant.d.cts.map +1 -1
- package/dist/constant.d.ts +1 -0
- package/dist/constant.d.ts.map +1 -1
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -1
- package/dist/index2.d.ts.map +1 -1
- package/dist/index3.d.cts +4 -4
- package/dist/index3.d.ts +15 -15
- package/dist/index4.d.cts +1612 -1201
- package/dist/index4.d.cts.map +1 -1
- package/dist/index4.d.ts +1618 -1207
- package/dist/index4.d.ts.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/namespaced/index.cjs +6 -0
- package/dist/namespaced/index.d.cts +7 -2
- package/dist/namespaced/index.d.mts +7 -2
- package/dist/namespaced/index.mjs +7 -2
- package/dist/shared/useSize.cjs +6 -2
- package/dist/shared/useSize.cjs.map +1 -1
- package/dist/shared/useSize.js +7 -3
- package/dist/shared/useSize.js.map +1 -1
- package/dist/utils/style.cjs +1 -1
- package/dist/utils/style.cjs.map +1 -1
- package/dist/utils/style.js +1 -1
- package/dist/utils/style.js.map +1 -1
- package/package.json +1 -1
- package/src/Collection/Collection.ts +2 -1
- package/src/Drawer/DrawerClose.vue +25 -0
- package/src/Drawer/DrawerContent.vue +102 -0
- package/src/Drawer/DrawerContentImpl.vue +395 -0
- package/src/Drawer/DrawerDescription.vue +24 -0
- package/src/Drawer/DrawerHandle.vue +25 -0
- package/src/Drawer/DrawerIndent.vue +64 -0
- package/src/Drawer/DrawerIndentBackground.vue +26 -0
- package/src/Drawer/DrawerOverlay.vue +42 -0
- package/src/Drawer/DrawerOverlayImpl.vue +55 -0
- package/src/Drawer/DrawerPortal.vue +17 -0
- package/src/Drawer/DrawerProvider.vue +95 -0
- package/src/Drawer/DrawerRoot.vue +252 -0
- package/src/Drawer/DrawerSwipeArea.vue +74 -0
- package/src/Drawer/DrawerTitle.vue +24 -0
- package/src/Drawer/DrawerTrigger.vue +45 -0
- package/src/Drawer/DrawerViewport.vue +34 -0
- package/src/Drawer/composables/useDrawerSnapPoints.ts +207 -0
- package/src/Drawer/composables/useSwipeDismiss.ts +586 -0
- package/src/Drawer/index.ts +74 -0
- package/src/Drawer/utils.ts +205 -0
- package/src/Rating/RatingItem.vue +1 -0
- package/src/Rating/RatingItemIndicator.vue +3 -2
- package/src/Rating/RatingRoot.vue +6 -2
- package/src/Rating/index.ts +3 -3
- package/src/Splitter/utils/style.ts +1 -1
- package/src/index.ts +2 -0
- package/src/shared/useEmitAsProps.test-d.ts +0 -1
- package/src/shared/useSize.ts +9 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useForwardExpose } from "../shared/useForwardExpose.js";
|
|
2
|
+
import { RadioGroupItem_default } from "../RadioGroup/RadioGroupItem.js";
|
|
3
|
+
import { RadioGroupIndicator_default } from "../RadioGroup/RadioGroupIndicator.js";
|
|
4
|
+
import { injectRatingRootContext } from "./RatingRoot.js";
|
|
5
|
+
import { injectRatingItemContext } from "./RatingItem.js";
|
|
6
|
+
import { computed, createBlock, createVNode, defineComponent, normalizeStyle, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
7
|
+
import { useActiveElement } from "@vueuse/core";
|
|
8
|
+
|
|
9
|
+
//#region src/Rating/RatingItemIndicator.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var RatingItemIndicator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
11
|
+
__name: "RatingItemIndicator",
|
|
12
|
+
props: {
|
|
13
|
+
step: {
|
|
14
|
+
type: Number,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
asChild: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
21
|
+
as: {
|
|
22
|
+
type: null,
|
|
23
|
+
required: false
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(__props) {
|
|
27
|
+
const props = __props;
|
|
28
|
+
const rootContext = injectRatingRootContext();
|
|
29
|
+
const { currentElement, forwardRef } = useForwardExpose();
|
|
30
|
+
const activeElement = useActiveElement();
|
|
31
|
+
const itemContext = injectRatingItemContext();
|
|
32
|
+
const isActive = computed(() => {
|
|
33
|
+
return rootContext.hoveredRating.value > 0 && props.step <= rootContext.hoveredRating.value || rootContext.hoveredRating.value === 0 && props.step <= rootContext.modelValue.value;
|
|
34
|
+
});
|
|
35
|
+
const isVisible = computed(() => {
|
|
36
|
+
return activeElement.value === currentElement.value || rootContext.step.value === 1 || props.step % 1 === 0 || props.step === rootContext.hoveredRating.value || props.step === rootContext.modelValue.value;
|
|
37
|
+
});
|
|
38
|
+
function handleMouseEnter() {
|
|
39
|
+
rootContext.changeHoveredRating(props.step);
|
|
40
|
+
}
|
|
41
|
+
return (_ctx, _cache) => {
|
|
42
|
+
return openBlock(), createBlock(unref(RadioGroupItem_default), {
|
|
43
|
+
ref: unref(forwardRef),
|
|
44
|
+
as: _ctx.as,
|
|
45
|
+
"as-child": _ctx.asChild,
|
|
46
|
+
style: normalizeStyle({
|
|
47
|
+
["--akar-rating-item-step-width"]: `${(_ctx.step % 1 || 1) * 100}%`,
|
|
48
|
+
["--akar-rating-item-step-opacity"]: isVisible.value ? 1 : 0,
|
|
49
|
+
["--akar-rating-item-step-z-index"]: unref(itemContext).steps.value.length - unref(itemContext).steps.value.indexOf(_ctx.step)
|
|
50
|
+
}),
|
|
51
|
+
value: _ctx.step,
|
|
52
|
+
"data-state": isActive.value ? "active" : void 0,
|
|
53
|
+
disabled: unref(rootContext).disabled.value,
|
|
54
|
+
onSelect: _cache[0] || (_cache[0] = ($event) => unref(rootContext).changeModelValue(_ctx.step)),
|
|
55
|
+
onMouseenter: handleMouseEnter
|
|
56
|
+
}, {
|
|
57
|
+
default: withCtx(() => [createVNode(unref(RadioGroupIndicator_default), {
|
|
58
|
+
"force-mount": "",
|
|
59
|
+
"as-child": ""
|
|
60
|
+
}, {
|
|
61
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
62
|
+
_: 3
|
|
63
|
+
})]),
|
|
64
|
+
_: 3
|
|
65
|
+
}, 8, [
|
|
66
|
+
"as",
|
|
67
|
+
"as-child",
|
|
68
|
+
"style",
|
|
69
|
+
"value",
|
|
70
|
+
"data-state",
|
|
71
|
+
"disabled"
|
|
72
|
+
]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/Rating/RatingItemIndicator.vue
|
|
79
|
+
var RatingItemIndicator_default = RatingItemIndicator_vue_vue_type_script_setup_true_lang_default;
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { RatingItemIndicator_default };
|
|
83
|
+
//# sourceMappingURL=RatingItemIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RatingItemIndicator.js","names":["as","asChild","step"],"sources":["../../src/Rating/RatingItemIndicator.vue","../../src/Rating/RatingItemIndicator.vue"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA,MAAM,QAAQ;EAEd,MAAM,cAAc,yBAAyB;EAC7C,MAAM,EAAE,gBAAgB,YAAY,GAAG,kBAAkB;EACzD,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,cAAc,yBAAyB;EAE7C,MAAM,WAAW,SAAS,MAAM;AAC9B,UAAQ,YAAY,cAAc,QAAQ,KAAK,MAAM,QAAQ,YAAY,cAAc,SAAW,YAAY,cAAc,UAAU,KAAK,MAAM,QAAQ,YAAY,WAAW;EACjL,EAAC;EAEF,MAAM,YAAY,SAAS,MAAM;AAC/B,UAAO,cAAc,UAAU,eAAe,SAAS,YAAY,KAAK,UAAU,KAAK,MAAM,OAAO,MAAM,KAAK,MAAM,SAAS,YAAY,cAAc,SAAS,MAAM,SAAS,YAAY,WAAW;EACxM,EAAC;EAEF,SAAS,mBAAmB;AAC1B,eAAY,oBAAoB,MAAM,KAAK;EAC7C;;uBAIE,YAsBiB,MAAA,uBAAA,EAAA;IArBd,KAAK,MAAA,WAAU;IACf,IAAIA,KAAAA;IACJ,YAAUC,KAAAA;IACV,OAAK,eAAA;4CAAkDC,KAAAA,OAAI,KAAA,KAAA,IAAA,CAAA,CAAA;0CAAiE,UAAA,QAAS,IAAA;0CAAqD,MAAA,YAAW,CAAC,MAAM,MAAM,SAAS,MAAA,YAAW,CAAC,MAAM,MAAM,QAAQA,KAAAA,KAAI;;IAM/P,OAAOA,KAAAA;IACP,cAAY,SAAA,QAAQ;IACpB,UAAU,MAAA,YAAW,CAAC,SAAS;IAC/B,UAAM,OAAA,OAAA,OAAA,KAAA,CAAA,WAAE,MAAA,YAAW,CAAC,iBAAiBA,KAAAA,KAAI;IACzC,cAAY;;qBAEb,MAKsB,CALtB,YAKsB,MAAA,4BAAA,EAAA;KAJpB,eAAA;KACA,YAAA;;sBAEA,MAAQ,CAAR,WAAQ,KAAA,QAAA,UAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../rolldown-runtime.cjs');
|
|
2
|
+
const require_shared_createContext = require('../shared/createContext.cjs');
|
|
3
|
+
const require_shared_useForwardExpose = require('../shared/useForwardExpose.cjs');
|
|
4
|
+
const require_RadioGroup_RadioGroupRoot = require('../RadioGroup/RadioGroupRoot.cjs');
|
|
5
|
+
const vue = require_rolldown_runtime.__toESM(require("vue"));
|
|
6
|
+
const __vueuse_core = require_rolldown_runtime.__toESM(require("@vueuse/core"));
|
|
7
|
+
|
|
8
|
+
//#region src/Rating/RatingRoot.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
+
const [injectRatingRootContext, provideRatingRootContext] = require_shared_createContext.createContext("RatingRoot");
|
|
10
|
+
var RatingRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
11
|
+
__name: "RatingRoot",
|
|
12
|
+
props: {
|
|
13
|
+
defaultValue: {
|
|
14
|
+
type: Number,
|
|
15
|
+
required: false
|
|
16
|
+
},
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
21
|
+
length: {
|
|
22
|
+
type: Number,
|
|
23
|
+
required: false,
|
|
24
|
+
default: 5
|
|
25
|
+
},
|
|
26
|
+
clearable: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
required: false
|
|
29
|
+
},
|
|
30
|
+
hoverable: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
step: {
|
|
35
|
+
type: Number,
|
|
36
|
+
required: false,
|
|
37
|
+
default: 1
|
|
38
|
+
},
|
|
39
|
+
disabled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
orientation: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: false,
|
|
46
|
+
default: "horizontal"
|
|
47
|
+
},
|
|
48
|
+
dir: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
loop: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
asChild: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
as: {
|
|
61
|
+
type: null,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
name: {
|
|
65
|
+
type: String,
|
|
66
|
+
required: false
|
|
67
|
+
},
|
|
68
|
+
required: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: false
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
emits: ["update:modelValue"],
|
|
74
|
+
setup(__props, { emit: __emit }) {
|
|
75
|
+
const props = __props;
|
|
76
|
+
const emits = __emit;
|
|
77
|
+
const { length, disabled, clearable, hoverable, step } = (0, vue.toRefs)(props);
|
|
78
|
+
require_shared_useForwardExpose.useForwardExpose();
|
|
79
|
+
const modelValue = (0, __vueuse_core.useVModel)(props, "modelValue", emits, {
|
|
80
|
+
defaultValue: props.defaultValue,
|
|
81
|
+
passive: props.modelValue === void 0
|
|
82
|
+
});
|
|
83
|
+
const items = (0, vue.computed)(() => {
|
|
84
|
+
return Array.from({ length: length.value }, (_, i) => i + 1);
|
|
85
|
+
});
|
|
86
|
+
const hoveredRating = (0, vue.ref)(0);
|
|
87
|
+
function changeModelValue(rating) {
|
|
88
|
+
if (disabled.value) return;
|
|
89
|
+
if (clearable.value && modelValue.value === rating) {
|
|
90
|
+
hoveredRating.value = 0;
|
|
91
|
+
modelValue.value = 0;
|
|
92
|
+
} else modelValue.value = rating;
|
|
93
|
+
}
|
|
94
|
+
function changeHoveredRating(rating) {
|
|
95
|
+
if (disabled.value || !hoverable.value) return;
|
|
96
|
+
hoveredRating.value = rating;
|
|
97
|
+
}
|
|
98
|
+
provideRatingRootContext({
|
|
99
|
+
modelValue,
|
|
100
|
+
items,
|
|
101
|
+
hoveredRating,
|
|
102
|
+
disabled,
|
|
103
|
+
step,
|
|
104
|
+
changeModelValue,
|
|
105
|
+
changeHoveredRating
|
|
106
|
+
});
|
|
107
|
+
return (_ctx, _cache) => {
|
|
108
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_RadioGroup_RadioGroupRoot.RadioGroupRoot_default), (0, vue.mergeProps)((0, vue.unref)(__vueuse_core.reactiveOmit)(props, "length", "clearable", "hoverable", "step"), { disabled: (0, vue.unref)(disabled) }), {
|
|
109
|
+
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", {
|
|
110
|
+
items: items.value,
|
|
111
|
+
modelValue: (0, vue.unref)(modelValue)
|
|
112
|
+
})]),
|
|
113
|
+
_: 3
|
|
114
|
+
}, 16, ["disabled"]);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/Rating/RatingRoot.vue
|
|
121
|
+
var RatingRoot_default = RatingRoot_vue_vue_type_script_setup_true_lang_default;
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
Object.defineProperty(exports, 'RatingRoot_default', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return RatingRoot_default;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, 'injectRatingRootContext', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () {
|
|
133
|
+
return injectRatingRootContext;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=RatingRoot.c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1,124 @@
|
|
|
1
|
+
import { createContext } from "../shared/createContext.js";
|
|
2
|
+
import { useForwardExpose } from "../shared/useForwardExpose.js";
|
|
3
|
+
import { RadioGroupRoot_default } from "../RadioGroup/RadioGroupRoot.js";
|
|
4
|
+
import { computed, createBlock, defineComponent, mergeProps, openBlock, ref, renderSlot, toRefs, unref, withCtx } from "vue";
|
|
5
|
+
import { reactiveOmit, useVModel } from "@vueuse/core";
|
|
6
|
+
|
|
7
|
+
//#region src/Rating/RatingRoot.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
const [injectRatingRootContext, provideRatingRootContext] = /*#__PURE__*/ createContext("RatingRoot");
|
|
9
|
+
var RatingRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
10
|
+
__name: "RatingRoot",
|
|
11
|
+
props: {
|
|
12
|
+
defaultValue: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: false
|
|
15
|
+
},
|
|
16
|
+
modelValue: {
|
|
17
|
+
type: Number,
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
length: {
|
|
21
|
+
type: Number,
|
|
22
|
+
required: false,
|
|
23
|
+
default: 5
|
|
24
|
+
},
|
|
25
|
+
clearable: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
required: false
|
|
28
|
+
},
|
|
29
|
+
hoverable: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
required: false
|
|
32
|
+
},
|
|
33
|
+
step: {
|
|
34
|
+
type: Number,
|
|
35
|
+
required: false,
|
|
36
|
+
default: 1
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
orientation: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false,
|
|
45
|
+
default: "horizontal"
|
|
46
|
+
},
|
|
47
|
+
dir: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: false
|
|
50
|
+
},
|
|
51
|
+
loop: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
asChild: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
required: false
|
|
58
|
+
},
|
|
59
|
+
as: {
|
|
60
|
+
type: null,
|
|
61
|
+
required: false
|
|
62
|
+
},
|
|
63
|
+
name: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: false
|
|
66
|
+
},
|
|
67
|
+
required: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
required: false
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
emits: ["update:modelValue"],
|
|
73
|
+
setup(__props, { emit: __emit }) {
|
|
74
|
+
const props = __props;
|
|
75
|
+
const emits = __emit;
|
|
76
|
+
const { length, disabled, clearable, hoverable, step } = toRefs(props);
|
|
77
|
+
useForwardExpose();
|
|
78
|
+
const modelValue = useVModel(props, "modelValue", emits, {
|
|
79
|
+
defaultValue: props.defaultValue,
|
|
80
|
+
passive: props.modelValue === void 0
|
|
81
|
+
});
|
|
82
|
+
const items = computed(() => {
|
|
83
|
+
return Array.from({ length: length.value }, (_, i) => i + 1);
|
|
84
|
+
});
|
|
85
|
+
const hoveredRating = ref(0);
|
|
86
|
+
function changeModelValue(rating) {
|
|
87
|
+
if (disabled.value) return;
|
|
88
|
+
if (clearable.value && modelValue.value === rating) {
|
|
89
|
+
hoveredRating.value = 0;
|
|
90
|
+
modelValue.value = 0;
|
|
91
|
+
} else modelValue.value = rating;
|
|
92
|
+
}
|
|
93
|
+
function changeHoveredRating(rating) {
|
|
94
|
+
if (disabled.value || !hoverable.value) return;
|
|
95
|
+
hoveredRating.value = rating;
|
|
96
|
+
}
|
|
97
|
+
provideRatingRootContext({
|
|
98
|
+
modelValue,
|
|
99
|
+
items,
|
|
100
|
+
hoveredRating,
|
|
101
|
+
disabled,
|
|
102
|
+
step,
|
|
103
|
+
changeModelValue,
|
|
104
|
+
changeHoveredRating
|
|
105
|
+
});
|
|
106
|
+
return (_ctx, _cache) => {
|
|
107
|
+
return openBlock(), createBlock(unref(RadioGroupRoot_default), mergeProps(unref(reactiveOmit)(props, "length", "clearable", "hoverable", "step"), { disabled: unref(disabled) }), {
|
|
108
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
|
|
109
|
+
items: items.value,
|
|
110
|
+
modelValue: unref(modelValue)
|
|
111
|
+
})]),
|
|
112
|
+
_: 3
|
|
113
|
+
}, 16, ["disabled"]);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/Rating/RatingRoot.vue
|
|
120
|
+
var RatingRoot_default = RatingRoot_vue_vue_type_script_setup_true_lang_default;
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { RatingRoot_default, injectRatingRootContext };
|
|
124
|
+
//# sourceMappingURL=RatingRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RatingRoot.js","names":[],"sources":["../../src/Rating/RatingRoot.vue","../../src/Rating/RatingRoot.vue"],"sourcesContent":[],"mappings":";;;;;;;AAsCA,MAAa,CAAC,yBAAyB,yBAAwB,GAC3D,cAAiC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlD,MAAM,QAAQ;EAKd,MAAM,QAAQ;EASd,MAAM,EAAE,QAAQ,UAAU,WAAW,WAAW,MAAM,GAAG,OAAO,MAAM;AAEtE,oBAAkB;EAElB,MAAM,aAAa,UAA8D,OAAO,cAAc,OAAO;GAC3G,cAAc,MAAM;GACpB,SAAU,MAAM;EACjB,EAAC;EAEF,MAAM,QAAQ,SAAS,MAAM;AAC3B,UAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,MAAO,GAAE,CAAC,GAAG,MAAM,IAAI,EAAE;EAC7D,EAAC;EAEF,MAAM,gBAAgB,IAAY,EAAE;EAEpC,SAAS,iBAAiB,QAAgB;AACxC,OAAI,SAAS,MACX;AAGF,OAAI,UAAU,SAAS,WAAW,UAAU,QAAQ;AAClD,kBAAc,QAAQ;AACtB,eAAW,QAAQ;GACpB,MACC,YAAW,QAAQ;EAEvB;EAEA,SAAS,oBAAoB,QAAgB;AAC3C,OAAI,SAAS,UAAU,UAAU,MAC/B;AAGF,iBAAc,QAAQ;EACxB;AAEA,2BAAyB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;EACD,EAAC;;uBAIA,YAQiB,MAAA,uBAAA,EARjB,WACU,MAOO,aAPK,CAAC,OAAK,UAAA,aAAA,aAAA,OAAA,EAAA,EACzB,UAAU,MAAA,SAAQ,CAAA,EAAA,EAAA;qBAEnB,MAGE,CAHF,WAGE,KAAA,QAAA,WAAA;KAFC,OAAO,MAAA;KACP,YAAa,MAAA,WAAU"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../rolldown-runtime.cjs');
|
|
2
|
+
const vue = require_rolldown_runtime.__toESM(require("vue"));
|
|
3
|
+
const __vueuse_core = require_rolldown_runtime.__toESM(require("@vueuse/core"));
|
|
4
|
+
|
|
5
|
+
//#region src/Drawer/composables/useDrawerSnapPoints.ts
|
|
6
|
+
const SNAP_VELOCITY_THRESHOLD = .5;
|
|
7
|
+
const SNAP_VELOCITY_MULTIPLIER = 300;
|
|
8
|
+
const MAX_SNAP_VELOCITY = 4;
|
|
9
|
+
const FAST_SWIPE_VELOCITY = .5;
|
|
10
|
+
function parseSnapPoint(value, viewportHeight, rootFontSize) {
|
|
11
|
+
let result = null;
|
|
12
|
+
if (typeof value === "number") result = value >= 0 && value <= 1 ? value * viewportHeight : value;
|
|
13
|
+
else if (value.endsWith("rem")) result = Number.parseFloat(value) * rootFontSize;
|
|
14
|
+
else if (value.endsWith("px")) result = Number.parseFloat(value);
|
|
15
|
+
if (result == null || !Number.isFinite(result) || result < 0) return null;
|
|
16
|
+
return Math.round(result);
|
|
17
|
+
}
|
|
18
|
+
function useDrawerSnapPoints(options) {
|
|
19
|
+
const { snapPoints, activeSnapPoint, popupHeight, onSnapPointChange } = options;
|
|
20
|
+
const viewportHeight = (0, vue.ref)(typeof window !== "undefined" ? window.innerHeight : 0);
|
|
21
|
+
const rootFontSize = (0, vue.ref)(typeof document !== "undefined" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16 : 16);
|
|
22
|
+
if (typeof window !== "undefined") (0, __vueuse_core.useEventListener)(window, "resize", () => {
|
|
23
|
+
viewportHeight.value = window.innerHeight;
|
|
24
|
+
});
|
|
25
|
+
const resolvedSnapPoints = (0, vue.computed)(() => {
|
|
26
|
+
const points = snapPoints.value;
|
|
27
|
+
if (!points || points.length === 0) return [];
|
|
28
|
+
const vh = viewportHeight.value;
|
|
29
|
+
const fs = rootFontSize.value;
|
|
30
|
+
const ph = popupHeight.value;
|
|
31
|
+
const resolved = [];
|
|
32
|
+
for (const pt of points) {
|
|
33
|
+
const height = parseSnapPoint(pt, vh, fs);
|
|
34
|
+
if (height == null) continue;
|
|
35
|
+
if (resolved.some((r) => Math.abs(r.height - height) <= 1)) continue;
|
|
36
|
+
const clampedHeight = Math.min(height, Math.min(ph, vh));
|
|
37
|
+
resolved.push({
|
|
38
|
+
value: pt,
|
|
39
|
+
height: clampedHeight,
|
|
40
|
+
offset: Math.max(0, ph - clampedHeight)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return resolved.sort((a, b) => a.height - b.height);
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the currently-active snap point to its resolved entry, matching by
|
|
47
|
+
* raw value OR by parsed-height equivalence. This lets a controlled drawer use
|
|
48
|
+
* interchangeable representations (`'16rem'` vs `256`, `0.5` vs `400`) without
|
|
49
|
+
* the release math falling back to offset `0` and jumping to the wrong target.
|
|
50
|
+
*/
|
|
51
|
+
function findActiveResolvedPoint() {
|
|
52
|
+
if (!activeSnapPoint.value || resolvedSnapPoints.value.length === 0) return void 0;
|
|
53
|
+
const activeHeight = parseSnapPoint(activeSnapPoint.value, viewportHeight.value, rootFontSize.value);
|
|
54
|
+
return resolvedSnapPoints.value.find((r) => r.value === activeSnapPoint.value || activeHeight != null && Math.abs(r.height - activeHeight) <= 1);
|
|
55
|
+
}
|
|
56
|
+
const activeSnapPointOffset = (0, vue.computed)(() => findActiveResolvedPoint()?.offset ?? null);
|
|
57
|
+
/**
|
|
58
|
+
* BaseUI-parity snap release math (ported from `DrawerViewport.tsx` lines ~577-714).
|
|
59
|
+
*
|
|
60
|
+
* Takes a **dismiss-signed** drag delta (positive = dismiss direction, negative =
|
|
61
|
+
* open direction) and the raw velocity vector. Computes a velocity-boosted target
|
|
62
|
+
* offset, then either dismisses, snaps to the closest point, or (in sequential
|
|
63
|
+
* mode) advances one step based on physical crossing + fast-swipe velocity.
|
|
64
|
+
*/
|
|
65
|
+
function snapToNearest(dragDelta, velocity, direction, sequential) {
|
|
66
|
+
const points = resolvedSnapPoints.value;
|
|
67
|
+
if (points.length === 0) return;
|
|
68
|
+
const ph = popupHeight.value;
|
|
69
|
+
const axisVel = direction === "up" || direction === "down" ? velocity.y : velocity.x;
|
|
70
|
+
const velSigned = direction === "up" || direction === "left" ? -axisVel : axisVel;
|
|
71
|
+
const activePoint = findActiveResolvedPoint();
|
|
72
|
+
const currentOffset = activePoint?.offset ?? 0;
|
|
73
|
+
const dragTargetOffset = Math.max(0, Math.min(ph, currentOffset + dragDelta));
|
|
74
|
+
let targetOffset = dragTargetOffset;
|
|
75
|
+
if (Math.abs(velSigned) >= SNAP_VELOCITY_THRESHOLD) {
|
|
76
|
+
const clampedVel = Math.max(-MAX_SNAP_VELOCITY, Math.min(MAX_SNAP_VELOCITY, velSigned));
|
|
77
|
+
targetOffset = dragTargetOffset + clampedVel * SNAP_VELOCITY_MULTIPLIER;
|
|
78
|
+
}
|
|
79
|
+
let closest = points[0];
|
|
80
|
+
let closestDist = Math.abs(targetOffset - closest.offset);
|
|
81
|
+
for (const p of points) {
|
|
82
|
+
const d = Math.abs(targetOffset - p.offset);
|
|
83
|
+
if (d < closestDist) {
|
|
84
|
+
closest = p;
|
|
85
|
+
closestDist = d;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const closeDistance = Math.abs(targetOffset - ph);
|
|
89
|
+
if (closeDistance < closestDist) {
|
|
90
|
+
onSnapPointChange(null);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (sequential) {
|
|
94
|
+
const sorted = [...points].sort((a, b) => a.offset - b.offset);
|
|
95
|
+
const currentIdx = activePoint ? sorted.indexOf(activePoint) : -1;
|
|
96
|
+
if (currentIdx < 0) {
|
|
97
|
+
onSnapPointChange(closest.value);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const dragDir = Math.sign(dragDelta);
|
|
101
|
+
const velDir = Math.sign(velSigned);
|
|
102
|
+
const shouldAdvance = velDir === dragDir && Math.abs(velSigned) >= FAST_SWIPE_VELOCITY;
|
|
103
|
+
const adjacentIdx = Math.max(0, Math.min(sorted.length - 1, currentIdx + dragDir));
|
|
104
|
+
const adjacent = sorted[adjacentIdx];
|
|
105
|
+
if (shouldAdvance) {
|
|
106
|
+
onSnapPointChange(adjacent.value);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const crossed = dragDir > 0 ? targetOffset > adjacent.offset : targetOffset < adjacent.offset;
|
|
110
|
+
onSnapPointChange(crossed ? adjacent.value : activeSnapPoint.value ?? closest.value);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
onSnapPointChange(closest.value);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
resolvedSnapPoints,
|
|
117
|
+
activeSnapPointOffset,
|
|
118
|
+
viewportHeight,
|
|
119
|
+
snapToNearest
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
Object.defineProperty(exports, 'useDrawerSnapPoints', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return useDrawerSnapPoints;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=useDrawerSnapPoints.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawerSnapPoints.cjs","names":["value: DrawerSnapPoint","viewportHeight: number","rootFontSize: number","result: number | null","options: {\n snapPoints: Ref<Array<DrawerSnapPoint> | undefined>;\n activeSnapPoint: Ref<DrawerSnapPoint | null | undefined>;\n popupHeight: Ref<number>;\n viewportRef: Ref<HTMLElement | null | undefined>;\n onSnapPointChange: (point: DrawerSnapPoint | null) => void;\n}","resolved: Array<ResolvedSnapPoint>","dragDelta: number","velocity: { x: number; y: number }","direction: SwipeDirection","sequential: boolean"],"sources":["../../src/Drawer/composables/useDrawerSnapPoints.ts"],"sourcesContent":[],"mappings":";;;;;AAMA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;AAC1B,MAAM,sBAAsB;AAQ5B,SAAS,eAAeA,OAAwBC,gBAAwBC,cAAqC;CAC3G,IAAIC,SAAwB;AAC5B,YAAW,UAAU,SACnB,UAAU,SAAS,KAAK,SAAS,IAAK,QAAQ,iBAAiB;UACtD,MAAM,SAAS,MAAM,CAC9B,UAAS,OAAO,WAAW,MAAM,GAAG;UAC3B,MAAM,SAAS,KAAK,CAC7B,UAAS,OAAO,WAAW,MAAM;AAKnC,KAAI,UAAU,SAAS,OAAO,SAAS,OAAO,IAAI,SAAS,EACzD,QAAO;AAET,QAAO,KAAK,MAAM,OAAO;AAC1B;AAED,SAAgB,oBAAoBC,SAMjC;CACD,MAAM,EAAE,YAAY,iBAAiB,aAAa,mBAAmB,GAAG;CAExE,MAAM,iBAAiB,oBAAW,WAAW,cAAc,OAAO,cAAc,EAAE;CAClF,MAAM,eAAe,oBACZ,aAAa,cAChB,OAAO,WAAW,iBAAiB,SAAS,gBAAgB,CAAC,SAAS,IAAI,KAC1E,GACL;AAED,YAAW,WAAW,YACpB,qC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AS,SACxB,eAAe,SAAS;AAC5B,qBAAkB,UAAU,SAAS,QAAS,gBAAgB,SAAS,QAAQ,MAAO;AACtF;EACD;AAED,oBAAkB,QAAQ,MAAM;CACjC;AAED,QAAO;EACL;EACA;EACA;EACA;CACD;AACF"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
import { useEventListener } from "@vueuse/core";
|
|
3
|
+
|
|
4
|
+
//#region src/Drawer/composables/useDrawerSnapPoints.ts
|
|
5
|
+
const SNAP_VELOCITY_THRESHOLD = .5;
|
|
6
|
+
const SNAP_VELOCITY_MULTIPLIER = 300;
|
|
7
|
+
const MAX_SNAP_VELOCITY = 4;
|
|
8
|
+
const FAST_SWIPE_VELOCITY = .5;
|
|
9
|
+
function parseSnapPoint(value, viewportHeight, rootFontSize) {
|
|
10
|
+
let result = null;
|
|
11
|
+
if (typeof value === "number") result = value >= 0 && value <= 1 ? value * viewportHeight : value;
|
|
12
|
+
else if (value.endsWith("rem")) result = Number.parseFloat(value) * rootFontSize;
|
|
13
|
+
else if (value.endsWith("px")) result = Number.parseFloat(value);
|
|
14
|
+
if (result == null || !Number.isFinite(result) || result < 0) return null;
|
|
15
|
+
return Math.round(result);
|
|
16
|
+
}
|
|
17
|
+
function useDrawerSnapPoints(options) {
|
|
18
|
+
const { snapPoints, activeSnapPoint, popupHeight, onSnapPointChange } = options;
|
|
19
|
+
const viewportHeight = ref(typeof window !== "undefined" ? window.innerHeight : 0);
|
|
20
|
+
const rootFontSize = ref(typeof document !== "undefined" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16 : 16);
|
|
21
|
+
if (typeof window !== "undefined") useEventListener(window, "resize", () => {
|
|
22
|
+
viewportHeight.value = window.innerHeight;
|
|
23
|
+
});
|
|
24
|
+
const resolvedSnapPoints = computed(() => {
|
|
25
|
+
const points = snapPoints.value;
|
|
26
|
+
if (!points || points.length === 0) return [];
|
|
27
|
+
const vh = viewportHeight.value;
|
|
28
|
+
const fs = rootFontSize.value;
|
|
29
|
+
const ph = popupHeight.value;
|
|
30
|
+
const resolved = [];
|
|
31
|
+
for (const pt of points) {
|
|
32
|
+
const height = parseSnapPoint(pt, vh, fs);
|
|
33
|
+
if (height == null) continue;
|
|
34
|
+
if (resolved.some((r) => Math.abs(r.height - height) <= 1)) continue;
|
|
35
|
+
const clampedHeight = Math.min(height, Math.min(ph, vh));
|
|
36
|
+
resolved.push({
|
|
37
|
+
value: pt,
|
|
38
|
+
height: clampedHeight,
|
|
39
|
+
offset: Math.max(0, ph - clampedHeight)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return resolved.sort((a, b) => a.height - b.height);
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the currently-active snap point to its resolved entry, matching by
|
|
46
|
+
* raw value OR by parsed-height equivalence. This lets a controlled drawer use
|
|
47
|
+
* interchangeable representations (`'16rem'` vs `256`, `0.5` vs `400`) without
|
|
48
|
+
* the release math falling back to offset `0` and jumping to the wrong target.
|
|
49
|
+
*/
|
|
50
|
+
function findActiveResolvedPoint() {
|
|
51
|
+
if (!activeSnapPoint.value || resolvedSnapPoints.value.length === 0) return void 0;
|
|
52
|
+
const activeHeight = parseSnapPoint(activeSnapPoint.value, viewportHeight.value, rootFontSize.value);
|
|
53
|
+
return resolvedSnapPoints.value.find((r) => r.value === activeSnapPoint.value || activeHeight != null && Math.abs(r.height - activeHeight) <= 1);
|
|
54
|
+
}
|
|
55
|
+
const activeSnapPointOffset = computed(() => findActiveResolvedPoint()?.offset ?? null);
|
|
56
|
+
/**
|
|
57
|
+
* BaseUI-parity snap release math (ported from `DrawerViewport.tsx` lines ~577-714).
|
|
58
|
+
*
|
|
59
|
+
* Takes a **dismiss-signed** drag delta (positive = dismiss direction, negative =
|
|
60
|
+
* open direction) and the raw velocity vector. Computes a velocity-boosted target
|
|
61
|
+
* offset, then either dismisses, snaps to the closest point, or (in sequential
|
|
62
|
+
* mode) advances one step based on physical crossing + fast-swipe velocity.
|
|
63
|
+
*/
|
|
64
|
+
function snapToNearest(dragDelta, velocity, direction, sequential) {
|
|
65
|
+
const points = resolvedSnapPoints.value;
|
|
66
|
+
if (points.length === 0) return;
|
|
67
|
+
const ph = popupHeight.value;
|
|
68
|
+
const axisVel = direction === "up" || direction === "down" ? velocity.y : velocity.x;
|
|
69
|
+
const velSigned = direction === "up" || direction === "left" ? -axisVel : axisVel;
|
|
70
|
+
const activePoint = findActiveResolvedPoint();
|
|
71
|
+
const currentOffset = activePoint?.offset ?? 0;
|
|
72
|
+
const dragTargetOffset = Math.max(0, Math.min(ph, currentOffset + dragDelta));
|
|
73
|
+
let targetOffset = dragTargetOffset;
|
|
74
|
+
if (Math.abs(velSigned) >= SNAP_VELOCITY_THRESHOLD) {
|
|
75
|
+
const clampedVel = Math.max(-MAX_SNAP_VELOCITY, Math.min(MAX_SNAP_VELOCITY, velSigned));
|
|
76
|
+
targetOffset = dragTargetOffset + clampedVel * SNAP_VELOCITY_MULTIPLIER;
|
|
77
|
+
}
|
|
78
|
+
let closest = points[0];
|
|
79
|
+
let closestDist = Math.abs(targetOffset - closest.offset);
|
|
80
|
+
for (const p of points) {
|
|
81
|
+
const d = Math.abs(targetOffset - p.offset);
|
|
82
|
+
if (d < closestDist) {
|
|
83
|
+
closest = p;
|
|
84
|
+
closestDist = d;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const closeDistance = Math.abs(targetOffset - ph);
|
|
88
|
+
if (closeDistance < closestDist) {
|
|
89
|
+
onSnapPointChange(null);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (sequential) {
|
|
93
|
+
const sorted = [...points].sort((a, b) => a.offset - b.offset);
|
|
94
|
+
const currentIdx = activePoint ? sorted.indexOf(activePoint) : -1;
|
|
95
|
+
if (currentIdx < 0) {
|
|
96
|
+
onSnapPointChange(closest.value);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const dragDir = Math.sign(dragDelta);
|
|
100
|
+
const velDir = Math.sign(velSigned);
|
|
101
|
+
const shouldAdvance = velDir === dragDir && Math.abs(velSigned) >= FAST_SWIPE_VELOCITY;
|
|
102
|
+
const adjacentIdx = Math.max(0, Math.min(sorted.length - 1, currentIdx + dragDir));
|
|
103
|
+
const adjacent = sorted[adjacentIdx];
|
|
104
|
+
if (shouldAdvance) {
|
|
105
|
+
onSnapPointChange(adjacent.value);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const crossed = dragDir > 0 ? targetOffset > adjacent.offset : targetOffset < adjacent.offset;
|
|
109
|
+
onSnapPointChange(crossed ? adjacent.value : activeSnapPoint.value ?? closest.value);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
onSnapPointChange(closest.value);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
resolvedSnapPoints,
|
|
116
|
+
activeSnapPointOffset,
|
|
117
|
+
viewportHeight,
|
|
118
|
+
snapToNearest
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { useDrawerSnapPoints };
|
|
124
|
+
//# sourceMappingURL=useDrawerSnapPoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawerSnapPoints.js","names":["value: DrawerSnapPoint","viewportHeight: number","rootFontSize: number","result: number | null","options: {\n snapPoints: Ref<Array<DrawerSnapPoint> | undefined>;\n activeSnapPoint: Ref<DrawerSnapPoint | null | undefined>;\n popupHeight: Ref<number>;\n viewportRef: Ref<HTMLElement | null | undefined>;\n onSnapPointChange: (point: DrawerSnapPoint | null) => void;\n}","resolved: Array<ResolvedSnapPoint>","dragDelta: number","velocity: { x: number; y: number }","direction: SwipeDirection","sequential: boolean"],"sources":["../../src/Drawer/composables/useDrawerSnapPoints.ts"],"sourcesContent":[],"mappings":";;;;AAMA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;AAC1B,MA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