pith-ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/AI.md +75 -0
  2. package/API.md +3688 -0
  3. package/LICENSE +661 -0
  4. package/README.md +80 -2
  5. package/dist/composer.d.ts +38 -0
  6. package/dist/composer.d.ts.map +1 -0
  7. package/dist/composer.js +123 -0
  8. package/dist/composer.js.map +1 -0
  9. package/dist/content/conversation-reader.d.ts +19 -0
  10. package/dist/content/conversation-reader.d.ts.map +1 -0
  11. package/dist/content/conversation-reader.js +280 -0
  12. package/dist/content/conversation-reader.js.map +1 -0
  13. package/dist/content/conversation-view.d.ts +65 -0
  14. package/dist/content/conversation-view.d.ts.map +1 -0
  15. package/dist/content/conversation-view.js +140 -0
  16. package/dist/content/conversation-view.js.map +1 -0
  17. package/dist/content/image-viewer.d.ts +25 -0
  18. package/dist/content/image-viewer.d.ts.map +1 -0
  19. package/dist/content/image-viewer.js +114 -0
  20. package/dist/content/image-viewer.js.map +1 -0
  21. package/dist/content/markdown.d.ts +12 -0
  22. package/dist/content/markdown.d.ts.map +1 -0
  23. package/dist/content/markdown.js +68 -0
  24. package/dist/content/markdown.js.map +1 -0
  25. package/dist/content/paged-preview.d.ts +15 -0
  26. package/dist/content/paged-preview.d.ts.map +1 -0
  27. package/dist/content/paged-preview.js +108 -0
  28. package/dist/content/paged-preview.js.map +1 -0
  29. package/dist/content/views.d.ts +9 -0
  30. package/dist/content/views.d.ts.map +1 -0
  31. package/dist/content/views.js +53 -0
  32. package/dist/content/views.js.map +1 -0
  33. package/dist/content/welcome.d.ts +18 -0
  34. package/dist/content/welcome.d.ts.map +1 -0
  35. package/dist/content/welcome.js +54 -0
  36. package/dist/content/welcome.js.map +1 -0
  37. package/dist/core.d.ts +36 -0
  38. package/dist/core.d.ts.map +1 -0
  39. package/dist/core.js +44 -0
  40. package/dist/core.js.map +1 -0
  41. package/dist/dom.d.ts +14 -0
  42. package/dist/dom.d.ts.map +1 -0
  43. package/dist/dom.js +69 -0
  44. package/dist/dom.js.map +1 -0
  45. package/dist/files/panels.d.ts +100 -0
  46. package/dist/files/panels.d.ts.map +1 -0
  47. package/dist/files/panels.js +286 -0
  48. package/dist/files/panels.js.map +1 -0
  49. package/dist/files/systems.d.ts +91 -0
  50. package/dist/files/systems.d.ts.map +1 -0
  51. package/dist/files/systems.js +273 -0
  52. package/dist/files/systems.js.map +1 -0
  53. package/dist/forms/actions.d.ts +27 -0
  54. package/dist/forms/actions.d.ts.map +1 -0
  55. package/dist/forms/actions.js +39 -0
  56. package/dist/forms/actions.js.map +1 -0
  57. package/dist/forms/custom-connection.d.ts +62 -0
  58. package/dist/forms/custom-connection.d.ts.map +1 -0
  59. package/dist/forms/custom-connection.js +72 -0
  60. package/dist/forms/custom-connection.js.map +1 -0
  61. package/dist/forms/dialog-frame.d.ts +41 -0
  62. package/dist/forms/dialog-frame.d.ts.map +1 -0
  63. package/dist/forms/dialog-frame.js +95 -0
  64. package/dist/forms/dialog-frame.js.map +1 -0
  65. package/dist/forms/history.d.ts +16 -0
  66. package/dist/forms/history.d.ts.map +1 -0
  67. package/dist/forms/history.js +21 -0
  68. package/dist/forms/history.js.map +1 -0
  69. package/dist/forms/identity.d.ts +16 -0
  70. package/dist/forms/identity.d.ts.map +1 -0
  71. package/dist/forms/identity.js +53 -0
  72. package/dist/forms/identity.js.map +1 -0
  73. package/dist/forms/model-editor.d.ts +40 -0
  74. package/dist/forms/model-editor.d.ts.map +1 -0
  75. package/dist/forms/model-editor.js +89 -0
  76. package/dist/forms/model-editor.js.map +1 -0
  77. package/dist/forms/panels.d.ts +146 -0
  78. package/dist/forms/panels.d.ts.map +1 -0
  79. package/dist/forms/panels.js +339 -0
  80. package/dist/forms/panels.js.map +1 -0
  81. package/dist/forms/provider-login.d.ts +22 -0
  82. package/dist/forms/provider-login.d.ts.map +1 -0
  83. package/dist/forms/provider-login.js +116 -0
  84. package/dist/forms/provider-login.js.map +1 -0
  85. package/dist/forms/resource-editor.d.ts +27 -0
  86. package/dist/forms/resource-editor.d.ts.map +1 -0
  87. package/dist/forms/resource-editor.js +34 -0
  88. package/dist/forms/resource-editor.js.map +1 -0
  89. package/dist/foundations.d.ts +95 -0
  90. package/dist/foundations.d.ts.map +1 -0
  91. package/dist/foundations.js +315 -0
  92. package/dist/foundations.js.map +1 -0
  93. package/dist/index.d.ts +28 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +28 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/navigation/context-menu.d.ts +26 -0
  98. package/dist/navigation/context-menu.d.ts.map +1 -0
  99. package/dist/navigation/context-menu.js +81 -0
  100. package/dist/navigation/context-menu.js.map +1 -0
  101. package/dist/navigation/navigation.d.ts +92 -0
  102. package/dist/navigation/navigation.d.ts.map +1 -0
  103. package/dist/navigation/navigation.js +368 -0
  104. package/dist/navigation/navigation.js.map +1 -0
  105. package/dist/primitives.d.ts +310 -0
  106. package/dist/primitives.d.ts.map +1 -0
  107. package/dist/primitives.js +633 -0
  108. package/dist/primitives.js.map +1 -0
  109. package/dist/styles.css +853 -0
  110. package/dist/surface.d.ts +29 -0
  111. package/dist/surface.d.ts.map +1 -0
  112. package/dist/surface.js +154 -0
  113. package/dist/surface.js.map +1 -0
  114. package/dist/tasks/approval.d.ts +25 -0
  115. package/dist/tasks/approval.d.ts.map +1 -0
  116. package/dist/tasks/approval.js +64 -0
  117. package/dist/tasks/approval.js.map +1 -0
  118. package/dist/tasks/permission.d.ts +37 -0
  119. package/dist/tasks/permission.d.ts.map +1 -0
  120. package/dist/tasks/permission.js +73 -0
  121. package/dist/tasks/permission.js.map +1 -0
  122. package/dist/tasks/runtime.d.ts +31 -0
  123. package/dist/tasks/runtime.d.ts.map +1 -0
  124. package/dist/tasks/runtime.js +34 -0
  125. package/dist/tasks/runtime.js.map +1 -0
  126. package/dist/theme.d.ts +4 -0
  127. package/dist/theme.d.ts.map +1 -0
  128. package/dist/theme.js +6 -0
  129. package/dist/theme.js.map +1 -0
  130. package/dist/workspace.d.ts +92 -0
  131. package/dist/workspace.d.ts.map +1 -0
  132. package/dist/workspace.js +288 -0
  133. package/dist/workspace.js.map +1 -0
  134. package/package.json +27 -4
