@leavepulse/ui 0.72.8 → 0.73.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/chunks/{DropzoneLinkField-C-9BCGJn.js → DropzoneLinkField-ppY9xalk.js} +2 -2
- package/dist/chunks/{FieldWrapper-CORPzo9s.js → FieldWrapper-y5bKBNxA.js} +1 -1
- package/dist/chunks/{LpActionBar-BP1ld7-S.js → LpActionBar-B55msXTr.js} +2 -2
- package/dist/chunks/{LpAddressInput-Al3HT5ey.js → LpAddressInput-mf_dEpj_.js} +3 -3
- package/dist/chunks/{LpAlert-n5XPAZfv.js → LpAlert-Cg7oIx1B.js} +2 -2
- package/dist/chunks/{LpAppShell-CPCG0I-c.js → LpAppShell-B0Yu9MVs.js} +11 -5
- package/dist/chunks/{LpBadge-wUYLN4U9.js → LpBadge-0A6sPks3.js} +1 -1
- package/dist/chunks/{LpBottomNav-CbNQQPuL.js → LpBottomNav-Dik-ZcHv.js} +1 -1
- package/dist/chunks/{LpBreadcrumbs-DPdbth-c.js → LpBreadcrumbs-ssZV3_od.js} +1 -1
- package/dist/chunks/{LpButton-CFb44IjC.js → LpButton-BgdewXxF.js} +1 -1
- package/dist/chunks/{LpCard-r13WRqox.js → LpCard-BJ59q6hR.js} +1 -1
- package/dist/chunks/{LpCheckbox-Cs4SHaHX.js → LpCheckbox-B0kJ-t6T.js} +1 -1
- package/dist/chunks/{LpCodeBlock-DRC8VbXW.js → LpCodeBlock-CXR_7t_F.js} +1 -1
- package/dist/chunks/{LpCodeDisplay-CE9TxCA4.js → LpCodeDisplay-BCghfBFC.js} +4 -4
- package/dist/chunks/{LpConfirmDialog-DY2VjDji.js → LpConfirmDialog-CaA4pAre.js} +1 -1
- package/dist/chunks/{LpConfirmHost-DvSZTJ4N.js → LpConfirmHost-CBIzALSL.js} +1 -1
- package/dist/chunks/{LpCopyButton-xF7wFVoU.js → LpCopyButton-Cw-lF7Q3.js} +1 -1
- package/dist/chunks/{LpCountdown-DgeY3cLG.js → LpCountdown-BNNhnQAK.js} +1 -1
- package/dist/chunks/{LpDataList-Jxyl9H5w.js → LpDataList-CcAA-rD9.js} +1 -1
- package/dist/chunks/{LpEditable-Cy6GLbFx.js → LpEditable-CSuJIPbG.js} +2 -2
- package/dist/chunks/{LpFileTree-zIFEgo3I.js → LpFileTree-CxOh3rL2.js} +1 -1
- package/dist/chunks/{LpFileTreeNode-cT6BIWvz.js → LpFileTreeNode-9ue2P7ER.js} +3 -3
- package/dist/chunks/{LpFormField-Ch69Jd-X.js → LpFormField-BBFg8i2I.js} +1 -1
- package/dist/chunks/{LpHintLayer-CgObdUsM.js → LpHintLayer-Db_s9_DL.js} +2 -2
- package/dist/chunks/{LpHints-Bz-BlaSl.js → LpHints-Cxf5GXsx.js} +3 -3
- package/dist/chunks/{LpInfraNode-46XOCkfq.js → LpInfraNode-6NLxkAnr.js} +2 -2
- package/dist/chunks/{LpInput-Tw-yxT4I.js → LpInput-B2dTt4pc.js} +1 -1
- package/dist/chunks/{LpLightbox-B95yu22B.js → LpLightbox-Coe4OBUl.js} +2 -2
- package/dist/chunks/{LpLoader-DVwkOmt9.js → LpLoader-DPTNhqLu.js} +1 -1
- package/dist/chunks/{LpLogViewer-D25jM2_I.js → LpLogViewer-DxiR6Mbd.js} +3 -3
- package/dist/chunks/{LpMapPicker-DRGgh89B.js → LpMapPicker-DeJRMfFN.js} +1 -1
- package/dist/chunks/{LpMediaGallery-Bkram-MO.js → LpMediaGallery-B7Km8N9l.js} +1 -1
- package/dist/chunks/{LpModalNav-DQpV2kdn.js → LpModalNav-BmxEyqOx.js} +2 -2
- package/dist/chunks/{LpNotificationBell-3244LUVc.js → LpNotificationBell-u8-ZjRON.js} +3 -3
- package/dist/chunks/{LpPaletteTheme-DiLYKQiZ.js → LpPaletteTheme-CWAIjBCi.js} +3 -3
- package/dist/chunks/{LpPasswordInput-BkHKQDhM.js → LpPasswordInput-Ih7Lv43S.js} +2 -2
- package/dist/chunks/{LpPie-DrZepi0p.js → LpPie-Idujdb3M.js} +2 -2
- package/dist/chunks/{LpPipeline-B3aOVOkV.js → LpPipeline-QCZWWB0G.js} +2 -2
- package/dist/chunks/{LpRepeater-D7ZmnIYd.js → LpRepeater-DghUJ3bc.js} +2 -2
- package/dist/chunks/{LpScramble-Bn9OoOtC.js → LpScramble-DeT_D36q.js} +1 -1
- package/dist/chunks/{LpSecretField-BbmqM9ye.js → LpSecretField-osKPNdNT.js} +6 -6
- package/dist/chunks/{LpShift-CCq7dofl.js → LpShift-kKUeG9NS.js} +4 -2
- package/dist/chunks/{LpSidebar-BoNLKgh-.js → LpSidebar-CR_WKcn2.js} +2 -2
- package/dist/chunks/{LpSidebarNav-Bky8chrv.js → LpSidebarNav-h3YunOAr.js} +2 -2
- package/dist/chunks/{LpSidebarRow-BRYhNDSo.js → LpSidebarRow-SjV0Ouhq.js} +1 -1
- package/dist/chunks/{LpStat-BVf2UvEc.js → LpStat-DXqKD1h5.js} +34 -18
- package/dist/chunks/{LpStatus-DglxttQ7.js → LpStatus-DfZREVe0.js} +2 -2
- package/dist/chunks/{LpStepMark-DpzKVyh8.js → LpStepMark-TaAyuNsH.js} +1 -1
- package/dist/chunks/{LpStepper-DpsocBNJ.js → LpStepper-CKSTFzHE.js} +1 -1
- package/dist/chunks/{LpSwap-C96c0LWh.js → LpSwap-KIS24N8W.js} +1 -1
- package/dist/chunks/{LpSwitch-BnXd1llc.js → LpSwitch-DlZHmj-M.js} +1 -1
- package/dist/chunks/{LpTabFace-DPCwKkH2.js → LpTabFace-JFJLW0kA.js} +1 -1
- package/dist/chunks/{LpTableFilter-CiVBpaq0.js → LpTableFilter-47ANnx_a.js} +3 -3
- package/dist/chunks/{LpTableOfContents-CraicEs4.js → LpTableOfContents-BN5zvpnx.js} +2 -2
- package/dist/chunks/{LpTagsInput-C-mDG648.js → LpTagsInput-CHoiid8u.js} +2 -2
- package/dist/chunks/{LpTextarea-TE-yZv2U.js → LpTextarea-CU7C1pLO.js} +1 -1
- package/dist/chunks/{LpThemeStudio-BpORDvH6.js → LpThemeStudio-zyOH3dF2.js} +2 -2
- package/dist/chunks/{LpThemeSwitcher-BnEn_mvf.js → LpThemeSwitcher-BXJhQYGD.js} +2 -2
- package/dist/chunks/{LpToaster-IwTXjbbU.js → LpToaster-C1D35SKk.js} +1 -1
- package/dist/chunks/{LpTopologyCanvas-B1gIbS0n.js → LpTopologyCanvas-1OufbBtQ.js} +1 -1
- package/dist/chunks/{LpTour-BZq-mUMv.js → LpTour-XshJslGg.js} +1 -1
- package/dist/chunks/{LpTruncate-CflAIwiJ.js → LpTruncate-qgKA-3K3.js} +1 -1
- package/dist/chunks/{LpUptimeBar-DqNvvMBK.js → LpUptimeBar-qhvvmmoI.js} +2 -2
- package/dist/chunks/{RevealToggle-BEit1n6Z.js → RevealToggle-6MlmohxS.js} +1 -1
- package/dist/chunks/{TourCard-DNclH3u_.js → TourCard-BuB-i4kv.js} +3 -3
- package/dist/components/DropzoneLinkField.vue.js +1 -1
- package/dist/components/FieldWrapper.vue.js +1 -1
- package/dist/components/LpActionBar.vue.js +1 -1
- package/dist/components/LpAddressInput.vue.js +1 -1
- package/dist/components/LpAlert.vue.js +1 -1
- package/dist/components/LpAppShell.vue.d.ts +20 -0
- package/dist/components/LpAppShell.vue.js +1 -1
- package/dist/components/LpBadge.vue.js +1 -1
- package/dist/components/LpBottomNav.vue.js +1 -1
- package/dist/components/LpBreadcrumbs.vue.js +1 -1
- package/dist/components/LpButton.vue.js +1 -1
- package/dist/components/LpCard.vue.js +1 -1
- package/dist/components/LpChart.vue.js +2 -2
- package/dist/components/LpCheckbox.vue.js +1 -1
- package/dist/components/LpCodeBlock.vue.js +1 -1
- package/dist/components/LpCodeDisplay.vue.js +1 -1
- package/dist/components/LpCommandPalette.vue.js +2 -2
- package/dist/components/LpConfirmDialog.vue.js +1 -1
- package/dist/components/LpConfirmHost.vue.js +1 -1
- package/dist/components/LpCopyButton.vue.js +1 -1
- package/dist/components/LpCountdown.vue.js +1 -1
- package/dist/components/LpDataList.vue.js +1 -1
- package/dist/components/LpDropzone.vue.js +1 -1
- package/dist/components/LpEditable.vue.js +1 -1
- package/dist/components/LpFileTree.vue.js +1 -1
- package/dist/components/LpFileTreeNode.vue.js +1 -1
- package/dist/components/LpFormField.vue.js +1 -1
- package/dist/components/LpHintLayer.vue.js +1 -1
- package/dist/components/LpHints.vue.js +1 -1
- package/dist/components/LpImageEditor.vue.js +1 -1
- package/dist/components/LpInfraNode.vue.js +1 -1
- package/dist/components/LpInput.vue.js +1 -1
- package/dist/components/LpLightbox.vue.js +1 -1
- package/dist/components/LpLoader.vue.js +1 -1
- package/dist/components/LpLogViewer.vue.js +1 -1
- package/dist/components/LpMapPicker.vue.js +1 -1
- package/dist/components/LpMediaGallery.vue.js +1 -1
- package/dist/components/LpModalNav.vue.js +1 -1
- package/dist/components/LpNotificationBell.vue.js +1 -1
- package/dist/components/LpPaletteTheme.vue.js +1 -1
- package/dist/components/LpPasswordInput.vue.js +1 -1
- package/dist/components/LpPie.vue.js +1 -1
- package/dist/components/LpPipeline.vue.js +1 -1
- package/dist/components/LpRepeater.vue.js +1 -1
- package/dist/components/LpScramble.vue.js +1 -1
- package/dist/components/LpSecretField.vue.js +1 -1
- package/dist/components/LpShift.vue.js +1 -1
- package/dist/components/LpSidebar.vue.js +1 -1
- package/dist/components/LpSidebarNav.vue.js +1 -1
- package/dist/components/LpSidebarRow.vue.js +1 -1
- package/dist/components/LpStat.vue.js +1 -1
- package/dist/components/LpStatus.vue.js +1 -1
- package/dist/components/LpStepMark.vue.js +1 -1
- package/dist/components/LpStepper.vue.js +1 -1
- package/dist/components/LpSwap.vue.js +1 -1
- package/dist/components/LpSwitch.vue.js +1 -1
- package/dist/components/LpTabFace.vue.js +1 -1
- package/dist/components/LpTable.vue.js +6 -6
- package/dist/components/LpTableFilter.vue.js +1 -1
- package/dist/components/LpTableOfContents.vue.js +1 -1
- package/dist/components/LpTabs.vue.js +1 -1
- package/dist/components/LpTagsInput.vue.js +1 -1
- package/dist/components/LpTextarea.vue.js +1 -1
- package/dist/components/LpThemeStudio.vue.js +1 -1
- package/dist/components/LpThemeSwitcher.vue.js +1 -1
- package/dist/components/LpToaster.vue.js +1 -1
- package/dist/components/LpTopologyCanvas.vue.js +1 -1
- package/dist/components/LpTour.vue.js +1 -1
- package/dist/components/LpTruncate.vue.js +1 -1
- package/dist/components/LpUptimeBar.vue.js +1 -1
- package/dist/components/RevealToggle.vue.js +1 -1
- package/dist/components/TourCard.vue.js +1 -1
- package/dist/composables/scroll.d.ts +2 -0
- package/dist/composables/scroll.js +4 -0
- package/dist/composables/scrollMemory.d.ts +1 -0
- package/dist/composables/scrollMemory.js +111 -0
- package/dist/composables/useFitScale.d.ts +5 -0
- package/dist/composables/useFitScale.js +30 -0
- package/dist/composables/useShift.d.ts +2 -0
- package/dist/composables/useShift.js +5 -0
- package/dist/index.js +56 -56
- package/package.json +1 -1
- package/src/components/LpAppShell.vue +18 -2
- package/src/components/LpShift.vue +4 -2
- package/src/components/LpStat.vue +24 -3
- package/src/components/LpTableOfContents.vue +4 -2
- package/src/composables/scroll.ts +5 -0
- package/src/composables/scrollMemory.ts +145 -0
- package/src/composables/useFitScale.ts +43 -0
- package/src/composables/useShift.ts +10 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { defineComponent, computed, useAttrs, ref, shallowRef, watch, onMounted, onBeforeUnmount, useId, h, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, createTextVNode, toDisplayString, createCommentVNode, Fragment, renderList, createBlock, createElementVNode, Transition, renderSlot, mergeProps, normalizeStyle, TransitionGroup, unref, withModifiers, nextTick } from "vue";
|
|
2
2
|
import { usePaletteScope, suppressPaletteDiscovery, usePaletteCommands } from "../composables/usePaletteCommands.js";
|
|
3
3
|
import { menuPaletteCommands } from "./commandPalette.js";
|
|
4
|
-
import { _ as _sfc_main$1 } from "../chunks/LpDataList-
|
|
5
|
-
import { _ as _sfc_main$9 } from "../chunks/LpCheckbox-
|
|
4
|
+
import { _ as _sfc_main$1 } from "../chunks/LpDataList-CcAA-rD9.js";
|
|
5
|
+
import { _ as _sfc_main$9 } from "../chunks/LpCheckbox-B0kJ-t6T.js";
|
|
6
6
|
import { _ as _sfc_main$8 } from "../chunks/LpContextMenu-rx2tCjwk.js";
|
|
7
7
|
import { _ as _sfc_main$d } from "../chunks/LpEmptyState-EQHiRYhG.js";
|
|
8
|
-
import { _ as _sfc_main$5 } from "../chunks/LpBadge-
|
|
8
|
+
import { _ as _sfc_main$5 } from "../chunks/LpBadge-0A6sPks3.js";
|
|
9
9
|
import { _ as _sfc_main$3 } from "../chunks/LpIcon--5WSb3jJ.js";
|
|
10
10
|
import { _ as _sfc_main$c } from "../chunks/LpSkeleton-BB6XIV-w.js";
|
|
11
11
|
import { _ as _sfc_main$e } from "../chunks/LpPagination-BIIiYHXR.js";
|
|
12
12
|
import { _ as _sfc_main$a } from "../chunks/LpPopover-DmZ3wUtP.js";
|
|
13
13
|
import { _ as _sfc_main$7 } from "../chunks/LpScrollArea-Hz3-JWUG.js";
|
|
14
14
|
import { _ as _sfc_main$6 } from "../chunks/LpRollingText-B54Pje7P.js";
|
|
15
|
-
import { _ as _sfc_main$4 } from "../chunks/LpShift-
|
|
16
|
-
import { _ as _sfc_main$b } from "../chunks/LpTableFilter-
|
|
15
|
+
import { _ as _sfc_main$4 } from "../chunks/LpShift-kKUeG9NS.js";
|
|
16
|
+
import { _ as _sfc_main$b } from "../chunks/LpTableFilter-47ANnx_a.js";
|
|
17
17
|
import { useKitStorage } from "../composables/usePersisted.js";
|
|
18
18
|
import { useAsyncTask } from "../composables/useAsyncTask.js";
|
|
19
19
|
import { useTableFacets } from "./tableFacets.js";
|
|
@@ -23,7 +23,7 @@ import { useRovingFocus } from "../composables/useRovingFocus.js";
|
|
|
23
23
|
import { useLabels } from "../composables/useLpConfig.js";
|
|
24
24
|
import { useResizeObserver } from "../composables/useResizeObserver.js";
|
|
25
25
|
import { compareValues } from "./tableSort.js";
|
|
26
|
-
import { _ as _sfc_main$2 } from "../chunks/LpButton-
|
|
26
|
+
import { _ as _sfc_main$2 } from "../chunks/LpButton-BgdewXxF.js";
|
|
27
27
|
import { toCsv, downloadFile, fileStem } from "./exportData.js";
|
|
28
28
|
import { summarizeShown, parseTableState, serializeTableState } from "./tableFilter.js";
|
|
29
29
|
import { resolveRowMenu } from "./tableRowMenu.js";
|
|
@@ -6,7 +6,7 @@ import { usePillTransition } from "../composables/usePillTransition.js";
|
|
|
6
6
|
import { prefersReducedMotion } from "../composables/easing.js";
|
|
7
7
|
import { _ as _sfc_main$1 } from "../chunks/LpContextMenu-rx2tCjwk.js";
|
|
8
8
|
import { _ as _sfc_main$3 } from "../chunks/LpSkeleton-BB6XIV-w.js";
|
|
9
|
-
import { _ as _sfc_main$2 } from "../chunks/LpTabFace-
|
|
9
|
+
import { _ as _sfc_main$2 } from "../chunks/LpTabFace-JFJLW0kA.js";
|
|
10
10
|
import { pickTab, BOTTOM_BAR, BOTTOM_ITEM, BOTTOM_MARKER } from "./tabs.js";
|
|
11
11
|
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper-1tPrXgE0.js";
|
|
12
12
|
import '../assets/LpTabs-CDchzoRL.css';const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -19,4 +19,6 @@ export interface ScrollToElementOptions {
|
|
|
19
19
|
margin?: number;
|
|
20
20
|
}
|
|
21
21
|
/** Scroll the nearest scroller, and only it, so that `el` is in view. */
|
|
22
|
+
/** The element's own `scroll-margin-top`, the gap it asks to keep above it when scrolled to. */
|
|
23
|
+
export declare function scrollMarginTop(el: Element): number;
|
|
22
24
|
export declare function scrollToElement(el: Element | null | undefined, { block, behavior, margin }?: ScrollToElementOptions): void;
|
|
@@ -15,6 +15,9 @@ function atScrollEnd(el, slack = 2) {
|
|
|
15
15
|
if (!box) return true;
|
|
16
16
|
return box.scrollTop + box.clientHeight >= box.scrollHeight - slack;
|
|
17
17
|
}
|
|
18
|
+
function scrollMarginTop(el) {
|
|
19
|
+
return Number.parseFloat(getComputedStyle(el).scrollMarginTop) || 0;
|
|
20
|
+
}
|
|
18
21
|
function scrollToElement(el, { block = "nearest", behavior = "auto", margin = 0 } = {}) {
|
|
19
22
|
if (!el) return;
|
|
20
23
|
const doc = el.ownerDocument;
|
|
@@ -33,6 +36,7 @@ function scrollToElement(el, { block = "nearest", behavior = "auto", margin = 0
|
|
|
33
36
|
}
|
|
34
37
|
export {
|
|
35
38
|
atScrollEnd,
|
|
39
|
+
scrollMarginTop,
|
|
36
40
|
scrollParent,
|
|
37
41
|
scrollToElement
|
|
38
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useScrollMemory(viewport: () => HTMLElement | null | undefined, path: () => string | undefined, hash: () => string | undefined): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { watch, nextTick, onMounted, onBeforeUnmount } from "vue";
|
|
2
|
+
import { scrollMarginTop } from "./scroll.js";
|
|
3
|
+
const SETTLE_MS = 1500;
|
|
4
|
+
const DIALOG_WAIT_MS = 2e3;
|
|
5
|
+
const SETTLE_STOP = ["wheel", "touchstart", "keydown", "pointerdown"];
|
|
6
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7
|
+
function addressKey() {
|
|
8
|
+
return `${location.pathname}${location.search}`;
|
|
9
|
+
}
|
|
10
|
+
function useScrollMemory(viewport, path, hash) {
|
|
11
|
+
if (typeof window === "undefined") return;
|
|
12
|
+
let current = addressKey();
|
|
13
|
+
let shown = path();
|
|
14
|
+
let travelled = false;
|
|
15
|
+
let stopHold;
|
|
16
|
+
let pending = 0;
|
|
17
|
+
const onPop = () => {
|
|
18
|
+
travelled = true;
|
|
19
|
+
};
|
|
20
|
+
window.addEventListener("popstate", onPop);
|
|
21
|
+
function anchor(value) {
|
|
22
|
+
if (!value || value === "#") return null;
|
|
23
|
+
const id = decodeURIComponent(value.replace(/^#/, ""));
|
|
24
|
+
return document.getElementById(id);
|
|
25
|
+
}
|
|
26
|
+
function reach(value, behavior) {
|
|
27
|
+
const view = viewport();
|
|
28
|
+
const target = anchor(value);
|
|
29
|
+
if (!view || !target || !view.contains(target)) return false;
|
|
30
|
+
const top = target.getBoundingClientRect().top - view.getBoundingClientRect().top + view.scrollTop - scrollMarginTop(target);
|
|
31
|
+
view.scrollTo({ top: Math.max(0, top), behavior });
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function hold(land) {
|
|
35
|
+
stopHold?.();
|
|
36
|
+
const view = viewport();
|
|
37
|
+
const content = view?.firstElementChild;
|
|
38
|
+
land();
|
|
39
|
+
if (!content) return;
|
|
40
|
+
const watcher = new ResizeObserver(land);
|
|
41
|
+
const timer = window.setTimeout(() => stop(), SETTLE_MS);
|
|
42
|
+
const stop = () => {
|
|
43
|
+
watcher.disconnect();
|
|
44
|
+
window.clearTimeout(timer);
|
|
45
|
+
for (const name of SETTLE_STOP) window.removeEventListener(name, stop, true);
|
|
46
|
+
if (stopHold === stop) stopHold = void 0;
|
|
47
|
+
};
|
|
48
|
+
for (const name of SETTLE_STOP) window.addEventListener(name, stop, { capture: true, passive: true });
|
|
49
|
+
watcher.observe(content);
|
|
50
|
+
stopHold = stop;
|
|
51
|
+
}
|
|
52
|
+
function arrive() {
|
|
53
|
+
const back = travelled;
|
|
54
|
+
travelled = false;
|
|
55
|
+
current = addressKey();
|
|
56
|
+
shown = path();
|
|
57
|
+
const view = viewport();
|
|
58
|
+
if (!view) return;
|
|
59
|
+
const saved = positions.get(current);
|
|
60
|
+
if (back && saved !== void 0) {
|
|
61
|
+
hold(() => view.scrollTo({ top: saved, behavior: "instant" }));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (hash()) {
|
|
65
|
+
hold(() => {
|
|
66
|
+
if (!reach(hash(), "instant")) view.scrollTo({ top: 0, behavior: "instant" });
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
stopHold?.();
|
|
71
|
+
view.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
72
|
+
}
|
|
73
|
+
function afterDialogs(run) {
|
|
74
|
+
const since = performance.now();
|
|
75
|
+
const mine = ++pending;
|
|
76
|
+
const tick = () => {
|
|
77
|
+
if (mine !== pending) return;
|
|
78
|
+
const locked = document.querySelector('[role="dialog"]') || getComputedStyle(document.body).overflow === "hidden";
|
|
79
|
+
if (locked && performance.now() - since < DIALOG_WAIT_MS) requestAnimationFrame(tick);
|
|
80
|
+
else run();
|
|
81
|
+
};
|
|
82
|
+
requestAnimationFrame(tick);
|
|
83
|
+
}
|
|
84
|
+
watch(
|
|
85
|
+
path,
|
|
86
|
+
() => {
|
|
87
|
+
const view = viewport();
|
|
88
|
+
if (view) positions.set(current, view.scrollTop);
|
|
89
|
+
void nextTick(() => requestAnimationFrame(arrive));
|
|
90
|
+
},
|
|
91
|
+
{ flush: "pre" }
|
|
92
|
+
);
|
|
93
|
+
watch(hash, (next, previous) => {
|
|
94
|
+
if (next === previous) return;
|
|
95
|
+
if (path() !== shown) return;
|
|
96
|
+
afterDialogs(() => {
|
|
97
|
+
travelled = false;
|
|
98
|
+
if (!reach(next, "smooth")) viewport()?.scrollTo({ top: 0, behavior: "smooth" });
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
onMounted(() => {
|
|
102
|
+
if (hash()) requestAnimationFrame(() => hold(() => void reach(hash(), "instant")));
|
|
103
|
+
});
|
|
104
|
+
onBeforeUnmount(() => {
|
|
105
|
+
stopHold?.();
|
|
106
|
+
window.removeEventListener("popstate", onPop);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
useScrollMemory
|
|
111
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref, onMounted, watch, onBeforeUnmount } from "vue";
|
|
2
|
+
function useFitScale(box, content, min = 0.6) {
|
|
3
|
+
const scale = ref(1);
|
|
4
|
+
const clipped = ref(false);
|
|
5
|
+
let observer;
|
|
6
|
+
function measure() {
|
|
7
|
+
const room = box.value?.clientWidth ?? 0;
|
|
8
|
+
const width = content.value?.scrollWidth ?? 0;
|
|
9
|
+
if (!room || !width) return;
|
|
10
|
+
const natural = width / scale.value;
|
|
11
|
+
const next = Math.max(min, Math.min(1, Math.floor(room / natural * 100) / 100));
|
|
12
|
+
if (next !== scale.value) scale.value = next;
|
|
13
|
+
clipped.value = natural * next > room + 0.5;
|
|
14
|
+
}
|
|
15
|
+
function observe() {
|
|
16
|
+
observer?.disconnect();
|
|
17
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
18
|
+
observer = new ResizeObserver(measure);
|
|
19
|
+
if (box.value) observer.observe(box.value);
|
|
20
|
+
if (content.value) observer.observe(content.value);
|
|
21
|
+
measure();
|
|
22
|
+
}
|
|
23
|
+
onMounted(observe);
|
|
24
|
+
watch([box, content], observe, { flush: "post" });
|
|
25
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
26
|
+
return { scale, clipped };
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
useFitScale
|
|
30
|
+
};
|
|
@@ -32,4 +32,6 @@ export interface UseShift {
|
|
|
32
32
|
/** Re-measure and ease to the current natural size. Rarely needed by hand. */
|
|
33
33
|
retune: () => void;
|
|
34
34
|
}
|
|
35
|
+
/** Set on the box while it eases its width: where that width will land. */
|
|
36
|
+
export declare const TARGET_WIDTH = "--lp-shift-to-w";
|
|
35
37
|
export declare function useShift(options?: UseShiftOptions): UseShift;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, watch, toValue, onBeforeUnmount } from "vue";
|
|
2
2
|
import { prefersReducedMotion } from "./easing.js";
|
|
3
|
+
const TARGET_WIDTH = "--lp-shift-to-w";
|
|
3
4
|
const TWEEN_MS = 160;
|
|
4
5
|
const RETARGET_AFTER_MS = 40;
|
|
5
6
|
function useShift(options = {}) {
|
|
@@ -54,6 +55,7 @@ function useShift(options = {}) {
|
|
|
54
55
|
if (wantsWidth()) node.style.width = "";
|
|
55
56
|
const toHeight = wantsHeight() ? node.offsetHeight : 0;
|
|
56
57
|
const toWidth = wantsWidth() ? node.offsetWidth : 0;
|
|
58
|
+
const exactWidth = wantsWidth() ? Math.ceil(node.getBoundingClientRect().width) : 0;
|
|
57
59
|
restoreScroll(tops);
|
|
58
60
|
lastHeight = toHeight;
|
|
59
61
|
lastWidth = toWidth;
|
|
@@ -67,6 +69,7 @@ function useShift(options = {}) {
|
|
|
67
69
|
void node.offsetHeight;
|
|
68
70
|
if (movesHeight) node.style.height = `${toHeight}px`;
|
|
69
71
|
if (movesWidth) node.style.width = `${toWidth}px`;
|
|
72
|
+
if (movesWidth) node.style.setProperty(TARGET_WIDTH, `${exactWidth}px`);
|
|
70
73
|
restoreScroll(tops);
|
|
71
74
|
inFlight = true;
|
|
72
75
|
tweenStart = performance.now();
|
|
@@ -78,6 +81,7 @@ function useShift(options = {}) {
|
|
|
78
81
|
resizing.value = false;
|
|
79
82
|
if (wantsHeight()) node.style.height = "";
|
|
80
83
|
if (wantsWidth()) node.style.width = "";
|
|
84
|
+
node.style.removeProperty(TARGET_WIDTH);
|
|
81
85
|
lastHeight = node.offsetHeight;
|
|
82
86
|
lastWidth = node.offsetWidth;
|
|
83
87
|
}, wait);
|
|
@@ -140,5 +144,6 @@ function useShift(options = {}) {
|
|
|
140
144
|
return { el, tweening, resizing, retune };
|
|
141
145
|
}
|
|
142
146
|
export {
|
|
147
|
+
TARGET_WIDTH,
|
|
143
148
|
useShift
|
|
144
149
|
};
|