@vite-hub/ui 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -76
- package/dist/announce-Cy_Tn9wW.js +32 -0
- package/dist/{avatar-stack-DPRFuezh.d.ts → avatar-stack-DXmCQhxd.d.ts} +1 -1
- package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
- package/dist/{comment-composer-fINL5bxo.d.ts → comment-composer-DvKMTrAi.d.ts} +4 -4
- package/dist/{comment-layer-C_sbPIR5.d.ts → comment-layer-GTsLdABl.d.ts} +4 -4
- package/dist/{comment-list-BcSaLngS.d.ts → comment-list-BI96empx.d.ts} +2 -2
- package/dist/comment-marks.css +18 -22
- package/dist/{comment-panel-CfvdRUMX.d.ts → comment-panel-CsKWTms_.d.ts} +2 -2
- package/dist/{comment-pin-DHOdRvUw.d.ts → comment-pin-CvwgRSDR.d.ts} +1 -1
- package/dist/{comment-row-Bn3nr8l5.js → comment-row-JmTC0uXr.js} +1 -1
- package/dist/comment-send-7bg4NEEM.js +277 -0
- package/dist/comment-send-C45dHC22.d.ts +25 -0
- package/dist/comment-send.css +267 -0
- package/dist/comment-thread-B_Sc2QX6.js +797 -0
- package/dist/{comment-thread-DKJjmWN0.d.ts → comment-thread-C6U-bsK_.d.ts} +4 -4
- package/dist/{comments-D0d26ghV.js → comments-B88zg9gC.js} +1 -1
- package/dist/{comments-context-C2lOZyQ5.js → comments-context-DhbIdYQ1.js} +2 -1
- package/dist/{config-Dk67emQt.js → config-B1u7zqMB.js} +8 -1
- package/dist/{config-DgxBW013.d.ts → config-pHazYdq6.d.ts} +11 -0
- package/dist/drop-field-3CDRFFRm.js +163 -0
- package/dist/{editor-C_wt4RRV.js → editor-BHYGLgty.js} +42 -3
- package/dist/effects-Ql6VzCRa.js +2971 -0
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/hold-to-delete-DjWzRDyY.d.ts +51 -0
- package/dist/hold-to-delete-ROLQRZg_.js +434 -0
- package/dist/icon-c5Jb_Tl7.d.ts +31 -0
- package/dist/{image-preview-C9tdkmEj.js → image-preview-BigoAvb3.js} +2 -2
- package/dist/{index-BYRFQfCd.d.ts → index-YUvL2nV8.d.ts} +8 -10
- package/dist/index.d.ts +19 -14
- package/dist/index.js +45 -44
- package/dist/install-D5f6msEU.js +17 -0
- package/dist/list-RCbNZ14q.js +271 -0
- package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-Dfl2DgPS.js} +1 -1
- package/dist/markdown-editor.js +1 -1
- package/dist/{message-scroller-jrYN9dG9.d.ts → message-scroller-Bm1YWTeY.d.ts} +2 -2
- package/dist/motion/core.d.ts +4 -0
- package/dist/motion/core.js +11 -0
- package/dist/motion-core-lHRF8PZz.d.ts +456 -0
- package/dist/motion.d.ts +16 -0
- package/dist/motion.js +13 -0
- package/dist/{nuxt-ui-DSQFzq3s.js → nuxt-ui-CgvMzO5v.js} +20 -14
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +12 -3
- package/dist/opt-out-b6bnUjIT.js +208 -0
- package/dist/parts/components/agent-session.js +1 -1
- package/dist/parts/components/attachment.d.ts +1 -1
- package/dist/parts/components/attachment.js +1 -1
- package/dist/parts/components/avatar-stack.d.ts +1 -1
- package/dist/parts/components/avatar-stack.js +2 -1
- package/dist/parts/components/bubble.d.ts +1 -1
- package/dist/parts/components/chat-session.d.ts +1 -1
- package/dist/parts/components/chat.js +2 -2
- package/dist/parts/components/code-block.d.ts +1 -1
- package/dist/parts/components/code-block.js +1 -1
- package/dist/parts/components/comment-composer.d.ts +1 -1
- package/dist/parts/components/comment-composer.js +1 -1
- package/dist/parts/components/comment-layer.d.ts +1 -1
- package/dist/parts/components/comment-layer.js +24 -6
- package/dist/parts/components/comment-list.d.ts +1 -1
- package/dist/parts/components/comment-list.js +12 -7
- package/dist/parts/components/comment-panel.d.ts +1 -1
- package/dist/parts/components/comment-panel.js +24 -10
- package/dist/parts/components/comment-pin.d.ts +1 -1
- package/dist/parts/components/comment-selection-bar.js +3 -2
- package/dist/parts/components/comment-send.d.ts +2 -0
- package/dist/parts/components/comment-send.js +2 -0
- package/dist/parts/components/comment-thread.d.ts +1 -1
- package/dist/parts/components/comment-thread.js +2 -597
- package/dist/parts/components/comments.d.ts +8 -7
- package/dist/parts/components/comments.js +5 -4
- package/dist/parts/components/copy-button.d.ts +13 -3
- package/dist/parts/components/copy-button.js +226 -1
- package/dist/parts/components/device-frame.d.ts +2 -2
- package/dist/parts/components/drop-field.d.ts +69 -0
- package/dist/parts/components/drop-field.js +77 -0
- package/dist/parts/components/filter-search.js +1 -1
- package/dist/parts/components/hold-to-delete.d.ts +82 -0
- package/dist/parts/components/hold-to-delete.js +76 -0
- package/dist/parts/components/markdown-editor.js +1 -1
- package/dist/parts/components/markdown-renderer.js +1 -1
- package/dist/parts/components/markdown.js +1 -1
- package/dist/parts/components/marker.d.ts +1 -1
- package/dist/parts/components/message-parts.js +13 -5
- package/dist/parts/components/motion-list.d.ts +42 -0
- package/dist/parts/components/motion-list.js +42 -0
- package/dist/parts/components/motion.d.ts +124 -0
- package/dist/parts/components/motion.js +172 -0
- package/dist/parts/components/progress.d.ts +41 -0
- package/dist/parts/components/progress.js +54 -0
- package/dist/parts/components/prompt-input.d.ts +5 -5
- package/dist/parts/components/prompt-input.js +3 -3
- package/dist/parts/components/relative-time.js +1 -1
- package/dist/parts/components/sync-status.js +2 -1
- package/dist/parts/components/tool-list.d.ts +1 -1
- package/dist/parts/components/trace-run.d.ts +1 -1
- package/dist/parts/components/trace-run.js +1 -1
- package/dist/parts/components/trace.d.ts +1 -1
- package/dist/parts/headless/comments.js +1 -1
- package/dist/parts/headless/message-scroller.d.ts +1 -1
- package/dist/parts/playground/share.d.ts +36 -2
- package/dist/parts/workspace/browser-support-notice.d.ts +1 -1
- package/dist/parts/workspace/browser-support-notice.js +12 -4
- package/dist/parts/workspace/codemirror.d.ts +9 -0
- package/dist/parts/workspace/codemirror.js +37 -4
- package/dist/parts/workspace/connect-panel.d.ts +1 -1
- package/dist/parts/workspace/connect-panel.js +1 -1
- package/dist/parts/workspace/file-icons.d.ts +16 -0
- package/dist/parts/workspace/file-icons.js +82 -0
- package/dist/parts/workspace/icons.d.ts +1 -0
- package/dist/parts/workspace/icons.js +1 -0
- package/dist/parts/workspace/runners/render.d.ts +26 -0
- package/dist/parts/workspace/runners/render.js +124 -0
- package/dist/parts/workspace/runners/web-container.d.ts +29 -0
- package/dist/parts/workspace/runners/web-container.js +186 -0
- package/dist/parts/workspace/workspace-bar.d.ts +51 -0
- package/dist/parts/workspace/workspace-bar.js +51 -0
- package/dist/parts/workspace/workspace-editor-head.d.ts +47 -0
- package/dist/parts/workspace/workspace-editor-head.js +66 -0
- package/dist/parts/workspace/workspace-editor.d.ts +17 -0
- package/dist/parts/workspace/workspace-editor.js +29 -3
- package/dist/parts/workspace/workspace-examples.d.ts +74 -0
- package/dist/parts/workspace/workspace-examples.js +72 -0
- package/dist/parts/workspace/workspace-file-link.d.ts +35 -0
- package/dist/parts/workspace/workspace-file-link.js +39 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +8 -8
- package/dist/parts/workspace/workspace-file-tree.js +26 -19
- package/dist/parts/workspace/workspace-guide.d.ts +52 -0
- package/dist/parts/workspace/workspace-guide.js +91 -0
- package/dist/parts/workspace/workspace-issues.d.ts +46 -0
- package/dist/parts/workspace/workspace-issues.js +49 -0
- package/dist/parts/workspace/workspace-preview.js +1 -1
- package/dist/parts/workspace/workspace-shell.d.ts +2 -88
- package/dist/parts/workspace/workspace-shell.js +131 -78
- package/dist/parts/workspace/workspace-sidebar.d.ts +75 -0
- package/dist/parts/workspace/workspace-sidebar.js +132 -0
- package/dist/parts/workspace/workspace-start.d.ts +47 -0
- package/dist/parts/workspace/workspace-start.js +60 -0
- package/dist/parts/workspace/workspace-status.d.ts +69 -0
- package/dist/parts/workspace/workspace-status.js +74 -0
- package/dist/parts/workspace/workspace-steps.d.ts +2 -0
- package/dist/parts/workspace/workspace-steps.js +128 -0
- package/dist/parts/workspace/workspace-task.d.ts +20 -0
- package/dist/parts/workspace/workspace-task.js +20 -0
- package/dist/parts/workspace/workspace.d.ts +251 -0
- package/dist/parts/workspace/workspace.js +665 -0
- package/dist/playground.d.ts +1 -1
- package/dist/progress-C7afI5vq.js +266 -0
- package/dist/registry-D3-ysX7l.js +78 -0
- package/dist/{relative-time-BVmjOsYG.js → relative-time-DgSS3zKN.js} +1 -1
- package/dist/ring-B7Qxu7zd.js +175 -0
- package/dist/runtime/nuxt-plugin.js +2 -2
- package/dist/styles.css +586 -573
- package/dist/text-BCJflBJf.js +826 -0
- package/dist/theme.d.ts +43 -0
- package/dist/theme.js +22 -7
- package/dist/travel-C87xd5Wh.js +182 -0
- package/dist/tween-CO24nMpf.js +62 -0
- package/dist/{types-Dj7vp0lZ.d.ts → types-BX64qHlV.d.ts} +1 -1
- package/dist/visual-copy-CrVc3z4n.js +15 -0
- package/dist/workspace-shell-BJGnoF3p.d.ts +112 -0
- package/dist/workspace-steps-Bgph2rpr.d.ts +72 -0
- package/dist/workspace.d.ts +16 -3
- package/dist/workspace.js +15 -2
- package/package.json +21 -10
- package/dist/copy-button-CRN3kmSD.js +0 -253
- package/dist/icon-swap.css +0 -69
- package/dist/parts/playground/highlight.d.ts +0 -5
- package/dist/parts/playground/highlight.js +0 -23
- package/dist/parts/playground/playground-render.d.ts +0 -126
- package/dist/parts/playground/playground-render.js +0 -356
- package/dist/parts/workspace/playground-container.d.ts +0 -192
- package/dist/parts/workspace/playground-container.js +0 -603
- package/dist/share-DM4eNy4q.d.ts +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CommentComposerSlots, r as CommentComposerSize } from "./comment-composer-
|
|
1
|
+
import { i as CommentComposerSlots, r as CommentComposerSize } from "./comment-composer-DvKMTrAi.js";
|
|
2
2
|
import { t as CommentCan } from "./comments-D8hulVPy.js";
|
|
3
3
|
import { PropType, SlotsType, VNode } from "vue";
|
|
4
4
|
import { CommentDelivery, CommentMessage, CommentThread, CommentUser } from "@vite-hub/comments/client";
|
|
@@ -372,12 +372,12 @@ declare const CommentThread$1: import("vue").DefineComponent<import("vue").Extra
|
|
|
372
372
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
373
373
|
}>, {
|
|
374
374
|
size: CommentComposerSize;
|
|
375
|
-
people: CommentUser[];
|
|
376
|
-
readOnly: boolean;
|
|
377
375
|
preview: boolean;
|
|
378
376
|
busy: boolean;
|
|
379
|
-
|
|
377
|
+
people: CommentUser[];
|
|
380
378
|
attachments: boolean;
|
|
379
|
+
readOnly: boolean;
|
|
380
|
+
detached: boolean;
|
|
381
381
|
navigation: "close" | "back";
|
|
382
382
|
dismissible: boolean;
|
|
383
383
|
}, SlotsType<CommentThreadSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as uiErrorDiagnostics } from "./error-diagnostics-SXtnk6bz.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as hasDirtyComposer, n as injectComments, s as shakeDirtyComposers, t as commentsKey } from "./comments-context-DhbIdYQ1.js";
|
|
3
3
|
import { createCommentVisibility } from "./parts/headless/comment-visibility.js";
|
|
4
4
|
import { computed, getCurrentInstance, isRef, onBeforeUnmount, onMounted, provide, reactive, ref, shallowRef, toRaw, toValue, watch } from "vue";
|
|
5
5
|
import { createAnchor, resolveAnchor } from "@vite-hub/comments/client";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { inject, onBeforeUnmount, onMounted } from "vue";
|
|
2
2
|
//#region src/internal/comment-outside.ts
|
|
3
|
+
const commentThreadPortals = Symbol("comment-thread-portals");
|
|
3
4
|
const consumedPointerEvents = /* @__PURE__ */ new WeakSet();
|
|
4
5
|
function swallowNextClick() {
|
|
5
6
|
const stop = (event) => {
|
|
@@ -35,4 +36,4 @@ const commentsKey = Symbol("ViteHubComments");
|
|
|
35
36
|
/** The state of the nearest `CommentLayer`, `CommentPanel`, or `provideComments()`, if there is one. Call it in `setup()`. */
|
|
36
37
|
const injectComments = () => inject(commentsKey, null) ?? void 0;
|
|
37
38
|
//#endregion
|
|
38
|
-
export {
|
|
39
|
+
export { hasDirtyComposer as a, shakeEventName as c, consumedPointerEvents as i, swallowNextClick as l, injectComments as n, pathOf as o, commentThreadPortals as r, shakeDirtyComposers as s, commentsKey as t, useDocumentPointerDown as u };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { t as uiComponentsKey } from "./nuxt-ui-
|
|
1
|
+
import { t as uiComponentsKey } from "./nuxt-ui-CgvMzO5v.js";
|
|
2
|
+
import { vRing } from "./parts/components/motion.js";
|
|
3
|
+
import { t as installMotion } from "./install-D5f6msEU.js";
|
|
2
4
|
import { computed, inject, toValue } from "vue";
|
|
3
5
|
//#region src/config.ts
|
|
4
6
|
const defaultOptions = {
|
|
@@ -14,9 +16,12 @@ const defaultIcons = {
|
|
|
14
16
|
arrowLeft: "i-lucide-arrow-left",
|
|
15
17
|
arrowUp: "i-lucide-arrow-up",
|
|
16
18
|
check: "i-lucide-check",
|
|
19
|
+
chevronLeft: "i-lucide-chevron-left",
|
|
20
|
+
chevronRight: "i-lucide-chevron-right",
|
|
17
21
|
close: "i-lucide-x",
|
|
18
22
|
copy: "i-lucide-copy",
|
|
19
23
|
copyCheck: "i-lucide-check",
|
|
24
|
+
loading: "i-lucide-loader-circle",
|
|
20
25
|
external: "i-lucide-external-link",
|
|
21
26
|
file: "i-lucide-file",
|
|
22
27
|
plus: "i-lucide-plus",
|
|
@@ -57,6 +62,8 @@ function createViteHubUI(options = {}) {
|
|
|
57
62
|
if (options.components) app.provide(uiComponentsKey, options.components);
|
|
58
63
|
if (options.icons) app.provide(iconsKey, options.icons);
|
|
59
64
|
app.provide(ViteHubUIInjectionKey, resolveViteHubUIDefaults(options));
|
|
65
|
+
if (options.motion !== false && typeof document !== "undefined") app.onUnmount(installMotion());
|
|
66
|
+
app.directive("ring", vRing);
|
|
60
67
|
} };
|
|
61
68
|
}
|
|
62
69
|
//#endregion
|
|
@@ -27,10 +27,16 @@ interface ViteHubUIIconOptions {
|
|
|
27
27
|
arrowUp?: string;
|
|
28
28
|
/** Resolve on a comment thread. */
|
|
29
29
|
check?: string;
|
|
30
|
+
/** The previous picture of an image preview. */
|
|
31
|
+
chevronLeft?: string;
|
|
32
|
+
/** The next picture of an image preview. */
|
|
33
|
+
chevronRight?: string;
|
|
30
34
|
/** Close a comment thread, an image preview, or remove an attachment. */
|
|
31
35
|
close?: string;
|
|
32
36
|
copy?: string;
|
|
33
37
|
copyCheck?: string;
|
|
38
|
+
/** The spinner of `CopyButton` while its text loads. */
|
|
39
|
+
loading?: string;
|
|
34
40
|
/** Open the original of an image preview. */
|
|
35
41
|
external?: string;
|
|
36
42
|
/** An attachment that is not an image. */
|
|
@@ -60,6 +66,11 @@ interface ViteHubUIOptions {
|
|
|
60
66
|
components?: ViteHubUIComponents;
|
|
61
67
|
/** Icons by name, such as `vitehubTheme.icons` from `@vite-hub/ui/theme`. A ref or a getter keeps them reactive. */
|
|
62
68
|
icons?: MaybeRefOrGetter<ViteHubUIIconOptions | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* The motion layer of `@vite-hub/ui/motion`: press, toggle, select, drag, and appear motion by role. It starts in the
|
|
71
|
+
* browser and stops when the app unmounts. `false` leaves it off. Default: `true`.
|
|
72
|
+
*/
|
|
73
|
+
motion?: boolean;
|
|
63
74
|
}
|
|
64
75
|
interface ResolvedViteHubUIDefaults {
|
|
65
76
|
markdown: {
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { a as onEachFrame, t as isMotionOff, u as prefersReducedMotion } from "./opt-out-b6bnUjIT.js";
|
|
2
|
+
//#region src/motion/drop-field.ts
|
|
3
|
+
const gap = 14;
|
|
4
|
+
const reach = 110;
|
|
5
|
+
const lean = 3;
|
|
6
|
+
const powerRate = .15;
|
|
7
|
+
const dotRate = .2;
|
|
8
|
+
const carriesFiles = (event) => [...event.dataTransfer?.types ?? []].includes("Files");
|
|
9
|
+
const rate = (perFrame, seconds) => 1 - (1 - perFrame) ** (seconds * 60);
|
|
10
|
+
/**
|
|
11
|
+
* The drop field of docs/design/motion.md: "Files are dragged in". A grid of dots behind the content of `surface` leans
|
|
12
|
+
* toward the dragged file and rests again when it leaves or drops. It wraps the native file drop of `field`: the drag
|
|
13
|
+
* events, `dropEffect`, and `onFiles`. A click or a key that opens a file picker stays with the field's own controls.
|
|
14
|
+
*
|
|
15
|
+
* The dots use `--vh-drop-dot`, or the text color of the surface. Under reduced motion and inside `data-motion="none"`
|
|
16
|
+
* the dots stay still; `data-over` still marks the field, so its colors change.
|
|
17
|
+
*/
|
|
18
|
+
function createDropField(field, options = {}) {
|
|
19
|
+
const surface = options.surface ?? field;
|
|
20
|
+
const accepts = options.accepts ?? carriesFiles;
|
|
21
|
+
const canvas = document.createElement("canvas");
|
|
22
|
+
canvas.dataset.part = "dots";
|
|
23
|
+
canvas.setAttribute("aria-hidden", "true");
|
|
24
|
+
Object.assign(canvas.style, {
|
|
25
|
+
height: "100%",
|
|
26
|
+
inset: "0",
|
|
27
|
+
pointerEvents: "none",
|
|
28
|
+
position: "absolute",
|
|
29
|
+
width: "100%",
|
|
30
|
+
zIndex: "-1"
|
|
31
|
+
});
|
|
32
|
+
if (getComputedStyle(surface).position === "static") surface.style.position = "relative";
|
|
33
|
+
surface.style.isolation = "isolate";
|
|
34
|
+
surface.prepend(canvas);
|
|
35
|
+
const context = canvas.getContext("2d");
|
|
36
|
+
let dots = [];
|
|
37
|
+
let pointer = {
|
|
38
|
+
x: -999,
|
|
39
|
+
y: -999
|
|
40
|
+
};
|
|
41
|
+
let over = false;
|
|
42
|
+
let depth = 0;
|
|
43
|
+
let power = 0;
|
|
44
|
+
let stop;
|
|
45
|
+
const still = () => prefersReducedMotion() || isMotionOff(surface);
|
|
46
|
+
function build() {
|
|
47
|
+
dots = [];
|
|
48
|
+
for (let y = 10; y < surface.clientHeight; y += gap) for (let x = 10; x < surface.clientWidth; x += gap) dots.push({
|
|
49
|
+
x,
|
|
50
|
+
y,
|
|
51
|
+
pull: 0
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function draw(seconds) {
|
|
55
|
+
if (!context) return false;
|
|
56
|
+
const ratio = devicePixelRatio || 1;
|
|
57
|
+
const width = surface.clientWidth;
|
|
58
|
+
const height = surface.clientHeight;
|
|
59
|
+
if (canvas.width !== Math.round(width * ratio) || canvas.height !== Math.round(height * ratio)) {
|
|
60
|
+
canvas.width = Math.round(width * ratio);
|
|
61
|
+
canvas.height = Math.round(height * ratio);
|
|
62
|
+
}
|
|
63
|
+
context.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
64
|
+
context.clearRect(0, 0, width, height);
|
|
65
|
+
const style = getComputedStyle(surface);
|
|
66
|
+
context.fillStyle = style.getPropertyValue("--vh-drop-dot").trim() || style.color;
|
|
67
|
+
const target = over ? 1 : 0;
|
|
68
|
+
const quiet = still();
|
|
69
|
+
power += (target - power) * rate(powerRate, seconds);
|
|
70
|
+
let moving = false;
|
|
71
|
+
for (const dot of dots) {
|
|
72
|
+
const distance = Math.hypot(dot.x - pointer.x, dot.y - pointer.y);
|
|
73
|
+
const want = quiet ? 0 : power * Math.max(0, 1 - distance / reach) ** 2;
|
|
74
|
+
dot.pull += (want - dot.pull) * rate(dotRate, seconds);
|
|
75
|
+
if (Math.abs(want - dot.pull) > .002) moving = true;
|
|
76
|
+
const shift = quiet ? 0 : dot.pull * lean;
|
|
77
|
+
const angle = Math.atan2(pointer.y - dot.y, pointer.x - dot.x);
|
|
78
|
+
context.globalAlpha = .16 + dot.pull * .7;
|
|
79
|
+
context.beginPath();
|
|
80
|
+
context.arc(dot.x + Math.cos(angle) * shift, dot.y + Math.sin(angle) * shift, .9 + dot.pull * 1.9, 0, Math.PI * 2);
|
|
81
|
+
context.fill();
|
|
82
|
+
}
|
|
83
|
+
context.globalAlpha = 1;
|
|
84
|
+
return moving || Math.abs(power - target) > .01;
|
|
85
|
+
}
|
|
86
|
+
function kick() {
|
|
87
|
+
if (stop) return;
|
|
88
|
+
stop = onEachFrame((seconds) => {
|
|
89
|
+
if (draw(seconds)) return true;
|
|
90
|
+
stop = void 0;
|
|
91
|
+
return false;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function setOver(next) {
|
|
95
|
+
if (next === over) return;
|
|
96
|
+
over = next;
|
|
97
|
+
if (next) field.dataset.over = "";
|
|
98
|
+
else delete field.dataset.over;
|
|
99
|
+
kick();
|
|
100
|
+
}
|
|
101
|
+
function locate(event) {
|
|
102
|
+
const box = surface.getBoundingClientRect();
|
|
103
|
+
pointer = {
|
|
104
|
+
x: event.clientX - box.left,
|
|
105
|
+
y: event.clientY - box.top
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const onEnter = (event) => {
|
|
109
|
+
if (!accepts(event)) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
depth++;
|
|
112
|
+
locate(event);
|
|
113
|
+
setOver(true);
|
|
114
|
+
};
|
|
115
|
+
const onOver = (event) => {
|
|
116
|
+
if (!accepts(event)) return;
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
|
|
119
|
+
locate(event);
|
|
120
|
+
setOver(true);
|
|
121
|
+
kick();
|
|
122
|
+
};
|
|
123
|
+
const onLeave = (event) => {
|
|
124
|
+
if (!accepts(event)) return;
|
|
125
|
+
depth = Math.max(0, depth - 1);
|
|
126
|
+
if (!depth) setOver(false);
|
|
127
|
+
};
|
|
128
|
+
const onDrop = (event) => {
|
|
129
|
+
if (!accepts(event)) return;
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
depth = 0;
|
|
132
|
+
setOver(false);
|
|
133
|
+
options.onFiles?.([...event.dataTransfer?.files ?? []], event);
|
|
134
|
+
};
|
|
135
|
+
field.addEventListener("dragenter", onEnter);
|
|
136
|
+
field.addEventListener("dragover", onOver);
|
|
137
|
+
field.addEventListener("dragleave", onLeave);
|
|
138
|
+
field.addEventListener("drop", onDrop);
|
|
139
|
+
const resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
140
|
+
build();
|
|
141
|
+
draw(0);
|
|
142
|
+
}) : void 0;
|
|
143
|
+
resize?.observe(surface);
|
|
144
|
+
build();
|
|
145
|
+
draw(0);
|
|
146
|
+
return {
|
|
147
|
+
get over() {
|
|
148
|
+
return over;
|
|
149
|
+
},
|
|
150
|
+
destroy() {
|
|
151
|
+
stop?.();
|
|
152
|
+
resize?.disconnect();
|
|
153
|
+
field.removeEventListener("dragenter", onEnter);
|
|
154
|
+
field.removeEventListener("dragover", onOver);
|
|
155
|
+
field.removeEventListener("dragleave", onLeave);
|
|
156
|
+
field.removeEventListener("drop", onDrop);
|
|
157
|
+
delete field.dataset.over;
|
|
158
|
+
canvas.remove();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { createDropField as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { r as useUIComponent } from "./nuxt-ui-
|
|
2
|
-
import { a as useViteHubUIIcons } from "./config-
|
|
1
|
+
import { r as useUIComponent } from "./nuxt-ui-CgvMzO5v.js";
|
|
2
|
+
import { a as useViteHubUIIcons } from "./config-B1u7zqMB.js";
|
|
3
|
+
import { t as createMotionList } from "./list-RCbNZ14q.js";
|
|
3
4
|
import { n as editorHandlersKey, t as createEditorHandlers } from "./handlers-DMl-Na3x.js";
|
|
4
|
-
import { computed, defineComponent, h, inject, onMounted, ref, shallowRef } from "vue";
|
|
5
|
+
import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, ref, shallowRef } from "vue";
|
|
5
6
|
import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIcon, MenuSeparator, MenuTrigger } from "@ui-sdk/vue/menu";
|
|
6
7
|
import { flip, offset, shift } from "@floating-ui/dom";
|
|
7
8
|
import DragHandle from "@tiptap/extension-drag-handle-vue-3";
|
|
@@ -481,6 +482,36 @@ const UEditorSuggestionMenu = defineComponent({
|
|
|
481
482
|
}
|
|
482
483
|
});
|
|
483
484
|
/**
|
|
485
|
+
* Moves the drag handle to each new place with the list mover of the motion layer, as a neighbor of a list moves. The
|
|
486
|
+
* drag handle extension places it with `left` and `top`. A handle that was hidden shows at its new place at once.
|
|
487
|
+
*/
|
|
488
|
+
function followPlace(element) {
|
|
489
|
+
const parent = element.parentElement;
|
|
490
|
+
if (!parent) return () => {};
|
|
491
|
+
const list = createMotionList(parent, { items: () => [element] });
|
|
492
|
+
const read = () => ({
|
|
493
|
+
place: `${element.style.left} ${element.style.top}`,
|
|
494
|
+
shown: element.style.visibility !== "hidden"
|
|
495
|
+
});
|
|
496
|
+
let last = read();
|
|
497
|
+
list.measure();
|
|
498
|
+
const observer = new MutationObserver(() => {
|
|
499
|
+
const next = read();
|
|
500
|
+
if (next.place === last.place && next.shown === last.shown) return;
|
|
501
|
+
if (next.shown && last.shown) list.play();
|
|
502
|
+
last = next;
|
|
503
|
+
list.measure();
|
|
504
|
+
});
|
|
505
|
+
observer.observe(element, {
|
|
506
|
+
attributes: true,
|
|
507
|
+
attributeFilter: ["style"]
|
|
508
|
+
});
|
|
509
|
+
return () => {
|
|
510
|
+
observer.disconnect();
|
|
511
|
+
list.destroy();
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
484
515
|
* Nuxt UI's `UEditorDragHandle`: a handle beside the block under the pointer, which drags the block to move it. A press
|
|
485
516
|
* selects the block and emits `nodeChange`. The default slot replaces the button and gets `onClick`, which selects the
|
|
486
517
|
* block and returns it, and `ui.handle()`, the class of a handle button.
|
|
@@ -542,6 +573,13 @@ const UEditorDragHandle = defineComponent({
|
|
|
542
573
|
props.ui.handle,
|
|
543
574
|
options?.class
|
|
544
575
|
].filter(Boolean).join(" ") };
|
|
576
|
+
const handle = ref();
|
|
577
|
+
let stopFollowing;
|
|
578
|
+
onMounted(() => {
|
|
579
|
+
const element = handle.value?.$el;
|
|
580
|
+
if (element instanceof HTMLElement) stopFollowing = followPlace(element);
|
|
581
|
+
});
|
|
582
|
+
onBeforeUnmount(() => stopFollowing?.());
|
|
545
583
|
const computePositionConfig = {
|
|
546
584
|
middleware: [
|
|
547
585
|
offset(({ rects }) => ({
|
|
@@ -557,6 +595,7 @@ const UEditorDragHandle = defineComponent({
|
|
|
557
595
|
return () => h(BlockHandle, {
|
|
558
596
|
class: ["vh-editor-drag-handle", props.ui.root].filter(Boolean).join(" "),
|
|
559
597
|
computePositionConfig,
|
|
598
|
+
ref: handle,
|
|
560
599
|
"data-slot": "editor-drag-handle",
|
|
561
600
|
editor: props.editor,
|
|
562
601
|
nested: props.nested,
|