element-book 10.0.2 → 10.1.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/ui/elements/element-book-app/element-book-app.element.d.ts +1 -0
- package/dist/ui/elements/element-book-app/element-book-app.element.js +81 -57
- package/dist/ui/elements/element-book-app/element-book-config.d.ts +1 -0
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.js +0 -2
- package/dist/ui/elements/entry-display/book-page/book-page-controls.element.js +14 -8
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.d.ts +17 -0
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.js +116 -0
- package/dist/ui/elements/entry-display/entry-display/create-node-templates.d.ts +12 -0
- package/dist/ui/elements/entry-display/{book-entry-display.element.js → entry-display/create-node-templates.js} +13 -69
- package/package.json +14 -14
- package/dist/ui/elements/entry-display/book-entry-display.element.d.ts +0 -12
|
@@ -16,6 +16,7 @@ export declare const ElementBookApp: import("element-vir").DeclarativeElementDef
|
|
|
16
16
|
lastGlobalInputs: GlobalValues;
|
|
17
17
|
controls: ControlsWrapper;
|
|
18
18
|
} | undefined;
|
|
19
|
+
originalWindowTitle: string | undefined;
|
|
19
20
|
}, {
|
|
20
21
|
pathUpdate: import("element-vir").DefinedTypedEventNameDefinition<readonly string[]>;
|
|
21
22
|
}, "element-book-app-", "element-book-app-", import("lit-html").HTMLTemplateResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { waitForAnimationFrame } from '@augment-vir/browser';
|
|
2
|
-
import { areJsonEqual, extractErrorMessage } from '@augment-vir/common';
|
|
2
|
+
import { areJsonEqual, extractErrorMessage, isTruthy } from '@augment-vir/common';
|
|
3
3
|
import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
|
|
4
4
|
import { createNewControls, updateTreeControls, } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
5
5
|
import { createBookTreeFromEntries } from '../../../data/book-tree/book-tree';
|
|
@@ -11,8 +11,8 @@ import { createTheme } from '../../color-theme/create-color-theme';
|
|
|
11
11
|
import { ChangeRouteEvent } from '../../events/change-route.event';
|
|
12
12
|
import { BookNav, scrollSelectedNavElementIntoView } from '../book-nav/book-nav.element';
|
|
13
13
|
import { BookError } from '../common/book-error.element';
|
|
14
|
-
import { BookEntryDisplay } from '../entry-display/book-entry-display.element';
|
|
15
14
|
import { BookPageControls } from '../entry-display/book-page/book-page-controls.element';
|
|
15
|
+
import { BookEntryDisplay } from '../entry-display/entry-display/book-entry-display.element';
|
|
16
16
|
import { ElementBookSlotName } from './element-book-app-slots';
|
|
17
17
|
import { getCurrentNodes } from './get-current-nodes';
|
|
18
18
|
export const ElementBookApp = defineElement()({
|
|
@@ -23,12 +23,13 @@ export const ElementBookApp = defineElement()({
|
|
|
23
23
|
stateInitStatic: {
|
|
24
24
|
currentRoute: defaultBookFullRoute,
|
|
25
25
|
router: undefined,
|
|
26
|
-
loading:
|
|
26
|
+
loading: true,
|
|
27
27
|
colors: {
|
|
28
28
|
config: undefined,
|
|
29
29
|
theme: createTheme(undefined),
|
|
30
30
|
},
|
|
31
31
|
treeBasedControls: undefined,
|
|
32
|
+
originalWindowTitle: undefined,
|
|
32
33
|
},
|
|
33
34
|
styles: css `
|
|
34
35
|
:host {
|
|
@@ -67,15 +68,11 @@ export const ElementBookApp = defineElement()({
|
|
|
67
68
|
top: 0;
|
|
68
69
|
max-width: min(400px, 40%);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
.loading {
|
|
72
|
-
padding: 64px;
|
|
73
|
-
}
|
|
74
71
|
`,
|
|
75
72
|
initCallback({ host, state }) {
|
|
76
73
|
setTimeout(() => {
|
|
77
74
|
scrollNav(host, extractSearchQuery(state.currentRoute.paths), state.currentRoute);
|
|
78
|
-
},
|
|
75
|
+
}, 500);
|
|
79
76
|
},
|
|
80
77
|
cleanupCallback({ state, updateState }) {
|
|
81
78
|
if (state.router) {
|
|
@@ -87,24 +84,51 @@ export const ElementBookApp = defineElement()({
|
|
|
87
84
|
if (inputs._debug) {
|
|
88
85
|
console.info('rendering element-book app');
|
|
89
86
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
!areJsonEqual(inputs.elementBookRoutePaths, state.currentRoute.paths)) {
|
|
105
|
-
dispatch(new events.pathUpdate(newRoute.paths ?? []));
|
|
87
|
+
function mergeRoutes(newRouteInput) {
|
|
88
|
+
return {
|
|
89
|
+
...state.currentRoute,
|
|
90
|
+
...newRouteInput,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function areRoutesNew(newRouteInput) {
|
|
94
|
+
const newRoute = mergeRoutes(newRouteInput);
|
|
95
|
+
return !areJsonEqual(state.currentRoute, newRoute);
|
|
96
|
+
}
|
|
97
|
+
function updateWindowTitle(topNodeTitle) {
|
|
98
|
+
if (!inputs.preventWindowTitleChange) {
|
|
99
|
+
if (!state.originalWindowTitle) {
|
|
100
|
+
updateState({ originalWindowTitle: document.title });
|
|
106
101
|
}
|
|
102
|
+
document.title = [
|
|
103
|
+
state.originalWindowTitle,
|
|
104
|
+
topNodeTitle,
|
|
105
|
+
]
|
|
106
|
+
.filter(isTruthy)
|
|
107
|
+
.join(' - ');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function updateRoutes(newRouteInput) {
|
|
111
|
+
if (!areRoutesNew(newRouteInput)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const newRoute = mergeRoutes(newRouteInput);
|
|
115
|
+
if (state.router) {
|
|
116
|
+
state.router.setRoutes(newRoute);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
updateState({
|
|
120
|
+
currentRoute: {
|
|
121
|
+
...state.currentRoute,
|
|
122
|
+
...newRoute,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
107
125
|
}
|
|
126
|
+
if (inputs.elementBookRoutePaths &&
|
|
127
|
+
!areJsonEqual(inputs.elementBookRoutePaths, state.currentRoute.paths)) {
|
|
128
|
+
dispatch(new events.pathUpdate(newRoute.paths ?? []));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
108
132
|
if (inputs.elementBookRoutePaths &&
|
|
109
133
|
!areJsonEqual(inputs.elementBookRoutePaths, state.currentRoute.paths)) {
|
|
110
134
|
updateRoutes({ paths: inputs.elementBookRoutePaths });
|
|
@@ -165,6 +189,7 @@ export const ElementBookApp = defineElement()({
|
|
|
165
189
|
: undefined;
|
|
166
190
|
const currentNodes = searchedNodes ??
|
|
167
191
|
getCurrentNodes(originalTree.flattenedNodes, state.currentRoute.paths, updateRoutes);
|
|
192
|
+
updateWindowTitle(currentNodes[0]?.entry.title);
|
|
168
193
|
const currentControls = state.treeBasedControls?.controls;
|
|
169
194
|
if (!currentControls) {
|
|
170
195
|
return html `
|
|
@@ -180,25 +205,16 @@ export const ElementBookApp = defineElement()({
|
|
|
180
205
|
<div
|
|
181
206
|
class="root"
|
|
182
207
|
${listen(ChangeRouteEvent, async (event) => {
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
while (!host.shadowRoot.querySelector('.loading')) {
|
|
187
|
-
await waitForAnimationFrame();
|
|
188
|
-
}
|
|
189
|
-
await waitForAnimationFrame();
|
|
190
|
-
if (entryDisplay) {
|
|
191
|
-
entryDisplay.scroll({ top: 0, behavior: 'smooth' });
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
console.error(`Failed to find '${BookEntryDisplay.tagName}' for scrolling.`);
|
|
208
|
+
const newRoute = event.detail;
|
|
209
|
+
if (!areRoutesNew(newRoute)) {
|
|
210
|
+
return;
|
|
195
211
|
}
|
|
196
|
-
|
|
212
|
+
updateState({ loading: true });
|
|
213
|
+
updateRoutes(newRoute);
|
|
197
214
|
const navElement = host.shadowRoot.querySelector(BookNav.tagName);
|
|
198
215
|
if (!(navElement instanceof BookNav)) {
|
|
199
216
|
throw new Error(`Failed to find child '${BookNav.tagName}'`);
|
|
200
217
|
}
|
|
201
|
-
updateState({ loading: false });
|
|
202
218
|
scrollNav(host, searchQuery, state.currentRoute);
|
|
203
219
|
})}
|
|
204
220
|
${listen(BookPageControls.events.controlValueChange, (event) => {
|
|
@@ -224,25 +240,33 @@ export const ElementBookApp = defineElement()({
|
|
|
224
240
|
slot=${ElementBookSlotName.NavHeader}
|
|
225
241
|
></slot>
|
|
226
242
|
</${BookNav}>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
<${BookEntryDisplay.assign({
|
|
244
|
+
controls: currentControls,
|
|
245
|
+
currentNodes,
|
|
246
|
+
currentRoute: state.currentRoute,
|
|
247
|
+
debug,
|
|
248
|
+
originalTree: originalTree.tree,
|
|
249
|
+
router: state.router,
|
|
250
|
+
showLoading: state.loading,
|
|
251
|
+
})}
|
|
252
|
+
${listen(BookEntryDisplay.events.loadingRender, async (event) => {
|
|
253
|
+
await waitForAnimationFrame();
|
|
254
|
+
const entryDisplay = host.shadowRoot.querySelector(BookEntryDisplay.tagName);
|
|
255
|
+
if (entryDisplay) {
|
|
256
|
+
entryDisplay.scroll({ top: 0, behavior: 'instant' });
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
console.error(`Failed to find '${BookEntryDisplay.tagName}' for scrolling.`);
|
|
260
|
+
}
|
|
261
|
+
await waitForAnimationFrame();
|
|
262
|
+
updateState({ loading: !event.detail });
|
|
263
|
+
})}
|
|
264
|
+
>
|
|
265
|
+
<slot
|
|
266
|
+
name=${ElementBookSlotName.Footer}
|
|
267
|
+
slot=${ElementBookSlotName.Footer}
|
|
268
|
+
></slot>
|
|
269
|
+
</${BookEntryDisplay}>
|
|
246
270
|
</div>
|
|
247
271
|
`;
|
|
248
272
|
}
|
|
@@ -11,6 +11,7 @@ type OptionalConfig = {
|
|
|
11
11
|
themeColor: string;
|
|
12
12
|
_debug: boolean;
|
|
13
13
|
globalValues: GlobalValues;
|
|
14
|
+
preventWindowTitleChange: boolean;
|
|
14
15
|
} & RequireExactlyOne<{
|
|
15
16
|
/**
|
|
16
17
|
* Set this internal router config if element-book is intended to be the current website's
|
|
@@ -9,8 +9,6 @@ export const BookBreadcrumbsBar = defineBookElement()({
|
|
|
9
9
|
tagName: 'book-breadcrumbs-bar',
|
|
10
10
|
styles: css `
|
|
11
11
|
:host {
|
|
12
|
-
position: sticky;
|
|
13
|
-
top: 0;
|
|
14
12
|
border-bottom: 1px solid
|
|
15
13
|
${colorThemeCssVars['element-book-page-foreground-faint-level-2-color'].value};
|
|
16
14
|
padding: 4px 8px;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractEventTarget } from '@augment-vir/browser';
|
|
2
2
|
import { isRuntimeTypeOf } from '@augment-vir/common';
|
|
3
3
|
import { css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
4
|
-
import { Options24Icon, ViraIcon } from 'vira';
|
|
4
|
+
import { Options24Icon, ViraIcon, ViraInput } from 'vira';
|
|
5
5
|
import { BookPageControlTypeEnum, isControlInitType, } from '../../../../data/book-entry/book-page/book-page-controls';
|
|
6
6
|
import { colorThemeCssVars } from '../../../color-theme/color-theme';
|
|
7
7
|
import { defineBookElement } from '../../define-book-element';
|
|
@@ -41,6 +41,11 @@ export const BookPageControls = defineBookElement()({
|
|
|
41
41
|
color: red;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
${ViraInput} {
|
|
45
|
+
height: 24px;
|
|
46
|
+
max-width: 128px;
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
${ViraIcon}.options-icon {
|
|
45
50
|
position: absolute;
|
|
46
51
|
left: 0;
|
|
@@ -117,14 +122,15 @@ function createControlInput(value, controlInit, valueChange) {
|
|
|
117
122
|
}
|
|
118
123
|
else if (isControlInitType(controlInit, BookPageControlTypeEnum.Text)) {
|
|
119
124
|
return html `
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const inputElement = extractEventTarget(event, HTMLInputElement);
|
|
125
|
-
valueChange(inputElement.value);
|
|
125
|
+
<${ViraInput.assign({
|
|
126
|
+
value: String(value),
|
|
127
|
+
showClearButton: true,
|
|
128
|
+
disableBrowserHelps: true,
|
|
126
129
|
})}
|
|
127
|
-
|
|
130
|
+
${listen(ViraInput.events.valueChange, (event) => {
|
|
131
|
+
valueChange(event.detail);
|
|
132
|
+
})}
|
|
133
|
+
></${ViraInput}>
|
|
128
134
|
`;
|
|
129
135
|
}
|
|
130
136
|
else if (isControlInitType(controlInit, BookPageControlTypeEnum.Number)) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BookEntryTypeEnum } from '../../../../data/book-entry/book-entry-type';
|
|
2
|
+
import { ControlsWrapper } from '../../../../data/book-entry/book-page/controls-wrapper';
|
|
3
|
+
import { BookTreeNode } from '../../../../data/book-tree/book-tree-node';
|
|
4
|
+
import { BookFullRoute, BookRouter } from '../../../../routing/book-routing';
|
|
5
|
+
export declare const BookEntryDisplay: import("element-vir").DeclarativeElementDefinition<"book-entry-display", {
|
|
6
|
+
controls: ControlsWrapper;
|
|
7
|
+
currentNodes: ReadonlyArray<BookTreeNode>;
|
|
8
|
+
currentRoute: Readonly<BookFullRoute>;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
originalTree: Readonly<BookTreeNode<BookEntryTypeEnum.Root>>;
|
|
11
|
+
router: BookRouter | undefined;
|
|
12
|
+
showLoading: boolean;
|
|
13
|
+
}, {
|
|
14
|
+
lastElement: Element | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
loadingRender: import("element-vir").DefinedTypedEventNameDefinition<boolean>;
|
|
17
|
+
}, `book-entry-display-${string}`, `book-entry-display-${string}`, import("lit-html").HTMLTemplateResult>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { css, defineElementEvent, html, onDomCreated, renderIf } from 'element-vir';
|
|
2
|
+
import { LoaderAnimated24Icon, ViraIcon, viraAnimationDurations } from 'vira';
|
|
3
|
+
import { extractSearchQuery } from '../../../../routing/book-routing';
|
|
4
|
+
import { defineBookElement } from '../../define-book-element';
|
|
5
|
+
import { ElementBookSlotName } from '../../element-book-app/element-book-app-slots';
|
|
6
|
+
import { BookBreadcrumbsBar } from '../book-breadcrumbs-bar.element';
|
|
7
|
+
import { createNodeTemplates } from './create-node-templates';
|
|
8
|
+
export const BookEntryDisplay = defineBookElement()({
|
|
9
|
+
tagName: 'book-entry-display',
|
|
10
|
+
styles: css `
|
|
11
|
+
:host {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.all-book-entries-wrapper {
|
|
18
|
+
flex-grow: 1;
|
|
19
|
+
padding: 32px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.inline-entry {
|
|
23
|
+
margin: 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
* + .block-entry {
|
|
27
|
+
margin-top: 32px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.block-entry + * {
|
|
31
|
+
margin-top: 32px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${BookBreadcrumbsBar} {
|
|
40
|
+
position: sticky;
|
|
41
|
+
top: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.loading {
|
|
45
|
+
flex-grow: 1;
|
|
46
|
+
padding: 64px;
|
|
47
|
+
position: absolute;
|
|
48
|
+
background-color: white;
|
|
49
|
+
animation: fade-in linear
|
|
50
|
+
${viraAnimationDurations['vira-interaction-animation-duration'].value} forwards;
|
|
51
|
+
z-index: 100;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
top: 0;
|
|
55
|
+
left: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@keyframes fade-in {
|
|
59
|
+
from {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
}
|
|
62
|
+
to {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
events: {
|
|
68
|
+
loadingRender: defineElementEvent(),
|
|
69
|
+
},
|
|
70
|
+
stateInitStatic: {
|
|
71
|
+
lastElement: undefined,
|
|
72
|
+
},
|
|
73
|
+
renderCallback: ({ inputs, dispatch, events, state, updateState }) => {
|
|
74
|
+
const currentSearch = extractSearchQuery(inputs.currentRoute.paths);
|
|
75
|
+
const entryTemplates = createNodeTemplates({
|
|
76
|
+
currentNodes: inputs.currentNodes,
|
|
77
|
+
isTopLevel: true,
|
|
78
|
+
router: inputs.router,
|
|
79
|
+
isSearching: !!currentSearch,
|
|
80
|
+
controls: inputs.controls,
|
|
81
|
+
originalTree: inputs.originalTree,
|
|
82
|
+
});
|
|
83
|
+
return html `
|
|
84
|
+
<${BookBreadcrumbsBar.assign({
|
|
85
|
+
currentSearch,
|
|
86
|
+
currentRoute: inputs.currentRoute,
|
|
87
|
+
router: inputs.router,
|
|
88
|
+
})}></${BookBreadcrumbsBar}>
|
|
89
|
+
|
|
90
|
+
${renderIf(inputs.showLoading, html `
|
|
91
|
+
<div
|
|
92
|
+
${onDomCreated(() => {
|
|
93
|
+
dispatch(new events.loadingRender(true));
|
|
94
|
+
})}
|
|
95
|
+
class="loading"
|
|
96
|
+
>
|
|
97
|
+
<${ViraIcon.assign({ icon: LoaderAnimated24Icon })}></${ViraIcon}>
|
|
98
|
+
</div>
|
|
99
|
+
${renderIf(!!state.lastElement, html `
|
|
100
|
+
${state.lastElement}
|
|
101
|
+
<slot name=${ElementBookSlotName.Footer}></slot>
|
|
102
|
+
`)}
|
|
103
|
+
`, html `
|
|
104
|
+
<div
|
|
105
|
+
${onDomCreated((element) => {
|
|
106
|
+
updateState({ lastElement: element });
|
|
107
|
+
})}
|
|
108
|
+
class="all-book-entries-wrapper"
|
|
109
|
+
>
|
|
110
|
+
${entryTemplates}
|
|
111
|
+
</div>
|
|
112
|
+
<slot name=${ElementBookSlotName.Footer}></slot>
|
|
113
|
+
`)}
|
|
114
|
+
`;
|
|
115
|
+
},
|
|
116
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BookEntryTypeEnum } from '../../../../data/book-entry/book-entry-type';
|
|
2
|
+
import { ControlsWrapper } from '../../../../data/book-entry/book-page/controls-wrapper';
|
|
3
|
+
import { BookTreeNode } from '../../../../data/book-tree/book-tree-node';
|
|
4
|
+
import { BookRouter } from '../../../../routing/book-routing';
|
|
5
|
+
export declare function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, controls, originalTree, }: {
|
|
6
|
+
currentNodes: ReadonlyArray<BookTreeNode>;
|
|
7
|
+
isTopLevel: boolean;
|
|
8
|
+
router: BookRouter | undefined;
|
|
9
|
+
isSearching: boolean;
|
|
10
|
+
controls: ControlsWrapper;
|
|
11
|
+
originalTree: Readonly<BookTreeNode<BookEntryTypeEnum.Root>>;
|
|
12
|
+
}): unknown[];
|
|
@@ -1,67 +1,12 @@
|
|
|
1
|
-
import { assign, css, html, repeat } from 'element-vir';
|
|
2
|
-
import { BookEntryTypeEnum } from '../../../data/book-entry/book-entry-type';
|
|
3
1
|
import { isLengthAtLeast, mapObjectValues } from '@augment-vir/common';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { BookPageWrapper } from './book-page/book-page-wrapper.element';
|
|
13
|
-
import { BookElementExampleWrapper } from './element-example/book-element-example-wrapper.element';
|
|
14
|
-
export const BookEntryDisplay = defineBookElement()({
|
|
15
|
-
tagName: 'book-entry-display',
|
|
16
|
-
styles: css `
|
|
17
|
-
:host {
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.all-book-entries-wrapper {
|
|
23
|
-
flex-grow: 1;
|
|
24
|
-
padding: 32px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.inline-entry {
|
|
28
|
-
margin: 8px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
* + .block-entry {
|
|
32
|
-
margin-top: 32px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.block-entry + * {
|
|
36
|
-
margin-top: 32px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
h1 {
|
|
40
|
-
margin: 0;
|
|
41
|
-
padding: 0;
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
renderCallback: ({ inputs }) => {
|
|
45
|
-
const currentSearch = extractSearchQuery(inputs.currentRoute.paths);
|
|
46
|
-
const entryTemplates = createNodeTemplates({
|
|
47
|
-
currentNodes: inputs.currentNodes,
|
|
48
|
-
isTopLevel: true,
|
|
49
|
-
router: inputs.router,
|
|
50
|
-
isSearching: !!currentSearch,
|
|
51
|
-
controls: inputs.controls,
|
|
52
|
-
originalTree: inputs.originalTree,
|
|
53
|
-
});
|
|
54
|
-
return html `
|
|
55
|
-
<${BookBreadcrumbsBar.assign({
|
|
56
|
-
currentSearch,
|
|
57
|
-
currentRoute: inputs.currentRoute,
|
|
58
|
-
router: inputs.router,
|
|
59
|
-
})}></${BookBreadcrumbsBar}>
|
|
60
|
-
<div class="all-book-entries-wrapper">${entryTemplates}</div>
|
|
61
|
-
<slot name=${ElementBookSlotName.Footer}></slot>
|
|
62
|
-
`;
|
|
63
|
-
},
|
|
64
|
-
});
|
|
2
|
+
import { html, repeat } from 'element-vir';
|
|
3
|
+
import { BookEntryTypeEnum } from '../../../../data/book-entry/book-entry-type';
|
|
4
|
+
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper';
|
|
5
|
+
import { isBookTreeNode, traverseToImmediateParent } from '../../../../data/book-tree/book-tree';
|
|
6
|
+
import { BookError } from '../../common/book-error.element';
|
|
7
|
+
import { BookPageControls } from '../book-page/book-page-controls.element';
|
|
8
|
+
import { BookPageWrapper } from '../book-page/book-page-wrapper.element';
|
|
9
|
+
import { BookElementExampleWrapper } from '../element-example/book-element-example-wrapper.element';
|
|
65
10
|
function getFlattenedControlsFromHiddenParents(currentNodes, currentControls, currentNode, originalTree) {
|
|
66
11
|
const parent = traverseToImmediateParent(currentNode, originalTree);
|
|
67
12
|
const allControls = [];
|
|
@@ -99,7 +44,7 @@ function getFlattenedControlsFromHiddenParents(currentNodes, currentControls, cu
|
|
|
99
44
|
};
|
|
100
45
|
}, { config: {}, current: {}, breadcrumbs: {} });
|
|
101
46
|
}
|
|
102
|
-
function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, controls, originalTree, }) {
|
|
47
|
+
export function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, controls, originalTree, }) {
|
|
103
48
|
if (!currentNodes.length && isSearching) {
|
|
104
49
|
return [
|
|
105
50
|
html `
|
|
@@ -147,15 +92,14 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, co
|
|
|
147
92
|
`;
|
|
148
93
|
}
|
|
149
94
|
else if (isBookTreeNode(currentNode, BookEntryTypeEnum.Root)) {
|
|
150
|
-
return
|
|
95
|
+
return '';
|
|
151
96
|
}
|
|
152
97
|
else {
|
|
153
98
|
return html `
|
|
154
|
-
<${BookError
|
|
155
|
-
class="block-entry"
|
|
156
|
-
${assign(BookError, {
|
|
99
|
+
<${BookError.assign({
|
|
157
100
|
message: `Unknown entry type for rendering: '${currentNode.entry.entryType}'`,
|
|
158
101
|
})}
|
|
102
|
+
class="block-entry"
|
|
159
103
|
></${BookError}>
|
|
160
104
|
`;
|
|
161
105
|
}
|
|
@@ -163,5 +107,5 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, co
|
|
|
163
107
|
return [
|
|
164
108
|
hiddenAncestorControlsTemplate,
|
|
165
109
|
templates,
|
|
166
|
-
];
|
|
110
|
+
].flat();
|
|
167
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-book",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"book",
|
|
6
6
|
"design system",
|
|
@@ -39,28 +39,28 @@
|
|
|
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": "^18.0.0",
|
|
43
|
+
"@augment-vir/common": "^18.0.0",
|
|
44
44
|
"colorjs.io": "0.4.5",
|
|
45
|
-
"element-vir": "^16.
|
|
46
|
-
"lit-css-vars": "^3.0.
|
|
47
|
-
"object-shape-tester": "^0.4.
|
|
48
|
-
"spa-router-vir": "^
|
|
49
|
-
"typed-event-target": "^1.
|
|
50
|
-
"vira": "^
|
|
45
|
+
"element-vir": "^16.3.2",
|
|
46
|
+
"lit-css-vars": "^3.0.1",
|
|
47
|
+
"object-shape-tester": "^0.4.3",
|
|
48
|
+
"spa-router-vir": "^3.0.1",
|
|
49
|
+
"typed-event-target": "^1.4.1",
|
|
50
|
+
"vira": "^2.2.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@augment-vir/browser-testing": "^
|
|
53
|
+
"@augment-vir/browser-testing": "^18.0.0",
|
|
54
54
|
"@open-wc/testing": "^3.2.0",
|
|
55
|
-
"@types/chai": "^4.3.
|
|
55
|
+
"@types/chai": "^4.3.6",
|
|
56
56
|
"@types/mocha": "^10.0.1",
|
|
57
57
|
"@web/dev-server-esbuild": "^0.4.1",
|
|
58
|
-
"@web/test-runner": "^0.17.
|
|
58
|
+
"@web/test-runner": "^0.17.1",
|
|
59
59
|
"@web/test-runner-commands": "^0.8.0",
|
|
60
60
|
"@web/test-runner-playwright": "^0.10.1",
|
|
61
61
|
"@web/test-runner-visual-regression": "^0.8.2",
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.2",
|
|
63
|
-
"type-fest": "^4.
|
|
64
|
-
"typescript": "^5.
|
|
63
|
+
"type-fest": "^4.3.1",
|
|
64
|
+
"typescript": "^5.2.2"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BookEntryTypeEnum } from '../../../data/book-entry/book-entry-type';
|
|
2
|
-
import { ControlsWrapper } from '../../../data/book-entry/book-page/controls-wrapper';
|
|
3
|
-
import { BookTreeNode } from '../../../data/book-tree/book-tree-node';
|
|
4
|
-
import { BookFullRoute, BookRouter } from '../../../routing/book-routing';
|
|
5
|
-
export declare const BookEntryDisplay: import("element-vir").DeclarativeElementDefinition<"book-entry-display", {
|
|
6
|
-
currentRoute: Readonly<BookFullRoute>;
|
|
7
|
-
currentNodes: ReadonlyArray<BookTreeNode>;
|
|
8
|
-
originalTree: Readonly<BookTreeNode<BookEntryTypeEnum.Root>>;
|
|
9
|
-
router: BookRouter | undefined;
|
|
10
|
-
debug: boolean;
|
|
11
|
-
controls: ControlsWrapper;
|
|
12
|
-
}, {}, {}, `book-entry-display-${string}`, `book-entry-display-${string}`, import("lit-html").HTMLTemplateResult>;
|