@tempoxyz/ds 0.3.15 → 0.3.17

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 (130) hide show
  1. package/dist/docs/AGENTS.md +10 -6
  2. package/dist/docs/arsenal.md +44 -0
  3. package/dist/docs/marketing.md +703 -4
  4. package/dist/docs/product/components/actions.md +53 -1
  5. package/dist/docs/product/components/blockchain.md +147 -3
  6. package/dist/docs/product/components/feedback-and-status.md +137 -7
  7. package/dist/docs/product/components/navigation.md +1 -1
  8. package/dist/docs/product/documents.md +225 -0
  9. package/dist/docs/product/foundations.md +2 -1
  10. package/dist/docs/product/patterns.md +3 -22
  11. package/dist/document/Document.d.ts +46 -0
  12. package/dist/document/Document.d.ts.map +1 -0
  13. package/dist/document/Document.js +190 -0
  14. package/dist/document/Document.js.map +1 -0
  15. package/dist/document/Enhance.d.ts +13 -0
  16. package/dist/document/Enhance.d.ts.map +1 -0
  17. package/dist/document/Enhance.js +421 -0
  18. package/dist/document/Enhance.js.map +1 -0
  19. package/dist/document/bin.d.ts +3 -0
  20. package/dist/document/bin.d.ts.map +1 -0
  21. package/dist/document/bin.js +38 -0
  22. package/dist/document/bin.js.map +1 -0
  23. package/dist/document/document.css +373 -0
  24. package/dist/document/index.d.ts +3 -0
  25. package/dist/document/index.d.ts.map +1 -0
  26. package/dist/document/index.js +3 -0
  27. package/dist/document/index.js.map +1 -0
  28. package/dist/document/internal/Cli.d.ts +43 -0
  29. package/dist/document/internal/Cli.d.ts.map +1 -0
  30. package/dist/document/internal/Cli.js +87 -0
  31. package/dist/document/internal/Cli.js.map +1 -0
  32. package/dist/document/internal/Template.d.ts +21 -0
  33. package/dist/document/internal/Template.d.ts.map +1 -0
  34. package/dist/document/internal/Template.js +15 -0
  35. package/dist/document/internal/Template.js.map +1 -0
  36. package/dist/document/script.d.ts +2 -0
  37. package/dist/document/script.d.ts.map +1 -0
  38. package/dist/document/script.js +379 -0
  39. package/dist/document/templates/brief.html +96 -0
  40. package/dist/document/templates/essay.html +70 -0
  41. package/dist/document/templates/post.html +69 -0
  42. package/dist/marketing/index.js.zyzz.json +1 -1
  43. package/dist/marketing/vars.d.ts +618 -758
  44. package/dist/marketing/vars.d.ts.map +1 -1
  45. package/dist/marketing/vars.js +8 -5
  46. package/dist/marketing/vars.js.map +1 -1
  47. package/dist/marketing/vars.js.zyzz.json +1 -1
  48. package/dist/marketing/zyzz.config.d.ts +3042 -3757
  49. package/dist/marketing/zyzz.config.d.ts.map +1 -1
  50. package/dist/marketing/zyzz.config.js +1 -1
  51. package/dist/marketing/zyzz.config.js.map +1 -1
  52. package/dist/marketing/zyzz.config.js.zyzz.json +1 -1
  53. package/dist/mobile/components/Button.d.ts +115 -15
  54. package/dist/mobile/components/Button.d.ts.map +1 -1
  55. package/dist/mobile/components/Button.js +85 -14
  56. package/dist/mobile/components/Button.js.map +1 -1
  57. package/dist/mobile/components/IconButton.d.ts +129 -40
  58. package/dist/mobile/components/IconButton.d.ts.map +1 -1
  59. package/dist/mobile/components/IconButton.js +97 -28
  60. package/dist/mobile/components/IconButton.js.map +1 -1
  61. package/dist/mobile/components/TextInput.d.ts +132 -11
  62. package/dist/mobile/components/TextInput.d.ts.map +1 -1
  63. package/dist/mobile/components/TextInput.js +115 -14
  64. package/dist/mobile/components/TextInput.js.map +1 -1
  65. package/dist/mobile/index.d.ts +1 -0
  66. package/dist/mobile/index.d.ts.map +1 -1
  67. package/dist/mobile/index.js +1 -0
  68. package/dist/mobile/index.js.map +1 -1
  69. package/dist/mobile/vars.d.ts +103 -0
  70. package/dist/mobile/vars.d.ts.map +1 -1
  71. package/dist/mobile/vars.js +74 -0
  72. package/dist/mobile/vars.js.map +1 -1
  73. package/dist/mobile/zyzz.config.d.ts +408 -0
  74. package/dist/mobile/zyzz.config.d.ts.map +1 -1
  75. package/dist/web/components/AddressCard.js.zyzz.json +1 -1
  76. package/dist/web/components/Amount.css +1 -1
  77. package/dist/web/components/Amount.d.ts +9 -0
  78. package/dist/web/components/Amount.d.ts.map +1 -1
  79. package/dist/web/components/Amount.js +8 -5
  80. package/dist/web/components/Amount.js.map +1 -1
  81. package/dist/web/components/Amount.js.zyzz.json +1 -1
  82. package/dist/web/components/CopyButton.d.ts +6 -0
  83. package/dist/web/components/CopyButton.d.ts.map +1 -1
  84. package/dist/web/components/CopyButton.js +4 -1
  85. package/dist/web/components/CopyButton.js.map +1 -1
  86. package/dist/web/components/CopyButton.js.zyzz.json +1 -1
  87. package/dist/web/components/Hex.css +1 -1
  88. package/dist/web/components/Hex.d.ts +84 -3
  89. package/dist/web/components/Hex.d.ts.map +1 -1
  90. package/dist/web/components/Hex.js +20 -13
  91. package/dist/web/components/Hex.js.map +1 -1
  92. package/dist/web/components/Hex.js.zyzz.json +1 -1
  93. package/dist/web/components/Progress.css +1 -1
  94. package/dist/web/components/Progress.d.ts +12 -2
  95. package/dist/web/components/Progress.d.ts.map +1 -1
  96. package/dist/web/components/Progress.js +9 -5
  97. package/dist/web/components/Progress.js.map +1 -1
  98. package/dist/web/components/Progress.js.zyzz.json +1 -1
  99. package/dist/web/components/SecretValue.js.zyzz.json +1 -1
  100. package/dist/web/components/SidebarMenu.d.ts +4 -4
  101. package/dist/web/components/SidebarMenu.js +6 -6
  102. package/dist/web/components/SidebarMenu.js.map +1 -1
  103. package/dist/web/components/Snippet.js.zyzz.json +1 -1
  104. package/dist/web/index.js.zyzz.json +1 -1
  105. package/package.json +19 -1
  106. package/src/document/Document.ts +277 -0
  107. package/src/document/Enhance.ts +434 -0
  108. package/src/document/bin.ts +38 -0
  109. package/src/document/document.css +373 -0
  110. package/src/document/index.ts +2 -0
  111. package/src/document/internal/Cli.ts +132 -0
  112. package/src/document/internal/Template.ts +25 -0
  113. package/src/document/script.ts +8 -0
  114. package/src/document/templates/brief.html +96 -0
  115. package/src/document/templates/essay.html +70 -0
  116. package/src/document/templates/post.html +69 -0
  117. package/src/marketing/README.md +1 -1
  118. package/src/marketing/vars.ts +526 -604
  119. package/src/marketing/zyzz.config.ts +5 -4
  120. package/src/mobile/README.md +19 -6
  121. package/src/mobile/components/Button.tsx +94 -17
  122. package/src/mobile/components/IconButton.tsx +122 -30
  123. package/src/mobile/components/TextInput.tsx +139 -24
  124. package/src/mobile/index.ts +1 -0
  125. package/src/mobile/vars.ts +74 -0
  126. package/src/web/components/Amount.tsx +37 -3
  127. package/src/web/components/CopyButton.tsx +8 -0
  128. package/src/web/components/Hex.tsx +79 -13
  129. package/src/web/components/Progress.tsx +8 -2
  130. package/src/web/components/SidebarMenu.tsx +6 -6
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tempoxyz/ds",
3
3
  "type": "module",
