@getcliqio/hug-frontend 0.0.0-stage → 1.15.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/base_css.d.ts +6 -0
- package/dist/base_css.d.ts.map +1 -0
- package/dist/base_css.js +28 -0
- package/dist/base_css.js.map +1 -0
- package/dist/build.d.ts +45 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +44 -0
- package/dist/build.js.map +1 -0
- package/dist/current.d.ts +10 -0
- package/dist/current.d.ts.map +1 -0
- package/dist/current.js +14 -0
- package/dist/current.js.map +1 -0
- package/dist/define.d.ts +12 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +9 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +137 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +368 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mount.d.ts +64 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +106 -0
- package/dist/mount.js.map +1 -0
- package/dist/paths.d.ts +12 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +42 -0
- package/dist/paths.js.map +1 -0
- package/dist/react.d.ts +63 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +149 -0
- package/dist/react.js.map +1 -0
- package/dist/runtime.d.ts +140 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +284 -0
- package/dist/runtime.js.map +1 -0
- package/dist/shared/bridge/index.d.ts +16 -0
- package/dist/shared/bridge/index.d.ts.map +1 -0
- package/dist/shared/bridge/index.js +14 -0
- package/dist/shared/bridge/index.js.map +1 -0
- package/dist/shared/bridge/messages.d.ts +559 -0
- package/dist/shared/bridge/messages.d.ts.map +1 -0
- package/dist/shared/bridge/messages.js +166 -0
- package/dist/shared/bridge/messages.js.map +1 -0
- package/dist/shared/context.d.ts +54 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/context.js +28 -0
- package/dist/shared/context.js.map +1 -0
- package/dist/shared/define.d.ts +116 -0
- package/dist/shared/define.d.ts.map +1 -0
- package/dist/shared/define.js +120 -0
- package/dist/shared/define.js.map +1 -0
- package/dist/shared/definitions/approval.d.ts +216 -0
- package/dist/shared/definitions/approval.d.ts.map +1 -0
- package/dist/shared/definitions/approval.js +51 -0
- package/dist/shared/definitions/approval.js.map +1 -0
- package/dist/shared/definitions/common.d.ts +122 -0
- package/dist/shared/definitions/common.d.ts.map +1 -0
- package/dist/shared/definitions/common.js +71 -0
- package/dist/shared/definitions/common.js.map +1 -0
- package/dist/shared/definitions/form.d.ts +197 -0
- package/dist/shared/definitions/form.d.ts.map +1 -0
- package/dist/shared/definitions/form.js +30 -0
- package/dist/shared/definitions/form.js.map +1 -0
- package/dist/shared/definitions/index.d.ts +10 -0
- package/dist/shared/definitions/index.d.ts.map +1 -0
- package/dist/shared/definitions/index.js +9 -0
- package/dist/shared/definitions/index.js.map +1 -0
- package/dist/shared/problems.d.ts +35 -0
- package/dist/shared/problems.d.ts.map +1 -0
- package/dist/shared/problems.js +54 -0
- package/dist/shared/problems.js.map +1 -0
- package/dist/shared/requested_inputs.d.ts +190 -0
- package/dist/shared/requested_inputs.d.ts.map +1 -0
- package/dist/shared/requested_inputs.js +221 -0
- package/dist/shared/requested_inputs.js.map +1 -0
- package/dist/shared/schema_for_inputs.d.ts +20 -0
- package/dist/shared/schema_for_inputs.d.ts.map +1 -0
- package/dist/shared/schema_for_inputs.js +96 -0
- package/dist/shared/schema_for_inputs.js.map +1 -0
- package/dist/state.d.ts +58 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +124 -0
- package/dist/state.js.map +1 -0
- package/dist/testing.d.ts +96 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +156 -0
- package/dist/testing.js.map +1 -0
- package/dist/theme.d.ts +15 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +18 -0
- package/dist/theme.js.map +1 -0
- package/dist/transport.d.ts +19 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +21 -0
- package/dist/transport.js.map +1 -0
- package/dist/ui/base.d.ts +33 -0
- package/dist/ui/base.d.ts.map +1 -0
- package/dist/ui/base.js +99 -0
- package/dist/ui/base.js.map +1 -0
- package/dist/ui/choices.d.ts +46 -0
- package/dist/ui/choices.d.ts.map +1 -0
- package/dist/ui/choices.js +121 -0
- package/dist/ui/choices.js.map +1 -0
- package/dist/ui/fields.d.ts +46 -0
- package/dist/ui/fields.d.ts.map +1 -0
- package/dist/ui/fields.js +169 -0
- package/dist/ui/fields.js.map +1 -0
- package/dist/ui/files.d.ts +80 -0
- package/dist/ui/files.d.ts.map +1 -0
- package/dist/ui/files.js +342 -0
- package/dist/ui/files.js.map +1 -0
- package/dist/ui/fonts.css +7 -0
- package/dist/ui/fonts_css.d.ts +3 -0
- package/dist/ui/fonts_css.d.ts.map +1 -0
- package/dist/ui/fonts_css.js +4 -0
- package/dist/ui/fonts_css.js.map +1 -0
- package/dist/ui/index.d.ts +24 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +32 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/markdown.d.ts +46 -0
- package/dist/ui/markdown.d.ts.map +1 -0
- package/dist/ui/markdown.js +318 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/view.d.ts +49 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +136 -0
- package/dist/view.js.map +1 -0
- package/dist/zod_config.d.ts +2 -0
- package/dist/zod_config.d.ts.map +1 -0
- package/dist/zod_config.js +10 -0
- package/dist/zod_config.js.map +1 -0
- package/fonts/LICENSE.txt +92 -0
- package/package.json +82 -5
package/dist/ui/files.js
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files in the UI kit: `<cliq-attachment .ref=…>` (one file: name, type and size, an inline preview of text, Markdown
|
|
3
|
+
* and images, download) and
|
|
4
|
+
* `<cliq-file key="evidence">` (an upload slot: the host's picker through `upload`, the uploaded files, remove).
|
|
5
|
+
* Both reach files only through the runtime (`current_hug`).
|
|
6
|
+
*/
|
|
7
|
+
import { html, nothing, svg } from 'lit-html';
|
|
8
|
+
import { current_hug } from '../current.js';
|
|
9
|
+
import { HugError } from '../errors.js';
|
|
10
|
+
import { format_bytes } from '../view.js';
|
|
11
|
+
import { define_element, KitElement, reactive } from './base.js';
|
|
12
|
+
const ATTACHMENT_CSS = `
|
|
13
|
+
:host { display: block; max-width: 100%; }
|
|
14
|
+
.row { display: flex; gap: 10px; align-items: center; border: 1px solid var(--cliq-line, rgba(127,127,127,.3)); border-radius: var(--cliq-radius, 6px); padding: 6px 6px 6px 10px; }
|
|
15
|
+
.row.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
|
|
16
|
+
.what { flex: 1; min-width: 0; }
|
|
17
|
+
.name { font-weight: 500; font-size: 13px; overflow-wrap: anywhere; }
|
|
18
|
+
.meta { font-size: 11.5px; }
|
|
19
|
+
.thumb { width: 36px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--cliq-line, rgba(127,127,127,.3)); }
|
|
20
|
+
.actions { display: flex; gap: 2px; }
|
|
21
|
+
.icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
|
|
22
|
+
background: transparent; border: 0; border-radius: var(--cliq-radius, 6px); color: var(--cliq-ink-2, inherit); }
|
|
23
|
+
.icon:hover { background: var(--cliq-line, rgba(127,127,127,.2)); color: var(--cliq-ink, inherit); }
|
|
24
|
+
.icon[aria-expanded=true] { color: var(--cliq-acc, LinkText); }
|
|
25
|
+
.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
|
|
26
|
+
.panel { border: 1px solid var(--cliq-line, rgba(127,127,127,.3)); border-top: 0; border-radius: 0 0 var(--cliq-radius, 6px) var(--cliq-radius, 6px);
|
|
27
|
+
padding: 8px 12px; background: var(--cliq-bg, transparent); }
|
|
28
|
+
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--cliq-ink-2, inherit); }
|
|
29
|
+
.panel img { display: block; max-width: 100%; border-radius: 4px; }
|
|
30
|
+
.note { font-size: 12px; margin: 8px 0 0; }
|
|
31
|
+
`;
|
|
32
|
+
/** Outline icons the kit carries itself (a bundle loads nothing from outside): eye, eye-off, download. */
|
|
33
|
+
const ICONS = {
|
|
34
|
+
eye: svg `<path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>`,
|
|
35
|
+
eye_off: svg `<path d="M10.6 5.1A10.9 10.9 0 0 1 12 5c6.4 0 10 7 10 7a17 17 0 0 1-2.4 3.3M6.6 6.6A17 17 0 0 0 2 12s3.6 7 10 7a10 10 0 0 0 5.4-1.6"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/><path d="M3 3l18 18"/>`,
|
|
36
|
+
download: svg `<path d="M12 4v11"/><path d="M7 10l5 5 5-5"/><path d="M5 20h14"/>`,
|
|
37
|
+
};
|
|
38
|
+
/** An icon in a 24×24 box, drawn in the text colour. */
|
|
39
|
+
function icon(name) {
|
|
40
|
+
return html `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">${ICONS[name]}</svg>`;
|
|
41
|
+
}
|
|
42
|
+
/** Largest part of a file previewed (bytes), and the most lines shown. */
|
|
43
|
+
export const PREVIEW_MAX_BYTES = 256 * 1024;
|
|
44
|
+
export const PREVIEW_MAX_LINES = 200;
|
|
45
|
+
const TEXT_TYPES = new Set(['application/json', 'application/x-ndjson', 'application/yaml', 'application/x-yaml', 'application/xml', 'application/csv']);
|
|
46
|
+
const TEXT_EXTENSIONS = new Set(['txt', 'log', 'csv', 'tsv', 'json', 'jsonl', 'yaml', 'yml', 'xml', 'ini', 'toml', 'sql', 'diff', 'patch']);
|
|
47
|
+
const MARKDOWN_EXTENSIONS = new Set(['md', 'markdown']);
|
|
48
|
+
/** How a file can be previewed in the frame: Markdown rendered, text as is, an image; null — download only (PDF, binary). */
|
|
49
|
+
export function preview_kind(ref) {
|
|
50
|
+
const type = (ref.content_type || '').toLowerCase().split(';')[0].trim();
|
|
51
|
+
const ext = ref.name.toLowerCase().split('.').pop() ?? '';
|
|
52
|
+
if (type === 'text/markdown' || MARKDOWN_EXTENSIONS.has(ext))
|
|
53
|
+
return 'markdown';
|
|
54
|
+
if (type.startsWith('image/') && type !== 'image/svg+xml')
|
|
55
|
+
return 'image';
|
|
56
|
+
if (type.startsWith('text/') || TEXT_TYPES.has(type) || TEXT_EXTENSIONS.has(ext))
|
|
57
|
+
return 'text';
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** A short type label for the row ("Markdown", "Text", "PDF", "Image", else the subtype). */
|
|
61
|
+
function type_label(ref) {
|
|
62
|
+
const kind = preview_kind(ref);
|
|
63
|
+
if (kind === 'markdown')
|
|
64
|
+
return 'Markdown';
|
|
65
|
+
if (kind === 'image')
|
|
66
|
+
return 'Image';
|
|
67
|
+
const type = (ref.content_type || '').toLowerCase();
|
|
68
|
+
if (type === 'application/pdf')
|
|
69
|
+
return 'PDF';
|
|
70
|
+
if (kind !== 'text')
|
|
71
|
+
return type.split('/')[1]?.toUpperCase() || 'File';
|
|
72
|
+
if (ref.name.toLowerCase().endsWith('.csv'))
|
|
73
|
+
return 'CSV';
|
|
74
|
+
return type.includes('json') ? 'JSON' : 'Text';
|
|
75
|
+
}
|
|
76
|
+
/** The first {@link PREVIEW_MAX_LINES} lines of the first {@link PREVIEW_MAX_BYTES} of a text file, and whether there's more. */
|
|
77
|
+
export async function preview_text(blob) {
|
|
78
|
+
const head = await blob.slice(0, PREVIEW_MAX_BYTES).text();
|
|
79
|
+
const lines = head.split('\n');
|
|
80
|
+
const more = blob.size > PREVIEW_MAX_BYTES || lines.length > PREVIEW_MAX_LINES;
|
|
81
|
+
return { text: lines.slice(0, PREVIEW_MAX_LINES).join('\n'), more };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* `<cliq-attachment .ref=${ref}>` — one file as a row: its name, type and size, Download (an icon), and — for text,
|
|
85
|
+
* Markdown and images — Preview (an eye; eye-off while open), which reads the file through the host (with the viewer's permissions) and shows it inline below
|
|
86
|
+
* the row (Markdown rendered, text as is; the first 200 lines / 256 KB). Images show a thumbnail in the row. Collapsed
|
|
87
|
+
* by default; a Hug's only previewable attachment opens by itself. `preview="none"` turns previews off.
|
|
88
|
+
*/
|
|
89
|
+
export class CliqAttachment extends KitElement {
|
|
90
|
+
open = null;
|
|
91
|
+
loaded_for = null;
|
|
92
|
+
thumb = null;
|
|
93
|
+
body = null;
|
|
94
|
+
loading = false;
|
|
95
|
+
constructor() { super(ATTACHMENT_CSS); }
|
|
96
|
+
/** Whether this is the Hug's only previewable attachment (it then opens by itself). */
|
|
97
|
+
only_previewable(ref) {
|
|
98
|
+
const atts = current_hug()?.attachments ?? [];
|
|
99
|
+
const previewable = atts.filter((a) => preview_kind(a) !== null);
|
|
100
|
+
return previewable.length === 1 && previewable[0].artifact_id === ref.artifact_id;
|
|
101
|
+
}
|
|
102
|
+
template() {
|
|
103
|
+
const ref = this.ref;
|
|
104
|
+
if (!ref)
|
|
105
|
+
return nothing;
|
|
106
|
+
const kind = this.preview === 'none' ? null : preview_kind(ref);
|
|
107
|
+
this.prepare(ref, kind);
|
|
108
|
+
const shown = Boolean(this.open && kind);
|
|
109
|
+
const panel_id = `p-${ref.artifact_id}`;
|
|
110
|
+
return html `<div class=${shown ? 'row open' : 'row'}>${this.row(ref, kind, panel_id)}</div>${shown
|
|
111
|
+
? html `<div class="panel" id=${panel_id} aria-busy=${String(this.loading)}>${this.panel()}</div>`
|
|
112
|
+
: nothing}`;
|
|
113
|
+
}
|
|
114
|
+
/** Track the file shown; decide whether it starts open; load what's needed. */
|
|
115
|
+
prepare(ref, kind) {
|
|
116
|
+
if (this.loaded_for !== ref.artifact_id)
|
|
117
|
+
this.reset(ref);
|
|
118
|
+
if (this.open === null)
|
|
119
|
+
this.open = kind !== null && this.only_previewable(ref);
|
|
120
|
+
if (kind === 'image')
|
|
121
|
+
this.load_thumb(ref);
|
|
122
|
+
if (this.open && kind)
|
|
123
|
+
this.load(ref, kind);
|
|
124
|
+
}
|
|
125
|
+
/** Preview (an eye) or, while open, Hide (eye-off). */
|
|
126
|
+
toggle(ref, panel_id) {
|
|
127
|
+
const open = Boolean(this.open);
|
|
128
|
+
const label = open ? `Hide preview of ${ref.name}` : `Preview ${ref.name}`;
|
|
129
|
+
const title = open ? 'Hide preview' : 'Preview';
|
|
130
|
+
return html `<button type="button" class="icon" aria-label=${label} title=${title} aria-expanded=${String(open)}
|
|
131
|
+
aria-controls=${panel_id} @click=${() => { this.open = !open; this.request_draw(); }}>${icon(open ? 'eye_off' : 'eye')}</button>`;
|
|
132
|
+
}
|
|
133
|
+
/** The row: thumbnail, name, type and size, Preview / Hide and Download. */
|
|
134
|
+
row(ref, kind, panel_id) {
|
|
135
|
+
const hug = current_hug();
|
|
136
|
+
const size = format_bytes(ref.size, hug?.locale ?? 'en-US');
|
|
137
|
+
const toggle = kind ? this.toggle(ref, panel_id) : nothing;
|
|
138
|
+
return html `${this.thumb ? html `<img class="thumb" src=${this.thumb} alt="">` : nothing}
|
|
139
|
+
<div class="what">
|
|
140
|
+
<div class="name">${ref.name}</div>
|
|
141
|
+
<div class="meta muted">${type_label(ref)} · ${size}${kind ? '' : ' · download to view'}</div>
|
|
142
|
+
</div>
|
|
143
|
+
<div class="actions">${toggle}
|
|
144
|
+
<button type="button" class="icon" aria-label=${`Download ${ref.name}`} title="Download"
|
|
145
|
+
@click=${() => hug?.download(ref)}>${icon('download')}</button>
|
|
146
|
+
</div>`;
|
|
147
|
+
}
|
|
148
|
+
panel() {
|
|
149
|
+
const b = this.body;
|
|
150
|
+
if (!b)
|
|
151
|
+
return html `<span class="muted">Loading…</span>`;
|
|
152
|
+
if (b.kind === 'error')
|
|
153
|
+
return html `<span class="problem" role="alert">${b.message}</span>`;
|
|
154
|
+
if (b.kind === 'image')
|
|
155
|
+
return html `<img src=${b.url} alt=${this.ref?.name ?? ''}>`;
|
|
156
|
+
const note = b.more ? html `<p class="note muted">Showing the first ${PREVIEW_MAX_LINES} lines · Download for the rest</p>` : nothing;
|
|
157
|
+
return b.kind === 'markdown'
|
|
158
|
+
? html `<cliq-markdown .text=${b.text}></cliq-markdown>${note}`
|
|
159
|
+
: html `<pre>${b.text}</pre>${note}`;
|
|
160
|
+
}
|
|
161
|
+
reset(ref) {
|
|
162
|
+
this.loaded_for = ref.artifact_id;
|
|
163
|
+
this.open = null;
|
|
164
|
+
this.thumb = null;
|
|
165
|
+
this.body = null;
|
|
166
|
+
this.loading = false;
|
|
167
|
+
}
|
|
168
|
+
load_thumb(ref) {
|
|
169
|
+
if (this.thumb !== null)
|
|
170
|
+
return;
|
|
171
|
+
this.thumb = '';
|
|
172
|
+
current_hug()?.file_url(ref).then((url) => {
|
|
173
|
+
if (this.loaded_for !== ref.artifact_id)
|
|
174
|
+
return;
|
|
175
|
+
this.thumb = url;
|
|
176
|
+
this.request_draw();
|
|
177
|
+
}, () => undefined);
|
|
178
|
+
}
|
|
179
|
+
load(ref, kind) {
|
|
180
|
+
if (this.body || this.loading)
|
|
181
|
+
return;
|
|
182
|
+
const hug = current_hug();
|
|
183
|
+
if (!hug)
|
|
184
|
+
return;
|
|
185
|
+
this.loading = true;
|
|
186
|
+
const done = (body) => {
|
|
187
|
+
if (this.loaded_for !== ref.artifact_id)
|
|
188
|
+
return;
|
|
189
|
+
this.body = body;
|
|
190
|
+
this.loading = false;
|
|
191
|
+
this.request_draw();
|
|
192
|
+
};
|
|
193
|
+
const failed = (err) => done({
|
|
194
|
+
kind: 'error',
|
|
195
|
+
message: err instanceof HugError && err.code === 'read_denied' ? "You can't read this file." : "Couldn't load the preview — download it instead.",
|
|
196
|
+
});
|
|
197
|
+
if (kind === 'image') {
|
|
198
|
+
hug.file_url(ref).then((url) => done({ kind: 'image', url }), failed);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
hug.read_file(ref).then((blob) => preview_text(blob)).then((t) => done({ kind, ...t }), failed);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
reactive(CliqAttachment, ['ref', 'preview'], ['preview']);
|
|
205
|
+
define_element('cliq-attachment', CliqAttachment);
|
|
206
|
+
const FILE_CSS = `
|
|
207
|
+
ul { list-style: none; margin: 0 0 6px; padding: 0; }
|
|
208
|
+
li { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
|
|
209
|
+
.remove { padding: 0 6px; }
|
|
210
|
+
`;
|
|
211
|
+
/** A slot's accepted types, for people: `.csv` → "CSV", `image/*` → "images", `application/pdf` → "PDF". */
|
|
212
|
+
export function accepted_types(accept) {
|
|
213
|
+
if (!accept?.length)
|
|
214
|
+
return null;
|
|
215
|
+
const named = (a) => {
|
|
216
|
+
const t = a.trim().toLowerCase();
|
|
217
|
+
if (t.endsWith('/*'))
|
|
218
|
+
return `${t.slice(0, -2)}s`; // image/* → images, audio/* → audios
|
|
219
|
+
if (t === 'application/pdf' || t === '.pdf')
|
|
220
|
+
return 'PDF';
|
|
221
|
+
if (t === 'text/plain' || t === '.txt')
|
|
222
|
+
return 'text';
|
|
223
|
+
if (t === 'text/csv' || t === '.csv')
|
|
224
|
+
return 'CSV';
|
|
225
|
+
if (t.startsWith('.'))
|
|
226
|
+
return t.slice(1).toUpperCase();
|
|
227
|
+
return t;
|
|
228
|
+
};
|
|
229
|
+
const names = [...new Set(accept.map(named))];
|
|
230
|
+
const list = names.length > 1 ? `${names.slice(0, -1).join(', ')} or ${names.at(-1)}` : names[0];
|
|
231
|
+
return list.charAt(0).toUpperCase() + list.slice(1);
|
|
232
|
+
}
|
|
233
|
+
/** A size limit as authors write it — in thousands (`5_000_000` → "5 MB"), not the 1,024s file sizes use. */
|
|
234
|
+
function limit_text(bytes, locale) {
|
|
235
|
+
const units = [[1e9, 'GB'], [1e6, 'MB'], [1e3, 'KB']];
|
|
236
|
+
const [size, unit] = units.find(([n]) => bytes >= n) ?? [1, 'bytes'];
|
|
237
|
+
return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(bytes / size)} ${unit}`;
|
|
238
|
+
}
|
|
239
|
+
/** What a slot takes, under its label: "CSV · up to 5 MB", "Images, PDF or text · optional · up to 5 MB". */
|
|
240
|
+
export function slot_hint(slot, locale = 'en-US') {
|
|
241
|
+
if (!slot)
|
|
242
|
+
return null;
|
|
243
|
+
const parts = [
|
|
244
|
+
accepted_types(slot.accept) ?? (slot.max_bytes ? 'Any file' : null),
|
|
245
|
+
slot.required === false ? 'optional' : null,
|
|
246
|
+
slot.max_bytes ? `up to ${limit_text(slot.max_bytes, locale)}` : null,
|
|
247
|
+
].filter((p) => !!p);
|
|
248
|
+
return parts.length ? parts.join(' · ') : null;
|
|
249
|
+
}
|
|
250
|
+
const UPLOAD_MESSAGES = {
|
|
251
|
+
file_too_large: 'That file is too large.',
|
|
252
|
+
file_type: "That type of file isn't accepted here.",
|
|
253
|
+
rate_limited: 'Too many uploads — try again in a moment.',
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* `<cliq-file key="evidence" .value=${…}>` — an upload slot. Emits `change` with the file reference (or a list, for a
|
|
257
|
+
* `multiple` slot; `null` when emptied). `label`, `required` and `.problem` as on `<cliq-field>`.
|
|
258
|
+
*/
|
|
259
|
+
export class CliqFile extends KitElement {
|
|
260
|
+
busy = false;
|
|
261
|
+
error = null;
|
|
262
|
+
constructor() { super(FILE_CSS); }
|
|
263
|
+
get many() {
|
|
264
|
+
if (this.multiple !== undefined)
|
|
265
|
+
return this.multiple !== false && this.multiple !== 'false';
|
|
266
|
+
return !!current_hug()?.files.find((f) => f.name === this.key)?.multiple;
|
|
267
|
+
}
|
|
268
|
+
/** This slot as the Hug declares it (accepted types, size, required). */
|
|
269
|
+
get declared() {
|
|
270
|
+
return current_hug()?.files.find((f) => f.name === this.key);
|
|
271
|
+
}
|
|
272
|
+
get list() {
|
|
273
|
+
const v = this.value;
|
|
274
|
+
if (!v)
|
|
275
|
+
return [];
|
|
276
|
+
return Array.isArray(v) ? v : [v];
|
|
277
|
+
}
|
|
278
|
+
template() {
|
|
279
|
+
const files = this.list;
|
|
280
|
+
const can_add = !this.busy && (this.many || files.length === 0);
|
|
281
|
+
const message = this.problem ?? this.error;
|
|
282
|
+
const hint = slot_hint(this.declared, current_hug()?.locale);
|
|
283
|
+
return html `
|
|
284
|
+
${this.label ? html `<span class="label">${this.label}</span>` : nothing}
|
|
285
|
+
${hint ? html `<div class="help" part="hint">${hint}</div>` : nothing}
|
|
286
|
+
${files.length ? html `<ul>${files.map((f, i) => html `<li>
|
|
287
|
+
<cliq-attachment .ref=${f} preview="none"></cliq-attachment>
|
|
288
|
+
<button type="button" class="remove" aria-label=${`Remove ${f.name}`} @click=${() => this.remove_file(i)}>×</button>
|
|
289
|
+
</li>`)}</ul>` : nothing}
|
|
290
|
+
${can_add || this.busy ? this.add_button(files.length, !!message) : nothing}
|
|
291
|
+
${message ? html `<div class="problem" role="alert">${message}</div>` : nothing}`;
|
|
292
|
+
}
|
|
293
|
+
add_button(count, invalid) {
|
|
294
|
+
const label = this.busy ? 'Uploading…' : this.add_label(count);
|
|
295
|
+
return html `<button type="button" ?disabled=${this.busy} aria-invalid=${invalid ? 'true' : 'false'}
|
|
296
|
+
@click=${() => this.pick()}>${label}</button>`;
|
|
297
|
+
}
|
|
298
|
+
add_label(count) {
|
|
299
|
+
if (count === 0)
|
|
300
|
+
return this.many ? 'Upload files' : 'Upload a file';
|
|
301
|
+
return 'Add another';
|
|
302
|
+
}
|
|
303
|
+
async pick() {
|
|
304
|
+
const hug = current_hug();
|
|
305
|
+
if (!hug || !this.key)
|
|
306
|
+
return;
|
|
307
|
+
this.busy = true;
|
|
308
|
+
this.error = null;
|
|
309
|
+
this.draw();
|
|
310
|
+
try {
|
|
311
|
+
const ref = await hug.upload(this.key);
|
|
312
|
+
this.set_files(this.many ? [...this.list, ref] : [ref]);
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
const code = error instanceof HugError ? error.code : 'upload_failed';
|
|
316
|
+
const types = accepted_types(this.declared?.accept);
|
|
317
|
+
if (code === 'file_type' && types)
|
|
318
|
+
this.error = `That type of file isn't accepted here — ${types} only.`;
|
|
319
|
+
else if (code !== 'upload_cancelled')
|
|
320
|
+
this.error = UPLOAD_MESSAGES[code] ?? "The upload didn't work.";
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
this.busy = false;
|
|
324
|
+
this.draw();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
remove_file(index) {
|
|
328
|
+
this.set_files(this.list.filter((_, i) => i !== index));
|
|
329
|
+
}
|
|
330
|
+
set_files(files) {
|
|
331
|
+
let next;
|
|
332
|
+
if (this.many)
|
|
333
|
+
next = files.length ? files : undefined;
|
|
334
|
+
else
|
|
335
|
+
next = files[0];
|
|
336
|
+
this.value = next;
|
|
337
|
+
this.emit(next);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
reactive(CliqFile, ['key', 'value', 'label', 'problem', 'multiple'], ['key', 'label', 'multiple']);
|
|
341
|
+
define_element('cliq-file', CliqFile);
|
|
342
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/ui/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,WAAW,E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