tosijs-ui 1.16.19 → 1.16.21

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.
@@ -22,7 +22,7 @@ preview.append(tosiThemeEditor())
22
22
 
23
23
  The `liveTheme` observable lets you read and write theme values from code:
24
24
 
25
- ```js
25
+ ```js:static
26
26
  import { liveTheme } from 'tosijs-ui'
27
27
 
28
28
  // Read current values
package/dist/router.js CHANGED
@@ -9,6 +9,7 @@ named route views (slots).
9
9
 
10
10
  ```js
11
11
  import { defineRoutes, navigate, router, tosiRouteView } from 'tosijs-ui'
12
+ import { elements } from 'tosijs'
12
13
 
13
14
  const home = () => {
14
15
  const el = document.createElement('div')
@@ -28,21 +29,39 @@ const greeting = (params) => {
28
29
  return el
29
30
  }
30
31
 
31
- defineRoutes(
32
- [
33
- { pattern: '', targets: [{ component: home }] },
34
- { pattern: 'about', targets: [{ component: about }] },
35
- { pattern: 'greet/:name', targets: [{ component: greeting }] },
36
- ],
37
- { hashRouting: true }
38
- )
32
+ const routes = [
33
+ { pattern: '', targets: [{ component: home }] },
34
+ { pattern: 'about', targets: [{ component: about }] },
35
+ { pattern: 'greet/:name', targets: [{ component: greeting }] },
36
+ ]
39
37
 
38
+ // An app calls defineRoutes once. This page has several router examples sharing the
39
+ // one router, so each link here defines its routes again before it navigates.
40
+ const go = (path) => () => {
41
+ defineRoutes(routes, { hashRouting: true })
42
+ navigate(path)
43
+ }
44
+
45
+ const { button, nav } = elements
40
46
  preview.append(
47
+ nav(
48
+ button({ onClick: go('') }, 'Home'),
49
+ button({ onClick: go('about') }, 'About'),
50
+ button({ onClick: go('greet/World') }, 'Greet World')
51
+ ),
41
52
  tosiRouteView(),
42
53
  )
43
54
 
44
55
  // Navigate programmatically
45
- navigate('greet/World')
56
+ go('greet/World')()
57
+ ```
58
+ ```test
59
+ test('the first example holds the router when the page loads', async () => {
60
+ for (let i = 0; i < 50 && !preview.textContent.includes('Hello, World!'); i++) {
61
+ await waitMs(20)
62
+ }
63
+ expect(preview.textContent).toContain('Hello, World!')
64
+ })
46
65
  ```
47
66
 
48
67
  ## Named Views
@@ -69,18 +88,21 @@ const sidebar = () => {
69
88
  return el
70
89
  }
71
90
 
72
- defineRoutes(
73
- [
74
- {
75
- pattern: 'photos/:id/edit',
76
- targets: [
77
- { view: 'main', component: mainContent },
78
- { view: 'tools', component: sidebar },
79
- ],
80
- },
81
- ],
82
- { hashRouting: true }
83
- )
91
+ const show = () => {
92
+ defineRoutes(
93
+ [
94
+ {
95
+ pattern: 'photos/:id/edit',
96
+ targets: [
97
+ { view: 'main', component: mainContent },
98
+ { view: 'tools', component: sidebar },
99
+ ],
100
+ },
101
+ ],
102
+ { hashRouting: true }
103
+ )
104
+ navigate('photos/42/edit')
105
+ }
84
106
 
85
107
  const container = document.createElement('div')
86
108
  container.style.display = 'flex'
@@ -89,9 +111,14 @@ container.append(
89
111
  tosiRouteView({ name: 'main', style: { flex: '1' } }),
90
112
  tosiRouteView({ name: 'tools', style: { width: '200px' } }),
91
113
  )
92
- preview.append(container)
93
-
94
- navigate('photos/42/edit')
114
+ // An app has one router, and so does this page: the example above holds it, so this one
115
+ // routes when you ask it to.
116
+ const note = document.createElement('p')
117
+ note.textContent = 'One router serves the page; the example above holds it until you press:'
118
+ const showButton = document.createElement('button')
119
+ showButton.textContent = 'Edit photo 42'
120
+ showButton.addEventListener('click', show)
121
+ preview.append(note, showButton, container)
95
122
  ```
96
123
 
97
124
  ## Hash Routing
@@ -99,8 +126,9 @@ navigate('photos/42/edit')
99
126
  Set `hashRouting: true` when defining routes to use hash-based URLs
100
127
  (`#/path`) instead of History API paths. This is useful when your app
101
128
  is served from a static file server that doesn't support URL rewriting.
129
+ The examples above all use it.
102
130
 
103
- ```js
131
+ ```js:static
104
132
  import { defineRoutes, navigate, tosiRouteView } from 'tosijs-ui'
105
133
 
106
134
  defineRoutes(
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.16.19";
1
+ export declare const version = "1.16.21";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.16.19';
1
+ export const version = '1.16.21';
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # tosijs-ui v1.16.19
1
+ # tosijs-ui v1.16.21
2
2
 
3
3
  Simple, robust web-components for use with tosijs or anything else.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tosijs-ui",
3
- "version": "1.16.19",
3
+ "version": "1.16.21",
4
4
  "description": "simple robust web-components for use with tosijs or anything else",
5
5
  "scripts": {
6
6
  "start": "bun --watch bin/dev.ts",
@@ -57,7 +57,7 @@
57
57
  "prettier": "^2.8.8",
58
58
  "prismjs": "^1.30.0",
59
59
  "tjs-lang": "0.14.0-rc.5",
60
- "tosijs": "1.10.7",
60
+ "tosijs": "1.10.9",
61
61
  "tosijs-schema": "1.10.2",
62
62
  "typescript": "^5.9.3",
63
63
  "typescript-eslint": "^8.65.0"
@@ -67,7 +67,7 @@
67
67
  "happy-dom": "^20.7.0",
68
68
  "marked": "^16.4.2 || ^17.0.0 || ^18.0.0",
69
69
  "tjs-lang": "^0.13.1 || ^0.14.0-rc.5",
70
- "tosijs": "^1.10.3",
70
+ "tosijs": "^1.10.9",
71
71
  "tosijs-schema": "^1.8.0",
72
72
  "chokidar": "^4.0.3"
73
73
  },