tosijs-ui 1.5.23 → 1.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 (85) hide show
  1. package/README.md +4 -2
  2. package/bin/docs.ts +9 -233
  3. package/dist/ab-test.js +1 -0
  4. package/dist/babylon-3d.js +1 -0
  5. package/dist/bodymovin-player.js +1 -0
  6. package/dist/carousel.js +1 -0
  7. package/dist/code-editor.js +1 -0
  8. package/dist/color-input.js +1 -0
  9. package/dist/data-table.js +3 -3
  10. package/dist/dialog.js +1 -0
  11. package/dist/doc-browser.d.ts +28 -0
  12. package/dist/doc-browser.js +241 -96
  13. package/dist/doc-system/doc-system-styles.d.ts +13 -0
  14. package/dist/doc-system/doc-system-styles.js +377 -0
  15. package/dist/doc-system/doc-system.d.ts +28 -0
  16. package/dist/doc-system/doc-system.js +292 -0
  17. package/dist/doc-system/nav-tree.d.ts +34 -0
  18. package/dist/doc-system/nav-tree.js +0 -0
  19. package/dist/doc-system/render.d.ts +12 -0
  20. package/dist/doc-system/render.js +74 -0
  21. package/dist/doc-system/routing.d.ts +42 -0
  22. package/dist/doc-system/routing.js +116 -0
  23. package/dist/doc-system/site/build-dom-shim.d.ts +1 -0
  24. package/dist/doc-system/site/build-dom-shim.js +73 -0
  25. package/dist/doc-system/site/dev-server.d.ts +7 -0
  26. package/dist/doc-system/site/dev-server.js +232 -0
  27. package/dist/doc-system/site/docs.d.ts +24 -0
  28. package/dist/doc-system/site/docs.js +205 -0
  29. package/dist/doc-system/site/generate-css.d.ts +6 -0
  30. package/dist/doc-system/site/generate-css.js +26 -0
  31. package/dist/doc-system/site/generate-site.d.ts +43 -0
  32. package/dist/doc-system/site/generate-site.js +212 -0
  33. package/dist/doc-system/site/index.d.ts +8 -0
  34. package/dist/doc-system/site/index.js +10 -0
  35. package/dist/doc-system/site/make-llms-txt.d.ts +1 -0
  36. package/dist/doc-system/site/make-llms-txt.js +96 -0
  37. package/dist/doc-system/site/orchestrator.d.ts +5 -0
  38. package/dist/doc-system/site/orchestrator.js +146 -0
  39. package/dist/doc-system/site/sections.d.ts +9 -0
  40. package/dist/doc-system/site/sections.js +79 -0
  41. package/dist/doc-system/site/site-config.d.ts +100 -0
  42. package/dist/doc-system/site/site-config.js +16 -0
  43. package/dist/drag-and-drop.js +1 -0
  44. package/dist/editable-rect.js +1 -0
  45. package/dist/filter-builder.js +1 -0
  46. package/dist/float.js +1 -0
  47. package/dist/form.js +14 -7
  48. package/dist/header.js +1 -0
  49. package/dist/icon-data.js +271 -271
  50. package/dist/iife.js +72 -72
  51. package/dist/iife.js.map +53 -48
  52. package/dist/index.d.ts +1 -0
  53. package/dist/index.js +1 -0
  54. package/dist/layout.js +1 -0
  55. package/dist/live-example/component.js +1 -0
  56. package/dist/live-example/remote-sync.js +1 -1
  57. package/dist/live-theme.js +1 -0
  58. package/dist/localize.d.ts +7 -0
  59. package/dist/localize.js +145 -0
  60. package/dist/make-sorter.js +1 -0
  61. package/dist/mapbox.js +1 -0
  62. package/dist/markdown-viewer.js +1 -0
  63. package/dist/menu.js +1 -0
  64. package/dist/month.js +1 -0
  65. package/dist/notifications.js +1 -0
  66. package/dist/password-strength.js +1 -0
  67. package/dist/rating.js +1 -0
  68. package/dist/rich-text.js +3 -3
  69. package/dist/router.js +1 -0
  70. package/dist/segmented.js +1 -0
  71. package/dist/select.js +1 -0
  72. package/dist/side-nav.js +2 -1
  73. package/dist/size-break.js +1 -0
  74. package/dist/sizer.js +1 -0
  75. package/dist/tab-selector.js +1 -0
  76. package/dist/tag-list.js +1 -0
  77. package/dist/theme.js +1 -0
  78. package/dist/tooltip.js +1 -0
  79. package/dist/track-drag.js +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/dist/version.d.ts +1 -1
  82. package/dist/version.js +1 -1
  83. package/dist/via-tag.js +1 -0
  84. package/llms.txt +1 -1
  85. package/package.json +18 -9
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # tosijs-ui
2
2
 
