element-book 26.16.1 → 26.17.1
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/dist/data/book-entry/book-page/controls-wrapper.js +3 -1
- package/dist/data/book-tree/book-tree.js +18 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/ui/color-theme/color-theme.d.ts +0 -12
- package/dist/ui/color-theme/color-theme.js +0 -14
- package/dist/ui/color-theme/create-color-theme.d.ts +2 -2
- package/dist/ui/color-theme/create-color-theme.js +31 -54
- package/dist/ui/elements/book-breadcrumbs.element.js +2 -1
- package/dist/ui/elements/book-nav/book-nav-filter.js +1 -1
- package/dist/ui/elements/book-nav/book-nav.element.js +8 -5
- package/dist/ui/elements/element-book-app/element-book-app.element.d.ts +4 -1
- package/dist/ui/elements/element-book-app/element-book-app.element.js +72 -30
- package/dist/ui/elements/element-book-app/element-book-config.d.ts +2 -0
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.js +7 -4
- package/dist/ui/elements/entry-display/book-entry-description.element.js +4 -3
- package/dist/ui/elements/entry-display/book-page/book-page-controls.element.js +7 -11
- package/dist/ui/elements/entry-display/book-page/book-page-wrapper.element.js +2 -2
- package/dist/ui/elements/entry-display/element-example/book-element-example-title.element.js +2 -2
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js +5 -5
- package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.js +2 -6
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.js +13 -7
- package/dist/ui/elements/entry-display/entry-display/book-lazy-entry.element.js +6 -2
- package/dist/ui/elements/entry-display/entry-display/create-node-templates.js +9 -5
- package/dist/util/fuzzy-search.js +1 -2
- package/package.json +15 -13
- package/dist/ui/elements/common/book-error.element.d.ts +0 -3
- package/dist/ui/elements/common/book-error.element.js +0 -25
- package/dist/ui/elements/element-book-app/element-book-app-slots.d.ts +0 -17
- package/dist/ui/elements/element-book-app/element-book-app-slots.js +0 -18
|
@@ -35,7 +35,9 @@ function traverseAndInsertNewControls(controlsWrapper, urlBreadcrumbs, newValues
|
|
|
35
35
|
* @category Internal
|
|
36
36
|
*/
|
|
37
37
|
export function createNewControls(controlsWrapper, breadcrumbsForNewValue, newValues) {
|
|
38
|
-
const newControls = {
|
|
38
|
+
const newControls = {
|
|
39
|
+
...controlsWrapper,
|
|
40
|
+
};
|
|
39
41
|
traverseAndInsertNewControls(newControls, [
|
|
40
42
|
/** Empty string represents the breadcrumb for the root node */
|
|
41
43
|
'',
|
|
@@ -42,7 +42,12 @@ export function createBookTreeFromEntries({ entries, debug, }) {
|
|
|
42
42
|
return cachedTree;
|
|
43
43
|
}
|
|
44
44
|
const tree = createEmptyBookTreeRoot();
|
|
45
|
-
entries.forEach((newEntry) => addEntryToTree({
|
|
45
|
+
entries.forEach((newEntry) => addEntryToTree({
|
|
46
|
+
tree,
|
|
47
|
+
newEntry,
|
|
48
|
+
debug,
|
|
49
|
+
manuallyAdded: true,
|
|
50
|
+
}));
|
|
46
51
|
const flattenedNodes = flattenTree(tree);
|
|
47
52
|
const bookTree = {
|
|
48
53
|
tree,
|
|
@@ -65,7 +70,12 @@ function getOrAddImmediateParent(tree, entry, debug) {
|
|
|
65
70
|
if (debug) {
|
|
66
71
|
console.info(`parent of ${entry.title} not found in tree; adding it now.`);
|
|
67
72
|
}
|
|
68
|
-
addEntryToTree({
|
|
73
|
+
addEntryToTree({
|
|
74
|
+
tree,
|
|
75
|
+
newEntry: entry.parent,
|
|
76
|
+
debug,
|
|
77
|
+
manuallyAdded: false,
|
|
78
|
+
});
|
|
69
79
|
const immediateParentAfterAdding = traverseToImmediateParent(entry, tree);
|
|
70
80
|
if (!immediateParentAfterAdding) {
|
|
71
81
|
throw new Error(`Failed to find node despite having just added it: ${listUrlBreadcrumbs(entry, false).join(' > ')}`);
|
|
@@ -105,7 +115,12 @@ function addEntryToTree({ tree, newEntry, debug, manuallyAdded, }) {
|
|
|
105
115
|
immediateParent.children[newEntryUrlBreadcrumb] = newNode;
|
|
106
116
|
if (isBookEntry(newEntry, BookEntryType.Page) &&
|
|
107
117
|
Object.values(newEntry.elementExamples).length) {
|
|
108
|
-
Object.values(newEntry.elementExamples).forEach((elementExample) => addEntryToTree({
|
|
118
|
+
Object.values(newEntry.elementExamples).forEach((elementExample) => addEntryToTree({
|
|
119
|
+
tree,
|
|
120
|
+
newEntry: elementExample,
|
|
121
|
+
debug,
|
|
122
|
+
manuallyAdded,
|
|
123
|
+
}));
|
|
109
124
|
}
|
|
110
125
|
}
|
|
111
126
|
export function traverseToImmediateParent(entryOrNode, currentTree) {
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export * from './data/book-tree/book-tree-node.js';
|
|
|
11
11
|
export * from './routing/book-routing.js';
|
|
12
12
|
export * from './ui/color-theme/color-theme.js';
|
|
13
13
|
export * from './ui/color-theme/create-color-theme.js';
|
|
14
|
-
export * from './ui/elements/element-book-app/element-book-app-slots.js';
|
|
15
14
|
export * from './ui/elements/element-book-app/element-book-app.element.js';
|
|
16
15
|
export * from './ui/elements/element-book-app/element-book-config.js';
|
|
17
16
|
export * from './ui/elements/element-book-app/global-values.js';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,6 @@ export * from './data/book-tree/book-tree-node.js';
|
|
|
11
11
|
export * from './routing/book-routing.js';
|
|
12
12
|
export * from './ui/color-theme/color-theme.js';
|
|
13
13
|
export * from './ui/color-theme/create-color-theme.js';
|
|
14
|
-
export * from './ui/elements/element-book-app/element-book-app-slots.js';
|
|
15
14
|
export * from './ui/elements/element-book-app/element-book-app.element.js';
|
|
16
15
|
export * from './ui/elements/element-book-app/element-book-config.js';
|
|
17
16
|
export * from './ui/elements/element-book-app/global-values.js';
|
|
@@ -22,12 +22,6 @@ export type ColorTheme = {
|
|
|
22
22
|
accent: {
|
|
23
23
|
icon: CSSResult;
|
|
24
24
|
};
|
|
25
|
-
page: ColorPair & {
|
|
26
|
-
backgroundFaint1: CSSResult;
|
|
27
|
-
backgroundFaint2: CSSResult;
|
|
28
|
-
foregroundFaint1: CSSResult;
|
|
29
|
-
foregroundFaint2: CSSResult;
|
|
30
|
-
};
|
|
31
25
|
};
|
|
32
26
|
/**
|
|
33
27
|
* All color theme CSS vars for the element-book app.
|
|
@@ -42,12 +36,6 @@ export declare const colorThemeCssVars: import("lit-css-vars").CssVarDefinitions
|
|
|
42
36
|
readonly 'element-book-nav-selected-background-color': "magenta";
|
|
43
37
|
readonly 'element-book-nav-selected-foreground-color': "magenta";
|
|
44
38
|
readonly 'element-book-accent-icon-color': "magenta";
|
|
45
|
-
readonly 'element-book-page-background-color': "magenta";
|
|
46
|
-
readonly 'element-book-page-background-faint-level-1-color': "magenta";
|
|
47
|
-
readonly 'element-book-page-background-faint-level-2-color': "magenta";
|
|
48
|
-
readonly 'element-book-page-foreground-color': "magenta";
|
|
49
|
-
readonly 'element-book-page-foreground-faint-level-1-color': "magenta";
|
|
50
|
-
readonly 'element-book-page-foreground-faint-level-2-color': "magenta";
|
|
51
39
|
}>;
|
|
52
40
|
/**
|
|
53
41
|
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
@@ -13,12 +13,6 @@ export const colorThemeCssVars = defineCssVars({
|
|
|
13
13
|
'element-book-nav-selected-background-color': 'magenta',
|
|
14
14
|
'element-book-nav-selected-foreground-color': 'magenta',
|
|
15
15
|
'element-book-accent-icon-color': 'magenta',
|
|
16
|
-
'element-book-page-background-color': 'magenta',
|
|
17
|
-
'element-book-page-background-faint-level-1-color': 'magenta',
|
|
18
|
-
'element-book-page-background-faint-level-2-color': 'magenta',
|
|
19
|
-
'element-book-page-foreground-color': 'magenta',
|
|
20
|
-
'element-book-page-foreground-faint-level-1-color': 'magenta',
|
|
21
|
-
'element-book-page-foreground-faint-level-2-color': 'magenta',
|
|
22
16
|
});
|
|
23
17
|
const colorThemeCssVarMapping = {
|
|
24
18
|
nav: {
|
|
@@ -38,14 +32,6 @@ const colorThemeCssVarMapping = {
|
|
|
38
32
|
accent: {
|
|
39
33
|
icon: colorThemeCssVars['element-book-accent-icon-color'],
|
|
40
34
|
},
|
|
41
|
-
page: {
|
|
42
|
-
background: colorThemeCssVars['element-book-page-background-color'],
|
|
43
|
-
backgroundFaint1: colorThemeCssVars['element-book-page-background-faint-level-1-color'],
|
|
44
|
-
backgroundFaint2: colorThemeCssVars['element-book-page-background-faint-level-2-color'],
|
|
45
|
-
foreground: colorThemeCssVars['element-book-page-foreground-color'],
|
|
46
|
-
foregroundFaint1: colorThemeCssVars['element-book-page-foreground-faint-level-1-color'],
|
|
47
|
-
foregroundFaint2: colorThemeCssVars['element-book-page-foreground-faint-level-2-color'],
|
|
48
|
-
},
|
|
49
35
|
};
|
|
50
36
|
/**
|
|
51
37
|
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
@@ -5,7 +5,7 @@ import { type ColorTheme } from './color-theme.js';
|
|
|
5
5
|
*
|
|
6
6
|
* @category Internal
|
|
7
7
|
*/
|
|
8
|
-
export declare const defaultThemeStartColor
|
|
8
|
+
export declare const defaultThemeStartColor: string;
|
|
9
9
|
/**
|
|
10
10
|
* Theme style options for the element-book app.
|
|
11
11
|
*
|
|
@@ -29,4 +29,4 @@ export type ThemeConfig = PartialWithUndefined<{
|
|
|
29
29
|
*
|
|
30
30
|
* @category Internal
|
|
31
31
|
*/
|
|
32
|
-
export declare function createTheme({ themeColor: inputThemeColor,
|
|
32
|
+
export declare function createTheme({ themeColor: inputThemeColor, }?: ThemeConfig): ColorTheme;
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import { mapObjectValues } from '@augment-vir/common';
|
|
2
1
|
import Color from 'colorjs.io';
|
|
3
2
|
import { unsafeCSS } from 'element-vir';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
else {
|
|
10
|
-
return colorsObjectToCssResult(value);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
3
|
+
import { viraColorPalette } from 'vira';
|
|
4
|
+
function colorToCss(color) {
|
|
5
|
+
return unsafeCSS(color.toString({
|
|
6
|
+
format: 'hex',
|
|
7
|
+
}));
|
|
13
8
|
}
|
|
14
9
|
/**
|
|
15
10
|
* The default theme color.
|
|
16
11
|
*
|
|
17
12
|
* @category Internal
|
|
18
13
|
*/
|
|
19
|
-
export const defaultThemeStartColor = '
|
|
14
|
+
export const defaultThemeStartColor = viraColorPalette['vira-accent-500'].default;
|
|
20
15
|
function calculateTextColorString(color) {
|
|
21
16
|
const onWhite = Math.abs(color.contrast('white', 'APCA'));
|
|
22
17
|
const onBlack = Math.abs(color.contrast('black', 'APCA'));
|
|
23
18
|
const textColorString = onWhite > onBlack ? 'white' : 'black';
|
|
24
19
|
return textColorString;
|
|
25
20
|
}
|
|
26
|
-
function
|
|
21
|
+
function createCssColorPair({ background, foreground, }) {
|
|
22
|
+
const bg = background ?? new Color(calculateTextColorString(foreground));
|
|
23
|
+
const fg = foreground ?? new Color(calculateTextColorString(background));
|
|
27
24
|
return {
|
|
28
|
-
background:
|
|
29
|
-
foreground:
|
|
25
|
+
background: colorToCss(bg),
|
|
26
|
+
foreground: colorToCss(fg),
|
|
30
27
|
};
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
@@ -39,55 +36,35 @@ export var ThemeStyle;
|
|
|
39
36
|
ThemeStyle["Dark"] = "dark";
|
|
40
37
|
ThemeStyle["Light"] = "light";
|
|
41
38
|
})(ThemeStyle || (ThemeStyle = {}));
|
|
42
|
-
function flipBackForeground(input) {
|
|
43
|
-
return input === 'black' ? 'white' : 'black';
|
|
44
|
-
}
|
|
45
|
-
const faintForegroundColors = {
|
|
46
|
-
black: {
|
|
47
|
-
foregroundFaint1: new Color('#ccc'),
|
|
48
|
-
foregroundFaint2: new Color('#eee'),
|
|
49
|
-
},
|
|
50
|
-
white: {
|
|
51
|
-
foregroundFaint1: new Color('#ccc'),
|
|
52
|
-
foregroundFaint2: new Color('#eee'),
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
const faintBackgroundColors = {
|
|
56
|
-
black: {
|
|
57
|
-
backgroundFaint1: new Color('#666'),
|
|
58
|
-
backgroundFaint2: new Color('#444'),
|
|
59
|
-
},
|
|
60
|
-
white: {
|
|
61
|
-
backgroundFaint1: new Color('#ccc'),
|
|
62
|
-
backgroundFaint2: new Color('#fafafa'),
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
39
|
/**
|
|
66
40
|
* Creates a theme from the given theme configuration.
|
|
67
41
|
*
|
|
68
42
|
* @category Internal
|
|
69
43
|
*/
|
|
70
|
-
export function createTheme({ themeColor: inputThemeColor = defaultThemeStartColor,
|
|
44
|
+
export function createTheme({ themeColor: inputThemeColor = defaultThemeStartColor, } = {}) {
|
|
71
45
|
const themeColor = new Color(inputThemeColor);
|
|
72
|
-
|
|
73
|
-
const foregroundColorString = calculateTextColorString(backgroundColor);
|
|
74
|
-
const foregroundColor = new Color(foregroundColorString);
|
|
75
|
-
const colors = {
|
|
46
|
+
return {
|
|
76
47
|
nav: {
|
|
77
|
-
hover:
|
|
78
|
-
|
|
79
|
-
|
|
48
|
+
hover: createCssColorPair({
|
|
49
|
+
background: themeColor.clone().set({
|
|
50
|
+
'hsl.l': 93,
|
|
51
|
+
}),
|
|
52
|
+
}),
|
|
53
|
+
active: createCssColorPair({
|
|
54
|
+
background: themeColor.clone().set({
|
|
55
|
+
'hsl.l': 90,
|
|
56
|
+
}),
|
|
57
|
+
}),
|
|
58
|
+
selected: createCssColorPair({
|
|
59
|
+
background: themeColor.clone().set({
|
|
60
|
+
'hsl.l': 85,
|
|
61
|
+
}),
|
|
62
|
+
}),
|
|
80
63
|
},
|
|
81
64
|
accent: {
|
|
82
|
-
icon: themeColor.clone().set({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
background: backgroundColor,
|
|
86
|
-
...faintBackgroundColors[flipBackForeground(foregroundColorString)],
|
|
87
|
-
foreground: foregroundColor,
|
|
88
|
-
...faintForegroundColors[foregroundColorString],
|
|
65
|
+
icon: colorToCss(themeColor.clone().set({
|
|
66
|
+
'hsl.l': 40,
|
|
67
|
+
})),
|
|
89
68
|
},
|
|
90
69
|
};
|
|
91
|
-
const convertedToCssResults = colorsObjectToCssResult(colors);
|
|
92
|
-
return convertedToCssResults;
|
|
93
70
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { BookMainRoute } from '../../routing/book-routing.js';
|
|
3
4
|
import { BookRouteLink } from './common/book-route-link.element.js';
|
|
4
5
|
import { defineBookElement } from './define-book-element.js';
|
|
@@ -7,7 +8,7 @@ export const BookBreadcrumbs = defineBookElement()({
|
|
|
7
8
|
styles: css `
|
|
8
9
|
:host {
|
|
9
10
|
display: flex;
|
|
10
|
-
color:
|
|
11
|
+
color: ${viraTheme.colors['vira-grey-foreground-header'].foreground.value};
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.spacer {
|
|
@@ -4,7 +4,7 @@ export function shouldShowTreeNodeInNav(currentNode, selectedPath) {
|
|
|
4
4
|
if (currentNode.entry.entryType === BookEntryType.Root) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
if (currentNode.entry.entryType === BookEntryType.Page) {
|
|
7
|
+
else if (currentNode.entry.entryType === BookEntryType.Page) {
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
const isParentSelected = check.jsonEquals(selectedPath, currentNode.fullUrlBreadcrumbs.slice(0, -1));
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { classMap, css, html, renderIf } from 'element-vir';
|
|
3
|
-
import { Element16Icon, ViraIcon } from 'vira';
|
|
3
|
+
import { Element16Icon, ViraIcon, viraTheme } from 'vira';
|
|
4
4
|
import { BookEntryType } from '../../../data/book-entry/book-entry-type.js';
|
|
5
5
|
import { isBookTreeNode } from '../../../data/book-tree/book-tree.js';
|
|
6
6
|
import { BookMainRoute, defaultBookFullRoute } from '../../../routing/book-routing.js';
|
|
7
7
|
import { colorThemeCssVars } from '../../color-theme/color-theme.js';
|
|
8
8
|
import { BookRouteLink } from '../common/book-route-link.element.js';
|
|
9
9
|
import { defineBookElement } from '../define-book-element.js';
|
|
10
|
-
import { ElementBookSlotName } from '../element-book-app/element-book-app-slots.js';
|
|
11
10
|
import { shouldShowTreeNodeInNav } from './book-nav-filter.js';
|
|
12
11
|
export const BookNav = defineBookElement()({
|
|
13
12
|
tagName: 'book-nav',
|
|
@@ -19,7 +18,9 @@ export const BookNav = defineBookElement()({
|
|
|
19
18
|
display: flex;
|
|
20
19
|
flex-direction: column;
|
|
21
20
|
padding: 16px 0;
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
background-color: ${viraTheme.colors['vira-grey-behind-fg-highest-contrast'].background
|
|
23
|
+
.value};
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
.title-row:hover {
|
|
@@ -97,7 +98,9 @@ export const BookNav = defineBookElement()({
|
|
|
97
98
|
>
|
|
98
99
|
<div class="title-text">
|
|
99
100
|
${renderIf(isBookTreeNode(treeNode, BookEntryType.ElementExample), html `
|
|
100
|
-
<${ViraIcon.assign({
|
|
101
|
+
<${ViraIcon.assign({
|
|
102
|
+
icon: Element16Icon,
|
|
103
|
+
})}></${ViraIcon}>
|
|
101
104
|
`)}
|
|
102
105
|
${treeNode.entry.title}
|
|
103
106
|
</div>
|
|
@@ -110,7 +113,7 @@ export const BookNav = defineBookElement()({
|
|
|
110
113
|
route: defaultBookFullRoute,
|
|
111
114
|
router: inputs.router,
|
|
112
115
|
})}>
|
|
113
|
-
<slot
|
|
116
|
+
<slot>Book</slot>
|
|
114
117
|
</${BookRouteLink}>
|
|
115
118
|
<ul>
|
|
116
119
|
${navTreeTemplates}
|
|
@@ -30,6 +30,9 @@ export declare const ElementBookApp: import("element-vir").DeclarativeElementDef
|
|
|
30
30
|
controls: ControlsWrapper;
|
|
31
31
|
} | undefined;
|
|
32
32
|
originalWindowTitle: string | undefined;
|
|
33
|
+
isDarkMode: boolean;
|
|
34
|
+
/** Cleanup callback for the dark mode media query listener. */
|
|
35
|
+
darkModeCleanup: (() => void) | undefined;
|
|
33
36
|
}, {
|
|
34
37
|
pathUpdate: import("element-vir").DefineEvent<readonly string[]>;
|
|
35
|
-
}, "element-book-app-", "element-book-app-", readonly [], readonly []>;
|
|
38
|
+
}, "element-book-app-", "element-book-app-", readonly ["footer", "navHeader"], readonly []>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { extractErrorMessage, makeWritable } from '@augment-vir/common';
|
|
3
3
|
import { waitForAnimationFrame } from '@augment-vir/web';
|
|
4
|
+
import { colorCss } from '@electrovir/color';
|
|
4
5
|
import { css, defineElement, defineElementEvent, html, listen, nothing } from 'element-vir';
|
|
6
|
+
import { applyCssVarsViaStyleElement } from 'lit-css-vars';
|
|
7
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
8
|
+
import { ViraError, viraTheme, viraThemeDarkOverride } from 'vira';
|
|
5
9
|
import { createNewControls, updateTreeControls, } from '../../../data/book-entry/book-page/controls-wrapper.js';
|
|
6
10
|
import { createBookTreeFromEntries } from '../../../data/book-tree/book-tree.js';
|
|
7
11
|
import { searchFlattenedNodes } from '../../../data/book-tree/search-nodes.js';
|
|
8
12
|
import { createBookRouter } from '../../../routing/book-router.js';
|
|
9
13
|
import { defaultBookFullRoute, extractSearchQuery, } from '../../../routing/book-routing.js';
|
|
10
|
-
import {
|
|
14
|
+
import { setThemeCssVars } from '../../color-theme/color-theme.js';
|
|
11
15
|
import { createTheme } from '../../color-theme/create-color-theme.js';
|
|
12
16
|
import { ChangeRouteEvent } from '../../events/change-route.event.js';
|
|
13
17
|
import { BookNav } from '../book-nav/book-nav.element.js';
|
|
14
|
-
import { BookError } from '../common/book-error.element.js';
|
|
15
18
|
import { BookPageControls } from '../entry-display/book-page/book-page-controls.element.js';
|
|
16
19
|
import { BookEntryDisplay } from '../entry-display/entry-display/book-entry-display.element.js';
|
|
17
|
-
import { ElementBookSlotName } from './element-book-app-slots.js';
|
|
18
20
|
import { getCurrentNodes } from './get-current-nodes.js';
|
|
19
21
|
/**
|
|
20
22
|
* The element-book app itself. Instantiate one of these where you want your element-book pages to
|
|
@@ -35,11 +37,26 @@ export const ElementBookApp = defineElement()({
|
|
|
35
37
|
},
|
|
36
38
|
treeBasedControls: undefined,
|
|
37
39
|
originalWindowTitle: undefined,
|
|
40
|
+
isDarkMode: globalThis.matchMedia('(prefers-color-scheme: dark)').matches,
|
|
41
|
+
/** Cleanup callback for the dark mode media query listener. */
|
|
42
|
+
darkModeCleanup: undefined,
|
|
38
43
|
};
|
|
39
44
|
},
|
|
40
45
|
events: {
|
|
41
46
|
pathUpdate: defineElementEvent(),
|
|
42
47
|
},
|
|
48
|
+
slotNames: [
|
|
49
|
+
/**
|
|
50
|
+
* Used to specify a footer for the main element example viewer. It always appears at the
|
|
51
|
+
* bottom of the viewer's scroll area.
|
|
52
|
+
*/
|
|
53
|
+
'footer',
|
|
54
|
+
/**
|
|
55
|
+
* Used to specify a header above the navigation sidebar. This is a particularly good place
|
|
56
|
+
* for branding.
|
|
57
|
+
*/
|
|
58
|
+
'navHeader',
|
|
59
|
+
],
|
|
43
60
|
styles: css `
|
|
44
61
|
:host {
|
|
45
62
|
display: flex;
|
|
@@ -47,12 +64,7 @@ export const ElementBookApp = defineElement()({
|
|
|
47
64
|
height: 100%;
|
|
48
65
|
width: 100%;
|
|
49
66
|
font-family: sans-serif;
|
|
50
|
-
|
|
51
|
-
color: ${colorThemeCssVars['element-book-page-foreground-color'].value};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.error {
|
|
55
|
-
color: red;
|
|
67
|
+
${colorCss(viraTheme.colors[themeDefaultKey])}
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
.root {
|
|
@@ -79,10 +91,16 @@ export const ElementBookApp = defineElement()({
|
|
|
79
91
|
cleanup({ state, updateState }) {
|
|
80
92
|
if (state.router) {
|
|
81
93
|
state.router.destroy();
|
|
82
|
-
updateState({ router: undefined });
|
|
83
94
|
}
|
|
95
|
+
if (state.darkModeCleanup) {
|
|
96
|
+
state.darkModeCleanup();
|
|
97
|
+
}
|
|
98
|
+
updateState({
|
|
99
|
+
router: undefined,
|
|
100
|
+
darkModeCleanup: undefined,
|
|
101
|
+
});
|
|
84
102
|
},
|
|
85
|
-
render: ({ state, inputs, host, updateState, dispatch, events }) => {
|
|
103
|
+
render: ({ state, inputs, host, updateState, dispatch, events, slotNames }) => {
|
|
86
104
|
if (inputs._debug) {
|
|
87
105
|
console.info('rendering element-book app');
|
|
88
106
|
}
|
|
@@ -99,7 +117,9 @@ export const ElementBookApp = defineElement()({
|
|
|
99
117
|
function updateWindowTitle(topNodeTitle) {
|
|
100
118
|
if (!inputs.preventWindowTitleChange) {
|
|
101
119
|
if (!state.originalWindowTitle) {
|
|
102
|
-
updateState({
|
|
120
|
+
updateState({
|
|
121
|
+
originalWindowTitle: document.title,
|
|
122
|
+
});
|
|
103
123
|
}
|
|
104
124
|
document.title = [
|
|
105
125
|
state.originalWindowTitle,
|
|
@@ -133,11 +153,15 @@ export const ElementBookApp = defineElement()({
|
|
|
133
153
|
try {
|
|
134
154
|
if (inputs.elementBookRoutePaths &&
|
|
135
155
|
!check.jsonEquals(inputs.elementBookRoutePaths, state.currentRoute.paths)) {
|
|
136
|
-
updateRoutes({
|
|
156
|
+
updateRoutes({
|
|
157
|
+
paths: makeWritable(inputs.elementBookRoutePaths),
|
|
158
|
+
});
|
|
137
159
|
}
|
|
138
160
|
if (inputs.internalRouterConfig?.useInternalRouter && !state.router) {
|
|
139
161
|
const router = createBookRouter(inputs.internalRouterConfig.basePath);
|
|
140
|
-
updateState({
|
|
162
|
+
updateState({
|
|
163
|
+
router,
|
|
164
|
+
});
|
|
141
165
|
router.listen(true, (fullRoute) => {
|
|
142
166
|
updateState({
|
|
143
167
|
currentRoute: fullRoute,
|
|
@@ -160,6 +184,23 @@ export const ElementBookApp = defineElement()({
|
|
|
160
184
|
});
|
|
161
185
|
setThemeCssVars(host, newTheme);
|
|
162
186
|
}
|
|
187
|
+
if (!state.darkModeCleanup) {
|
|
188
|
+
const query = globalThis.matchMedia('(prefers-color-scheme: dark)');
|
|
189
|
+
const listener = (event) => {
|
|
190
|
+
updateState({
|
|
191
|
+
isDarkMode: event.matches,
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
query.addEventListener('change', listener);
|
|
195
|
+
updateState({
|
|
196
|
+
isDarkMode: query.matches,
|
|
197
|
+
darkModeCleanup: () => {
|
|
198
|
+
query.removeEventListener('change', listener);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const isDarkMode = inputs.darkMode ?? state.isDarkMode;
|
|
203
|
+
applyCssVarsViaStyleElement(isDarkMode ? viraThemeDarkOverride.overrides : {}, 'element-book-dark-mode');
|
|
163
204
|
const debug = inputs._debug ?? false;
|
|
164
205
|
const originalTree = createBookTreeFromEntries({
|
|
165
206
|
entries: inputs.pages,
|
|
@@ -195,13 +236,13 @@ export const ElementBookApp = defineElement()({
|
|
|
195
236
|
const currentControls = state.treeBasedControls?.controls;
|
|
196
237
|
if (!currentControls) {
|
|
197
238
|
return html `
|
|
198
|
-
<${
|
|
199
|
-
message: 'Failed to generate page controls.',
|
|
200
|
-
})}></${BookError}>
|
|
239
|
+
<${ViraError}>Failed to generate page controls.</${ViraError}>
|
|
201
240
|
`;
|
|
202
241
|
}
|
|
203
242
|
if (inputs._debug) {
|
|
204
|
-
console.info({
|
|
243
|
+
console.info({
|
|
244
|
+
currentControls,
|
|
245
|
+
});
|
|
205
246
|
}
|
|
206
247
|
return html `
|
|
207
248
|
<div
|
|
@@ -211,7 +252,9 @@ export const ElementBookApp = defineElement()({
|
|
|
211
252
|
if (!areRoutesNew(newRoute)) {
|
|
212
253
|
return;
|
|
213
254
|
}
|
|
214
|
-
updateState({
|
|
255
|
+
updateState({
|
|
256
|
+
loading: true,
|
|
257
|
+
});
|
|
215
258
|
updateRoutes(newRoute);
|
|
216
259
|
const navElement = host.shadowRoot.querySelector(BookNav.tagName);
|
|
217
260
|
if (!(navElement instanceof BookNav)) {
|
|
@@ -241,10 +284,7 @@ export const ElementBookApp = defineElement()({
|
|
|
241
284
|
? undefined
|
|
242
285
|
: state.currentRoute.paths.slice(1),
|
|
243
286
|
})}>
|
|
244
|
-
<slot
|
|
245
|
-
name=${ElementBookSlotName.NavHeader}
|
|
246
|
-
slot=${ElementBookSlotName.NavHeader}
|
|
247
|
-
></slot>
|
|
287
|
+
<slot name=${slotNames.navHeader}></slot>
|
|
248
288
|
</${BookNav}>
|
|
249
289
|
`}
|
|
250
290
|
<${BookEntryDisplay.assign({
|
|
@@ -261,19 +301,21 @@ export const ElementBookApp = defineElement()({
|
|
|
261
301
|
await waitForAnimationFrame();
|
|
262
302
|
const entryDisplay = host.shadowRoot.querySelector(BookEntryDisplay.tagName);
|
|
263
303
|
if (entryDisplay) {
|
|
264
|
-
entryDisplay.scroll({
|
|
304
|
+
entryDisplay.scroll({
|
|
305
|
+
top: 0,
|
|
306
|
+
behavior: 'instant',
|
|
307
|
+
});
|
|
265
308
|
}
|
|
266
309
|
else {
|
|
267
310
|
console.error(`Failed to find '${BookEntryDisplay.tagName}' for scrolling.`);
|
|
268
311
|
}
|
|
269
312
|
await waitForAnimationFrame();
|
|
270
|
-
updateState({
|
|
313
|
+
updateState({
|
|
314
|
+
loading: !event.detail,
|
|
315
|
+
});
|
|
271
316
|
})}
|
|
272
317
|
>
|
|
273
|
-
<slot
|
|
274
|
-
name=${ElementBookSlotName.Footer}
|
|
275
|
-
slot=${ElementBookSlotName.Footer}
|
|
276
|
-
></slot>
|
|
318
|
+
<slot name=${slotNames.footer}></slot>
|
|
277
319
|
</${BookEntryDisplay}>
|
|
278
320
|
</div>
|
|
279
321
|
`;
|
|
@@ -281,7 +323,7 @@ export const ElementBookApp = defineElement()({
|
|
|
281
323
|
catch (error) {
|
|
282
324
|
console.error(error);
|
|
283
325
|
return html `
|
|
284
|
-
|
|
326
|
+
<${ViraError}>${extractErrorMessage(error)}</${ViraError}>
|
|
285
327
|
`;
|
|
286
328
|
}
|
|
287
329
|
},
|
|
@@ -20,6 +20,8 @@ export type ElementBookConfig = {
|
|
|
20
20
|
export type OptionalConfig = {
|
|
21
21
|
/** The base theme color from which all other element-book colors will be generated from. */
|
|
22
22
|
themeColor: string;
|
|
23
|
+
/** Force dark mode on or off. When `undefined`, follows the system preference. */
|
|
24
|
+
darkMode: boolean;
|
|
23
25
|
_debug: boolean;
|
|
24
26
|
globalValues: GlobalValues;
|
|
25
27
|
preventWindowTitleChange: boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { wait } from '@augment-vir/common';
|
|
2
2
|
import { css, html, listen, renderIf } from 'element-vir';
|
|
3
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
4
|
+
import { viraTheme } from 'vira';
|
|
3
5
|
import { BookMainRoute, defaultBookFullRoute, } from '../../../routing/book-routing.js';
|
|
4
|
-
import { colorThemeCssVars } from '../../color-theme/color-theme.js';
|
|
5
6
|
import { ChangeRouteEvent } from '../../events/change-route.event.js';
|
|
6
7
|
import { BookBreadcrumbs } from '../book-breadcrumbs.element.js';
|
|
7
8
|
import { defineBookElement } from '../define-book-element.js';
|
|
@@ -10,9 +11,9 @@ export const BookBreadcrumbsBar = defineBookElement()({
|
|
|
10
11
|
styles: css `
|
|
11
12
|
:host {
|
|
12
13
|
border-bottom: 1px solid
|
|
13
|
-
${
|
|
14
|
+
${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
14
15
|
padding: 4px 8px;
|
|
15
|
-
background-color: ${
|
|
16
|
+
background-color: ${viraTheme.colors[themeDefaultKey].background.value};
|
|
16
17
|
display: flex;
|
|
17
18
|
gap: 16px;
|
|
18
19
|
justify-content: space-between;
|
|
@@ -38,7 +39,9 @@ export const BookBreadcrumbsBar = defineBookElement()({
|
|
|
38
39
|
}
|
|
39
40
|
const preThrottleValue = inputElement.value;
|
|
40
41
|
// throttle it a bit
|
|
41
|
-
await wait({
|
|
42
|
+
await wait({
|
|
43
|
+
milliseconds: 200,
|
|
44
|
+
});
|
|
42
45
|
if (inputElement.value !== preThrottleValue) {
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
-
import {
|
|
2
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
3
|
+
import { viraTheme } from 'vira';
|
|
3
4
|
import { defineBookElement } from '../define-book-element.js';
|
|
4
5
|
export const BookEntryDescription = defineBookElement()({
|
|
5
6
|
tagName: 'book-entry-description',
|
|
6
7
|
styles: css `
|
|
7
8
|
:host {
|
|
8
|
-
color: ${
|
|
9
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
9
10
|
display: inline-flex;
|
|
10
11
|
flex-direction: column;
|
|
11
12
|
gap: 8px;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
:host(:hover) {
|
|
15
|
-
color: ${
|
|
16
|
+
color: ${viraTheme.colors[themeDefaultKey].foreground.value};
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
p {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { VirColorPicker } from '@electrovir/color';
|
|
3
3
|
import { css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
4
|
-
import { Options24Icon, ViraCheckbox, ViraIcon, ViraInput, ViraSelect } from 'vira';
|
|
4
|
+
import { Options24Icon, ViraCheckbox, ViraError, ViraIcon, ViraInput, ViraSelect, viraTheme, } from 'vira';
|
|
5
5
|
import { BookPageControlType, isControlInitType, } from '../../../../data/book-entry/book-page/book-page-controls.js';
|
|
6
|
-
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
7
6
|
import { defineBookElement } from '../../define-book-element.js';
|
|
8
7
|
export const BookPageControls = defineBookElement()({
|
|
9
8
|
tagName: 'book-page-controls',
|
|
@@ -22,7 +21,7 @@ export const BookPageControls = defineBookElement()({
|
|
|
22
21
|
align-content: flex-start;
|
|
23
22
|
gap: 16px;
|
|
24
23
|
row-gap: 10px;
|
|
25
|
-
color: ${
|
|
24
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
${hostClasses['book-page-controls-has-controls'].selector} {
|
|
@@ -36,11 +35,6 @@ export const BookPageControls = defineBookElement()({
|
|
|
36
35
|
flex-direction: column;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
.error {
|
|
40
|
-
font-weight: bold;
|
|
41
|
-
color: red;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
${ViraInput}, ${ViraSelect} {
|
|
45
39
|
height: 24px;
|
|
46
40
|
max-width: 128px;
|
|
@@ -87,7 +81,9 @@ export const BookPageControls = defineBookElement()({
|
|
|
87
81
|
return html `
|
|
88
82
|
<div class="control-wrapper">
|
|
89
83
|
${renderIf(index === 0, html `
|
|
90
|
-
<${ViraIcon.assign({
|
|
84
|
+
<${ViraIcon.assign({
|
|
85
|
+
icon: Options24Icon,
|
|
86
|
+
})}
|
|
91
87
|
class="options-icon"
|
|
92
88
|
></${ViraIcon}>
|
|
93
89
|
`)}
|
|
@@ -183,9 +179,9 @@ function createControlInput(value, controlInit, valueChange) {
|
|
|
183
179
|
}
|
|
184
180
|
else {
|
|
185
181
|
return html `
|
|
186
|
-
|
|
182
|
+
<${ViraError}>
|
|
187
183
|
${controlInit.controlType} controls are not implemented yet.
|
|
188
|
-
|
|
184
|
+
</${ViraError}>
|
|
189
185
|
`;
|
|
190
186
|
}
|
|
191
187
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { combineErrors } from '@augment-vir/common';
|
|
2
2
|
import { css, html } from 'element-vir';
|
|
3
|
+
import { ViraError } from 'vira';
|
|
3
4
|
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper.js';
|
|
4
5
|
import { BookMainRoute } from '../../../../routing/book-routing.js';
|
|
5
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
6
6
|
import { BookRouteLink } from '../../common/book-route-link.element.js';
|
|
7
7
|
import { defineBookElement } from '../../define-book-element.js';
|
|
8
8
|
import { BookEntryDescription } from '../book-entry-description.element.js';
|
|
@@ -72,7 +72,7 @@ export const BookPageWrapper = defineBookElement()({
|
|
|
72
72
|
${headerTemplate}
|
|
73
73
|
${error
|
|
74
74
|
? html `
|
|
75
|
-
<${
|
|
75
|
+
<${ViraError}>${error.message}</${ViraError}>
|
|
76
76
|
`
|
|
77
77
|
: html `
|
|
78
78
|
<${BookEntryDescription.assign({
|
package/dist/ui/elements/entry-display/element-example/book-element-example-title.element.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { BookMainRoute } from '../../../../routing/book-routing.js';
|
|
3
|
-
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
4
4
|
import { BookRouteLink } from '../../common/book-route-link.element.js';
|
|
5
5
|
import { defineBookElement } from '../../define-book-element.js';
|
|
6
6
|
export const BookElementExampleTitle = defineBookElement()({
|
|
@@ -8,7 +8,7 @@ export const BookElementExampleTitle = defineBookElement()({
|
|
|
8
8
|
styles: css `
|
|
9
9
|
:host {
|
|
10
10
|
display: flex;
|
|
11
|
-
color: ${
|
|
11
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
12
12
|
border-bottom: 1px solid currentColor;
|
|
13
13
|
padding: 0 8px 4px;
|
|
14
14
|
}
|
package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { combineErrors, extractErrorMessage } from '@augment-vir/common';
|
|
2
2
|
import { html, renderIf } from 'element-vir';
|
|
3
|
+
import { ViraError } from 'vira';
|
|
3
4
|
import { unsetInternalState } from '../../../../data/unset.js';
|
|
4
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
5
5
|
import { defineBookElement } from '../../define-book-element.js';
|
|
6
6
|
export const BookElementExampleViewer = defineBookElement()({
|
|
7
7
|
tagName: 'book-element-example-viewer',
|
|
@@ -15,7 +15,7 @@ export const BookElementExampleViewer = defineBookElement()({
|
|
|
15
15
|
if (inputs.elementExampleNode.entry.errors.length) {
|
|
16
16
|
throw combineErrors(inputs.elementExampleNode.entry.errors);
|
|
17
17
|
}
|
|
18
|
-
if (
|
|
18
|
+
else if (
|
|
19
19
|
/** This is a check to make sure the input entry _does_ match the expected type. */
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
21
21
|
!inputs.elementExampleNode.entry.render ||
|
|
@@ -49,9 +49,9 @@ export const BookElementExampleViewer = defineBookElement()({
|
|
|
49
49
|
console.error('ERROR HERE', extractErrorMessage(error));
|
|
50
50
|
console.error(error);
|
|
51
51
|
return html `
|
|
52
|
-
<${
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
<${ViraError}>
|
|
53
|
+
${inputs.elementExampleNode.entry.title} failed: ${extractErrorMessage(error)}
|
|
54
|
+
</${ViraError}>
|
|
55
55
|
`;
|
|
56
56
|
}
|
|
57
57
|
},
|
package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
3
4
|
import { defineBookElement } from '../../define-book-element.js';
|
|
4
5
|
import { BookElementExampleTitle } from './book-element-example-title.element.js';
|
|
@@ -17,11 +18,6 @@ export const BookElementExampleWrapper = defineBookElement()({
|
|
|
17
18
|
flex-wrap: wrap;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
.error {
|
|
21
|
-
color: red;
|
|
22
|
-
font-weight: bold;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
.individual-example-wrapper {
|
|
26
22
|
display: flex;
|
|
27
23
|
flex-direction: column;
|
|
@@ -31,7 +27,7 @@ export const BookElementExampleWrapper = defineBookElement()({
|
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
${BookElementExampleTitle} {
|
|
34
|
-
color: ${
|
|
30
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
:host(:hover) ${BookElementExampleTitle} {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { colorCss } from '@electrovir/color';
|
|
1
2
|
import { css, defineElementEvent, html, onDomCreated, renderIf } from 'element-vir';
|
|
2
|
-
import {
|
|
3
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
4
|
+
import { LoaderAnimated24Icon, ViraIcon, viraAnimationDurations, viraTheme } from 'vira';
|
|
3
5
|
import { extractSearchQuery } from '../../../../routing/book-routing.js';
|
|
4
6
|
import { defineBookElement } from '../../define-book-element.js';
|
|
5
|
-
import { ElementBookSlotName } from '../../element-book-app/element-book-app-slots.js';
|
|
6
7
|
import { BookBreadcrumbsBar } from '../book-breadcrumbs-bar.element.js';
|
|
7
8
|
import { createNodeTemplates } from './create-node-templates.js';
|
|
8
9
|
export const BookEntryDisplay = defineBookElement()({
|
|
@@ -20,6 +21,7 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
.all-book-entries-wrapper {
|
|
24
|
+
background-color: ${viraTheme.colors[themeDefaultKey].background.value};
|
|
23
25
|
flex-grow: 1;
|
|
24
26
|
padding: 32px;
|
|
25
27
|
}
|
|
@@ -54,7 +56,7 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
54
56
|
flex-grow: 1;
|
|
55
57
|
padding: 64px;
|
|
56
58
|
position: absolute;
|
|
57
|
-
|
|
59
|
+
${colorCss(viraTheme.colors[themeDefaultKey])}
|
|
58
60
|
animation: fade-in linear
|
|
59
61
|
${viraAnimationDurations['vira-interaction-animation-duration'].value} forwards;
|
|
60
62
|
z-index: 100;
|
|
@@ -101,22 +103,26 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
101
103
|
})}
|
|
102
104
|
class="loading"
|
|
103
105
|
>
|
|
104
|
-
<${ViraIcon.assign({
|
|
106
|
+
<${ViraIcon.assign({
|
|
107
|
+
icon: LoaderAnimated24Icon,
|
|
108
|
+
})}></${ViraIcon}>
|
|
105
109
|
</div>
|
|
106
110
|
${renderIf(!!state.lastElement, html `
|
|
107
111
|
${state.lastElement}
|
|
108
|
-
<slot
|
|
112
|
+
<slot></slot>
|
|
109
113
|
`)}
|
|
110
114
|
`, html `
|
|
111
115
|
<div
|
|
112
116
|
${onDomCreated((element) => {
|
|
113
|
-
updateState({
|
|
117
|
+
updateState({
|
|
118
|
+
lastElement: element,
|
|
119
|
+
});
|
|
114
120
|
})}
|
|
115
121
|
class="all-book-entries-wrapper"
|
|
116
122
|
>
|
|
117
123
|
${entryTemplates}
|
|
118
124
|
</div>
|
|
119
|
-
<slot
|
|
125
|
+
<slot></slot>
|
|
120
126
|
`)}
|
|
121
127
|
`;
|
|
122
128
|
},
|
|
@@ -97,9 +97,13 @@ export const BookLazyEntry = defineBookElement()({
|
|
|
97
97
|
if (state.placeholderElement) {
|
|
98
98
|
unobserveElement(state.placeholderElement);
|
|
99
99
|
}
|
|
100
|
-
updateState({
|
|
100
|
+
updateState({
|
|
101
|
+
placeholderElement: element,
|
|
102
|
+
});
|
|
101
103
|
observedElements.set(element, () => {
|
|
102
|
-
updateState({
|
|
104
|
+
updateState({
|
|
105
|
+
hasRendered: true,
|
|
106
|
+
});
|
|
103
107
|
});
|
|
104
108
|
getSharedObserver().observe(element);
|
|
105
109
|
})}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { mapObjectValues } from '@augment-vir/common';
|
|
3
3
|
import { classMap, html, nothing, repeat, } from 'element-vir';
|
|
4
|
+
import { ViraError } from 'vira';
|
|
4
5
|
import { BookEntryType } from '../../../../data/book-entry/book-entry-type.js';
|
|
5
6
|
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper.js';
|
|
6
7
|
import { isBookTreeNode, traverseToImmediateParent } from '../../../../data/book-tree/book-tree.js';
|
|
7
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
8
8
|
import { BookPageControls } from '../book-page/book-page-controls.element.js';
|
|
9
9
|
import { BookPageWrapper } from '../book-page/book-page-wrapper.element.js';
|
|
10
10
|
import { BookElementExampleWrapper } from '../element-example/book-element-example-wrapper.element.js';
|
|
@@ -43,7 +43,11 @@ function getFlattenedControlsFromHiddenParents(currentNodes, currentControls, cu
|
|
|
43
43
|
...currentControls.breadcrumbs,
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
-
}, {
|
|
46
|
+
}, {
|
|
47
|
+
config: {},
|
|
48
|
+
current: {},
|
|
49
|
+
breadcrumbs: {},
|
|
50
|
+
});
|
|
47
51
|
}
|
|
48
52
|
export function createNodeTemplates({ blockNavigation, currentNodes, isTopLevel, router, isSearching, controls, originalTree, }) {
|
|
49
53
|
if (!currentNodes.length && isSearching) {
|
|
@@ -106,9 +110,9 @@ export function createNodeTemplates({ blockNavigation, currentNodes, isTopLevel,
|
|
|
106
110
|
}
|
|
107
111
|
else {
|
|
108
112
|
const content = html `
|
|
109
|
-
<${
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
<${ViraError}>
|
|
114
|
+
Unknown entry type for rendering: '${currentNode.entry.entryType}'
|
|
115
|
+
</${ViraError}>
|
|
112
116
|
`;
|
|
113
117
|
return html `
|
|
114
118
|
<${BookLazyEntry.assign({
|
|
@@ -36,12 +36,11 @@ searchIn, }) {
|
|
|
36
36
|
if (searchQueryLength > searchInLength) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
if (searchQueryLength === searchInLength) {
|
|
39
|
+
else if (searchQueryLength === searchInLength) {
|
|
40
40
|
return searchQuery === searchIn;
|
|
41
41
|
}
|
|
42
42
|
const lowercaseSearchIn = searchIn.toLowerCase();
|
|
43
43
|
const lowercaseSearchQuery = searchQuery.toLowerCase();
|
|
44
|
-
// eslint-disable-next-line sonarjs/no-labels
|
|
45
44
|
outer: for (let i = 0, j = 0; i < searchQueryLength; i++) {
|
|
46
45
|
const charCode = lowercaseSearchQuery.codePointAt(i);
|
|
47
46
|
while (j < searchInLength) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-book",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.17.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"book",
|
|
6
6
|
"design system",
|
|
@@ -41,33 +41,35 @@
|
|
|
41
41
|
"test:docs": "virmator docs check"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@augment-vir/assert": "^31.
|
|
45
|
-
"@augment-vir/common": "^31.
|
|
46
|
-
"@augment-vir/web": "^31.
|
|
47
|
-
"@electrovir/color": "^1.7.
|
|
44
|
+
"@augment-vir/assert": "^31.68.2",
|
|
45
|
+
"@augment-vir/common": "^31.68.2",
|
|
46
|
+
"@augment-vir/web": "^31.68.2",
|
|
47
|
+
"@electrovir/color": "^1.7.9",
|
|
48
48
|
"colorjs.io": "^0.6.1",
|
|
49
|
-
"date-vir": "^8.
|
|
50
|
-
"lit-css-vars": "^3.
|
|
49
|
+
"date-vir": "^8.2.1",
|
|
50
|
+
"lit-css-vars": "^3.6.2",
|
|
51
51
|
"spa-router-vir": "^6.4.1",
|
|
52
|
-
"typed-event-target": "^4.
|
|
52
|
+
"typed-event-target": "^4.3.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@augment-vir/test": "^31.
|
|
55
|
+
"@augment-vir/test": "^31.68.2",
|
|
56
56
|
"@web/dev-server-esbuild": "^1.0.5",
|
|
57
57
|
"@web/test-runner": "^0.20.2",
|
|
58
58
|
"@web/test-runner-commands": "^0.9.0",
|
|
59
59
|
"@web/test-runner-playwright": "^0.11.1",
|
|
60
60
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
61
|
-
"element-vir": "^26.
|
|
61
|
+
"element-vir": "^26.15.1",
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
63
63
|
"markdown-code-example-inserter": "^3.0.3",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"theme-vir": "^28.25.0",
|
|
65
|
+
"type-fest": "^5.5.0",
|
|
66
|
+
"typedoc": "^0.28.18",
|
|
66
67
|
"typescript": "5.9.3",
|
|
67
|
-
"vira": "^
|
|
68
|
+
"vira": "^31.13.0"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"element-vir": ">=17",
|
|
72
|
+
"theme-vir": ">=28.0.0",
|
|
71
73
|
"vira": ">=28.0.0"
|
|
72
74
|
},
|
|
73
75
|
"engines": {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { css, html } from 'element-vir';
|
|
3
|
-
import { defineBookElement } from '../define-book-element.js';
|
|
4
|
-
export const BookError = defineBookElement()({
|
|
5
|
-
tagName: 'book-error',
|
|
6
|
-
styles: css `
|
|
7
|
-
:host {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
color: red;
|
|
11
|
-
font-weight: bold;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
p {
|
|
15
|
-
margin: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
}
|
|
18
|
-
`,
|
|
19
|
-
render({ inputs }) {
|
|
20
|
-
const paragraphs = check.isArray(inputs.message) ? inputs.message : [inputs.message];
|
|
21
|
-
return paragraphs.map((paragraph) => html `
|
|
22
|
-
<p>${paragraph}</p>
|
|
23
|
-
`);
|
|
24
|
-
},
|
|
25
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Slots to be used on an element-book app instance for inserting custom HTML into the app.
|
|
3
|
-
*
|
|
4
|
-
* @category Main
|
|
5
|
-
*/
|
|
6
|
-
export declare enum ElementBookSlotName {
|
|
7
|
-
/**
|
|
8
|
-
* Used to specify a footer for the main element example viewer. It always appears at the bottom
|
|
9
|
-
* of the viewer's scroll area.
|
|
10
|
-
*/
|
|
11
|
-
Footer = "book-footer",
|
|
12
|
-
/**
|
|
13
|
-
* Used to specify a header above the navigation sidebar. This is a particularly good place for
|
|
14
|
-
* branding.
|
|
15
|
-
*/
|
|
16
|
-
NavHeader = "book-nav-header"
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Slots to be used on an element-book app instance for inserting custom HTML into the app.
|
|
3
|
-
*
|
|
4
|
-
* @category Main
|
|
5
|
-
*/
|
|
6
|
-
export var ElementBookSlotName;
|
|
7
|
-
(function (ElementBookSlotName) {
|
|
8
|
-
/**
|
|
9
|
-
* Used to specify a footer for the main element example viewer. It always appears at the bottom
|
|
10
|
-
* of the viewer's scroll area.
|
|
11
|
-
*/
|
|
12
|
-
ElementBookSlotName["Footer"] = "book-footer";
|
|
13
|
-
/**
|
|
14
|
-
* Used to specify a header above the navigation sidebar. This is a particularly good place for
|
|
15
|
-
* branding.
|
|
16
|
-
*/
|
|
17
|
-
ElementBookSlotName["NavHeader"] = "book-nav-header";
|
|
18
|
-
})(ElementBookSlotName || (ElementBookSlotName = {}));
|