4
- "version": "0.3.15",
4
+ "version": "0.3.17",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "DESIGN.md",
@@ -16,6 +16,10 @@
16
16
  "!src/**/__screenshots__/**"
17
17
  ],
18
18
  "description": "Tempo Design System",
19
+ "bin": {
20
+ "tempo-document": "./dist/document/bin.js",
21
+ "tempo-document.src": "./src/document/bin.ts"
22
+ },
19
23
  "dependencies": {
20
24
  "@base-ui/react": "^1.8.0",
21
25
  "@oxlint/plugins": "1.79.0",
@@ -31,6 +35,20 @@
31
35
  "types": "./dist/web/index.d.ts",
32
36
  "default": "./dist/web/index.js"
33
37
  },
38
+ "./document": {
39
+ "src": "./src/document/index.ts",
40
+ "types": "./dist/document/index.d.ts",
41
+ "default": "./dist/document/index.js"
42
+ },
43
+ "./document.css": {
44
+ "src": "./src/document/document.css",
45
+ "default": "./dist/document/document.css"
46
+ },
47
+ "./document.js": {
48
+ "src": "./src/document/script.ts",
49
+ "types": "./dist/document/script.d.ts",
50
+ "default": "./dist/document/script.js"
51
+ },
34
52
  "./fonts/Inter-cyrillic-ext.woff2": {
35
53
  "src": "./src/fonts/Inter-cyrillic-ext.woff2",
36
54
  "default": "./dist/fonts/Inter-cyrillic-ext.woff2"
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Document mode: the markup contract for agent-written HTML documents, and a lint that checks a
3
+ * document against it. Documents link `@tempoxyz/ds/document.css` and `@tempoxyz/ds/document.js`,
4
+ * or the same files at `dist/document/document.css` and `dist/document/script.js` on a CDN.
5
+ * @module
6
+ */
7
+
8
+ /** Classes an author may write. Anything else is outside the contract. */
9
+ export const classes = [
10
+ 'brief',
11
+ 'byline',
12
+ 'chart',
13
+ 'chart-key',
14
+ 'chart-plot',
15
+ 'chart-scroll',
16
+ 'axis',
17
+ 'chronology',
18
+ 'dek',
19
+ 'doc',
20
+ 'facts',
21
+ 'figures',
22
+ 'fill-ink',
23
+ 'fill-line',
24
+ 'fill-quiet',
25
+ 'input',
26
+ 'kv',
27
+ 'l-body',
28
+ 'l-outset',
29
+ 'l-page',
30
+ 'l-screen',
31
+ 'minor',
32
+ 'n',
33
+ 'note',
34
+ 'outcome',
35
+ 'phase',
36
+ 'results',
37
+ 'sn',
38
+ 'steps',
39
+ 'summary',
40
+ 'swatch',
41
+ ] as const
42
+
43
+ /** Classes allowed inside inline SVG diagrams and charts. */
44
+ export const svgClasses = [
45
+ 'fill-ink',
46
+ 'fill-line',
47
+ 'fill-quiet',
48
+ 'hair',
49
+ 'ink',
50
+ 'label',
51
+ 'meta',
52
+ ] as const
53
+
54
+ /** The templates an `article.doc` can name in `data-template`. */
55
+ export const templates = ['brief', 'essay', 'post'] as const
56
+
57
+ // Patterns that read as UI rather than a document. Matched against whole class names.
58
+ const banned = /^(?:badge|badges|callout|card|cards|chip|chips|pill|pills|tab|tabs|tag|tags)$/
59
+
60
+ // The built script and stylesheet, by package path or by the export names a copied file keeps.
61
+ const script = /(?:^|\/)(?:document\.js|document\/script\.js)(?:[?#]|$)/
62
+ const stylesheet = /(?:^|\/)document\.css(?:[?#]|$)/
63
+
64
+ /**
65
+ * Checks an HTML document against the document mode contract and returns its diagnostics in
66
+ * line order. An empty array means the document passes.
67
+ *
68
+ * The check reads tags with a small scanner rather than a full HTML parser: it skips comments, text,
69
+ * and the contents of `<script>` and `<style>`, and it pairs `<figure>` tags by nesting. Markup built
70
+ * at runtime is not seen.
71
+ *
72
+ * With `page`, the lint also checks that the tags before `<body>` link the document stylesheet and
73
+ * load the document script with `defer`, as one classic script.
74
+ *
75
+ * @example
76
+ * Document.lint('<article class="doc" data-template="post"><h4>Steps</h4></article>')
77
+ * // [{ line: 1, message: '<h4> is not allowed. Use h2 for sections and h3 below them.', rule: 'heading-depth' }]
78
+ */
79
+ export function lint(html: string, options: lint.Options = {}): lint.Diagnostic[] {
80
+ const { page = false } = options
81
+ const diagnostics: lint.Diagnostic[] = []
82
+ const report = (index: number, rule: lint.Rule, message: string) =>
83
+ diagnostics.push({ line: html.slice(0, index).split('\n').length, message, rule })
84
+ const figures: {
85
+ caption: boolean
86
+ chart: boolean
87
+ index: number
88
+ key: boolean
89
+ series: number
90
+ }[] = []
91
+ const head = { index: 0, open: true, script: false, stylesheet: false }
92
+ let svg = 0
93
+
94
+ for (const tag of scan(html)) {
95
+ if (tag.name === 'body' || tag.name === 'article' || (tag.name === 'head' && tag.closing))
96
+ head.open = false
97
+ if (tag.name === 'head' && !tag.closing) head.index = tag.index
98
+ if (head.open && !tag.closing) {
99
+ const href = attribute(tag.attributes, 'href') ?? ''
100
+ const src = attribute(tag.attributes, 'src') ?? ''
101
+ if (
102
+ tag.name === 'link' &&
103
+ attribute(tag.attributes, 'rel')?.toLowerCase() === 'stylesheet' &&
104
+ stylesheet.test(href)
105
+ )
106
+ head.stylesheet = true
107
+ if (
108
+ tag.name === 'script' &&
109
+ attribute(tag.attributes, 'defer') !== undefined &&
110
+ attribute(tag.attributes, 'type') === undefined &&
111
+ script.test(src)
112
+ )
113
+ head.script = true
114
+ }
115
+
116
+ if (tag.name === 'svg' && !tag.selfClosing) svg += tag.closing ? -1 : 1
117
+ if (tag.closing) {
118
+ if (tag.name !== 'figure') continue
119
+ const figure = figures.pop()
120
+ if (!figure) continue
121
+ if (!figure.caption)
122
+ report(
123
+ figure.index,
124
+ 'figure-caption',
125
+ 'A <figure> needs a <figcaption> that states its takeaway.',
126
+ )
127
+ if (figure.chart && figure.series > 1 && !figure.key)
128
+ report(figure.index, 'chart-key', 'A chart with more than one series needs a ul.chart-key.')
129
+ continue
130
+ }
131
+
132
+ const names = (attribute(tag.attributes, 'class') ?? '').split(/\s+/).filter(Boolean)
133
+ const inSvg = svg > 0 || tag.name === 'svg'
134
+
135
+ if (/^h[4-6]$/.test(tag.name))
136
+ report(
137
+ tag.index,
138
+ 'heading-depth',
139
+ `<${tag.name}> is not allowed. Use h2 for sections and h3 below them.`,
140
+ )
141
+ if (tag.name === 'details')
142
+ report(
143
+ tag.index,
144
+ 'no-disclosure',
145
+ `<${tag.name}> is not allowed. A document shows everything it says.`,
146
+ )
147
+ const role = attribute(tag.attributes, 'role')
148
+ if (role === 'tab' || role === 'tablist')
149
+ report(tag.index, 'no-ui', `role="${role}" is not allowed. A document has no tabs.`)
150
+
151
+ for (const name of names) {
152
+ if (banned.test(name) || /^(?:badge|card|chip|pill|tab)-/.test(name))
153
+ report(tag.index, 'no-ui', `.${name} reads as UI. Write it as text, a table, or a list.`)
154
+ else if (!(inSvg ? svgClasses : classes).includes(name as never))
155
+ report(tag.index, 'unknown-class', `.${name} is not in the document mode contract.`)
156
+ }
157
+
158
+ if (tag.name === 'article' && names.includes('doc')) {
159
+ const template = attribute(tag.attributes, 'data-template')
160
+ if (!templates.includes(template as never))
161
+ report(
162
+ tag.index,
163
+ 'template',
164
+ 'An article.doc needs data-template="essay", "brief", or "post".',
165
+ )
166
+ }
167
+
168
+ if (tag.name === 'figure') {
169
+ const chart = names.includes('chart')
170
+ if (chart && names.includes('l-screen'))
171
+ report(
172
+ tag.index,
173
+ 'chart-width',
174
+ 'A chart stays inside the page. Use l-body, l-outset, or l-page.',
175
+ )
176
+ figures.push({
177
+ caption: false,
178
+ chart,
179
+ index: tag.index,
180
+ key: false,
181
+ series: Number(attribute(tag.attributes, 'data-series') ?? 1),
182
+ })
183
+ }
184
+ const figure = figures.at(-1)
185
+ if (figure && tag.name === 'figcaption') figure.caption = true
186
+ if (figure && names.includes('chart-key')) figure.key = true
187
+
188
+ if (names.includes('chart-scroll')) {
189
+ const named =
190
+ attribute(tag.attributes, 'aria-label') ?? attribute(tag.attributes, 'aria-labelledby')
191
+ if (
192
+ attribute(tag.attributes, 'role') !== 'region' ||
193
+ attribute(tag.attributes, 'tabindex') !== '0' ||
194
+ !named
195
+ )
196
+ report(
197
+ tag.index,
198
+ 'chart-scroll',
199
+ '.chart-scroll needs role="region", tabindex="0", and an accessible name.',
200
+ )
201
+ }
202
+ }
203
+
204
+ if (page && !head.stylesheet)
205
+ report(
206
+ head.index,
207
+ 'stylesheet',
208
+ 'The <head> needs <link rel="stylesheet"> to the document stylesheet, dist/document/document.css.',
209
+ )
210
+ if (page && !head.script)
211
+ report(
212
+ head.index,
213
+ 'script',
214
+ 'The <head> needs <script defer src> with the document script, dist/document/script.js, and no type.',
215
+ )
216
+
217
+ return diagnostics.sort((a, b) => a.line - b.line)
218
+ }
219
+
220
+ export declare namespace lint {
221
+ /** One problem in a document, at the line of the tag that causes it. */
222
+ type Diagnostic = { line: number; message: string; rule: Rule }
223
+
224
+ type Options = {
225
+ /**
226
+ * Whether the HTML is a whole page, whose head must link the document stylesheet and load the
227
+ * document script with `defer`. Defaults to false, which checks a fragment.
228
+ */
229
+ page?: boolean | undefined
230
+ }
231
+
232
+ /** The checks the lint runs. */
233
+ type Rule =
234
+ | 'chart-key'
235
+ | 'chart-scroll'
236
+ | 'chart-width'
237
+ | 'figure-caption'
238
+ | 'heading-depth'
239
+ | 'no-disclosure'
240
+ | 'no-ui'
241
+ | 'script'
242
+ | 'stylesheet'
243
+ | 'template'
244
+ | 'unknown-class'
245
+ }
246
+
247
+ /** Returns an attribute's value, or undefined when the tag does not have it. */
248
+ function attribute(attributes: string, name: string): string | undefined {
249
+ const pattern = new RegExp(
250
+ `(?:^|\\s)${name}(?:\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+)))?(?=\\s|$)`,
251
+ 'i',
252
+ )
253
+ const match = pattern.exec(attributes)
254
+ if (!match) return undefined
255
+ return match[1] ?? match[2] ?? match[3] ?? ''
256
+ }
257
+
258
+ /**
259
+ * Yields each tag in source order, skipping comments. A raw text element, such as `<script>`, yields
260
+ * its start tag and skips its contents and end tag.
261
+ */
262
+ function* scan(html: string) {
263
+ const pattern =
264
+ /<!--[\s\S]*?-->|<(script|style|textarea)\b((?:[^>"']|"[^"]*"|'[^']*')*)>[\s\S]*?<\/\1\s*>|<(\/?)([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g
265
+
266
+ for (const match of html.matchAll(pattern)) {
267
+ if (match[0].startsWith('<!--')) continue
268
+ const attributes = (match[1] ? match[2] : match[5])?.trim() ?? ''
269
+ yield {
270
+ attributes: attributes.replace(/\/$/, ''),
271
+ closing: match[3] === '/',
272
+ index: match.index,
273
+ name: (match[1] ?? match[4] ?? '').toLowerCase(),
274
+ selfClosing: attributes.endsWith('/'),
275
+ }
276
+ }
277
+ }