@ponchia/ui 0.4.1 → 0.6.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +552 -8
  2. package/MIGRATIONS.json +106 -0
  3. package/README.md +34 -8
  4. package/annotations/index.d.ts +402 -0
  5. package/annotations/index.d.ts.map +1 -0
  6. package/annotations/index.js +792 -0
  7. package/behaviors/carousel.js +198 -0
  8. package/behaviors/combobox.js +226 -0
  9. package/behaviors/command.js +190 -0
  10. package/behaviors/connectors.js +95 -0
  11. package/behaviors/crosshair.js +57 -0
  12. package/behaviors/dialog.js +74 -0
  13. package/behaviors/disclosure.js +26 -0
  14. package/behaviors/dismissible.js +25 -0
  15. package/behaviors/forms.js +186 -0
  16. package/behaviors/glyph.js +108 -0
  17. package/behaviors/index.d.ts +79 -0
  18. package/behaviors/index.js +18 -1409
  19. package/behaviors/internal.js +97 -0
  20. package/behaviors/legend.js +67 -0
  21. package/behaviors/menu.js +47 -0
  22. package/behaviors/popover.js +179 -0
  23. package/behaviors/spotlight.js +52 -0
  24. package/behaviors/table.js +136 -0
  25. package/behaviors/tabs.js +103 -0
  26. package/behaviors/theme.js +84 -0
  27. package/behaviors/toast.js +164 -0
  28. package/classes/classes.json +1857 -0
  29. package/classes/index.d.ts +306 -13
  30. package/classes/index.js +339 -12
  31. package/classes/vscode.css-custom-data.json +12 -0
  32. package/connectors/index.d.ts +191 -0
  33. package/connectors/index.d.ts.map +1 -0
  34. package/connectors/index.js +275 -0
  35. package/css/analytical.css +21 -0
  36. package/css/annotations.css +292 -0
  37. package/css/app.css +43 -13
  38. package/css/base.css +15 -10
  39. package/css/command.css +97 -0
  40. package/css/connectors.css +110 -0
  41. package/css/content.css +7 -1
  42. package/css/crosshair.css +100 -0
  43. package/css/dataviz.css +5 -1
  44. package/css/disclosure.css +38 -6
  45. package/css/dots.css +57 -0
  46. package/css/feedback.css +111 -2
  47. package/css/fonts.css +11 -7
  48. package/css/forms.css +42 -1
  49. package/css/generated.css +117 -0
  50. package/css/legend.css +272 -0
  51. package/css/marks.css +174 -0
  52. package/css/motion.css +24 -44
  53. package/css/navigation.css +7 -0
  54. package/css/overlay.css +31 -1
  55. package/css/primitives.css +109 -5
  56. package/css/report.css +39 -81
  57. package/css/selection.css +46 -0
  58. package/css/site.css +16 -2
  59. package/css/sources.css +221 -0
  60. package/css/spotlight.css +104 -0
  61. package/css/state.css +121 -0
  62. package/css/tokens.css +60 -37
  63. package/css/workbench.css +83 -0
  64. package/dist/bronto.css +1 -1
  65. package/dist/css/analytical.css +1 -0
  66. package/dist/css/annotations.css +1 -0
  67. package/dist/css/app.css +1 -1
  68. package/dist/css/base.css +1 -1
  69. package/dist/css/command.css +1 -0
  70. package/dist/css/connectors.css +1 -0
  71. package/dist/css/content.css +1 -1
  72. package/dist/css/crosshair.css +1 -0
  73. package/dist/css/disclosure.css +1 -1
  74. package/dist/css/dots.css +1 -1
  75. package/dist/css/feedback.css +1 -1
  76. package/dist/css/fonts.css +1 -1
  77. package/dist/css/forms.css +1 -1
  78. package/dist/css/generated.css +1 -0
  79. package/dist/css/legend.css +1 -0
  80. package/dist/css/marks.css +1 -0
  81. package/dist/css/motion.css +1 -1
  82. package/dist/css/navigation.css +1 -1
  83. package/dist/css/overlay.css +1 -1
  84. package/dist/css/primitives.css +1 -1
  85. package/dist/css/report.css +1 -1
  86. package/dist/css/selection.css +1 -0
  87. package/dist/css/site.css +1 -1
  88. package/dist/css/sources.css +1 -0
  89. package/dist/css/spotlight.css +1 -0
  90. package/dist/css/state.css +1 -0
  91. package/dist/css/tokens.css +1 -1
  92. package/dist/css/workbench.css +1 -0
  93. package/docs/adr/0003-theme-model.md +7 -4
  94. package/docs/annotations.md +425 -0
  95. package/docs/architecture.md +246 -0
  96. package/docs/command.md +95 -0
  97. package/docs/connectors.md +91 -0
  98. package/docs/contrast.md +116 -92
  99. package/docs/crosshair.md +63 -0
  100. package/docs/d2.md +195 -0
  101. package/docs/generated.md +91 -0
  102. package/docs/legends.md +184 -0
  103. package/docs/marks.md +93 -0
  104. package/docs/mermaid.md +152 -0
  105. package/docs/reference.md +385 -23
  106. package/docs/reporting.md +436 -63
  107. package/docs/selection.md +40 -0
  108. package/docs/sources.md +137 -0
  109. package/docs/spotlight.md +78 -0
  110. package/docs/stability.md +24 -2
  111. package/docs/state.md +85 -0
  112. package/docs/usage.md +123 -4
  113. package/docs/vega.md +225 -0
  114. package/docs/workbench.md +78 -0
  115. package/fonts/doto-400.woff2 +0 -0
  116. package/fonts/doto-500.woff2 +0 -0
  117. package/fonts/doto-600.woff2 +0 -0
  118. package/fonts/doto-700.woff2 +0 -0
  119. package/fonts/doto-800.woff2 +0 -0
  120. package/fonts/doto-900.woff2 +0 -0
  121. package/glyphs/glyphs.js +6 -4
  122. package/llms.txt +362 -14
  123. package/package.json +115 -12
  124. package/qwik/index.d.ts +42 -54
  125. package/qwik/index.d.ts.map +1 -0
  126. package/qwik/index.js +75 -3
  127. package/react/index.d.ts +39 -56
  128. package/react/index.d.ts.map +1 -0
  129. package/react/index.js +67 -3
  130. package/solid/index.d.ts +64 -56
  131. package/solid/index.d.ts.map +1 -0
  132. package/solid/index.js +70 -3
  133. package/tokens/d2.d.ts +38 -0
  134. package/tokens/d2.js +71 -0
  135. package/tokens/d2.json +43 -0
  136. package/tokens/index.d.ts +5 -5
  137. package/tokens/index.js +23 -5
  138. package/tokens/index.json +9 -0
  139. package/tokens/mermaid.d.ts +23 -0
  140. package/tokens/mermaid.js +181 -0
  141. package/tokens/mermaid.json +163 -0
  142. package/tokens/resolved.json +45 -1
  143. package/tokens/skins.js +3 -2
  144. package/tokens/tokens.dtcg.json +26 -0
  145. package/tokens/vega.d.ts +34 -0
  146. package/tokens/vega.js +155 -0
  147. package/tokens/vega.json +179 -0
  148. package/fonts/doto-400.ttf +0 -0
  149. package/fonts/doto-500.ttf +0 -0
  150. package/fonts/doto-600.ttf +0 -0
  151. package/fonts/doto-700.ttf +0 -0
  152. package/fonts/doto-800.ttf +0 -0
  153. package/fonts/doto-900.ttf +0 -0
