@hina-ui/vue 1.7.4 → 1.7.5
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/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/types/vue/src/components/anchor/Anchor.vue.d.ts.map +1 -1
- package/dist/types/vue/src/components/anchor/composables/useAnchorFollow.d.ts +1 -1
- package/dist/types/vue/src/components/anchor/composables/useAnchorFollow.d.ts.map +1 -1
- package/dist/types/vue/src/components/lightbox/composables/useLightboxHint.d.ts.map +1 -1
- package/dist/types/vue/src/components/prev-next/PrevNextLink.vue.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/anchor/Anchor.vue +13 -9
- package/src/components/anchor/composables/useAnchorFollow.ts +18 -3
- package/src/components/lightbox/composables/useLightboxHint.ts +6 -1
- package/src/components/prev-next/PrevNext.vue +1 -1
- package/src/components/prev-next/PrevNextLink.vue +1 -1
package/dist/index.js
CHANGED
|
@@ -7685,6 +7685,10 @@ function useLightboxPhase(options) {
|
|
|
7685
7685
|
//#endregion
|
|
7686
7686
|
//#region src/components/lightbox/composables/useLightboxHint.ts
|
|
7687
7687
|
function useLightboxHint(options) {
|
|
7688
|
+
if (typeof window === "undefined") return {
|
|
7689
|
+
x: useMotionValue(0),
|
|
7690
|
+
y: useMotionValue(0)
|
|
7691
|
+
};
|
|
7688
7692
|
const { motion, frames, paging } = options;
|
|
7689
7693
|
function corner() {
|
|
7690
7694
|
const frame = frames.frameOf(options.current());
|
|
@@ -11401,7 +11405,7 @@ var PrevNext_default = /* @__PURE__ */ defineComponent({
|
|
|
11401
11405
|
return (_ctx, _cache) => {
|
|
11402
11406
|
return openBlock(), createElementBlock("nav", {
|
|
11403
11407
|
"aria-label": props.label ?? unref(t).pagination.navLabel,
|
|
11404
|
-
class: normalizeClass(unref(cn)("grid gap-4 sm:grid-cols-2", props.class))
|
|
11408
|
+
class: normalizeClass(unref(cn)("grid grid-cols-1 gap-4 sm:grid-cols-2", props.class))
|
|
11405
11409
|
}, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$104);
|
|
11406
11410
|
};
|
|
11407
11411
|
}
|
|
@@ -11426,7 +11430,7 @@ var prevNextEyebrow = tv({
|
|
|
11426
11430
|
});
|
|
11427
11431
|
//#endregion
|
|
11428
11432
|
//#region src/components/prev-next/PrevNextLink.vue?vue&type=script&setup=true&lang.ts
|
|
11429
|
-
var _hoisted_1$103 = { class: "text-fg font-medium" };
|
|
11433
|
+
var _hoisted_1$103 = { class: "text-fg max-w-full font-medium" };
|
|
11430
11434
|
//#endregion
|
|
11431
11435
|
//#region src/components/prev-next/PrevNextLink.vue
|
|
11432
11436
|
var PrevNextLink_default = /* @__PURE__ */ defineComponent({
|
|
@@ -25991,11 +25995,12 @@ function useAnchor(items) {
|
|
|
25991
25995
|
}
|
|
25992
25996
|
//#endregion
|
|
25993
25997
|
//#region src/components/anchor/composables/useAnchorFollow.ts
|
|
25994
|
-
function useAnchorFollow(root, current, enabled) {
|
|
25998
|
+
function useAnchorFollow(root, current, lastCovered, enabled) {
|
|
25995
25999
|
const viewport = shallowRef();
|
|
25996
26000
|
let mounted = false;
|
|
25997
26001
|
let frame = 0;
|
|
25998
26002
|
let lastCurrent;
|
|
26003
|
+
let lastEnd;
|
|
25999
26004
|
function findViewport(nav, target) {
|
|
26000
26005
|
const doc = nav.ownerDocument;
|
|
26001
26006
|
const view = doc.defaultView;
|
|
@@ -26014,13 +26019,27 @@ function useAnchorFollow(root, current, enabled) {
|
|
|
26014
26019
|
if (!target || !link || !link.getClientRects().length) return;
|
|
26015
26020
|
const port = findViewport(nav, target);
|
|
26016
26021
|
viewport.value = port;
|
|
26017
|
-
const
|
|
26022
|
+
const endId = lastCovered.value ?? id;
|
|
26023
|
+
const changed = lastCurrent !== void 0 && (lastCurrent !== id || lastEnd !== endId);
|
|
26018
26024
|
lastCurrent = id;
|
|
26025
|
+
lastEnd = endId;
|
|
26019
26026
|
if (!port || port.clientHeight <= 0 || port.scrollHeight <= port.clientHeight) return;
|
|
26020
26027
|
const box = port.getBoundingClientRect();
|
|
26021
|
-
|
|
26028
|
+
let row = link.getBoundingClientRect();
|
|
26022
26029
|
const scale = port.offsetHeight ? box.height / port.offsetHeight : 1;
|
|
26023
26030
|
if (scale <= 0) return;
|
|
26031
|
+
if (endId !== id) {
|
|
26032
|
+
const end = nav.querySelector(`a[href="#${CSS.escape(endId)}"]`);
|
|
26033
|
+
if (end?.getClientRects().length) {
|
|
26034
|
+
const bottom = end.getBoundingClientRect().bottom;
|
|
26035
|
+
const height = bottom - row.top;
|
|
26036
|
+
if (height >= row.height && height <= port.clientHeight * scale) row = {
|
|
26037
|
+
top: row.top,
|
|
26038
|
+
bottom,
|
|
26039
|
+
height
|
|
26040
|
+
};
|
|
26041
|
+
}
|
|
26042
|
+
}
|
|
26024
26043
|
const top = box.top + port.clientTop * scale;
|
|
26025
26044
|
const bottom = top + port.clientHeight * scale;
|
|
26026
26045
|
if (row.top >= top && row.bottom <= bottom) return;
|
|
@@ -26044,6 +26063,7 @@ function useAnchorFollow(root, current, enabled) {
|
|
|
26044
26063
|
watch([
|
|
26045
26064
|
root,
|
|
26046
26065
|
current,
|
|
26066
|
+
lastCovered,
|
|
26047
26067
|
enabled
|
|
26048
26068
|
], schedule, { flush: "post" });
|
|
26049
26069
|
useResizeObserver(() => [
|
|
@@ -26082,7 +26102,10 @@ var Anchor_default = /* @__PURE__ */ defineComponent({
|
|
|
26082
26102
|
props: {
|
|
26083
26103
|
items: {},
|
|
26084
26104
|
label: {},
|
|
26085
|
-
autoScroll: {
|
|
26105
|
+
autoScroll: {
|
|
26106
|
+
type: Boolean,
|
|
26107
|
+
default: true
|
|
26108
|
+
},
|
|
26086
26109
|
class: {}
|
|
26087
26110
|
},
|
|
26088
26111
|
emits: ["change"],
|
|
@@ -26090,9 +26113,10 @@ var Anchor_default = /* @__PURE__ */ defineComponent({
|
|
|
26090
26113
|
const props = __props;
|
|
26091
26114
|
const emit = __emit;
|
|
26092
26115
|
const t = useUiLocale();
|
|
26093
|
-
const { entries, visible, current, span, jump } = useAnchor(() => props.items);
|
|
26116
|
+
const { entries, visible, covered, current, span, jump } = useAnchor(() => props.items);
|
|
26117
|
+
const lastCovered = computed(() => covered.value.at(-1)?.id);
|
|
26094
26118
|
const root = useTemplateRef("root");
|
|
26095
|
-
useAnchorFollow(root, current, () => props.autoScroll
|
|
26119
|
+
useAnchorFollow(root, current, lastCovered, () => props.autoScroll);
|
|
26096
26120
|
watch(current, (id) => emit("change", id), { flush: "post" });
|
|
26097
26121
|
__expose({ current });
|
|
26098
26122
|
return (_ctx, _cache) => {
|