plggmatic 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +115 -4
  2. package/package.json +11 -9
package/README.md CHANGED
@@ -14,7 +14,118 @@ The vocabulary is one word per concept: **Column**, **Pane**, **Alignment**,
14
14
  **Token**, **Scheme**. The design system is emergent — seeded minimal, one
15
15
  recorded rule per component.
16
16
 
17
- This is the UI design framework — distinct from the app-framework facade that
18
- [plggpress](../plggpress/) absorbed. See the documentation site in
19
- [`packages/site/`](../site/) and the workbench demo in
20
- [`packages/plggmatic-example/`](../plggmatic-example/).
17
+ This is the UI design framework, canonical in this monorepo (decision D13). See
18
+ the reference app in [`packages/plggmatic-example/`](../plggmatic-example/).
19
+
20
+ **Disambiguation — "plggmatic" has two historical meanings.** (a) A retired
21
+ 2026-06/07 *app-framework facade*, absorbed into
22
+ [`plggpress/src/framework/`](../plggpress/src/framework/) in `31fdee9`; archived
23
+ tickets and their "rewire map" tables describe *that* plggmatic — do not apply
24
+ them to this package. (b) *This* package — the UI design framework — re-imported
25
+ at `6d7a832` and canonical here (D13). This note is the single source of the
26
+ distinction; other sites link here rather than repeating it.
27
+
28
+ ## The declarative scheduler (framework half)
29
+
30
+ plggmatic is not only the design system — its essence is **declarative
31
+ definition of menus, data lists/details, actions, search, and flows, from which
32
+ a UI program is automatically _scheduled_** (D1). You write a **declaration** as
33
+ data; `schedule(...)` derives the whole plgg-view program except the view — the
34
+ `Model`, the `Msg` union, a pure `update`, and a total URL codec — plus a typed
35
+ `Scene` a renderer draws. The vocabulary is **mode-agnostic** (D10): no
36
+ declaration or derived type names a column, pane, drawer, or screen. Renderers
37
+ (tickets 10/11) project the derived level stack into a display.
38
+
39
+ ```ts
40
+ import {
41
+ schedule, declare, menu, menuEntry,
42
+ collection, sync, query, makeRow,
43
+ } from "plggmatic";
44
+ import { application } from "plgg-view/client";
45
+
46
+ // a declaration — pure data, performs nothing
47
+ const app = declare({
48
+ title: "Field Notes",
49
+ menu: menu([menuEntry("Sections", "sections")]),
50
+ collections: [
51
+ collection<Section>({
52
+ id: "sections",
53
+ title: "Sections",
54
+ toRow: (s) => makeRow(s.id, s.label),
55
+ source: sync(() => sections),
56
+ child: "notes",
57
+ query: query("Filter"),
58
+ }),
59
+ collection<Note>({
60
+ id: "notes",
61
+ title: "Notes",
62
+ toRow: (n) => makeRow(n.id, n.title, [/*…*/]),
63
+ source: sync((path) => notesFor(path[0])),
64
+ }),
65
+ ],
66
+ });
67
+
68
+ // schedule derives init/update/onUrlChange/toUrl/scene;
69
+ // a renderer supplies the missing `view`
70
+ const s = schedule(app);
71
+ application({
72
+ ...s,
73
+ view: (m) => render(s.scene(m)),
74
+ })(document.getElementById("root")!);
75
+ ```
76
+
77
+ ### Two modes, one declaration (D10)
78
+
79
+ The scheduled `Scene` is **mode-agnostic**: the multi-column renderer draws it
80
+ as panes expanding rightward, the single-column renderer as one operation per
81
+ screen, and `renderMode(mode)(scene)` dispatches between them. A consumer holds
82
+ the `Mode` *beside* the scheduled model (never in it), and a flip mid-flow is
83
+ loss-free by construction — same flow position, selection, query, confirmation,
84
+ and URL:
85
+
86
+ ```ts
87
+ import {
88
+ schedule, renderMode, toggleMode,
89
+ type Mode,
90
+ } from "plggmatic";
91
+
92
+ const scheduled = schedule(app);
93
+
94
+ // the consumer's model = scheduled model + a Mode
95
+ type Model = { scheduled: ScheduledModel; mode: Mode };
96
+
97
+ const view = (model: Model) =>
98
+ renderMode(model.mode)(
99
+ scheduled.scene(model.scheduled),
100
+ );
101
+ // a "toggle mode" button dispatches toggleMode(model.mode)
102
+ ```
103
+
104
+ The vocabulary — **Resource/Collection** (sync or async through one shape),
105
+ **Menu**, **Row** (the list/detail projection), **Action** (create/update/delete
106
+ with confirmation-as-data), **Query**, and the **Flow** graph (menu roots +
107
+ each collection's `child`) — is a set of closed unions consumed with exhaustive
108
+ `match`, so adding a variant is a compile error at every interpreter. Effects
109
+ are `Cmd` data: an `async` source read and an `Action`'s verb are _returned_ by
110
+ `update`, never run by it. See the runnable proof-of-value — the reference app
111
+ is itself a declaration scheduled and drawn by the multi-column renderer —
112
+ in [`packages/plggmatic-example/`](../plggmatic-example/) (`src/declaration.ts` +
113
+ `src/app.ts`; the form components have their own showcase in `src/forms/`), and
114
+ the design record at
115
+ [`.workaholic/specs/20260704-plggmatic-scheduler-design.md`](../../.workaholic/specs/20260704-plggmatic-scheduler-design.md).
116
+
117
+ ## Palette override & scheme persistence
118
+
119
+ The color system is a closed role×variant matrix with a **monochrome default**.
120
+ Two consumer seams:
121
+
122
+ - **Override** — `defaultPalette` is the shipped monochrome palette; an app
123
+ validates its own brand colors with `asPalette` (`unknown` → `Result`, a
124
+ missing scheme/token/bad-hex is an `Err` naming the path) and emits the CSS
125
+ with `schemeCssOf`. `contrastRatio` runs the same WCAG math the phase-1 gate
126
+ uses so an override can be audited. Atoms and `var(--pm-*)` are untouched.
127
+ - **Persistence** — the contract is framework-owned: one storage key
128
+ `appearanceStorageKey` = **`vp-appearance`** (preserved per D16), one
129
+ mechanism **`html.dark`**, a no-FOUC `appearanceInitScript` +
130
+ `injectAppearanceScript`, a pure `decideScheme`, and an `applyScheme` effect
131
+ helper. Every consumer schemes identically — no per-app key drift.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plggmatic",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "A column-oriented UI design framework on the plgg family: pane alignment, a typed light/dark color scheme, and fundamental components as pure functions returning plgg-view Html",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
@@ -23,27 +23,29 @@
23
23
  "tsc:watch": "tsc --noEmit --watch",
24
24
  "test:watch": "plgg-test src --watch",
25
25
  "coverage": "tsc --noEmit && plgg-test src --coverage",
26
- "coverage:watch": "plgg-test src --coverage --watch",
27
- "publish": "npm run build && npm publish"
26
+ "coverage:watch": "plgg-test src --coverage --watch"
28
27
  },
