element-book 10.0.0 → 10.0.2
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.d.ts +12 -0
- package/dist/data/book-entry/book-page/controls-wrapper.js +50 -0
- package/dist/ui/elements/book-breadcrumbs.element.d.ts +1 -1
- package/dist/ui/elements/element-book-app/element-book-app.element.d.ts +4 -4
- package/dist/ui/elements/element-book-app/element-book-app.element.js +24 -16
- package/dist/ui/elements/element-book-app/element-book-config.d.ts +1 -1
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/book-entry-display.element.d.ts +3 -3
- package/dist/ui/elements/entry-display/book-entry-display.element.js +7 -7
- package/dist/ui/elements/entry-display/book-page/book-page-wrapper.element.d.ts +3 -3
- 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-controls.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.d.ts +1 -1
- package/package.json +7 -7
- package/dist/data/book-entry/book-page/current-controls.d.ts +0 -13
- package/dist/data/book-entry/book-page/current-controls.js +0 -65
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PartialAndUndefined } from '@augment-vir/common';
|
|
2
|
+
import { BookTreeNode } from '../../book-tree/book-tree-node';
|
|
3
|
+
import { BookPageControlsValues } from './book-page-controls';
|
|
4
|
+
export type ControlsWrapper = {
|
|
5
|
+
children: {
|
|
6
|
+
[Breadcrumb: string]: ControlsWrapper;
|
|
7
|
+
};
|
|
8
|
+
controls: BookPageControlsValues;
|
|
9
|
+
};
|
|
10
|
+
export declare function traverseControls(controlsWrapper: ControlsWrapper, fullUrlBreadcrumbs: ReadonlyArray<string>): BookPageControlsValues;
|
|
11
|
+
export declare function createNewControls(controlsWrapper: ControlsWrapper, breadcrumbsForNewValue: ReadonlyArray<string>, newValues: BookPageControlsValues): ControlsWrapper;
|
|
12
|
+
export declare function updateTreeControls(node: BookTreeNode, existingControls: PartialAndUndefined<ControlsWrapper> | undefined): ControlsWrapper;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { copyThroughJson, mapObjectValues } from '@augment-vir/common';
|
|
2
|
+
import { isBookTreeNode } from '../../book-tree/book-tree';
|
|
3
|
+
import { BookEntryTypeEnum } from '../book-entry-type';
|
|
4
|
+
export function traverseControls(controlsWrapper, fullUrlBreadcrumbs) {
|
|
5
|
+
return traverseAndInsertNewControls(controlsWrapper, [
|
|
6
|
+
/** Empty string represents the breadcrumb for the root node */
|
|
7
|
+
'',
|
|
8
|
+
...fullUrlBreadcrumbs,
|
|
9
|
+
], undefined);
|
|
10
|
+
}
|
|
11
|
+
function traverseAndInsertNewControls(controlsWrapper, urlBreadcrumbs, newValues) {
|
|
12
|
+
const nextBreadcrumbs = urlBreadcrumbs.slice(1);
|
|
13
|
+
const nextBreadcrumb = nextBreadcrumbs[0];
|
|
14
|
+
/** If we're at the end of the breadcrumbs, then it's time to insert the new controls. */
|
|
15
|
+
if (!nextBreadcrumb && newValues) {
|
|
16
|
+
controlsWrapper.controls = newValues;
|
|
17
|
+
}
|
|
18
|
+
const childControlsWrapper = controlsWrapper.children[nextBreadcrumb || ''];
|
|
19
|
+
const childrenControls = childControlsWrapper &&
|
|
20
|
+
traverseAndInsertNewControls(childControlsWrapper, nextBreadcrumbs, newValues);
|
|
21
|
+
const allControls = {
|
|
22
|
+
...controlsWrapper.controls,
|
|
23
|
+
...childrenControls,
|
|
24
|
+
};
|
|
25
|
+
return allControls;
|
|
26
|
+
}
|
|
27
|
+
export function createNewControls(controlsWrapper, breadcrumbsForNewValue, newValues) {
|
|
28
|
+
const newControls = copyThroughJson(controlsWrapper);
|
|
29
|
+
traverseAndInsertNewControls(newControls, [
|
|
30
|
+
/** Empty string represents the breadcrumb for the root node */
|
|
31
|
+
'',
|
|
32
|
+
...breadcrumbsForNewValue,
|
|
33
|
+
], newValues);
|
|
34
|
+
return newControls;
|
|
35
|
+
}
|
|
36
|
+
export function updateTreeControls(node, existingControls) {
|
|
37
|
+
const controls = existingControls?.controls ||
|
|
38
|
+
(isBookTreeNode(node, BookEntryTypeEnum.Page)
|
|
39
|
+
? mapObjectValues(node.entry.controls, (name, setup) => {
|
|
40
|
+
return setup.initValue;
|
|
41
|
+
})
|
|
42
|
+
: {});
|
|
43
|
+
const controlsWrapper = {
|
|
44
|
+
children: mapObjectValues(node.children, (childName, childTreeNode) => {
|
|
45
|
+
return updateTreeControls(childTreeNode, existingControls?.children?.[childTreeNode.urlBreadcrumb]);
|
|
46
|
+
}),
|
|
47
|
+
controls,
|
|
48
|
+
};
|
|
49
|
+
return controlsWrapper;
|
|
50
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BookFullRoute, BookRouter } from '../../routing/book-routing';
|
|
2
2
|
export declare const BookBreadcrumbs: import("element-vir").DeclarativeElementDefinition<"book-breadcrumbs", {
|
|
3
3
|
currentRoute: Readonly<BookFullRoute>;
|
|
4
|
-
router: BookRouter;
|
|
4
|
+
router: BookRouter | undefined;
|
|
5
5
|
}, {}, {}, `book-breadcrumbs-${string}`, `book-breadcrumbs-${string}`, import("lit-html").HTMLTemplateResult | import("lit-html").HTMLTemplateResult[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ControlsWrapper } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
2
2
|
import { ColorTheme } from '../../color-theme/color-theme';
|
|
3
3
|
import { ThemeConfig } from '../../color-theme/create-color-theme';
|
|
4
4
|
import { ElementBookConfig, GlobalValues } from './element-book-config';
|
|
@@ -11,10 +11,10 @@ export declare const ElementBookApp: import("element-vir").DeclarativeElementDef
|
|
|
11
11
|
router: Readonly<import("spa-router-vir").SpaRouter<import("../../../routing/book-routing").ValidBookPaths, Record<string, string> | undefined, undefined>> | undefined;
|
|
12
12
|
loading: boolean;
|
|
13
13
|
colors: ColorThemeState;
|
|
14
|
-
|
|
14
|
+
treeBasedControls: {
|
|
15
15
|
entries: ElementBookConfig['entries'];
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
lastGlobalInputs: GlobalValues;
|
|
17
|
+
controls: ControlsWrapper;
|
|
18
18
|
} | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
pathUpdate: import("element-vir").DefinedTypedEventNameDefinition<readonly string[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { waitForAnimationFrame } from '@augment-vir/browser';
|
|
2
2
|
import { areJsonEqual, extractErrorMessage } from '@augment-vir/common';
|
|
3
3
|
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
4
|
-
import {
|
|
4
|
+
import { createNewControls, updateTreeControls, } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
5
5
|
import { createBookTreeFromEntries } from '../../../data/book-tree/book-tree';
|
|
6
6
|
import { searchFlattenedNodes } from '../../../data/book-tree/search-nodes';
|
|
7
7
|
import { defaultBookFullRoute, extractSearchQuery, } from '../../../routing/book-routing';
|
|
@@ -28,7 +28,7 @@ export const ElementBookApp = defineElement()({
|
|
|
28
28
|
config: undefined,
|
|
29
29
|
theme: createTheme(undefined),
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
treeBasedControls: undefined,
|
|
32
32
|
},
|
|
33
33
|
styles: css `
|
|
34
34
|
:host {
|
|
@@ -84,6 +84,9 @@ export const ElementBookApp = defineElement()({
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
renderCallback: ({ state, inputs, host, updateState, dispatch, events }) => {
|
|
87
|
+
if (inputs._debug) {
|
|
88
|
+
console.info('rendering element-book app');
|
|
89
|
+
}
|
|
87
90
|
try {
|
|
88
91
|
function updateRoutes(newRoute) {
|
|
89
92
|
if (state.router) {
|
|
@@ -136,14 +139,20 @@ export const ElementBookApp = defineElement()({
|
|
|
136
139
|
entries: inputs.entries,
|
|
137
140
|
debug,
|
|
138
141
|
});
|
|
139
|
-
if (!state.
|
|
140
|
-
state.
|
|
141
|
-
state.
|
|
142
|
+
if (!state.treeBasedControls ||
|
|
143
|
+
state.treeBasedControls.entries !== inputs.entries ||
|
|
144
|
+
state.treeBasedControls.lastGlobalInputs !== inputs.globalValues) {
|
|
145
|
+
if (inputs._debug) {
|
|
146
|
+
console.info('regenerating global controls');
|
|
147
|
+
}
|
|
142
148
|
updateState({
|
|
143
|
-
|
|
149
|
+
treeBasedControls: {
|
|
144
150
|
entries: inputs.entries,
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
lastGlobalInputs: inputs.globalValues ?? {},
|
|
152
|
+
controls: updateTreeControls(originalTree.tree, {
|
|
153
|
+
children: state.treeBasedControls?.controls?.children,
|
|
154
|
+
controls: inputs.globalValues,
|
|
155
|
+
}),
|
|
147
156
|
},
|
|
148
157
|
});
|
|
149
158
|
}
|
|
@@ -156,7 +165,7 @@ export const ElementBookApp = defineElement()({
|
|
|
156
165
|
: undefined;
|
|
157
166
|
const currentNodes = searchedNodes ??
|
|
158
167
|
getCurrentNodes(originalTree.flattenedNodes, state.currentRoute.paths, updateRoutes);
|
|
159
|
-
const currentControls = state.
|
|
168
|
+
const currentControls = state.treeBasedControls?.controls;
|
|
160
169
|
if (!currentControls) {
|
|
161
170
|
return html `
|
|
162
171
|
<${BookError.assign({
|
|
@@ -175,7 +184,6 @@ export const ElementBookApp = defineElement()({
|
|
|
175
184
|
updateState({ loading: true });
|
|
176
185
|
/** Wait for the loading div to show up. */
|
|
177
186
|
while (!host.shadowRoot.querySelector('.loading')) {
|
|
178
|
-
console.log('waiting');
|
|
179
187
|
await waitForAnimationFrame();
|
|
180
188
|
}
|
|
181
189
|
await waitForAnimationFrame();
|
|
@@ -194,14 +202,14 @@ export const ElementBookApp = defineElement()({
|
|
|
194
202
|
scrollNav(host, searchQuery, state.currentRoute);
|
|
195
203
|
})}
|
|
196
204
|
${listen(BookPageControls.events.controlValueChange, (event) => {
|
|
197
|
-
if (!state.
|
|
205
|
+
if (!state.treeBasedControls) {
|
|
198
206
|
return;
|
|
199
207
|
}
|
|
200
|
-
const newControls =
|
|
208
|
+
const newControls = createNewControls(currentControls, event.detail.fullUrlBreadcrumbs, event.detail.newValues);
|
|
201
209
|
updateState({
|
|
202
|
-
|
|
203
|
-
...state.
|
|
204
|
-
|
|
210
|
+
treeBasedControls: {
|
|
211
|
+
...state.treeBasedControls,
|
|
212
|
+
controls: newControls,
|
|
205
213
|
},
|
|
206
214
|
});
|
|
207
215
|
})}
|
|
@@ -226,7 +234,7 @@ export const ElementBookApp = defineElement()({
|
|
|
226
234
|
currentNodes,
|
|
227
235
|
router: state.router,
|
|
228
236
|
debug,
|
|
229
|
-
currentControls,
|
|
237
|
+
controls: currentControls,
|
|
230
238
|
originalTree: originalTree.tree,
|
|
231
239
|
})}>
|
|
232
240
|
<slot
|
|
@@ -5,7 +5,7 @@ export type ElementBookConfig = {
|
|
|
5
5
|
/** All element-book entries in order. */
|
|
6
6
|
entries: ReadonlyArray<BookEntry>;
|
|
7
7
|
} & PartialAndUndefined<OptionalConfig>;
|
|
8
|
-
export type GlobalValues = Readonly<Record<string, unknown
|
|
8
|
+
export type GlobalValues = Readonly<Record<string, unknown>> | undefined;
|
|
9
9
|
type OptionalConfig = {
|
|
10
10
|
/** The base theme color from which all other element-book colors will be generated from. */
|
|
11
11
|
themeColor: string;
|
|
@@ -2,5 +2,5 @@ import { BookFullRoute, BookRouter } from '../../../routing/book-routing';
|
|
|
2
2
|
export declare const BookBreadcrumbsBar: import("element-vir").DeclarativeElementDefinition<"book-breadcrumbs-bar", {
|
|
3
3
|
currentSearch: string;
|
|
4
4
|
currentRoute: BookFullRoute;
|
|
5
|
-
router: BookRouter;
|
|
5
|
+
router: BookRouter | undefined;
|
|
6
6
|
}, {}, {}, `book-breadcrumbs-bar-${string}`, `book-breadcrumbs-bar-${string}`, import("lit-html").HTMLTemplateResult>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BookEntryTypeEnum } from '../../../data/book-entry/book-entry-type';
|
|
2
|
-
import {
|
|
2
|
+
import { ControlsWrapper } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
3
3
|
import { BookTreeNode } from '../../../data/book-tree/book-tree-node';
|
|
4
4
|
import { BookFullRoute, BookRouter } from '../../../routing/book-routing';
|
|
5
5
|
export declare const BookEntryDisplay: import("element-vir").DeclarativeElementDefinition<"book-entry-display", {
|
|
6
6
|
currentRoute: Readonly<BookFullRoute>;
|
|
7
7
|
currentNodes: ReadonlyArray<BookTreeNode>;
|
|
8
8
|
originalTree: Readonly<BookTreeNode<BookEntryTypeEnum.Root>>;
|
|
9
|
-
router: BookRouter;
|
|
9
|
+
router: BookRouter | undefined;
|
|
10
10
|
debug: boolean;
|
|
11
|
-
|
|
11
|
+
controls: ControlsWrapper;
|
|
12
12
|
}, {}, {}, `book-entry-display-${string}`, `book-entry-display-${string}`, import("lit-html").HTMLTemplateResult>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assign, css, html, repeat } from 'element-vir';
|
|
2
2
|
import { BookEntryTypeEnum } from '../../../data/book-entry/book-entry-type';
|
|
3
3
|
import { isLengthAtLeast, mapObjectValues } from '@augment-vir/common';
|
|
4
|
-
import {
|
|
4
|
+
import { traverseControls, } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
5
5
|
import { isBookTreeNode, traverseToImmediateParent } from '../../../data/book-tree/book-tree';
|
|
6
6
|
import { extractSearchQuery } from '../../../routing/book-routing';
|
|
7
7
|
import { BookError } from '../common/book-error.element';
|
|
@@ -48,7 +48,7 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
48
48
|
isTopLevel: true,
|
|
49
49
|
router: inputs.router,
|
|
50
50
|
isSearching: !!currentSearch,
|
|
51
|
-
|
|
51
|
+
controls: inputs.controls,
|
|
52
52
|
originalTree: inputs.originalTree,
|
|
53
53
|
});
|
|
54
54
|
return html `
|
|
@@ -73,7 +73,7 @@ function getFlattenedControlsFromHiddenParents(currentNodes, currentControls, cu
|
|
|
73
73
|
}
|
|
74
74
|
if (isBookTreeNode(currentNode, BookEntryTypeEnum.Page) &&
|
|
75
75
|
!currentNodes.includes(currentNode)) {
|
|
76
|
-
const currentEntryControls =
|
|
76
|
+
const currentEntryControls = traverseControls(currentControls, currentNode.fullUrlBreadcrumbs);
|
|
77
77
|
allControls.push({
|
|
78
78
|
config: currentNode.entry.controls,
|
|
79
79
|
current: currentEntryControls,
|
|
@@ -99,7 +99,7 @@ function getFlattenedControlsFromHiddenParents(currentNodes, currentControls, cu
|
|
|
99
99
|
};
|
|
100
100
|
}, { config: {}, current: {}, breadcrumbs: {} });
|
|
101
101
|
}
|
|
102
|
-
function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching,
|
|
102
|
+
function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, controls, originalTree, }) {
|
|
103
103
|
if (!currentNodes.length && isSearching) {
|
|
104
104
|
return [
|
|
105
105
|
html `
|
|
@@ -108,7 +108,7 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, cu
|
|
|
108
108
|
];
|
|
109
109
|
}
|
|
110
110
|
const hiddenAncestorControls = isLengthAtLeast(currentNodes, 1)
|
|
111
|
-
? getFlattenedControlsFromHiddenParents(currentNodes,
|
|
111
|
+
? getFlattenedControlsFromHiddenParents(currentNodes, controls, currentNodes[0], originalTree)
|
|
112
112
|
: undefined;
|
|
113
113
|
const hiddenAncestorControlsTemplate = hiddenAncestorControls &&
|
|
114
114
|
Object.values(hiddenAncestorControls.config).length &&
|
|
@@ -127,7 +127,7 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, cu
|
|
|
127
127
|
<${BookPageWrapper.assign({
|
|
128
128
|
isTopLevel,
|
|
129
129
|
pageNode: currentNode,
|
|
130
|
-
|
|
130
|
+
controls: controls,
|
|
131
131
|
router,
|
|
132
132
|
})}
|
|
133
133
|
class="block-entry"
|
|
@@ -135,7 +135,7 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, cu
|
|
|
135
135
|
`;
|
|
136
136
|
}
|
|
137
137
|
else if (isBookTreeNode(currentNode, BookEntryTypeEnum.ElementExample)) {
|
|
138
|
-
const controlsForElementExample =
|
|
138
|
+
const controlsForElementExample = traverseControls(controls, currentNode.fullUrlBreadcrumbs.slice(0, -1));
|
|
139
139
|
return html `
|
|
140
140
|
<${BookElementExampleWrapper.assign({
|
|
141
141
|
elementExampleNode: currentNode,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BookEntryTypeEnum } from '../../../../data/book-entry/book-entry-type';
|
|
2
|
-
import {
|
|
2
|
+
import { ControlsWrapper } from '../../../../data/book-entry/book-page/controls-wrapper';
|
|
3
3
|
import { BookTreeNode } from '../../../../data/book-tree/book-tree-node';
|
|
4
4
|
import { BookRouter } from '../../../../routing/book-routing';
|
|
5
5
|
export declare const BookPageWrapper: import("element-vir").DeclarativeElementDefinition<"book-page-wrapper", {
|
|
6
6
|
isTopLevel: boolean;
|
|
7
7
|
pageNode: BookTreeNode<BookEntryTypeEnum.Page>;
|
|
8
|
-
router: BookRouter;
|
|
9
|
-
|
|
8
|
+
router: BookRouter | undefined;
|
|
9
|
+
controls: ControlsWrapper;
|
|
10
10
|
}, {}, {}, `book-page-wrapper-${string}`, `book-page-wrapper-${string}`, import("lit-html").HTMLTemplateResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { combineErrors } from '@augment-vir/common';
|
|
2
2
|
import { css, html } from 'element-vir';
|
|
3
|
-
import {
|
|
3
|
+
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper';
|
|
4
4
|
import { BookMainRoute } from '../../../../routing/book-routing';
|
|
5
5
|
import { BookError } from '../../common/book-error.element';
|
|
6
6
|
import { BookRouteLink } from '../../common/book-route-link.element';
|
|
@@ -73,7 +73,7 @@ export const BookPageWrapper = defineBookElement()({
|
|
|
73
73
|
})}></${BookEntryDescription}>
|
|
74
74
|
<${BookPageControls.assign({
|
|
75
75
|
config: inputs.pageNode.entry.controls,
|
|
76
|
-
currentValues:
|
|
76
|
+
currentValues: traverseControls(inputs.controls, inputs.pageNode.fullUrlBreadcrumbs),
|
|
77
77
|
fullUrlBreadcrumbs: inputs.pageNode.fullUrlBreadcrumbs,
|
|
78
78
|
})}></${BookPageControls}>
|
|
79
79
|
`}
|
package/dist/ui/elements/entry-display/element-example/book-element-example-controls.element.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { BookTreeNode } from '../../../../data/book-tree/book-tree-node';
|
|
|
3
3
|
import { BookRouter } from '../../../../routing/book-routing';
|
|
4
4
|
export declare const BookElementExampleControls: import("element-vir").DeclarativeElementDefinition<"book-element-example-controls", {
|
|
5
5
|
elementExampleNode: BookTreeNode<BookEntryTypeEnum.ElementExample>;
|
|
6
|
-
router: BookRouter;
|
|
6
|
+
router: BookRouter | undefined;
|
|
7
7
|
}, {}, {}, `book-element-example-controls-${string}`, `book-element-example-controls-${string}`, import("lit-html").HTMLTemplateResult>;
|
package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import { BookRouter } from '../../../../routing/book-routing';
|
|
|
5
5
|
export declare const BookElementExampleViewer: import("element-vir").DeclarativeElementDefinition<"book-element-example-viewer", {
|
|
6
6
|
elementExampleNode: BookTreeNode<BookEntryTypeEnum.ElementExample>;
|
|
7
7
|
currentPageControls: BookPageControlsValues;
|
|
8
|
-
router: BookRouter;
|
|
8
|
+
router: BookRouter | undefined;
|
|
9
9
|
}, any, {}, `book-element-example-viewer-${string}`, `book-element-example-viewer-${string}`, import("lit-html").HTMLTemplateResult>;
|
package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import { BookRouter } from '../../../../routing/book-routing';
|
|
|
5
5
|
export declare const BookElementExampleWrapper: import("element-vir").DeclarativeElementDefinition<"book-element-example-wrapper", {
|
|
6
6
|
elementExampleNode: BookTreeNode<BookEntryTypeEnum.ElementExample>;
|
|
7
7
|
currentPageControls: BookPageControlsValues;
|
|
8
|
-
router: BookRouter;
|
|
8
|
+
router: BookRouter | undefined;
|
|
9
9
|
}, {}, {}, `book-element-example-wrapper-${string}`, `book-element-example-wrapper-${string}`, import("lit-html").HTMLTemplateResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-book",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"book",
|
|
6
6
|
"design system",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"test:watch": "web-test-runner --color --watch --config configs/web-test-runner.config.mjs"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/browser": "^
|
|
43
|
-
"@augment-vir/common": "^
|
|
42
|
+
"@augment-vir/browser": "^16.0.1",
|
|
43
|
+
"@augment-vir/common": "^16.0.1",
|
|
44
44
|
"colorjs.io": "0.4.5",
|
|
45
|
-
"element-vir": "^16.0.
|
|
46
|
-
"lit-css-vars": "^
|
|
45
|
+
"element-vir": "^16.0.3",
|
|
46
|
+
"lit-css-vars": "^3.0.0",
|
|
47
47
|
"object-shape-tester": "^0.4.0",
|
|
48
48
|
"spa-router-vir": "^2.1.1",
|
|
49
49
|
"typed-event-target": "^1.3.1",
|
|
50
|
-
"vira": "^0.
|
|
50
|
+
"vira": "^0.7.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@augment-vir/browser-testing": "^
|
|
53
|
+
"@augment-vir/browser-testing": "^16.0.1",
|
|
54
54
|
"@open-wc/testing": "^3.2.0",
|
|
55
55
|
"@types/chai": "^4.3.5",
|
|
56
56
|
"@types/mocha": "^10.0.1",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GlobalValues } from '../../../ui/elements/element-book-app/element-book-config';
|
|
2
|
-
import { BookTreeNode } from '../../book-tree/book-tree-node';
|
|
3
|
-
import { BookPageControlsValues } from './book-page-controls';
|
|
4
|
-
export type ControlsWrapper = {
|
|
5
|
-
children: CurrentControls;
|
|
6
|
-
controls: BookPageControlsValues;
|
|
7
|
-
};
|
|
8
|
-
export type CurrentControls = {
|
|
9
|
-
[Breadcrumb: string]: ControlsWrapper;
|
|
10
|
-
};
|
|
11
|
-
export declare function traverseCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>): BookPageControlsValues;
|
|
12
|
-
export declare function createNewCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>, newValues: BookPageControlsValues): CurrentControls;
|
|
13
|
-
export declare function createControlsFromTree(node: BookTreeNode, globalValues: GlobalValues): CurrentControls;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { copyThroughJson, mapObjectValues } from '@augment-vir/common';
|
|
2
|
-
import { isBookTreeNode } from '../../book-tree/book-tree';
|
|
3
|
-
import { BookEntryTypeEnum } from '../book-entry-type';
|
|
4
|
-
function getOrCreateControlsWrapper(currentControls, currentBreadcrumb, newValues) {
|
|
5
|
-
const controlsWrapper = currentControls[currentBreadcrumb];
|
|
6
|
-
if (controlsWrapper) {
|
|
7
|
-
return controlsWrapper;
|
|
8
|
-
}
|
|
9
|
-
if (newValues) {
|
|
10
|
-
const newControls = {
|
|
11
|
-
children: {},
|
|
12
|
-
controls: {},
|
|
13
|
-
};
|
|
14
|
-
currentControls[currentBreadcrumb] = newControls;
|
|
15
|
-
return newControls;
|
|
16
|
-
}
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
export function traverseCurrentControls(currentControls, fullUrlBreadcrumbs) {
|
|
20
|
-
return internalTraverseCurrentControls(currentControls, fullUrlBreadcrumbs, undefined);
|
|
21
|
-
}
|
|
22
|
-
function internalTraverseCurrentControls(currentControls, fullUrlBreadcrumbs, newValues) {
|
|
23
|
-
const currentBreadcrumb = fullUrlBreadcrumbs[0];
|
|
24
|
-
if (!currentBreadcrumb) {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
const controlsWrapper = getOrCreateControlsWrapper(currentControls, currentBreadcrumb, newValues);
|
|
28
|
-
if (!controlsWrapper) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
const nextBreadcrumbs = fullUrlBreadcrumbs.slice(1);
|
|
32
|
-
if (!nextBreadcrumbs.length && newValues) {
|
|
33
|
-
controlsWrapper.controls = newValues;
|
|
34
|
-
}
|
|
35
|
-
const controlsValues = controlsWrapper.controls;
|
|
36
|
-
return {
|
|
37
|
-
...controlsValues,
|
|
38
|
-
...internalTraverseCurrentControls(controlsWrapper.children, nextBreadcrumbs, newValues),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export function createNewCurrentControls(currentControls, fullUrlBreadcrumbs, newValues) {
|
|
42
|
-
const newCurrentControls = copyThroughJson(currentControls);
|
|
43
|
-
internalTraverseCurrentControls(newCurrentControls, fullUrlBreadcrumbs, newValues);
|
|
44
|
-
return newCurrentControls;
|
|
45
|
-
}
|
|
46
|
-
export function createControlsFromTree(node, globalValues) {
|
|
47
|
-
const currentControls = mapObjectValues(node.children, (childName, child) => {
|
|
48
|
-
if (!isBookTreeNode(child, BookEntryTypeEnum.Page)) {
|
|
49
|
-
return {
|
|
50
|
-
children: {},
|
|
51
|
-
controls: {},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
children: createControlsFromTree(child, {}),
|
|
56
|
-
controls: {
|
|
57
|
-
...globalValues,
|
|
58
|
-
...mapObjectValues(child.entry.controls, (name, setup) => {
|
|
59
|
-
return setup.initValue;
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
return currentControls;
|
|
65
|
-
}
|