@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.
Files changed (175) hide show
  1. package/README.md +102 -76
  2. package/dist/announce-Cy_Tn9wW.js +32 -0
  3. package/dist/{avatar-stack-DPRFuezh.d.ts → avatar-stack-DXmCQhxd.d.ts} +1 -1
  4. package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
  5. package/dist/{comment-composer-fINL5bxo.d.ts → comment-composer-DvKMTrAi.d.ts} +4 -4
  6. package/dist/{comment-layer-C_sbPIR5.d.ts → comment-layer-GTsLdABl.d.ts} +4 -4
  7. package/dist/{comment-list-BcSaLngS.d.ts → comment-list-BI96empx.d.ts} +2 -2
  8. package/dist/comment-marks.css +18 -22
  9. package/dist/{comment-panel-CfvdRUMX.d.ts → comment-panel-CsKWTms_.d.ts} +2 -2
  10. package/dist/{comment-pin-DHOdRvUw.d.ts → comment-pin-CvwgRSDR.d.ts} +1 -1
  11. package/dist/{comment-row-Bn3nr8l5.js → comment-row-JmTC0uXr.js} +1 -1
  12. package/dist/comment-send-7bg4NEEM.js +277 -0
  13. package/dist/comment-send-C45dHC22.d.ts +25 -0
  14. package/dist/comment-send.css +267 -0
  15. package/dist/comment-thread-B_Sc2QX6.js +797 -0
  16. package/dist/{comment-thread-DKJjmWN0.d.ts → comment-thread-C6U-bsK_.d.ts} +4 -4
  17. package/dist/{comments-D0d26ghV.js → comments-B88zg9gC.js} +1 -1
  18. package/dist/{comments-context-C2lOZyQ5.js → comments-context-DhbIdYQ1.js} +2 -1
  19. package/dist/{config-Dk67emQt.js → config-B1u7zqMB.js} +8 -1
  20. package/dist/{config-DgxBW013.d.ts → config-pHazYdq6.d.ts} +11 -0
  21. package/dist/drop-field-3CDRFFRm.js +163 -0
  22. package/dist/{editor-C_wt4RRV.js → editor-BHYGLgty.js} +42 -3
  23. package/dist/effects-Ql6VzCRa.js +2971 -0
  24. package/dist/headless.d.ts +1 -1
  25. package/dist/headless.js +1 -1
  26. package/dist/hold-to-delete-DjWzRDyY.d.ts +51 -0
  27. package/dist/hold-to-delete-ROLQRZg_.js +434 -0
  28. package/dist/icon-c5Jb_Tl7.d.ts +31 -0
  29. package/dist/{image-preview-C9tdkmEj.js → image-preview-BigoAvb3.js} +2 -2
  30. package/dist/{index-BYRFQfCd.d.ts → index-YUvL2nV8.d.ts} +8 -10
  31. package/dist/index.d.ts +19 -14
  32. package/dist/index.js +45 -44
  33. package/dist/install-D5f6msEU.js +17 -0
  34. package/dist/list-RCbNZ14q.js +271 -0
  35. package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-Dfl2DgPS.js} +1 -1
  36. package/dist/markdown-editor.js +1 -1
  37. package/dist/{message-scroller-jrYN9dG9.d.ts → message-scroller-Bm1YWTeY.d.ts} +2 -2
  38. package/dist/motion/core.d.ts +4 -0
  39. package/dist/motion/core.js +11 -0
  40. package/dist/motion-core-lHRF8PZz.d.ts +456 -0
  41. package/dist/motion.d.ts +16 -0
  42. package/dist/motion.js +13 -0
  43. package/dist/{nuxt-ui-DSQFzq3s.js → nuxt-ui-CgvMzO5v.js} +20 -14
  44. package/dist/nuxt.d.ts +1 -1
  45. package/dist/nuxt.js +12 -3
  46. package/dist/opt-out-b6bnUjIT.js +208 -0
  47. package/dist/parts/components/agent-session.js +1 -1
  48. package/dist/parts/components/attachment.d.ts +1 -1
  49. package/dist/parts/components/attachment.js +1 -1
  50. package/dist/parts/components/avatar-stack.d.ts +1 -1
  51. package/dist/parts/components/avatar-stack.js +2 -1
  52. package/dist/parts/components/bubble.d.ts +1 -1
  53. package/dist/parts/components/chat-session.d.ts +1 -1
  54. package/dist/parts/components/chat.js +2 -2
  55. package/dist/parts/components/code-block.d.ts +1 -1
  56. package/dist/parts/components/code-block.js +1 -1
  57. package/dist/parts/components/comment-composer.d.ts +1 -1
  58. package/dist/parts/components/comment-composer.js +1 -1
  59. package/dist/parts/components/comment-layer.d.ts +1 -1
  60. package/dist/parts/components/comment-layer.js +24 -6
  61. package/dist/parts/components/comment-list.d.ts +1 -1
  62. package/dist/parts/components/comment-list.js +12 -7
  63. package/dist/parts/components/comment-panel.d.ts +1 -1
  64. package/dist/parts/components/comment-panel.js +24 -10
  65. package/dist/parts/components/comment-pin.d.ts +1 -1
  66. package/dist/parts/components/comment-selection-bar.js +3 -2
  67. package/dist/parts/components/comment-send.d.ts +2 -0
  68. package/dist/parts/components/comment-send.js +2 -0
  69. package/dist/parts/components/comment-thread.d.ts +1 -1
  70. package/dist/parts/components/comment-thread.js +2 -597
  71. package/dist/parts/components/comments.d.ts +8 -7
  72. package/dist/parts/components/comments.js +5 -4
  73. package/dist/parts/components/copy-button.d.ts +13 -3
  74. package/dist/parts/components/copy-button.js +226 -1
  75. package/dist/parts/components/device-frame.d.ts +2 -2
  76. package/dist/parts/components/drop-field.d.ts +69 -0
  77. package/dist/parts/components/drop-field.js +77 -0
  78. package/dist/parts/components/filter-search.js +1 -1
  79. package/dist/parts/components/hold-to-delete.d.ts +82 -0
  80. package/dist/parts/components/hold-to-delete.js +76 -0
  81. package/dist/parts/components/markdown-editor.js +1 -1
  82. package/dist/parts/components/markdown-renderer.js +1 -1
  83. package/dist/parts/components/markdown.js +1 -1
  84. package/dist/parts/components/marker.d.ts +1 -1
  85. package/dist/parts/components/message-parts.js +13 -5
  86. package/dist/parts/components/motion-list.d.ts +42 -0
  87. package/dist/parts/components/motion-list.js +42 -0
  88. package/dist/parts/components/motion.d.ts +124 -0
  89. package/dist/parts/components/motion.js +172 -0
  90. package/dist/parts/components/progress.d.ts +41 -0
  91. package/dist/parts/components/progress.js +54 -0
  92. package/dist/parts/components/prompt-input.d.ts +5 -5
  93. package/dist/parts/components/prompt-input.js +3 -3
  94. package/dist/parts/components/relative-time.js +1 -1
  95. package/dist/parts/components/sync-status.js +2 -1
  96. package/dist/parts/components/tool-list.d.ts +1 -1
  97. package/dist/parts/components/trace-run.d.ts +1 -1
  98. package/dist/parts/components/trace-run.js +1 -1
  99. package/dist/parts/components/trace.d.ts +1 -1
  100. package/dist/parts/headless/comments.js +1 -1
  101. package/dist/parts/headless/message-scroller.d.ts +1 -1
  102. package/dist/parts/playground/share.d.ts +36 -2
  103. package/dist/parts/workspace/browser-support-notice.d.ts +1 -1
  104. package/dist/parts/workspace/browser-support-notice.js +12 -4
  105. package/dist/parts/workspace/codemirror.d.ts +9 -0
  106. package/dist/parts/workspace/codemirror.js +37 -4
  107. package/dist/parts/workspace/connect-panel.d.ts +1 -1
  108. package/dist/parts/workspace/connect-panel.js +1 -1
  109. package/dist/parts/workspace/file-icons.d.ts +16 -0
  110. package/dist/parts/workspace/file-icons.js +82 -0
  111. package/dist/parts/workspace/icons.d.ts +1 -0
  112. package/dist/parts/workspace/icons.js +1 -0
  113. package/dist/parts/workspace/runners/render.d.ts +26 -0
  114. package/dist/parts/workspace/runners/render.js +124 -0
  115. package/dist/parts/workspace/runners/web-container.d.ts +29 -0
  116. package/dist/parts/workspace/runners/web-container.js +186 -0
  117. package/dist/parts/workspace/workspace-bar.d.ts +51 -0
  118. package/dist/parts/workspace/workspace-bar.js +51 -0
  119. package/dist/parts/workspace/workspace-editor-head.d.ts +47 -0
  120. package/dist/parts/workspace/workspace-editor-head.js +66 -0
  121. package/dist/parts/workspace/workspace-editor.d.ts +17 -0
  122. package/dist/parts/workspace/workspace-editor.js +29 -3
  123. package/dist/parts/workspace/workspace-examples.d.ts +74 -0
  124. package/dist/parts/workspace/workspace-examples.js +72 -0
  125. package/dist/parts/workspace/workspace-file-link.d.ts +35 -0
  126. package/dist/parts/workspace/workspace-file-link.js +39 -0
  127. package/dist/parts/workspace/workspace-file-tree.d.ts +8 -8
  128. package/dist/parts/workspace/workspace-file-tree.js +26 -19
  129. package/dist/parts/workspace/workspace-guide.d.ts +52 -0
  130. package/dist/parts/workspace/workspace-guide.js +91 -0
  131. package/dist/parts/workspace/workspace-issues.d.ts +46 -0
  132. package/dist/parts/workspace/workspace-issues.js +49 -0
  133. package/dist/parts/workspace/workspace-preview.js +1 -1
  134. package/dist/parts/workspace/workspace-shell.d.ts +2 -88
  135. package/dist/parts/workspace/workspace-shell.js +131 -78
  136. package/dist/parts/workspace/workspace-sidebar.d.ts +75 -0
  137. package/dist/parts/workspace/workspace-sidebar.js +132 -0
  138. package/dist/parts/workspace/workspace-start.d.ts +47 -0
  139. package/dist/parts/workspace/workspace-start.js +60 -0
  140. package/dist/parts/workspace/workspace-status.d.ts +69 -0
  141. package/dist/parts/workspace/workspace-status.js +74 -0
  142. package/dist/parts/workspace/workspace-steps.d.ts +2 -0
  143. package/dist/parts/workspace/workspace-steps.js +128 -0
  144. package/dist/parts/workspace/workspace-task.d.ts +20 -0
  145. package/dist/parts/workspace/workspace-task.js +20 -0
  146. package/dist/parts/workspace/workspace.d.ts +251 -0
  147. package/dist/parts/workspace/workspace.js +665 -0
  148. package/dist/playground.d.ts +1 -1
  149. package/dist/progress-C7afI5vq.js +266 -0
  150. package/dist/registry-D3-ysX7l.js +78 -0
  151. package/dist/{relative-time-BVmjOsYG.js → relative-time-DgSS3zKN.js} +1 -1
  152. package/dist/ring-B7Qxu7zd.js +175 -0
  153. package/dist/runtime/nuxt-plugin.js +2 -2
  154. package/dist/styles.css +586 -573
  155. package/dist/text-BCJflBJf.js +826 -0
  156. package/dist/theme.d.ts +43 -0
  157. package/dist/theme.js +22 -7
  158. package/dist/travel-C87xd5Wh.js +182 -0
  159. package/dist/tween-CO24nMpf.js +62 -0
  160. package/dist/{types-Dj7vp0lZ.d.ts → types-BX64qHlV.d.ts} +1 -1
  161. package/dist/visual-copy-CrVc3z4n.js +15 -0
  162. package/dist/workspace-shell-BJGnoF3p.d.ts +112 -0
  163. package/dist/workspace-steps-Bgph2rpr.d.ts +72 -0
  164. package/dist/workspace.d.ts +16 -3
  165. package/dist/workspace.js +15 -2
  166. package/package.json +21 -10
  167. package/dist/copy-button-CRN3kmSD.js +0 -253
  168. package/dist/icon-swap.css +0 -69
  169. package/dist/parts/playground/highlight.d.ts +0 -5
  170. package/dist/parts/playground/highlight.js +0 -23
  171. package/dist/parts/playground/playground-render.d.ts +0 -126
  172. package/dist/parts/playground/playground-render.js +0 -356
  173. package/dist/parts/workspace/playground-container.d.ts +0 -192
  174. package/dist/parts/workspace/playground-container.js +0 -603
  175. package/dist/share-DM4eNy4q.d.ts +0 -37