@@ -0,0 +1,152 @@
1
+ # Mermaid
2
+
3
+ [Mermaid](https://mermaid.js.org) renders diagrams (flowcharts, sequence, pie,
4
+ git, gantt…) from text to **SVG**. `@ponchia/ui` does not render diagrams — it
5
+ **themes** the ones you already have and lets you **annotate** them, the same way
6
+ it dresses any other SVG figure in a report. Two things ship:
7
+
8
+ - `@ponchia/ui/mermaid` — a resolved Mermaid `base` theme, per bronto theme.
9
+ - `@ponchia/ui/mermaid.json` — the same data as plain JSON, for any consumer.
10
+
11
+ Mermaid stays the consumer's renderer. This is config only: bronto never imports
12
+ or runs Mermaid, and Mermaid is **not** a dependency.
13
+
14
+ ## Theme a diagram
15
+
16
+ Mermaid's `base` theme is the only one meant to be customized. Hand it the
17
+ bronto theme variables:
18
+
19
+ ```js
20
+ import mermaid from 'mermaid';
21
+ import { brontoMermaidTheme } from '@ponchia/ui/mermaid';
22
+
23
+ mermaid.initialize(brontoMermaidTheme()); // light
24
+ await mermaid.run();
25
+ ```
26
+
27
+ `brontoMermaidTheme(theme)` returns `{ theme: 'base', themeVariables }` ready to
28
+ spread into `initialize`. Pass `'dark'` for the dark palette, or read the active
29
+ bronto theme:
30
+
31
+ ```js
32
+ const theme = document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light';
33
+ mermaid.initialize(brontoMermaidTheme(theme));
34
+ ```
35
+
36
+ You can also splice the variables into a single diagram via an init directive,
37
+ or read the raw maps (`import { mermaid } from '@ponchia/ui/mermaid'` →
38
+ `{ light, dark }`). For a build step or non-JS host, read
39
+ `@ponchia/ui/mermaid.json` directly.
40
+
41
+ > **file:// portability.** A report opened straight from disk (`file://`) cannot
42
+ > `import` the `@ponchia/ui/mermaid` module **nor** `fetch('…/mermaid.json')` —
43
+ > the browser blocks both across the `null`/file origin (CORS), exactly as with
44
+ > [Vega](./vega.md#from-a-cdn-no-bundler). So for a double-clickable or PDF-bound
45
+ > report either **inline the theme variables** (paste the object for your theme
46
+ > from `mermaid.json` into the init directive) or, better, **pre-render to a
47
+ > frozen SVG** with the Mermaid CLI (`mmdc`, below) so there is no runtime at
48
+ > all. Over an `http(s)` origin the `import`/`fetch` forms both work.
49
+
50
+ The result is monochrome surfaces and lines with the rationed accent reserved
51
+ for notes — a diagram that looks like the rest of a bronto surface and
52
+ **re-skins for free** when you change `--accent`, exactly like the chart palette.
53
+
54
+ ### Why resolved colours, not `var(--x)`
55
+
56
+ Mermaid's theming engine derives shades (lighten/darken) from your seed colours,
57
+ so it only understands real colours — a `var(--accent)` string breaks
58
+ derivation. The theme map therefore ships **resolved hex/rgba per theme**,
59
+ projected from the same token source that feeds
60
+ [`tokens/resolved.json`](./architecture.md) and `charts.json`. That projection
61
+ is the bridge a CSS-first system needs until Mermaid can read CSS variables
62
+ directly. It also means the theme is **static per theme**: on a light/dark
63
+ switch, re-`initialize` with the other palette and re-render.
64
+
65
+ ### Which diagrams get the palette
66
+
67
+ - **Chart-like** diagrams carry a categorical series palette — **pie**
68
+ (`pie1`…`pie12`), **git** (`git0`…`git7`), and **user-journey**
69
+ (`fillType0`…`fillType7`) are wired to the CVD-safe
70
+ [charts palette](./legends.md) (series 1 = the live accent).
71
+ - **Structural** diagrams — flowchart, sequence, class, ER, state — use the
72
+ monochrome node/edge/cluster grammar and spend the accent only on notes.
73
+ - **Not themed: `gantt` and `timeline`.** Their colours come from
74
+ diagram-specific slots (`taskBkgColor`, `sectionBkgColor*`, `gridColor`,
75
+ `todayLineColor`, …) that the base `themeVariables` map does **not** set, so a
76
+ gantt/timeline renders with Mermaid's own off-brand defaults (red/grey bars),
77
+ not the bronto palette. For a **report timeline**, prefer the native,
78
+ fully-themed [`ui-timeline`](./reporting.md) primitive (it also prints and
79
+ needs no renderer); reach for a Mermaid gantt only when you specifically need
80
+ its scheduling layout, and accept its default colours.
81
+
82
+ Pie wedge labels (`pieSectionTextColor`) sit on arbitrary palette colours; if a
83
+ label is hard to read on a given wedge, prefer a legend or direct labels over
84
+ recolouring.
85
+
86
+ ### Fit to small screens
87
+
88
+ The theme map sets colours, not size — sizing stays Mermaid's. Keep `useMaxWidth`
89
+ on (the default for most diagram types) so each SVG scales to its container
90
+ instead of forcing page-wide horizontal scroll:
91
+
92
+ ```js
93
+ mermaid.initialize({
94
+ ...brontoMermaidTheme(theme),
95
+ flowchart: { useMaxWidth: true },
96
+ sequence: { useMaxWidth: true },
97
+ });
98
+ ```
99
+
100
+ A genuinely wide diagram (a long flowchart, a big ER) can still be unreadable
101
+ once squeezed onto a phone. Rather than let it overflow the page, wrap the render
102
+ in a scroll container so the *diagram* scrolls, not the document — the same
103
+ pattern the report layer uses for wide figures and tables:
104
+
105
+ ```css
106
+ .diagram-scroll {
107
+ overflow-x: auto;
108
+ }
109
+ ```
110
+
111
+ ## Annotate a diagram
112
+
113
+ Mermaid output is SVG, and the [annotation layer](./annotations.md) is
114
+ renderer-agnostic SVG — so a `<g class="ui-annotation">` callout composes onto a
115
+ rendered diagram the same as onto any figure. bronto supplies the geometry and
116
+ the styling; **placing a callout on a specific node is yours**, because that
117
+ means reading Mermaid's laid-out coordinates, which bronto deliberately does not
118
+ own (no scales, no DOM, no hit-testing — see [annotations.md](./annotations.md)).
119
+
120
+ The robust path is **build-time**, mirroring the
121
+ [static-report recipe](./annotations.md#using-the-helpers-in-a-static-no-js-report):
122
+
123
+ 1. Pre-render the diagram to a frozen SVG with the Mermaid CLI
124
+ (`mmdc -t base -i diagram.mmd -o diagram.svg`, feeding the same
125
+ `themeVariables`).
126
+ 2. From that SVG, read the target node's box (`getBBox()` / the node's
127
+ `transform`), accounting for the diagram's root `<g>` translate and the
128
+ `viewBox`.
129
+ 3. Compute the callout strings with `@ponchia/ui/annotations` and paste a
130
+ `<g class="ui-annotation …">` into the SVG at those coordinates.
131
+
132
+ The output is a static, on-brand, annotated SVG with no runtime — ideal for the
133
+ [report layer](./reporting.md).
134
+
135
+ To annotate a **live** client render instead, run the same measure-and-inject
136
+ pass on the SVG returned by `mermaid.render()`, after it is in the DOM. Two
137
+ honest caveats, both inherent to overlaying a foreign renderer (not bronto
138
+ limitations):
139
+
140
+ - **Mermaid's internal SVG structure is not a public contract.** Node ids and
141
+ classes are undocumented and have changed across major versions. Match nodes
142
+ by your own author-supplied id substring, measure positions rather than
143
+ hard-coding them, and **pin your Mermaid version**.
144
+ - **Every re-render replaces the SVG**, discarding injected overlays. Re-apply
145
+ the annotation pass after each `render()` / theme switch / resize.
146
+
147
+ ## Scope
148
+
149
+ bronto owns the theme map (gated: every value resolves to a colour, both themes,
150
+ no `var()` leaks) and the annotation geometry. It does **not** own Mermaid's
151
+ rendering, its internal DOM, or its re-render lifecycle — those stay Mermaid's,
152
+ and the overlay above is a documented composition, not a shipped runtime binding.