create-pmos 0.668.0 → 0.670.0

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.
@@ -0,0 +1,54 @@
1
+ /* pm/set-ds.js — the parts Settings is drawn from (initiative settings-ds-page; Exploring 3 page "pages", board SettingsDS; brief
2
+ * design-system/pages-rebuild/brief.md, Settings). Built only from PMOS Komorebi parts (workspace/design-system/ui): Settings rows (pm-set),
3
+ * Tabs as the way picker (pm-tabs, role radiogroup), the switch (pm-switch), the expanded Suggestion (pm-sug x, from bd-stands.js).
4
+ * PURE: no DOM, no fetch. pm/cozy-settings.js draws them and wires the presses by their data-ev- attributes (unchanged).
5
+ *
6
+ * SECTIONS the sections at the left, in the board's order, then Workspaces and Updates (nothing dropped)
7
+ * row(title, sub, right) one Settings row
8
+ * seg(label, key, cur, opts) Tabs that pick one value
9
+ * sw(on, attrs, label) a switch
10
+ * kindMeta(k) "31 made · 29 kept"
11
+ * sugOf(kinds, no) the one Suggestion on How PMOS decides, from what you kept and undid, or null
12
+ * sugHtml(s) its expanded form: Why, PMOS will, What changes, Based on; Change it first, Yes, No
13
+ *
14
+ * NOTHING HERE MAKES A FACT UP: a Suggestion needs at least MIN changes of one kind, and says the counts it rests on. */
15
+ import { sugHtml as sugBlock } from './bd-stands.js';
16
+
17
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
18
+ export const SECTIONS = [['general', 'General'], ['claude', 'How PMOS decides'], ['checks', 'Checks'], ['rules', 'Prototype rules'], ['connectors', 'Connectors'],
19
+ ['account', 'Your account'], ['workspaces', 'Workspaces'], ['updates', 'Updates']];
20
+ export const MIN = 5;
21
+ export const WAYS = { quiet: 'Quietly', show: 'Show me', ask: 'Ask first' };
22
+
23
+ export const row = (title, sub, right) => `<div class="ev-trow pm-set"><div class="ev-tx"><b>${esc(title)}</b>${sub ? `<p class="pm-meta">${esc(sub)}</p>` : ''}</div>${right}</div>`;
24
+ export const seg = (label, key, cur, opts) => `<span class="pm-tabs" role="radiogroup" aria-label="${esc(label)}">${opts.map(([k, w]) => {
25
+ const on = String(cur) === String(k);
26
+ return `<button type="button" class="pm-tab" role="radio" data-ev-seg="${esc(key)}" data-v="${esc(k)}" aria-checked="${on}" aria-selected="${on}">${esc(w)}</button>`;
27
+ }).join('')}</span>`;
28
+ export const sw = (on, attrs, label) => `<button type="button" class="pm-switch" role="switch" aria-checked="${!!on}" aria-label="${esc(label)}" ${attrs}></button>`;
29
+ export const kindMeta = (k) => `${k.made || 0} made · ${k.kept || 0} kept`;
30
+
31
+ const low = (s) => String(s || '').charAt(0).toLowerCase() + String(s || '').slice(1);
32
+ /** The one Suggestion. First a kind PMOS made at least MIN times that you never undid and that still shows or asks: Quietly. Else a kind you
33
+ * set to Quietly yourself and undid at least twice: Ask first. `no`: the "kind:way" pairs you said No to. → s | null */
34
+ export function sugOf(kinds, no = new Set()) {
35
+ const K = Array.isArray(kinds) ? kinds : [];
36
+ const up = K.find((k) => k.made >= MIN && !k.undone && k.kept === k.made && k.way !== 'quiet' && !no.has(k.kind + ':quiet'));
37
+ if (up) return {
38
+ kind: up.kind, to: 'quiet', title: `Let PMOS ${low(up.label)} quietly`,
39
+ why: `PMOS made ${up.made} of these by itself and you kept all ${up.made}. You undid none.`,
40
+ will: [`Set ${up.label} to Quietly`, 'Keep Undo on each one'],
41
+ changes: `These no longer wait in PMOS did; each one still has Undo.`,
42
+ basis: `The ${up.made} changes of this kind and your Undos`,
43
+ };
44
+ const down = K.find((k) => k.set === 'quiet' && k.undone >= 2 && !no.has(k.kind + ':ask'));
45
+ if (down) return {
46
+ kind: down.kind, to: 'ask', title: `Let PMOS ask first before it does ${low(down.label)}`,
47
+ why: `You set it to Quietly and then undid ${down.undone} of ${down.made}.`,
48
+ will: [`Set ${down.label} to Ask first`],
49
+ changes: 'PMOS waits for your yes before each one.',
50
+ basis: `The ${down.made} changes of this kind and your ${down.undone} Undos`,
51
+ };
52
+ return null;
53
+ }
54
+ export const sugHtml = (s) => (s ? sugBlock(s, `data-kind="${esc(s.kind)}" data-to="${esc(s.to)}"`, 'data-ev-sug') : '');
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Settings rebuilt from design system blocks (initiative settings-ds-page, done test C1-C6): pm/set-ds.js, pm/cozy-settings.js sections and rows. Pure, node.",
3
+ "modules": [
4
+ "set-ds.test.js"
5
+ ],
6
+ "seconds": {
7
+ "set-ds.test.js": 2
8
+ }
9
+ }