@yugoo-design/dsh-design-studio-ui 0.1.0-beta.2 → 0.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Fragment, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
1
+ import { Fragment, createContext, createElement, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
2
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { createPortal } from "react-dom";
4
4
  //#region src/controller.ts
@@ -707,6 +707,17 @@ const STUDIO_WORKSPACE_CSS = `
707
707
  background:var(--ds-background);color:var(--ds-text);
708
708
  font-family:var(--ds-body-font);font-size:var(--ds-base-font-size);line-height:var(--ds-line-height)}
709
709
  .ygd-studio-workspace *{box-sizing:border-box}
710
+ .ygd-studio-workspace .ygd-studio-select{
711
+ --ds-bg-white:var(--ds-surface);--ds-fill-5:var(--ds-border);--ds-border-default:var(--ds-border);
712
+ --ds-text-primary:var(--ds-text);--ds-icon-outline-default:var(--ds-text-secondary);
713
+ --ds-brand-light-bg-default:var(--ds-primary-light);--ds-brand-text-primary:var(--ds-primary-dark);
714
+ --ds-radius-4:var(--ds-radius);--ygd-panel-control-focus:var(--ds-primary);
715
+ display:inline-flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;max-width:100%;height:32px;
716
+ padding:4px 10px;border:1px solid var(--ds-border);border-radius:var(--ds-radius);background:var(--ds-surface);color:var(--ds-text);font:inherit;line-height:20px;text-align:start;cursor:pointer}
717
+ .ygd-studio-select:focus-visible{outline:2px solid var(--ds-primary);outline-offset:2px}
718
+ .ygd-studio-select:disabled{cursor:not-allowed;opacity:.6}
719
+ button.ygd-studio-select>span:first-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
720
+ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:center;color:var(--ds-text-secondary)}
710
721
  .ygd-studio-workspace h1,.ygd-studio-workspace h2,.ygd-studio-workspace h3,.ygd-studio-workspace h4,.ygd-studio-workspace p,.ygd-studio-workspace ul,.ygd-studio-workspace ol{margin:0}
711
722
 
712
723
  /* Narrow-viewport drawer toggle; positioned by the responsive block below */
@@ -1173,6 +1184,39 @@ function LoadingIndicator({ label }) {
1173
1184
  });
1174
1185
  }
1175
1186
  //#endregion
1187
+ //#region src/StudioSelect.tsx
1188
+ const StudioSelectContext = createContext(void 0);
1189
+ /** Hosts may supply their shared accessible control; minimal hosts keep a
1190
+ * controlled native select, including visible unknown values and disabled state. */
1191
+ function StudioSelect({ className, ...props }) {
1192
+ const renderer = useContext(StudioSelectContext);
1193
+ const controlProps = {
1194
+ ...props,
1195
+ className: `ygd-studio-select${className ? ` ${className}` : ""}`
1196
+ };
1197
+ if (renderer) return createElement(renderer, controlProps);
1198
+ const choices = props.options.some((option) => option.value === props.value) ? props.options : [{
1199
+ value: props.value,
1200
+ label: props.value,
1201
+ disabled: props.value !== ""
1202
+ }, ...props.options];
1203
+ return /* @__PURE__ */ jsx("select", {
1204
+ className: controlProps.className,
1205
+ "aria-label": props["aria-label"],
1206
+ value: props.value,
1207
+ disabled: props.disabled,
1208
+ onChange: (event) => {
1209
+ const value = event.currentTarget.value;
1210
+ if (!props.disabled && choices.some((option) => option.value === value && !option.disabled)) props.onValueChange(value);
1211
+ },
1212
+ children: choices.map((option) => /* @__PURE__ */ jsx("option", {
1213
+ value: option.value,
1214
+ disabled: option.disabled,
1215
+ children: option.label
1216
+ }, option.value))
1217
+ });
1218
+ }
1219
+ //#endregion
1176
1220
  //#region src/FileExplorer.tsx
1177
1221
  function FileExplorer({ paths, selected, openFile, disabled = false }) {
1178
1222
  const branch = (prefix) => {
@@ -1943,18 +1987,21 @@ function KitDraftEditor({ record, authoring, locale, opening, onDirtyChange, onR
1943
1987
  /* @__PURE__ */ jsxs("div", {
1944
1988
  className: "ygd-studio-draft-sources",
1945
1989
  children: [
1946
- /* @__PURE__ */ jsxs("label", { children: ["Bundle", /* @__PURE__ */ jsxs("select", {
1990
+ /* @__PURE__ */ jsxs("label", { children: ["Bundle", /* @__PURE__ */ jsx(StudioSelect, {
1947
1991
  "aria-label": "Preview Bundle",
1948
1992
  disabled: opening || state.busy,
1949
1993
  value: bundleKey,
1950
- onChange: (event) => {
1994
+ onValueChange: (value) => {
1951
1995
  controller.clearPreview();
1952
- setBundleKey(event.target.value);
1996
+ setBundleKey(value);
1953
1997
  },
1954
- children: [/* @__PURE__ */ jsx("option", {
1998
+ options: [{
1955
1999
  value: "",
1956
- children: "—"
1957
- }), record.mounts.map((mount) => /* @__PURE__ */ jsx("option", { children: `${mount.name}@${mount.version}` }, `${mount.name}@${mount.version}`))]
2000
+ label: "—"
2001
+ }, ...record.mounts.map((mount) => ({
2002
+ value: `${mount.name}@${mount.version}`,
2003
+ label: `${mount.name}@${mount.version}`
2004
+ }))]
1958
2005
  })] }),
1959
2006
  /* @__PURE__ */ jsxs("label", { children: [t.sample, /* @__PURE__ */ jsx("textarea", {
1960
2007
  "aria-label": t.sample,
@@ -3583,18 +3630,14 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, renderPrevie
3583
3630
  children: [
3584
3631
  record?.kind === "kit" && /* @__PURE__ */ jsx("div", {
3585
3632
  className: "ygd-studio-doc-toolbar",
3586
- children: /* @__PURE__ */ jsxs("label", { children: [zh ? "Bundle " : "Bundle ", /* @__PURE__ */ jsx("select", {
3633
+ children: /* @__PURE__ */ jsxs("label", { children: [zh ? "Bundle " : "Bundle ", /* @__PURE__ */ jsx(StudioSelect, {
3587
3634
  "aria-label": "Preview Bundle",
3588
3635
  value: bundleKey,
3589
- onChange: (event) => setBundleKey(event.target.value),
3590
- children: record.mounts.map((mount) => /* @__PURE__ */ jsxs("option", {
3636
+ onValueChange: setBundleKey,
3637
+ options: record.mounts.map((mount) => ({
3591
3638
  value: `${mount.bundle.name}@${mount.bundle.version}`,
3592
- children: [
3593
- mount.bundle.name,
3594
- " · ",
3595
- mount.bundle.version
3596
- ]
3597
- }, `${mount.bundle.name}@${mount.bundle.version}`))
3639
+ label: `${mount.bundle.name} · ${mount.bundle.version}`
3640
+ }))
3598
3641
  })] })
3599
3642
  }),
3600
3643
  previewBusy && /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在准备预览" : "Preparing preview" }),
@@ -4730,7 +4773,7 @@ function InstalledPreview({ authoring, client, kit, bundle, locale, declarative,
4730
4773
  });
4731
4774
  }
4732
4775
  /** Read-only Studio surface: one complete page with global nav, sidebar, and workspace main. */
4733
- function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring, trials, instances, componentLibrary, contentClient, onDraftDirtyChange, locale: hostLocale, onLocaleChange }) {
4776
+ function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring, trials, instances, componentLibrary, renderSelect, contentClient, onDraftDirtyChange, locale: hostLocale, onLocaleChange }) {
4734
4777
  const controller = useMemo(() => supplied ?? new StudioWorkspaceController(client), [client, supplied]);
4735
4778
  const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
4736
4779
  const tabElements = useRef(/* @__PURE__ */ new Map());
@@ -5157,17 +5200,14 @@ function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring
5157
5200
  className: "ygd-studio-page-title",
5158
5201
  children: bundleTitle(bundleWorkspace.name, bundleWorkspace.version)
5159
5202
  }),
5160
- /* @__PURE__ */ jsxs("label", { children: [locale === "zh" ? "版本 " : "Version ", /* @__PURE__ */ jsx("select", {
5203
+ /* @__PURE__ */ jsxs("label", { children: [locale === "zh" ? "版本 " : "Version ", /* @__PURE__ */ jsx(StudioSelect, {
5161
5204
  "aria-label": locale === "zh" ? "Bundle 版本" : "Bundle version",
5162
5205
  value: bundleWorkspace.version,
5163
- onChange: (event) => {
5164
- const version = event.currentTarget.value;
5165
- leaveDrafts(() => void controller.openBundleWorkspace(bundleWorkspace.name, version));
5166
- },
5167
- children: groupInstalledContent(snapshot.view?.bundles ?? []).find((group) => group.name === bundleWorkspace.name)?.versions.map((bundle) => /* @__PURE__ */ jsx("option", {
5206
+ onValueChange: (version) => leaveDrafts(() => void controller.openBundleWorkspace(bundleWorkspace.name, version)),
5207
+ options: groupInstalledContent(snapshot.view?.bundles ?? []).find((group) => group.name === bundleWorkspace.name)?.versions.map((bundle) => ({
5168
5208
  value: bundle.version,
5169
- children: bundle.version
5170
- }, bundle.version))
5209
+ label: bundle.version
5210
+ })) ?? []
5171
5211
  })] })
5172
5212
  ]
5173
5213
  }),
@@ -5538,17 +5578,14 @@ function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring
5538
5578
  className: "ygd-studio-page-title",
5539
5579
  children: displayName(workspace.name)
5540
5580
  }),
5541
- /* @__PURE__ */ jsxs("label", { children: [locale === "zh" ? "版本 " : "Version ", /* @__PURE__ */ jsx("select", {
5581
+ /* @__PURE__ */ jsxs("label", { children: [locale === "zh" ? "版本 " : "Version ", /* @__PURE__ */ jsx(StudioSelect, {
5542
5582
  "aria-label": locale === "zh" ? "Kit 版本" : "Kit version",
5543
5583
  value: workspace.version,
5544
- onChange: (event) => {
5545
- const version = event.currentTarget.value;
5546
- leaveDrafts(() => void controller.selectKit(workspace.name, version));
5547
- },
5548
- children: groupInstalledContent(snapshot.view?.kits ?? []).find((group) => group.name === workspace.name)?.versions.map((kit) => /* @__PURE__ */ jsx("option", {
5584
+ onValueChange: (version) => leaveDrafts(() => void controller.selectKit(workspace.name, version)),
5585
+ options: groupInstalledContent(snapshot.view?.kits ?? []).find((group) => group.name === workspace.name)?.versions.map((kit) => ({
5549
5586
  value: kit.version,
5550
- children: kit.version
5551
- }, kit.version))
5587
+ label: kit.version
5588
+ })) ?? []
5552
5589
  })] })
5553
5590
  ]
5554
5591
  }),
@@ -5650,340 +5687,338 @@ function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring
5650
5687
  })
5651
5688
  ]
5652
5689
  });
5653
- return /* @__PURE__ */ jsxs("section", {
5654
- className: "ygd-studio-workspace",
5655
- "aria-label": "Design Studio",
5656
- children: [
5657
- /* @__PURE__ */ jsx("style", { children: STUDIO_WORKSPACE_CSS }),
5658
- /* @__PURE__ */ jsx("button", {
5659
- className: "ygd-studio-menu-btn",
5660
- type: "button",
5661
- "aria-label": "Toggle menu",
5662
- "aria-expanded": sidebarOpen,
5663
- onClick: () => setSidebarOpen(!sidebarOpen),
5664
- children: "☰"
5665
- }),
5666
- /* @__PURE__ */ jsxs("div", {
5667
- className: "ygd-studio-body",
5668
- children: [/* @__PURE__ */ jsxs("aside", {
5669
- className: `ygd-studio-sidebar${sidebarOpen ? " open" : ""}`,
5670
- "aria-label": "Product navigation",
5671
- children: [
5672
- /* @__PURE__ */ jsx("div", {
5673
- className: "ygd-studio-sidebar-logo",
5674
- children: "Yugoo Design"
5675
- }),
5676
- /* @__PURE__ */ jsxs("nav", {
5677
- className: "ygd-studio-sidebar-nav",
5678
- "aria-label": "Studio sections",
5679
- children: [/* @__PURE__ */ jsxs("button", {
5680
- className: "ygd-studio-sidebar-item",
5681
- type: "button",
5682
- "aria-current": !componentsOpen && !archivesOpen && !draftsOpen && !bundleWorkspace && snapshot.section === "kits" ? "page" : void 0,
5683
- onClick: () => leaveDrafts(() => {
5684
- setComponentsOpen(false);
5685
- controller.backToList();
5686
- }),
5687
- children: [/* @__PURE__ */ jsx(StudioGlyph, {}), t.kitsTitle]
5688
- }), /* @__PURE__ */ jsxs("button", {
5689
- className: "ygd-studio-sidebar-item",
5690
- type: "button",
5691
- "aria-current": !componentsOpen && !archivesOpen && !draftsOpen && (bundleWorkspace || snapshot.section === "bundles") ? "page" : void 0,
5692
- onClick: () => leaveDrafts(() => {
5693
- setComponentsOpen(false);
5694
- controller.setSection("bundles");
5695
- }),
5696
- children: [/* @__PURE__ */ jsx(StudioGlyph, { bundle: true }), t.bundlesTitle]
5697
- })]
5698
- }),
5699
- /* @__PURE__ */ jsxs("div", {
5700
- className: "ygd-studio-sidebar-footer",
5701
- children: [componentLibrary && /* @__PURE__ */ jsx("nav", {
5702
- className: "ygd-studio-sidebar-utilities",
5703
- "aria-label": locale === "zh" ? "Studio 工具" : "Studio utilities",
5704
- children: /* @__PURE__ */ jsxs("button", {
5690
+ return /* @__PURE__ */ jsx(StudioSelectContext.Provider, {
5691
+ value: renderSelect,
5692
+ children: /* @__PURE__ */ jsxs("section", {
5693
+ className: "ygd-studio-workspace",
5694
+ "aria-label": "Design Studio",
5695
+ children: [
5696
+ /* @__PURE__ */ jsx("style", { children: STUDIO_WORKSPACE_CSS }),
5697
+ /* @__PURE__ */ jsx("button", {
5698
+ className: "ygd-studio-menu-btn",
5699
+ type: "button",
5700
+ "aria-label": "Toggle menu",
5701
+ "aria-expanded": sidebarOpen,
5702
+ onClick: () => setSidebarOpen(!sidebarOpen),
5703
+ children: "☰"
5704
+ }),
5705
+ /* @__PURE__ */ jsxs("div", {
5706
+ className: "ygd-studio-body",
5707
+ children: [/* @__PURE__ */ jsxs("aside", {
5708
+ className: `ygd-studio-sidebar${sidebarOpen ? " open" : ""}`,
5709
+ "aria-label": "Product navigation",
5710
+ children: [
5711
+ /* @__PURE__ */ jsx("div", {
5712
+ className: "ygd-studio-sidebar-logo",
5713
+ children: "Yugoo Design"
5714
+ }),
5715
+ /* @__PURE__ */ jsxs("nav", {
5716
+ className: "ygd-studio-sidebar-nav",
5717
+ "aria-label": "Studio sections",
5718
+ children: [/* @__PURE__ */ jsxs("button", {
5705
5719
  className: "ygd-studio-sidebar-item",
5706
5720
  type: "button",
5707
- "aria-current": componentsOpen ? "page" : void 0,
5708
- onClick: () => leaveDrafts(() => setComponentsOpen(true)),
5709
- children: [/* @__PURE__ */ jsx("span", {
5710
- className: "ygd-studio-kitmark",
5721
+ "aria-current": !componentsOpen && !archivesOpen && !draftsOpen && !bundleWorkspace && snapshot.section === "kits" ? "page" : void 0,
5722
+ onClick: () => leaveDrafts(() => {
5723
+ setComponentsOpen(false);
5724
+ controller.backToList();
5725
+ }),
5726
+ children: [/* @__PURE__ */ jsx(StudioGlyph, {}), t.kitsTitle]
5727
+ }), /* @__PURE__ */ jsxs("button", {
5728
+ className: "ygd-studio-sidebar-item",
5729
+ type: "button",
5730
+ "aria-current": !componentsOpen && !archivesOpen && !draftsOpen && (bundleWorkspace || snapshot.section === "bundles") ? "page" : void 0,
5731
+ onClick: () => leaveDrafts(() => {
5732
+ setComponentsOpen(false);
5733
+ controller.setSection("bundles");
5734
+ }),
5735
+ children: [/* @__PURE__ */ jsx(StudioGlyph, { bundle: true }), t.bundlesTitle]
5736
+ })]
5737
+ }),
5738
+ /* @__PURE__ */ jsxs("div", {
5739
+ className: "ygd-studio-sidebar-footer",
5740
+ children: [componentLibrary && /* @__PURE__ */ jsx("nav", {
5741
+ className: "ygd-studio-sidebar-utilities",
5742
+ "aria-label": locale === "zh" ? "Studio 工具" : "Studio utilities",
5743
+ children: /* @__PURE__ */ jsxs("button", {
5744
+ className: "ygd-studio-sidebar-item",
5745
+ type: "button",
5746
+ "aria-current": componentsOpen ? "page" : void 0,
5747
+ onClick: () => leaveDrafts(() => setComponentsOpen(true)),
5748
+ children: [/* @__PURE__ */ jsx("span", {
5749
+ className: "ygd-studio-kitmark",
5750
+ "aria-hidden": "true",
5751
+ children: /* @__PURE__ */ jsxs("svg", {
5752
+ viewBox: "0 0 24 24",
5753
+ fill: "none",
5754
+ stroke: "currentColor",
5755
+ strokeWidth: "1.5",
5756
+ children: [
5757
+ /* @__PURE__ */ jsx("rect", {
5758
+ x: "3",
5759
+ y: "3",
5760
+ width: "7",
5761
+ height: "7",
5762
+ rx: "1"
5763
+ }),
5764
+ /* @__PURE__ */ jsx("rect", {
5765
+ x: "14",
5766
+ y: "3",
5767
+ width: "7",
5768
+ height: "7",
5769
+ rx: "1"
5770
+ }),
5771
+ /* @__PURE__ */ jsx("rect", {
5772
+ x: "3",
5773
+ y: "14",
5774
+ width: "7",
5775
+ height: "7",
5776
+ rx: "1"
5777
+ }),
5778
+ /* @__PURE__ */ jsx("rect", {
5779
+ x: "14",
5780
+ y: "14",
5781
+ width: "7",
5782
+ height: "7",
5783
+ rx: "1"
5784
+ })
5785
+ ]
5786
+ })
5787
+ }), locale === "zh" ? "面板组件库" : "Panel Component Library"]
5788
+ })
5789
+ }), /* @__PURE__ */ jsxs("div", {
5790
+ className: "ygd-studio-language",
5791
+ role: "group",
5792
+ "aria-label": locale === "zh" ? "界面语言" : "Interface language",
5793
+ children: [/* @__PURE__ */ jsx("button", {
5794
+ type: "button",
5795
+ lang: "zh-CN",
5796
+ "aria-pressed": locale === "zh",
5797
+ onClick: () => changeLocale("zh"),
5798
+ children: "中文"
5799
+ }), /* @__PURE__ */ jsx("button", {
5800
+ type: "button",
5801
+ lang: "en",
5802
+ "aria-pressed": locale === "en",
5803
+ onClick: () => changeLocale("en"),
5804
+ children: "EN"
5805
+ })]
5806
+ })]
5807
+ })
5808
+ ]
5809
+ }), /* @__PURE__ */ jsxs("div", {
5810
+ className: "ygd-studio-stage",
5811
+ children: [/* @__PURE__ */ jsxs("div", {
5812
+ className: "ygd-studio-topbar",
5813
+ children: [/* @__PURE__ */ jsxs("span", {
5814
+ "aria-label": "Breadcrumb",
5815
+ children: [
5816
+ /* @__PURE__ */ jsx("button", {
5817
+ className: "ygd-studio-breadcrumb-button",
5818
+ type: "button",
5819
+ onClick: () => {
5820
+ if (!componentsOpen) leaveDrafts(() => snapshot.section === "kits" ? controller.backToList() : controller.closeBundleWorkspace());
5821
+ },
5822
+ children: componentsOpen ? locale === "zh" ? "面板组件库" : "Panel Component Library" : snapshot.section === "kits" ? t.kitsTitle : t.bundlesTitle
5823
+ }),
5824
+ !componentsOpen && !archivesOpen && !instanceId && workspace && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5711
5825
  "aria-hidden": "true",
5712
- children: /* @__PURE__ */ jsxs("svg", {
5713
- viewBox: "0 0 24 24",
5714
- fill: "none",
5715
- stroke: "currentColor",
5716
- strokeWidth: "1.5",
5717
- children: [
5718
- /* @__PURE__ */ jsx("rect", {
5719
- x: "3",
5720
- y: "3",
5721
- width: "7",
5722
- height: "7",
5723
- rx: "1"
5724
- }),
5725
- /* @__PURE__ */ jsx("rect", {
5726
- x: "14",
5727
- y: "3",
5728
- width: "7",
5729
- height: "7",
5730
- rx: "1"
5731
- }),
5732
- /* @__PURE__ */ jsx("rect", {
5733
- x: "3",
5734
- y: "14",
5735
- width: "7",
5736
- height: "7",
5737
- rx: "1"
5738
- }),
5739
- /* @__PURE__ */ jsx("rect", {
5740
- x: "14",
5741
- y: "14",
5742
- width: "7",
5743
- height: "7",
5744
- rx: "1"
5745
- })
5746
- ]
5747
- })
5748
- }), locale === "zh" ? "面板组件库" : "Panel Component Library"]
5749
- })
5826
+ children: "/"
5827
+ }), bundleWorkspace ? /* @__PURE__ */ jsx("button", {
5828
+ className: "ygd-studio-breadcrumb-button",
5829
+ type: "button",
5830
+ onClick: () => leaveDrafts(() => controller.closeBundleWorkspace()),
5831
+ children: displayName(workspace.name)
5832
+ }) : /* @__PURE__ */ jsx("span", {
5833
+ "aria-current": "page",
5834
+ children: displayName(workspace.name)
5835
+ })] }),
5836
+ !componentsOpen && !archivesOpen && !instanceId && bundleWorkspace && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5837
+ "aria-hidden": "true",
5838
+ children: "/"
5839
+ }), bundleTitle(bundleWorkspace.name, bundleWorkspace.version)] }),
5840
+ !componentsOpen && instanceId && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5841
+ "aria-hidden": "true",
5842
+ children: "/"
5843
+ }), localInstances.find((record) => record.id === instanceId)?.title[locale]] }),
5844
+ archivesOpen && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5845
+ "aria-hidden": "true",
5846
+ children: "/"
5847
+ }), /* @__PURE__ */ jsx("span", {
5848
+ "aria-current": "page",
5849
+ children: locale === "zh" ? "内容归档" : "Content archives"
5850
+ })] })
5851
+ ]
5750
5852
  }), /* @__PURE__ */ jsxs("div", {
5751
- className: "ygd-studio-language",
5752
- role: "group",
5753
- "aria-label": locale === "zh" ? "界面语言" : "Interface language",
5754
- children: [/* @__PURE__ */ jsx("button", {
5853
+ className: "ygd-studio-topbar-actions",
5854
+ children: [contentClient && /* @__PURE__ */ jsx("button", {
5855
+ className: "ygd-studio-btn-link",
5755
5856
  type: "button",
5756
- lang: "zh-CN",
5757
- "aria-pressed": locale === "zh",
5758
- onClick: () => changeLocale("zh"),
5759
- children: "中文"
5760
- }), /* @__PURE__ */ jsx("button", {
5857
+ disabled: archivesOpen,
5858
+ onClick: () => leaveDrafts(() => {
5859
+ setComponentsOpen(false);
5860
+ setArchivesOpen(true);
5861
+ }),
5862
+ children: locale === "zh" ? "内容归档" : "Content archives"
5863
+ }), !componentsOpen && /* @__PURE__ */ jsx("button", {
5864
+ className: "ygd-studio-btn-link",
5761
5865
  type: "button",
5762
- lang: "en",
5763
- "aria-pressed": locale === "en",
5764
- onClick: () => changeLocale("en"),
5765
- children: "EN"
5866
+ disabled: snapshot.phase === "loading",
5867
+ onClick: () => leaveDrafts(() => {
5868
+ (async () => {
5869
+ await controller.load();
5870
+ await refreshInstances();
5871
+ if (workspace) await controller.selectKit(workspace.name, workspace.version);
5872
+ if (bundleWorkspace) {
5873
+ await controller.openBundleWorkspace(bundleWorkspace.name, bundleWorkspace.version);
5874
+ if (bundleFile) await controller.openBundleFile(bundleFile.path);
5875
+ }
5876
+ })();
5877
+ }),
5878
+ children: locale === "zh" ? "刷新内容" : "Refresh content"
5766
5879
  })]
5767
5880
  })]
5768
- })
5769
- ]
5770
- }), /* @__PURE__ */ jsxs("div", {
5771
- className: "ygd-studio-stage",
5772
- children: [/* @__PURE__ */ jsxs("div", {
5773
- className: "ygd-studio-topbar",
5774
- children: [/* @__PURE__ */ jsxs("span", {
5775
- "aria-label": "Breadcrumb",
5776
- children: [
5777
- /* @__PURE__ */ jsx("button", {
5778
- className: "ygd-studio-breadcrumb-button",
5779
- type: "button",
5780
- onClick: () => {
5781
- if (!componentsOpen) leaveDrafts(() => snapshot.section === "kits" ? controller.backToList() : controller.closeBundleWorkspace());
5782
- },
5783
- children: componentsOpen ? locale === "zh" ? "面板组件库" : "Panel Component Library" : snapshot.section === "kits" ? t.kitsTitle : t.bundlesTitle
5784
- }),
5785
- !componentsOpen && !archivesOpen && !instanceId && workspace && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5786
- "aria-hidden": "true",
5787
- children: "/"
5788
- }), bundleWorkspace ? /* @__PURE__ */ jsx("button", {
5789
- className: "ygd-studio-breadcrumb-button",
5790
- type: "button",
5791
- onClick: () => leaveDrafts(() => controller.closeBundleWorkspace()),
5792
- children: displayName(workspace.name)
5793
- }) : /* @__PURE__ */ jsx("span", {
5794
- "aria-current": "page",
5795
- children: displayName(workspace.name)
5796
- })] }),
5797
- !componentsOpen && !archivesOpen && !instanceId && bundleWorkspace && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5798
- "aria-hidden": "true",
5799
- children: "/"
5800
- }), bundleTitle(bundleWorkspace.name, bundleWorkspace.version)] }),
5801
- !componentsOpen && instanceId && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5802
- "aria-hidden": "true",
5803
- children: "/"
5804
- }), localInstances.find((record) => record.id === instanceId)?.title[locale]] }),
5805
- archivesOpen && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
5806
- "aria-hidden": "true",
5807
- children: "/"
5808
- }), /* @__PURE__ */ jsx("span", {
5809
- "aria-current": "page",
5810
- children: locale === "zh" ? "内容归档" : "Content archives"
5811
- })] })
5812
- ]
5813
- }), /* @__PURE__ */ jsxs("div", {
5814
- className: "ygd-studio-topbar-actions",
5815
- children: [contentClient && /* @__PURE__ */ jsx("button", {
5816
- className: "ygd-studio-btn-link",
5817
- type: "button",
5818
- disabled: archivesOpen,
5819
- onClick: () => leaveDrafts(() => {
5820
- setComponentsOpen(false);
5821
- setArchivesOpen(true);
5822
- }),
5823
- children: locale === "zh" ? "内容归档" : "Content archives"
5824
- }), !componentsOpen && /* @__PURE__ */ jsx("button", {
5825
- className: "ygd-studio-btn-link",
5826
- type: "button",
5827
- disabled: snapshot.phase === "loading",
5828
- onClick: () => leaveDrafts(() => {
5829
- (async () => {
5830
- await controller.load();
5831
- await refreshInstances();
5832
- if (workspace) await controller.selectKit(workspace.name, workspace.version);
5833
- if (bundleWorkspace) {
5834
- await controller.openBundleWorkspace(bundleWorkspace.name, bundleWorkspace.version);
5835
- if (bundleFile) await controller.openBundleFile(bundleFile.path);
5836
- }
5837
- })();
5838
- }),
5839
- children: locale === "zh" ? "刷新内容" : "Refresh content"
5840
- })]
5841
- })]
5842
- }), componentsOpen && componentLibrary ? /* @__PURE__ */ jsx(ComponentLibrary, {
5843
- library: componentLibrary,
5844
- locale
5845
- }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [authoringError && /* @__PURE__ */ jsx("p", {
5846
- role: "alert",
5847
- className: "ygd-studio-error",
5848
- children: authoringError
5849
- }), archivesOpen && contentClient ? /* @__PURE__ */ jsx(ContentArchiveWorkbench, {
5850
- client: contentClient,
5851
- installedKit: workspace ? {
5852
- name: workspace.name,
5853
- version: workspace.version
5854
- } : void 0,
5855
- locale,
5856
- canAdoptKit: !!kitAuthoring,
5857
- onBack: () => leaveDrafts(() => {}),
5858
- onAdopt: (result) => leaveDrafts(() => {
5859
- if (result.draft && kitAuthoring) {
5860
- setDraftId(result.draft.id);
5861
- setDraftsOpen("kit");
5862
- controller.load();
5863
- return;
5881
+ }), componentsOpen && componentLibrary ? /* @__PURE__ */ jsx(ComponentLibrary, {
5882
+ library: componentLibrary,
5883
+ locale
5884
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [authoringError && /* @__PURE__ */ jsx("p", {
5885
+ role: "alert",
5886
+ className: "ygd-studio-error",
5887
+ children: authoringError
5888
+ }), archivesOpen && contentClient ? /* @__PURE__ */ jsx(ContentArchiveWorkbench, {
5889
+ client: contentClient,
5890
+ installedKit: workspace ? {
5891
+ name: workspace.name,
5892
+ version: workspace.version
5893
+ } : void 0,
5894
+ locale,
5895
+ canAdoptKit: !!kitAuthoring,
5896
+ onBack: () => leaveDrafts(() => {}),
5897
+ onAdopt: (result) => leaveDrafts(() => {
5898
+ if (result.draft && kitAuthoring) {
5899
+ setDraftId(result.draft.id);
5900
+ setDraftsOpen("kit");
5901
+ controller.load();
5902
+ return;
5903
+ }
5904
+ const bundle = result.contents.find((item) => item.kind === "bundle");
5905
+ if (!bundle) return;
5906
+ const request = createGeneration.current;
5907
+ (async () => {
5908
+ await controller.load();
5909
+ if (request !== createGeneration.current || controller.getSnapshot().phase !== "ready") return;
5910
+ controller.setSection("bundles");
5911
+ await controller.openBundleWorkspace(bundle.pin.name, bundle.pin.version);
5912
+ })();
5913
+ }),
5914
+ onDirtyChange: (value) => {
5915
+ draftDirty.current = value;
5916
+ onDraftDirtyChange?.(value);
5864
5917
  }
5865
- const bundle = result.contents.find((item) => item.kind === "bundle");
5866
- if (!bundle) return;
5867
- const request = createGeneration.current;
5868
- (async () => {
5869
- await controller.load();
5870
- if (request !== createGeneration.current || controller.getSnapshot().phase !== "ready") return;
5871
- controller.setSection("bundles");
5872
- await controller.openBundleWorkspace(bundle.pin.name, bundle.pin.version);
5873
- })();
5874
- }),
5875
- onDirtyChange: (value) => {
5876
- draftDirty.current = value;
5877
- onDraftDirtyChange?.(value);
5878
- }
5879
- }) : snapshot.phase === "loading" && !instanceId && !draftsOpen ? /* @__PURE__ */ jsx("main", {
5880
- className: "ygd-studio-main",
5881
- children: /* @__PURE__ */ jsx(LoadingIndicator, { label: t.loading })
5882
- }) : instanceId && instances ? /* @__PURE__ */ jsx(InstanceWorkbench, {
5883
- client: instances,
5884
- id: instanceId,
5885
- locale,
5886
- renderPreview: authoring?.renderPreview,
5887
- onBack: () => leaveDrafts(() => controller.backToList()),
5888
- onChanged: (record) => {
5889
- setInstanceId(record?.id);
5890
- refreshInstances().catch((error) => setAuthoringError(String(error)));
5891
- },
5892
- onDirtyChange: (value) => {
5893
- draftDirty.current = value;
5894
- onDraftDirtyChange?.(value);
5895
- }
5896
- }, instanceId) : draftsOpen === "kit" && kitAuthoring ? /* @__PURE__ */ jsx(KitDraftWorkbench, {
5897
- authoring: kitAuthoring,
5898
- initialId: draftId,
5899
- locale,
5900
- onDirtyChange: (value) => {
5901
- draftDirty.current = value;
5902
- onDraftDirtyChange?.(value);
5903
- }
5904
- }) : draftsOpen === "panel" && authoring ? /* @__PURE__ */ jsx(PanelDraftWorkbench, {
5905
- onBack: () => leaveDrafts(() => {
5906
- setBundleTab("preview");
5907
- setPreviewMode("sample");
5908
- }),
5909
- trials,
5910
- authoring,
5911
- initialId: draftId,
5912
- locale,
5913
- onDirtyChange: (value) => {
5914
- draftDirty.current = value;
5915
- onDraftDirtyChange?.(value);
5916
- }
5917
- }) : bundleMain !== void 0 ? bundleMain : snapshot.section === "bundles" ? bundlesListMain : kitMain] })]
5918
- })]
5919
- }),
5920
- workspace && recoveryOpen && /* @__PURE__ */ jsx(StudioDialog, {
5921
- title: locale === "zh" ? "恢复工作副本" : "Restore working copy",
5922
- close: () => setRecoveryOpen(false),
5923
- children: kitAuthoring && mindsetChoices.length > 0 && /* @__PURE__ */ jsxs("label", {
5924
- className: "ygd-studio-mindset-recovery",
5925
- children: [
5926
- locale === "zh" ? "工作副本" : "Working copy",
5927
- " ",
5928
- /* @__PURE__ */ jsxs("select", {
5929
- "aria-label": "Mindset working copy",
5930
- value: mindsetRecords.current.get(kitKey) ?? "",
5931
- onChange: (event) => {
5932
- const id = event.target.value;
5933
- leaveDrafts(() => {
5934
- if (id) mindsetRecords.current.set(kitKey, id);
5935
- else mindsetRecords.current.delete(kitKey);
5936
- setSavedMindsets((previous) => {
5937
- const next = { ...previous };
5938
- delete next[kitKey];
5939
- return next;
5940
- });
5941
- setMindsetEditorEpoch((epoch) => epoch + 1);
5942
- setRecoveryOpen(false);
5943
- });
5918
+ }) : snapshot.phase === "loading" && !instanceId && !draftsOpen ? /* @__PURE__ */ jsx("main", {
5919
+ className: "ygd-studio-main",
5920
+ children: /* @__PURE__ */ jsx(LoadingIndicator, { label: t.loading })
5921
+ }) : instanceId && instances ? /* @__PURE__ */ jsx(InstanceWorkbench, {
5922
+ client: instances,
5923
+ id: instanceId,
5924
+ locale,
5925
+ renderPreview: authoring?.renderPreview,
5926
+ onBack: () => leaveDrafts(() => controller.backToList()),
5927
+ onChanged: (record) => {
5928
+ setInstanceId(record?.id);
5929
+ refreshInstances().catch((error) => setAuthoringError(String(error)));
5944
5930
  },
5945
- children: [/* @__PURE__ */ jsx("option", {
5946
- value: "",
5947
- children: locale === "zh" ? "已安装原文" : "Installed source"
5948
- }), mindsetChoices.map((record) => /* @__PURE__ */ jsxs("option", {
5949
- value: record.id,
5950
- children: [
5951
- record.id.slice(0, 8),
5952
- " · r",
5953
- record.revision
5954
- ]
5955
- }, record.id))]
5956
- })
5957
- ]
5931
+ onDirtyChange: (value) => {
5932
+ draftDirty.current = value;
5933
+ onDraftDirtyChange?.(value);
5934
+ }
5935
+ }, instanceId) : draftsOpen === "kit" && kitAuthoring ? /* @__PURE__ */ jsx(KitDraftWorkbench, {
5936
+ authoring: kitAuthoring,
5937
+ initialId: draftId,
5938
+ locale,
5939
+ onDirtyChange: (value) => {
5940
+ draftDirty.current = value;
5941
+ onDraftDirtyChange?.(value);
5942
+ }
5943
+ }) : draftsOpen === "panel" && authoring ? /* @__PURE__ */ jsx(PanelDraftWorkbench, {
5944
+ onBack: () => leaveDrafts(() => {
5945
+ setBundleTab("preview");
5946
+ setPreviewMode("sample");
5947
+ }),
5948
+ trials,
5949
+ authoring,
5950
+ initialId: draftId,
5951
+ locale,
5952
+ onDirtyChange: (value) => {
5953
+ draftDirty.current = value;
5954
+ onDraftDirtyChange?.(value);
5955
+ }
5956
+ }) : bundleMain !== void 0 ? bundleMain : snapshot.section === "bundles" ? bundlesListMain : kitMain] })]
5957
+ })]
5958
+ }),
5959
+ workspace && recoveryOpen && /* @__PURE__ */ jsx(StudioDialog, {
5960
+ title: locale === "zh" ? "恢复工作副本" : "Restore working copy",
5961
+ close: () => setRecoveryOpen(false),
5962
+ children: kitAuthoring && mindsetChoices.length > 0 && /* @__PURE__ */ jsxs("label", {
5963
+ className: "ygd-studio-mindset-recovery",
5964
+ children: [
5965
+ locale === "zh" ? "工作副本" : "Working copy",
5966
+ " ",
5967
+ /* @__PURE__ */ jsx(StudioSelect, {
5968
+ "aria-label": "Mindset working copy",
5969
+ value: mindsetRecords.current.get(kitKey) ?? "",
5970
+ onValueChange: (id) => {
5971
+ leaveDrafts(() => {
5972
+ if (id) mindsetRecords.current.set(kitKey, id);
5973
+ else mindsetRecords.current.delete(kitKey);
5974
+ setSavedMindsets((previous) => {
5975
+ const next = { ...previous };
5976
+ delete next[kitKey];
5977
+ return next;
5978
+ });
5979
+ setMindsetEditorEpoch((epoch) => epoch + 1);
5980
+ setRecoveryOpen(false);
5981
+ });
5982
+ },
5983
+ options: [{
5984
+ value: "",
5985
+ label: locale === "zh" ? "已安装原文" : "Installed source"
5986
+ }, ...mindsetChoices.map((record) => ({
5987
+ value: record.id,
5988
+ label: `${record.id.slice(0, 8)} · r${record.revision}`
5989
+ }))]
5990
+ })
5991
+ ]
5992
+ })
5993
+ }),
5994
+ fileLocationOpen && /* @__PURE__ */ jsxs(StudioDialog, {
5995
+ title: locale === "zh" ? "文件位置" : "File location",
5996
+ close: () => setFileLocationOpen(false),
5997
+ children: [/* @__PURE__ */ jsx("p", { children: bundleWorkspace ? `${bundleWorkspace.name}/${bundleFile?.path ?? ""}` : "mindset.md" }), /* @__PURE__ */ jsx("p", { children: locale === "zh" ? "当前为包内相对路径。此宿主尚未提供本机绝对路径或打开编辑器接口。" : "Package-relative path. This host does not expose a local absolute path or editor launch capability." })]
5998
+ }),
5999
+ workspace && fullMindset && /* @__PURE__ */ jsxs(StudioDialog, {
6000
+ title: "mindset.md · 完整文件",
6001
+ close: () => setFullMindset(false),
6002
+ children: [/* @__PURE__ */ jsx("p", { children: locale === "zh" ? "包含 frontmatter 与 <design_skills>;阅读视图不会修改或丢弃文件内容。" : "Includes frontmatter and <design_skills>; the reading view never changes file content." }), codeFrame(visibleMindset, "Complete Mindset file")]
6003
+ }),
6004
+ workspace && kitFilesOpen && /* @__PURE__ */ jsxs(StudioDialog, {
6005
+ title: `${locale === "zh" ? "设计套件文件" : "Kit Files"} · ${workspace.name}`,
6006
+ close: () => setKitFilesOpen(false),
6007
+ children: [/* @__PURE__ */ jsx("button", {
6008
+ className: "ygd-studio-tree-node",
6009
+ type: "button",
6010
+ onClick: () => {
6011
+ setKitFilesOpen(false);
6012
+ setFullMindset(true);
6013
+ },
6014
+ children: "mindset.md"
6015
+ }), /* @__PURE__ */ jsx("p", {
6016
+ className: "ygd-studio-subtitle",
6017
+ children: locale === "zh" ? "Bundle 资源请在对应 Bundle 的文件树中查看;其他 Kit 根目录文件读取尚未接入。" : "Compiled resource list; reading other Kit-root files is not yet connected."
6018
+ })]
5958
6019
  })
5959
- }),
5960
- fileLocationOpen && /* @__PURE__ */ jsxs(StudioDialog, {
5961
- title: locale === "zh" ? "文件位置" : "File location",
5962
- close: () => setFileLocationOpen(false),
5963
- children: [/* @__PURE__ */ jsx("p", { children: bundleWorkspace ? `${bundleWorkspace.name}/${bundleFile?.path ?? ""}` : "mindset.md" }), /* @__PURE__ */ jsx("p", { children: locale === "zh" ? "当前为包内相对路径。此宿主尚未提供本机绝对路径或打开编辑器接口。" : "Package-relative path. This host does not expose a local absolute path or editor launch capability." })]
5964
- }),
5965
- workspace && fullMindset && /* @__PURE__ */ jsxs(StudioDialog, {
5966
- title: "mindset.md · 完整文件",
5967
- close: () => setFullMindset(false),
5968
- children: [/* @__PURE__ */ jsx("p", { children: locale === "zh" ? "包含 frontmatter 与 <design_skills>;阅读视图不会修改或丢弃文件内容。" : "Includes frontmatter and <design_skills>; the reading view never changes file content." }), codeFrame(visibleMindset, "Complete Mindset file")]
5969
- }),
5970
- workspace && kitFilesOpen && /* @__PURE__ */ jsxs(StudioDialog, {
5971
- title: `${locale === "zh" ? "设计套件文件" : "Kit Files"} · ${workspace.name}`,
5972
- close: () => setKitFilesOpen(false),
5973
- children: [/* @__PURE__ */ jsx("button", {
5974
- className: "ygd-studio-tree-node",
5975
- type: "button",
5976
- onClick: () => {
5977
- setKitFilesOpen(false);
5978
- setFullMindset(true);
5979
- },
5980
- children: "mindset.md"
5981
- }), /* @__PURE__ */ jsx("p", {
5982
- className: "ygd-studio-subtitle",
5983
- children: locale === "zh" ? "Bundle 资源请在对应 Bundle 的文件树中查看;其他 Kit 根目录文件读取尚未接入。" : "Compiled resource list; reading other Kit-root files is not yet connected."
5984
- })]
5985
- })
5986
- ]
6020
+ ]
6021
+ })
5987
6022
  });
5988
6023
  }
5989
6024
  //#endregion