@vite-hub/ui 0.3.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 +107 -81
- package/dist/announce-Cy_Tn9wW.js +32 -0
- package/dist/{code-view-D0bqhogi.js → code-view-DsU-xzic.js} +4 -4
- package/dist/comment-attachments-C4yNbcx5.js +20 -0
- package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
- package/dist/{comment-composer-Cc8Jvu6u.d.ts → comment-composer-DvKMTrAi.d.ts} +1 -1
- package/dist/{comment-layer-ClH4MLj4.d.ts → comment-layer-GTsLdABl.d.ts} +17 -6
- package/dist/{comment-list-B8hphLfS.d.ts → comment-list-BI96empx.d.ts} +2 -2
- package/dist/comment-marks.css +18 -22
- package/dist/{comment-panel-fcKSKwLC.d.ts → comment-panel-CsKWTms_.d.ts} +15 -4
- package/dist/{comment-row-Bbm9WwuF.js → comment-row-JmTC0uXr.js} +2 -2
- package/dist/comment-selection-bar-CyVBNYl9.d.ts +42 -0
- 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-CoTLrdal.d.ts → comment-thread-C6U-bsK_.d.ts} +23 -6
- package/dist/{comments-CkWc2Khc.js → comments-B88zg9gC.js} +66 -10
- package/dist/{comments-Bx2WRsYy.d.ts → comments-D8hulVPy.d.ts} +34 -6
- 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/format-orwcdZL_.js +39 -0
- package/dist/headless.d.ts +2 -2
- 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-BD1e8vx5.d.ts → index-YUvL2nV8.d.ts} +10 -6
- package/dist/index.d.ts +18 -12
- package/dist/index.js +47 -45
- 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-DqdZfIEn.d.ts → markdown-editor-wQF0yD5o.d.ts} +1 -1
- package/dist/markdown-editor.d.ts +1 -1
- package/dist/markdown-editor.js +1 -1
- 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 +2 -2
- package/dist/nuxt.js +20 -5
- package/dist/opt-out-b6bnUjIT.js +208 -0
- package/dist/parts/components/agent-session.js +1 -1
- package/dist/parts/components/attachment.js +1 -1
- package/dist/parts/components/avatar-stack.js +3 -2
- package/dist/parts/components/chat-session.d.ts +1 -1
- package/dist/parts/components/chat.js +2 -2
- package/dist/parts/components/code-block.js +1 -1
- package/dist/parts/components/code-view.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 +54 -23
- package/dist/parts/components/comment-list.d.ts +1 -1
- package/dist/parts/components/comment-list.js +13 -7
- package/dist/parts/components/comment-panel.d.ts +1 -1
- package/dist/parts/components/comment-panel.js +46 -20
- package/dist/parts/components/comment-pin.js +1 -1
- package/dist/parts/components/comment-selection-bar.d.ts +2 -0
- package/dist/parts/components/comment-selection-bar.js +117 -0
- 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 +2 -2
- package/dist/parts/components/comment-thread.js +2 -570
- package/dist/parts/components/comments.d.ts +8 -6
- package/dist/parts/components/comments.js +6 -4
- package/dist/parts/components/copy-button.d.ts +12 -2
- package/dist/parts/components/copy-button.js +226 -1
- 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.d.ts +1 -1
- 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/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 +3 -3
- 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 +2 -2
- package/dist/parts/headless/comments.d.ts +2 -2
- package/dist/parts/headless/comments.js +1 -1
- package/dist/parts/playground/share.d.ts +36 -2
- 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.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-boot-status.js +1 -1
- 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/{pierre-code-view-xgBL6DO7.js → pierre-code-view-NE35tkmR.js} +37 -17
- 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 +657 -526
- 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-Dyr6CfBW.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 +17 -4
- package/dist/workspace.js +16 -3
- package/package.json +22 -11
- package/dist/copy-button-CRN3kmSD.js +0 -253
- package/dist/format-Du58PlsG.js +0 -18
- 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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PropType, SlotsType, VNode } from "vue";
|
|
2
|
+
//#region src/workspace/workspace-sidebar.d.ts
|
|
3
|
+
/** An action at the bottom of the sidebar. */
|
|
4
|
+
export type WorkspaceSidebarAction = "reset" | "download" | "copy-link";
|
|
5
|
+
/**
|
|
6
|
+
* A panel that opens over the workspace from the sidebar button of `WorkspaceBar`, under the bar. It does not push the
|
|
7
|
+
* workspace. Focus moves into it when it opens and back to the button when it closes. Escape and a click outside close
|
|
8
|
+
* it. Reset, Download and Copy link sit at the bottom. Put it in the box of the bar, such as the `bar` slot of
|
|
9
|
+
* `WorkspaceShell`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const WorkspaceSidebar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
12
|
+
open: {
|
|
13
|
+
default: boolean;
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
};
|
|
16
|
+
id: {
|
|
17
|
+
default: undefined;
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
};
|
|
20
|
+
label: {
|
|
21
|
+
default: string;
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
};
|
|
24
|
+
actions: {
|
|
25
|
+
default: () => string[];
|
|
26
|
+
type: PropType<readonly WorkspaceSidebarAction[]>;
|
|
27
|
+
};
|
|
28
|
+
copied: {
|
|
29
|
+
default: boolean;
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
};
|
|
32
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
35
|
+
"update:open": (open: boolean) => boolean;
|
|
36
|
+
reset: () => true;
|
|
37
|
+
download: () => true;
|
|
38
|
+
"copy-link": () => true;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
|
+
open: {
|
|
41
|
+
default: boolean;
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
};
|
|
44
|
+
id: {
|
|
45
|
+
default: undefined;
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
};
|
|
48
|
+
label: {
|
|
49
|
+
default: string;
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
};
|
|
52
|
+
actions: {
|
|
53
|
+
default: () => string[];
|
|
54
|
+
type: PropType<readonly WorkspaceSidebarAction[]>;
|
|
55
|
+
};
|
|
56
|
+
copied: {
|
|
57
|
+
default: boolean;
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
};
|
|
60
|
+
}>> & Readonly<{
|
|
61
|
+
onReset?: (() => any) | undefined;
|
|
62
|
+
onDownload?: (() => any) | undefined;
|
|
63
|
+
"onCopy-link"?: (() => any) | undefined;
|
|
64
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
65
|
+
}>, {
|
|
66
|
+
label: string;
|
|
67
|
+
open: boolean;
|
|
68
|
+
actions: readonly WorkspaceSidebarAction[];
|
|
69
|
+
id: string;
|
|
70
|
+
copied: boolean;
|
|
71
|
+
}, SlotsType<{
|
|
72
|
+
default?: () => VNode[];
|
|
73
|
+
footer?: () => VNode[];
|
|
74
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
75
|
+
//#endregion
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
|
|
2
|
+
import { t as ring } from "../../ring-B7Qxu7zd.js";
|
|
3
|
+
import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from "vue";
|
|
4
|
+
//#region src/workspace/workspace-sidebar.ts
|
|
5
|
+
const tabbable = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])";
|
|
6
|
+
/**
|
|
7
|
+
* A panel that opens over the workspace from the sidebar button of `WorkspaceBar`, under the bar. It does not push the
|
|
8
|
+
* workspace. Focus moves into it when it opens and back to the button when it closes. Escape and a click outside close
|
|
9
|
+
* it. Reset, Download and Copy link sit at the bottom. Put it in the box of the bar, such as the `bar` slot of
|
|
10
|
+
* `WorkspaceShell`.
|
|
11
|
+
*/
|
|
12
|
+
const WorkspaceSidebar = defineComponent({
|
|
13
|
+
name: "WorkspaceSidebar",
|
|
14
|
+
props: {
|
|
15
|
+
open: {
|
|
16
|
+
default: false,
|
|
17
|
+
type: Boolean
|
|
18
|
+
},
|
|
19
|
+
id: {
|
|
20
|
+
default: void 0,
|
|
21
|
+
type: String
|
|
22
|
+
},
|
|
23
|
+
label: {
|
|
24
|
+
default: "Sidebar",
|
|
25
|
+
type: String
|
|
26
|
+
},
|
|
27
|
+
actions: {
|
|
28
|
+
default: () => [
|
|
29
|
+
"reset",
|
|
30
|
+
"download",
|
|
31
|
+
"copy-link"
|
|
32
|
+
],
|
|
33
|
+
type: Array
|
|
34
|
+
},
|
|
35
|
+
copied: {
|
|
36
|
+
default: false,
|
|
37
|
+
type: Boolean
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
emits: {
|
|
41
|
+
"update:open": (open) => typeof open === "boolean",
|
|
42
|
+
reset: () => true,
|
|
43
|
+
download: () => true,
|
|
44
|
+
"copy-link": () => true
|
|
45
|
+
},
|
|
46
|
+
slots: Object,
|
|
47
|
+
setup(props, { emit, slots }) {
|
|
48
|
+
const UButton = useUIComponent("UButton");
|
|
49
|
+
const fallbackId = useId();
|
|
50
|
+
const id = () => props.id ?? fallbackId;
|
|
51
|
+
const panel = ref();
|
|
52
|
+
const copyButton = ref();
|
|
53
|
+
let previous;
|
|
54
|
+
function enter() {
|
|
55
|
+
const active = document.activeElement;
|
|
56
|
+
previous = active instanceof HTMLElement ? active : void 0;
|
|
57
|
+
nextTick(() => {
|
|
58
|
+
(panel.value?.querySelector(tabbable) ?? panel.value)?.focus();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
watch(() => props.open, (open) => {
|
|
62
|
+
if (open) return enter();
|
|
63
|
+
const active = document.activeElement;
|
|
64
|
+
const inside = !active || active === document.body || !!panel.value?.contains(active);
|
|
65
|
+
const target = previous?.isConnected && previous !== document.body ? previous : document.querySelector(`[aria-controls="${CSS.escape(id())}"]`);
|
|
66
|
+
if (inside) target?.focus();
|
|
67
|
+
previous = void 0;
|
|
68
|
+
}, { flush: "pre" });
|
|
69
|
+
watch(() => props.copied, (copied) => {
|
|
70
|
+
const target = copyButton.value instanceof HTMLElement ? copyButton.value : copyButton.value?.$el;
|
|
71
|
+
if (copied && target instanceof HTMLElement) ring(target);
|
|
72
|
+
});
|
|
73
|
+
function outside(event) {
|
|
74
|
+
if (!props.open) return;
|
|
75
|
+
const path = event.composedPath();
|
|
76
|
+
if (panel.value && path.includes(panel.value)) return;
|
|
77
|
+
if (path.some((node) => node instanceof Element && node.getAttribute("aria-controls") === id())) return;
|
|
78
|
+
emit("update:open", false);
|
|
79
|
+
}
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
document.addEventListener("pointerdown", outside, true);
|
|
82
|
+
if (props.open) enter();
|
|
83
|
+
});
|
|
84
|
+
onBeforeUnmount(() => document.removeEventListener("pointerdown", outside, true));
|
|
85
|
+
const button = (action) => {
|
|
86
|
+
const shared = {
|
|
87
|
+
class: "vh-ws-sidebar-action",
|
|
88
|
+
color: "neutral",
|
|
89
|
+
key: action,
|
|
90
|
+
variant: "ghost"
|
|
91
|
+
};
|
|
92
|
+
if (action === "reset") return h(UButton, {
|
|
93
|
+
...shared,
|
|
94
|
+
icon: "i-lucide-rotate-ccw",
|
|
95
|
+
label: "Reset",
|
|
96
|
+
onClick: () => emit("reset")
|
|
97
|
+
});
|
|
98
|
+
if (action === "download") return h(UButton, {
|
|
99
|
+
...shared,
|
|
100
|
+
icon: "i-lucide-download",
|
|
101
|
+
label: "Download",
|
|
102
|
+
onClick: () => emit("download")
|
|
103
|
+
});
|
|
104
|
+
return h(UButton, {
|
|
105
|
+
...shared,
|
|
106
|
+
icon: props.copied ? "i-lucide-check" : "i-lucide-link",
|
|
107
|
+
label: props.copied ? "Link copied" : "Copy link",
|
|
108
|
+
ref: copyButton,
|
|
109
|
+
onClick: () => emit("copy-link")
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return () => {
|
|
113
|
+
const footer = slots.footer?.() ?? (props.actions.length ? props.actions.map(button) : void 0);
|
|
114
|
+
return h("aside", {
|
|
115
|
+
"aria-label": props.label,
|
|
116
|
+
class: "vh-ws-sidebar",
|
|
117
|
+
"data-open": props.open ? "" : void 0,
|
|
118
|
+
id: id(),
|
|
119
|
+
inert: !props.open,
|
|
120
|
+
ref: panel,
|
|
121
|
+
tabindex: -1,
|
|
122
|
+
onKeydown: (event) => {
|
|
123
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
emit("update:open", false);
|
|
126
|
+
}
|
|
127
|
+
}, [h("div", { class: "vh-ws-sidebar-body" }, slots.default?.()), footer ? h("div", { class: "vh-ws-sidebar-footer" }, footer) : void 0]);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
//#endregion
|
|
132
|
+
export { WorkspaceSidebar };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WorkspaceExample } from "./workspace-examples.js";
|
|
2
|
+
import { PropType, SlotsType, VNode } from "vue";
|
|
3
|
+
//#region src/workspace/workspace-start.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The start screen of a first visit: the examples as cards over the workspace, under the bar. A pick emits `pick` with
|
|
6
|
+
* the id of the example. Show it only when the page opens without a share link, so a link opens its files at once.
|
|
7
|
+
* Put it in the box of the bar, as `WorkspaceSidebar`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const WorkspaceStart: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
examples: {
|
|
11
|
+
required: true;
|
|
12
|
+
type: PropType<readonly WorkspaceExample[]>;
|
|
13
|
+
};
|
|
14
|
+
title: {
|
|
15
|
+
default: string;
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
};
|
|
18
|
+
description: {
|
|
19
|
+
default: string;
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
};
|
|
22
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
pick: (id: string) => boolean;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
+
examples: {
|
|
28
|
+
required: true;
|
|
29
|
+
type: PropType<readonly WorkspaceExample[]>;
|
|
30
|
+
};
|
|
31
|
+
title: {
|
|
32
|
+
default: string;
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
35
|
+
description: {
|
|
36
|
+
default: string;
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
};
|
|
39
|
+
}>> & Readonly<{
|
|
40
|
+
onPick?: ((id: string) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
title: string;
|
|
43
|
+
description: string;
|
|
44
|
+
}, SlotsType<{
|
|
45
|
+
footer?: () => VNode[];
|
|
46
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
47
|
+
//#endregion
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
|
|
2
|
+
import { defineComponent, h, useId } from "vue";
|
|
3
|
+
//#region src/workspace/workspace-start.ts
|
|
4
|
+
/**
|
|
5
|
+
* The start screen of a first visit: the examples as cards over the workspace, under the bar. A pick emits `pick` with
|
|
6
|
+
* the id of the example. Show it only when the page opens without a share link, so a link opens its files at once.
|
|
7
|
+
* Put it in the box of the bar, as `WorkspaceSidebar`.
|
|
8
|
+
*/
|
|
9
|
+
const WorkspaceStart = defineComponent({
|
|
10
|
+
name: "WorkspaceStart",
|
|
11
|
+
props: {
|
|
12
|
+
examples: {
|
|
13
|
+
required: true,
|
|
14
|
+
type: Array
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
default: "Start from an example",
|
|
18
|
+
type: String
|
|
19
|
+
},
|
|
20
|
+
description: {
|
|
21
|
+
default: "Each one runs in this tab. Edit it, then copy a link or download the files.",
|
|
22
|
+
type: String
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: { pick: (id) => typeof id === "string" },
|
|
26
|
+
slots: Object,
|
|
27
|
+
setup(props, { emit, slots }) {
|
|
28
|
+
const UIcon = useUIComponent("UIcon");
|
|
29
|
+
const titleId = useId();
|
|
30
|
+
const count = (files) => {
|
|
31
|
+
const length = files ? Object.keys(files).length : 0;
|
|
32
|
+
return files ? h("span", { class: "vh-ws-start-files" }, length === 1 ? "1 file" : `${length} files`) : void 0;
|
|
33
|
+
};
|
|
34
|
+
return () => h("section", {
|
|
35
|
+
"aria-labelledby": titleId,
|
|
36
|
+
class: "vh-ws-start"
|
|
37
|
+
}, h("div", { class: "vh-ws-start-content" }, [
|
|
38
|
+
h("h2", {
|
|
39
|
+
class: "vh-ws-start-title",
|
|
40
|
+
id: titleId
|
|
41
|
+
}, props.title),
|
|
42
|
+
h("p", { class: "vh-ws-start-description" }, props.description),
|
|
43
|
+
h("ul", { class: "vh-ws-start-grid" }, props.examples.map((example) => h("li", { key: example.id }, h("button", {
|
|
44
|
+
class: "vh-ws-start-card",
|
|
45
|
+
type: "button",
|
|
46
|
+
onClick: () => emit("pick", example.id)
|
|
47
|
+
}, [
|
|
48
|
+
h("span", { class: "vh-ws-start-label" }, example.label),
|
|
49
|
+
example.description ? h("span", { class: "vh-ws-start-text" }, example.description) : void 0,
|
|
50
|
+
count(example.files)
|
|
51
|
+
])))),
|
|
52
|
+
h("div", { class: "vh-ws-start-foot" }, slots.footer?.() ?? [h(UIcon, {
|
|
53
|
+
class: "vh-ws-icon",
|
|
54
|
+
name: "i-lucide-link"
|
|
55
|
+
}), "Opened from a share link? The files open at once, without this screen."])
|
|
56
|
+
]));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
//#endregion
|
|
60
|
+
export { WorkspaceStart };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PropType } from "vue";
|
|
2
|
+
//#region src/workspace/workspace-status.d.ts
|
|
3
|
+
/** The cursor position that `WorkspaceEditor` emits with `cursor`. Both numbers start at 1. */
|
|
4
|
+
export interface WorkspaceCursor {
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
/** The name of the language of `path`, as VS Code shows it, such as `TypeScript` for `app.ts`. */
|
|
9
|
+
export declare function workspaceLanguage(path: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The status line under the editor: the cursor line and column, the language of the open file, and the indentation.
|
|
12
|
+
* Put it in the `status` slot of `WorkspaceShell`, which makes the line 24px high.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WorkspaceStatus: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
15
|
+
/** The path of the open file. It names the language. */
|
|
16
|
+
path: {
|
|
17
|
+
required: true;
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
};
|
|
20
|
+
/** The cursor, from the `cursor` event of `WorkspaceEditor`. */
|
|
21
|
+
cursor: {
|
|
22
|
+
default: () => {
|
|
23
|
+
column: number;
|
|
24
|
+
line: number;
|
|
25
|
+
};
|
|
26
|
+
type: PropType<WorkspaceCursor>;
|
|
27
|
+
};
|
|
28
|
+
/** The language name. By default it comes from the file extension. */
|
|
29
|
+
language: {
|
|
30
|
+
default: undefined;
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
};
|
|
33
|
+
/** The indentation: a number of spaces, or `"tab"`. */
|
|
34
|
+
indent: {
|
|
35
|
+
default: number;
|
|
36
|
+
type: PropType<number | "tab">;
|
|
37
|
+
};
|
|
38
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
|
+
/** The path of the open file. It names the language. */
|
|
42
|
+
path: {
|
|
43
|
+
required: true;
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
};
|
|
46
|
+
/** The cursor, from the `cursor` event of `WorkspaceEditor`. */
|
|
47
|
+
cursor: {
|
|
48
|
+
default: () => {
|
|
49
|
+
column: number;
|
|
50
|
+
line: number;
|
|
51
|
+
};
|
|
52
|
+
type: PropType<WorkspaceCursor>;
|
|
53
|
+
};
|
|
54
|
+
/** The language name. By default it comes from the file extension. */
|
|
55
|
+
language: {
|
|
56
|
+
default: undefined;
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
};
|
|
59
|
+
/** The indentation: a number of spaces, or `"tab"`. */
|
|
60
|
+
indent: {
|
|
61
|
+
default: number;
|
|
62
|
+
type: PropType<number | "tab">;
|
|
63
|
+
};
|
|
64
|
+
}>> & Readonly<{}>, {
|
|
65
|
+
cursor: WorkspaceCursor;
|
|
66
|
+
language: string;
|
|
67
|
+
indent: number | "tab";
|
|
68
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
69
|
+
//#endregion
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
//#region src/workspace/workspace-status.ts
|
|
3
|
+
const languages = {
|
|
4
|
+
astro: "Astro",
|
|
5
|
+
cjs: "JavaScript",
|
|
6
|
+
css: "CSS",
|
|
7
|
+
html: "HTML",
|
|
8
|
+
js: "JavaScript",
|
|
9
|
+
json: "JSON",
|
|
10
|
+
jsonc: "JSON with Comments",
|
|
11
|
+
jsonl: "JSON Lines",
|
|
12
|
+
jsx: "JavaScript JSX",
|
|
13
|
+
md: "Markdown",
|
|
14
|
+
mdx: "MDX",
|
|
15
|
+
mjs: "JavaScript",
|
|
16
|
+
mts: "TypeScript",
|
|
17
|
+
svelte: "Svelte",
|
|
18
|
+
ts: "TypeScript",
|
|
19
|
+
tsx: "TypeScript JSX",
|
|
20
|
+
vue: "Vue"
|
|
21
|
+
};
|
|
22
|
+
/** The name of the language of `path`, as VS Code shows it, such as `TypeScript` for `app.ts`. */
|
|
23
|
+
function workspaceLanguage(path) {
|
|
24
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
25
|
+
const dot = name.lastIndexOf(".");
|
|
26
|
+
const type = dot > 0 ? name.slice(dot + 1).toLowerCase() : "";
|
|
27
|
+
return Object.hasOwn(languages, type) ? languages[type] : "Plain Text";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The status line under the editor: the cursor line and column, the language of the open file, and the indentation.
|
|
31
|
+
* Put it in the `status` slot of `WorkspaceShell`, which makes the line 24px high.
|
|
32
|
+
*/
|
|
33
|
+
const WorkspaceStatus = defineComponent({
|
|
34
|
+
name: "WorkspaceStatus",
|
|
35
|
+
props: {
|
|
36
|
+
/** The path of the open file. It names the language. */
|
|
37
|
+
path: {
|
|
38
|
+
required: true,
|
|
39
|
+
type: String
|
|
40
|
+
},
|
|
41
|
+
/** The cursor, from the `cursor` event of `WorkspaceEditor`. */
|
|
42
|
+
cursor: {
|
|
43
|
+
default: () => ({
|
|
44
|
+
column: 1,
|
|
45
|
+
line: 1
|
|
46
|
+
}),
|
|
47
|
+
type: Object
|
|
48
|
+
},
|
|
49
|
+
/** The language name. By default it comes from the file extension. */
|
|
50
|
+
language: {
|
|
51
|
+
default: void 0,
|
|
52
|
+
type: String
|
|
53
|
+
},
|
|
54
|
+
/** The indentation: a number of spaces, or `"tab"`. */
|
|
55
|
+
indent: {
|
|
56
|
+
default: 2,
|
|
57
|
+
type: [Number, String]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
setup(props, { slots }) {
|
|
61
|
+
return () => {
|
|
62
|
+
const language = props.language ?? workspaceLanguage(props.path);
|
|
63
|
+
const indent = props.indent === "tab" ? "Tabs" : `Spaces: ${props.indent}`;
|
|
64
|
+
return h("div", { class: "vh-ws-status-items" }, [
|
|
65
|
+
h("span", { class: "vh-ws-status-cursor" }, [h("span", { "aria-hidden": "true" }, `Ln ${props.cursor.line}, Col ${props.cursor.column}`), h("span", { class: "vh-ws-sr-only" }, `Line ${props.cursor.line}, column ${props.cursor.column}`)]),
|
|
66
|
+
h("span", { title: language }, language),
|
|
67
|
+
h("span", { title: indent }, indent),
|
|
68
|
+
slots.default ? [h("span", { class: "vh-ws-status-spacer" }), slots.default()] : void 0
|
|
69
|
+
]);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
//#endregion
|
|
74
|
+
export { WorkspaceStatus, workspaceLanguage };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
|
|
2
|
+
import { computed, defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
//#region src/workspace/workspace-steps.ts
|
|
4
|
+
/**
|
|
5
|
+
* The current step of `v-model:step`, from 0, kept inside the steps. Without a `step` prop the part keeps its own.
|
|
6
|
+
* `go(index)` moves to a step that exists and does nothing for one that does not.
|
|
7
|
+
*/
|
|
8
|
+
function useStepModel(props, emit) {
|
|
9
|
+
const local = ref(0);
|
|
10
|
+
const current = computed(() => {
|
|
11
|
+
const last = Math.max(0, props.steps.length - 1);
|
|
12
|
+
return Math.min(last, Math.max(0, Math.trunc(props.step ?? local.value)));
|
|
13
|
+
});
|
|
14
|
+
function go(index) {
|
|
15
|
+
if (!Number.isInteger(index) || index < 0 || index >= props.steps.length || index === current.value) return;
|
|
16
|
+
local.value = index;
|
|
17
|
+
emit("update:step", index);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
current,
|
|
21
|
+
go
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const focusable = "button:not(:disabled), a[href]";
|
|
25
|
+
/**
|
|
26
|
+
* After a move from a control inside `root`, focus the control that `pick` returns when the move removed or disabled
|
|
27
|
+
* the focused one. Focus that is still on a live control stays where it is.
|
|
28
|
+
*/
|
|
29
|
+
function keepFocus(root, pick) {
|
|
30
|
+
nextTick(() => {
|
|
31
|
+
const element = root();
|
|
32
|
+
if (!element || typeof document === "undefined") return;
|
|
33
|
+
const active = document.activeElement;
|
|
34
|
+
if (!active || active === document.body || !active.isConnected || active instanceof HTMLButtonElement && active.disabled) pick([...element.querySelectorAll(focusable)])?.focus();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The steps of a lesson for the bar of a workspace: a menu with every step, the position, and Back and Next.
|
|
39
|
+
* Use `v-model:step`. The step is a 0-based index.
|
|
40
|
+
*/
|
|
41
|
+
const WorkspaceSteps = defineComponent({
|
|
42
|
+
name: "WorkspaceSteps",
|
|
43
|
+
props: {
|
|
44
|
+
/** The steps of the lesson, in order. */
|
|
45
|
+
steps: {
|
|
46
|
+
required: true,
|
|
47
|
+
type: Array
|
|
48
|
+
},
|
|
49
|
+
/** The current step, from 0. Use `v-model:step`. */
|
|
50
|
+
step: {
|
|
51
|
+
default: void 0,
|
|
52
|
+
type: Number
|
|
53
|
+
},
|
|
54
|
+
/** A heading over the steps in the menu, such as the name of the lesson. */
|
|
55
|
+
label: {
|
|
56
|
+
default: void 0,
|
|
57
|
+
type: String
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
emits: { "update:step": (step) => Number.isInteger(step) },
|
|
61
|
+
setup(props, { emit }) {
|
|
62
|
+
const { current, go } = useStepModel(props, emit);
|
|
63
|
+
const UButton = useUIComponent("UButton");
|
|
64
|
+
const UDropdownMenu = useUIComponent("UDropdownMenu");
|
|
65
|
+
const nav = ref(null);
|
|
66
|
+
function move(index, other) {
|
|
67
|
+
go(index);
|
|
68
|
+
keepFocus(() => nav.value, (controls) => controls.find((control) => control.matches(other)) ?? controls[0]);
|
|
69
|
+
}
|
|
70
|
+
return () => {
|
|
71
|
+
const total = props.steps.length;
|
|
72
|
+
const index = current.value;
|
|
73
|
+
const title = props.steps[index]?.title ?? "";
|
|
74
|
+
const name = total ? `${index + 1}. ${title}` : "";
|
|
75
|
+
const items = props.steps.map((item, position) => ({
|
|
76
|
+
description: item.description,
|
|
77
|
+
label: `${position + 1}. ${item.title}`,
|
|
78
|
+
onSelect: () => go(position)
|
|
79
|
+
}));
|
|
80
|
+
return h("nav", {
|
|
81
|
+
"aria-label": "Steps",
|
|
82
|
+
class: "vh-ws-step-nav",
|
|
83
|
+
ref: nav
|
|
84
|
+
}, [
|
|
85
|
+
h(UDropdownMenu, {
|
|
86
|
+
content: { align: "start" },
|
|
87
|
+
items: props.label ? [[{
|
|
88
|
+
label: props.label,
|
|
89
|
+
type: "label"
|
|
90
|
+
}], items] : [items],
|
|
91
|
+
ui: { content: "w-72" }
|
|
92
|
+
}, () => h(UButton, {
|
|
93
|
+
"aria-label": `Step: ${name}`,
|
|
94
|
+
class: "vh-ws-step-nav-menu",
|
|
95
|
+
color: "neutral",
|
|
96
|
+
size: "sm",
|
|
97
|
+
trailingIcon: "i-lucide-chevron-down",
|
|
98
|
+
variant: "ghost"
|
|
99
|
+
}, () => h("span", { class: "vh-ws-step-nav-name" }, name))),
|
|
100
|
+
h("span", { class: "vh-ws-step-nav-count" }, total ? `Step ${index + 1} of ${total}` : ""),
|
|
101
|
+
h(UButton, {
|
|
102
|
+
"aria-label": "Previous step",
|
|
103
|
+
class: "vh-ws-step-nav-back",
|
|
104
|
+
color: "neutral",
|
|
105
|
+
disabled: index === 0,
|
|
106
|
+
icon: "i-lucide-chevron-left",
|
|
107
|
+
size: "sm",
|
|
108
|
+
square: true,
|
|
109
|
+
variant: "ghost",
|
|
110
|
+
onClick: () => move(index - 1, ".vh-ws-step-nav-next")
|
|
111
|
+
}),
|
|
112
|
+
h(UButton, {
|
|
113
|
+
"aria-label": "Next step",
|
|
114
|
+
class: "vh-ws-step-nav-next",
|
|
115
|
+
color: "neutral",
|
|
116
|
+
disabled: index >= total - 1,
|
|
117
|
+
icon: "i-lucide-chevron-right",
|
|
118
|
+
size: "sm",
|
|
119
|
+
square: true,
|
|
120
|
+
variant: "ghost",
|
|
121
|
+
onClick: () => move(index + 1, ".vh-ws-step-nav-back")
|
|
122
|
+
})
|
|
123
|
+
]);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
//#endregion
|
|
128
|
+
export { WorkspaceSteps, keepFocus, useStepModel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/workspace/workspace-task.d.ts
|
|
2
|
+
/** The task of a step: what the reader does next, in a box under the step's text. */
|
|
3
|
+
export declare const WorkspaceTask: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
/** The heading of the box. */
|
|
5
|
+
title: {
|
|
6
|
+
default: string;
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
};
|
|
9
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
/** The heading of the box. */
|
|
13
|
+
title: {
|
|
14
|
+
default: string;
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
};
|
|
17
|
+
}>> & Readonly<{}>, {
|
|
18
|
+
title: string;
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
//#region src/workspace/workspace-task.ts
|
|
3
|
+
/** The task of a step: what the reader does next, in a box under the step's text. */
|
|
4
|
+
const WorkspaceTask = defineComponent({
|
|
5
|
+
name: "WorkspaceTask",
|
|
6
|
+
props: {
|
|
7
|
+
/** The heading of the box. */
|
|
8
|
+
title: {
|
|
9
|
+
default: "Try it",
|
|
10
|
+
type: String
|
|
11
|
+
} },
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
return () => h("div", {
|
|
14
|
+
class: "vh-ws-task",
|
|
15
|
+
role: "note"
|
|
16
|
+
}, [h("p", { class: "vh-ws-task-title" }, slots.title?.() ?? props.title), h("div", { class: "vh-ws-task-body" }, slots.default?.())]);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
export { WorkspaceTask };
|