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.
- package/AI.md +75 -0
- package/API.md +3688 -0
- package/LICENSE +661 -0
- package/README.md +80 -2
- package/dist/composer.d.ts +38 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +123 -0
- package/dist/composer.js.map +1 -0
- package/dist/content/conversation-reader.d.ts +19 -0
- package/dist/content/conversation-reader.d.ts.map +1 -0
- package/dist/content/conversation-reader.js +280 -0
- package/dist/content/conversation-reader.js.map +1 -0
- package/dist/content/conversation-view.d.ts +65 -0
- package/dist/content/conversation-view.d.ts.map +1 -0
- package/dist/content/conversation-view.js +140 -0
- package/dist/content/conversation-view.js.map +1 -0
- package/dist/content/image-viewer.d.ts +25 -0
- package/dist/content/image-viewer.d.ts.map +1 -0
- package/dist/content/image-viewer.js +114 -0
- package/dist/content/image-viewer.js.map +1 -0
- package/dist/content/markdown.d.ts +12 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +68 -0
- package/dist/content/markdown.js.map +1 -0
- package/dist/content/paged-preview.d.ts +15 -0
- package/dist/content/paged-preview.d.ts.map +1 -0
- package/dist/content/paged-preview.js +108 -0
- package/dist/content/paged-preview.js.map +1 -0
- package/dist/content/views.d.ts +9 -0
- package/dist/content/views.d.ts.map +1 -0
- package/dist/content/views.js +53 -0
- package/dist/content/views.js.map +1 -0
- package/dist/content/welcome.d.ts +18 -0
- package/dist/content/welcome.d.ts.map +1 -0
- package/dist/content/welcome.js +54 -0
- package/dist/content/welcome.js.map +1 -0
- package/dist/core.d.ts +36 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +44 -0
- package/dist/core.js.map +1 -0
- package/dist/dom.d.ts +14 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +69 -0
- package/dist/dom.js.map +1 -0
- package/dist/files/panels.d.ts +100 -0
- package/dist/files/panels.d.ts.map +1 -0
- package/dist/files/panels.js +286 -0
- package/dist/files/panels.js.map +1 -0
- package/dist/files/systems.d.ts +91 -0
- package/dist/files/systems.d.ts.map +1 -0
- package/dist/files/systems.js +273 -0
- package/dist/files/systems.js.map +1 -0
- package/dist/forms/actions.d.ts +27 -0
- package/dist/forms/actions.d.ts.map +1 -0
- package/dist/forms/actions.js +39 -0
- package/dist/forms/actions.js.map +1 -0
- package/dist/forms/custom-connection.d.ts +62 -0
- package/dist/forms/custom-connection.d.ts.map +1 -0
- package/dist/forms/custom-connection.js +72 -0
- package/dist/forms/custom-connection.js.map +1 -0
- package/dist/forms/dialog-frame.d.ts +41 -0
- package/dist/forms/dialog-frame.d.ts.map +1 -0
- package/dist/forms/dialog-frame.js +95 -0
- package/dist/forms/dialog-frame.js.map +1 -0
- package/dist/forms/history.d.ts +16 -0
- package/dist/forms/history.d.ts.map +1 -0
- package/dist/forms/history.js +21 -0
- package/dist/forms/history.js.map +1 -0
- package/dist/forms/identity.d.ts +16 -0
- package/dist/forms/identity.d.ts.map +1 -0
- package/dist/forms/identity.js +53 -0
- package/dist/forms/identity.js.map +1 -0
- package/dist/forms/model-editor.d.ts +40 -0
- package/dist/forms/model-editor.d.ts.map +1 -0
- package/dist/forms/model-editor.js +89 -0
- package/dist/forms/model-editor.js.map +1 -0
- package/dist/forms/panels.d.ts +146 -0
- package/dist/forms/panels.d.ts.map +1 -0
- package/dist/forms/panels.js +339 -0
- package/dist/forms/panels.js.map +1 -0
- package/dist/forms/provider-login.d.ts +22 -0
- package/dist/forms/provider-login.d.ts.map +1 -0
- package/dist/forms/provider-login.js +116 -0
- package/dist/forms/provider-login.js.map +1 -0
- package/dist/forms/resource-editor.d.ts +27 -0
- package/dist/forms/resource-editor.d.ts.map +1 -0
- package/dist/forms/resource-editor.js +34 -0
- package/dist/forms/resource-editor.js.map +1 -0
- package/dist/foundations.d.ts +95 -0
- package/dist/foundations.d.ts.map +1 -0
- package/dist/foundations.js +315 -0
- package/dist/foundations.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation/context-menu.d.ts +26 -0
- package/dist/navigation/context-menu.d.ts.map +1 -0
- package/dist/navigation/context-menu.js +81 -0
- package/dist/navigation/context-menu.js.map +1 -0
- package/dist/navigation/navigation.d.ts +92 -0
- package/dist/navigation/navigation.d.ts.map +1 -0
- package/dist/navigation/navigation.js +368 -0
- package/dist/navigation/navigation.js.map +1 -0
- package/dist/primitives.d.ts +310 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +633 -0
- package/dist/primitives.js.map +1 -0
- package/dist/styles.css +853 -0
- package/dist/surface.d.ts +29 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +154 -0
- package/dist/surface.js.map +1 -0
- package/dist/tasks/approval.d.ts +25 -0
- package/dist/tasks/approval.d.ts.map +1 -0
- package/dist/tasks/approval.js +64 -0
- package/dist/tasks/approval.js.map +1 -0
- package/dist/tasks/permission.d.ts +37 -0
- package/dist/tasks/permission.d.ts.map +1 -0
- package/dist/tasks/permission.js +73 -0
- package/dist/tasks/permission.js.map +1 -0
- package/dist/tasks/runtime.d.ts +31 -0
- package/dist/tasks/runtime.d.ts.map +1 -0
- package/dist/tasks/runtime.js +34 -0
- package/dist/tasks/runtime.js.map +1 -0
- package/dist/theme.d.ts +4 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +6 -0
- package/dist/theme.js.map +1 -0
- package/dist/workspace.d.ts +92 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +288 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +27 -4
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { controlDisabled, Generation, Lifetime, setControlPending } from './core.js';
|
|
2
|
+
import { iconElement, setText, uniqueId } from './dom.js';
|
|
3
|
+
export function adoptAction(node, options = {}) {
|
|
4
|
+
const life = options.onAction ? new Lifetime() : undefined;
|
|
5
|
+
const generation = options.onAction ? new Generation() : undefined;
|
|
6
|
+
let state = { disabled: node.disabled };
|
|
7
|
+
let localPending = false;
|
|
8
|
+
let disposed = false;
|
|
9
|
+
let glyph = node.querySelector(':scope > svg') ?? undefined;
|
|
10
|
+
const caption = options.caption ?? [...node.children].find((child) => child instanceof HTMLElement && child.tagName === 'SPAN');
|
|
11
|
+
const iconOnly = !caption && !!glyph && ![...node.childNodes].some(child => child.nodeType === Node.TEXT_NODE && child.textContent?.trim());
|
|
12
|
+
let iconName;
|
|
13
|
+
const update = (next) => {
|
|
14
|
+
if (disposed)
|
|
15
|
+
return;
|
|
16
|
+
state = { ...state, ...next };
|
|
17
|
+
if (next.label != null) {
|
|
18
|
+
if (caption)
|
|
19
|
+
setText(caption, next.label);
|
|
20
|
+
else if (iconOnly)
|
|
21
|
+
node.setAttribute('aria-label', next.label);
|
|
22
|
+
else
|
|
23
|
+
setText(node, next.label);
|
|
24
|
+
}
|
|
25
|
+
if (next.intent != null) {
|
|
26
|
+
for (const intent of ['neutral', 'primary', 'danger'])
|
|
27
|
+
node.classList.toggle(`pui-${intent}`, next.intent === intent);
|
|
28
|
+
}
|
|
29
|
+
if (next.density != null) {
|
|
30
|
+
node.classList.toggle('pui-normal', next.density === 'normal');
|
|
31
|
+
node.classList.toggle('pui-compact', next.density === 'compact');
|
|
32
|
+
}
|
|
33
|
+
if (next.appearance != null)
|
|
34
|
+
node.classList.toggle('pui-secondary-button', next.appearance === 'secondary');
|
|
35
|
+
// Adopted nodes keep their host-owned attributes unless explicitly updated.
|
|
36
|
+
if (next.disabled != null || next.pending != null || localPending) {
|
|
37
|
+
// A retained product action can also be pending in the application's
|
|
38
|
+
// adapter or native-copy controller. Only clear pending that we own.
|
|
39
|
+
if (state.pending != null || options.onAction)
|
|
40
|
+
setControlPending(node, !!(state.pending || localPending));
|
|
41
|
+
node.disabled = controlDisabled(node, !!(state.disabled || state.pending || localPending));
|
|
42
|
+
node.setAttribute('aria-busy', String(!!(state.pending || localPending || node.dataset.controlPending || node.dataset.copyPending)));
|
|
43
|
+
}
|
|
44
|
+
if (next.title != null)
|
|
45
|
+
node.title = next.title;
|
|
46
|
+
if (next.icon != null && iconName !== next.icon) {
|
|
47
|
+
glyph?.remove();
|
|
48
|
+
iconName = next.icon;
|
|
49
|
+
glyph = next.icon ? iconElement(next.icon) : undefined;
|
|
50
|
+
if (glyph)
|
|
51
|
+
node.prepend(glyph);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// A delegated product action has no local handler and needs no second listener.
|
|
55
|
+
if (options.onAction)
|
|
56
|
+
life.listen(node, 'click', (() => {
|
|
57
|
+
if (node.disabled || localPending || disposed)
|
|
58
|
+
return;
|
|
59
|
+
const seq = generation.next();
|
|
60
|
+
localPending = true;
|
|
61
|
+
update(state);
|
|
62
|
+
const complete = (result) => {
|
|
63
|
+
if (generation.current(seq) && result && !result.ok)
|
|
64
|
+
options.onError?.(result.error);
|
|
65
|
+
};
|
|
66
|
+
const failed = (reason) => {
|
|
67
|
+
if (generation.current(seq))
|
|
68
|
+
options.onError?.(reason instanceof Error ? reason.message : String(reason));
|
|
69
|
+
};
|
|
70
|
+
const finish = () => {
|
|
71
|
+
if (!generation.current(seq))
|
|
72
|
+
return;
|
|
73
|
+
localPending = false;
|
|
74
|
+
// Include both properties so releasing local pending can enable an action,
|
|
75
|
+
// while a newer external disabled state remains authoritative.
|
|
76
|
+
update({ ...state, disabled: !!state.disabled, pending: !!state.pending });
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
const result = options.onAction();
|
|
80
|
+
if (result && 'then' in result)
|
|
81
|
+
void result.then(complete).catch(failed).finally(finish);
|
|
82
|
+
else {
|
|
83
|
+
complete(result);
|
|
84
|
+
finish();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (reason) {
|
|
88
|
+
failed(reason);
|
|
89
|
+
finish();
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
return { element: node, update, destroy() { disposed = true; generation?.destroy(); life?.destroy(); } };
|
|
93
|
+
}
|
|
94
|
+
/** Reconcile native options by their stable value without replacing the select.
|
|
95
|
+
* Callers decide the fallback when a preferred value has disappeared.
|
|
96
|
+
*/
|
|
97
|
+
export function reconcileSelectOptions(control, entries, preferred) {
|
|
98
|
+
const selected = new Set(preferred == null ? [...control.selectedOptions].map(option => option.value) : [preferred]);
|
|
99
|
+
const existing = new Map();
|
|
100
|
+
for (const option of control.options) {
|
|
101
|
+
const group = existing.get(option.value) ?? [];
|
|
102
|
+
group.push(option);
|
|
103
|
+
existing.set(option.value, group);
|
|
104
|
+
}
|
|
105
|
+
const keep = new Set();
|
|
106
|
+
entries.forEach((entry, index) => {
|
|
107
|
+
const option = existing.get(entry.value)?.shift() ?? document.createElement('option');
|
|
108
|
+
keep.add(option);
|
|
109
|
+
if (option.value !== entry.value)
|
|
110
|
+
option.value = entry.value;
|
|
111
|
+
if (option.textContent !== entry.label)
|
|
112
|
+
option.textContent = entry.label;
|
|
113
|
+
if (option.disabled !== !!entry.disabled)
|
|
114
|
+
option.disabled = !!entry.disabled;
|
|
115
|
+
if (control.options[index] !== option)
|
|
116
|
+
control.insertBefore(option, control.options[index] ?? null);
|
|
117
|
+
});
|
|
118
|
+
for (const option of [...control.options])
|
|
119
|
+
if (!keep.has(option))
|
|
120
|
+
option.remove();
|
|
121
|
+
if (control.multiple) {
|
|
122
|
+
for (const option of control.options)
|
|
123
|
+
if (option.selected !== selected.has(option.value))
|
|
124
|
+
option.selected = selected.has(option.value);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const value = preferred ?? [...selected][0] ?? '';
|
|
128
|
+
if (control.value !== value || !selected.size)
|
|
129
|
+
control.value = value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function adoptNativeControl(control, options = {}) {
|
|
133
|
+
const life = options.onInput || options.onChange ? new Lifetime() : undefined;
|
|
134
|
+
let disposed = false;
|
|
135
|
+
const originalDescriptions = new Set((control.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean));
|
|
136
|
+
const ownedDescriptions = new Set();
|
|
137
|
+
if (options.label) {
|
|
138
|
+
if (!control.id)
|
|
139
|
+
control.id = uniqueId('pui-input');
|
|
140
|
+
options.label.htmlFor = control.id;
|
|
141
|
+
}
|
|
142
|
+
for (const node of [options.description, options.error])
|
|
143
|
+
if (node) {
|
|
144
|
+
if (!node.id)
|
|
145
|
+
node.id = uniqueId('pui-field-message');
|
|
146
|
+
ownedDescriptions.add(node.id);
|
|
147
|
+
}
|
|
148
|
+
if (options.error)
|
|
149
|
+
options.error.setAttribute('role', 'alert');
|
|
150
|
+
const update = (state) => {
|
|
151
|
+
if (disposed)
|
|
152
|
+
return;
|
|
153
|
+
if (state.label != null && options.label)
|
|
154
|
+
setText(options.label, state.label);
|
|
155
|
+
if (state.disabled != null)
|
|
156
|
+
control.disabled = state.disabled;
|
|
157
|
+
if (state.required != null)
|
|
158
|
+
control.required = state.required;
|
|
159
|
+
if (state.readOnly != null && !(control instanceof HTMLSelectElement))
|
|
160
|
+
control.readOnly = state.readOnly;
|
|
161
|
+
if (state.placeholder != null && !(control instanceof HTMLSelectElement))
|
|
162
|
+
control.placeholder = state.placeholder;
|
|
163
|
+
if (state.description != null && options.description) {
|
|
164
|
+
setText(options.description, state.description);
|
|
165
|
+
options.description.hidden = !state.description;
|
|
166
|
+
}
|
|
167
|
+
if (state.error != null) {
|
|
168
|
+
control.setAttribute('aria-invalid', String(!!state.error));
|
|
169
|
+
if (options.error) {
|
|
170
|
+
setText(options.error, state.error);
|
|
171
|
+
options.error.hidden = !state.error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (options.description || options.error) {
|
|
175
|
+
// Preserve descriptions supplied by the host or another owned component.
|
|
176
|
+
const ids = new Set([...originalDescriptions, ...(control.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean)]);
|
|
177
|
+
for (const id of ownedDescriptions)
|
|
178
|
+
ids.delete(id);
|
|
179
|
+
if (options.description && !options.description.hidden && options.description.textContent)
|
|
180
|
+
ids.add(options.description.id);
|
|
181
|
+
if (options.error && !options.error.hidden && options.error.textContent)
|
|
182
|
+
ids.add(options.error.id);
|
|
183
|
+
if (ids.size)
|
|
184
|
+
control.setAttribute('aria-describedby', [...ids].join(' '));
|
|
185
|
+
else
|
|
186
|
+
control.removeAttribute('aria-describedby');
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
if (options.onInput)
|
|
190
|
+
life.listen(control, 'input', (event => options.onInput(control.value, event)));
|
|
191
|
+
if (options.onChange)
|
|
192
|
+
life.listen(control, 'change', (event => options.onChange(control.value, event)));
|
|
193
|
+
return { element: control, update, getValue: () => control.value,
|
|
194
|
+
getChecked: () => control instanceof HTMLInputElement && control.checked,
|
|
195
|
+
reset(value) { if (disposed)
|
|
196
|
+
return; if (typeof value === 'boolean' && control instanceof HTMLInputElement)
|
|
197
|
+
control.checked = value;
|
|
198
|
+
else if (typeof value === 'string' && control.value !== value)
|
|
199
|
+
control.value = value; },
|
|
200
|
+
focus() { if (!disposed)
|
|
201
|
+
control.focus(); }, destroy() { disposed = true; life?.destroy(); } };
|
|
202
|
+
}
|
|
203
|
+
export function adoptFeedback(node, options) {
|
|
204
|
+
let disposed = false;
|
|
205
|
+
const update = (state) => {
|
|
206
|
+
if (disposed)
|
|
207
|
+
return;
|
|
208
|
+
const tone = state.tone ?? (options.presentation === 'status' ? 'neutral' : 'info');
|
|
209
|
+
if (options.presentation !== 'inline') {
|
|
210
|
+
const prefix = options.presentation === 'notice' ? 'pui-notice' : 'pui-status';
|
|
211
|
+
node.classList.add(prefix);
|
|
212
|
+
for (const value of ['info', 'neutral', 'success', 'warning', 'error'])
|
|
213
|
+
node.classList.toggle(`${prefix}-${value}`, tone === value);
|
|
214
|
+
}
|
|
215
|
+
if (options.presentation !== 'status')
|
|
216
|
+
node.setAttribute('role', tone === 'error' || tone === 'warning' ? 'alert' : 'status');
|
|
217
|
+
if (options.autoHide !== false)
|
|
218
|
+
node.hidden = !state.message;
|
|
219
|
+
setText(node, state.message);
|
|
220
|
+
};
|
|
221
|
+
return { element: node, update, destroy() { disposed = true; } };
|
|
222
|
+
}
|
|
223
|
+
export function adoptActionLayout(node, kind) {
|
|
224
|
+
let disposed = false;
|
|
225
|
+
return { element: node, update(state) {
|
|
226
|
+
if (disposed)
|
|
227
|
+
return;
|
|
228
|
+
if (state.align != null)
|
|
229
|
+
node.dataset.align = state.align;
|
|
230
|
+
if (state.density != null)
|
|
231
|
+
node.classList.toggle('pui-compact', state.density === 'compact');
|
|
232
|
+
if (state.label != null) {
|
|
233
|
+
node.setAttribute('role', 'group');
|
|
234
|
+
node.setAttribute('aria-label', state.label);
|
|
235
|
+
}
|
|
236
|
+
node.dataset.puiActionLayout = kind;
|
|
237
|
+
}, destroy() { disposed = true; } };
|
|
238
|
+
}
|
|
239
|
+
/** Owned controllers for existing product templates; not a renderer or observer.
|
|
240
|
+
* Controllers are lazy. Reconciliation prunes owned handles without rescanning
|
|
241
|
+
* long message histories or allocating a controller for every static button.
|
|
242
|
+
*/
|
|
243
|
+
export function adoptProductParts(owner) {
|
|
244
|
+
const actions = new Map();
|
|
245
|
+
const controls = new Map();
|
|
246
|
+
const feedbacks = new Map();
|
|
247
|
+
const layouts = new Map();
|
|
248
|
+
let disposed = false;
|
|
249
|
+
const action = (node) => {
|
|
250
|
+
let handle = actions.get(node);
|
|
251
|
+
if (!handle) {
|
|
252
|
+
handle = adoptAction(node);
|
|
253
|
+
if (disposed)
|
|
254
|
+
handle.destroy();
|
|
255
|
+
else
|
|
256
|
+
actions.set(node, handle);
|
|
257
|
+
}
|
|
258
|
+
return handle;
|
|
259
|
+
};
|
|
260
|
+
const control = (node) => {
|
|
261
|
+
let handle = controls.get(node);
|
|
262
|
+
if (!handle) {
|
|
263
|
+
handle = adoptNativeControl(node);
|
|
264
|
+
if (disposed)
|
|
265
|
+
handle.destroy();
|
|
266
|
+
else
|
|
267
|
+
controls.set(node, handle);
|
|
268
|
+
}
|
|
269
|
+
return handle;
|
|
270
|
+
};
|
|
271
|
+
const feedback = (node) => {
|
|
272
|
+
let handle = feedbacks.get(node);
|
|
273
|
+
if (!handle) {
|
|
274
|
+
handle = adoptFeedback(node, { presentation: 'inline', autoHide: false });
|
|
275
|
+
if (disposed)
|
|
276
|
+
handle.destroy();
|
|
277
|
+
else
|
|
278
|
+
feedbacks.set(node, handle);
|
|
279
|
+
}
|
|
280
|
+
return handle;
|
|
281
|
+
};
|
|
282
|
+
const layout = (node, kind) => {
|
|
283
|
+
let handle = layouts.get(node);
|
|
284
|
+
if (!handle) {
|
|
285
|
+
handle = adoptActionLayout(node, kind);
|
|
286
|
+
if (disposed)
|
|
287
|
+
handle.destroy();
|
|
288
|
+
else
|
|
289
|
+
layouts.set(node, handle);
|
|
290
|
+
}
|
|
291
|
+
return handle;
|
|
292
|
+
};
|
|
293
|
+
const update = () => {
|
|
294
|
+
if (disposed)
|
|
295
|
+
return;
|
|
296
|
+
for (const map of [actions, controls, feedbacks, layouts])
|
|
297
|
+
for (const [node, handle] of map) {
|
|
298
|
+
if (!owner.contains(node) && node !== owner) {
|
|
299
|
+
handle.destroy();
|
|
300
|
+
map.delete(node);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
return { update, action, control, feedback, layout, destroy() {
|
|
305
|
+
if (disposed)
|
|
306
|
+
return;
|
|
307
|
+
disposed = true;
|
|
308
|
+
for (const map of [actions, controls, feedbacks, layouts]) {
|
|
309
|
+
for (const handle of map.values())
|
|
310
|
+
handle.destroy();
|
|
311
|
+
map.clear();
|
|
312
|
+
}
|
|
313
|
+
} };
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=foundations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundations.js","sourceRoot":"","sources":["../src/foundations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE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AAC;oBAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBAAC,GAAG,CAAC,MAAM,CAAC,IAAa,CAAC,CAAC;gBAAC,CAAC;YAC/F,CAAC;IACH,CAAC,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO;YACzD,IAAI,QAAQ;gBAAE,OAAO;YAAC,QAAQ,GAAG,IAAI,CAAC;YACtC,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;gBAAC,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE;oBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;QAClI,CAAC,EAAE,CAAC;AACN,CAAC","sourcesContent":["import { controlDisabled, Generation, Lifetime, setControlPending } from './core.js';\nimport type { ActionResult, Density, Intent, UIAction } from './core.js';\nimport { iconElement, setText, uniqueId } from './dom.js';\n\n/** Private controllers shared by factories and the retained product templates.\n * Adoption does not replace nodes, move controls or infer business availability.\n */\nexport interface ActionState {\n label?: string;\n intent?: Intent;\n density?: Density;\n disabled?: boolean;\n pending?: boolean;\n icon?: string;\n title?: string;\n appearance?: 'standard' | 'secondary';\n}\nexport interface ActionController {\n readonly element: HTMLButtonElement;\n update(state: Readonly<ActionState>): void;\n destroy(): void;\n}\nexport function adoptAction(node: HTMLButtonElement, options: {\n caption?: HTMLElement;\n onAction?: UIAction;\n onError?: (message: string) => void;\n} = {}): ActionController {\n const life = options.onAction ? new Lifetime() : undefined;\n const generation = options.onAction ? new Generation() : undefined;\n let state: ActionState = { disabled: node.disabled };\n let localPending = false; let disposed = false;\n let glyph = node.querySelector<SVGSVGElement>(':scope > svg') ?? undefined;\n const caption = options.caption ?? [...node.children].find((child): child is HTMLElement => child instanceof HTMLElement && child.tagName === 'SPAN');\n const iconOnly = !caption && !!glyph && ![...node.childNodes].some(child => child.nodeType === Node.TEXT_NODE && child.textContent?.trim());\n let iconName: string | undefined;\n const update = (next: Readonly<ActionState>): void => {\n if (disposed) return;\n state = { ...state, ...next };\n if (next.label != null) {\n if (caption) setText(caption, next.label);\n else if (iconOnly) node.setAttribute('aria-label', next.label);\n else setText(node, next.label);\n }\n if (next.intent != null) {\n for (const intent of ['neutral', 'primary', 'danger']) node.classList.toggle(`pui-${intent}`, next.intent === intent);\n }\n if (next.density != null) {\n node.classList.toggle('pui-normal', next.density === 'normal');\n node.classList.toggle('pui-compact', next.density === 'compact');\n }\n if (next.appearance != null) node.classList.toggle('pui-secondary-button', next.appearance === 'secondary');\n // Adopted nodes keep their host-owned attributes unless explicitly updated.\n if (next.disabled != null || next.pending != null || localPending) {\n // A retained product action can also be pending in the application's\n // adapter or native-copy controller. Only clear pending that we own.\n if (state.pending != null || options.onAction) setControlPending(node, !!(state.pending || localPending));\n node.disabled = controlDisabled(node, !!(state.disabled || state.pending || localPending));\n node.setAttribute('aria-busy', String(!!(state.pending || localPending || node.dataset.controlPending || node.dataset.copyPending)));\n }\n if (next.title != null) node.title = next.title;\n if (next.icon != null && iconName !== next.icon) {\n glyph?.remove(); iconName = next.icon;\n glyph = next.icon ? iconElement(next.icon) : undefined;\n if (glyph) node.prepend(glyph);\n }\n };\n // A delegated product action has no local handler and needs no second listener.\n if (options.onAction) life!.listen(node, 'click', (() => {\n if (node.disabled || localPending || disposed) return;\n const seq = generation!.next(); localPending = true; update(state);\n const complete = (result: void | ActionResult): void => {\n if (generation!.current(seq) && result && !result.ok) options.onError?.(result.error);\n };\n const failed = (reason: unknown): void => {\n if (generation!.current(seq)) options.onError?.(reason instanceof Error ? reason.message : String(reason));\n };\n const finish = (): void => {\n if (!generation!.current(seq)) return;\n localPending = false;\n // Include both properties so releasing local pending can enable an action,\n // while a newer external disabled state remains authoritative.\n update({ ...state, disabled: !!state.disabled, pending: !!state.pending });\n };\n try {\n const result = options.onAction!();\n if (result && 'then' in result) void result.then(complete).catch(failed).finally(finish);\n else { complete(result); finish(); }\n } catch (reason) { failed(reason); finish(); }\n }) as EventListener);\n return { element: node, update, destroy() { disposed = true; generation?.destroy(); life?.destroy(); } };\n}\n\nexport type NativeControl = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\nexport interface NativeSelectOption { value: string; label: string; disabled?: boolean; }\n/** Reconcile native options by their stable value without replacing the select.\n * Callers decide the fallback when a preferred value has disappeared.\n */\nexport function reconcileSelectOptions(control: HTMLSelectElement, entries: readonly NativeSelectOption[], preferred?: string): void {\n const selected = new Set(preferred == null ? [...control.selectedOptions].map(option => option.value) : [preferred]);\n const existing = new Map<string, HTMLOptionElement[]>();\n for (const option of control.options) { const group = existing.get(option.value) ?? []; group.push(option); existing.set(option.value, group); }\n const keep = new Set<HTMLOptionElement>();\n entries.forEach((entry, index) => {\n const option = existing.get(entry.value)?.shift() ?? document.createElement('option');\n keep.add(option);\n if (option.value !== entry.value) option.value = entry.value;\n if (option.textContent !== entry.label) option.textContent = entry.label;\n if (option.disabled !== !!entry.disabled) option.disabled = !!entry.disabled;\n if (control.options[index] !== option) control.insertBefore(option, control.options[index] ?? null);\n });\n for (const option of [...control.options]) if (!keep.has(option)) option.remove();\n if (control.multiple) {\n for (const option of control.options) if (option.selected !== selected.has(option.value)) option.selected = selected.has(option.value);\n } else {\n const value = preferred ?? [...selected][0] ?? '';\n if (control.value !== value || !selected.size) control.value = value;\n }\n}\nexport interface NativeControlState {\n label?: string;\n description?: string;\n error?: string;\n disabled?: boolean;\n required?: boolean;\n readOnly?: boolean;\n placeholder?: string;\n}\nexport interface NativeControlController {\n readonly element: NativeControl;\n update(state: Readonly<NativeControlState>): void;\n getValue(): string;\n getChecked(): boolean;\n reset(value: string | boolean): void;\n focus(): void;\n destroy(): void;\n}\nexport function adoptNativeControl(control: NativeControl, options: {\n label?: HTMLLabelElement;\n description?: HTMLElement;\n error?: HTMLElement;\n onInput?: (value: string, event: Event) => void;\n onChange?: (value: string, event: Event) => void;\n} = {}): NativeControlController {\n const life = options.onInput || options.onChange ? new Lifetime() : undefined; let disposed = false;\n const originalDescriptions = new Set((control.getAttribute('aria-describedby') ?? '').split(/\\s+/).filter(Boolean));\n const ownedDescriptions = new Set<string>();\n if (options.label) {\n if (!control.id) control.id = uniqueId('pui-input');\n options.label.htmlFor = control.id;\n }\n for (const node of [options.description, options.error]) if (node) {\n if (!node.id) node.id = uniqueId('pui-field-message');\n ownedDescriptions.add(node.id);\n }\n if (options.error) options.error.setAttribute('role', 'alert');\n const update = (state: Readonly<NativeControlState>): void => {\n if (disposed) return;\n if (state.label != null && options.label) setText(options.label, state.label);\n if (state.disabled != null) control.disabled = state.disabled;\n if (state.required != null) control.required = state.required;\n if (state.readOnly != null && !(control instanceof HTMLSelectElement)) control.readOnly = state.readOnly;\n if (state.placeholder != null && !(control instanceof HTMLSelectElement)) control.placeholder = state.placeholder;\n if (state.description != null && options.description) {\n setText(options.description, state.description); options.description.hidden = !state.description;\n }\n if (state.error != null) {\n control.setAttribute('aria-invalid', String(!!state.error));\n if (options.error) { setText(options.error, state.error); options.error.hidden = !state.error; }\n }\n if (options.description || options.error) {\n // Preserve descriptions supplied by the host or another owned component.\n const ids = new Set([...originalDescriptions, ...(control.getAttribute('aria-describedby') ?? '').split(/\\s+/).filter(Boolean)]);\n for (const id of ownedDescriptions) ids.delete(id);\n if (options.description && !options.description.hidden && options.description.textContent) ids.add(options.description.id);\n if (options.error && !options.error.hidden && options.error.textContent) ids.add(options.error.id);\n if (ids.size) control.setAttribute('aria-describedby', [...ids].join(' ')); else control.removeAttribute('aria-describedby');\n }\n };\n if (options.onInput) life!.listen(control, 'input', (event => options.onInput!(control.value, event)) as EventListener);\n if (options.onChange) life!.listen(control, 'change', (event => options.onChange!(control.value, event)) as EventListener);\n return { element: control, update, getValue: () => control.value,\n getChecked: () => control instanceof HTMLInputElement && control.checked,\n reset(value) { if (disposed) return; if (typeof value === 'boolean' && control instanceof HTMLInputElement) control.checked = value; else if (typeof value === 'string' && control.value !== value) control.value = value; },\n focus() { if (!disposed) control.focus(); }, destroy() { disposed = true; life?.destroy(); } };\n}\n\nexport interface FeedbackState { message: string; tone?: 'info' | 'neutral' | 'success' | 'warning' | 'error'; }\nexport interface FeedbackController {\n readonly element: HTMLElement;\n update(state: Readonly<FeedbackState>): void;\n destroy(): void;\n}\nexport function adoptFeedback(node: HTMLElement, options: {\n presentation: 'notice' | 'inline' | 'status';\n autoHide?: boolean;\n}): FeedbackController {\n let disposed = false;\n const update = (state: Readonly<FeedbackState>): void => {\n if (disposed) return;\n const tone = state.tone ?? (options.presentation === 'status' ? 'neutral' : 'info');\n if (options.presentation !== 'inline') {\n const prefix = options.presentation === 'notice' ? 'pui-notice' : 'pui-status';\n node.classList.add(prefix);\n for (const value of ['info', 'neutral', 'success', 'warning', 'error']) node.classList.toggle(`${prefix}-${value}`, tone === value);\n }\n if (options.presentation !== 'status') node.setAttribute('role', tone === 'error' || tone === 'warning' ? 'alert' : 'status');\n if (options.autoHide !== false) node.hidden = !state.message;\n setText(node, state.message);\n };\n return { element: node, update, destroy() { disposed = true; } };\n}\n\nexport interface ActionLayoutState { align?: 'start' | 'end' | 'between'; density?: Density; label?: string; }\nexport function adoptActionLayout(node: HTMLElement, kind: 'actions' | 'toolbar'): {\n readonly element: HTMLElement;\n update(state: Readonly<ActionLayoutState>): void;\n destroy(): void;\n} {\n let disposed = false;\n return { element: node, update(state) {\n if (disposed) return;\n if (state.align != null) node.dataset.align = state.align;\n if (state.density != null) node.classList.toggle('pui-compact', state.density === 'compact');\n if (state.label != null) { node.setAttribute('role', 'group'); node.setAttribute('aria-label', state.label); }\n node.dataset.puiActionLayout = kind;\n }, destroy() { disposed = true; } };\n}\n\n/** Owned controllers for existing product templates; not a renderer or observer.\n * Controllers are lazy. Reconciliation prunes owned handles without rescanning\n * long message histories or allocating a controller for every static button.\n */\nexport function adoptProductParts(owner: HTMLElement): {\n update(): void;\n action(node: HTMLButtonElement): ActionController;\n control(node: NativeControl): NativeControlController;\n feedback(node: HTMLElement): FeedbackController;\n layout(node: HTMLElement, kind: 'actions' | 'toolbar'): ReturnType<typeof adoptActionLayout>;\n destroy(): void;\n} {\n const actions = new Map<HTMLButtonElement, ActionController>();\n const controls = new Map<NativeControl, NativeControlController>();\n const feedbacks = new Map<HTMLElement, FeedbackController>();\n const layouts = new Map<HTMLElement, ReturnType<typeof adoptActionLayout>>();\n let disposed = false;\n const action = (node: HTMLButtonElement): ActionController => {\n let handle = actions.get(node); if (!handle) { handle = adoptAction(node); if (disposed) handle.destroy(); else actions.set(node, handle); } return handle;\n };\n const control = (node: NativeControl): NativeControlController => {\n let handle = controls.get(node); if (!handle) { handle = adoptNativeControl(node); if (disposed) handle.destroy(); else controls.set(node, handle); } return handle;\n };\n const feedback = (node: HTMLElement): FeedbackController => {\n let handle = feedbacks.get(node); if (!handle) { handle = adoptFeedback(node, { presentation: 'inline', autoHide: false }); if (disposed) handle.destroy(); else feedbacks.set(node, handle); } return handle;\n };\n const layout = (node: HTMLElement, kind: 'actions' | 'toolbar'): ReturnType<typeof adoptActionLayout> => {\n let handle = layouts.get(node); if (!handle) { handle = adoptActionLayout(node, kind); if (disposed) handle.destroy(); else layouts.set(node, handle); } return handle;\n };\n const update = (): void => {\n if (disposed) return;\n for (const map of [actions, controls, feedbacks, layouts]) for (const [node, handle] of map) {\n if (!owner.contains(node) && node !== owner) { handle.destroy(); map.delete(node as never); }\n }\n };\n return { update, action, control, feedback, layout, destroy() {\n if (disposed) return; disposed = true;\n for (const map of [actions, controls, feedbacks, layouts]) { for (const handle of map.values()) handle.destroy(); map.clear(); }\n } };\n}\n\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from './core.js';
|
|
2
|
+
export * from './dom.js';
|
|
3
|
+
export * from './primitives.js';
|
|
4
|
+
export * from './theme.js';
|
|
5
|
+
export * from './workspace.js';
|
|
6
|
+
export * from './composer.js';
|
|
7
|
+
export * from './content/markdown.js';
|
|
8
|
+
export * from './content/conversation-reader.js';
|
|
9
|
+
export * from './content/conversation-view.js';
|
|
10
|
+
export * from './content/paged-preview.js';
|
|
11
|
+
export * from './content/image-viewer.js';
|
|
12
|
+
export * from './content/welcome.js';
|
|
13
|
+
export * from './forms/panels.js';
|
|
14
|
+
export * from './forms/model-editor.js';
|
|
15
|
+
export * from './forms/custom-connection.js';
|
|
16
|
+
export * from './forms/resource-editor.js';
|
|
17
|
+
export * from './forms/history.js';
|
|
18
|
+
export * from './forms/provider-login.js';
|
|
19
|
+
export * from './forms/dialog-frame.js';
|
|
20
|
+
export * from './forms/actions.js';
|
|
21
|
+
export * from './files/panels.js';
|
|
22
|
+
export * from './files/systems.js';
|
|
23
|
+
export * from './navigation/navigation.js';
|
|
24
|
+
export * from './navigation/context-menu.js';
|
|
25
|
+
export * from './tasks/approval.js';
|
|
26
|
+
export * from './tasks/permission.js';
|
|
27
|
+
export * from './tasks/runtime.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from './core.js';
|
|
2
|
+
export * from './dom.js';
|
|
3
|
+
export * from './primitives.js';
|
|
4
|
+
export * from './theme.js';
|
|
5
|
+
export * from './workspace.js';
|
|
6
|
+
export * from './composer.js';
|
|
7
|
+
export * from './content/markdown.js';
|
|
8
|
+
export * from './content/conversation-reader.js';
|
|
9
|
+
export * from './content/conversation-view.js';
|
|
10
|
+
export * from './content/paged-preview.js';
|
|
11
|
+
export * from './content/image-viewer.js';
|
|
12
|
+
export * from './content/welcome.js';
|
|
13
|
+
export * from './forms/panels.js';
|
|
14
|
+
export * from './forms/model-editor.js';
|
|
15
|
+
export * from './forms/custom-connection.js';
|
|
16
|
+
export * from './forms/resource-editor.js';
|
|
17
|
+
export * from './forms/history.js';
|
|
18
|
+
export * from './forms/provider-login.js';
|
|
19
|
+
export * from './forms/dialog-frame.js';
|
|
20
|
+
export * from './forms/actions.js';
|
|
21
|
+
export * from './files/panels.js';
|
|
22
|
+
export * from './files/systems.js';
|
|
23
|
+
export * from './navigation/navigation.js';
|
|
24
|
+
export * from './navigation/context-menu.js';
|
|
25
|
+
export * from './tasks/approval.js';
|
|
26
|
+
export * from './tasks/permission.js';
|
|
27
|
+
export * from './tasks/runtime.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './core.js';\nexport * from './dom.js';\nexport * from './primitives.js';\nexport * from './theme.js';\nexport * from './workspace.js';\nexport * from './composer.js';\nexport * from './content/markdown.js';\nexport * from './content/conversation-reader.js';\nexport * from './content/conversation-view.js';\nexport * from './content/paged-preview.js';\nexport * from './content/image-viewer.js';\nexport * from './content/welcome.js';\nexport * from './forms/panels.js';\nexport * from './forms/model-editor.js';\nexport * from './forms/custom-connection.js';\nexport * from './forms/resource-editor.js';\nexport * from './forms/history.js';\nexport * from './forms/provider-login.js';\nexport * from './forms/dialog-frame.js';\nexport * from './forms/actions.js';\nexport * from './files/panels.js';\nexport * from './files/systems.js';\nexport * from './navigation/navigation.js';\nexport * from './navigation/context-menu.js';\nexport * from './tasks/approval.js';\nexport * from './tasks/permission.js';\nexport * from './tasks/runtime.js';\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UIBlock } from '../core.js';
|
|
2
|
+
export interface ContextMenuItem {
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
action?: string;
|
|
6
|
+
sdkAction?: string;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
idle?: {
|
|
10
|
+
conversationId?: string;
|
|
11
|
+
workspaceId?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ContextMenuState {
|
|
15
|
+
label: string;
|
|
16
|
+
items: readonly ContextMenuItem[];
|
|
17
|
+
}
|
|
18
|
+
export declare function createContextMenu(options?: {
|
|
19
|
+
element?: HTMLElement;
|
|
20
|
+
onDismiss?: (restoreFocus: boolean) => void;
|
|
21
|
+
onAction?: (item: ContextMenuItem) => void;
|
|
22
|
+
}): UIBlock<ContextMenuState> & {
|
|
23
|
+
open(trigger: HTMLElement, state: ContextMenuState): void;
|
|
24
|
+
close(restoreFocus?: boolean): void;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=context-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/navigation/context-menu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACtG,IAAI,CAAC,EAAE;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CACxD;AACD,MAAM,WAAW,gBAAgB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAA;CAAC;AACpF,wBAAgB,iBAAiB,CAAC,OAAO,GAAE;IAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;CAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG;IAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAC,CAkC9R"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { installMenuNavigation } from '../surface.js';
|
|
2
|
+
import { adoptProductParts } from '../foundations.js';
|
|
3
|
+
export function createContextMenu(options = {}) {
|
|
4
|
+
const element = options.element || document.createElement('div');
|
|
5
|
+
if (!options.element) {
|
|
6
|
+
element.className = 'pui-sidebar-conversation-menu pui-context-menu';
|
|
7
|
+
element.setAttribute('role', 'menu');
|
|
8
|
+
element.hidden = true;
|
|
9
|
+
}
|
|
10
|
+
const abort = new AbortController();
|
|
11
|
+
let trigger = null;
|
|
12
|
+
let destroyed = false;
|
|
13
|
+
const parts = adoptProductParts(element);
|
|
14
|
+
const rows = new Map();
|
|
15
|
+
const actions = new Map();
|
|
16
|
+
const close = (restoreFocus = false) => { element.hidden = true; trigger?.setAttribute('aria-expanded', 'false'); if (restoreFocus)
|
|
17
|
+
trigger?.focus(); trigger = null; };
|
|
18
|
+
const dismiss = (restoreFocus) => { close(restoreFocus); options.onDismiss?.(restoreFocus); };
|
|
19
|
+
const navigation = installMenuNavigation(element, { onDismiss: dismiss, isOpen: () => !element.hidden, closeOnOutside: true, contains: target => !!trigger?.contains(target) });
|
|
20
|
+
const update = (state) => {
|
|
21
|
+
if (destroyed)
|
|
22
|
+
return;
|
|
23
|
+
element.setAttribute('aria-label', state.label);
|
|
24
|
+
const keep = new Set();
|
|
25
|
+
let cursor = element.firstElementChild;
|
|
26
|
+
for (const [index, item] of state.items.entries()) {
|
|
27
|
+
const key = item.id ?? `${item.action || ''}/${item.sdkAction || ''}/${index}`;
|
|
28
|
+
keep.add(key);
|
|
29
|
+
let button = rows.get(key);
|
|
30
|
+
if (!button) {
|
|
31
|
+
button = document.createElement('button');
|
|
32
|
+
button.type = 'button';
|
|
33
|
+
button.setAttribute('role', 'menuitem');
|
|
34
|
+
rows.set(key, button);
|
|
35
|
+
}
|
|
36
|
+
parts.action(button).update({ label: item.label, disabled: !!item.disabled });
|
|
37
|
+
button.classList.toggle('pui-destructive-menu-item', !!item.danger);
|
|
38
|
+
if (item.action)
|
|
39
|
+
button.dataset.action = item.action;
|
|
40
|
+
else
|
|
41
|
+
delete button.dataset.action;
|
|
42
|
+
if (item.sdkAction)
|
|
43
|
+
button.dataset.sdk = item.sdkAction;
|
|
44
|
+
else
|
|
45
|
+
delete button.dataset.sdk;
|
|
46
|
+
for (const name of ['idleAction', 'idleConversation', 'idleWorkspace'])
|
|
47
|
+
delete button.dataset[name];
|
|
48
|
+
if (item.idle) {
|
|
49
|
+
button.dataset.idleAction = '';
|
|
50
|
+
if (item.idle.conversationId)
|
|
51
|
+
button.dataset.idleConversation = item.idle.conversationId;
|
|
52
|
+
if (item.idle.workspaceId)
|
|
53
|
+
button.dataset.idleWorkspace = item.idle.workspaceId;
|
|
54
|
+
}
|
|
55
|
+
actions.set(button, item);
|
|
56
|
+
if (cursor !== button)
|
|
57
|
+
element.insertBefore(button, cursor);
|
|
58
|
+
cursor = button.nextElementSibling;
|
|
59
|
+
}
|
|
60
|
+
for (const [key, button] of rows)
|
|
61
|
+
if (!keep.has(key)) {
|
|
62
|
+
button.remove();
|
|
63
|
+
rows.delete(key);
|
|
64
|
+
actions.delete(button);
|
|
65
|
+
}
|
|
66
|
+
parts.update();
|
|
67
|
+
};
|
|
68
|
+
if (options.onAction)
|
|
69
|
+
element.addEventListener('click', event => { const button = event.target.closest('button'); const item = button ? actions.get(button) : undefined; if (item && !button.disabled)
|
|
70
|
+
options.onAction(item); }, { signal: abort.signal });
|
|
71
|
+
const onScroll = (event) => { if (!element.hidden && event.target instanceof Node && !element.contains(event.target))
|
|
72
|
+
dismiss(false); };
|
|
73
|
+
document.addEventListener('scroll', onScroll, { capture: true, passive: true, signal: abort.signal });
|
|
74
|
+
window.addEventListener('resize', () => { if (!element.hidden)
|
|
75
|
+
dismiss(false); }, { signal: abort.signal });
|
|
76
|
+
return { element, update, close, open(source, state) { if (destroyed)
|
|
77
|
+
return; close(); trigger = source; trigger.setAttribute('aria-expanded', 'true'); update(state); element.hidden = false; const rect = source.getBoundingClientRect(); element.style.left = `${Math.max(8, Math.min(rect.right, window.innerWidth - element.offsetWidth - 8))}px`; element.style.top = `${Math.max(8, Math.min(rect.bottom + 4, window.innerHeight - element.offsetHeight - 8))}px`; navigation.focus(); }, destroy() { if (destroyed)
|
|
78
|
+
return; destroyed = true; close(); navigation.destroy(); abort.abort(); parts.destroy(); rows.clear(); actions.clear(); if (!options.element)
|
|
79
|
+
element.remove(); } };
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=context-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../../src/navigation/context-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAMtD,MAAM,UAAU,iBAAiB,CAAC,UAA4H,EAAE;IAC9J,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,gDAAgD,CAAC;QAAC,OAAO,CAAC,YAAY,C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GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAA,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;AAC5pB,CAAC","sourcesContent":["import type { UIBlock } from '../core.js';\nimport { installMenuNavigation } from '../surface.js';\nimport { adoptProductParts } from '../foundations.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 function createContextMenu(options: {element?: HTMLElement; onDismiss?: (restoreFocus: boolean) => void; onAction?: (item: ContextMenuItem) => void} = {}): UIBlock<ContextMenuState> & {open(trigger: HTMLElement, state: ContextMenuState): 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 const abort = new AbortController(); let trigger: HTMLElement | null = null; let destroyed = false;\n const parts = adoptProductParts(element);\n const rows = new Map<string, HTMLButtonElement>();\n const actions = new Map<HTMLButtonElement, ContextMenuItem>();\n const close = (restoreFocus = false) => {element.hidden = true; trigger?.setAttribute('aria-expanded', 'false'); if (restoreFocus) trigger?.focus(); trigger = null;};\n const dismiss = (restoreFocus: boolean) => {close(restoreFocus); options.onDismiss?.(restoreFocus);};\n const navigation = installMenuNavigation(element, {onDismiss: dismiss, isOpen: () => !element.hidden, closeOnOutside: true, contains: target => !!trigger?.contains(target)});\n const update = (state: Readonly<ContextMenuState>) => {\n if (destroyed) return; element.setAttribute('aria-label', state.label);\n const keep = new Set<string>(); let cursor = element.firstElementChild;\n for (const [index, item] of state.items.entries()) {\n const key = item.id ?? `${item.action || ''}/${item.sdkAction || ''}/${index}`; keep.add(key);\n let button = rows.get(key);\n if (!button) {button = document.createElement('button'); button.type = 'button'; button.setAttribute('role', 'menuitem'); rows.set(key, button);}\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 if (cursor !== button) element.insertBefore(button, cursor); cursor = button.nextElementSibling;\n }\n for (const [key, button] of rows) if (!keep.has(key)) {button.remove(); rows.delete(key); actions.delete(button);}\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) options.onAction!(item);}, {signal: abort.signal});\n const onScroll = (event: Event) => {if (!element.hidden && event.target instanceof Node && !element.contains(event.target)) dismiss(false);};\n document.addEventListener('scroll', onScroll, {capture: true, passive: true, signal: abort.signal});\n window.addEventListener('resize', () => {if (!element.hidden) dismiss(false);}, {signal: abort.signal});\n return {element, update, close, open(source, state) {if (destroyed) return; close(); trigger = source; trigger.setAttribute('aria-expanded', 'true'); update(state); element.hidden = false; const rect = source.getBoundingClientRect(); element.style.left = `${Math.max(8, Math.min(rect.right, window.innerWidth - element.offsetWidth - 8))}px`; element.style.top = `${Math.max(8, Math.min(rect.bottom + 4, window.innerHeight - element.offsetHeight - 8))}px`; navigation.focus();}, destroy() {if (destroyed) return; destroyed = true; close(); navigation.destroy(); abort.abort(); parts.destroy(); rows.clear(); actions.clear(); if (!options.element) element.remove();}};\n}\n"]}
|