29
28
  "repository": {
30
29
  "type": "git",
31
- "url": "git+https://github.com/qmu/plggmatic.git"
30
+ "url": "git+https://github.com/qmu/plgg.git"
32
31
  },
33
32
  "author": "qmu",
34
33
  "license": "MIT",
35
34
  "bugs": {
36
- "url": "https://github.com/qmu/plggmatic/issues"
35
+ "url": "https://github.com/qmu/plgg/issues"
37
36
  },
38
- "homepage": "https://github.com/qmu/plggmatic#readme",
37
+ "homepage": "https://github.com/qmu/plgg#readme",
39
38
  "dependencies": {
40
39
  "plgg": "^0.0.27",
41
- "plgg-view": "^0.0.1"
40
+ "plgg-ir-language": "^0.0.2",
41
+ "plgg-ir-manifest": "^0.0.2",
42
+ "plgg-ir-syntax": "^0.0.1",
43
+ "plgg-view": "^0.0.2"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@types/node": "^25.6.0",
45
- "plgg-bundle": "^0.0.2",
46
- "plgg-test": "^0.0.3",
47
+ "plgg-bundle": "^0.0.6",
48
+ "plgg-test": "^0.0.5",
47
49
  "typescript": "^6.0.3"
48
50
  }
49
51
  }