@@ -0,0 +1,92 @@
1
+ import { type ActionResult, type UIBlock } from '../core.js';
2
+ export interface NavigationConversation {
3
+ id: string;
4
+ title?: string;
5
+ active: boolean;
6
+ menuOpen?: boolean;
7
+ status?: Node | null;
8
+ }
9
+ export interface NavigationWorkspace {
10
+ id: string;
11
+ name: string;
12
+ path: string;
13
+ expanded: boolean;
14
+ selected: boolean;
15
+ menuOpen?: boolean;
16
+ children: readonly NavigationConversation[];
17
+ }
18
+ export interface WorkspaceNavigationState {
19
+ groups: readonly NavigationWorkspace[];
20
+ empty: 'workspaces' | 'search' | null;
21
+ disabled?: boolean;
22
+ }
23
+ export declare function createWorkspaceNavigation(initial: WorkspaceNavigationState, options?: {
24
+ element?: HTMLElement;
25
+ idPrefix?: string;
26
+ onToggle?: (id: string) => void;
27
+ onSelect?: (id: string) => void;
28
+ }): UIBlock<WorkspaceNavigationState>;
29
+ export interface RenameConversationState {
30
+ id: string;
31
+ title: string;
32
+ error?: string;
33
+ disabled?: boolean;
34
+ }
35
+ export interface RenameConversationDraft {
36
+ id: string;
37
+ title: string;
38
+ }
39
+ export interface RenameConversationOptions {
40
+ idPrefix?: string;
41
+ dialog?: HTMLDialogElement;
42
+ unavailable?: () => boolean;
43
+ onSubmit?: (draft: RenameConversationDraft) => Promise<ActionResult> | ActionResult;
44
+ onSubmitted?: () => void;
45
+ onCancel?: () => void;
46
+ }
47
+ export interface RenameConversationBlock extends UIBlock<RenameConversationState> {
48
+ readonly input: HTMLInputElement;
49
+ readonly form: HTMLFormElement;
50
+ read(): RenameConversationDraft;
51
+ reset(state: RenameConversationState): void;
52
+ open(state?: RenameConversationState): void;
53
+ close(): void;
54
+ focus(): void;
55
+ }
56
+ export declare function createRenameConversation(initial: RenameConversationState, options?: RenameConversationOptions): RenameConversationBlock;
57
+ export interface WorkspacePickerState {
58
+ workspaces: readonly {
59
+ id: string;
60
+ name: string;
61
+ path: string;
62
+ }[];
63
+ error?: string;
64
+ disabled?: boolean;
65
+ }
66
+ export interface WorkspacePickerOptions {
67
+ idPrefix?: string;
68
+ dialog?: HTMLDialogElement;
69
+ unavailable?: () => boolean;
70
+ onSubmit?: (path: string) => Promise<ActionResult> | ActionResult;
71
+ onPick?: () => Promise<{
72
+ path?: string;
73
+ error?: string;
74
+ }>;
75
+ onSelect?: (id: string) => void;
76
+ onSubmitted?: () => void;
77
+ onCancel?: () => void;
78
+ }
79
+ export interface WorkspacePickerBlock extends UIBlock<WorkspacePickerState> {
80
+ readonly input: HTMLInputElement;
81
+ readonly form: HTMLFormElement;
82
+ readonly pickButton: HTMLButtonElement;
83
+ read(): {
84
+ path: string;
85
+ };
86
+ reset(path?: string): void;
87
+ open(): void;
88
+ close(): void;
89
+ focus(): void;
90
+ }
91
+ export declare function createWorkspacePicker(initial: WorkspacePickerState, options?: WorkspacePickerOptions): WorkspacePickerBlock;
92
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/navigation/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAInF,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,O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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,CA2D/H"}
@@ -0,0 +1,368 @@
1
+ import { scopeIds } from '../forms/identity.js';
2
+ import { Generation, Lifetime } from '../core.js';
3
+ import { dialogHeading, escape, icon, uniqueId } from '../dom.js';
4
+ import { adoptProductParts } from '../foundations.js';
5
+ import { installDialogLifecycle } from '../surface.js';
6
+ export function createWorkspaceNavigation(initial, options = {}) {
7
+ const element = options.element || document.createElement('nav');
8
+ if (!options.element) {
9
+ element.className = 'pui-history-list pui-workspace-navigation';
10
+ element.setAttribute('aria-label', 'Workspaces and conversations');
11
+ }
12
+ const prefix = options.idPrefix ?? uniqueId('pui-nav') + '-';
13
+ const abort = new AbortController();
14
+ let destroyed = false;
15
+ const parts = adoptProductParts(element);
16
+ const workspaces = new Map();
17
+ const conversations = new Map();
18
+ const emptyWorkspace = document.createElement('button');
19
+ emptyWorkspace.type = 'button';
20
+ emptyWorkspace.className = 'pui-workspace-item pui-empty-workspace';
21
+ emptyWorkspace.dataset.action = 'workspace';
22
+ emptyWorkspace.innerHTML = `${icon('folder')}<span>Add a workspace</span>`;
23
+ const emptySearch = document.createElement('p');
24
+ emptySearch.className = 'pui-history-empty';
25
+ emptySearch.textContent = 'No matching conversations.';
26
+ function createWorkspace() {
27
+ const root = document.createElement('section');
28
+ root.className = 'pui-workspace-group';
29
+ 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>`;
30
+ const buttons = root.querySelectorAll('button');
31
+ const empty = document.createElement('p');
32
+ empty.className = 'pui-workspace-empty';
33
+ empty.textContent = 'No conversations yet';
34
+ return { element: root, heading: root.firstElementChild, toggle: buttons[0], title: buttons[0].querySelector('span'), more: buttons[1], create: buttons[2], children: root.lastElementChild, empty };
35
+ }
36
+ function createConversation() {
37
+ const root = document.createElement('div');
38
+ root.className = 'pui-history-row';
39
+ root.innerHTML = `<button class="pui-history-item"><span></span></button><button class="pui-quiet-icon pui-history-more" aria-haspopup="menu">${icon('more')}</button>`;
40
+ const buttons = root.querySelectorAll('button');
41
+ return { element: root, button: buttons[0], title: buttons[0].querySelector('span'), more: buttons[1], status: [], statusSignature: '' };
42
+ }
43
+ function statusSignature(node) {
44
+ if (!node)
45
+ return '';
46
+ const holder = document.createElement('div');
47
+ holder.append(node.cloneNode(true));
48
+ return holder.innerHTML;
49
+ }
50
+ const update = (state) => {
51
+ if (destroyed)
52
+ return;
53
+ const currentWorkspaces = new Set();
54
+ const currentConversations = new Set();
55
+ let groupCursor = element.firstElementChild;
56
+ for (const workspace of state.groups) {
57
+ currentWorkspaces.add(workspace.id);
58
+ let group = workspaces.get(workspace.id);
59
+ if (!group) {
60
+ group = createWorkspace();
61
+ workspaces.set(workspace.id, group);
62
+ }
63
+ group.element.setAttribute('aria-label', workspace.name);
64
+ group.heading.classList.toggle('pui-selected', workspace.selected);
65
+ group.toggle.dataset.toggleWorkspace = workspace.id;
66
+ group.toggle.setAttribute('aria-expanded', String(workspace.expanded));
67
+ group.toggle.setAttribute('aria-controls', prefix + 'workspace-children-' + workspace.id);
68
+ group.toggle.title = workspace.path;
69
+ if (group.title.textContent !== workspace.name)
70
+ group.title.textContent = workspace.name;
71
+ group.more.id = prefix + 'workspace-actions-' + workspace.id;
72
+ group.more.dataset.workspaceMenu = workspace.id;
73
+ group.more.setAttribute('aria-label', 'Actions for workspace ' + workspace.name);
74
+ group.more.setAttribute('aria-expanded', String(!!workspace.menuOpen));
75
+ parts.action(group.more).update({ disabled: !!state.disabled });
76
+ group.create.dataset.newWorkspace = workspace.id;
77
+ group.create.setAttribute('aria-label', 'New conversation in ' + workspace.name);
78
+ parts.action(group.create).update({ disabled: !!state.disabled });
79
+ group.children.id = prefix + 'workspace-children-' + workspace.id;
80
+ group.children.hidden = !workspace.expanded;
81
+ let rowCursor = group.children.firstElementChild;
82
+ for (const entry of workspace.children) {
83
+ currentConversations.add(entry.id);
84
+ let row = conversations.get(entry.id);
85
+ if (!row) {
86
+ row = createConversation();
87
+ conversations.set(entry.id, row);
88
+ }
89
+ const title = entry.title || 'Untitled conversation';
90
+ row.element.classList.toggle('pui-active', entry.active);
91
+ row.button.dataset.conversation = entry.id;
92
+ parts.action(row.button).update({ title, disabled: !!state.disabled });
93
+ if (entry.active)
94
+ row.button.setAttribute('aria-current', 'page');
95
+ else
96
+ row.button.removeAttribute('aria-current');
97
+ if (row.title.textContent !== title)
98
+ row.title.textContent = title;
99
+ row.more.id = prefix + 'conversation-actions-' + entry.id;
100
+ row.more.dataset.conversationMenu = entry.id;
101
+ row.more.setAttribute('aria-label', 'Actions for ' + title);
102
+ row.more.setAttribute('aria-expanded', String(!!entry.menuOpen));
103
+ parts.action(row.more).update({ disabled: !!state.disabled });
104
+ const signature = entry.status === row.statusSource && entry.status instanceof DocumentFragment && entry.status.childNodes.length === 0 ? row.statusSignature : statusSignature(entry.status);
105
+ row.statusSource = entry.status;
106
+ if (signature !== row.statusSignature) {
107
+ for (const node of row.status)
108
+ node.parentNode?.removeChild(node);
109
+ row.status = entry.status ? entry.status instanceof DocumentFragment ? [...entry.status.childNodes] : [entry.status] : [];
110
+ row.button.append(...row.status);
111
+ row.statusSignature = signature;
112
+ }
113
+ if (row.element !== rowCursor)
114
+ group.children.insertBefore(row.element, rowCursor);
115
+ rowCursor = row.element.nextElementSibling;
116
+ }
117
+ if (!workspace.children.length) {
118
+ if (group.empty.parentElement !== group.children)
119
+ group.children.append(group.empty);
120
+ }
121
+ else
122
+ group.empty.remove();
123
+ if (group.element !== groupCursor)
124
+ element.insertBefore(group.element, groupCursor);
125
+ groupCursor = group.element.nextElementSibling;
126
+ }
127
+ for (const [id, row] of conversations)
128
+ if (!currentConversations.has(id)) {
129
+ row.element.remove();
130
+ conversations.delete(id);
131
+ }
132
+ for (const [id, group] of workspaces)
133
+ if (!currentWorkspaces.has(id)) {
134
+ group.element.remove();
135
+ workspaces.delete(id);
136
+ }
137
+ if (state.empty === 'workspaces') {
138
+ if (emptyWorkspace.parentElement !== element)
139
+ element.append(emptyWorkspace);
140
+ }
141
+ else
142
+ emptyWorkspace.remove();
143
+ if (state.empty === 'search') {
144
+ if (emptySearch.parentElement !== element)
145
+ element.append(emptySearch);
146
+ }
147
+ else
148
+ emptySearch.remove();
149
+ parts.update();
150
+ };
151
+ element.addEventListener('click', event => { const target = event.target.closest('button'); if (target?.disabled)
152
+ return; if (target?.dataset.toggleWorkspace)
153
+ options.onToggle?.(target.dataset.toggleWorkspace); if (target?.dataset.conversation)
154
+ options.onSelect?.(target.dataset.conversation); }, { signal: abort.signal });
155
+ update(initial);
156
+ return { element, update, destroy() { if (destroyed)
157
+ return; destroyed = true; abort.abort(); parts.destroy(); workspaces.clear(); conversations.clear(); if (!options.element)
158
+ element.remove(); } };
159
+ }
160
+ export function createRenameConversation(initial, options = {}) {
161
+ const state = initial;
162
+ const element = document.createElement('div');
163
+ element.className = 'pui-rename-conversation';
164
+ 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>`;
165
+ const input = element.querySelector('#conversation-title');
166
+ const form = element.querySelector('#rename-form');
167
+ const error = element.querySelector('#rename-error');
168
+ scopeIds(element, options.idPrefix ?? uniqueId('pui-rename') + '-');
169
+ const parts = adoptProductParts(element);
170
+ const control = parts.control(input);
171
+ const feedback = parts.feedback(error);
172
+ const button = form.querySelector('button[type="submit"]');
173
+ const action = parts.action(button);
174
+ const generation = new Generation();
175
+ const life = new Lifetime();
176
+ let current = initial;
177
+ let targetId = initial.id;
178
+ let pending = false;
179
+ let destroyed = false;
180
+ const sync = () => { action.update({ disabled: !!current.disabled || !!options.unavailable?.(), pending }); feedback.update({ message: current.error || '', tone: 'error' }); };
181
+ const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, { onOpen() { generation.invalidate(); pending = false; sync(); }, onClose() { generation.invalidate(); pending = false; sync(); } }) : undefined;
182
+ const update = (next) => { if (destroyed)
183
+ return; current = { ...next, error: next.error ?? current.error }; sync(); };
184
+ const reset = (next) => { if (destroyed)
185
+ return; generation.invalidate(); pending = false; targetId = next.id; current = next; control.reset(next.title); button.dataset.idleConversation = next.id; sync(); };
186
+ const close = () => { generation.invalidate(); pending = false; lifecycle?.close(); sync(); };
187
+ if (options.onSubmit)
188
+ life.listen(form, 'submit', (async (event) => {
189
+ event.preventDefault();
190
+ const title = control.getValue().trim();
191
+ if (destroyed || pending || current.disabled || options.unavailable?.() || !title)
192
+ return;
193
+ const seq = generation.next();
194
+ pending = true;
195
+ current = { ...current, error: '' };
196
+ sync();
197
+ let result;
198
+ try {
199
+ result = await options.onSubmit({ id: targetId, title });
200
+ }
201
+ catch (reason) {
202
+ result = { ok: false, error: reason instanceof Error ? reason.message : String(reason) };
203
+ }
204
+ if (!generation.current(seq) || (options.dialog && !options.dialog.open))
205
+ return;
206
+ pending = false;
207
+ if (result.ok) {
208
+ lifecycle?.close();
209
+ options.onSubmitted?.();
210
+ }
211
+ else
212
+ current = { ...current, error: result.error };
213
+ sync();
214
+ }));
215
+ life.listen(element, 'click', (event => { if (event.target.closest('[data-close]')) {
216
+ generation.invalidate();
217
+ pending = false;
218
+ options.onCancel?.();
219
+ lifecycle?.close();
220
+ } }));
221
+ update(initial);
222
+ return { element, input, form, update, read: () => ({ id: targetId, title: control.getValue() }), reset, open(next) { if (next)
223
+ reset(next); lifecycle?.open(); input.select(); }, close, focus() { input.select(); }, destroy() { if (destroyed)
224
+ return; destroyed = true; generation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove(); } };
225
+ }
226
+ export function createWorkspacePicker(initial, options = {}) {
227
+ const state = initial;
228
+ const element = document.createElement('div');
229
+ element.className = 'pui-workspace-picker';
230
+ 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>`;
231
+ const input = element.querySelector('#workspace-path');
232
+ const form = element.querySelector('#workspace-form');
233
+ const pickButton = element.querySelector('#pick-folder');
234
+ const error = element.querySelector('#workspace-error');
235
+ scopeIds(element, options.idPrefix ?? uniqueId('pui-workspace') + '-');
236
+ const list = element.querySelector('.pui-modal-workspaces');
237
+ const rows = new Map([...list.querySelectorAll('[data-modal-workspace]')].map(row => [row.dataset.modalWorkspace, row]));
238
+ const parts = adoptProductParts(element);
239
+ const control = parts.control(input);
240
+ const feedback = parts.feedback(error);
241
+ const submitButton = form.querySelector('button[type="submit"]');
242
+ const generation = new Generation();
243
+ const life = new Lifetime();
244
+ let current = initial;
245
+ let pending = false;
246
+ let destroyed = false;
247
+ const sync = () => { const disabled = !!current.disabled || !!options.unavailable?.(); parts.action(submitButton).update({ disabled, pending }); parts.action(pickButton).update({ disabled, pending }); for (const row of rows.values())
248
+ parts.action(row).update({ disabled: disabled || pending }); feedback.update({ message: current.error || '', tone: 'error' }); };
249
+ const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, { onOpen() { generation.invalidate(); pending = false; sync(); }, onClose() { generation.invalidate(); pending = false; sync(); } }) : undefined;
250
+ const update = (next) => {
251
+ if (destroyed)
252
+ return;
253
+ current = { ...next, error: next.error ?? current.error };
254
+ const keep = new Set(next.workspaces.map(entry => entry.id));
255
+ for (const [id, row] of rows)
256
+ if (!keep.has(id)) {
257
+ row.remove();
258
+ rows.delete(id);
259
+ }
260
+ let cursor = list.firstElementChild;
261
+ for (const entry of next.workspaces) {
262
+ let row = rows.get(entry.id);
263
+ if (!row) {
264
+ row = document.createElement('button');
265
+ row.type = 'button';
266
+ row.className = 'pui-modal-workspace';
267
+ row.dataset.modalWorkspace = entry.id;
268
+ row.innerHTML = `${icon('folder')}<span><strong></strong><small></small></span>${icon('chevron')}`;
269
+ rows.set(entry.id, row);
270
+ }
271
+ const name = row.querySelector('strong');
272
+ const path = row.querySelector('small');
273
+ if (name.textContent !== entry.name)
274
+ name.textContent = entry.name;
275
+ if (path.textContent !== entry.path)
276
+ path.textContent = entry.path;
277
+ if (cursor !== row)
278
+ list.insertBefore(row, cursor);
279
+ cursor = row.nextElementSibling;
280
+ }
281
+ parts.update();
282
+ sync();
283
+ };
284
+ const submit = async (path, owner) => {
285
+ if (!options.onSubmit || destroyed || (pending && owner === undefined) || current.disabled || options.unavailable?.() || !path.trim())
286
+ return;
287
+ const seq = owner ?? generation.next();
288
+ pending = true;
289
+ current = { ...current, error: '' };
290
+ sync();
291
+ let result;
292
+ try {
293
+ result = await options.onSubmit(path.trim());
294
+ }
295
+ catch (reason) {
296
+ result = { ok: false, error: reason instanceof Error ? reason.message : String(reason) };
297
+ }
298
+ if (!generation.current(seq) || (options.dialog && !options.dialog.open))
299
+ return;
300
+ pending = false;
301
+ if (result.ok) {
302
+ lifecycle?.close();
303
+ options.onSubmitted?.();
304
+ }
305
+ else
306
+ current = { ...current, error: result.error };
307
+ sync();
308
+ };
309
+ if (options.onSubmit)
310
+ life.listen(form, 'submit', (event => { event.preventDefault(); void submit(control.getValue()); }));
311
+ if (options.onPick)
312
+ life.listen(pickButton, 'click', (async () => {
313
+ if (destroyed || pending || current.disabled || options.unavailable?.())
314
+ return;
315
+ const seq = generation.next();
316
+ pending = true;
317
+ current = { ...current, error: '' };
318
+ sync();
319
+ let result;
320
+ try {
321
+ result = await options.onPick();
322
+ }
323
+ catch (reason) {
324
+ result = { error: `${reason instanceof Error ? reason.message : String(reason)} You can enter the path below.` };
325
+ }
326
+ if (!generation.current(seq) || (options.dialog && !options.dialog.open))
327
+ return;
328
+ if (result.error) {
329
+ pending = false;
330
+ current = { ...current, error: result.error };
331
+ sync();
332
+ control.focus();
333
+ }
334
+ else if (result.path) {
335
+ control.reset(result.path);
336
+ if (options.onSubmit)
337
+ await submit(result.path, seq);
338
+ else {
339
+ pending = false;
340
+ sync();
341
+ }
342
+ }
343
+ else {
344
+ pending = false;
345
+ sync();
346
+ }
347
+ }));
348
+ life.listen(element, 'click', (event => {
349
+ const target = event.target;
350
+ const selection = target.closest('[data-modal-workspace]');
351
+ if (selection && options.onSelect) {
352
+ event.stopPropagation();
353
+ if (!pending && !current.disabled && !options.unavailable?.())
354
+ options.onSelect(selection.dataset.modalWorkspace);
355
+ }
356
+ if (target.closest('[data-close]')) {
357
+ generation.invalidate();
358
+ pending = false;
359
+ options.onCancel?.();
360
+ lifecycle?.close();
361
+ }
362
+ }));
363
+ update(initial);
364
+ return { element, input, form, pickButton, update, read: () => ({ path: control.getValue() }), reset(path = '') { if (destroyed)
365
+ return; generation.invalidate(); pending = false; current = { ...current, error: '' }; control.reset(path); sync(); }, open() { lifecycle?.open(); }, close() { generation.invalidate(); pending = false; lifecycle?.close(); sync(); }, focus: control.focus, destroy() { if (destroyed)
366
+ return; destroyed = true; generation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove(); } };
367
+ }
368
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
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,UAAU,EAAE,QAAQ,EAAmC,MAAM,YAAY,CAAC;AACnF,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;AAMvD,MAAM,UAAU,yBAAyB,CAAC,OAAiC,EAAE,UAAwH,EAAE;IACrM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC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.js';\nimport {dialogHeading, escape, icon, uniqueId} from '../dom.js';\nimport { adoptProductParts } from '../foundations.js';\nimport { installDialogLifecycle } from '../surface.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 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 if (state.empty === 'search') {if (emptySearch.parentElement !== element) element.append(emptySearch);} else emptySearch.remove();\n parts.update();\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(); 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 generation = new Generation(); const life = new Lifetime();\n let current = initial; let targetId = initial.id; let pending = false; let destroyed = false;\n const sync = () => {action.update({disabled: !!current.disabled || !!options.unavailable?.(), pending}); feedback.update({message: current.error || '', tone: 'error'});};\n const lifecycle = options.dialog ? installDialogLifecycle(options.dialog, {onOpen() {generation.invalidate(); pending = false; sync();}, onClose() {generation.invalidate(); pending = false; sync();}}) : 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; generation.invalidate(); pending = false; targetId = next.id; current = next; control.reset(next.title); button.dataset.idleConversation = next.id; sync();};\n const close = () => {generation.invalidate(); pending = false; lifecycle?.close(); sync();};\n if (options.onSubmit) life.listen(form, 'submit', (async event => {\n event.preventDefault();\n const title = control.getValue().trim();\n if (destroyed || pending || current.disabled || options.unavailable?.() || !title) return;\n const seq = generation.next(); pending = true; current = {...current, error: ''}; sync();\n let result: ActionResult;\n try {result = await options.onSubmit!({id: targetId, title});}\n catch (reason) {result = {ok: false, error: reason instanceof Error ? reason.message : String(reason)};}\n if (!generation.current(seq) || (options.dialog && !options.dialog.open)) return;\n pending = false;\n if (result.ok) {lifecycle?.close(); options.onSubmitted?.();}\n else current = {...current, error: result.error};\n sync();\n }) as EventListener);\n life.listen(element, 'click', (event => {if ((event.target as Element).closest('[data-close]')) {generation.invalidate(); pending = false; 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; generation.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 generation = new Generation(); const life = new Lifetime();\n let current = initial; let pending = false; let destroyed = false;\n const sync = () => {const disabled = !!current.disabled || !!options.unavailable?.(); 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 lifecycle = options.dialog ? installDialogLifecycle(options.dialog, {onOpen() {generation.invalidate(); pending = false; sync();}, onClose() {generation.invalidate(); pending = false; sync();}}) : undefined;\n const update = (next: Readonly<WorkspacePickerState>) => {\n if (destroyed) return; current = {...next, error: next.error ?? current.error};\n const keep = new Set(next.workspaces.map(entry => entry.id));\n for (const [id, row] of rows) if (!keep.has(id)) {row.remove(); rows.delete(id);}\n let cursor = list.firstElementChild;\n for (const entry of next.workspaces) {\n let row = rows.get(entry.id);\n if (!row) {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')}`; rows.set(entry.id, row);}\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 if (cursor !== row) list.insertBefore(row, cursor); cursor = row.nextElementSibling;\n }\n parts.update(); sync();\n };\n const submit = async (path: string, owner?: number): Promise<void> => {\n if (!options.onSubmit || destroyed || (pending && owner === undefined) || current.disabled || options.unavailable?.() || !path.trim()) return;\n const seq = owner ?? generation.next(); pending = true; current = {...current, error: ''}; sync();\n let result: ActionResult;\n try {result = await options.onSubmit(path.trim());}\n catch (reason) {result = {ok: false, error: reason instanceof Error ? reason.message : String(reason)};}\n if (!generation.current(seq) || (options.dialog && !options.dialog.open)) return;\n pending = false;\n if (result.ok) {lifecycle?.close(); options.onSubmitted?.();}\n else current = {...current, error: result.error};\n sync();\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', (async () => {\n if (destroyed || pending || current.disabled || options.unavailable?.()) return;\n const seq = generation.next(); pending = true; current = {...current, error: ''}; sync();\n let result: {path?: string; error?: string};\n try {result = await options.onPick!();}\n catch (reason) {result = {error: `${reason instanceof Error ? reason.message : String(reason)} You can enter the path below.`};}\n if (!generation.current(seq) || (options.dialog && !options.dialog.open)) return;\n if (result.error) {pending = false; current = {...current, error: result.error}; sync(); control.focus();}\n else if (result.path) {control.reset(result.path); if (options.onSubmit) await submit(result.path, seq); else {pending = false; sync();}}\n else {pending = false; sync();}\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 (!pending && !current.disabled && !options.unavailable?.()) options.onSelect(selection.dataset.modalWorkspace!);}\n if (target.closest('[data-close]')) {generation.invalidate(); pending = false; 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; generation.invalidate(); pending = false; current = {...current, error: ''}; control.reset(path); sync();}, open() {lifecycle?.open();}, close() {generation.invalidate(); pending = false; lifecycle?.close(); sync();}, focus: control.focus, destroy() {if (destroyed) return; destroyed = true; generation.destroy(); life.destroy(); lifecycle?.close(); lifecycle?.destroy(); parts.destroy(); element.remove();}};\n}\n"]}