clavarium 0.2.171-beta.1 → 0.2.172-beta.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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/boxes.mjs +11 -1
- package/server/rooms.mjs +10 -3
- package/server/settingswords.mjs +18 -0
- package/web/app.js +96 -137
- package/web/index.html +2 -2
- package/web/kit.js +273 -0
- package/web/style.css +71 -23
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.172-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.172-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/boxes.mjs
CHANGED
|
@@ -787,7 +787,7 @@ export class Boxes {
|
|
|
787
787
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
788
788
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
789
789
|
}
|
|
790
|
-
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; link.voice = NaN; link.endReason = ''; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
790
|
+
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; link.voice = NaN; link.endReason = ''; link.startReason = String(m.reason ?? ''); link.clipSeen = false; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
791
791
|
if (m.t === 'listen.start') { if (this.stop(box.id)) this.#log(`voice box ${box.name}: stopped playing, someone speaks`); sentence = []; size = 0; return; }
|
|
792
792
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
793
793
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -923,6 +923,16 @@ export class Boxes {
|
|
|
923
923
|
/* The wake word heard again (wake.clip): said beside the message; dropped in silence only once that is
|
|
924
924
|
turned on (WAKE_DROP), after its results were looked at -- a real call must never be lost to it. */
|
|
925
925
|
const check = link.wakeCheck ? await link.wakeCheck.catch(() => null) : null; link.wakeCheck = null;
|
|
926
|
+
/* WOKEN BY THE WORD, BUT NO CLIP TO CHECK IT (06-11: « ce ne sera pas au niveau de fond », voice 195, passed): as a
|
|
927
|
+
clip with no word in it -- dropped only when faint too; a firm voice, a button, a knock still go. */
|
|
928
|
+
if (!check && link.startReason === 'wake' && dropsWake(false, link.voice, link.endReason, '')) {
|
|
929
|
+
if (Number.isFinite(link.voice) && link.voice > 0 && link.voice < WAKE_FAINT) {
|
|
930
|
+
link.send({ t: 'cue', name: 'done' });
|
|
931
|
+
this.#log(`voice box ${box.name}: wake ignored (no wake clip to check, faint voice ${Math.round(link.voice)})`);
|
|
932
|
+
try { this.#note?.(box.conversation, { kind: 'box-wake-ignored', text: `Wake ignored on ${box.name}: no wake word to check, faint voice`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
926
936
|
if (check) {
|
|
927
937
|
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
928
938
|
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
package/server/rooms.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { mkdirSync, rmSync } from 'node:fs';
|
|
|
18
18
|
import { randomUUID } from 'node:crypto';
|
|
19
19
|
import { Parley } from 'clavarium-parley/host';
|
|
20
20
|
import { Refusal } from './conversations.mjs';
|
|
21
|
+
import { scan } from './secret-scan.mjs';
|
|
21
22
|
|
|
22
23
|
export const ROOM_NAME_MAX = 60;
|
|
23
24
|
export const ROOMS_MAX = 20;
|
|
@@ -29,6 +30,12 @@ export const THINKING_MS = 10 * 60_000;
|
|
|
29
30
|
const KINDS = ['person', 'ai', 'box'];
|
|
30
31
|
const nameOf = (v) => String(v ?? '').replace(/\s+/g, ' ').trim().slice(0, ROOM_NAME_MAX);
|
|
31
32
|
|
|
33
|
+
/* A SECRET IN A ROOM (06-11): a room's thread is read by all its members, now and later -- a token, a key pasted
|
|
34
|
+
there is never kept: the thread shows it as stars, and only the AI the message goes to gets it (lifted into its
|
|
35
|
+
own short-lived store by its chat, as any secret said to it). What an AI writes in a room is masked the same way:
|
|
36
|
+
a secret never passes from one AI to another through a room. */
|
|
37
|
+
export const masked = (text) => { const str = String(text ?? ''); const hits = scan(str); if (!hits.length) return str; let out = ''; let last = 0; for (const h of hits) { out += str.slice(last, h.start) + '••••••'; last = h.end; } return out + str.slice(last); };
|
|
38
|
+
|
|
32
39
|
/* A sign as the cards draw it (web/kit.js hueOf, initialOf): the same name, the same letter and colour. */
|
|
33
40
|
export const lookOf = (name) => { const text = String(name ?? ''); let h = 0; for (const ch of text) h = (h * 31 + ch.codePointAt(0)) >>> 0; return { initial: ([...text.trim()][0] ?? '?').toUpperCase(), hue: h % 360 }; };
|
|
34
41
|
|
|
@@ -144,13 +151,13 @@ export class Rooms {
|
|
|
144
151
|
const t = this.#thread(room.id);
|
|
145
152
|
this.#hops.set(room.id, 0);
|
|
146
153
|
/* The owner is the room's own side (no name over their words, as in any chat); anyone else is named. */
|
|
147
|
-
const now = t.say(text, undefined, [], who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind, look: who.look } });
|
|
154
|
+
const now = t.say(masked(text), undefined, [], who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind, look: who.look } });
|
|
148
155
|
const said = now.messages.at(-1);
|
|
149
156
|
const named = (Array.isArray(to) ? to : []).map((x) => members.find((m) => m.id === x && m.kind === 'ai')).filter(Boolean);
|
|
150
157
|
const host = members.find((m) => m.id === room.host);
|
|
151
158
|
for (const ai of named.length ? named : host ? [host] : []) {
|
|
152
159
|
this.#think(room.id, ai.id, true);
|
|
153
|
-
await this.#say(ai.ref,
|
|
160
|
+
await this.#say(ai.ref, text, { by: { id: who.id, name: who.name, kind: who.kind, look: who.look }, room: { id: room.id, name: room.name, message: said.id } });
|
|
154
161
|
}
|
|
155
162
|
/* Handed to its AIs: read, as a conversation's agent would say it (06-11: the clock stayed on every message). */
|
|
156
163
|
try { t.seen?.(); } catch { /* an older Parley */ }
|
|
@@ -192,7 +199,7 @@ export class Rooms {
|
|
|
192
199
|
}
|
|
193
200
|
if (!String(entry.text ?? '').trim()) return null;
|
|
194
201
|
/* @Name of a member, exactly: kept as its id (the screen says its name of the moment). */
|
|
195
|
-
const text =
|
|
202
|
+
const text = masked(entry.text).replace(/@([^\s@{][^@\n]{0,40}?)(?=[\s,.;:!?)]|$)/g, (whole, name) => { const m = members.find((x) => x.name.toLowerCase() === name.toLowerCase()); return m ? `@{${m.id}}` : whole; });
|
|
196
203
|
const id = t.relay({ text, by: { id: me.id, name: me.name, kind: 'ai', look: me.look }, to, re, kind: kind === 'doing' ? 'doing' : 'say' });
|
|
197
204
|
/* The boxes it is sent to say it aloud (#281): its words, a member named by its name, never an id. */
|
|
198
205
|
const boxes = to.map((x) => members.find((m) => m.id === x && m.kind === 'box')).filter(Boolean).map((m) => m.ref);
|
package/server/settingswords.mjs
CHANGED
|
@@ -69,5 +69,23 @@ export const SETTINGS_WORDS_FR = {
|
|
|
69
69
|
'set-apikeys-convs': 'Conversations', 'set-apikeys-convs-hint': 'Une par une : lire ou parler', 'set-apikeys-off': 'Non',
|
|
70
70
|
'set-apikeys-read': 'Lire', 'set-apikeys-talk': 'Parler', 'set-apikeys-no-convs': 'Aucune conversation pour l\'instant',
|
|
71
71
|
'set-apikeys-journal': 'Journal', 'set-apikeys-no-use': 'Aucun appel pour l\'instant',
|
|
72
|
+
/* The rights of an asset (06-11, kit.js RIGHTS): what it has (a pill), a choice, its one line. */
|
|
73
|
+
'set-rt-none': 'Aucun', 'set-rt-read': 'Lit', 'set-rt-write': 'Écrit', 'set-rt-use': 'Utilise', 'set-rt-watch': 'Surveille',
|
|
74
|
+
'set-rt-propose': 'Propose', 'set-rt-frame': 'Encadré', 'set-rt-free': 'Libre', 'set-rt-terminal': 'Terminal', 'set-rt-chat': 'Chat',
|
|
75
|
+
'set-rt-both': 'Chat + terminal',
|
|
76
|
+
'set-rt-pick-none': 'Aucun', 'set-rt-pick-read': 'Lire', 'set-rt-pick-write': 'Écrire', 'set-rt-pick-use': 'Utiliser',
|
|
77
|
+
'set-rt-pick-watch': 'Surveiller', 'set-rt-pick-propose': 'Proposer', 'set-rt-pick-frame': 'Encadrer', 'set-rt-pick-free': 'Libre',
|
|
78
|
+
'set-rt-pick-terminal': 'Terminal', 'set-rt-pick-chat': 'Chat', 'set-rt-pick-both': 'Les deux',
|
|
79
|
+
'set-rt-hint-none': 'Pas donné', 'set-rt-hint-read': 'Lecture seule', 'set-rt-hint-write': 'Lecture et écriture',
|
|
80
|
+
'set-rt-hint-use': 'Remis à son outil, jamais affiché', 'set-rt-hint-watch': 'Lecture seule',
|
|
81
|
+
'set-rt-hint-propose': 'Vous demande avant chaque action', 'set-rt-hint-frame': 'Agit selon ses règles, vous demande le reste',
|
|
82
|
+
'set-rt-hint-free': 'Agit seul, tout est noté au journal', 'set-rt-hint-terminal': 'Tout son terminal',
|
|
83
|
+
'set-rt-hint-chat': 'Lit et écrit dans son chat', 'set-rt-hint-both': 'Son chat et son terminal',
|
|
84
|
+
'set-as-nobody': 'personne',
|
|
85
|
+
/* The one list of assets (06-11, kit AssetList): its views, its one button, a group's head, what an empty one says. */
|
|
86
|
+
'set-as-new': 'Nouveau', 'set-as-by-group': 'Groupes', 'set-as-by-type': 'Types', 'set-as-no-group': 'Sans groupe',
|
|
87
|
+
'set-as-fold': 'Replier', 'set-as-unfold': 'Déplier', 'set-as-group-open': 'Réglages de {name}', 'set-as-group-gear': 'Donner, renommer, supprimer',
|
|
88
|
+
'set-as-group-empty': 'Vide : glissez un asset ici', 'set-as-all-grouped': 'Chaque asset est dans un groupe',
|
|
89
|
+
'set-as-no-groups': 'Créez un groupe, puis glissez-y un asset',
|
|
72
90
|
};
|
|
73
91
|
export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
|
package/web/app.js
CHANGED
|
@@ -1316,6 +1316,8 @@
|
|
|
1316
1316
|
let words = null; try { words = chatWords; } catch { /* not read yet */ }
|
|
1317
1317
|
return (typeof words?.[key] === 'string' ? words[key] : fallback).replace(/\{(\w+)\}/g, (all, k) => (k in vars ? String(vars[k]) : all));
|
|
1318
1318
|
};
|
|
1319
|
+
/* The kit says its few words in the screen's language too (Holders' "nobody", the rights, the list's). */
|
|
1320
|
+
KIT.setWords((key, fallback) => uiSaid(key, fallback));
|
|
1319
1321
|
/* Who of a room speaks now (#282, an AI given a message and not done): « Cuisine parle… ». */
|
|
1320
1322
|
const speaking = (who) => (who.length > 1 ? uiSaid('room-speaking-many', '{names} are speaking\u2026', { names: who.join(', ') }) : uiSaid('room-speaking', '{name} is speaking\u2026', { name: who[0] }));
|
|
1321
1323
|
const thinkingOf = (r) => (Array.isArray(r?.thinking) ? r.thinking.filter((x) => typeof x === 'string' && x) : []);
|
|
@@ -3750,7 +3752,7 @@
|
|
|
3750
3752
|
/* BINDER'S LISTS, AS THIS PAGE NAMES THEM: the one place for the word (Assets, a conversation's tab). */
|
|
3751
3753
|
const LISTS_WORD = { many: 'Binders', one: 'Binder', a: 'a binder', its: 'Its binders' };
|
|
3752
3754
|
$('view-lists-word').textContent = LISTS_WORD.many; $('listnew-head').textContent = `New ${LISTS_WORD.one.toLowerCase()}`;
|
|
3753
|
-
const ASSET_KINDS = [['git', 'Git repositories', 'git-branch'], ['folder', 'Folders', 'folder'], ['mailbox', 'Mailboxes', 'mail'], ['agenda', 'Calendars', 'calendar'], ['contacts', 'Contacts', 'users'], ['secret', 'Secrets', 'key-round'], ['list', LISTS_WORD.many, '']];
|
|
3755
|
+
const ASSET_KINDS = [['git', 'Git repositories', 'git-branch'], ['folder', 'Folders', 'folder'], ['mailbox', 'Mailboxes', 'mail'], ['agenda', 'Calendars', 'calendar'], ['contacts', 'Contacts', 'users'], ['secret', 'Secrets', 'key-round'], ['list', LISTS_WORD.many, ''], ['acces', 'Accesses', 'link']];
|
|
3754
3756
|
/* A live Tether target shows in the category of its kind (a mailbox among the
|
|
3755
3757
|
mailboxes), not apart. Its connecting account is the rest of its id. */
|
|
3756
3758
|
const TETHER_CAT = { mail: 'mailbox', calendar: 'agenda', contacts: 'contacts' };
|
|
@@ -3817,92 +3819,37 @@
|
|
|
3817
3819
|
row.addEventListener('click', () => choose(item.key));
|
|
3818
3820
|
return row;
|
|
3819
3821
|
}
|
|
3820
|
-
/*
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3822
|
+
/* AN ITEM OF THESE LISTS, as the kit's AssetCard takes it (06-11, assets step 2): its point when it asks for
|
|
3823
|
+
you (a secret soon or past, a mailbox failing), the shade of its line, who has it or its right. */
|
|
3824
|
+
const cardOf = (item) => ({ key: item.key, kind: item.kind, name: item.name, sub: item.sub ?? '', live: item.live,
|
|
3825
|
+
state: item.dot === 'bad' || item.tone === 'bad' ? 'problem' : item.dot === 'warn' ? 'wait' : '', tone: item.dot || item.tone || '',
|
|
3826
|
+
holders: item.holders, right: item.right, count: item.count });
|
|
3827
|
+
/* Who has an asset, for its row: the conversations (their name as shown), then the devices given it. */
|
|
3828
|
+
const holdersOf = (names, key) => [...names.map((n) => ({ name: shownName(conversations.find((c) => c.name === n)) || n })), ...sharedDevices.filter((d) => (d.grants ?? []).some((g) => g.asset === key)).map((d) => ({ name: d.name ?? d.id }))];
|
|
3829
|
+
/* Who uses it, for the list (its holders) and for its panel's title (the number, as before: step 3 redraws it). */
|
|
3830
|
+
const usedBy = (names, key) => ({ holders: holdersOf(names, key), badge: String(names.length), badgeTitle: `Used by ${names.length} conversation${names.length === 1 ? '' : 's'}`, badgeTone: 'count' });
|
|
3831
|
+
/* A row pinned above the list (To send, Demandes): the same card, its number on its right. */
|
|
3832
|
+
const pinnedCard = (entry, { chosen, onOpen, extra = '' }) => KIT.AssetCard({ key: entry.key, kind: entry.kind, name: entry.name, sub: entry.sub, count: entry.count },
|
|
3833
|
+
{ cls: `as-row ts-entry${extra ? ` ${extra}` : ''}`, current: entry.key === chosen, onOpen });
|
|
3834
|
+
/* THE ONE LIST (kit AssetList), in `holder`: the Assets menu (scope 'all') or a conversation's tab. */
|
|
3835
|
+
function paintAssetList(holder, model, opts) {
|
|
3836
|
+
holder.replaceChildren(KIT.AssetList(model, { rowCls: 'as-row', ...opts }));
|
|
3835
3837
|
}
|
|
3836
3838
|
/* The group an asset is in, or '' for none. */
|
|
3837
3839
|
const groupOf = (key, groups) => groups.find((g) => (g.members ?? []).includes(key))?.id ?? '';
|
|
3838
3840
|
/* Groups the owner has folded shut in the by-group view (a convenience). */
|
|
3839
3841
|
const groupsFolded = (() => { try { const v = JSON.parse(localStorage.getItem('clavarium-groups-folded') ?? '[]'); return new Set(Array.isArray(v) ? v : []); } catch { return new Set(); } })();
|
|
3840
3842
|
const keepGroupsFolded = () => { try { localStorage.setItem('clavarium-groups-folded', JSON.stringify([...groupsFolded])); } catch { /* a private window */ } };
|
|
3841
|
-
/* The rows, by the owner's groups: a foldable section per group, then the
|
|
3842
|
-
loose ones. A group's name opens its own detail (rename, remove, give the
|
|
3843
|
-
whole group); the chevron folds it; "+" makes a new one. An asset is put
|
|
3844
|
-
into a group from the asset's own detail. */
|
|
3845
|
-
function paintAsGroups(holder, items, groups, { chosen, choose, empty }) {
|
|
3846
|
-
holder.replaceChildren();
|
|
3847
|
-
const byKey = new Map(items.map((i) => [i.key, i]));
|
|
3848
|
-
const addBar = el('div', 'as-group-new');
|
|
3849
|
-
if (groupAdding) {
|
|
3850
|
-
const form = el('form', 'as-group-form'); form.autocomplete = 'off';
|
|
3851
|
-
const input = el('input'); input.placeholder = 'Group name'; input.maxLength = 40; input.setAttribute('aria-label', 'New group name');
|
|
3852
|
-
const make = el('button', 'primary', 'Add'); make.type = 'submit';
|
|
3853
|
-
const cancel = el('button', '', 'Cancel'); cancel.type = 'button'; cancel.addEventListener('click', () => { groupAdding = false; void paintAssets(); });
|
|
3854
|
-
form.append(input, make, cancel);
|
|
3855
|
-
form.addEventListener('submit', async (event) => {
|
|
3856
|
-
event.preventDefault(); $('assets-error').hidden = true;
|
|
3857
|
-
try { const made = await post(`${API}/asset-groups`, { label: input.value.trim() }); groupAdding = false; assetOpen = `group:${made.id}`; remember(); }
|
|
3858
|
-
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3859
|
-
void paintAssets();
|
|
3860
|
-
});
|
|
3861
|
-
addBar.append(form);
|
|
3862
|
-
holder.append(addBar);
|
|
3863
|
-
queueMicrotask(() => input.focus());
|
|
3864
|
-
} else {
|
|
3865
|
-
addBar.append(roundPlus('New group', () => { groupAdding = true; void paintAssets(); }), el('span', 'hint', 'New group'));
|
|
3866
|
-
holder.append(addBar);
|
|
3867
|
-
}
|
|
3868
|
-
const section = (head, rows, none, { foldable, drop } = {}) => {
|
|
3869
|
-
const s = el('section', 'as-kind as-group'); s.append(head); s.dataset.drop = drop;
|
|
3870
|
-
if (!foldable || !head.dataset.folded) {
|
|
3871
|
-
if (rows.length === 0) s.append(el('p', 'hint as-none', none));
|
|
3872
|
-
for (const item of rows) s.append(assetRow(item, { chosen, choose }));
|
|
3873
|
-
}
|
|
3874
|
-
holder.append(s);
|
|
3875
|
-
};
|
|
3876
|
-
for (const g of groups) {
|
|
3877
|
-
const members = (g.members ?? []).map((k) => byKey.get(k)).filter(Boolean);
|
|
3878
|
-
const folded = groupsFolded.has(g.id);
|
|
3879
|
-
const head = el('div', 'as-kind-head as-group-head'); if (folded) head.dataset.folded = 'true';
|
|
3880
|
-
/* The whole header folds/unfolds the group; a gear opens its settings. */
|
|
3881
|
-
const toggle = el('button', 'as-group-name'); toggle.type = 'button';
|
|
3882
|
-
if (`group:${g.id}` === chosen) toggle.setAttribute('aria-current', 'true');
|
|
3883
|
-
toggle.setAttribute('aria-expanded', String(!folded));
|
|
3884
|
-
toggle.append(el('span', 'as-chev', folded ? '▸' : '▾'), el('h3', '', g.label), el('span', 'as-badge count', String(members.length)));
|
|
3885
|
-
toggle.title = folded ? 'Unfold' : 'Fold';
|
|
3886
|
-
toggle.addEventListener('click', () => { if (folded) groupsFolded.delete(g.id); else groupsFolded.add(g.id); keepGroupsFolded(); void paintAssets(); });
|
|
3887
|
-
const gear = el('button', 'as-gear', '⚙'); gear.type = 'button'; gear.setAttribute('aria-label', `Settings for ${g.label}`); gear.title = 'Give, rename, remove';
|
|
3888
|
-
gear.addEventListener('click', (e) => { e.stopPropagation(); choose(`group:${g.id}`); });
|
|
3889
|
-
head.append(toggle, gear);
|
|
3890
|
-
section(head, members, 'Empty. Drag an asset here, or open one to put it here.', { foldable: true, drop: g.id });
|
|
3891
|
-
}
|
|
3892
|
-
const grouped = new Set(groups.flatMap((g) => g.members ?? []));
|
|
3893
|
-
const loose = items.filter((i) => !grouped.has(i.key));
|
|
3894
|
-
const looseHead = el('div', 'as-kind-head'); looseHead.append(el('h3', '', 'No group'));
|
|
3895
|
-
section(looseHead, loose, groups.length ? 'Every asset is in a group.' : 'Make a group above, then open an asset to put it in it.', { drop: '' });
|
|
3896
|
-
if (items.length === 0 && empty) holder.append(el('p', 'hint', empty));
|
|
3897
|
-
if (groups.length) dragToGroups(holder);
|
|
3898
|
-
}
|
|
3899
3843
|
/* DRAGGING AN ASSET ONTO A GROUP (#111), like a binder's Kanban: a mouse drags once it
|
|
3900
3844
|
has moved a little; a finger after a short hold (so a swipe still scrolls). The row
|
|
3901
3845
|
follows the pointer as a light copy; the group under it lights up; let go on it, and
|
|
3902
3846
|
the asset is placed there ("No group" takes it out). A tap still opens the asset. */
|
|
3903
3847
|
function dragToGroups(holder) {
|
|
3848
|
+
/* Wired once: the list is drawn again and again inside the same holder. */
|
|
3849
|
+
if (holder.dataset.dragWired) return;
|
|
3850
|
+
holder.dataset.dragWired = 'true';
|
|
3904
3851
|
let drag = null;
|
|
3905
|
-
const sectionAt = (x, y) => document.elementFromPoint(x, y)?.closest?.('.
|
|
3852
|
+
const sectionAt = (x, y) => document.elementFromPoint(x, y)?.closest?.('.kit-aslist-group[data-drop]') ?? null;
|
|
3906
3853
|
const end = () => { if (!drag) return; clearTimeout(drag.hold); drag.ghost?.remove(); drag.over?.classList.remove('as-drop-over'); document.body.classList.remove('as-dragging'); drag = null; };
|
|
3907
3854
|
const start = (d) => {
|
|
3908
3855
|
d.on = true;
|
|
@@ -3913,9 +3860,10 @@
|
|
|
3913
3860
|
document.body.append(d.ghost); document.body.classList.add('as-dragging');
|
|
3914
3861
|
};
|
|
3915
3862
|
holder.addEventListener('pointerdown', (e) => {
|
|
3916
|
-
const row = e.target.closest('.as-row[data-asset]');
|
|
3917
|
-
|
|
3918
|
-
|
|
3863
|
+
const row = e.target.closest('.as-row[data-asset]:not(.ts-entry)');
|
|
3864
|
+
/* Only in the view by group, once there is a group to drag to. */
|
|
3865
|
+
if (!row || !holder.contains(row) || e.button > 0 || !holder.querySelector('.kit-aslist-group[data-drop]:not([data-drop=""])')) return;
|
|
3866
|
+
drag = { row, id: e.pointerId, x0: e.clientX, y0: e.clientY, on: false, touch: e.pointerType !== 'mouse', from: row.closest('.kit-aslist-group')?.dataset.drop };
|
|
3919
3867
|
if (drag.touch) { const d = drag; d.hold = setTimeout(() => { if (drag === d) { start(d); try { row.setPointerCapture(d.id); } catch { /* still heard */ } } }, 350); }
|
|
3920
3868
|
});
|
|
3921
3869
|
holder.addEventListener('pointermove', (e) => {
|
|
@@ -3965,16 +3913,31 @@
|
|
|
3965
3913
|
if (item.kind === 'list') return item.list.grants?.[id] ?? 'none';
|
|
3966
3914
|
return item.resource?.attachments?.[conversationName] ?? 'none';
|
|
3967
3915
|
}
|
|
3968
|
-
/* The toggle above the rows:
|
|
3969
|
-
function paintAssetsView() {
|
|
3916
|
+
/* The toggle above the rows: the owner's groups or the types (kit Segmented); `view`, the one shown. */
|
|
3917
|
+
function paintAssetsView(view) {
|
|
3970
3918
|
const bar = $('assets-view'); if (!bar) return;
|
|
3971
|
-
bar.replaceChildren()
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3919
|
+
bar.replaceChildren(KIT.Segmented({ options: [{ value: 'group', label: uiSaid('set-as-by-group', 'Groups') }, { value: 'type', label: uiSaid('set-as-by-type', 'Types') }], value: view, label: 'Arrange assets',
|
|
3920
|
+
onChange: (by) => { if (by === view) return; assetsBy = by; keepAssetsBy(); groupAdding = false; void paintAssets(); } }));
|
|
3921
|
+
}
|
|
3922
|
+
/* "+ New group", above the groups: a name in place, then made and opened. */
|
|
3923
|
+
function newGroupBar() {
|
|
3924
|
+
const addBar = el('div', 'as-group-new');
|
|
3925
|
+
if (groupAdding) {
|
|
3926
|
+
const form = el('form', 'as-group-form'); form.autocomplete = 'off';
|
|
3927
|
+
const input = el('input'); input.placeholder = 'Group name'; input.maxLength = 40; input.setAttribute('aria-label', 'New group name');
|
|
3928
|
+
const make = el('button', 'primary', 'Add'); make.type = 'submit';
|
|
3929
|
+
const cancel = el('button', '', 'Cancel'); cancel.type = 'button'; cancel.addEventListener('click', () => { groupAdding = false; void paintAssets(); });
|
|
3930
|
+
form.append(input, make, cancel);
|
|
3931
|
+
form.addEventListener('submit', async (event) => {
|
|
3932
|
+
event.preventDefault(); $('assets-error').hidden = true;
|
|
3933
|
+
try { const made = await post(`${API}/asset-groups`, { label: input.value.trim() }); groupAdding = false; assetOpen = `group:${made.id}`; remember(); }
|
|
3934
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3935
|
+
void paintAssets();
|
|
3936
|
+
});
|
|
3937
|
+
addBar.append(form);
|
|
3938
|
+
queueMicrotask(() => input.focus());
|
|
3939
|
+
} else addBar.append(roundPlus('New group', () => { groupAdding = true; void paintAssets(); }), el('span', 'hint', 'New group'));
|
|
3940
|
+
return addBar;
|
|
3978
3941
|
}
|
|
3979
3942
|
/* In an asset's detail: which group it is in. Moving it is a folder move
|
|
3980
3943
|
(it leaves any other group). New groups are made in the by-group view. */
|
|
@@ -4594,6 +4557,10 @@
|
|
|
4594
4557
|
const noAssetChosen = () => el('p', 'hint as-none', 'Select an asset to see its detail.');
|
|
4595
4558
|
|
|
4596
4559
|
/* ---- a conversation's own ---- */
|
|
4560
|
+
/* A conversation's tab, searched: its words, and whose they are. */
|
|
4561
|
+
let cassetsQuery = ''; let cassetsFor = '';
|
|
4562
|
+
$('cassets-search').addEventListener('input', () => { cassetsQuery = $('cassets-search').value.trim(); void paintRoomAssets(); });
|
|
4563
|
+
$('cassets-attach').addEventListener('click', () => { void openAccess(true); });
|
|
4597
4564
|
async function paintRoomAssets() {
|
|
4598
4565
|
if (!assetsShown) return;
|
|
4599
4566
|
watchTether();
|
|
@@ -4607,15 +4574,15 @@
|
|
|
4607
4574
|
const mineJobs = (Array.isArray(tether.jobs) ? tether.jobs : []).filter((j) => j.agent === `conversation:${current}`);
|
|
4608
4575
|
const mine = new Map((c?.resources ?? []).map((r) => [r.name, r.access]));
|
|
4609
4576
|
const items = [];
|
|
4610
|
-
if (c?.work === 'kept') items.push({ key: 'folder:work', kind: 'folder', name: 'work', own: true, sub: 'where its tool works', badge: 'write', badgeTone: 'write' });
|
|
4577
|
+
if (c?.work === 'kept') items.push({ key: 'folder:work', kind: 'folder', name: 'work', own: true, sub: 'where its tool works', badge: 'write', badgeTone: 'write', right: { level: 'write' } });
|
|
4611
4578
|
for (const r of all.filter((x) => mine.has(x.name))) {
|
|
4612
4579
|
const kind = kindOf(r); const access = mine.get(r.name);
|
|
4613
4580
|
const box = kind === 'mailbox' ? boxes.find((m) => m.name === r.name) : undefined;
|
|
4614
|
-
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: access, badgeTone: access, badgeLong: access === 'write' ? 'read and write' : 'read only',
|
|
4581
|
+
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: access, badgeTone: access, badgeLong: access === 'write' ? 'read and write' : 'read only', right: { key: kind, value: access },
|
|
4615
4582
|
sub: kind === 'git' ? gitSub(r) : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
4616
4583
|
}
|
|
4617
4584
|
markSecrets(secrets);
|
|
4618
|
-
for (const s2 of secrets.filter((x) => x.conversations.includes(current))) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, ...secretItem(s2, 'name only · used by its agent') });
|
|
4585
|
+
for (const s2 of secrets.filter((x) => x.conversations.includes(current))) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, right: { level: 'use' }, ...secretItem(s2, 'name only · used by its agent') });
|
|
4619
4586
|
/* TO SEND, above them all, once it has a repository: every one of them on one screen. */
|
|
4620
4587
|
const gits = items.filter((i) => i.kind === 'git').map((i) => i.name);
|
|
4621
4588
|
const outbox = gits.length ? { key: 'send:all', kind: 'send', name: 'To send', sub: 'every repository, reviewed and sent at once' } : null;
|
|
@@ -4624,20 +4591,15 @@
|
|
|
4624
4591
|
const chosen = (outbox && roomPick === outbox.key ? outbox : null) ?? (demandes && roomPick === demandes.key ? demandes : null) ?? items.find((i) => i.key === roomPick) ?? null;
|
|
4625
4592
|
const as = $('cassets-as');
|
|
4626
4593
|
as.dataset.open = chosen ? 'detail' : 'list';
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
return row;
|
|
4637
|
-
};
|
|
4638
|
-
if (outbox) $('cassets-rows').prepend(pinnedRow(outbox));
|
|
4639
|
-
if (demandes) $('cassets-rows').prepend(pinnedRow(demandes, 'demande-entry'));
|
|
4640
|
-
$('cassets-rows').prepend(top);
|
|
4594
|
+
/* THE ONE LIST (kit AssetList), scope this conversation: by type, its right on each row; To send and
|
|
4595
|
+
Demandes pinned above. Its search is its own, emptied when another conversation is shown. */
|
|
4596
|
+
if (cassetsFor !== current) { cassetsFor = current; cassetsQuery = ''; $('cassets-search').value = ''; }
|
|
4597
|
+
const model = KIT.assetListModel({ items: items.map(cardOf), scope: `conversation:${current}`, query: cassetsQuery, kinds: ASSET_KINDS });
|
|
4598
|
+
const pinned = cassetsQuery ? [] : [
|
|
4599
|
+
demandes && pinnedCard({ ...demandes, count: waitingCount }, { chosen: chosen?.key, onOpen: pickRoomAsset, extra: 'demande-entry' }),
|
|
4600
|
+
outbox && pinnedCard(outbox, { chosen: chosen?.key, onOpen: pickRoomAsset }),
|
|
4601
|
+
];
|
|
4602
|
+
paintAssetList($('cassets-rows'), model, { chosen: chosen?.key, onOpen: pickRoomAsset, pinned, empty: 'Nothing is given to it yet.', noMatch: 'Nothing by that name.' });
|
|
4641
4603
|
if (c?.work === 'disk') $('cassets-rows').append(el('p', 'hint as-disk', 'Its work is on the disk of its machine: nothing of it is kept here.'));
|
|
4642
4604
|
const detail = $('cassets-detail');
|
|
4643
4605
|
if (!chosen) { unembedFiles(); detail.replaceChildren(); if (items.length) detail.append(noAssetChosen()); return; }
|
|
@@ -4748,10 +4710,10 @@
|
|
|
4748
4710
|
|
|
4749
4711
|
/* ---- the server's ---- */
|
|
4750
4712
|
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false; let listOpen = ''; let listsSig = '';
|
|
4751
|
-
/* How the Assets list is arranged: by type
|
|
4752
|
-
|
|
4753
|
-
let assetsBy = '
|
|
4754
|
-
try {
|
|
4713
|
+
/* How the Assets list is arranged: by the owner's groups or by type. A per-viewer convenience, kept in the
|
|
4714
|
+
browser once chosen; never chosen (''), groups as soon as one exists, else types (kit assetListModel). */
|
|
4715
|
+
let assetsBy = '';
|
|
4716
|
+
try { const kept = localStorage.getItem('clavarium-assets-by'); if (kept === 'group' || kept === 'type') assetsBy = kept; } catch { /* a private window */ }
|
|
4755
4717
|
const keepAssetsBy = () => { try { localStorage.setItem('clavarium-assets-by', assetsBy); } catch { /* as above */ } };
|
|
4756
4718
|
/* The "+ New group" inline form being shown in the by-group view. */
|
|
4757
4719
|
let groupAdding = false;
|
|
@@ -4961,31 +4923,28 @@
|
|
|
4961
4923
|
markSecrets(secrets);
|
|
4962
4924
|
const items = [];
|
|
4963
4925
|
for (const r of all) {
|
|
4964
|
-
const kind = kindOf(r);
|
|
4926
|
+
const kind = kindOf(r);
|
|
4965
4927
|
const box = kind === 'mailbox' ? boxes.find((m) => m.name === r.name) : undefined;
|
|
4966
|
-
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box,
|
|
4928
|
+
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, ...usedBy(Object.keys(r.attachments ?? {}), `${kind}:${r.name}`),
|
|
4967
4929
|
sub: kind === 'git' ? `${gitSub(r)}${viaText(r.via)}` : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
4968
4930
|
}
|
|
4969
|
-
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2,
|
|
4931
|
+
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, ...usedBy(s2.conversations, `secret:${s2.name}`), ...secretItem(s2, 'name only') });
|
|
4970
4932
|
/* Tether targets ("Connexions"): a mailbox, calendar or address book connected
|
|
4971
4933
|
by token, given to a conversation at a level. The token lives on the server. */
|
|
4972
4934
|
const allTargets = Array.isArray(tether.targets) ? tether.targets : [];
|
|
4973
4935
|
for (const tgt of allTargets) {
|
|
4974
|
-
const users = Object.keys(tgt.grants ?? {}).filter((id) => id.startsWith('conversation:')).length;
|
|
4936
|
+
const users = Object.keys(tgt.grants ?? {}).filter((id) => id.startsWith('conversation:')).map((id) => id.slice('conversation:'.length));
|
|
4975
4937
|
const acct = tetherAccount(tgt.id);
|
|
4976
4938
|
const siblings = allTargets.filter((o) => o.id !== tgt.id && tetherAccount(o.id) === acct).map((o) => connexionSub(o.kind));
|
|
4977
|
-
items.push({ key: `connexion:${tgt.id}`, kind: tetherCat(tgt.kind), name: tgt.title, target: tgt, siblings, live: true,
|
|
4978
|
-
badge: String(users), badgeTitle: `Used by ${users} conversation${users === 1 ? '' : 's'}`, badgeTone: 'count',
|
|
4939
|
+
items.push({ key: `connexion:${tgt.id}`, kind: tetherCat(tgt.kind), name: tgt.title, target: tgt, siblings, live: true, ...usedBy(users, `connexion:${tgt.id}`),
|
|
4979
4940
|
sub: siblings.length ? `linked: ${siblings.join(', ')}` : connexionSub(tgt.kind) });
|
|
4980
4941
|
}
|
|
4981
4942
|
/* Binder's lists: given to a conversation (read, write) in Binder itself. */
|
|
4982
4943
|
const shownLists = lists.ok && Array.isArray(lists.data) ? lists.data.filter((l) => !l.archived) : [];
|
|
4983
4944
|
listsSig = binderSig(lists.data);
|
|
4984
4945
|
for (const l of shownLists) {
|
|
4985
|
-
|
|
4986
|
-
items.push({ key: `list:${l.id}`, kind: 'list', name: l.title, list: l, badge: String(users), badgeTitle: `Used by ${users} conversation${users === 1 ? '' : 's'}`, badgeTone: 'count', sub: `${l.count} card${l.count === 1 ? '' : 's'}` });
|
|
4946
|
+
items.push({ key: `list:${l.id}`, kind: 'list', name: l.title, list: l, ...usedBy(givenTo(l).map((id) => id.slice('conversation:'.length)), `list:${l.id}`), sub: `${l.count} card${l.count === 1 ? '' : 's'}` });
|
|
4987
4947
|
}
|
|
4988
|
-
const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
|
|
4989
4948
|
const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
|
|
4990
4949
|
if (justMade && !justMade.to && justMade.key !== chosen?.key) justMade = null;
|
|
4991
4950
|
/* A group can be the open thing too (its own detail: give it, rename it). */
|
|
@@ -4995,24 +4954,19 @@
|
|
|
4995
4954
|
const allApprovals = Array.isArray(tether.approvals) ? tether.approvals : [];
|
|
4996
4955
|
const onDemandes = !assetsAdding && !chosen && !chosenGroup && assetOpen === 'demandes:all';
|
|
4997
4956
|
$('assets-as').dataset.open = chosen || chosenGroup || assetsAdding || onDemandes ? 'detail' : 'list';
|
|
4998
|
-
/* The "by type / by group" toggle sits above the rows (built once, kept). */
|
|
4999
|
-
paintAssetsView();
|
|
5000
4957
|
const choose = (key) => { placeAssetStep(); if (key !== assetOpen) groupGiveShow.clear(); assetOpen = key; assetsAdding = ''; remoteEditing = false; remember(); void paintAssets(); };
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
if (
|
|
5009
|
-
|
|
5010
|
-
if (
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
row.addEventListener('click', () => choose('demandes:all'));
|
|
5014
|
-
$('assets-rows').prepend(row);
|
|
5015
|
-
}
|
|
4958
|
+
/* THE ONE LIST (kit AssetList), scope all: groups by default once one exists; who has each on its right. */
|
|
4959
|
+
const model = KIT.assetListModel({ items: items.map(cardOf), groups: assetGroups, scope: 'all', by: assetsBy, query: assetsQuery, folded: [...groupsFolded], kinds: ASSET_KINDS });
|
|
4960
|
+
paintAssetsView(model.view);
|
|
4961
|
+
/* Above them all, once something waits: the owner reaches every call from here, not only by opening the
|
|
4962
|
+
right connexion. Then, in the view by group, "+ New group". */
|
|
4963
|
+
const pinned = [];
|
|
4964
|
+
if (allApprovals.length && !assetsQuery) pinned.push(pinnedCard({ key: 'demandes:all', kind: 'demandes', name: 'Demandes', sub: `${allApprovals.length} waiting for you`, count: allApprovals.length }, { chosen: onDemandes ? 'demandes:all' : '', onOpen: choose, extra: 'demande-entry' }));
|
|
4965
|
+
if (model.view === 'group') pinned.push(newGroupBar());
|
|
4966
|
+
paintAssetList($('assets-rows'), model, { chosen: chosen?.key ?? (chosenGroup ? `group:${chosenGroup.id}` : onDemandes ? 'demandes:all' : ''), onOpen: choose, pinned,
|
|
4967
|
+
onFold: (id) => { if (groupsFolded.has(id)) groupsFolded.delete(id); else groupsFolded.add(id); keepGroupsFolded(); void paintAssets(); },
|
|
4968
|
+
onGroup: (id) => choose(`group:${id}`), noMatch: 'Nothing by that name.' });
|
|
4969
|
+
if (model.view === 'group') dragToGroups($('assets-rows'));
|
|
5016
4970
|
const detail = $('assets-detail');
|
|
5017
4971
|
/* The forms go back to where they wait before the detail is drawn again. */
|
|
5018
4972
|
for (const form of detail.querySelectorAll('.as-form, #gitview-remote-box')) $('assets-forms').append(form);
|
|
@@ -5020,9 +4974,9 @@
|
|
|
5020
4974
|
const back = () => { assetOpen = ''; assetsAdding = ''; remember(); void paintAssets(); };
|
|
5021
4975
|
if (assetsAdding) {
|
|
5022
4976
|
/* The New asset box: from the map's "+" of Assets, which kind first ("<" goes back to the map);
|
|
5023
|
-
from
|
|
5024
|
-
const out = assetsFromMap
|
|
5025
|
-
out.addEventListener('click', () => { if (!nav.close(assetsFromMap
|
|
4977
|
+
from "+ New" of the list, which kind first too ("<" Assets). */
|
|
4978
|
+
const out = assetsFromMap ? el('button', 'as-link', '‹ Access') : el('button', 'as-link as-back', '‹ Assets'); out.type = 'button';
|
|
4979
|
+
out.addEventListener('click', () => { if (!nav.close(assetsFromMap ? 'compose' : 'asset')) back(); });
|
|
5026
4980
|
const kind = assetsAdding === 'choose' ? '' : assetsAdding;
|
|
5027
4981
|
detail.append(out, newAssetBox({ kind, onKind: (k) => { assetsAdding = k; void paintAssets(); }, boxHost: { where: '', repaint: () => { void paintAssets(); }, close: back } }));
|
|
5028
4982
|
if (kind) focusFirst(detail);
|
|
@@ -5294,6 +5248,8 @@
|
|
|
5294
5248
|
: settings.sshKey ? `Push key: SSH key ${settings.sshKey}` : 'Push key: none · the clone\'s access, same server only';
|
|
5295
5249
|
}
|
|
5296
5250
|
$('assets-search').addEventListener('input', () => { assetsQuery = $('assets-search').value.trim(); void paintAssets(); });
|
|
5251
|
+
/* ONE "+ New" (06-11, assets step 2), in place of a "+" per kind: the New asset box, its kind chosen in it. */
|
|
5252
|
+
$('assets-new').addEventListener('click', () => { placeAssetStep(); assetsAdding = 'choose'; remoteEditing = false; $('assets-error').hidden = true; void paintAssets(); });
|
|
5297
5253
|
$('assets-close').addEventListener('click', () => leavePlace());
|
|
5298
5254
|
/* The Assets place, on one asset (`key`), its remote form open (`remote`). */
|
|
5299
5255
|
async function openAssetsPlace(key, { remote = false, push = true } = {}) {
|
|
@@ -6372,6 +6328,9 @@
|
|
|
6372
6328
|
for (const b of document.querySelectorAll('button.tip-btn')) b.setAttribute('aria-label', uiSaid('set-why', 'Why'));
|
|
6373
6329
|
const s = document.querySelector('#settings .settings-search'); if (s) s.placeholder = uiSaid('set-search', 'Search');
|
|
6374
6330
|
const p = document.querySelector('#panel .settings-search'); if (p) p.placeholder = uiSaid('set-search', 'Search');
|
|
6331
|
+
$('cassets-search').placeholder = uiSaid('set-search', 'Search');
|
|
6332
|
+
/* The lists of assets drawn before the words came: drawn again, the kit's words in the screen's language. */
|
|
6333
|
+
try { if (place === 'assets') void paintAssets(); if (assetsShown) void paintRoomAssets(); } catch { /* not drawn yet */ }
|
|
6375
6334
|
}
|
|
6376
6335
|
void readWords().then(saySettings).catch(() => {});
|
|
6377
6336
|
|
package/web/index.html
CHANGED
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
each opened on the right (a folder: its files). -->
|
|
106
106
|
<div id="cassets" class="sheet as-room" hidden>
|
|
107
107
|
<div class="as" id="cassets-as">
|
|
108
|
-
<div class="as-list"><div id="cassets-rows"></div></div>
|
|
108
|
+
<div class="as-list"><div class="as-tools"><input type="search" id="cassets-search" placeholder="Search" aria-label="Search its assets" spellcheck="false" autocomplete="off"><button type="button" id="cassets-attach" class="as-new"><span aria-hidden="true">+ </span><span data-said="set-na-attach">Attach</span></button></div><div id="cassets-rows"></div></div>
|
|
109
109
|
<div class="as-detail" id="cassets-detail"></div>
|
|
110
110
|
</div>
|
|
111
111
|
</div>
|
|
@@ -751,7 +751,7 @@
|
|
|
751
751
|
<div class="panel-top"><b>Assets</b><button type="button" id="assets-close" class="as-link place-back">‹ Conversations</button></div>
|
|
752
752
|
<p id="assets-error" class="error" role="alert" hidden></p>
|
|
753
753
|
<div class="as" id="assets-as">
|
|
754
|
-
<div class="as-list"><div class="as-
|
|
754
|
+
<div class="as-list"><div class="as-tools"><input type="search" id="assets-search" placeholder="Search assets" aria-label="Search assets" spellcheck="false" autocomplete="off"><button type="button" id="assets-new" class="as-new primary"><span aria-hidden="true">+ </span><span data-said="set-as-new">New</span></button></div><div class="as-view" id="assets-view"></div><div id="assets-rows"></div></div>
|
|
755
755
|
<div class="as-detail" id="assets-detail"></div>
|
|
756
756
|
</div>
|
|
757
757
|
<div id="assets-forms" hidden>
|
package/web/kit.js
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
* its views on the right) and `sub` (a page of its own or inside one: a way back on the right)
|
|
20
20
|
* ShareDonut who takes a whole (memory, a disk): a small donut, its slices from shareSlices, the main
|
|
21
21
|
* figure in its middle; ShareKey, a slice's swatch beside its row in the list
|
|
22
|
+
* AssetIcon an asset's sign and colour, by its kind (one table, ASSET_ICONS)
|
|
23
|
+
* AssetCard ONE ASSET, three sizes like ConvCard (06-11, assets step 1): `row` (a list), `chip` (a pill:
|
|
24
|
+
* a folded group, the thread, a call waiting), `head` (atop its panel). On its right, who has
|
|
25
|
+
* it (Holders) or, seen from one holder, its right (RightsBadge).
|
|
26
|
+
* AssetList THE ONE LIST of assets (06-11, assets step 2): the Assets menu and a conversation's tab, only its
|
|
27
|
+
* scope changes; by type or by group; an empty type not shown; assetListModel places the rows.
|
|
28
|
+
* RIGHTS THE ONE TABLE of what an asset can be given at, by its kind and by who gets it (a
|
|
29
|
+
* conversation, a device); "none" first. RightsBadge reads a right, RightsPicker sets it.
|
|
22
30
|
*
|
|
23
31
|
* No framework: each piece is a function that returns an element. Words: English here; the page
|
|
24
32
|
* hands its own (`setWords`, app.js `uiSaid`) for the few the kit says by itself.
|
|
@@ -391,7 +399,272 @@
|
|
|
391
399
|
return root;
|
|
392
400
|
}
|
|
393
401
|
|
|
402
|
+
/* ---------- ASSETS (06-11, the unified assets, step 1: the pieces; the screens move to them in step 2) ---------- */
|
|
403
|
+
|
|
404
|
+
/* AN ASSET'S SIGN, by its kind: the icon set's name (Lucide, icons.js), or '' for one drawn here (a binder).
|
|
405
|
+
A live link (a connexion) takes the sign of what it links (a mailbox, a calendar); `acces`, any other. */
|
|
406
|
+
const ASSET_ICONS = { folder: 'folder', git: 'git-branch', mailbox: 'mail', agenda: 'calendar', contacts: 'user', secret: 'key-round', list: '', acces: 'link', send: 'arrow-up', demandes: 'arrow-up', box: 'mic', device: 'smartphone', conversation: 'message-square' };
|
|
407
|
+
const ASSET_KINDS = Object.keys(ASSET_ICONS);
|
|
408
|
+
/* A binder: the set has no such sign, so it is drawn here, in its style (was app.js listIcon). */
|
|
409
|
+
function listSign() {
|
|
410
|
+
const svg = svgNode('svg'); svg.setAttribute('viewBox', '0 0 24 24'); svg.setAttribute('aria-hidden', 'true');
|
|
411
|
+
for (const d of ['m3 17 2 2 4-4', 'm3 7 2 2 4-4', 'M13 6h8', 'M13 12h8', 'M13 18h8']) { const p = svgNode('path'); p.setAttribute('d', d); svg.append(p); }
|
|
412
|
+
return svg;
|
|
413
|
+
}
|
|
414
|
+
function AssetIcon({ kind = 'folder', cls = '' } = {}) {
|
|
415
|
+
const k = kind in ASSET_ICONS ? kind : 'folder';
|
|
416
|
+
const box = node('span', `kit-asset-ic${cls ? ` ${cls}` : ''}`); box.dataset.kind = k; box.setAttribute('aria-hidden', 'true');
|
|
417
|
+
const name = ASSET_ICONS[k];
|
|
418
|
+
const svg = name ? window.clavariumIcons?.icon?.(name) : listSign();
|
|
419
|
+
if (svg) box.append(svg);
|
|
420
|
+
return box;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/* THE RIGHTS: one level each, its tone (r: reads, w: changes, x: uses or watches, n: none). The words come
|
|
424
|
+
three ways: `badge` (what it has: "Reads"), `pick` (a choice: "Read"), `hint` (one line, its title). */
|
|
425
|
+
const RIGHT_LEVELS = {
|
|
426
|
+
none: { tone: 'n', badge: 'None', pick: 'None', hint: 'Not given' },
|
|
427
|
+
read: { tone: 'r', badge: 'Reads', pick: 'Read', hint: 'Reads only' },
|
|
428
|
+
write: { tone: 'w', badge: 'Writes', pick: 'Write', hint: 'Reads and writes' },
|
|
429
|
+
use: { tone: 'x', badge: 'Uses', pick: 'Use', hint: 'Handed to its tool, never shown' },
|
|
430
|
+
watch: { tone: 'x', badge: 'Watches', pick: 'Watch', hint: 'Reads only' },
|
|
431
|
+
propose: { tone: 'x', badge: 'Proposes', pick: 'Propose', hint: 'Asks you before each action' },
|
|
432
|
+
frame: { tone: 'w', badge: 'Framed', pick: 'Frame', hint: 'Acts within its rules, asks the rest' },
|
|
433
|
+
free: { tone: 'w', badge: 'Free', pick: 'Free', hint: 'Acts, kept in the journal' },
|
|
434
|
+
terminal: { tone: 'x', badge: 'Terminal', pick: 'Terminal', hint: 'Its whole terminal' },
|
|
435
|
+
chat: { tone: 'r', badge: 'Chat', pick: 'Chat', hint: 'Reads and writes in its chat' },
|
|
436
|
+
both: { tone: 'w', badge: 'Chat + terminal', pick: 'Both', hint: 'Its chat and its terminal' },
|
|
437
|
+
};
|
|
438
|
+
/* THE ONE TABLE (was app.js levelOptionsFor, the "Used by" options, levelControl, partsControl, fixedRight,
|
|
439
|
+
fixedUse, Attach's Read / Write / Use): what each kind can be given at, by who gets it. "none" is first,
|
|
440
|
+
always: it replaces Off, Detach, Remove all and Take back. A kind not in a holder's column is not given
|
|
441
|
+
to it. `connexion`: a live link (Tether: a mailbox, a calendar, contacts or an access connected). */
|
|
442
|
+
const RIGHTS = {
|
|
443
|
+
folder: { conversation: ['none', 'read', 'write'], device: ['none', 'read', 'write'] },
|
|
444
|
+
git: { conversation: ['none', 'read', 'write'], device: ['none', 'read', 'write'] },
|
|
445
|
+
mailbox: { conversation: ['none', 'read'], device: ['none', 'read'] },
|
|
446
|
+
secret: { conversation: ['none', 'use'] },
|
|
447
|
+
list: { conversation: ['none', 'read', 'write'] },
|
|
448
|
+
connexion: { conversation: ['none', 'watch', 'propose', 'frame', 'free'] },
|
|
449
|
+
conversation: { device: ['none', 'terminal', 'chat', 'both'] },
|
|
450
|
+
};
|
|
451
|
+
const HOLDERS = ['conversation', 'device'];
|
|
452
|
+
/* The table's key of an asset: a live link is a connexion, whatever it links; else its kind. */
|
|
453
|
+
const rightsKey = (a) => (a?.live || a?.target ? 'connexion' : a?.kind ?? '');
|
|
454
|
+
const rightsFor = (key, holder = 'conversation') => [...(RIGHTS[key]?.[HOLDERS.includes(holder) ? holder : 'conversation'] ?? [])];
|
|
455
|
+
/* The lightest real level (what "give the group" gives): the first after none. */
|
|
456
|
+
const lightest = (key, holder) => rightsFor(key, holder)[1] ?? null;
|
|
457
|
+
/* AS THE SERVER KEEPS THEM -> a level, and back. A secret is 'off' / 'use' (secrets.mjs); a device's
|
|
458
|
+
grant is 'r' / 'rw', a conversation given to a device 'x' (terminal), 'rw' (chat), 'rwx' (devices.mjs);
|
|
459
|
+
the rest keeps the level's own name. Nothing, '', null, 'off': none. */
|
|
460
|
+
function rightOf(key, stored, holder = 'conversation') {
|
|
461
|
+
const s = String(stored ?? '').trim();
|
|
462
|
+
if (!s || s === 'off' || s === 'none') return 'none';
|
|
463
|
+
if (holder === 'device' || /^(r|rw|x|rwx)$/.test(s)) {
|
|
464
|
+
if (key === 'conversation') return { x: 'terminal', rw: 'chat', r: 'chat', rwx: 'both', xrw: 'both' }[s] ?? (s in RIGHT_LEVELS ? s : 'none');
|
|
465
|
+
if (s === 'r') return 'read';
|
|
466
|
+
if (s === 'rw' || s === 'rwx') return 'write';
|
|
467
|
+
}
|
|
468
|
+
return s in RIGHT_LEVELS ? s : 'none';
|
|
469
|
+
}
|
|
470
|
+
function storedOf(key, level, holder = 'conversation') {
|
|
471
|
+
if (holder === 'device') {
|
|
472
|
+
if (level === 'none') return null;
|
|
473
|
+
if (key === 'conversation') return { terminal: 'x', chat: 'rw', both: 'rwx' }[level] ?? null;
|
|
474
|
+
return { read: 'r', write: 'rw' }[level] ?? null;
|
|
475
|
+
}
|
|
476
|
+
if (key === 'secret') return level === 'use' ? 'use' : 'off';
|
|
477
|
+
return level;
|
|
478
|
+
}
|
|
479
|
+
const levelOf = (opts) => { const l = opts.level ?? rightOf(opts.key ?? '', opts.value, opts.holder); return l in RIGHT_LEVELS ? l : 'none'; };
|
|
480
|
+
const rightWord = (level, form = 'badge') => {
|
|
481
|
+
const l = RIGHT_LEVELS[level] ?? RIGHT_LEVELS.none;
|
|
482
|
+
return say(`set-rt-${form === 'badge' ? '' : `${form}-`}${level in RIGHT_LEVELS ? level : 'none'}`, l[form] ?? l.badge);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
/* A RIGHT, READ: a small pill, its tone by what it lets do. `level`, or `value` as kept (with its `key`, `holder`). */
|
|
486
|
+
function RightsBadge(opts = {}) {
|
|
487
|
+
const level = levelOf(opts);
|
|
488
|
+
const b = node('span', `kit-rights${opts.cls ? ` ${opts.cls}` : ''}`, rightWord(level, 'badge'));
|
|
489
|
+
b.dataset.level = level; b.dataset.tone = RIGHT_LEVELS[level].tone;
|
|
490
|
+
b.title = rightWord(level, 'hint');
|
|
491
|
+
return b;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/* A RIGHT, SET: the kind's levels from the table, "None" first, the one held pressed. `onChange(level,
|
|
495
|
+
stored)`: the level, and as the server keeps it; the buttons wait while it works (a promise). Nothing
|
|
496
|
+
to choose (a kind not given to that holder): null. */
|
|
497
|
+
function RightsPicker({ key = '', holder = 'conversation', value, level, label = '', cls = '', onChange = () => {} } = {}) {
|
|
498
|
+
const levels = rightsFor(key, holder);
|
|
499
|
+
if (!levels.length) return null;
|
|
500
|
+
const now = level ?? rightOf(key, value, holder);
|
|
501
|
+
const options = levels.map((l) => ({ value: l, label: rightWord(l, 'pick') }));
|
|
502
|
+
let held = now;
|
|
503
|
+
const pick = Segmented({ options, value: now, label, onChange: async (l) => {
|
|
504
|
+
if (l === held) return;
|
|
505
|
+
const buttons = pick.children; for (const b of buttons) b.disabled = true;
|
|
506
|
+
try { if ((await onChange(l, storedOf(key, l, holder))) === false) pick.set(held); else held = l; }
|
|
507
|
+
catch { pick.set(held); }
|
|
508
|
+
finally { for (const b of buttons) b.disabled = false; }
|
|
509
|
+
} });
|
|
510
|
+
addClass(pick, `kit-rights-pick${cls ? ` ${cls}` : ''}`);
|
|
511
|
+
pick.dataset.key = key; pick.dataset.holder = holder;
|
|
512
|
+
for (const b of pick.children) b.title = rightWord(b.dataset.value, 'hint');
|
|
513
|
+
return pick;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/* WHO HAS IT: their initials, up to `max`, then "+n"; nobody, said in grey. `list` [{ name, hue?, glyph? }]. */
|
|
517
|
+
function Holders(list = [], { max = 3 } = {}) {
|
|
518
|
+
const box = node('span', 'kit-holders');
|
|
519
|
+
const all = (list ?? []).filter((h) => h && h.name);
|
|
520
|
+
if (!all.length) { box.dataset.none = 'true'; box.append(node('small', 'kit-holders-none', say('set-as-nobody', 'nobody'))); return box; }
|
|
521
|
+
for (const h of all.slice(0, max)) box.append(Avatar(h));
|
|
522
|
+
if (all.length > max) box.append(node('small', 'kit-holders-more', `+${all.length - max}`));
|
|
523
|
+
box.title = all.map((h) => h.name).join(', ');
|
|
524
|
+
return box;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* ONE ASSET. `a`, what the page knows of it, said once:
|
|
528
|
+
key, kind 'folder:reports', its kind (ASSET_ICONS) name its name
|
|
529
|
+
live a live link (a connexion): its rights are a connexion's
|
|
530
|
+
sub its one line ('' : none) state a point when it asks for you (wait,
|
|
531
|
+
problem: expiring, failing); else none
|
|
532
|
+
tone its line's shade, when the page has one ('warn': soon; 'bad': past, failing)
|
|
533
|
+
count a number that waits for you (calls waiting)
|
|
534
|
+
holders [{ name, hue? }] who has it (Assets) right { level | value, holder? } its right,
|
|
535
|
+
seen from one holder (a conversation)
|
|
536
|
+
chips [{ text, … }] on a head (its group ▾, its type, its size)
|
|
537
|
+
`size`: 'row' | 'chip' | 'head'. `tag`: 'button' (it opens: `onOpen`) or the page's; a head is a div.
|
|
538
|
+
`current`: the one open (aria-current). `actions`: the place's own gestures, on its right. */
|
|
539
|
+
function AssetCard(a, { size = 'row', tag, cls = '', current = false, onOpen = null, actions = [] } = {}) {
|
|
540
|
+
const s = ['row', 'chip', 'head'].includes(size) ? size : 'row';
|
|
541
|
+
const t = tag ?? (s === 'head' ? 'div' : onOpen || s === 'row' ? 'button' : 'span');
|
|
542
|
+
const root = node(t, `kit-asset kit-asset-${s}${cls ? ` ${cls}` : ''}`);
|
|
543
|
+
if (t === 'button') root.type = 'button';
|
|
544
|
+
if (a.key) root.dataset.asset = a.key;
|
|
545
|
+
root.dataset.kind = a.kind ?? 'folder'; root.dataset.name = a.name ?? '';
|
|
546
|
+
if (current) root.setAttribute('aria-current', 'true');
|
|
547
|
+
root.append(AssetIcon({ kind: a.kind }));
|
|
548
|
+
if (s === 'chip') {
|
|
549
|
+
root.append(node('span', 'kit-asset-name', a.name ?? ''));
|
|
550
|
+
if (a.right) root.append(RightsBadge({ ...a.right, key: a.right.key ?? rightsKey(a) }));
|
|
551
|
+
} else {
|
|
552
|
+
const main = node('span', 'kit-asset-main');
|
|
553
|
+
main.append(node(s === 'head' ? 'h2' : 'b', 'kit-asset-name', a.name ?? ''));
|
|
554
|
+
if (a.sub || a.state) {
|
|
555
|
+
const line = node('small', 'kit-asset-sub');
|
|
556
|
+
if (a.state) { line.append(StatusDot({ state: a.state, label: a.sub ?? '' })); line.dataset.state = stateOf(a.state); }
|
|
557
|
+
if (a.tone) line.dataset.tone = a.tone;
|
|
558
|
+
if (a.sub) line.append(node('span', '', a.sub));
|
|
559
|
+
main.append(line);
|
|
560
|
+
}
|
|
561
|
+
if (s === 'head') { const chips = Chips(a.chips ?? []); if (chips) main.append(chips); }
|
|
562
|
+
root.append(main);
|
|
563
|
+
const side = node('span', 'kit-asset-side');
|
|
564
|
+
if (Number.isFinite(a.count) && a.count > 0) side.append(Chips([{ text: String(a.count), tone: 'count' }]));
|
|
565
|
+
if (a.right) side.append(RightsBadge({ ...a.right, key: a.right.key ?? rightsKey(a) }));
|
|
566
|
+
else if (a.holders && s === 'row') side.append(Holders(a.holders));
|
|
567
|
+
side.append(...actions.filter(Boolean));
|
|
568
|
+
if (side.children.length) root.append(side);
|
|
569
|
+
}
|
|
570
|
+
if (onOpen && t === 'button') root.addEventListener('click', () => onOpen(a.key));
|
|
571
|
+
return root;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/* THE LIST OF ASSETS (06-11, assets step 2): ONE LIST in the Assets menu and in a conversation's Assets tab;
|
|
575
|
+
only its scope changes -- 'all' (every asset, who has each on its right) or 'conversation:<name>' (what it
|
|
576
|
+
was given, each with its right). Two views of the same rows: by type, or by the owner's groups (the menu
|
|
577
|
+
only). A type with nothing in it is not shown; a group is (a place to drag to), unless a search empties it.
|
|
578
|
+
|
|
579
|
+
assetListModel: the rows placed, no page needed (tested alone).
|
|
580
|
+
items [{ key, kind, name, … }] as AssetCard takes them groups [{ id, label, members: [key] }]
|
|
581
|
+
scope 'all' | 'conversation:x' by the view kept ('type' | 'group'), or
|
|
582
|
+
'': groups once one exists, else types
|
|
583
|
+
query a name searched (any case) folded group ids folded shut kinds [[kind, title]] in order
|
|
584
|
+
-> { view, canGroup, sections: [{ id, title, kind | group, items, holders, folded, drop, empty }], shown, total } */
|
|
585
|
+
const scopeOf = (scope) => (String(scope ?? 'all').startsWith('conversation:') ? 'conversation' : 'all');
|
|
586
|
+
function assetListModel({ items = [], groups = [], scope = 'all', by = '', query = '', folded = [], kinds = [] } = {}) {
|
|
587
|
+
const canGroup = scopeOf(scope) === 'all';
|
|
588
|
+
const view = canGroup && (by === 'group' || (by !== 'type' && groups.length > 0)) ? 'group' : 'type';
|
|
589
|
+
const q = String(query ?? '').trim().toLowerCase();
|
|
590
|
+
const shown = q ? items.filter((i) => String(i.name ?? '').toLowerCase().includes(q)) : [...items];
|
|
591
|
+
const sections = [];
|
|
592
|
+
if (view === 'type') {
|
|
593
|
+
const order = kinds.length ? kinds : [...new Set(shown.map((i) => i.kind))].map((k) => [k, k]);
|
|
594
|
+
const known = new Set(order.map(([k]) => k));
|
|
595
|
+
for (const [kind, title] of order) {
|
|
596
|
+
const mine = shown.filter((i) => i.kind === kind);
|
|
597
|
+
if (mine.length) sections.push({ id: `kind:${kind}`, kind, title, items: mine });
|
|
598
|
+
}
|
|
599
|
+
/* A kind the page did not name is never dropped: it comes last, under its own name. */
|
|
600
|
+
for (const kind of [...new Set(shown.map((i) => i.kind).filter((k) => !known.has(k)))]) sections.push({ id: `kind:${kind}`, kind, title: kind, items: shown.filter((i) => i.kind === kind) });
|
|
601
|
+
} else {
|
|
602
|
+
const byKey = new Map(shown.map((i) => [i.key, i]));
|
|
603
|
+
const shut = new Set(folded);
|
|
604
|
+
const grouped = new Set();
|
|
605
|
+
for (const g of groups) {
|
|
606
|
+
for (const k of g.members ?? []) grouped.add(k);
|
|
607
|
+
const mine = (g.members ?? []).map((k) => byKey.get(k)).filter(Boolean);
|
|
608
|
+
if (q && !mine.length) continue;
|
|
609
|
+
const seen = new Set(); const holders = [];
|
|
610
|
+
for (const h of mine.flatMap((i) => i.holders ?? [])) if (h?.name && !seen.has(h.name)) { seen.add(h.name); holders.push(h); }
|
|
611
|
+
sections.push({ id: `group:${g.id}`, group: g.id, title: g.label, items: mine, holders, folded: shut.has(g.id), drop: g.id, empty: mine.length ? '' : 'group' });
|
|
612
|
+
}
|
|
613
|
+
const loose = shown.filter((i) => !grouped.has(i.key));
|
|
614
|
+
/* The loose ones stay a place to drag to (out of a group) while there are groups, even emptied. */
|
|
615
|
+
if (loose.length || (!q && items.length)) sections.push({ id: 'group:', group: '', title: say('set-as-no-group', 'No group'), items: loose, drop: '', empty: loose.length ? '' : groups.length ? 'grouped' : 'nogroups' });
|
|
616
|
+
}
|
|
617
|
+
return { view, canGroup, sections, shown: shown.length, total: items.length };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* The list drawn from its model. A row is an AssetCard (`rowCls` added: the page's handle on it); `pinned`,
|
|
621
|
+
rows above every section (what waits: To send, Demandes). `onOpen(key)`; a group's head folds it
|
|
622
|
+
(`onFold(id)`), its ⚙ opens it (`onGroup(id)`). `empty`: said when there is nothing at all; `noMatch`,
|
|
623
|
+
when a search finds nothing. */
|
|
624
|
+
function AssetList(model, { chosen = '', onOpen = () => {}, onFold = () => {}, onGroup = () => {}, rowCls = '', pinned = [], empty = '', noMatch = '' } = {}) {
|
|
625
|
+
const box = node('div', 'kit-aslist'); box.dataset.view = model.view;
|
|
626
|
+
box.append(...pinned.filter(Boolean));
|
|
627
|
+
const hints = {
|
|
628
|
+
group: say('set-as-group-empty', 'Empty: drag an asset here'),
|
|
629
|
+
grouped: say('set-as-all-grouped', 'Every asset is in a group'),
|
|
630
|
+
nogroups: say('set-as-no-groups', 'Make a group, then drag an asset into it'),
|
|
631
|
+
};
|
|
632
|
+
for (const s of model.sections) {
|
|
633
|
+
const sec = node('section', `kit-aslist-sec${s.group !== undefined ? ' kit-aslist-group' : ''}`);
|
|
634
|
+
if (s.kind !== undefined) sec.dataset.kind = s.kind;
|
|
635
|
+
if (s.drop !== undefined) sec.dataset.drop = s.drop;
|
|
636
|
+
const head = node('div', 'kit-aslist-head');
|
|
637
|
+
if (s.group) {
|
|
638
|
+
if (s.folded) head.dataset.folded = 'true';
|
|
639
|
+
const toggle = node('button', 'kit-aslist-fold'); toggle.type = 'button';
|
|
640
|
+
if (`group:${s.group}` === chosen) toggle.setAttribute('aria-current', 'true');
|
|
641
|
+
toggle.setAttribute('aria-expanded', String(!s.folded));
|
|
642
|
+
toggle.title = s.folded ? say('set-as-unfold', 'Unfold') : say('set-as-fold', 'Fold');
|
|
643
|
+
toggle.append(node('span', 'kit-aslist-chev', s.folded ? '▸' : '▾'), node('h3', '', s.title), node('span', 'kit-aslist-n', String(s.items.length)));
|
|
644
|
+
toggle.addEventListener('click', () => onFold(s.group));
|
|
645
|
+
head.append(toggle);
|
|
646
|
+
if (s.holders?.length) head.append(Holders(s.holders));
|
|
647
|
+
const gear = node('button', 'kit-aslist-gear', '⚙'); gear.type = 'button';
|
|
648
|
+
gear.setAttribute('aria-label', say('set-as-group-open', 'Settings for {name}').replace('{name}', s.title));
|
|
649
|
+
gear.title = say('set-as-group-gear', 'Give, rename, remove');
|
|
650
|
+
gear.addEventListener('click', (e) => { e?.stopPropagation?.(); onGroup(s.group); });
|
|
651
|
+
head.append(gear);
|
|
652
|
+
} else head.append(node('h3', '', s.title));
|
|
653
|
+
sec.append(head);
|
|
654
|
+
if (!s.folded) {
|
|
655
|
+
for (const a of s.items) sec.append(AssetCard(a, { size: 'row', cls: rowCls, current: a.key === chosen, onOpen }));
|
|
656
|
+
if (s.empty) sec.append(node('p', 'hint kit-aslist-none', hints[s.empty] ?? ''));
|
|
657
|
+
}
|
|
658
|
+
box.append(sec);
|
|
659
|
+
}
|
|
660
|
+
if (!model.total && empty) box.append(node('p', 'hint kit-aslist-said', empty));
|
|
661
|
+
else if (model.total && !model.shown && noMatch) box.append(node('p', 'hint kit-aslist-said', noMatch));
|
|
662
|
+
return box;
|
|
663
|
+
}
|
|
664
|
+
|
|
394
665
|
window.clavariumKit = {
|
|
666
|
+
AssetIcon, AssetCard, Holders, RightsBadge, RightsPicker, AssetList, assetListModel,
|
|
667
|
+
ASSET_ICONS, ASSET_KINDS, RIGHTS, RIGHT_LEVELS, rightsKey, rightsFor, rightOf, storedOf, lightest, rightWord,
|
|
395
668
|
shareSlices, ShareDonut, ShareKey,
|
|
396
669
|
STATES, STATE_WORDS, stateOf, hueOf, initialOf,
|
|
397
670
|
setWords(fn) { if (typeof fn === 'function') words = fn; },
|
package/web/style.css
CHANGED
|
@@ -1159,26 +1159,17 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
|
|
|
1159
1159
|
.as-detail { padding: 16px 20px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
|
|
1160
1160
|
/* The detail scrolls as a whole: nothing in it is squeezed (a branch diagram cut, its buttons over it) when a folder's files open below. */
|
|
1161
1161
|
.as-detail > * { flex-shrink: 0; }
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
.as-
|
|
1165
|
-
.as-
|
|
1166
|
-
|
|
1167
|
-
.as-view
|
|
1168
|
-
.as-view
|
|
1169
|
-
|
|
1162
|
+
/* Above the list: its search and its one button (+ New in Assets, + Attach in a conversation). */
|
|
1163
|
+
.as-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
|
|
1164
|
+
.as-tools input[type="search"] { flex: 1 1 auto; min-width: 0; width: 100%; padding: 9px 12px; border-radius: 9px; }
|
|
1165
|
+
.as-tools .as-new { flex: none; white-space: nowrap; font-size: .8125rem; font-weight: 600; padding: 8px 12px; border-radius: 9px; }
|
|
1166
|
+
/* Groups / Types (kit Segmented), above the rows. */
|
|
1167
|
+
.as-view { display: flex; margin-bottom: 4px; }
|
|
1168
|
+
.as-view .kit-seg { width: 100%; }
|
|
1169
|
+
.as-view .kit-seg > button { flex: 1 1 0; font-size: .8125rem; padding: 7px 8px; }
|
|
1170
|
+
/* The by-group view: make-a-group bar, its inline editor. */
|
|
1170
1171
|
.as-group-new { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
|
|
1171
1172
|
.as-group-new .hint { color: var(--ink2); }
|
|
1172
|
-
.as-group-head { gap: 4px; }
|
|
1173
|
-
.as-chev { flex: 0 0 auto; width: 16px; text-align: center; color: var(--ink2); font-size: .75rem; }
|
|
1174
|
-
.as-group-name { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; justify-content: flex-start; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 3px 6px; }
|
|
1175
|
-
.as-group-name:hover { border-color: var(--line); }
|
|
1176
|
-
.as-group-name[aria-current="true"] { background: var(--panel); border-color: var(--line); }
|
|
1177
|
-
.as-gear { flex: 0 0 auto; width: 30px; height: 30px; min-width: 0 !important; min-height: 0 !important; padding: 0; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ink2); font-size: 1rem; opacity: 1; }
|
|
1178
|
-
/* On a mouse, keep it quiet until the group is hovered or open; on touch (no
|
|
1179
|
-
hover) it must stay visible, or it can never be reached. */
|
|
1180
|
-
@media (hover: hover) { .as-gear { opacity: 0; } .as-group-head:hover .as-gear, .as-group-name[aria-current="true"] + .as-gear { opacity: 1; } }
|
|
1181
|
-
.as-gear:hover { border-color: var(--line); color: var(--ink); }
|
|
1182
1173
|
.as-group-members { display: flex; flex-direction: column; gap: 2px; }
|
|
1183
1174
|
/* Give the group: a block per conversation, a row per asset at its own level. */
|
|
1184
1175
|
.as-give { display: flex; flex-direction: column; gap: 12px; }
|
|
@@ -1207,10 +1198,7 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
|
|
|
1207
1198
|
.as-group-of { display: flex; align-items: center; gap: 10px; }
|
|
1208
1199
|
.as-group-of-label { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|
|
1209
1200
|
.as-group-of select { padding: 6px 9px; border-radius: 8px; }
|
|
1210
|
-
.as-
|
|
1211
|
-
.as-kind-head, .as-chapter { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
1212
|
-
.as-kind-head h3 { margin: 0; padding: 4px 6px; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|
|
1213
|
-
.as-list-top h3 { text-transform: none; letter-spacing: 0; font-size: .8125rem; color: var(--ink); }
|
|
1201
|
+
.as-chapter { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
1214
1202
|
.as-add { width: 30px; height: 30px; min-height: 0 !important; min-width: 0 !important; padding: 0; border-radius: 50%; font-size: 1rem; line-height: 1; color: var(--brass-ink); background: transparent; flex: 0 0 auto; }
|
|
1215
1203
|
.as-add:hover { border-color: var(--brass); }
|
|
1216
1204
|
.as-none { padding: 2px 8px 6px; }
|
|
@@ -2168,7 +2156,7 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
|
|
|
2168
2156
|
.as-signature { display: flex; flex-direction: column; gap: 6px; margin: .6rem 0; }
|
|
2169
2157
|
.as-signature textarea { width: 100%; font: inherit; }
|
|
2170
2158
|
.as-drag-ghost { position: fixed; z-index: 90; pointer-events: none; opacity: .9; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); border-radius: 10px; background: var(--panel); }
|
|
2171
|
-
.
|
|
2159
|
+
.kit-aslist-group.as-drop-over { outline: 2px dashed var(--brass); outline-offset: 2px; border-radius: 10px; background: color-mix(in srgb, var(--brass) 7%, transparent); }
|
|
2172
2160
|
body.as-dragging { user-select: none; -webkit-user-select: none; }
|
|
2173
2161
|
body.as-dragging #assets-rows .as-row { touch-action: none; }
|
|
2174
2162
|
/* A flash started from its button in the thread: Tether's module draws its steps here, over the page. */
|
|
@@ -2793,6 +2781,46 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
|
|
|
2793
2781
|
.kit-conv-row .kit-conv-main > .kit-chips, .kit-conv-sub > .kit-chips { flex: none; margin: 0; gap: 6px; flex-wrap: nowrap; }
|
|
2794
2782
|
.kit-conv-row .kit-conv-main .kit-chip:not([data-tone="count"]) { border: 0; padding: 0; background: none; line-height: inherit; font-size: .75rem; }
|
|
2795
2783
|
|
|
2784
|
+
/* ONE ASSET (06-11, assets step 1: kit.js AssetIcon, AssetCard, RightsBadge, RightsPicker, Holders). Its sign on a
|
|
2785
|
+
tile of its kind's colour; a row (a list), a chip (a pill), a head (atop its panel). */
|
|
2786
|
+
.kit-asset-ic { --ka-ic: 30px; width: var(--ka-ic); height: var(--ka-ic); border-radius: 8px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, currentColor 12%, transparent); color: var(--brass-ink); }
|
|
2787
|
+
.kit-asset-ic svg { width: 57%; height: 57%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
2788
|
+
.kit-asset-ic[data-kind="git"] { color: color-mix(in srgb, var(--danger) 75%, var(--warn)); }
|
|
2789
|
+
.kit-asset-ic[data-kind="mailbox"] { color: var(--wait); }
|
|
2790
|
+
.kit-asset-ic[data-kind="agenda"], .kit-asset-ic[data-kind="contacts"] { color: color-mix(in srgb, var(--wait) 55%, var(--danger)); }
|
|
2791
|
+
.kit-asset-ic[data-kind="secret"], .kit-asset-ic[data-kind="acces"], .kit-asset-ic[data-kind="device"], .kit-asset-ic[data-kind="conversation"] { color: var(--ink2); }
|
|
2792
|
+
.kit-asset-ic[data-kind="list"] { color: var(--ok); }
|
|
2793
|
+
.kit-asset { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; color: var(--ink); }
|
|
2794
|
+
.kit-asset-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
|
2795
|
+
.kit-asset-name { min-width: 0; margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2796
|
+
.kit-asset-sub { display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--ink2); font-size: .75rem; }
|
|
2797
|
+
.kit-asset-sub > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2798
|
+
.kit-asset-sub[data-state="problem"] { color: var(--danger); }
|
|
2799
|
+
.kit-asset-side { flex: none; display: flex; align-items: center; gap: 6px; }
|
|
2800
|
+
.kit-asset-row { width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; }
|
|
2801
|
+
.kit-asset-row:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
|
|
2802
|
+
.kit-asset-row[aria-current="true"] { background: color-mix(in srgb, var(--brass) 14%, transparent); }
|
|
2803
|
+
.kit-asset-chip { display: inline-flex; gap: 6px; max-width: 100%; padding: 2px 10px 2px 3px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: .8125rem; }
|
|
2804
|
+
.kit-asset-chip .kit-asset-ic { --ka-ic: 22px; border-radius: 50%; }
|
|
2805
|
+
.kit-asset-head { gap: 12px; align-items: flex-start; }
|
|
2806
|
+
.kit-asset-head .kit-asset-ic { --ka-ic: 38px; border-radius: 10px; }
|
|
2807
|
+
.kit-asset-head .kit-asset-name { font-size: 1.25rem; white-space: normal; overflow-wrap: anywhere; }
|
|
2808
|
+
.kit-asset-head .kit-asset-sub { font-size: .8125rem; }
|
|
2809
|
+
/* A RIGHT, READ: its tone by what it lets do (reads, changes, uses or watches, none). */
|
|
2810
|
+
.kit-rights { flex: none; padding: 1px 8px; border-radius: 999px; font-size: .6875rem; font-weight: 700; line-height: 1.6; white-space: nowrap; }
|
|
2811
|
+
.kit-rights[data-tone="r"] { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
|
|
2812
|
+
.kit-rights[data-tone="w"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
|
|
2813
|
+
.kit-rights[data-tone="x"] { color: var(--wait); background: color-mix(in srgb, var(--wait) 14%, transparent); }
|
|
2814
|
+
.kit-rights[data-tone="n"] { color: var(--ink2); background: color-mix(in srgb, var(--ink) 6%, transparent); }
|
|
2815
|
+
/* A RIGHT, SET: the Segmented, smaller; it wraps on a narrow screen rather than overflow. */
|
|
2816
|
+
.kit-rights-pick { flex: none; max-width: 100%; flex-wrap: wrap; }
|
|
2817
|
+
.kit-rights-pick > button { min-height: 30px; padding: 0 9px; font-size: .78125rem; font-weight: 600; }
|
|
2818
|
+
/* WHO HAS IT: initials over each other, then "+n"; nobody in grey. */
|
|
2819
|
+
.kit-holders { display: inline-flex; align-items: center; flex: none; }
|
|
2820
|
+
.kit-holders > .kit-av { --kc-av: 22px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
|
|
2821
|
+
.kit-holders > .kit-av + .kit-av { margin-left: -6px; }
|
|
2822
|
+
.kit-holders-more, .kit-holders-none { margin-left: 4px; font-size: .75rem; color: var(--ink2); }
|
|
2823
|
+
|
|
2796
2824
|
/* A MAIL CITED BY ITS REFERENCE (06-11, app.js openMailRef): the same viewer, as a sheet over the thread --
|
|
2797
2825
|
from the bottom on a phone, a panel at the right on a wide screen; where it is now, one line; Reply. */
|
|
2798
2826
|
#viewer.viewer-sheet { padding: 0; align-items: flex-end; background: rgba(8, 11, 15, 0.45); }
|
|
@@ -2811,3 +2839,23 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
|
|
|
2811
2839
|
/* An API key's configuration, shown with it once (06-11). */
|
|
2812
2840
|
.apikeys-config { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); font: .8125rem/1.45 var(--mono, ui-monospace, monospace); white-space: pre; overflow-x: auto; max-width: 100%; }
|
|
2813
2841
|
.apikeys-curl code { word-break: break-all; font-size: .75rem; }
|
|
2842
|
+
|
|
2843
|
+
/* THE ONE LIST OF ASSETS (06-11, kit AssetList): a section per type or per group, an empty type not shown; a group's
|
|
2844
|
+
head folds it, says how many, who has its assets, its ⚙ opens it. Rows are AssetCards. */
|
|
2845
|
+
.kit-aslist { display: flex; flex-direction: column; gap: 2px; }
|
|
2846
|
+
.kit-aslist > .kit-asset-row { margin-bottom: 2px; }
|
|
2847
|
+
.kit-aslist-sec { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; }
|
|
2848
|
+
.kit-aslist-head { display: flex; align-items: center; gap: 6px; min-height: 30px; }
|
|
2849
|
+
.kit-aslist-head h3 { margin: 0; padding: 4px 6px; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2850
|
+
.kit-aslist-fold { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; justify-content: flex-start; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 4px; min-height: 0 !important; }
|
|
2851
|
+
.kit-aslist-fold:hover { border-color: var(--line); }
|
|
2852
|
+
.kit-aslist-fold[aria-current="true"] { background: var(--panel); border-color: var(--line); }
|
|
2853
|
+
.kit-aslist-chev { flex: none; width: 16px; text-align: center; color: var(--ink2); font-size: .75rem; }
|
|
2854
|
+
.kit-aslist-n { flex: none; font-size: .6875rem; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--button); color: var(--ink); }
|
|
2855
|
+
.kit-aslist-gear { flex: none; width: 30px; height: 30px; min-width: 0 !important; min-height: 0 !important; padding: 0; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ink2); font-size: 1rem; }
|
|
2856
|
+
.kit-aslist-gear:hover { border-color: var(--line); color: var(--ink); }
|
|
2857
|
+
@media (hover: hover) { .kit-aslist-gear { opacity: 0; } .kit-aslist-head:hover .kit-aslist-gear, .kit-aslist-gear:focus-visible, .kit-aslist-fold[aria-current="true"] ~ .kit-aslist-gear { opacity: 1; } }
|
|
2858
|
+
.kit-aslist-none, .kit-aslist-said { margin: 2px 8px 4px; font-size: .8125rem; }
|
|
2859
|
+
/* A line that asks for you keeps its shade: soon (warn), past or failing (bad). */
|
|
2860
|
+
.kit-asset-sub[data-tone="warn"] > .state-dot { background: var(--warn); }
|
|
2861
|
+
.kit-asset-sub[data-tone="bad"] { color: var(--danger); }
|