pith-ui 0.1.0 → 0.1.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/AI.md +20 -1
- package/API.md +834 -272
- package/README.md +3 -1
- package/dist/composer.d.ts.map +1 -1
- package/dist/composer.js +48 -29
- package/dist/composer.js.map +1 -1
- package/dist/content/conversation-reader.d.ts.map +1 -1
- package/dist/content/conversation-reader.js +8 -1
- package/dist/content/conversation-reader.js.map +1 -1
- package/dist/content/conversation-view.d.ts +21 -4
- package/dist/content/conversation-view.d.ts.map +1 -1
- package/dist/content/conversation-view.js +72 -13
- package/dist/content/conversation-view.js.map +1 -1
- package/dist/content/image-viewer.d.ts +4 -2
- package/dist/content/image-viewer.d.ts.map +1 -1
- package/dist/content/image-viewer.js +36 -15
- package/dist/content/image-viewer.js.map +1 -1
- package/dist/content/paged-preview.d.ts +1 -1
- package/dist/content/paged-preview.d.ts.map +1 -1
- package/dist/content/paged-preview.js +10 -5
- package/dist/content/paged-preview.js.map +1 -1
- package/dist/content/views.d.ts +3 -0
- package/dist/content/views.d.ts.map +1 -1
- package/dist/content/views.js +110 -41
- package/dist/content/views.js.map +1 -1
- package/dist/content/welcome.d.ts.map +1 -1
- package/dist/content/welcome.js +19 -7
- package/dist/content/welcome.js.map +1 -1
- package/dist/dom.js +1 -1
- package/dist/dom.js.map +1 -1
- package/dist/files/panels.d.ts +8 -1
- package/dist/files/panels.d.ts.map +1 -1
- package/dist/files/panels.js +235 -120
- package/dist/files/panels.js.map +1 -1
- package/dist/files/systems.d.ts.map +1 -1
- package/dist/files/systems.js +81 -91
- package/dist/files/systems.js.map +1 -1
- package/dist/forms/actions.d.ts +28 -7
- package/dist/forms/actions.d.ts.map +1 -1
- package/dist/forms/actions.js +59 -11
- package/dist/forms/actions.js.map +1 -1
- package/dist/forms/custom-connection.d.ts +2 -1
- package/dist/forms/custom-connection.d.ts.map +1 -1
- package/dist/forms/custom-connection.js +36 -28
- package/dist/forms/custom-connection.js.map +1 -1
- package/dist/forms/dialog-frame.d.ts +2 -0
- package/dist/forms/dialog-frame.d.ts.map +1 -1
- package/dist/forms/dialog-frame.js +46 -26
- package/dist/forms/dialog-frame.js.map +1 -1
- package/dist/forms/history.d.ts +1 -1
- package/dist/forms/history.d.ts.map +1 -1
- package/dist/forms/history.js +78 -15
- package/dist/forms/history.js.map +1 -1
- package/dist/forms/identity.d.ts +12 -0
- package/dist/forms/identity.d.ts.map +1 -1
- package/dist/forms/identity.js +16 -0
- package/dist/forms/identity.js.map +1 -1
- package/dist/forms/model-editor.d.ts +8 -3
- package/dist/forms/model-editor.d.ts.map +1 -1
- package/dist/forms/model-editor.js +73 -62
- package/dist/forms/model-editor.js.map +1 -1
- package/dist/forms/panels.d.ts +103 -7
- package/dist/forms/panels.d.ts.map +1 -1
- package/dist/forms/panels.js +183 -77
- package/dist/forms/panels.js.map +1 -1
- package/dist/forms/provider-login.d.ts.map +1 -1
- package/dist/forms/provider-login.js +25 -39
- package/dist/forms/provider-login.js.map +1 -1
- package/dist/forms/resource-editor.d.ts +9 -5
- package/dist/forms/resource-editor.d.ts.map +1 -1
- package/dist/forms/resource-editor.js +20 -9
- package/dist/forms/resource-editor.js.map +1 -1
- package/dist/foundations.d.ts +95 -0
- package/dist/foundations.d.ts.map +1 -0
- package/dist/foundations.js +299 -0
- package/dist/foundations.js.map +1 -0
- package/dist/navigation/context-menu.d.ts +8 -1
- package/dist/navigation/context-menu.d.ts.map +1 -1
- package/dist/navigation/context-menu.js +67 -50
- package/dist/navigation/context-menu.js.map +1 -1
- package/dist/navigation/navigation.d.ts +55 -7
- package/dist/navigation/navigation.d.ts.map +1 -1
- package/dist/navigation/navigation.js +167 -18
- package/dist/navigation/navigation.js.map +1 -1
- package/dist/operation.d.ts +12 -0
- package/dist/operation.d.ts.map +1 -0
- package/dist/operation.js +49 -0
- package/dist/operation.js.map +1 -0
- package/dist/primitives.d.ts +11 -1
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +164 -301
- package/dist/primitives.js.map +1 -1
- package/dist/reconcile.d.ts +11 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +36 -0
- package/dist/reconcile.js.map +1 -0
- package/dist/select.d.ts +14 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +304 -0
- package/dist/select.js.map +1 -0
- package/dist/styles.css +452 -382
- package/dist/surface.d.ts +60 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +344 -0
- package/dist/surface.js.map +1 -0
- package/dist/tasks/approval.d.ts.map +1 -1
- package/dist/tasks/approval.js +86 -45
- package/dist/tasks/approval.js.map +1 -1
- package/dist/tasks/permission-element.d.ts +3 -0
- package/dist/tasks/permission-element.d.ts.map +1 -0
- package/dist/tasks/permission-element.js +10 -0
- package/dist/tasks/permission-element.js.map +1 -0
- package/dist/tasks/permission.d.ts +5 -3
- package/dist/tasks/permission.d.ts.map +1 -1
- package/dist/tasks/permission.js +47 -22
- package/dist/tasks/permission.js.map +1 -1
- package/dist/tasks/runtime.d.ts.map +1 -1
- package/dist/tasks/runtime.js +30 -13
- package/dist/tasks/runtime.js.map +1 -1
- package/dist/workspace.d.ts +58 -4
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +202 -44
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../../src/navigation/context-menu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../../src/navigation/context-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOjD,MAAM,UAAU,iBAAiB,CAAC,UAA4H,EAAE;IAC9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AAC;YACH,OAAO,CAAC,IAAI,EAAE,CAAC;YAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAAE,OAAO,CAAC,KAAK,CAAC,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;QAC1G,CAAC,EAAE,OAAO,KAAI,IAAI,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC,EAAC,CAAC;AACjM,CAAC","sourcesContent":["import type { UIBlock } from '../core.js';\nimport { installAnchoredSurface, installMenuNavigation } from '../surface.js';\nimport { adoptProductParts } from '../foundations.js';\nimport { reconcileKeyed } from '../reconcile.js';\nexport interface ContextMenuItem {\n id?: string; label: string; action?: string; sdkAction?: string; danger?: boolean; disabled?: boolean;\n idle?: {conversationId?: string; workspaceId?: string};\n}\nexport interface ContextMenuState {label: string; items: readonly ContextMenuItem[]}\nexport interface ContextMenuOpenOptions {point?: {x: number; y: number}}\nexport function createContextMenu(options: {element?: HTMLElement; onDismiss?: (restoreFocus: boolean) => void; onAction?: (item: ContextMenuItem) => void} = {}): UIBlock<ContextMenuState> & {open(trigger: HTMLElement, state: ContextMenuState, options?: ContextMenuOpenOptions): void; close(restoreFocus?: boolean): void} {\n const element = options.element || document.createElement('div');\n if (!options.element) {element.className = 'pui-sidebar-conversation-menu pui-context-menu'; element.setAttribute('role', 'menu'); element.hidden = true;}\n element.setAttribute('role', 'menu'); element.tabIndex = -1;\n const abort = new AbortController(); let destroyed = false, programmaticClose = false;\n let surface: ReturnType<typeof installAnchoredSurface> | undefined;\n const parts = adoptProductParts(element);\n const rows = new Map<string, HTMLButtonElement>();\n const actions = new Map<HTMLButtonElement, ContextMenuItem>();\n const close = (restoreFocus = false) => {\n programmaticClose = true;\n surface?.close(restoreFocus); surface?.destroy(); surface = undefined;\n element.hidden = true; programmaticClose = false;\n };\n const dismiss = (restoreFocus: boolean) => {close(restoreFocus); options.onDismiss?.(restoreFocus);};\n const navigation = installMenuNavigation(element, {onDismiss: dismiss, isOpen: () => surface?.isOpen() ?? false});\n const update = (state: Readonly<ContextMenuState>) => {\n if (destroyed) return; element.setAttribute('aria-label', state.label);\n const entries = state.items.map((item, index) => ({item, key: item.id ?? `${item.action || ''}/${item.sdkAction || ''}/${index}`}));\n reconcileKeyed(element, rows, entries, {key: entry => entry.key, element: button => button,\n create() {const button = document.createElement('button'); button.type = 'button'; button.setAttribute('role', 'menuitem'); return button;},\n update(button, {item}) {\n parts.action(button).update({label: item.label, disabled: !!item.disabled});\n button.classList.toggle('pui-destructive-menu-item', !!item.danger);\n if (item.action) button.dataset.action = item.action; else delete button.dataset.action;\n if (item.sdkAction) button.dataset.sdk = item.sdkAction; else delete button.dataset.sdk;\n for (const name of ['idleAction', 'idleConversation', 'idleWorkspace']) delete button.dataset[name];\n if (item.idle) {button.dataset.idleAction = ''; if (item.idle.conversationId) button.dataset.idleConversation = item.idle.conversationId; if (item.idle.workspaceId) button.dataset.idleWorkspace = item.idle.workspaceId;}\n actions.set(button, item);\n }, destroy(button) {actions.delete(button);},\n });\n parts.update();\n };\n if (options.onAction) element.addEventListener('click', event => {const button = (event.target as Element).closest<HTMLButtonElement>('button'); const item = button ? actions.get(button) : undefined; if (item && !button!.disabled) {event.stopPropagation();options.onAction!(item);}}, {signal: abort.signal});\n return {element, update, close, open(source, state, anchor = {}) {\n if (destroyed) return;\n close(); update(state); source.focus({preventScroll: true});\n surface = installAnchoredSurface({trigger: source, panel: element, dismissOnMove: true,\n ...(anchor.point ? {getAnchor: () => ({left: anchor.point!.x, right: anchor.point!.x, top: anchor.point!.y, bottom: anchor.point!.y, width: 0, height: 0})} : {}),\n onToggle(open, restoreFocus) {if (!open && !programmaticClose) options.onDismiss?.(!!restoreFocus);},\n });\n surface.open(); navigation.focus();\n if (surface.isOpen() && !element.contains(document.activeElement)) element.focus({preventScroll: true});\n }, destroy() {if (destroyed) return; destroyed = true; close(); navigation.destroy(); abort.abort(); parts.destroy(); rows.clear(); actions.clear(); if (!options.element) element.remove();}};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ActionResult, type UIBlock } from '../core.js';
|
|
2
2
|
export interface NavigationConversation {
|
|
3
3
|
id: string;
|
|
4
4
|
title?: string;
|
|
@@ -20,11 +20,24 @@ export interface WorkspaceNavigationState {
|
|
|
20
20
|
empty: 'workspaces' | 'search' | null;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
}
|
|
23
|
+
export type WorkspaceNavigationAction = {
|
|
24
|
+
action: 'add-workspace';
|
|
25
|
+
trigger: HTMLButtonElement;
|
|
26
|
+
} | {
|
|
27
|
+
action: 'new-conversation' | 'workspace-menu';
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
trigger: HTMLButtonElement;
|
|
30
|
+
} | {
|
|
31
|
+
action: 'conversation-menu';
|
|
32
|
+
conversationId: string;
|
|
33
|
+
trigger: HTMLButtonElement;
|
|
34
|
+
};
|
|
23
35
|
export declare function createWorkspaceNavigation(initial: WorkspaceNavigationState, options?: {
|
|
24
36
|
element?: HTMLElement;
|
|
25
37
|
idPrefix?: string;
|
|
26
38
|
onToggle?: (id: string) => void;
|
|
27
39
|
onSelect?: (id: string) => void;
|
|
40
|
+
onAction?: (action: WorkspaceNavigationAction) => void;
|
|
28
41
|
}): UIBlock<WorkspaceNavigationState>;
|
|
29
42
|
export interface RenameConversationState {
|
|
30
43
|
id: string;
|
|
@@ -32,12 +45,28 @@ export interface RenameConversationState {
|
|
|
32
45
|
error?: string;
|
|
33
46
|
disabled?: boolean;
|
|
34
47
|
}
|
|
35
|
-
export
|
|
48
|
+
export interface RenameConversationDraft {
|
|
49
|
+
id: string;
|
|
50
|
+
title: string;
|
|
51
|
+
}
|
|
52
|
+
export interface RenameConversationOptions {
|
|
36
53
|
idPrefix?: string;
|
|
37
|
-
|
|
54
|
+
dialog?: HTMLDialogElement;
|
|
55
|
+
unavailable?: () => boolean;
|
|
56
|
+
onSubmit?: (draft: RenameConversationDraft) => Promise<ActionResult> | ActionResult;
|
|
57
|
+
onSubmitted?: () => void;
|
|
58
|
+
onCancel?: () => void;
|
|
59
|
+
}
|
|
60
|
+
export interface RenameConversationBlock extends UIBlock<RenameConversationState> {
|
|
38
61
|
readonly input: HTMLInputElement;
|
|
39
62
|
readonly form: HTMLFormElement;
|
|
40
|
-
|
|
63
|
+
read(): RenameConversationDraft;
|
|
64
|
+
reset(state: RenameConversationState): void;
|
|
65
|
+
open(state?: RenameConversationState): void;
|
|
66
|
+
close(): void;
|
|
67
|
+
focus(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare function createRenameConversation(initial: RenameConversationState, options?: RenameConversationOptions): RenameConversationBlock;
|
|
41
70
|
export interface WorkspacePickerState {
|
|
42
71
|
workspaces: readonly {
|
|
43
72
|
id: string;
|
|
@@ -47,11 +76,30 @@ export interface WorkspacePickerState {
|
|
|
47
76
|
error?: string;
|
|
48
77
|
disabled?: boolean;
|
|
49
78
|
}
|
|
50
|
-
export
|
|
79
|
+
export interface WorkspacePickerOptions {
|
|
51
80
|
idPrefix?: string;
|
|
52
|
-
|
|
81
|
+
dialog?: HTMLDialogElement;
|
|
82
|
+
unavailable?: () => boolean;
|
|
83
|
+
onSubmit?: (path: string) => Promise<ActionResult> | ActionResult;
|
|
84
|
+
onPick?: () => Promise<{
|
|
85
|
+
path?: string;
|
|
86
|
+
error?: string;
|
|
87
|
+
}>;
|
|
88
|
+
onSelect?: (id: string) => void;
|
|
89
|
+
onSubmitted?: () => void;
|
|
90
|
+
onCancel?: () => void;
|
|
91
|
+
}
|
|
92
|
+
export interface WorkspacePickerBlock extends UIBlock<WorkspacePickerState> {
|
|
53
93
|
readonly input: HTMLInputElement;
|
|
54
94
|
readonly form: HTMLFormElement;
|
|
55
95
|
readonly pickButton: HTMLButtonElement;
|
|
56
|
-
|
|
96
|
+
read(): {
|
|
97
|
+
path: string;
|
|
98
|
+
};
|
|
99
|
+
reset(path?: string): void;
|
|
100
|
+
open(): void;
|
|
101
|
+
close(): void;
|
|
102
|
+
focus(): void;
|
|
103
|
+
}
|
|
104
|
+
export declare function createWorkspacePicker(initial: WorkspacePickerState, options?: WorkspacePickerOptions): WorkspacePickerBlock;
|
|
57
105
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/navigation/navigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/navigation/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAMvE,MAAM,WAAW,sBAAsB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAC;AAC/H,MAAM,WAAW,mBAAmB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;I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IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAClE,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AACD,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,oBAAoB,CAAC;IACzE,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,IAAI,IAAI;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC;IACvB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf;AACD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,GAAE,sBAA2B,GAAG,oBAAoB,CAyD/H"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { scopeIds } from '../forms/identity.js';
|
|
2
|
+
import { Lifetime } from '../core.js';
|
|
2
3
|
import { dialogHeading, escape, icon, uniqueId } from '../dom.js';
|
|
4
|
+
import { adoptProductParts } from '../foundations.js';
|
|
5
|
+
import { installDialogLifecycle } from '../surface.js';
|
|
6
|
+
import { createOperation } from '../operation.js';
|
|
7
|
+
import { reconcileKeyed } from '../reconcile.js';
|
|
3
8
|
export function createWorkspaceNavigation(initial, options = {}) {
|
|
4
9
|
const element = options.element || document.createElement('nav');
|
|
5
10
|
if (!options.element) {
|
|
@@ -9,6 +14,7 @@ export function createWorkspaceNavigation(initial, options = {}) {
|
|
|
9
14
|
const prefix = options.idPrefix ?? uniqueId('pui-nav') + '-';
|
|
10
15
|
const abort = new AbortController();
|
|
11
16
|
let destroyed = false;
|
|
17
|
+
const parts = adoptProductParts(element);
|
|
12
18
|
const workspaces = new Map();
|
|
13
19
|
const conversations = new Map();
|
|
14
20
|
const emptyWorkspace = document.createElement('button');
|
|
@@ -68,10 +74,10 @@ export function createWorkspaceNavigation(initial, options = {}) {
|
|
|
68
74
|
group.more.dataset.workspaceMenu = workspace.id;
|
|
69
75
|
group.more.setAttribute('aria-label', 'Actions for workspace ' + workspace.name);
|
|
70
76
|
group.more.setAttribute('aria-expanded', String(!!workspace.menuOpen));
|
|
71
|
-
group.more.disabled
|
|
77
|
+
parts.action(group.more).update({ disabled: !!state.disabled });
|
|
72
78
|
group.create.dataset.newWorkspace = workspace.id;
|
|
73
79
|
group.create.setAttribute('aria-label', 'New conversation in ' + workspace.name);
|
|
74
|
-
group.create.disabled
|
|
80
|
+
parts.action(group.create).update({ disabled: !!state.disabled });
|
|
75
81
|
group.children.id = prefix + 'workspace-children-' + workspace.id;
|
|
76
82
|
group.children.hidden = !workspace.expanded;
|
|
77
83
|
let rowCursor = group.children.firstElementChild;
|
|
@@ -85,8 +91,7 @@ export function createWorkspaceNavigation(initial, options = {}) {
|
|
|
85
91
|
const title = entry.title || 'Untitled conversation';
|
|
86
92
|
row.element.classList.toggle('pui-active', entry.active);
|
|
87
93
|
row.button.dataset.conversation = entry.id;
|
|
88
|
-
row.button.title
|
|
89
|
-
row.button.disabled = !!state.disabled;
|
|
94
|
+
parts.action(row.button).update({ title, disabled: !!state.disabled });
|
|
90
95
|
if (entry.active)
|
|
91
96
|
row.button.setAttribute('aria-current', 'page');
|
|
92
97
|
else
|
|
@@ -97,7 +102,7 @@ export function createWorkspaceNavigation(initial, options = {}) {
|
|
|
97
102
|
row.more.dataset.conversationMenu = entry.id;
|
|
98
103
|
row.more.setAttribute('aria-label', 'Actions for ' + title);
|
|
99
104
|
row.more.setAttribute('aria-expanded', String(!!entry.menuOpen));
|
|
100
|
-
row.more.disabled
|
|
105
|
+
parts.action(row.more).update({ disabled: !!state.disabled });
|
|
101
106
|
const signature = entry.status === row.statusSource && entry.status instanceof DocumentFragment && entry.status.childNodes.length === 0 ? row.statusSignature : statusSignature(entry.status);
|
|
102
107
|
row.statusSource = entry.status;
|
|
103
108
|
if (signature !== row.statusSignature) {
|
|
@@ -137,20 +142,41 @@ export function createWorkspaceNavigation(initial, options = {}) {
|
|
|
137
142
|
}
|
|
138
143
|
else
|
|
139
144
|
emptyWorkspace.remove();
|
|
145
|
+
parts.action(emptyWorkspace).update({ disabled: !!state.disabled });
|
|
140
146
|
if (state.empty === 'search') {
|
|
141
147
|
if (emptySearch.parentElement !== element)
|
|
142
148
|
element.append(emptySearch);
|
|
143
149
|
}
|
|
144
150
|
else
|
|
145
151
|
emptySearch.remove();
|
|
152
|
+
parts.update();
|
|
146
153
|
};
|
|
147
|
-
element.addEventListener('click', event => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
element.addEventListener('click', event => {
|
|
155
|
+
const target = event.target.closest('button');
|
|
156
|
+
if (!target || target.disabled)
|
|
157
|
+
return;
|
|
158
|
+
if (target.dataset.toggleWorkspace && options.onToggle) {
|
|
159
|
+
event.stopPropagation();
|
|
160
|
+
options.onToggle(target.dataset.toggleWorkspace);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (target.dataset.conversation && options.onSelect) {
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
options.onSelect(target.dataset.conversation);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const action = target === emptyWorkspace ? { action: 'add-workspace', trigger: target }
|
|
169
|
+
: target.dataset.newWorkspace ? { action: 'new-conversation', workspaceId: target.dataset.newWorkspace, trigger: target }
|
|
170
|
+
: target.dataset.workspaceMenu ? { action: 'workspace-menu', workspaceId: target.dataset.workspaceMenu, trigger: target }
|
|
171
|
+
: target.dataset.conversationMenu ? { action: 'conversation-menu', conversationId: target.dataset.conversationMenu, trigger: target } : undefined;
|
|
172
|
+
if (action && options.onAction) {
|
|
173
|
+
event.stopPropagation();
|
|
174
|
+
options.onAction(action);
|
|
175
|
+
}
|
|
176
|
+
}, { signal: abort.signal });
|
|
151
177
|
update(initial);
|
|
152
178
|
return { element, update, destroy() { if (destroyed)
|
|
153
|
-
return; destroyed = true; abort.abort(); workspaces.clear(); conversations.clear(); if (!options.element)
|
|
179
|
+
return; destroyed = true; abort.abort(); parts.destroy(); workspaces.clear(); conversations.clear(); if (!options.element)
|
|
154
180
|
element.remove(); } };
|
|
155
181
|
}
|
|
156
182
|
export function createRenameConversation(initial, options = {}) {
|
|
@@ -161,11 +187,51 @@ export function createRenameConversation(initial, options = {}) {
|
|
|
161
187
|
const input = element.querySelector('#conversation-title');
|
|
162
188
|
const form = element.querySelector('#rename-form');
|
|
163
189
|
const error = element.querySelector('#rename-error');
|
|
164
|
-
const update = (state) => { if (state.error !== undefined)
|
|
165
|
-
error.textContent = state.error; const button = form.querySelector('button[type="submit"]'); button.disabled = !!state.disabled; };
|
|
166
|
-
update(initial);
|
|
167
190
|
scopeIds(element, options.idPrefix ?? uniqueId('pui-rename') + '-');
|
|
168
|
-
|
|
191
|
+
const parts = adoptProductParts(element);
|
|
192
|
+
const control = parts.control(input);
|
|
193
|
+
const feedback = parts.feedback(error);
|
|
194
|
+
const button = form.querySelector('button[type="submit"]');
|
|
195
|
+
const action = parts.action(button);
|
|
196
|
+
const life = new Lifetime();
|
|
197
|
+
let current = initial;
|
|
198
|
+
let targetId = initial.id;
|
|
199
|
+
let destroyed = false;
|
|
200
|
+
const sync = () => { action.update({ disabled: !!current.disabled || !!options.unavailable?.(), pending: operation.pending }); feedback.update({ message: current.error || '', tone: 'error' }); };
|
|
201
|
+
const operation = createOperation({ unavailable: () => destroyed || !!current.disabled || !!options.unavailable?.(), onPending: sync, onError(message) { current = { ...current, error: message }; sync(); } });
|
|
202
|
+
const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, { onOpen() { operation.invalidate(); }, onClose() { operation.invalidate(); } }) : undefined;
|
|
203
|
+
const update = (next) => { if (destroyed)
|
|
204
|
+
return; current = { ...next, error: next.error ?? current.error }; sync(); };
|
|
205
|
+
const reset = (next) => { if (destroyed)
|
|
206
|
+
return; operation.invalidate(); targetId = next.id; current = next; control.reset(next.title); button.dataset.idleConversation = next.id; sync(); };
|
|
207
|
+
const close = () => { operation.invalidate(); lifecycle?.close(); };
|
|
208
|
+
if (options.onSubmit)
|
|
209
|
+
life.listen(form, 'submit', (event => {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
const title = control.getValue().trim();
|
|
212
|
+
if (!title)
|
|
213
|
+
return;
|
|
214
|
+
operation.run(() => { current = { ...current, error: '' }; sync(); return options.onSubmit({ id: targetId, title }); }, result => {
|
|
215
|
+
if (options.dialog && !options.dialog.open)
|
|
216
|
+
return;
|
|
217
|
+
if (result.ok) {
|
|
218
|
+
lifecycle?.close();
|
|
219
|
+
options.onSubmitted?.();
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
current = { ...current, error: result.error };
|
|
223
|
+
sync();
|
|
224
|
+
});
|
|
225
|
+
}));
|
|
226
|
+
life.listen(element, 'click', (event => { if (event.target.closest('[data-close]')) {
|
|
227
|
+
operation.invalidate();
|
|
228
|
+
options.onCancel?.();
|
|
229
|
+
lifecycle?.close();
|
|
230
|
+
} }));
|
|
231
|
+
update(initial);
|
|
232
|
+
return { element, input, form, update, read: () => ({ id: targetId, title: control.getValue() }), reset, open(next) { if (next)
|
|
233
|
+
reset(next); lifecycle?.open(); input.select(); }, close, focus() { input.select(); }, destroy() { if (destroyed)
|
|
234
|
+
return; destroyed = true; operation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove(); } };
|
|
169
235
|
}
|
|
170
236
|
export function createWorkspacePicker(initial, options = {}) {
|
|
171
237
|
const state = initial;
|
|
@@ -176,10 +242,93 @@ export function createWorkspacePicker(initial, options = {}) {
|
|
|
176
242
|
const form = element.querySelector('#workspace-form');
|
|
177
243
|
const pickButton = element.querySelector('#pick-folder');
|
|
178
244
|
const error = element.querySelector('#workspace-error');
|
|
179
|
-
const update = (state) => { if (state.error !== undefined)
|
|
180
|
-
error.textContent = state.error; const button = form.querySelector('button[type="submit"]'); button.disabled = !!state.disabled; };
|
|
181
|
-
update(initial);
|
|
182
245
|
scopeIds(element, options.idPrefix ?? uniqueId('pui-workspace') + '-');
|
|
183
|
-
|
|
246
|
+
const list = element.querySelector('.pui-modal-workspaces');
|
|
247
|
+
const rows = new Map([...list.querySelectorAll('[data-modal-workspace]')].map(row => [row.dataset.modalWorkspace, row]));
|
|
248
|
+
const parts = adoptProductParts(element);
|
|
249
|
+
const control = parts.control(input);
|
|
250
|
+
const feedback = parts.feedback(error);
|
|
251
|
+
const submitButton = form.querySelector('button[type="submit"]');
|
|
252
|
+
const life = new Lifetime();
|
|
253
|
+
let current = initial;
|
|
254
|
+
let destroyed = false;
|
|
255
|
+
const unavailable = () => destroyed || !!current.disabled || !!options.unavailable?.();
|
|
256
|
+
const sync = () => { const disabled = unavailable(), pending = pickOperation.pending || submitOperation.pending; parts.action(submitButton).update({ disabled, pending }); parts.action(pickButton).update({ disabled, pending }); for (const row of rows.values())
|
|
257
|
+
parts.action(row).update({ disabled: disabled || pending }); feedback.update({ message: current.error || '', tone: 'error' }); };
|
|
258
|
+
const fail = (message) => { current = { ...current, error: message }; sync(); };
|
|
259
|
+
const pickOperation = createOperation({ unavailable: () => unavailable() || submitOperation.pending, onPending: sync, onError(message) { fail(`${message} You can enter the path below.`); control.focus(); } });
|
|
260
|
+
const submitOperation = createOperation({ unavailable: () => unavailable() || pickOperation.pending, onPending: sync, onError: fail });
|
|
261
|
+
const invalidate = () => { pickOperation.invalidate(); submitOperation.invalidate(); };
|
|
262
|
+
const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, { onOpen: invalidate, onClose: invalidate }) : undefined;
|
|
263
|
+
const update = (next) => {
|
|
264
|
+
if (destroyed)
|
|
265
|
+
return;
|
|
266
|
+
current = { ...next, error: next.error ?? current.error };
|
|
267
|
+
reconcileKeyed(list, rows, next.workspaces, { key: entry => entry.id, element: row => row,
|
|
268
|
+
create(entry) { const row = document.createElement('button'); row.type = 'button'; row.className = 'pui-modal-workspace'; row.dataset.modalWorkspace = entry.id; row.innerHTML = `${icon('folder')}<span><strong></strong><small></small></span>${icon('chevron')}`; return row; },
|
|
269
|
+
update(row, entry) {
|
|
270
|
+
const name = row.querySelector('strong');
|
|
271
|
+
const path = row.querySelector('small');
|
|
272
|
+
if (name.textContent !== entry.name)
|
|
273
|
+
name.textContent = entry.name;
|
|
274
|
+
if (path.textContent !== entry.path)
|
|
275
|
+
path.textContent = entry.path;
|
|
276
|
+
}, destroy() { }, });
|
|
277
|
+
parts.update();
|
|
278
|
+
sync();
|
|
279
|
+
};
|
|
280
|
+
const submit = (path) => {
|
|
281
|
+
if (!options.onSubmit || !path.trim())
|
|
282
|
+
return;
|
|
283
|
+
submitOperation.run(() => { current = { ...current, error: '' }; sync(); return options.onSubmit(path.trim()); }, result => {
|
|
284
|
+
if (options.dialog && !options.dialog.open)
|
|
285
|
+
return;
|
|
286
|
+
if (result.ok) {
|
|
287
|
+
lifecycle?.close();
|
|
288
|
+
options.onSubmitted?.();
|
|
289
|
+
}
|
|
290
|
+
else
|
|
291
|
+
current = { ...current, error: result.error };
|
|
292
|
+
sync();
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
if (options.onSubmit)
|
|
296
|
+
life.listen(form, 'submit', (event => { event.preventDefault(); void submit(control.getValue()); }));
|
|
297
|
+
if (options.onPick)
|
|
298
|
+
life.listen(pickButton, 'click', (() => {
|
|
299
|
+
pickOperation.run(() => { current = { ...current, error: '' }; sync(); return options.onPick(); }, result => {
|
|
300
|
+
// End the picker ownership before handing a valid path to submission.
|
|
301
|
+
// A newly disabled target can refuse the write without retaining pending.
|
|
302
|
+
pickOperation.invalidate();
|
|
303
|
+
if (options.dialog && !options.dialog.open)
|
|
304
|
+
return;
|
|
305
|
+
if (result.error) {
|
|
306
|
+
fail(result.error);
|
|
307
|
+
control.focus();
|
|
308
|
+
}
|
|
309
|
+
else if (result.path) {
|
|
310
|
+
control.reset(result.path);
|
|
311
|
+
submit(result.path);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}));
|
|
315
|
+
life.listen(element, 'click', (event => {
|
|
316
|
+
const target = event.target;
|
|
317
|
+
const selection = target.closest('[data-modal-workspace]');
|
|
318
|
+
if (selection && options.onSelect) {
|
|
319
|
+
event.stopPropagation();
|
|
320
|
+
if (!pickOperation.pending && !submitOperation.pending && !unavailable())
|
|
321
|
+
options.onSelect(selection.dataset.modalWorkspace);
|
|
322
|
+
}
|
|
323
|
+
if (target.closest('[data-close]')) {
|
|
324
|
+
invalidate();
|
|
325
|
+
options.onCancel?.();
|
|
326
|
+
lifecycle?.close();
|
|
327
|
+
}
|
|
328
|
+
}));
|
|
329
|
+
update(initial);
|
|
330
|
+
return { element, input, form, pickButton, update, read: () => ({ path: control.getValue() }), reset(path = '') { if (destroyed)
|
|
331
|
+
return; invalidate(); current = { ...current, error: '' }; control.reset(path); sync(); }, open() { lifecycle?.open(); }, close() { invalidate(); lifecycle?.close(); }, focus: control.focus, destroy() { if (destroyed)
|
|
332
|
+
return; destroyed = true; pickOperation.destroy(); submitOperation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove(); } };
|
|
184
333
|
}
|
|
185
334
|
//# sourceMappingURL=navigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/navigation/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,aAA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AAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC,CAAC;IACzU,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,KAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC,EAAC,CAAC;AAClF,CAAC","sourcesContent":["import {scopeIds} from '../forms/identity.js';\nimport type { UIBlock } from '../core.js';\nimport {dialogHeading, escape, icon, uniqueId} from '../dom.js';\nexport interface NavigationConversation {id: string; title?: string; active: boolean; menuOpen?: boolean; status?: Node | null}\nexport interface NavigationWorkspace {id: string; name: string; path: string; expanded: boolean; selected: boolean; menuOpen?: boolean; children: readonly NavigationConversation[]}\nexport interface WorkspaceNavigationState {groups: readonly NavigationWorkspace[]; empty: 'workspaces' | 'search' | null; disabled?: boolean}\ntype ConversationDOM = {element: HTMLElement; button: HTMLButtonElement; title: HTMLElement; more: HTMLButtonElement; status: Node[]; statusSignature: string; statusSource?: Node | null};\ntype WorkspaceDOM = {element: HTMLElement; heading: HTMLElement; toggle: HTMLButtonElement; title: HTMLElement; more: HTMLButtonElement; create: HTMLButtonElement; children: HTMLElement; empty: HTMLElement};\nexport function createWorkspaceNavigation(initial: WorkspaceNavigationState, options: {element?: HTMLElement; idPrefix?: string; onToggle?: (id: string) => void; onSelect?: (id: string) => void} = {}): UIBlock<WorkspaceNavigationState> {\n const element = options.element || document.createElement('nav');\n if (!options.element) {element.className = 'pui-history-list pui-workspace-navigation'; element.setAttribute('aria-label', 'Workspaces and conversations');}\n const prefix = options.idPrefix ?? uniqueId('pui-nav') + '-';\n const abort = new AbortController(); let destroyed = false;\n const workspaces = new Map<string, WorkspaceDOM>(); const conversations = new Map<string, ConversationDOM>();\n const emptyWorkspace = document.createElement('button'); emptyWorkspace.type = 'button'; emptyWorkspace.className = 'pui-workspace-item pui-empty-workspace'; emptyWorkspace.dataset.action = 'workspace'; emptyWorkspace.innerHTML = `${icon('folder')}<span>Add a workspace</span>`;\n const emptySearch = document.createElement('p'); emptySearch.className = 'pui-history-empty'; emptySearch.textContent = 'No matching conversations.';\n function createWorkspace(): WorkspaceDOM {\n const root = document.createElement('section'); root.className = 'pui-workspace-group';\n root.innerHTML = `<div class=\"pui-workspace-heading\"><button class=\"pui-workspace-toggle\">${icon('chevron', 'pui-workspace-chevron')}${icon('folder')}<span></span></button><button class=\"pui-quiet-icon pui-workspace-more\" aria-haspopup=\"menu\">${icon('more')}</button><button class=\"pui-quiet-icon pui-workspace-new\" title=\"New conversation\">${icon('compose')}</button></div><div class=\"pui-workspace-children\"></div>`;\n const buttons = root.querySelectorAll<HTMLButtonElement>('button'); const empty = document.createElement('p'); empty.className = 'pui-workspace-empty'; empty.textContent = 'No conversations yet';\n return {element:root,heading:root.firstElementChild as HTMLElement,toggle:buttons[0],title:buttons[0].querySelector('span')!,more:buttons[1],create:buttons[2],children:root.lastElementChild as HTMLElement,empty};\n }\n function createConversation(): ConversationDOM {\n const root = document.createElement('div'); root.className = 'pui-history-row';\n root.innerHTML = `<button class=\"pui-history-item\"><span></span></button><button class=\"pui-quiet-icon pui-history-more\" aria-haspopup=\"menu\">${icon('more')}</button>`;\n const buttons = root.querySelectorAll<HTMLButtonElement>('button'); return {element:root,button:buttons[0],title:buttons[0].querySelector('span')!,more:buttons[1],status:[],statusSignature:''};\n }\n function statusSignature(node?: Node | null): string {\n if (!node) return ''; const holder = document.createElement('div'); holder.append(node.cloneNode(true)); return holder.innerHTML;\n }\n const update = (state: Readonly<WorkspaceNavigationState>) => {\n if (destroyed) return; const currentWorkspaces = new Set<string>(); const currentConversations = new Set<string>(); let groupCursor: Element | null = element.firstElementChild;\n for (const workspace of state.groups) {\n currentWorkspaces.add(workspace.id); let group = workspaces.get(workspace.id); if (!group) {group = createWorkspace(); workspaces.set(workspace.id,group);}\n group.element.setAttribute('aria-label',workspace.name); group.heading.classList.toggle('pui-selected',workspace.selected);\n group.toggle.dataset.toggleWorkspace = workspace.id; group.toggle.setAttribute('aria-expanded',String(workspace.expanded)); group.toggle.setAttribute('aria-controls',prefix+'workspace-children-'+workspace.id); group.toggle.title = workspace.path;\n if (group.title.textContent !== workspace.name) group.title.textContent = workspace.name;\n group.more.id = prefix+'workspace-actions-'+workspace.id; group.more.dataset.workspaceMenu = workspace.id; group.more.setAttribute('aria-label','Actions for workspace '+workspace.name); group.more.setAttribute('aria-expanded',String(!!workspace.menuOpen)); group.more.disabled = !!state.disabled;\n group.create.dataset.newWorkspace = workspace.id; group.create.setAttribute('aria-label','New conversation in '+workspace.name); group.create.disabled = !!state.disabled;\n group.children.id = prefix+'workspace-children-'+workspace.id; group.children.hidden = !workspace.expanded; let rowCursor: Element | null = group.children.firstElementChild;\n for (const entry of workspace.children) {\n currentConversations.add(entry.id); let row = conversations.get(entry.id); if (!row) {row = createConversation(); conversations.set(entry.id,row);}\n const title = entry.title || 'Untitled conversation'; row.element.classList.toggle('pui-active',entry.active); row.button.dataset.conversation = entry.id; row.button.title = title; row.button.disabled = !!state.disabled;\n if (entry.active) row.button.setAttribute('aria-current','page'); else row.button.removeAttribute('aria-current'); if (row.title.textContent !== title) row.title.textContent = title;\n row.more.id = prefix+'conversation-actions-'+entry.id; row.more.dataset.conversationMenu = entry.id; row.more.setAttribute('aria-label','Actions for '+title); row.more.setAttribute('aria-expanded',String(!!entry.menuOpen)); row.more.disabled = !!state.disabled;\n const signature = entry.status === row.statusSource && entry.status instanceof DocumentFragment && entry.status.childNodes.length === 0 ? row.statusSignature : statusSignature(entry.status);\n row.statusSource = entry.status;\n if (signature !== row.statusSignature) {for (const node of row.status) node.parentNode?.removeChild(node); row.status = entry.status ? entry.status instanceof DocumentFragment ? [...entry.status.childNodes] : [entry.status] : []; row.button.append(...row.status); row.statusSignature = signature;}\n if (row.element !== rowCursor) group.children.insertBefore(row.element,rowCursor); rowCursor = row.element.nextElementSibling;\n }\n if (!workspace.children.length) {if (group.empty.parentElement !== group.children) group.children.append(group.empty);} else group.empty.remove();\n if (group.element !== groupCursor) element.insertBefore(group.element,groupCursor); groupCursor = group.element.nextElementSibling;\n }\n for (const [id,row] of conversations) if (!currentConversations.has(id)) {row.element.remove(); conversations.delete(id);}\n for (const [id,group] of workspaces) if (!currentWorkspaces.has(id)) {group.element.remove(); workspaces.delete(id);}\n if (state.empty === 'workspaces') {if (emptyWorkspace.parentElement !== element) element.append(emptyWorkspace);} else emptyWorkspace.remove();\n if (state.empty === 'search') {if (emptySearch.parentElement !== element) element.append(emptySearch);} else emptySearch.remove();\n };\n element.addEventListener('click',event => {const target = (event.target as HTMLElement).closest<HTMLButtonElement>('button'); if (target?.disabled) return; if (target?.dataset.toggleWorkspace) options.onToggle?.(target.dataset.toggleWorkspace); if (target?.dataset.conversation) options.onSelect?.(target.dataset.conversation);},{signal:abort.signal});\n update(initial); return {element,update,destroy() {if (destroyed) return; destroyed = true; abort.abort(); workspaces.clear(); conversations.clear(); if (!options.element) element.remove();}};\n}\nexport interface RenameConversationState {id: string; title: string; error?: string; disabled?: boolean}\nexport function createRenameConversation(initial: RenameConversationState, options: {idPrefix?: string} = {}): UIBlock<RenameConversationState> & {readonly input: HTMLInputElement; readonly form: HTMLFormElement} {\n const state = initial; const element = document.createElement('div'); element.className = 'pui-rename-conversation'; element.innerHTML = `${dialogHeading('Rename conversation', 'rename-title', 'rename-dialog', 'CONVERSATION')}<form id=\"rename-form\"><label class=\"pui-field-label\" for=\"conversation-title\">Title</label><input id=\"conversation-title\" name=\"title\" value=\"${escape(state.title)}\" required autocomplete=\"off\" /><div id=\"rename-error\" class=\"pui-form-error\" role=\"alert\"></div><div class=\"pui-modal-footer\"><button type=\"button\" class=\"pui-secondary-button\" data-close=\"rename-dialog\">Cancel</button><button type=\"submit\" class=\"pui-primary-button\" data-idle-action data-idle-conversation=\"${escape(state.id)}\">Save title</button></div></form>`;\n const input = element.querySelector<HTMLInputElement>('#conversation-title')!; const form = element.querySelector<HTMLFormElement>('#rename-form')!; const error = element.querySelector<HTMLElement>('#rename-error')!;\n const update = (state: Readonly<RenameConversationState>) => {if (state.error !== undefined) error.textContent = state.error; const button = form.querySelector<HTMLButtonElement>('button[type=\"submit\"]')!; button.disabled = !!state.disabled;}; update(initial); scopeIds(element, options.idPrefix ?? uniqueId('pui-rename') + '-');\n return {element, input, form, update, destroy() {element.remove();}};\n}\nexport interface WorkspacePickerState {workspaces: readonly {id: string; name: string; path: string}[]; error?: string; disabled?: boolean}\nexport function createWorkspacePicker(initial: WorkspacePickerState, options: {idPrefix?: string} = {}): UIBlock<WorkspacePickerState> & {readonly input: HTMLInputElement; readonly form: HTMLFormElement; readonly pickButton: HTMLButtonElement} {\n const state = initial; const element = document.createElement('div'); element.className = 'pui-workspace-picker'; element.innerHTML = `${dialogHeading('Workspaces', 'workspace-title', 'workspace-dialog', 'A PLACE TO WORK')}<p class=\"pui-modal-description\">Choose a local folder. Conversations belong to a workspace, so Pith knows where to read and create files.</p><div class=\"pui-modal-workspaces\">${state.workspaces.map((entry) => `<button class=\"pui-modal-workspace\" data-modal-workspace=\"${escape(entry.id)}\">${icon('folder')}<span><strong>${escape(entry.name)}</strong><small>${escape(entry.path)}</small></span>${icon('chevron')}</button>`).join('')}</div><div class=\"pui-workspace-add\"><button class=\"pui-picker-button\" id=\"pick-folder\" type=\"button\">${icon('folder')}Choose a folder…</button><div class=\"pui-path-divider\"><span>or enter a folder path</span></div><form id=\"workspace-form\"><label class=\"pui-sr-only\" for=\"workspace-path\">Absolute folder path</label><input id=\"workspace-path\" name=\"path\" placeholder=\"/Users/you/Documents/my-work\" required autocomplete=\"off\" spellcheck=\"false\" /><p class=\"pui-field-hint\">Use an existing folder on this computer. Pith will work inside it.</p><div id=\"workspace-error\" class=\"pui-form-error\" role=\"alert\"></div><div class=\"pui-modal-footer\"><button class=\"pui-secondary-button\" type=\"button\" data-close=\"workspace-dialog\">Cancel</button><button class=\"pui-primary-button\" id=\"add-workspace\" type=\"submit\">Add workspace</button></div></form></div>`;\n const input = element.querySelector<HTMLInputElement>('#workspace-path')!; const form = element.querySelector<HTMLFormElement>('#workspace-form')!; const pickButton = element.querySelector<HTMLButtonElement>('#pick-folder')!; const error = element.querySelector<HTMLElement>('#workspace-error')!;\n const update = (state: Readonly<WorkspacePickerState>) => {if (state.error !== undefined) error.textContent = state.error; const button = form.querySelector<HTMLButtonElement>('button[type=\"submit\"]')!; button.disabled = !!state.disabled;}; update(initial); scopeIds(element, options.idPrefix ?? uniqueId('pui-workspace') + '-');\n return {element, input, form, pickButton, update, destroy() {element.remove();}};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/navigation/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAmC,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUjD,MAAM,UAAU,yBAAyB,CAAC,OAAiC,EAAE,UAAgL,EAAE;IAC7P,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAAA,OAAO,CAAC,SAAS,GAAG,2CAA2C,CAAC;QAAC,OAAO,CAAC,YAAY,CAAC,YAAY,EAAE,8BAA8B,CAAC,CAAC;IAAA,CAAC;IAC5J,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;IAC7D,MAAM,KAA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S,EAAE,IAAI,EAAE,CAAC,CAAA,CAAC,EAAE,KAAK,KAAI,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,KAAI,IAAI,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC,EAAC,CAAC;AAC7f,CAAC","sourcesContent":["import {scopeIds} from '../forms/identity.js';\nimport { Lifetime, type ActionResult, type UIBlock } from '../core.js';\nimport {dialogHeading, escape, icon, uniqueId} from '../dom.js';\nimport { adoptProductParts } from '../foundations.js';\nimport { installDialogLifecycle } from '../surface.js';\nimport { createOperation } from '../operation.js';\nimport { reconcileKeyed } from '../reconcile.js';\nexport interface NavigationConversation {id: string; title?: string; active: boolean; menuOpen?: boolean; status?: Node | null}\nexport interface NavigationWorkspace {id: string; name: string; path: string; expanded: boolean; selected: boolean; menuOpen?: boolean; children: readonly NavigationConversation[]}\nexport interface WorkspaceNavigationState {groups: readonly NavigationWorkspace[]; empty: 'workspaces' | 'search' | null; disabled?: boolean}\nexport type WorkspaceNavigationAction =\n | {action: 'add-workspace'; trigger: HTMLButtonElement}\n | {action: 'new-conversation' | 'workspace-menu'; workspaceId: string; trigger: HTMLButtonElement}\n | {action: 'conversation-menu'; conversationId: string; trigger: HTMLButtonElement};\ntype ConversationDOM = {element: HTMLElement; button: HTMLButtonElement; title: HTMLElement; more: HTMLButtonElement; status: Node[]; statusSignature: string; statusSource?: Node | null};\ntype WorkspaceDOM = {element: HTMLElement; heading: HTMLElement; toggle: HTMLButtonElement; title: HTMLElement; more: HTMLButtonElement; create: HTMLButtonElement; children: HTMLElement; empty: HTMLElement};\nexport function createWorkspaceNavigation(initial: WorkspaceNavigationState, options: {element?: HTMLElement; idPrefix?: string; onToggle?: (id: string) => void; onSelect?: (id: string) => void; onAction?: (action: WorkspaceNavigationAction) => void} = {}): UIBlock<WorkspaceNavigationState> {\n const element = options.element || document.createElement('nav');\n if (!options.element) {element.className = 'pui-history-list pui-workspace-navigation'; element.setAttribute('aria-label', 'Workspaces and conversations');}\n const prefix = options.idPrefix ?? uniqueId('pui-nav') + '-';\n const abort = new AbortController(); let destroyed = false;\n const parts = adoptProductParts(element);\n const workspaces = new Map<string, WorkspaceDOM>(); const conversations = new Map<string, ConversationDOM>();\n const emptyWorkspace = document.createElement('button'); emptyWorkspace.type = 'button'; emptyWorkspace.className = 'pui-workspace-item pui-empty-workspace'; emptyWorkspace.dataset.action = 'workspace'; emptyWorkspace.innerHTML = `${icon('folder')}<span>Add a workspace</span>`;\n const emptySearch = document.createElement('p'); emptySearch.className = 'pui-history-empty'; emptySearch.textContent = 'No matching conversations.';\n function createWorkspace(): WorkspaceDOM {\n const root = document.createElement('section'); root.className = 'pui-workspace-group';\n root.innerHTML = `<div class=\"pui-workspace-heading\"><button class=\"pui-workspace-toggle\">${icon('chevron', 'pui-workspace-chevron')}${icon('folder')}<span></span></button><button class=\"pui-quiet-icon pui-workspace-more\" aria-haspopup=\"menu\">${icon('more')}</button><button class=\"pui-quiet-icon pui-workspace-new\" title=\"New conversation\">${icon('compose')}</button></div><div class=\"pui-workspace-children\"></div>`;\n const buttons = root.querySelectorAll<HTMLButtonElement>('button'); const empty = document.createElement('p'); empty.className = 'pui-workspace-empty'; empty.textContent = 'No conversations yet';\n return {element:root,heading:root.firstElementChild as HTMLElement,toggle:buttons[0],title:buttons[0].querySelector('span')!,more:buttons[1],create:buttons[2],children:root.lastElementChild as HTMLElement,empty};\n }\n function createConversation(): ConversationDOM {\n const root = document.createElement('div'); root.className = 'pui-history-row';\n root.innerHTML = `<button class=\"pui-history-item\"><span></span></button><button class=\"pui-quiet-icon pui-history-more\" aria-haspopup=\"menu\">${icon('more')}</button>`;\n const buttons = root.querySelectorAll<HTMLButtonElement>('button'); return {element:root,button:buttons[0],title:buttons[0].querySelector('span')!,more:buttons[1],status:[],statusSignature:''};\n }\n function statusSignature(node?: Node | null): string {\n if (!node) return ''; const holder = document.createElement('div'); holder.append(node.cloneNode(true)); return holder.innerHTML;\n }\n const update = (state: Readonly<WorkspaceNavigationState>) => {\n if (destroyed) return; const currentWorkspaces = new Set<string>(); const currentConversations = new Set<string>(); let groupCursor: Element | null = element.firstElementChild;\n for (const workspace of state.groups) {\n currentWorkspaces.add(workspace.id); let group = workspaces.get(workspace.id); if (!group) {group = createWorkspace(); workspaces.set(workspace.id,group);}\n group.element.setAttribute('aria-label',workspace.name); group.heading.classList.toggle('pui-selected',workspace.selected);\n group.toggle.dataset.toggleWorkspace = workspace.id; group.toggle.setAttribute('aria-expanded',String(workspace.expanded)); group.toggle.setAttribute('aria-controls',prefix+'workspace-children-'+workspace.id); group.toggle.title = workspace.path;\n if (group.title.textContent !== workspace.name) group.title.textContent = workspace.name;\n group.more.id = prefix+'workspace-actions-'+workspace.id; group.more.dataset.workspaceMenu = workspace.id; group.more.setAttribute('aria-label','Actions for workspace '+workspace.name); group.more.setAttribute('aria-expanded',String(!!workspace.menuOpen)); parts.action(group.more).update({disabled: !!state.disabled});\n group.create.dataset.newWorkspace = workspace.id; group.create.setAttribute('aria-label','New conversation in '+workspace.name); parts.action(group.create).update({disabled: !!state.disabled});\n group.children.id = prefix+'workspace-children-'+workspace.id; group.children.hidden = !workspace.expanded; let rowCursor: Element | null = group.children.firstElementChild;\n for (const entry of workspace.children) {\n currentConversations.add(entry.id); let row = conversations.get(entry.id); if (!row) {row = createConversation(); conversations.set(entry.id,row);}\n const title = entry.title || 'Untitled conversation'; row.element.classList.toggle('pui-active',entry.active); row.button.dataset.conversation = entry.id; parts.action(row.button).update({title, disabled: !!state.disabled});\n if (entry.active) row.button.setAttribute('aria-current','page'); else row.button.removeAttribute('aria-current'); if (row.title.textContent !== title) row.title.textContent = title;\n row.more.id = prefix+'conversation-actions-'+entry.id; row.more.dataset.conversationMenu = entry.id; row.more.setAttribute('aria-label','Actions for '+title); row.more.setAttribute('aria-expanded',String(!!entry.menuOpen)); parts.action(row.more).update({disabled: !!state.disabled});\n const signature = entry.status === row.statusSource && entry.status instanceof DocumentFragment && entry.status.childNodes.length === 0 ? row.statusSignature : statusSignature(entry.status);\n row.statusSource = entry.status;\n if (signature !== row.statusSignature) {for (const node of row.status) node.parentNode?.removeChild(node); row.status = entry.status ? entry.status instanceof DocumentFragment ? [...entry.status.childNodes] : [entry.status] : []; row.button.append(...row.status); row.statusSignature = signature;}\n if (row.element !== rowCursor) group.children.insertBefore(row.element,rowCursor); rowCursor = row.element.nextElementSibling;\n }\n if (!workspace.children.length) {if (group.empty.parentElement !== group.children) group.children.append(group.empty);} else group.empty.remove();\n if (group.element !== groupCursor) element.insertBefore(group.element,groupCursor); groupCursor = group.element.nextElementSibling;\n }\n for (const [id,row] of conversations) if (!currentConversations.has(id)) {row.element.remove(); conversations.delete(id);}\n for (const [id,group] of workspaces) if (!currentWorkspaces.has(id)) {group.element.remove(); workspaces.delete(id);}\n if (state.empty === 'workspaces') {if (emptyWorkspace.parentElement !== element) element.append(emptyWorkspace);} else emptyWorkspace.remove();\n parts.action(emptyWorkspace).update({disabled: !!state.disabled});\n if (state.empty === 'search') {if (emptySearch.parentElement !== element) element.append(emptySearch);} else emptySearch.remove();\n parts.update();\n };\n element.addEventListener('click',event => {\n const target = (event.target as Element).closest<HTMLButtonElement>('button'); if (!target || target.disabled) return;\n if (target.dataset.toggleWorkspace && options.onToggle) {event.stopPropagation(); options.onToggle(target.dataset.toggleWorkspace); return;}\n if (target.dataset.conversation && options.onSelect) {event.stopPropagation(); options.onSelect(target.dataset.conversation); return;}\n const action: WorkspaceNavigationAction | undefined = target === emptyWorkspace ? {action:'add-workspace',trigger:target}\n : target.dataset.newWorkspace ? {action:'new-conversation',workspaceId:target.dataset.newWorkspace,trigger:target}\n : target.dataset.workspaceMenu ? {action:'workspace-menu',workspaceId:target.dataset.workspaceMenu,trigger:target}\n : target.dataset.conversationMenu ? {action:'conversation-menu',conversationId:target.dataset.conversationMenu,trigger:target} : undefined;\n if (action && options.onAction) {event.stopPropagation(); options.onAction(action);}\n },{signal:abort.signal});\n update(initial); return {element,update,destroy() {if (destroyed) return; destroyed = true; abort.abort(); parts.destroy(); workspaces.clear(); conversations.clear(); if (!options.element) element.remove();}};\n}\nexport interface RenameConversationState {id: string; title: string; error?: string; disabled?: boolean}\nexport interface RenameConversationDraft {id: string; title: string}\nexport interface RenameConversationOptions {\n idPrefix?: string;\n dialog?: HTMLDialogElement;\n unavailable?: () => boolean;\n onSubmit?: (draft: RenameConversationDraft) => Promise<ActionResult> | ActionResult;\n onSubmitted?: () => void;\n onCancel?: () => void;\n}\nexport interface RenameConversationBlock extends UIBlock<RenameConversationState> {\n readonly input: HTMLInputElement;\n readonly form: HTMLFormElement;\n read(): RenameConversationDraft;\n reset(state: RenameConversationState): void;\n open(state?: RenameConversationState): void;\n close(): void;\n focus(): void;\n}\nexport function createRenameConversation(initial: RenameConversationState, options: RenameConversationOptions = {}): RenameConversationBlock {\n const state = initial; const element = document.createElement('div'); element.className = 'pui-rename-conversation'; element.innerHTML = `${dialogHeading('Rename conversation', 'rename-title', 'rename-dialog', 'CONVERSATION')}<form id=\"rename-form\"><label class=\"pui-field-label\" for=\"conversation-title\">Title</label><input id=\"conversation-title\" name=\"title\" value=\"${escape(state.title)}\" required autocomplete=\"off\" /><div id=\"rename-error\" class=\"pui-form-error\" role=\"alert\"></div><div class=\"pui-modal-footer\"><button type=\"button\" class=\"pui-secondary-button\" data-close=\"rename-dialog\">Cancel</button><button type=\"submit\" class=\"pui-primary-button\" data-idle-action data-idle-conversation=\"${escape(state.id)}\">Save title</button></div></form>`;\n const input = element.querySelector<HTMLInputElement>('#conversation-title')!; const form = element.querySelector<HTMLFormElement>('#rename-form')!; const error = element.querySelector<HTMLElement>('#rename-error')!;\n scopeIds(element, options.idPrefix ?? uniqueId('pui-rename') + '-');\n const parts = adoptProductParts(element); const control = parts.control(input); const feedback = parts.feedback(error);\n const button = form.querySelector<HTMLButtonElement>('button[type=\"submit\"]')!; const action = parts.action(button);\n const life = new Lifetime();\n let current = initial; let targetId = initial.id; let destroyed = false;\n const sync = () => {action.update({disabled: !!current.disabled || !!options.unavailable?.(), pending:operation.pending}); feedback.update({message: current.error || '', tone: 'error'});};\n const operation = createOperation({unavailable:()=>destroyed || !!current.disabled || !!options.unavailable?.(),onPending:sync,onError(message) {current={...current,error:message};sync();}});\n const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, {onOpen() {operation.invalidate();}, onClose() {operation.invalidate();}}) : undefined;\n const update = (next: Readonly<RenameConversationState>) => {if (destroyed) return; current = {...next, error: next.error ?? current.error}; sync();};\n const reset = (next: RenameConversationState) => {if (destroyed) return; operation.invalidate(); targetId = next.id; current = next; control.reset(next.title); button.dataset.idleConversation = next.id; sync();};\n const close = () => {operation.invalidate(); lifecycle?.close();};\n if (options.onSubmit) life.listen(form, 'submit', (event => {\n event.preventDefault();\n const title = control.getValue().trim();\n if (!title) return;\n operation.run(()=>{current = {...current, error: ''}; sync(); return options.onSubmit!({id: targetId, title});},result=>{\n if (options.dialog && !options.dialog.open) return;\n if (result.ok) {lifecycle?.close(); options.onSubmitted?.();}\n else current = {...current, error: result.error};\n sync();\n });\n }) as EventListener);\n life.listen(element, 'click', (event => {if ((event.target as Element).closest('[data-close]')) {operation.invalidate(); options.onCancel?.(); lifecycle?.close();}}) as EventListener);\n update(initial);\n return {element, input, form, update, read: () => ({id: targetId, title: control.getValue()}), reset, open(next) {if (next) reset(next); lifecycle?.open(); input.select();}, close, focus() {input.select();}, destroy() {if (destroyed) return; destroyed = true; operation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove();}};\n}\nexport interface WorkspacePickerState {workspaces: readonly {id: string; name: string; path: string}[]; error?: string; disabled?: boolean}\nexport interface WorkspacePickerOptions {\n idPrefix?: string;\n dialog?: HTMLDialogElement;\n unavailable?: () => boolean;\n onSubmit?: (path: string) => Promise<ActionResult> | ActionResult;\n onPick?: () => Promise<{path?: string; error?: string}>;\n onSelect?: (id: string) => void;\n onSubmitted?: () => void;\n onCancel?: () => void;\n}\nexport interface WorkspacePickerBlock extends UIBlock<WorkspacePickerState> {\n readonly input: HTMLInputElement;\n readonly form: HTMLFormElement;\n readonly pickButton: HTMLButtonElement;\n read(): {path: string};\n reset(path?: string): void;\n open(): void;\n close(): void;\n focus(): void;\n}\nexport function createWorkspacePicker(initial: WorkspacePickerState, options: WorkspacePickerOptions = {}): WorkspacePickerBlock {\n const state = initial; const element = document.createElement('div'); element.className = 'pui-workspace-picker'; element.innerHTML = `${dialogHeading('Workspaces', 'workspace-title', 'workspace-dialog', 'A PLACE TO WORK')}<p class=\"pui-modal-description\">Choose a local folder. Conversations belong to a workspace, so Pith knows where to read and create files.</p><div class=\"pui-modal-workspaces\">${state.workspaces.map((entry) => `<button class=\"pui-modal-workspace\" data-modal-workspace=\"${escape(entry.id)}\">${icon('folder')}<span><strong>${escape(entry.name)}</strong><small>${escape(entry.path)}</small></span>${icon('chevron')}</button>`).join('')}</div><div class=\"pui-workspace-add\"><button class=\"pui-picker-button\" id=\"pick-folder\" type=\"button\">${icon('folder')}Choose a folder…</button><div class=\"pui-path-divider\"><span>or enter a folder path</span></div><form id=\"workspace-form\"><label class=\"pui-sr-only\" for=\"workspace-path\">Absolute folder path</label><input id=\"workspace-path\" name=\"path\" placeholder=\"/Users/you/Documents/my-work\" required autocomplete=\"off\" spellcheck=\"false\" /><p class=\"pui-field-hint\">Use an existing folder on this computer. Pith will work inside it.</p><div id=\"workspace-error\" class=\"pui-form-error\" role=\"alert\"></div><div class=\"pui-modal-footer\"><button class=\"pui-secondary-button\" type=\"button\" data-close=\"workspace-dialog\">Cancel</button><button class=\"pui-primary-button\" id=\"add-workspace\" type=\"submit\">Add workspace</button></div></form></div>`;\n const input = element.querySelector<HTMLInputElement>('#workspace-path')!; const form = element.querySelector<HTMLFormElement>('#workspace-form')!; const pickButton = element.querySelector<HTMLButtonElement>('#pick-folder')!; const error = element.querySelector<HTMLElement>('#workspace-error')!;\n scopeIds(element, options.idPrefix ?? uniqueId('pui-workspace') + '-');\n const list = element.querySelector<HTMLElement>('.pui-modal-workspaces')!;\n const rows = new Map([...list.querySelectorAll<HTMLButtonElement>('[data-modal-workspace]')].map(row => [row.dataset.modalWorkspace!, row]));\n const parts = adoptProductParts(element); const control = parts.control(input); const feedback = parts.feedback(error);\n const submitButton = form.querySelector<HTMLButtonElement>('button[type=\"submit\"]')!;\n const life = new Lifetime();\n let current = initial; let destroyed = false;\n const unavailable = () => destroyed || !!current.disabled || !!options.unavailable?.();\n const sync = () => {const disabled = unavailable(), pending = pickOperation.pending || submitOperation.pending; parts.action(submitButton).update({disabled, pending}); parts.action(pickButton).update({disabled, pending}); for (const row of rows.values()) parts.action(row).update({disabled: disabled || pending}); feedback.update({message: current.error || '', tone: 'error'});};\n const fail = (message: string) => {current={...current,error:message};sync();};\n const pickOperation = createOperation({unavailable:()=>unavailable() || submitOperation.pending,onPending:sync,onError(message) {fail(`${message} You can enter the path below.`);control.focus();}});\n const submitOperation = createOperation({unavailable:()=>unavailable() || pickOperation.pending,onPending:sync,onError:fail});\n const invalidate = () => {pickOperation.invalidate();submitOperation.invalidate();};\n const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, {onOpen:invalidate,onClose:invalidate}) : undefined;\n const update = (next: Readonly<WorkspacePickerState>) => {\n if (destroyed) return; current = {...next, error: next.error ?? current.error};\n reconcileKeyed(list,rows,next.workspaces,{key:entry=>entry.id,element:row=>row,\n create(entry) {const row=document.createElement('button'); row.type = 'button'; row.className = 'pui-modal-workspace'; row.dataset.modalWorkspace = entry.id; row.innerHTML = `${icon('folder')}<span><strong></strong><small></small></span>${icon('chevron')}`;return row;},\n update(row,entry) {\n const name = row.querySelector('strong')!; const path = row.querySelector('small')!;\n if (name.textContent !== entry.name) name.textContent = entry.name;\n if (path.textContent !== entry.path) path.textContent = entry.path;\n },destroy() {},\n });\n parts.update(); sync();\n };\n const submit = (path: string): void => {\n if (!options.onSubmit || !path.trim()) return;\n submitOperation.run(()=>{current = {...current, error: ''}; sync(); return options.onSubmit!(path.trim());},result=>{\n if (options.dialog && !options.dialog.open) return;\n if (result.ok) {lifecycle?.close(); options.onSubmitted?.();}\n else current = {...current, error: result.error};\n sync();\n });\n };\n if (options.onSubmit) life.listen(form, 'submit', (event => {event.preventDefault(); void submit(control.getValue());}) as EventListener);\n if (options.onPick) life.listen(pickButton, 'click', (() => {\n pickOperation.run(()=>{current = {...current, error: ''}; sync(); return options.onPick!();},result=>{\n // End the picker ownership before handing a valid path to submission.\n // A newly disabled target can refuse the write without retaining pending.\n pickOperation.invalidate();\n if (options.dialog && !options.dialog.open) return;\n if (result.error) {fail(result.error);control.focus();}\n else if (result.path) {control.reset(result.path);submit(result.path);}\n });\n }) as EventListener);\n life.listen(element, 'click', (event => {\n const target = event.target as Element;\n const selection = target.closest<HTMLButtonElement>('[data-modal-workspace]');\n if (selection && options.onSelect) {event.stopPropagation(); if (!pickOperation.pending && !submitOperation.pending && !unavailable()) options.onSelect(selection.dataset.modalWorkspace!);}\n if (target.closest('[data-close]')) {invalidate(); options.onCancel?.(); lifecycle?.close();}\n }) as EventListener);\n update(initial);\n return {element, input, form, pickButton, update, read: () => ({path: control.getValue()}), reset(path = '') {if (destroyed) return; invalidate(); current = {...current, error: ''}; control.reset(path); sync();}, open() {lifecycle?.open();}, close() {invalidate(); lifecycle?.close();}, focus: control.focus, destroy() {if (destroyed) return; destroyed = true; pickOperation.destroy(); submitOperation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove();}};\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** One owned operation. Invalidating UI never retries or cancels a business write. */
|
|
2
|
+
export declare function createOperation(options?: {
|
|
3
|
+
unavailable?: () => boolean;
|
|
4
|
+
onPending?: (pending: boolean) => void;
|
|
5
|
+
onError?: (message: string) => void;
|
|
6
|
+
}): {
|
|
7
|
+
readonly pending: boolean;
|
|
8
|
+
run<Value>(task: () => Value | PromiseLike<Value>, onResult?: (value: Value) => void): boolean;
|
|
9
|
+
invalidate(): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../src/operation.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,OAAO,GAAE;IACvC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;sBAKa,OAAO;QAClB,KAAK,QAAQ,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO;kBAchF,IAAI;eACP,IAAI;EAElB"}
|