element-book 22.2.2 → 23.0.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.
- package/README.md +65 -5
- package/dist/data/book-entry/base-book-entry.d.ts +7 -2
- package/dist/data/book-entry/book-entry-type.d.ts +12 -2
- package/dist/data/book-entry/book-entry-type.js +11 -6
- package/dist/data/book-entry/book-entry.d.ts +14 -4
- package/dist/data/book-entry/book-entry.js +7 -2
- package/dist/data/book-entry/book-page/book-page-controls.d.ts +62 -10
- package/dist/data/book-entry/book-page/book-page-controls.js +38 -16
- package/dist/data/book-entry/book-page/book-page.d.ts +29 -8
- package/dist/data/book-entry/book-page/book-page.js +1 -0
- package/dist/data/book-entry/book-page/controls-wrapper.d.ts +24 -4
- package/dist/data/book-entry/book-page/controls-wrapper.js +18 -3
- package/dist/data/book-entry/book-page/define-book-page.d.ts +44 -12
- package/dist/data/book-entry/book-page/define-book-page.js +19 -12
- package/dist/data/book-entry/book-root.d.ts +8 -3
- package/dist/data/book-entry/url-breadcrumbs.d.ts +17 -1
- package/dist/data/book-entry/url-breadcrumbs.js +16 -0
- package/dist/data/book-entry/verify-book-entry.d.ts +3 -6
- package/dist/data/book-entry/verify-book-entry.js +7 -7
- package/dist/data/book-tree/book-tree-node.d.ts +26 -7
- package/dist/data/book-tree/book-tree-node.js +5 -0
- package/dist/data/book-tree/book-tree.d.ts +7 -7
- package/dist/data/book-tree/book-tree.js +16 -15
- package/dist/data/book-tree/search-nodes.d.ts +1 -1
- package/dist/data/book-tree/search-nodes.js +4 -4
- package/dist/data/book-tree/tree-cache.d.ts +2 -2
- package/dist/index.d.ts +18 -10
- package/dist/index.js +18 -10
- package/dist/routing/book-router.d.ts +1 -1
- package/dist/routing/book-router.js +3 -3
- package/dist/routing/book-routing.d.ts +25 -0
- package/dist/routing/book-routing.js +15 -0
- package/dist/ui/color-theme/color-theme.d.ts +33 -13
- package/dist/ui/color-theme/color-theme.js +14 -5
- package/dist/ui/color-theme/create-color-theme.d.ts +23 -3
- package/dist/ui/color-theme/create-color-theme.js +15 -0
- package/dist/ui/elements/book-breadcrumbs.element.d.ts +3 -3
- package/dist/ui/elements/book-breadcrumbs.element.js +4 -4
- package/dist/ui/elements/book-nav/book-nav-filter.d.ts +1 -1
- package/dist/ui/elements/book-nav/book-nav-filter.js +6 -10
- package/dist/ui/elements/book-nav/book-nav.element.d.ts +3 -3
- package/dist/ui/elements/book-nav/book-nav.element.js +13 -13
- package/dist/ui/elements/common/book-error.element.d.ts +1 -1
- package/dist/ui/elements/common/book-error.element.js +4 -6
- package/dist/ui/elements/common/book-route-link.element.d.ts +3 -3
- package/dist/ui/elements/common/book-route-link.element.js +3 -3
- package/dist/ui/elements/define-book-element.d.ts +1 -1
- package/dist/ui/elements/element-book-app/element-book-app-slots.d.ts +13 -0
- package/dist/ui/elements/element-book-app/element-book-app-slots.js +13 -0
- package/dist/ui/elements/element-book-app/element-book-app.element.d.ts +22 -11
- package/dist/ui/elements/element-book-app/element-book-app.element.js +42 -36
- package/dist/ui/elements/element-book-app/element-book-config.d.ts +26 -16
- package/dist/ui/elements/element-book-app/get-current-nodes.d.ts +2 -2
- package/dist/ui/elements/element-book-app/get-current-nodes.js +3 -8
- package/dist/ui/elements/element-book-app/global-values.d.ts +5 -0
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.d.ts +3 -3
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.js +8 -8
- package/dist/ui/elements/entry-display/book-entry-description.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/book-entry-description.element.js +3 -3
- package/dist/ui/elements/entry-display/book-page/book-page-controls.element.d.ts +6 -6
- package/dist/ui/elements/entry-display/book-page/book-page-controls.element.js +14 -14
- package/dist/ui/elements/entry-display/book-page/book-page-wrapper.element.d.ts +6 -6
- package/dist/ui/elements/entry-display/book-page/book-page-wrapper.element.js +13 -11
- package/dist/ui/elements/entry-display/element-example/book-element-example-controls.element.d.ts +5 -5
- package/dist/ui/elements/entry-display/element-example/book-element-example-controls.element.js +5 -5
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.d.ts +5 -5
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js +13 -9
- package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.d.ts +6 -6
- package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.js +5 -5
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.d.ts +9 -9
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.js +6 -6
- package/dist/ui/elements/entry-display/entry-display/create-node-templates.d.ts +5 -5
- package/dist/ui/elements/entry-display/entry-display/create-node-templates.js +16 -16
- package/dist/ui/events/change-route.event.d.ts +1 -1
- package/dist/util/fuzzy-search.js +3 -2
- package/dist/util/type.d.ts +7 -0
- package/package.json +31 -29
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Overwrite } from '@augment-vir/common';
|
|
2
|
-
import { BaseBookEntry } from './base-book-entry';
|
|
3
|
-
import {
|
|
2
|
+
import { BaseBookEntry } from './base-book-entry.js';
|
|
3
|
+
import { BookEntryType } from './book-entry-type.js';
|
|
4
|
+
/**
|
|
5
|
+
* The root of a book tree.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
4
9
|
export type BookRoot = Overwrite<BaseBookEntry, {
|
|
5
|
-
entryType:
|
|
10
|
+
entryType: BookEntryType.Root;
|
|
6
11
|
parent: undefined;
|
|
7
12
|
}>;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import { BookEntry } from './book-entry';
|
|
1
|
+
import { BookEntry } from './book-entry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a list of URL breadcrumbs for the given element-book entry.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
2
7
|
export declare function listUrlBreadcrumbs(entry: BookEntry, includeSelf: boolean): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Convert an element-book entry's title to a URL-safe breadcrumb title.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
3
13
|
export declare function titleToUrlBreadcrumb(title: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a full list of URL breadcrumbs (`searchIn`) starts with the subset list of URL
|
|
16
|
+
* breadcrumbs (`searchFor`).
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
4
20
|
export declare function doBreadcrumbsStartWith({ searchFor, searchIn, }: {
|
|
5
21
|
searchIn: ReadonlyArray<string>;
|
|
6
22
|
searchFor: ReadonlyArray<string>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { collapseWhiteSpace } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* Create a list of URL breadcrumbs for the given element-book entry.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
2
7
|
export function listUrlBreadcrumbs(entry, includeSelf) {
|
|
3
8
|
const entryBreadcrumb = titleToUrlBreadcrumb(entry.title);
|
|
4
9
|
if (entry.parent) {
|
|
@@ -14,9 +19,20 @@ export function listUrlBreadcrumbs(entry, includeSelf) {
|
|
|
14
19
|
return [];
|
|
15
20
|
}
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Convert an element-book entry's title to a URL-safe breadcrumb title.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
17
27
|
export function titleToUrlBreadcrumb(title) {
|
|
18
28
|
return collapseWhiteSpace(title).toLowerCase().replaceAll(/\s/g, '-');
|
|
19
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a full list of URL breadcrumbs (`searchIn`) starts with the subset list of URL
|
|
32
|
+
* breadcrumbs (`searchFor`).
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
20
36
|
export function doBreadcrumbsStartWith({ searchFor, searchIn, }) {
|
|
21
37
|
return searchFor.every((breadcrumb, index) => {
|
|
22
38
|
return searchIn[index] === breadcrumb;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
page: (entry: BookEntry) => Error[];
|
|
5
|
-
root: (entry: BookEntry) => Error[];
|
|
6
|
-
};
|
|
1
|
+
import { BookEntryType } from './book-entry-type.js';
|
|
2
|
+
import { BookEntry } from './book-entry.js';
|
|
3
|
+
export declare const bookEntryVerifiers: { [EntryType in BookEntryType]: (entry: BookEntry) => Error[]; };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { checkControls } from './book-page/book-page-controls';
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { BookEntryType } from './book-entry-type.js';
|
|
3
|
+
import { checkControls } from './book-page/book-page-controls.js';
|
|
4
4
|
export const bookEntryVerifiers = {
|
|
5
|
-
[
|
|
5
|
+
[BookEntryType.ElementExample]: () => {
|
|
6
6
|
// currently all element example checking happens on page definition
|
|
7
7
|
return [];
|
|
8
8
|
},
|
|
9
|
-
[
|
|
9
|
+
[BookEntryType.Page]: (bookPage) => {
|
|
10
10
|
return [
|
|
11
11
|
!bookPage.title && new Error(`Cannot define an element-book page with an empty title.`),
|
|
12
12
|
...checkControls(bookPage.controls, bookPage.title),
|
|
13
|
-
].filter(isTruthy);
|
|
13
|
+
].filter(check.isTruthy);
|
|
14
14
|
},
|
|
15
|
-
[
|
|
15
|
+
[BookEntryType.Root]: () => {
|
|
16
16
|
return [];
|
|
17
17
|
},
|
|
18
18
|
};
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Values } from '@augment-vir/common';
|
|
2
|
+
import { AnyBookEntryType, BookEntryType } from '../book-entry/book-entry-type.js';
|
|
3
|
+
import { BookEntry } from '../book-entry/book-entry.js';
|
|
4
|
+
/**
|
|
5
|
+
* Property used to mark tree nodes.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
4
9
|
export declare const isBookTreeNodeMarker = "_isBookTreeNode";
|
|
5
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The base tree node type for {@link BookTreeNode}.
|
|
12
|
+
*
|
|
13
|
+
* @category Internal
|
|
14
|
+
*/
|
|
15
|
+
export type InternalBookTreeNodeType<Entry> = {
|
|
6
16
|
[isBookTreeNodeMarker]: true;
|
|
7
17
|
entry: Entry;
|
|
8
18
|
/** UrlBreadcrumb is different from entry.title because it's modified to support URLs. */
|
|
@@ -15,13 +25,22 @@ type InternalBookTreeNodeType<Entry> = {
|
|
|
15
25
|
*/
|
|
16
26
|
manuallyAdded: boolean;
|
|
17
27
|
};
|
|
18
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Any element-book tree node.
|
|
30
|
+
*
|
|
31
|
+
* @category Internal
|
|
32
|
+
*/
|
|
33
|
+
export type BookTreeNode<EntryTypes extends BookEntryType = AnyBookEntryType> = Values<{
|
|
19
34
|
[EntryType in EntryTypes]: InternalBookTreeNodeType<Extract<BookEntry, {
|
|
20
35
|
entryType: EntryType;
|
|
21
36
|
}>>;
|
|
22
37
|
}> | (AnyBookEntryType extends EntryTypes ? InternalBookTreeNodeType<BookEntry> : never);
|
|
38
|
+
/**
|
|
39
|
+
* The full element-book app tree for representing page structure.
|
|
40
|
+
*
|
|
41
|
+
* @category Internal
|
|
42
|
+
*/
|
|
23
43
|
export type BookTree = Readonly<{
|
|
24
|
-
tree: Readonly<BookTreeNode<
|
|
44
|
+
tree: Readonly<BookTreeNode<BookEntryType.Root>>;
|
|
25
45
|
flattenedNodes: ReadonlyArray<Readonly<BookTreeNode>>;
|
|
26
46
|
}>;
|
|
27
|
-
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BookTree, BookTreeNode } from './book-tree-node';
|
|
4
|
-
export declare function doesNodeHaveEntryType<const EntryType extends
|
|
5
|
-
export declare function isBookTreeNode<const SpecificType extends
|
|
6
|
-
export declare function isAnyBookTreeNode(input: unknown): input is BookTreeNode<
|
|
7
|
-
export declare function createEmptyBookTreeRoot(): BookTreeNode<
|
|
1
|
+
import { BookEntryType } from '../book-entry/book-entry-type.js';
|
|
2
|
+
import { BookEntry } from '../book-entry/book-entry.js';
|
|
3
|
+
import { BookTree, BookTreeNode } from './book-tree-node.js';
|
|
4
|
+
export declare function doesNodeHaveEntryType<const EntryType extends BookEntryType>(node: unknown, entryType: EntryType): node is BookTreeNode<EntryType>;
|
|
5
|
+
export declare function isBookTreeNode<const SpecificType extends BookEntryType>(input: unknown, entryType: SpecificType): input is BookTreeNode<SpecificType>;
|
|
6
|
+
export declare function isAnyBookTreeNode(input: unknown): input is BookTreeNode<BookEntryType>;
|
|
7
|
+
export declare function createEmptyBookTreeRoot(): BookTreeNode<BookEntryType.Root>;
|
|
8
8
|
export declare function createBookTreeFromEntries({ entries, debug, }: {
|
|
9
9
|
entries: ReadonlyArray<BookEntry>;
|
|
10
10
|
debug: boolean;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { listUrlBreadcrumbs, titleToUrlBreadcrumb } from '../book-entry/url-breadcrumbs';
|
|
5
|
-
import { bookEntryVerifiers } from '../book-entry/verify-book-entry';
|
|
6
|
-
import { isBookTreeNodeMarker } from './book-tree-node';
|
|
7
|
-
import { addTreeToCache, getTreeFromCache } from './tree-cache';
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { BookEntryType } from '../book-entry/book-entry-type.js';
|
|
3
|
+
import { isBookEntry } from '../book-entry/book-entry.js';
|
|
4
|
+
import { listUrlBreadcrumbs, titleToUrlBreadcrumb } from '../book-entry/url-breadcrumbs.js';
|
|
5
|
+
import { bookEntryVerifiers } from '../book-entry/verify-book-entry.js';
|
|
6
|
+
import { isBookTreeNodeMarker } from './book-tree-node.js';
|
|
7
|
+
import { addTreeToCache, getTreeFromCache } from './tree-cache.js';
|
|
8
8
|
export function doesNodeHaveEntryType(node, entryType) {
|
|
9
|
-
return node
|
|
9
|
+
return (check.hasKey(node, 'entry') &&
|
|
10
|
+
check.isObject(node.entry) &&
|
|
11
|
+
node.entry.entryType === entryType);
|
|
10
12
|
}
|
|
11
13
|
export function isBookTreeNode(input, entryType) {
|
|
12
14
|
return !!(isAnyBookTreeNode(input) && input.entry.entryType === entryType);
|
|
13
15
|
}
|
|
14
16
|
export function isAnyBookTreeNode(input) {
|
|
15
|
-
return !!(
|
|
17
|
+
return !!(check.hasKeys(input, [
|
|
16
18
|
isBookTreeNodeMarker,
|
|
17
19
|
'entry',
|
|
18
20
|
]) && input[isBookTreeNodeMarker]);
|
|
@@ -21,7 +23,7 @@ export function createEmptyBookTreeRoot() {
|
|
|
21
23
|
const rootNode = {
|
|
22
24
|
[isBookTreeNodeMarker]: true,
|
|
23
25
|
entry: {
|
|
24
|
-
entryType:
|
|
26
|
+
entryType: BookEntryType.Root,
|
|
25
27
|
title: '',
|
|
26
28
|
parent: undefined,
|
|
27
29
|
errors: [],
|
|
@@ -66,7 +68,7 @@ function getOrAddImmediateParent(tree, entry, debug) {
|
|
|
66
68
|
addEntryToTree({ tree, newEntry: entry.parent, debug, manuallyAdded: false });
|
|
67
69
|
const immediateParentAfterAdding = traverseToImmediateParent(entry, tree);
|
|
68
70
|
if (!immediateParentAfterAdding) {
|
|
69
|
-
throw new Error(`Failed to find node despite having just added it: ${listUrlBreadcrumbs(entry, false)}`);
|
|
71
|
+
throw new Error(`Failed to find node despite having just added it: ${listUrlBreadcrumbs(entry, false).join(' > ')}`);
|
|
70
72
|
}
|
|
71
73
|
return immediateParentAfterAdding;
|
|
72
74
|
}
|
|
@@ -101,10 +103,9 @@ function addEntryToTree({ tree, newEntry, debug, manuallyAdded, }) {
|
|
|
101
103
|
manuallyAdded,
|
|
102
104
|
};
|
|
103
105
|
immediateParent.children[newEntryUrlBreadcrumb] = newNode;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Object.values(newEntry.elementExamples
|
|
107
|
-
Object.values(newEntry.elementExamples ?? {}).forEach((elementExample) => addEntryToTree({ tree, newEntry: elementExample, debug, manuallyAdded }));
|
|
106
|
+
if (isBookEntry(newEntry, BookEntryType.Page) &&
|
|
107
|
+
Object.values(newEntry.elementExamples).length) {
|
|
108
|
+
Object.values(newEntry.elementExamples).forEach((elementExample) => addEntryToTree({ tree, newEntry: elementExample, debug, manuallyAdded }));
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
export function traverseToImmediateParent(entryOrNode, currentTree) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
1
2
|
import { randomString } from '@augment-vir/common';
|
|
2
|
-
import {
|
|
3
|
-
import { fuzzySearch } from '../../util/fuzzy-search';
|
|
3
|
+
import { fuzzySearch } from '../../util/fuzzy-search.js';
|
|
4
4
|
const searchJoin = randomString(32);
|
|
5
5
|
function createBreadcrumbsSearchKey(breadcrumbs) {
|
|
6
6
|
return breadcrumbs.join(searchJoin);
|
|
@@ -58,8 +58,8 @@ export function searchFlattenedNodes({ flattenedNodes, searchQuery, }) {
|
|
|
58
58
|
return flattenedNodes.filter((treeNode) => {
|
|
59
59
|
const inSearchResultsKey = createBreadcrumbsSearchKey(treeNode.fullUrlBreadcrumbs);
|
|
60
60
|
const shouldInclude = includeInSearchResults[inSearchResultsKey];
|
|
61
|
-
if (!
|
|
62
|
-
throw new
|
|
61
|
+
if (!check.isBoolean(shouldInclude)) {
|
|
62
|
+
throw new TypeError(`Failed to find '${treeNode.fullUrlBreadcrumbs.join(' > ')}' in includeInSearchResults.`);
|
|
63
63
|
}
|
|
64
64
|
return shouldInclude;
|
|
65
65
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BookEntry } from '../book-entry/book-entry';
|
|
2
|
-
import { BookTree } from './book-tree-node';
|
|
1
|
+
import { BookEntry } from '../book-entry/book-entry.js';
|
|
2
|
+
import { BookTree } from './book-tree-node.js';
|
|
3
3
|
export declare function getTreeFromCache(entries: ReadonlyArray<BookEntry>): BookTree | undefined;
|
|
4
4
|
export declare function addTreeToCache(entries: ReadonlyArray<BookEntry>, tree: BookTree): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
export * from './data/book-entry/book-entry';
|
|
2
|
-
export * from './data/book-entry/book-entry-type';
|
|
3
|
-
export * from './data/book-entry/book-
|
|
4
|
-
export * from './data/book-entry/book-page/book-page-controls';
|
|
5
|
-
export * from './data/book-entry/book-page/
|
|
6
|
-
export * from './data/book-entry/
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
1
|
+
export * from './data/book-entry/base-book-entry.js';
|
|
2
|
+
export * from './data/book-entry/book-entry-type.js';
|
|
3
|
+
export * from './data/book-entry/book-entry.js';
|
|
4
|
+
export * from './data/book-entry/book-page/book-page-controls.js';
|
|
5
|
+
export * from './data/book-entry/book-page/book-page.js';
|
|
6
|
+
export * from './data/book-entry/book-page/controls-wrapper.js';
|
|
7
|
+
export * from './data/book-entry/book-page/define-book-page.js';
|
|
8
|
+
export * from './data/book-entry/book-root.js';
|
|
9
|
+
export * from './data/book-entry/url-breadcrumbs.js';
|
|
10
|
+
export * from './data/book-tree/book-tree-node.js';
|
|
11
|
+
export * from './routing/book-routing.js';
|
|
12
|
+
export * from './ui/color-theme/color-theme.js';
|
|
13
|
+
export * from './ui/color-theme/create-color-theme.js';
|
|
14
|
+
export * from './ui/elements/element-book-app/element-book-app-slots.js';
|
|
15
|
+
export * from './ui/elements/element-book-app/element-book-app.element.js';
|
|
16
|
+
export * from './ui/elements/element-book-app/element-book-config.js';
|
|
17
|
+
export * from './ui/elements/element-book-app/global-values.js';
|
|
18
|
+
export * from './util/type.js';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
export * from './data/book-entry/book-entry';
|
|
2
|
-
export * from './data/book-entry/book-entry-type';
|
|
3
|
-
export * from './data/book-entry/book-
|
|
4
|
-
export * from './data/book-entry/book-page/book-page-controls';
|
|
5
|
-
export * from './data/book-entry/book-page/
|
|
6
|
-
export * from './data/book-entry/
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
1
|
+
export * from './data/book-entry/base-book-entry.js';
|
|
2
|
+
export * from './data/book-entry/book-entry-type.js';
|
|
3
|
+
export * from './data/book-entry/book-entry.js';
|
|
4
|
+
export * from './data/book-entry/book-page/book-page-controls.js';
|
|
5
|
+
export * from './data/book-entry/book-page/book-page.js';
|
|
6
|
+
export * from './data/book-entry/book-page/controls-wrapper.js';
|
|
7
|
+
export * from './data/book-entry/book-page/define-book-page.js';
|
|
8
|
+
export * from './data/book-entry/book-root.js';
|
|
9
|
+
export * from './data/book-entry/url-breadcrumbs.js';
|
|
10
|
+
export * from './data/book-tree/book-tree-node.js';
|
|
11
|
+
export * from './routing/book-routing.js';
|
|
12
|
+
export * from './ui/color-theme/color-theme.js';
|
|
13
|
+
export * from './ui/color-theme/create-color-theme.js';
|
|
14
|
+
export * from './ui/elements/element-book-app/element-book-app-slots.js';
|
|
15
|
+
export * from './ui/elements/element-book-app/element-book-app.element.js';
|
|
16
|
+
export * from './ui/elements/element-book-app/element-book-config.js';
|
|
17
|
+
export * from './ui/elements/element-book-app/global-values.js';
|
|
18
|
+
export * from './util/type.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SpaRouter } from 'spa-router-vir';
|
|
2
|
-
import { ValidBookPaths } from './book-routing';
|
|
2
|
+
import { ValidBookPaths } from './book-routing.js';
|
|
3
3
|
export declare function createBookRouter(basePath: string | undefined): SpaRouter<ValidBookPaths, undefined, undefined>;
|
|
4
4
|
export type BookRouter = ReturnType<typeof createBookRouter>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { SpaRouter } from 'spa-router-vir';
|
|
3
|
-
import { BookMainRoute, defaultBookFullRoute } from './book-routing';
|
|
3
|
+
import { BookMainRoute, defaultBookFullRoute } from './book-routing.js';
|
|
4
4
|
export function createBookRouter(basePath) {
|
|
5
5
|
return new SpaRouter({
|
|
6
6
|
basePath: basePath,
|
|
@@ -16,7 +16,7 @@ export function createBookRouter(basePath) {
|
|
|
16
16
|
}
|
|
17
17
|
function sanitizePaths(paths) {
|
|
18
18
|
const firstPath = paths[0];
|
|
19
|
-
if (!isEnumValue(firstPath, BookMainRoute)) {
|
|
19
|
+
if (!check.isEnumValue(firstPath, BookMainRoute)) {
|
|
20
20
|
return defaultBookFullRoute.paths;
|
|
21
21
|
}
|
|
22
22
|
else if (firstPath === BookMainRoute.Book) {
|
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import { FullRoute } from 'spa-router-vir';
|
|
2
|
+
/**
|
|
3
|
+
* Top level routes supported by the element-book app.
|
|
4
|
+
*
|
|
5
|
+
* @category Internal
|
|
6
|
+
*/
|
|
2
7
|
export declare enum BookMainRoute {
|
|
3
8
|
Search = "search",
|
|
4
9
|
Book = "book"
|
|
5
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Valid route paths for the element-book app.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
6
16
|
export type ValidBookPaths = [BookMainRoute.Search, string] | [BookMainRoute.Book, ...string[]];
|
|
17
|
+
/**
|
|
18
|
+
* A full element-book app route. Only paths are supported.
|
|
19
|
+
*
|
|
20
|
+
* @category Internal
|
|
21
|
+
*/
|
|
7
22
|
export type BookFullRoute = Required<Readonly<FullRoute<ValidBookPaths, undefined, undefined>>>;
|
|
23
|
+
/**
|
|
24
|
+
* Extract the current search query from the current route paths.
|
|
25
|
+
*
|
|
26
|
+
* @category Internal
|
|
27
|
+
*/
|
|
8
28
|
export declare function extractSearchQuery(paths: Readonly<ValidBookPaths>): string;
|
|
29
|
+
/**
|
|
30
|
+
* The default element-book app route.
|
|
31
|
+
*
|
|
32
|
+
* @category Internal
|
|
33
|
+
*/
|
|
9
34
|
export declare const defaultBookFullRoute: Readonly<BookFullRoute>;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top level routes supported by the element-book app.
|
|
3
|
+
*
|
|
4
|
+
* @category Internal
|
|
5
|
+
*/
|
|
1
6
|
export var BookMainRoute;
|
|
2
7
|
(function (BookMainRoute) {
|
|
3
8
|
BookMainRoute["Search"] = "search";
|
|
4
9
|
BookMainRoute["Book"] = "book";
|
|
5
10
|
})(BookMainRoute || (BookMainRoute = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Extract the current search query from the current route paths.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
6
16
|
export function extractSearchQuery(paths) {
|
|
7
17
|
if (paths[0] === BookMainRoute.Book) {
|
|
8
18
|
return '';
|
|
@@ -11,6 +21,11 @@ export function extractSearchQuery(paths) {
|
|
|
11
21
|
return paths[1] ? decodeURIComponent(paths[1]) : '';
|
|
12
22
|
}
|
|
13
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The default element-book app route.
|
|
26
|
+
*
|
|
27
|
+
* @category Internal
|
|
28
|
+
*/
|
|
14
29
|
export const defaultBookFullRoute = {
|
|
15
30
|
hash: undefined,
|
|
16
31
|
paths: [BookMainRoute.Book],
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { CSSResult } from 'element-vir';
|
|
2
|
+
/**
|
|
3
|
+
* A single background and foreground color pairing.
|
|
4
|
+
*
|
|
5
|
+
* @category Internal
|
|
6
|
+
*/
|
|
2
7
|
export type ColorPair = {
|
|
3
8
|
background: CSSResult;
|
|
4
9
|
foreground: CSSResult;
|
|
5
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Color pairs for everything used by the element-book app.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
6
16
|
export type ColorTheme = {
|
|
7
17
|
nav: {
|
|
8
18
|
hover: ColorPair;
|
|
@@ -19,19 +29,29 @@ export type ColorTheme = {
|
|
|
19
29
|
foregroundFaint2: CSSResult;
|
|
20
30
|
};
|
|
21
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* All color theme CSS vars for the element-book app.
|
|
34
|
+
*
|
|
35
|
+
* @category Internal
|
|
36
|
+
*/
|
|
22
37
|
export declare const colorThemeCssVars: import("lit-css-vars").CssVarDefinitions<{
|
|
23
|
-
'element-book-nav-hover-background-color':
|
|
24
|
-
'element-book-nav-hover-foreground-color':
|
|
25
|
-
'element-book-nav-active-background-color':
|
|
26
|
-
'element-book-nav-active-foreground-color':
|
|
27
|
-
'element-book-nav-selected-background-color':
|
|
28
|
-
'element-book-nav-selected-foreground-color':
|
|
29
|
-
'element-book-accent-icon-color':
|
|
30
|
-
'element-book-page-background-color':
|
|
31
|
-
'element-book-page-background-faint-level-1-color':
|
|
32
|
-
'element-book-page-background-faint-level-2-color':
|
|
33
|
-
'element-book-page-foreground-color':
|
|
34
|
-
'element-book-page-foreground-faint-level-1-color':
|
|
35
|
-
'element-book-page-foreground-faint-level-2-color':
|
|
38
|
+
readonly 'element-book-nav-hover-background-color': "magenta";
|
|
39
|
+
readonly 'element-book-nav-hover-foreground-color': "magenta";
|
|
40
|
+
readonly 'element-book-nav-active-background-color': "magenta";
|
|
41
|
+
readonly 'element-book-nav-active-foreground-color': "magenta";
|
|
42
|
+
readonly 'element-book-nav-selected-background-color': "magenta";
|
|
43
|
+
readonly 'element-book-nav-selected-foreground-color': "magenta";
|
|
44
|
+
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";
|
|
36
51
|
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
54
|
+
*
|
|
55
|
+
* @category Internal
|
|
56
|
+
*/
|
|
37
57
|
export declare function setThemeCssVars(element: HTMLElement, theme: ColorTheme): void;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { defineCssVars, setCssVarValue } from 'lit-css-vars';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* All color theme CSS vars for the element-book app.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
4
8
|
export const colorThemeCssVars = defineCssVars({
|
|
5
9
|
'element-book-nav-hover-background-color': 'magenta',
|
|
6
10
|
'element-book-nav-hover-foreground-color': 'magenta',
|
|
@@ -43,19 +47,24 @@ const colorThemeCssVarMapping = {
|
|
|
43
47
|
foregroundFaint2: colorThemeCssVars['element-book-page-foreground-faint-level-2-color'],
|
|
44
48
|
},
|
|
45
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
52
|
+
*
|
|
53
|
+
* @category Internal
|
|
54
|
+
*/
|
|
46
55
|
export function setThemeCssVars(element, theme) {
|
|
47
56
|
recursiveSetThemeCssVars(element, theme, colorThemeCssVarMapping);
|
|
48
57
|
}
|
|
49
58
|
function isCssResult(input) {
|
|
50
|
-
return
|
|
59
|
+
return check.hasKey(input, '_$cssResult$');
|
|
51
60
|
}
|
|
52
61
|
function isCssVarDefinition(input) {
|
|
53
|
-
return (
|
|
62
|
+
return (check.hasKeys(input, [
|
|
54
63
|
'name',
|
|
55
64
|
'value',
|
|
56
65
|
'default',
|
|
57
66
|
]) &&
|
|
58
|
-
|
|
67
|
+
check.isString(input.default) &&
|
|
59
68
|
isCssResult(input.name) &&
|
|
60
69
|
isCssResult(input.value));
|
|
61
70
|
}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ColorTheme } from './color-theme';
|
|
1
|
+
import { PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { ColorTheme } from './color-theme.js';
|
|
3
|
+
/**
|
|
4
|
+
* The default theme color.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
3
8
|
export declare const defaultThemeStartColor = "dodgerblue";
|
|
9
|
+
/**
|
|
10
|
+
* Theme style options for the element-book app.
|
|
11
|
+
*
|
|
12
|
+
* @category Internal
|
|
13
|
+
*/
|
|
4
14
|
export declare enum ThemeStyle {
|
|
5
15
|
Dark = "dark",
|
|
6
16
|
Light = "light"
|
|
7
17
|
}
|
|
8
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Theme configuration options for the element-book app.
|
|
20
|
+
*
|
|
21
|
+
* @category Internal
|
|
22
|
+
*/
|
|
23
|
+
export type ThemeConfig = PartialWithUndefined<{
|
|
9
24
|
themeColor: string;
|
|
10
25
|
themeStyle: ThemeStyle;
|
|
11
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a theme from the given theme configuration.
|
|
29
|
+
*
|
|
30
|
+
* @category Internal
|
|
31
|
+
*/
|
|
12
32
|
export declare function createTheme({ themeColor: inputThemeColor, themeStyle, }?: ThemeConfig): ColorTheme;
|
|
@@ -11,6 +11,11 @@ function colorsObjectToCssResult(colors) {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The default theme color.
|
|
16
|
+
*
|
|
17
|
+
* @category Internal
|
|
18
|
+
*/
|
|
14
19
|
export const defaultThemeStartColor = 'dodgerblue';
|
|
15
20
|
function calculateTextColorString(color) {
|
|
16
21
|
const onWhite = Math.abs(color.contrast('white', 'APCA'));
|
|
@@ -24,6 +29,11 @@ function createColorPair({ background, foreground, }) {
|
|
|
24
29
|
foreground: foreground ?? new Color(calculateTextColorString(background)),
|
|
25
30
|
};
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Theme style options for the element-book app.
|
|
34
|
+
*
|
|
35
|
+
* @category Internal
|
|
36
|
+
*/
|
|
27
37
|
export var ThemeStyle;
|
|
28
38
|
(function (ThemeStyle) {
|
|
29
39
|
ThemeStyle["Dark"] = "dark";
|
|
@@ -52,6 +62,11 @@ const faintBackgroundColors = {
|
|
|
52
62
|
backgroundFaint2: new Color('#fafafa'),
|
|
53
63
|
},
|
|
54
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Creates a theme from the given theme configuration.
|
|
67
|
+
*
|
|
68
|
+
* @category Internal
|
|
69
|
+
*/
|
|
55
70
|
export function createTheme({ themeColor: inputThemeColor = defaultThemeStartColor, themeStyle = ThemeStyle.Light, } = {}) {
|
|
56
71
|
const themeColor = new Color(inputThemeColor);
|
|
57
72
|
const backgroundColor = new Color(themeStyle === ThemeStyle.Dark ? 'black' : 'white');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BookRouter } from '../../routing/book-router';
|
|
2
|
-
import { BookFullRoute } from '../../routing/book-routing';
|
|
1
|
+
import { BookRouter } from '../../routing/book-router.js';
|
|
2
|
+
import { BookFullRoute } from '../../routing/book-routing.js';
|
|
3
3
|
export declare const BookBreadcrumbs: import("element-vir").DeclarativeElementDefinition<"book-breadcrumbs", {
|
|
4
4
|
currentRoute: Readonly<BookFullRoute>;
|
|
5
5
|
router: Readonly<BookRouter> | undefined;
|
|
6
|
-
}, {}, {},
|
|
6
|
+
}, {}, {}, "book-breadcrumbs-", "book-breadcrumbs-", readonly []>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
-
import { BookMainRoute } from '../../routing/book-routing';
|
|
3
|
-
import { BookRouteLink } from './common/book-route-link.element';
|
|
4
|
-
import { defineBookElement } from './define-book-element';
|
|
2
|
+
import { BookMainRoute } from '../../routing/book-routing.js';
|
|
3
|
+
import { BookRouteLink } from './common/book-route-link.element.js';
|
|
4
|
+
import { defineBookElement } from './define-book-element.js';
|
|
5
5
|
export const BookBreadcrumbs = defineBookElement()({
|
|
6
6
|
tagName: 'book-breadcrumbs',
|
|
7
7
|
styles: css `
|
|
@@ -14,7 +14,7 @@ export const BookBreadcrumbs = defineBookElement()({
|
|
|
14
14
|
padding: 0 4px;
|
|
15
15
|
}
|
|
16
16
|
`,
|
|
17
|
-
|
|
17
|
+
render: ({ inputs }) => {
|
|
18
18
|
const bookPaths = inputs.currentRoute.paths.slice(1);
|
|
19
19
|
if (!bookPaths.length) {
|
|
20
20
|
return html `
|