@@ -0,0 +1,91 @@
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
+ import { keepFocus, useStepModel } from "./workspace-steps.js";
3
+ import { defineComponent, h, ref, watch } from "vue";
4
+ //#region src/workspace/workspace-guide.ts
5
+ /**
6
+ * The guide of a lesson: the step's position and title, the page's text in the default slot, and Back and Next at the
7
+ * bottom of the column. It never parses Markdown: render the step's text into the slot. Put it in the `guide` slot of
8
+ * the shell, in the `guide-top` or `guide-side` layout. Use `v-model:step`; the step is a 0-based index.
9
+ */
10
+ const WorkspaceGuide = defineComponent({
11
+ name: "WorkspaceGuide",
12
+ props: {
13
+ /** The steps of the lesson, in order. The guide shows the title of the current one. */
14
+ steps: {
15
+ default: () => [],
16
+ type: Array
17
+ },
18
+ /** The current step, from 0. Use `v-model:step`. */
19
+ step: {
20
+ default: void 0,
21
+ type: Number
22
+ },
23
+ /** The title over the text. Defaults to the title of the current step. */
24
+ title: {
25
+ default: void 0,
26
+ type: String
27
+ }
28
+ },
29
+ emits: { "update:step": (step) => Number.isInteger(step) },
30
+ setup(props, { emit, slots }) {
31
+ const { current, go } = useStepModel(props, emit);
32
+ const UButton = useUIComponent("UButton");
33
+ const body = ref(null);
34
+ const nav = ref(null);
35
+ function move(index) {
36
+ const forward = index > current.value;
37
+ go(index);
38
+ keepFocus(() => nav.value, (controls) => forward ? controls.at(-1) : controls[0]);
39
+ }
40
+ watch(current, () => body.value?.scrollTo?.({ top: 0 }));
41
+ return () => {
42
+ const index = current.value;
43
+ const total = props.steps.length;
44
+ const previous = props.steps[index - 1];
45
+ const next = props.steps[index + 1];
46
+ const title = props.title ?? props.steps[index]?.title;
47
+ const slotProps = {
48
+ next: () => move(index + 1),
49
+ previous: () => move(index - 1),
50
+ step: index,
51
+ total
52
+ };
53
+ const content = slots.footer?.(slotProps) ?? (total > 1 ? [previous ? h(UButton, {
54
+ "aria-label": `Back to step ${index}: ${previous.title}`,
55
+ class: "vh-ws-guide-back",
56
+ color: "neutral",
57
+ icon: "i-lucide-chevron-left",
58
+ label: previous.title,
59
+ size: "sm",
60
+ variant: "ghost",
61
+ onClick: () => move(index - 1)
62
+ }) : h("span"), next ? h(UButton, {
63
+ class: "vh-ws-guide-next",
64
+ color: "neutral",
65
+ label: `Next: ${next.title}`,
66
+ size: "sm",
67
+ trailingIcon: "i-lucide-chevron-right",
68
+ variant: "solid",
69
+ onClick: () => move(index + 1)
70
+ }) : slots.finish?.(slotProps)] : total === 1 && slots.finish ? [h("span"), slots.finish(slotProps)] : void 0);
71
+ const footer = content ? h("nav", {
72
+ "aria-label": "Step navigation",
73
+ class: "vh-ws-guide-footer",
74
+ ref: nav
75
+ }, content) : void 0;
76
+ return h("article", {
77
+ class: "vh-ws-guide-pane",
78
+ "data-step": total ? index : void 0
79
+ }, [h("div", {
80
+ class: "vh-ws-guide-body",
81
+ ref: body
82
+ }, [
83
+ total > 1 ? h("p", { class: "vh-ws-guide-kicker" }, `Step ${index + 1} of ${total}`) : void 0,
84
+ title ? h("h2", { class: "vh-ws-guide-title" }, title) : void 0,
85
+ h("div", { class: "vh-ws-guide-content" }, slots.default?.(slotProps))
86
+ ]), footer]);
87
+ };
88
+ }
89
+ });
90
+ //#endregion
91
+ export { WorkspaceGuide };
@@ -0,0 +1,46 @@
1
+ import { PropType } from "vue";
2
+ //#region src/workspace/workspace-issues.d.ts
3
+ /**
4
+ * A problem in the files, such as a parse error. `file` is the path of the file that it is in, and `line` the line of
5
+ * that file, from 1.
6
+ */
7
+ export interface WorkspaceIssue {
8
+ message: string;
9
+ file?: string;
10
+ line?: number;
11
+ }
12
+ /**
13
+ * The issues of the last render, as a list. Screen readers hear each new list. Without issues the list hides, or shows
14
+ * `empty` when it is set, such as in an Issues tab. An issue with a `file` shows `file:line` as a button that emits
15
+ * `show` with the path.
16
+ */
17
+ export declare const WorkspaceIssues: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
18
+ issues: {
19
+ required: true;
20
+ type: PropType<readonly WorkspaceIssue[]>;
21
+ };
22
+ /** The text to show when there are no issues. Without it, the list hides. */
23
+ empty: {
24
+ default: undefined;
25
+ type: StringConstructor;
26
+ };
27
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
28
+ [key: string]: any;
29
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ show: (path: string) => boolean;
31
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
32
+ issues: {
33
+ required: true;
34
+ type: PropType<readonly WorkspaceIssue[]>;
35
+ };
36
+ /** The text to show when there are no issues. Without it, the list hides. */
37
+ empty: {
38
+ default: undefined;
39
+ type: StringConstructor;
40
+ };
41
+ }>> & Readonly<{
42
+ onShow?: ((path: string) => any) | undefined;
43
+ }>, {
44
+ empty: string;
45
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
46
+ //#endregion
@@ -0,0 +1,49 @@
1
+ import { defineComponent, h } from "vue";
2
+ //#region src/workspace/workspace-issues.ts
3
+ function where(issue) {
4
+ if (issue.file === void 0) return issue.line === void 0 ? void 0 : `Line ${issue.line}`;
5
+ return issue.line === void 0 ? issue.file : `${issue.file}:${issue.line}`;
6
+ }
7
+ /**
8
+ * The issues of the last render, as a list. Screen readers hear each new list. Without issues the list hides, or shows
9
+ * `empty` when it is set, such as in an Issues tab. An issue with a `file` shows `file:line` as a button that emits
10
+ * `show` with the path.
11
+ */
12
+ const WorkspaceIssues = defineComponent({
13
+ name: "WorkspaceIssues",
14
+ props: {
15
+ issues: {
16
+ required: true,
17
+ type: Array
18
+ },
19
+ /** The text to show when there are no issues. Without it, the list hides. */
20
+ empty: {
21
+ default: void 0,
22
+ type: String
23
+ }
24
+ },
25
+ emits: { show: (path) => typeof path === "string" },
26
+ setup(props, { emit }) {
27
+ return () => {
28
+ const none = props.issues.length === 0;
29
+ return h("ul", {
30
+ "aria-label": "Issues",
31
+ "aria-live": "polite",
32
+ class: "vh-ws-issues",
33
+ "data-empty": none ? "" : void 0,
34
+ hidden: none && !props.empty
35
+ }, none ? props.empty ? [h("li", { class: "vh-ws-issues-empty" }, props.empty)] : [] : props.issues.map((issue) => {
36
+ const label = where(issue);
37
+ const file = issue.file;
38
+ return h("li", [label === void 0 ? void 0 : file === void 0 ? h("span", { class: "vh-ws-issue-line" }, label) : h("button", {
39
+ class: "vh-ws-issue-line vh-ws-issue-file",
40
+ title: `Open ${file}`,
41
+ type: "button",
42
+ onClick: () => emit("show", file)
43
+ }, label), issue.message]);
44
+ }));
45
+ };
46
+ }
47
+ });
48
+ //#endregion
49
+ export { WorkspaceIssues };
@@ -1,4 +1,4 @@
1
- import { r as useUIComponent } from "../../nuxt-ui-DSQFzq3s.js";
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
2
  import { DeviceFrame } from "../components/device-frame.js";
3
3
  import { icon } from "./icons.js";
4
4
  import { computed, defineComponent, h, onBeforeUnmount, onMounted, ref, shallowRef, useId, watch } from "vue";
@@ -1,88 +1,2 @@
1
- import { PropType, VNode } from "vue";
2
- //#region src/workspace/workspace-shell.d.ts
3
- export type WorkspaceLayout = "tutorial" | "playground";
4
- /** A built-in panel, or the slot name of a panel that the page adds. */
5
- export type WorkspaceTab = "preview" | "terminal" | "connect" | (string & {});
6
- /** One tab of the panel group. It shows the slot with the name `value`. */
7
- export interface WorkspaceTabItem {
8
- value: WorkspaceTab;
9
- label: string;
10
- /** A short count or state next to the label, such as the number of connected accounts. */
11
- badge?: string | number;
12
- }
13
- /** Split sizes. `files` is in pixels. `main` and `side` are percents of the shell. */
14
- export interface WorkspaceSplits {
15
- files: number;
16
- main: number;
17
- side: number;
18
- }
19
- export declare const WorkspaceShell: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
20
- layout: {
21
- default: string;
22
- type: PropType<WorkspaceLayout>;
23
- };
24
- /** The visible tab. Use `v-model:tab`. */
25
- tab: {
26
- default: undefined;
27
- type: PropType<WorkspaceTab>;
28
- };
29
- /**
30
- * The tabs of the panel group, in order. Each tab shows the slot with the name of its `value`. Defaults to Preview,
31
- * Terminal, and Connect, for the slots that are set. A playground shows the preview at the side, never as a tab.
32
- */
33
- tabs: {
34
- default: undefined;
35
- type: PropType<readonly WorkspaceTabItem[]>;
36
- };
37
- /** The localStorage key for split sizes. `false` keeps them in memory. Defaults to one key per layout. */
38
- storageKey: {
39
- default: undefined;
40
- type: PropType<string | false>;
41
- };
42
- /** The accessible name of the workspace region. */
43
- label: {
44
- default: string;
45
- type: StringConstructor;
46
- };
47
- }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
48
- [key: string]: any;
49
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
50
- "update:tab": (tab: WorkspaceTab) => boolean;
51
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
52
- layout: {
53
- default: string;
54
- type: PropType<WorkspaceLayout>;
55
- };
56
- /** The visible tab. Use `v-model:tab`. */
57
- tab: {
58
- default: undefined;
59
- type: PropType<WorkspaceTab>;
60
- };
61
- /**
62
- * The tabs of the panel group, in order. Each tab shows the slot with the name of its `value`. Defaults to Preview,
63
- * Terminal, and Connect, for the slots that are set. A playground shows the preview at the side, never as a tab.
64
- */
65
- tabs: {
66
- default: undefined;
67
- type: PropType<readonly WorkspaceTabItem[]>;
68
- };
69
- /** The localStorage key for split sizes. `false` keeps them in memory. Defaults to one key per layout. */
70
- storageKey: {
71
- default: undefined;
72
- type: PropType<string | false>;
73
- };
74
- /** The accessible name of the workspace region. */
75
- label: {
76
- default: string;
77
- type: StringConstructor;
78
- };
79
- }>> & Readonly<{
80
- "onUpdate:tab"?: ((tab: WorkspaceTab) => any) | undefined;
81
- }>, {
82
- label: string;
83
- storageKey: string | false;
84
- layout: WorkspaceLayout;
85
- tab: WorkspaceTab;
86
- tabs: readonly WorkspaceTabItem[];
87
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
88
- //#endregion
1
+ import { a as WorkspaceTabItem, i as WorkspaceTab, n as WorkspaceShell, r as WorkspaceSplits, t as WorkspaceLayout } from "../../workspace-shell-BJGnoF3p.js";
2
+ export { WorkspaceLayout, WorkspaceShell, WorkspaceSplits, WorkspaceTab, WorkspaceTabItem };
@@ -1,16 +1,21 @@
1
- import { r as useUIComponent } from "../../nuxt-ui-DSQFzq3s.js";
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
2
  import { computed, defineComponent, h, onMounted, ref, watch } from "vue";
3
3
  //#region src/workspace/workspace-shell.ts
4
4
  const defaultSplits = {
5
- playground: {
6
- files: 200,
7
- main: 68,
8
- side: 40
5
+ "side": {
6
+ files: 199,
7
+ code: 50,
8
+ guide: 46
9
9
  },
10
- tutorial: {
11
- files: 180,
12
- main: 55,
13
- side: 45
10
+ "guide-top": {
11
+ files: 199,
12
+ code: 54,
13
+ guide: 46
14
+ },
15
+ "guide-side": {
16
+ files: 199,
17
+ code: 50,
18
+ guide: 46
14
19
  }
15
20
  };
16
21
  const limits = {
@@ -19,17 +24,18 @@ const limits = {
19
24
  420,
20
25
  16
21
26
  ],
22
- main: [
23
- 20,
24
- 80,
27
+ code: [
28
+ 25,
29
+ 75,
25
30
  5
26
31
  ],
27
- side: [
28
- 25,
32
+ guide: [
33
+ 15,
29
34
  75,
30
35
  5
31
36
  ]
32
37
  };
38
+ const editorReserve = 120;
33
39
  const builtInTabs = [
34
40
  {
35
41
  label: "Preview",
@@ -44,6 +50,16 @@ const builtInTabs = [
44
50
  value: "connect"
45
51
  }
46
52
  ];
53
+ const layoutSlots = /* @__PURE__ */ new Set([
54
+ "banner",
55
+ "bar",
56
+ "editor",
57
+ "editor-head",
58
+ "files",
59
+ "guide",
60
+ "overlay",
61
+ "status"
62
+ ]);
47
63
  function clamp(key, value) {
48
64
  const [min, max] = limits[key];
49
65
  return Math.round(Math.min(max, Math.max(min, value)));
@@ -67,7 +83,9 @@ function readSplits(key, layout) {
67
83
  */
68
84
  function separator(options) {
69
85
  const { name, orientation, splits } = options;
70
- const [min, max, step] = limits[name];
86
+ const [defaultMin, defaultMax, step] = limits[name];
87
+ const max = options.max ?? defaultMax;
88
+ const min = Math.min(defaultMin, max);
71
89
  const decrease = orientation === "vertical" ? "ArrowLeft" : "ArrowUp";
72
90
  const increase = orientation === "vertical" ? "ArrowRight" : "ArrowDown";
73
91
  return h("div", {
@@ -108,11 +126,17 @@ function separator(options) {
108
126
  }
109
127
  });
110
128
  }
129
+ /**
130
+ * The frame of a workspace. Slots: `bar` (44px, over everything), `banner` (under the bar, such as a notice), `files`,
131
+ * `editor-head` (32px, over the editor), `editor`, `status` (24px, under the editor), `guide`, one slot per tab
132
+ * (`preview`, `terminal`, `connect`, or `tab-<value>` for a custom tab), and `overlay` (over the body). The tab bar is
133
+ * 32px too, so its bottom line meets the bottom line of `editor-head`.
134
+ */
111
135
  const WorkspaceShell = defineComponent({
112
136
  name: "WorkspaceShell",
113
137
  props: {
114
138
  layout: {
115
- default: "tutorial",
139
+ default: "side",
116
140
  type: String
117
141
  },
118
142
  /** The visible tab. Use `v-model:tab`. */
@@ -121,8 +145,7 @@ const WorkspaceShell = defineComponent({
121
145
  type: String
122
146
  },
123
147
  /**
124
- * The tabs of the panel group, in order. Each tab shows the slot with the name of its `value`. Defaults to Preview,
125
- * Terminal, and Connect, for the slots that are set. A playground shows the preview at the side, never as a tab.
148
+ * The tabs of the output, in order. Defaults to Preview, Terminal, and Connect, for the slots that are set.
126
149
  */
127
150
  tabs: {
128
151
  default: void 0,
@@ -137,11 +160,17 @@ const WorkspaceShell = defineComponent({
137
160
  label: {
138
161
  default: "Workspace",
139
162
  type: String
163
+ },
164
+ covered: {
165
+ default: false,
166
+ type: Boolean
140
167
  }
141
168
  },
142
169
  emits: { "update:tab": (tab) => typeof tab === "string" },
143
170
  setup(props, { emit, slots }) {
144
171
  const root = ref(null);
172
+ const codePane = ref(null);
173
+ const filesMax = ref(limits.files[1]);
145
174
  const key = computed(() => props.storageKey === false ? false : props.storageKey ?? `vitehub:workspace:${props.layout}`);
146
175
  const splits = ref({ ...defaultSplits[props.layout] });
147
176
  const localTab = ref();
@@ -151,17 +180,31 @@ const WorkspaceShell = defineComponent({
151
180
  watch(() => props.layout, () => {
152
181
  splits.value = readSplits(key.value, props.layout);
153
182
  });
183
+ watch(codePane, (pane, _, onCleanup) => {
184
+ if (!pane || typeof ResizeObserver === "undefined") return;
185
+ const measure = (width) => {
186
+ const available = width - Math.min(editorReserve, width / 2) - 1;
187
+ filesMax.value = Math.max(0, Math.min(limits.files[1], Math.floor(available)));
188
+ };
189
+ measure(pane.clientWidth);
190
+ const observer = new ResizeObserver(([entry]) => {
191
+ if (entry) measure(entry.contentRect.width);
192
+ });
193
+ observer.observe(pane);
194
+ onCleanup(() => observer.disconnect());
195
+ }, { flush: "post" });
154
196
  function set(name, value) {
197
+ const size = clamp(name, value);
155
198
  splits.value = {
156
199
  ...splits.value,
157
- [name]: clamp(name, value)
200
+ [name]: name === "files" ? Math.min(filesMax.value, size) : size
158
201
  };
159
202
  if (!key.value) return;
160
203
  try {
161
204
  window.localStorage.setItem(key.value, JSON.stringify(splits.value));
162
205
  } catch {}
163
206
  }
164
- const items = computed(() => (props.tabs ?? builtInTabs.filter((item) => slots[item.value])).filter((item) => props.layout !== "playground" || item.value !== "preview"));
207
+ const items = computed(() => props.tabs ?? builtInTabs.filter((item) => slots[item.value]));
165
208
  const tabs = computed(() => items.value.map((item) => item.value));
166
209
  const active = computed(() => {
167
210
  const wanted = props.tab ?? localTab.value;
@@ -178,7 +221,12 @@ const WorkspaceShell = defineComponent({
178
221
  showTab: select
179
222
  });
180
223
  const UTabs = useUIComponent("UTabs");
181
- function tabList() {
224
+ function panelContent(name) {
225
+ const custom = slots[`tab-${name}`];
226
+ if (custom) return custom(slotProps());
227
+ if (!layoutSlots.has(name) && !name.startsWith("tab-")) return renderSlot(slots, name, slotProps());
228
+ }
229
+ function output() {
182
230
  if (tabs.value.length === 0) return void 0;
183
231
  const panels = tabs.value.map((name) => h("div", {
184
232
  "aria-label": items.value.find((item) => item.value === name)?.label,
@@ -187,8 +235,8 @@ const WorkspaceShell = defineComponent({
187
235
  inert: active.value === name ? void 0 : "",
188
236
  key: name,
189
237
  role: "tabpanel"
190
- }, renderSlot(slots, name, slotProps())));
191
- return h("div", { class: "vh-ws-tabs" }, [h(UTabs, {
238
+ }, panelContent(name)));
239
+ return h("div", { class: "vh-ws-pane vh-ws-pane--output" }, [h(UTabs, {
192
240
  "aria-label": "Workspace panels",
193
241
  class: "vh-ws-tab-list",
194
242
  content: false,
@@ -205,80 +253,85 @@ const WorkspaceShell = defineComponent({
205
253
  }), h("div", { class: "vh-ws-tab-panels" }, panels)]);
206
254
  }
207
255
  return () => {
208
- const s = splits.value;
209
- const container = () => root.value?.querySelector(".vh-ws-body") ?? null;
210
- const filesSplit = slots.files ? [h("div", {
256
+ const s = {
257
+ ...splits.value,
258
+ files: Math.min(splits.value.files, filesMax.value)
259
+ };
260
+ const layout = props.layout;
261
+ const body = () => root.value?.querySelector(".vh-ws-body") ?? null;
262
+ const code = (style) => h("div", {
263
+ class: "vh-ws-pane vh-ws-code",
264
+ ref: codePane,
265
+ style
266
+ }, [...slots.files ? [h("div", {
211
267
  class: "vh-ws-pane vh-ws-pane--files",
212
268
  style: { flexBasis: `${s.files}px` }
213
269
  }, renderSlot(slots, "files", slotProps())), separator({
214
- container,
270
+ container: () => codePane.value,
215
271
  label: "Resize files",
272
+ max: filesMax.value,
216
273
  measure: (event, rect) => event.clientX - rect.left,
217
274
  name: "files",
218
275
  orientation: "vertical",
219
276
  set,
220
277
  splits: s
221
- })] : [];
222
- const editor = h("div", { class: "vh-ws-pane vh-ws-pane--editor" }, renderSlot(slots, "editor", slotProps()));
223
- let body;
224
- if (props.layout === "playground") {
225
- const panels = tabList();
226
- const center = panels ? h("div", { class: "vh-ws-stack" }, [
227
- h("div", {
228
- class: "vh-ws-pane",
229
- style: { flexBasis: `${s.main}%` }
230
- }, [editor]),
278
+ })] : [], h("div", { class: "vh-ws-pane vh-ws-pane--editor" }, [
279
+ slots["editor-head"] ? h("div", { class: "vh-ws-head vh-ws-editor-head" }, renderSlot(slots, "editor-head", slotProps())) : void 0,
280
+ h("div", { class: "vh-ws-pane vh-ws-editor-body" }, renderSlot(slots, "editor", slotProps())),
281
+ slots.status ? h("div", { class: "vh-ws-status" }, renderSlot(slots, "status", slotProps())) : void 0
282
+ ])]);
283
+ const guide = (style) => slots.guide ? h("div", {
284
+ class: "vh-ws-pane vh-ws-guide",
285
+ style
286
+ }, renderSlot(slots, "guide", slotProps())) : void 0;
287
+ const codeSeparator = () => separator({
288
+ container: body,
289
+ label: "Resize code",
290
+ measure: (event, rect) => (event.clientX - rect.left) / rect.width * 100,
291
+ name: "code",
292
+ orientation: "vertical",
293
+ set,
294
+ splits: s
295
+ });
296
+ let children;
297
+ if (layout === "guide-side") children = [guide(), h("div", { class: "vh-ws-pane vh-ws-stack" }, [output(), code()])];
298
+ else {
299
+ const panels = output();
300
+ const width = panels ? { flex: `0 0 ${s.code}%` } : void 0;
301
+ const column = layout === "guide-top" && slots.guide ? h("div", {
302
+ class: "vh-ws-pane vh-ws-column",
303
+ style: width
304
+ }, [
305
+ guide({ flex: `0 0 ${s.guide}%` }),
231
306
  separator({
232
- container: () => root.value?.querySelector(".vh-ws-stack") ?? null,
233
- label: "Resize panels",
307
+ container: () => root.value?.querySelector(".vh-ws-column") ?? null,
308
+ label: "Resize guide",
234
309
  measure: (event, rect) => (event.clientY - rect.top) / rect.height * 100,
235
- name: "main",
310
+ name: "guide",
236
311
  orientation: "horizontal",
237
312
  set,
238
313
  splits: s
239
314
  }),
240
- h("div", { class: "vh-ws-pane vh-ws-pane--panels" }, [panels])
241
- ]) : editor;
242
- body = h("div", { class: "vh-ws-body vh-ws-body--row" }, [
243
- ...filesSplit,
244
- h("div", { class: "vh-ws-pane vh-ws-pane--center" }, [center]),
245
- ...slots.preview ? [separator({
246
- container,
247
- label: "Resize preview",
248
- measure: (event, rect) => (rect.right - event.clientX) / rect.width * 100,
249
- name: "side",
250
- orientation: "vertical",
251
- set,
252
- splits: s
253
- }), h("div", {
254
- class: "vh-ws-pane vh-ws-pane--side",
255
- style: { flexBasis: `${s.side}%` }
256
- }, renderSlot(slots, "preview", slotProps()))] : []
257
- ]);
258
- } else body = h("div", { class: "vh-ws-body vh-ws-body--column" }, [
259
- h("div", {
260
- class: "vh-ws-row",
261
- style: { flexBasis: `${s.main}%` }
262
- }, [...filesSplit, editor]),
263
- separator({
264
- container,
265
- label: "Resize editor",
266
- measure: (event, rect) => (event.clientY - rect.top) / rect.height * 100,
267
- name: "main",
268
- orientation: "horizontal",
269
- set,
270
- splits: s
271
- }),
272
- h("div", { class: "vh-ws-pane vh-ws-pane--panels" }, [tabList()])
273
- ]);
315
+ code()
316
+ ]) : code(width);
317
+ children = panels ? [
318
+ column,
319
+ codeSeparator(),
320
+ panels
321
+ ] : [column];
322
+ }
274
323
  return h("section", {
275
324
  "aria-label": props.label,
276
- class: ["vh-ws-shell", `vh-ws-shell--${props.layout}`],
277
- "data-layout": props.layout,
325
+ class: ["vh-ws-shell", `vh-ws-shell--${layout}`],
326
+ "data-layout": layout,
278
327
  ref: root
279
328
  }, [
280
- slots.toolbar ? h("div", { class: "vh-ws-toolbar" }, renderSlot(slots, "toolbar", slotProps())) : void 0,
281
- body,
329
+ slots.bar ? h("div", { class: "vh-ws-bar" }, renderSlot(slots, "bar", slotProps())) : void 0,
330
+ slots.banner ? h("div", { class: "vh-ws-banner" }, renderSlot(slots, "banner", slotProps())) : void 0,
331
+ h("div", {
332
+ class: "vh-ws-body",
333
+ inert: props.covered ? "" : void 0
334
+ }, children),
282
335
  slots.overlay ? h("div", { class: "vh-ws-overlay" }, renderSlot(slots, "overlay", slotProps())) : void 0
283
336
  ]);
284
337
  };