@dsh-stack/profile-ui 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # profile-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ User interface components for selecting and managing Stack profiles.
@@ -0,0 +1,4 @@
1
+ import type { Context as ClientContext } from "@deepseek-ai/cordis";
2
+ export declare const inject: string[];
3
+ /** Mount the profile selector and settings section into the client slot registry. */
4
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Menu } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { SETTINGS_SECTION_ICON_SLOT, SettingsSection, SettingsOptionRow, } from "@dsh-stack/settings-panel";
5
+ import { CheckIcon, LayersIcon, SettingsIcon } from "@dsh-stack/lucide-animated/client";
6
+ import { createProfileRuntime } from "@dsh-stack/profile-runtime";
7
+ import { profileOptions } from "../index.js";
8
+ const runtime = createProfileRuntime(profileOptions, { reload: () => window.location.reload() });
9
+ export const inject = ["slots"];
10
+ /** Render the compact or expanded profile selector in the sidebar footer. */
11
+ function ProfileSelector({ wide }) {
12
+ const [open, setOpen] = useState(false);
13
+ const active = runtime.getActive();
14
+ const activeOption = profileOptions.find((option) => option.id === active) ?? profileOptions[0];
15
+ return (_jsx(Menu, { open: open, onClose: () => setOpen(false), items: profileOptions.map((option) => ({ id: option.id, label: option.label })), selectedIds: [activeOption.id], onSelect: (id) => {
16
+ setOpen(false);
17
+ runtime.setActive(id);
18
+ }, align: "start", dense: true, portal: true, anchor: _jsxs("button", { type: "button", "aria-label": "Switch profile", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value), title: activeOption.label, style: {
19
+ width: "100%",
20
+ minHeight: 34,
21
+ display: "flex",
22
+ alignItems: "center",
23
+ gap: 8,
24
+ padding: wide ? "0 10px" : 0,
25
+ justifyContent: wide ? "flex-start" : "center",
26
+ border: 0,
27
+ borderRadius: 8,
28
+ background: "transparent",
29
+ color: "inherit",
30
+ cursor: "pointer",
31
+ font: "inherit",
32
+ }, children: [_jsx(SettingsIcon, { "aria-hidden": "true", size: 18 }), wide ? (_jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: activeOption.label })) : null] }) }));
33
+ }
34
+ /** Render the profile selection section inside the settings surface. */
35
+ function ProfileSettings({ close }) {
36
+ const [active, setActive] = useState(runtime.getActive());
37
+ return (_jsx(SettingsSection, { label: "Profiles", title: "Profiles", description: "Switch the active Stack composition. The new profile is applied after the interface reloads.", onClose: close, children: profileOptions.map((option) => (_jsx(SettingsOptionRow, { label: option.label, selected: option.id === active, onSelect: () => {
38
+ setActive(option.id);
39
+ runtime.setActive(option.id);
40
+ }, selectedMark: _jsx(CheckIcon, { "aria-hidden": "true", size: 18 }) }, option.id))) }));
41
+ }
42
+ /** Renders the Profiles section's nav glyph from the canonical animated icon set. */
43
+ function ProfileSettingsIcon() {
44
+ return _jsx(LayersIcon, { "aria-hidden": "true", size: 16 });
45
+ }
46
+ /** Mount the profile selector and settings section into the client slot registry. */
47
+ export function apply(ctx) {
48
+ ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({ name: "sidebar.footer.action", id: "profiles" }, ProfileSelector));
49
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
50
+ name: "settings.section",
51
+ id: "profiles",
52
+ order: 40,
53
+ label: "Profiles",
54
+ inject: () => ({}),
55
+ }, ProfileSettings));
56
+ ctx.slots.inject(SETTINGS_SECTION_ICON_SLOT, () => ctx.slots.register({ name: SETTINGS_SECTION_ICON_SLOT, id: "profiles", order: 0 }, ProfileSettingsIcon));
57
+ }