tosijs-ui 1.16.3 → 1.16.4
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.
- package/CHANGELOG.md +35 -0
- package/dist/doc-browser.js +76 -7
- package/dist/doc-system/site/site-config.d.ts +2 -2
- package/dist/iife.js +97 -91
- package/dist/iife.js.map +8 -8
- package/dist/live-example/component.d.ts +82 -25
- package/dist/live-example/component.js +297 -70
- package/dist/live-example/example-console.js +1 -1
- package/dist/live-example/execution.d.ts +28 -0
- package/dist/live-example/execution.js +51 -5
- package/dist/live-example/styles.d.ts +41 -20
- package/dist/live-example/styles.js +46 -27
- package/dist/live-example/types.d.ts +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.16.4
|
|
4
|
+
|
|
5
|
+
A patch: the example console becomes a tab with a REPL, test-only examples render on deployed
|
|
6
|
+
sites, and the doc nav search gets a clear button in every browser. The console's move from a
|
|
7
|
+
panel under the preview to a tab changes how live examples look; it ships as a patch because
|
|
8
|
+
live examples are a developer-facing tool. It does remove the panel's styling hooks: the
|
|
9
|
+
`[part="console"]` element, the `-has-console` class, and `console` from the `ExampleParts`
|
|
10
|
+
type. Nothing in tosijs-ui used them, and a site that styled the 1.16.2 panel should restyle
|
|
11
|
+
`.example-console` in the tab instead. `dist/iife.js` grows by 1.7 kB gzip (477.0 → 478.7 kB).
|
|
12
|
+
|
|
13
|
+
### The example console is a tab, and a REPL
|
|
14
|
+
|
|
15
|
+
What an example logs now appears in a **Console** tab beside its code, instead of a panel under
|
|
16
|
+
its preview, so the preview is never squeezed. The tab is also a REPL: type an expression and
|
|
17
|
+
press Enter to evaluate it inside the example's own scope (its top-level variables and
|
|
18
|
+
functions, `preview`, its `console`, the page's modules), as in the browser's console: input
|
|
19
|
+
gives its value, `await` works, Shift+Enter adds a line, and ↑/↓ recall what you've entered.
|
|
20
|
+
The REPL costs nothing until it's used: the first input re-runs the example once to give it
|
|
21
|
+
the example's scope. The error that stopped an
|
|
22
|
+
example appears there too. `exampleConsole: false` and `{"console": false}` still turn it off.
|
|
23
|
+
|
|
24
|
+
### A test-only example shows its results on deployed sites too
|
|
25
|
+
|
|
26
|
+
A ` ```test ` fence with nothing beside it shows its results as its body, but it ran its tests
|
|
27
|
+
only when the page's test toggle was on. That toggle is off by default anywhere but localhost,
|
|
28
|
+
so on every deployed site the example was an empty box. It now always runs its tests, because
|
|
29
|
+
they are its content; ordinary examples still follow the toggle.
|
|
30
|
+
|
|
31
|
+
### The doc navigation search has a clear button in every browser
|
|
32
|
+
|
|
33
|
+
The doc system's nav search relied on `type="search"` for its clear (✕) button, which browsers
|
|
34
|
+
draw inconsistently: Chromium only while the field is focused, Safari while it has text, and
|
|
35
|
+
Firefox never. It now has its own ✕, shown whenever there's text, with the native one hidden so
|
|
36
|
+
there's never two. Escape clears it as well.
|
|
37
|
+
|
|
3
38
|
## 1.16.3
|
|
4
39
|
|
|
5
40
|
A patch: iPhone menus that stay reachable, a Docs tab for live examples, and a way to declare
|
package/dist/doc-browser.js
CHANGED
|
@@ -344,6 +344,44 @@ function logoMark(logo, projectLinks) {
|
|
|
344
344
|
mark.classList.add('logo-mark');
|
|
345
345
|
return mark;
|
|
346
346
|
}
|
|
347
|
+
// The nav search box: the field, and its own clear button over the field's right end.
|
|
348
|
+
const navSearchStyleSpec = {
|
|
349
|
+
'.nav-search': {
|
|
350
|
+
position: 'relative',
|
|
351
|
+
margin: '5px',
|
|
352
|
+
},
|
|
353
|
+
'.nav-search input[type="search"]': {
|
|
354
|
+
width: '100%',
|
|
355
|
+
boxSizing: 'border-box',
|
|
356
|
+
// room for the clear button, so text never runs under it
|
|
357
|
+
paddingRight: varDefault.touchSize('44px'),
|
|
358
|
+
},
|
|
359
|
+
'.nav-search input[type="search"]::-webkit-search-cancel-button': {
|
|
360
|
+
display: 'none',
|
|
361
|
+
},
|
|
362
|
+
'.nav-search .nav-search-clear': {
|
|
363
|
+
position: 'absolute',
|
|
364
|
+
right: 0,
|
|
365
|
+
top: 0,
|
|
366
|
+
bottom: 0,
|
|
367
|
+
display: 'inline-flex',
|
|
368
|
+
alignItems: 'center',
|
|
369
|
+
justifyContent: 'center',
|
|
370
|
+
width: varDefault.touchSize('44px'),
|
|
371
|
+
padding: 0,
|
|
372
|
+
border: 'none',
|
|
373
|
+
boxShadow: 'none',
|
|
374
|
+
background: 'transparent',
|
|
375
|
+
color: 'inherit',
|
|
376
|
+
opacity: '0.5',
|
|
377
|
+
},
|
|
378
|
+
'.nav-search .nav-search-clear:hover, .nav-search .nav-search-clear:focus-visible': {
|
|
379
|
+
opacity: '1',
|
|
380
|
+
},
|
|
381
|
+
'.nav-search .nav-search-clear[hidden]': {
|
|
382
|
+
display: 'none',
|
|
383
|
+
},
|
|
384
|
+
};
|
|
347
385
|
const logoMarkStyleSpec = {
|
|
348
386
|
'.logo-mark': {
|
|
349
387
|
height: 'var(--tosi-logo-mark-size, 32px)',
|
|
@@ -565,8 +603,32 @@ export function createDocBrowser(options) {
|
|
|
565
603
|
// section; while typing, matching sections expand via the needle branch.
|
|
566
604
|
refreshNav(true);
|
|
567
605
|
});
|
|
606
|
+
/*
|
|
607
|
+
The nav search's clear (✕) button. `type="search"` alone gave a clear affordance only in
|
|
608
|
+
some browsers and some states: Chromium shows its ✕ only while the field is focused, Safari
|
|
609
|
+
while it has text, Firefox never. So the field has its own, shown whenever there is text,
|
|
610
|
+
and the native one is hidden so there is never two. Escape clears too.
|
|
611
|
+
*/
|
|
612
|
+
const updateSearchClear = () => {
|
|
613
|
+
searchClear.hidden = searchField.value === '';
|
|
614
|
+
};
|
|
615
|
+
const clearSearch = () => {
|
|
616
|
+
searchField.value = '';
|
|
617
|
+
updateSearchClear();
|
|
618
|
+
filterDocs();
|
|
619
|
+
searchField.focus();
|
|
620
|
+
};
|
|
621
|
+
const searchInput = () => {
|
|
622
|
+
updateSearchClear();
|
|
623
|
+
filterDocs();
|
|
624
|
+
};
|
|
625
|
+
const searchKeydown = (event) => {
|
|
626
|
+
if (event.key === 'Escape' && searchField.value !== '') {
|
|
627
|
+
event.preventDefault();
|
|
628
|
+
clearSearch();
|
|
629
|
+
}
|
|
630
|
+
};
|
|
568
631
|
const searchField = input({
|
|
569
|
-
slot: 'nav',
|
|
570
632
|
placeholder: 'search',
|
|
571
633
|
// A placeholder is not a label: it is not a reliable accessible name, and it
|
|
572
634
|
// disappears the moment anything is typed. This is the only text input in the
|
|
@@ -574,12 +636,18 @@ export function createDocBrowser(options) {
|
|
|
574
636
|
// site built with `tosijs-ui/site`.
|
|
575
637
|
'aria-label': 'Search documentation',
|
|
576
638
|
type: 'search',
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
margin: '5px',
|
|
580
|
-
},
|
|
581
|
-
onInput: filterDocs,
|
|
639
|
+
onInput: searchInput,
|
|
640
|
+
onKeydown: searchKeydown,
|
|
582
641
|
});
|
|
642
|
+
const searchClear = button({
|
|
643
|
+
type: 'button',
|
|
644
|
+
class: 'nav-search-clear',
|
|
645
|
+
title: 'Clear search',
|
|
646
|
+
'aria-label': 'Clear search',
|
|
647
|
+
hidden: true,
|
|
648
|
+
onClick: clearSearch,
|
|
649
|
+
}, icons.x());
|
|
650
|
+
const searchBox = div({ slot: 'nav', class: 'nav-search' }, searchField, searchClear);
|
|
583
651
|
// Memory routing is decoupled from the page URL, so it ignores browser
|
|
584
652
|
// back/forward (the host owns history, if any).
|
|
585
653
|
if (!memoryRouting) {
|
|
@@ -1462,7 +1530,7 @@ export function createDocBrowser(options) {
|
|
|
1462
1530
|
// The sidenav has just introduced itself; give it the layout the doc asked for.
|
|
1463
1531
|
applyFullScreen();
|
|
1464
1532
|
},
|
|
1465
|
-
},
|
|
1533
|
+
}, searchBox, navContent, div({
|
|
1466
1534
|
style: {
|
|
1467
1535
|
position: 'relative',
|
|
1468
1536
|
overflowY: 'scroll',
|
|
@@ -1475,6 +1543,7 @@ export function createDocBrowser(options) {
|
|
|
1475
1543
|
StyleSheet('test-indicators', testIndicatorStyleSpec);
|
|
1476
1544
|
// Header brand-mark sizing (icon / <img> / inline-<svg>), one CSS var each.
|
|
1477
1545
|
StyleSheet('doc-logo-mark', logoMarkStyleSpec);
|
|
1546
|
+
StyleSheet('doc-nav-search', navSearchStyleSpec);
|
|
1478
1547
|
// Floating widget for test status
|
|
1479
1548
|
const testWidget = button({
|
|
1480
1549
|
class: 'test-widget',
|
|
@@ -130,8 +130,8 @@ export interface SiteConfig {
|
|
|
130
130
|
*/
|
|
131
131
|
liveExamples?: 'auto' | 'opt-in';
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
133
|
+
* Give live examples a Console tab: what the example logs, and a REPL in its scope (default
|
|
134
|
+
* `true`; a tab since 1.16.4, a panel under the preview in 1.16.2–1.16.3). `false` turns it off site-wide;
|
|
135
135
|
* logs still reach the browser's devtools. One example opts out with the fence option
|
|
136
136
|
* `{"console": false}`.
|
|
137
137
|
*/
|