3
- <!--{ "pin": "top" }-->
3
+ <!--{ "pin": "top", "headTitle": "tosijs-ui — robust, dependency-free web components", "description": "A small, fast library of standards-based web components (data tables, dialogs, forms, rich text, carousels, and more) built on tosijs — smaller and faster than a React app, with no virtual DOM.", "keywords": "web components, custom elements, tosijs, data table, dialog, form, rich text, no virtual dom" }-->
4
4
 
5
5
  [ui.tosijs.net live demo](https://ui.tosijs.net) | [tosijs](https://tosijs.net) | [discord](https://discord.gg/ramJ9rgky5) | [github](https://github.com/tonioloewald/tosijs-ui#readme) | [npm](https://www.npmjs.com/package/tosijs-ui)
6
6
 
@@ -122,7 +122,9 @@ as globals which contain all the things exported by `tosijs` and `tosijs-ui`.
122
122
  </script>
123
123
  ```
124
124
 
125
- [Click here to see a simple iife demo](https://ui.tosijs.net/iife.html)
125
+ The entire [live documentation site](https://ui.tosijs.net) is built with the iife
126
+ bundle — every page is static HTML that loads `iife.js` and hydrates, so it doubles
127
+ as a working iife example (view source on any page).
126
128
 
127
129
  ## custom-elements
128
130
 
package/bin/docs.ts CHANGED
@@ -1,233 +1,9 @@
1
- /*#
2
- # docs
3
-
4
- Utility for extracting documentation from markdown files and inline comments in source code.
5
-
6
- > `docs.ts` is intended to be run directly using `bun`. You can transpile it to javascript if you
7
- want to run it using node.
8
-
9
- This is used by the `doc-browser` component to build searchable, navigable documentation
10
- from your project's source files.
11
-
12
- ## Usage
13
-
14
- import { extractDocs } from 'docs'
15
-
16
- extractDocs({
17
- paths: ['src', 'README.md'],
18
- ignore: ['node_modules', 'dist', 'build']
19
- path: 'public/docs.json'
20
- })
21
-
22
- ## API
23
-
24
- ### `extractDocs(options)`
25
-
26
- Scans directories for markdown files and source code comments.
27
-
28
- **Options:**
29
- - `paths`: Array of directory paths or file paths to scan
30
- - `ignore`: Array of directory names to ignore (default: ['node_modules', 'dist'])
31
- - `output`: if provided, path to write json result.
32
-
33
- **Returns:** Array of `Doc` objects
34
-
35
- ### `Doc` object structure
36
-
37
- {
38
- text: string, // Markdown content
39
- title: string, // First heading or filename
40
- filename: string, // Just the filename
41
- path: string, // Full file path
42
- pin?: 'top' | 'bottom' // Optional pinning for sort order
43
- }
44
-
45
- ## Documentation Format
46
-
47
- ### Markdown files
48
-
49
- Any `.md` file will be included in its entirety.
50
-
51
- ### Source code comments
52
-
53
- Multi-line comments that start with `/*#` will be extracted as markdown:
54
-
55
- /*#
56
- # My Component
57
-
58
- This is documentation for my component.
59
-
60
- ```html
61
- <my-component></my-component>
62
- ```
63
- ```js
64
- console.log('hello world')
65
- ```
66
- ```css
67
- my-componet {
68
- color: blue
69
- }
70
- ```
71
- *‎/
72
-
73
- export class MyComponent extends Component {
74
- // implementation
75
- }
76
- ...
77
-
78
- The [doc-browser](/?doc-browser.ts) will render the output as a test-bed project with documentation and live examples.
79
-
80
- ### Metadata
81
-
82
- You can include JSON metadata in comments to control sorting:
83
-
84
- html:
85
- <!--{ "pin": "bottom" }-->
86
-
87
- ts, js, css:
88
- /*{ "pin": "bottom" }*‎/
89
-
90
- This will pin the document to the top or bottom of the navigation list.
91
- */
92
- /*{ "pin": "bottom" }*/
93
-
94
- // TODO CLI options
95
-
96
- import * as fs from 'fs'
97
- import * as path from 'path'
98
-
99
- export interface Doc {
100
- text: string
101
- title: string
102
- filename: string
103
- path: string
104
- pin?: 'top' | 'bottom'
105
- hidden?: boolean
106
- }
107
-
108
- export interface ExtractDocsOptions {
109
- paths: string[]
110
- ignore?: string[]
111
- output?: string
112
- }
113
-
114
- const TRIM_REGEX = /^#+ |`/g
115
-
116
- function metadata(content: string, filePath: string): Partial<Doc> {
117
- const source = content.match(/<\!\-\-(\{.*\})\-\->|\/\*(\{.*\})\*\//)
118
- let data: Partial<Doc> = {}
119
- if (source) {
120
- try {
121
- data = JSON.parse(source[1] || source[2])
122
- } catch (e) {
123
- console.error('bad metadata in doc', filePath)
124
- }
125
- }
126
- return data
127
- }
128
-
129
- function pinnedSort(a: Doc, b: Doc): number {
130
- const aKey =
131
- (a.pin === 'top' ? 'A' : a.pin === 'bottom' ? 'Z' : 'M') +
132
- a.title.toLocaleLowerCase()
133
- const bKey =
134
- (b.pin === 'top' ? 'A' : b.pin === 'bottom' ? 'Z' : 'M') +
135
- b.title.toLocaleLowerCase()
136
- return aKey > bKey ? 1 : bKey > aKey ? -1 : 0
137
- }
138
-
139
- function findMarkdownFiles(paths: string[], ignore: string[]): Doc[] {
140
- const markdownFiles: Doc[] = []
141
-
142
- function traverseDirectory(dir: string, ignore: string[]) {
143
- console.log(dir)
144
- const files = fs.readdirSync(dir)
145
- const baseName = path.basename(dir)
146
-
147
- if (ignore.includes(baseName)) {
148
- return
149
- }
150
-
151
- files.forEach((file) => {
152
- const filePath = path.join(dir, file)
153
- let stats
154
-
155
- try {
156
- stats = fs.statSync(filePath)
157
- } catch (err) {
158
- return
159
- }
160
-
161
- if (stats.isDirectory()) {
162
- traverseDirectory(filePath, ignore)
163
- } else if (path.extname(file) === '.md') {
164
- const content = fs.readFileSync(filePath, 'utf8')
165
- markdownFiles.push({
166
- text: content,
167
- title: content.split('\n')[0].replace(TRIM_REGEX, ''),
168
- filename: file,
169
- path: filePath,
170
- ...metadata(content, filePath),
171
- })
172
- } else if (['.ts', '.js', '.css'].includes(path.extname(file))) {
173
- const content = fs.readFileSync(filePath, 'utf8')
174
- const docs = content.match(/\/\*#[\s\S]+?\*\//g) || []
175
- if (docs.length) {
176
- const markdown = docs.map((s) => s.substring(3, s.length - 2).trim())
177
- const text = markdown.join('\n\n')
178
- markdownFiles.push({
179
- text,
180
- title: text.split('\n')[0].replace(TRIM_REGEX, ''),
181
- filename: file,
182
- path: filePath,
183
- ...metadata(content, filePath),
184
- })
185
- }
186
- }
187
- })
188
- }
189
-
190
- paths.forEach((dir) => {
191
- try {
192
- const stats = fs.statSync(dir)
193
- if (stats.isDirectory()) {
194
- traverseDirectory(dir, ignore)
195
- } else if (stats.isFile()) {
196
- const file = path.basename(dir)
197
- if (path.extname(file) === '.md') {
198
- const content = fs.readFileSync(dir, 'utf8')
199
- markdownFiles.push({
200
- text: content,
201
- title: content.split('\n')[0].replace(TRIM_REGEX, ''),
202
- filename: file,
203
- path: dir,
204
- ...metadata(content, dir),
205
- })
206
- }
207
- }
208
- } catch (err) {
209
- console.error(`Could not read ${dir}:`, err)
210
- }
211
- })
212
-
213
- return markdownFiles.sort(pinnedSort)
214
- }
215
-
216
- export function extractDocs(options: ExtractDocsOptions): Doc[] {
217
- const {
218
- paths,
219
- ignore = ['node_modules', 'dist', 'build', 'docs'],
220
- output,
221
- } = options
222
- const docs = findMarkdownFiles(paths, ignore)
223
- if (output) {
224
- saveDocsJSON(docs, output)
225
- }
226
- return docs
227
- }
228
-
229
- export function saveDocsJSON(docs: Doc[], outputPath: string): void {
230
- const jsonData = JSON.stringify(docs, null, 2)
231
- fs.writeFileSync(outputPath, jsonData, 'utf8')
232
- console.log(`Documentation saved to ${outputPath}`)
233
- }
1
+ // Back-compat shim. The doc-extraction implementation now lives in the
2
+ // importable doc-site system at src/doc-system/site/docs.ts (shipped as
3
+ // `tosijs-ui/site`). This path is kept (package.json#files lists /bin/docs.ts)
4
+ // so existing `import { extractDocs } from 'tosijs-ui/bin/docs'` consumers and
5
+ // the `bun bin/docs.ts` CLI keep working.
6
+ //
7
+ // No `/*#` doc block here on purpose: the documented copy lives in the real
8
+ // module, so the doc extractor surfaces it once (avoiding a slug collision).
9
+ export * from '../src/doc-system/site/docs'
package/dist/ab-test.js CHANGED
@@ -75,6 +75,7 @@ randomize()
75
75
  - `condition` attribute determines which value in `AbTest.conditions` controls the element
76
76
  - `not` reverses the condition (so `<tosi-ab not condition="foo">` will be visible if `conditions.foo` is `false`)
77
77
  */
78
+ /*{ "parent": "Helper Libraries" }*/
78
79
  import { Component } from 'tosijs';
79
80
  const abTestConditions = {};
80
81
  export class AbTest extends Component {
@@ -177,6 +177,7 @@ be used to load `.glb` files.
177
177
 
178
178
  `<tosi-3d>.loadUI(options: B3dUIOptions)` loads babylonjs guis, which you can create programmatically or using the [babylonjs gui tool](https://gui.babylonjs.com/).
179
179
  */
180
+ /*{ "parent": "Components" }*/
180
181
  import { Component as WebComponent, elements } from 'tosijs';
181
182
  import { scriptTag } from './via-tag';
182
183
  import { icons, svg2DataUrl } from './icons';
@@ -101,6 +101,7 @@ And of course just access the element's `animation` property to [use the bodymov
101
101
 
102
102
  Also see the [documentation for advanced interactions](https://lottiefiles.github.io/lottie-docs/advanced_interactions/)
103
103
  */
104
+ /*{ "parent": "Components" }*/
104
105
  import { Component as WebComponent } from 'tosijs';
105
106
  import { scriptTag } from './via-tag';
106
107
  export class BodymovinPlayer extends WebComponent {
package/dist/carousel.js CHANGED
@@ -55,6 +55,7 @@ This is a minimalist carousel component that supports the usual stuff.
55
55
 
56
56
  <tosi-css-var-editor element-selector="tosi-carousel"></tosi-css-var-editor>
57
57
  */
58
+ /*{ "parent": "Components" }*/
58
59
  import { Component as WebComponent, elements, vars, } from 'tosijs';
59
60
  import { icons } from './icons';
60
61
  const { button, slot, div } = elements;
@@ -20,6 +20,7 @@ The `<tosi-code>` element has an `editor` property that gives you its ACE editor
20
20
  and an `ace` property that returns the `ace` module, giving you complete access to the
21
21
  [Ace API](https://ace.c9.io/api/index.html).
22
22
  */
23
+ /*{ "parent": "Components" }*/
23
24
  import { Component as WebComponent } from 'tosijs';
24
25
  import { scriptTag } from './via-tag';
25
26
  const ACE_BASE_URL = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.2/';
@@ -27,6 +27,7 @@ colorInput.addEventListener('change', () => {
27
27
 
28
28
  <tosi-css-var-editor element-selector="tosi-color"></tosi-css-var-editor>
29
29
  */
30
+ /*{ "parent": "Form Components" }*/
30
31
  import { Component, elements, Color, vars, } from 'tosijs';
31
32
  const { input } = elements;
32
33
  const defaultColor = Color.fromCss('#8888');
@@ -509,6 +509,7 @@ You'll need to make sure your localized strings include:
509
509
 
510
510
  As well as any column names you want localized.
511
511
  */
512
+ /*{ "parent": "Components" }*/
512
513
  import { Component as WebComponent, elements, vars, varDefault, tosiValue, getListItem, getListBinding, tosi, } from 'tosijs';
513
514
  import { trackDrag } from './track-drag';
514
515
  import { icons } from './icons';
@@ -1008,7 +1009,6 @@ export class TosiTable extends WebComponent {
1008
1009
  buildRow(item, cols, stickyInfo, rowClass = 'tr') {
1009
1010
  const cells = cols.map((col, i) => this.buildCell(col, i, stickyInfo[i], item));
1010
1011
  const selectBindingFn = this.selectBinding;
1011
- const tableInst = this;
1012
1012
  const props = { class: rowClass };
1013
1013
  // `item` here is the placeholder proxy from template-build time. The
1014
1014
  // actual stamped row's item is delivered to toDOM as the second arg
@@ -1019,7 +1019,7 @@ export class TosiTable extends WebComponent {
1019
1019
  binding: {
1020
1020
  toDOM: (rowEl, value) => {
1021
1021
  selectBindingFn(rowEl, value);
1022
- const fn = tableInst.rowRendered;
1022
+ const fn = this.rowRendered;
1023
1023
  if (fn) {
1024
1024
  fn(value, Array.from(rowEl.children));
1025
1025
  }
@@ -1116,7 +1116,7 @@ export class TosiTable extends WebComponent {
1116
1116
  const cols = this.visibleColumns;
1117
1117
  const rightScroll = scrollWidth - clientWidth - scrollLeft;
1118
1118
  let boundaryX = 0;
1119
- return cols.find((options, i) => {
1119
+ return cols.find((options) => {
1120
1120
  if (options.visible === false)
1121
1121
  return false;
1122
1122
  boundaryX += options.width;
package/dist/dialog.js CHANGED
@@ -117,6 +117,7 @@ preview.append(
117
117
  ```
118
118
 
119
119
  */
120
+ /*{ "parent": "Components" }*/
120
121
  import { Component, elements, on, vars, varDefault } from 'tosijs';
121
122
  import { findHighestZ } from './track-drag';
122
123
  const { dialog, button, header, footer, tosiSlot, h3, p, label, input, div } = elements;
@@ -34,6 +34,20 @@ export interface ProjectLinks {
34
34
  cdn?: string;
35
35
  [key: string]: string | undefined;
36
36
  }
37
+ /** A configurable link for the header bar or the overflow menu. */
38
+ export interface LinkItem {
39
+ href: string;
40
+ label: string;
41
+ /** optional icon name (from `icons`); falls back to the text label if unknown */
42
+ icon?: string;
43
+ }
44
+ /**
45
+ * How the doc browser maps docs to URLs.
46
+ * - 'query' (default, legacy): single-page app, links are `?filename`.
47
+ * - 'path': clean per-page URLs (`/slug/`), for the static pre-rendered site
48
+ * driven by <tosi-doc-system>. Requires a real page to exist at each path.
49
+ */
50
+ export type DocRoutingMode = 'query' | 'path';
37
51
  export interface DocBrowserOptions {
38
52
  docs: Doc[];
39
53
  context?: Record<string, any>;
@@ -41,5 +55,19 @@ export interface DocBrowserOptions {
41
55
  projectLinks?: ProjectLinks;
42
56
  navSize?: number;
43
57
  minSize?: number;
58
+ routing?: DocRoutingMode;
59
+ /**
60
+ * Header-bar links. When provided, these replace the legacy `projectLinks` icon
61
+ * set in the header (each renders as an icon if `icon` names a known icon, else
62
+ * as its text label). `projectLinks` is still used for the logo and view-source.
63
+ */
64
+ navbarLinks?: LinkItem[];
65
+ /**
66
+ * Pre-rendered content for the landing doc to ADOPT in place (true hydration).
67
+ * When provided, the current page's already-rendered markdown is left untouched
68
+ * — only live examples are wired up — instead of being re-rendered from text.
69
+ * Used by <tosi-doc-system>. Subsequent navigation renders from doc text.
70
+ */
71
+ contentElement?: HTMLElement;
44
72
  }
45
73
  export declare function createDocBrowser(options: DocBrowserOptions): HTMLElement;