element-book 7.0.8 → 9.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.
@@ -1,14 +1,15 @@
1
1
  import { Overwrite, RequireNonVoid, SetOptionalAndNullable } from '@augment-vir/common';
2
2
  import { PropertyInitMapBase, RenderParams, TypedEvent } from 'element-vir';
3
3
  import { CSSResult } from 'lit';
4
+ import { GlobalValues } from '../../../ui/elements/element-book-app/element-book-config';
4
5
  import { BaseBookEntry } from '../base-book-entry';
5
6
  import { BookEntryTypeEnum } from '../book-entry-type';
6
7
  import { BookPage } from '../book-page/book-page';
7
8
  import { BookPageControlsInitBase, ControlsToValues } from '../book-page/book-page-controls';
8
- export type BookPageExampleRenderParams<ControlsInit extends BookPageControlsInitBase, StateInit extends PropertyInitMapBase> = Pick<RenderParams<any, any, StateInit, any, any, any>, 'state' | 'updateState'> & {
9
- controls: ControlsToValues<ControlsInit>;
9
+ export type BookPageExampleRenderParams<GlobalValuesType extends GlobalValues, ControlsInit extends BookPageControlsInitBase, StateInit extends PropertyInitMapBase> = Pick<RenderParams<any, any, StateInit, any, any, any>, 'state' | 'updateState'> & {
10
+ controls: ControlsToValues<ControlsInit> & GlobalValuesType;
10
11
  };
11
- export type BookElementExample<ControlsInit extends BookPageControlsInitBase = {}, StateInit extends PropertyInitMapBase = {}, RenderOutput = unknown> = Overwrite<BaseBookEntry, {
12
+ export type BookElementExample<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = {}, StateInit extends PropertyInitMapBase = {}, RenderOutput = unknown> = Overwrite<BaseBookEntry, {
12
13
  parent: BookPage | undefined;
13
14
  entryType: BookEntryTypeEnum.ElementExample;
14
15
  } & {
@@ -22,10 +23,10 @@ export type BookElementExample<ControlsInit extends BookPageControlsInitBase = {
22
23
  */
23
24
  styles?: CSSResult | undefined;
24
25
  /** Render the example. */
25
- renderCallback: RequireNonVoid<RenderOutput, (renderParams: BookPageExampleRenderParams<ControlsInit, StateInit>) => RenderOutput, 'renderCallback is missing a return statement'>;
26
+ renderCallback: RequireNonVoid<RenderOutput, (renderParams: BookPageExampleRenderParams<GlobalValuesType, ControlsInit, StateInit>) => RenderOutput, 'renderCallback is missing a return statement'>;
26
27
  }>;
27
28
  /**
28
29
  * The properties that are necessary to initialize an element example. Missing properties will be
29
30
  * filling in by the parent.
30
31
  */
31
- export type BookElementExampleInit<Controls extends BookPageControlsInitBase, StateInit extends PropertyInitMapBase, RenderOutput> = SetOptionalAndNullable<Omit<BookElementExample<Controls, StateInit, RenderOutput>, 'entryType' | 'parent' | 'errors'>, 'descriptionParagraphs'>;
32
+ export type BookElementExampleInit<GlobalValuesType extends GlobalValues, Controls extends BookPageControlsInitBase, StateInit extends PropertyInitMapBase, RenderOutput> = SetOptionalAndNullable<Omit<BookElementExample<GlobalValuesType, Controls, StateInit, RenderOutput>, 'entryType' | 'parent' | 'errors'>, 'descriptionParagraphs'>;
@@ -1,9 +1,10 @@
1
1
  import { Overwrite } from '@augment-vir/common';
2
+ import { GlobalValues } from '../../../ui/elements/element-book-app/element-book-config';
2
3
  import { BaseBookEntry } from '../base-book-entry';
3
4
  import { BookElementExample } from '../book-element-example/book-element-example';
4
5
  import { BookEntryTypeEnum } from '../book-entry-type';
5
6
  import { BookPageControlsInitBase } from './book-page-controls';
6
- export type BookPage<ParentPage extends BookPage | undefined = any, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = Overwrite<BaseBookEntry, {
7
+ export type BookPage<GlobalValuesType extends GlobalValues = {}, ParentPage extends BookPage | undefined = any, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = Overwrite<BaseBookEntry, {
7
8
  parent: ParentPage;
8
9
  entryType: BookEntryTypeEnum.Page;
9
10
  }> & {
@@ -1,3 +1,4 @@
1
+ import { GlobalValues } from '../../../ui/elements/element-book-app/element-book-config';
1
2
  import { BookTreeNode } from '../../book-tree/book-tree-node';
2
3
  import { BookPageControlsValues } from './book-page-controls';
3
4
  export type ControlsWrapper = {
@@ -9,4 +10,4 @@ export type CurrentControls = {
9
10
  };
10
11
  export declare function traverseCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>): BookPageControlsValues;
11
12
  export declare function createNewCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>, newValues: BookPageControlsValues): CurrentControls;
12
- export declare function createControlsFromTree(node: BookTreeNode): CurrentControls;
13
+ export declare function createControlsFromTree(node: BookTreeNode, globalValues: GlobalValues): CurrentControls;
@@ -43,7 +43,7 @@ export function createNewCurrentControls(currentControls, fullUrlBreadcrumbs, ne
43
43
  internalTraverseCurrentControls(newCurrentControls, fullUrlBreadcrumbs, newValues);
44
44
  return newCurrentControls;
45
45
  }
46
- export function createControlsFromTree(node) {
46
+ export function createControlsFromTree(node, globalValues) {
47
47
  const currentControls = mapObjectValues(node.children, (childName, child) => {
48
48
  if (!isBookTreeNode(child, BookEntryTypeEnum.Page)) {
49
49
  return {
@@ -52,10 +52,13 @@ export function createControlsFromTree(node) {
52
52
  };
53
53
  }
54
54
  return {
55
- children: createControlsFromTree(child),
56
- controls: mapObjectValues(child.entry.controls, (name, setup) => {
57
- return setup.initValue;
58
- }),
55
+ children: createControlsFromTree(child, {}),
56
+ controls: {
57
+ ...globalValues,
58
+ ...mapObjectValues(child.entry.controls, (name, setup) => {
59
+ return setup.initValue;
60
+ }),
61
+ },
59
62
  };
60
63
  });
61
64
  return currentControls;
@@ -1,18 +1,27 @@
1
1
  import { SetOptionalAndNullable } from '@augment-vir/common';
2
2
  import { PropertyInitMapBase } from 'element-vir';
3
+ import { GlobalValues } from '../../../ui/elements/element-book-app/element-book-config';
3
4
  import { InfiniteRecursionLimiter } from '../../../util/type';
4
5
  import { BookElementExampleInit } from '../book-element-example/book-element-example';
5
6
  import { BookPage } from './book-page';
6
7
  import { BookPageControlsInitBase } from './book-page-controls';
7
- export type DefineExampleCallback<ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = <StateInit extends PropertyInitMapBase, RenderOutput>(exampleInit: BookElementExampleInit<ControlsInit, StateInit, RenderOutput>) => void;
8
- export type ElementExamplesDefiner<ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = (params: {
9
- defineExample: DefineExampleCallback<ControlsInit>;
8
+ export type DefineExampleCallback<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = <StateInit extends PropertyInitMapBase, RenderOutput>(exampleInit: BookElementExampleInit<GlobalValuesType, ControlsInit, StateInit, RenderOutput>) => void;
9
+ export type ElementExamplesDefiner<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = (params: {
10
+ defineExample: DefineExampleCallback<GlobalValuesType, ControlsInit>;
10
11
  }) => void;
11
12
  type CollapseControlsInit<ParentPage extends BookPage | undefined, CurrentControlsInit extends BookPageControlsInitBase,
12
13
  /** Prevent infinite recursion TypeScript errors. */
13
- RecursionDepth = InfiniteRecursionLimiter> = CurrentControlsInit & (RecursionDepth extends [any, ...infer RemainingDepth] ? ParentPage extends BookPage<infer GrandParentPage, infer ParentControls> ? CollapseControlsInit<GrandParentPage, ParentControls, RemainingDepth> : {} : {});
14
- export type BookPageInit<ParentPage extends BookPage | undefined, CurrentControlsInit extends BookPageControlsInitBase> = SetOptionalAndNullable<Omit<BookPage<ParentPage, CurrentControlsInit>, 'entryType' | 'elementExamples' | 'errors'>, 'controls' | 'descriptionParagraphs'> & {
15
- elementExamplesCallback?: ElementExamplesDefiner<CollapseControlsInit<ParentPage, CurrentControlsInit>> | undefined;
14
+ RecursionDepth = InfiniteRecursionLimiter> = CurrentControlsInit & (RecursionDepth extends [any, ...infer RemainingDepth] ? ParentPage extends BookPage<infer GlobalValuesType, infer GrandParentPage, infer ParentControls> ? CollapseControlsInit<GrandParentPage, ParentControls, RemainingDepth> : {} : {});
15
+ type CollapseGlobalValuesType<ParentPage extends BookPage | undefined, GlobalValuesType extends GlobalValues,
16
+ /** Prevent infinite recursion TypeScript errors. */
17
+ RecursionDepth = InfiniteRecursionLimiter> = GlobalValuesType & (RecursionDepth extends [any, ...infer RemainingDepth] ? ParentPage extends BookPage<infer GlobalValuesType, infer GrandParentPage, infer ParentControls> ? CollapseGlobalValuesType<GrandParentPage, GlobalValuesType, RemainingDepth> : {} : {});
18
+ export type BookPageInit<GlobalValuesType extends GlobalValues, ParentPage extends BookPage | undefined, CurrentControlsInit extends BookPageControlsInitBase> = SetOptionalAndNullable<Omit<BookPage<any, ParentPage, CurrentControlsInit>, 'entryType' | 'elementExamples' | 'errors'>, 'controls' | 'descriptionParagraphs'> & {
19
+ elementExamplesCallback?: ElementExamplesDefiner<CollapseGlobalValuesType<ParentPage, GlobalValuesType>, CollapseControlsInit<ParentPage, CurrentControlsInit>> | undefined;
16
20
  };
17
- export declare function defineBookPage<const ParentPage extends BookPage | undefined, const ControlsInit extends BookPageControlsInitBase = {}>(pageInit: BookPageInit<ParentPage, ControlsInit>): BookPage<ParentPage, ControlsInit>;
21
+ /**
22
+ * Allows insertion of the global values type to a page. This is not necessary if you aren't using
23
+ * global values in your element-book instance.
24
+ */
25
+ export declare function defineBookPageWithGlobals<const GlobalValuesType extends GlobalValues = {}>(): <const ParentPage extends BookPage | undefined = undefined, const ControlsInit extends BookPageControlsInitBase = {}>(pageInit: BookPageInit<GlobalValuesType, ParentPage, ControlsInit>) => BookPage<GlobalValuesType, ParentPage, ControlsInit>;
26
+ export declare function defineBookPage<const GlobalValuesType extends GlobalValues = {}, const ParentPage extends BookPage | undefined = undefined, const ControlsInit extends BookPageControlsInitBase = {}>(pageInit: BookPageInit<GlobalValuesType, ParentPage, ControlsInit>): BookPage<GlobalValuesType, ParentPage, ControlsInit>;
18
27
  export {};
@@ -1,6 +1,15 @@
1
1
  import { isTruthy } from '@augment-vir/common';
2
2
  import { BookEntryTypeEnum } from '../book-entry-type';
3
3
  import { titleToUrlBreadcrumb } from '../url-breadcrumbs';
4
+ /**
5
+ * Allows insertion of the global values type to a page. This is not necessary if you aren't using
6
+ * global values in your element-book instance.
7
+ */
8
+ export function defineBookPageWithGlobals() {
9
+ return (pageInit) => {
10
+ return defineBookPage(pageInit);
11
+ };
12
+ }
4
13
  export function defineBookPage(pageInit) {
5
14
  const page = {
6
15
  ...pageInit,
@@ -1,4 +1,4 @@
1
- import { assign, css, html } from 'element-vir';
1
+ import { css, html } from 'element-vir';
2
2
  import { BookMainRoute } from '../../routing/book-routing';
3
3
  import { BookRouteLink } from './common/book-route-link.element';
4
4
  import { defineBookElement } from './define-book-element';
@@ -30,8 +30,7 @@ export const BookBreadcrumbs = defineBookElement()({
30
30
  <span class="spacer">&gt;</span>
31
31
  `;
32
32
  return html `
33
- <${BookRouteLink}
34
- ${assign(BookRouteLink, {
33
+ <${BookRouteLink.assign({
35
34
  route: {
36
35
  hash: undefined,
37
36
  search: undefined,
@@ -41,8 +40,7 @@ export const BookBreadcrumbs = defineBookElement()({
41
40
  ],
42
41
  },
43
42
  router: inputs.router,
44
- })}
45
- >
43
+ })}>
46
44
  ${currentPath}
47
45
  </${BookRouteLink}>
48
46
  ${spacer}
@@ -1,6 +1,6 @@
1
1
  import { checkIfEntirelyInScrollView, waitForAnimationFrame } from '@augment-vir/browser';
2
2
  import { areJsonEqual } from '@augment-vir/common';
3
- import { assign, classMap, css, html, renderIf } from 'element-vir';
3
+ import { classMap, css, html, renderIf } from 'element-vir';
4
4
  import { Element16Icon, ViraIcon } from 'vira';
5
5
  import { BookEntryTypeEnum } from '../../data/book-entry/book-entry-type';
6
6
  import { isBookTreeNode } from '../../data/book-tree/book-tree';
@@ -76,8 +76,7 @@ export const BookNav = defineBookElement()({
76
76
  `;
77
77
  return html `
78
78
  <li style=${liStyle}>
79
- <${BookRouteLink}
80
- ${assign(BookRouteLink, {
79
+ <${BookRouteLink.assign({
81
80
  router: inputs.router,
82
81
  route: {
83
82
  paths: [
@@ -95,9 +94,7 @@ export const BookNav = defineBookElement()({
95
94
  >
96
95
  <div class="title-text">
97
96
  ${renderIf(isBookTreeNode(treeNode, BookEntryTypeEnum.ElementExample), html `
98
- <${ViraIcon}
99
- ${assign(ViraIcon, { icon: Element16Icon })}
100
- ></${ViraIcon}>
97
+ <${ViraIcon.assign({ icon: Element16Icon })}></${ViraIcon}>
101
98
  `)}
102
99
  ${treeNode.entry.title}
103
100
  </div>
@@ -1,7 +1,7 @@
1
1
  import { CurrentControls } from '../../../data/book-entry/book-page/current-controls';
2
2
  import { ColorTheme } from '../../color-theme/color-theme';
3
3
  import { ThemeConfig } from '../../color-theme/create-color-theme';
4
- import { ElementBookConfig } from './element-book-config';
4
+ import { ElementBookConfig, GlobalValues } from './element-book-config';
5
5
  type ColorThemeState = {
6
6
  config: ThemeConfig | undefined;
7
7
  theme: ColorTheme;
@@ -11,7 +11,8 @@ 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
  colors: ColorThemeState;
13
13
  treeBasedCurrentControls: {
14
- trigger: ElementBookConfig['entries'];
14
+ entries: ElementBookConfig['entries'];
15
+ globalValues: GlobalValues;
15
16
  currentControls: CurrentControls;
16
17
  } | undefined;
17
18
  }, {
@@ -1,5 +1,5 @@
1
1
  import { areJsonEqual, extractErrorMessage } from '@augment-vir/common';
2
- import { assign, css, defineElement, defineElementEvent, html, listen } from 'element-vir';
2
+ import { css, defineElement, defineElementEvent, html, listen } from 'element-vir';
3
3
  import { createControlsFromTree, createNewCurrentControls, } from '../../../data/book-entry/book-page/current-controls';
4
4
  import { createBookTreeFromEntries } from '../../../data/book-tree/book-tree';
5
5
  import { searchFlattenedNodes } from '../../../data/book-tree/search-nodes';
@@ -132,11 +132,13 @@ export const ElementBookApp = defineElement()({
132
132
  debug,
133
133
  });
134
134
  if (!state.treeBasedCurrentControls ||
135
- state.treeBasedCurrentControls.trigger !== inputs.entries) {
135
+ state.treeBasedCurrentControls.entries !== inputs.entries ||
136
+ state.treeBasedCurrentControls.globalValues !== inputs.globalValues) {
136
137
  updateState({
137
138
  treeBasedCurrentControls: {
138
- trigger: inputs.entries,
139
- currentControls: createControlsFromTree(originalTree.tree),
139
+ entries: inputs.entries,
140
+ globalValues: inputs.globalValues ?? {},
141
+ currentControls: createControlsFromTree(originalTree.tree, inputs.globalValues ?? {}),
140
142
  },
141
143
  });
142
144
  }
@@ -152,9 +154,9 @@ export const ElementBookApp = defineElement()({
152
154
  const currentControls = state.treeBasedCurrentControls?.currentControls;
153
155
  if (!currentControls) {
154
156
  return html `
155
- <${BookError}
156
- ${assign(BookError, { message: 'Failed to generate page controls.' })}
157
- ></${BookError}>
157
+ <${BookError.assign({
158
+ message: 'Failed to generate page controls.',
159
+ })}></${BookError}>
158
160
  `;
159
161
  }
160
162
  if (inputs.debug) {
@@ -191,30 +193,24 @@ export const ElementBookApp = defineElement()({
191
193
  });
192
194
  })}
193
195
  >
194
- <${BookNav}
195
- ${assign(BookNav, {
196
+ <${BookNav.assign({
196
197
  flattenedNodes: originalTree.flattenedNodes,
197
198
  router: state.router,
198
- selectedPath: searchQuery
199
- ? undefined
200
- : state.currentRoute.paths.slice(1),
201
- })}
202
- >
199
+ selectedPath: searchQuery ? undefined : state.currentRoute.paths.slice(1),
200
+ })}>
203
201
  <slot
204
202
  name=${ElementBookSlotName.NavHeader}
205
203
  slot=${ElementBookSlotName.NavHeader}
206
204
  ></slot>
207
205
  </${BookNav}>
208
- <${BookEntryDisplay}
209
- ${assign(BookEntryDisplay, {
206
+ <${BookEntryDisplay.assign({
210
207
  currentRoute: state.currentRoute,
211
208
  currentNodes,
212
209
  router: state.router,
213
210
  debug,
214
211
  currentControls,
215
212
  originalTree: originalTree.tree,
216
- })}
217
- >
213
+ })}>
218
214
  <slot
219
215
  name=${ElementBookSlotName.Footer}
220
216
  slot=${ElementBookSlotName.Footer}
@@ -5,6 +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
9
  type OptionalConfig = {
9
10
  /** The base theme color from which all other element-book colors will be generated from. */
10
11
  themeColor: string;
@@ -12,6 +13,7 @@ type OptionalConfig = {
12
13
  everythingTitle: string;
13
14
  everythingDescriptionParagraphs: ReadonlyArray<string>;
14
15
  debug: boolean;
16
+ globalValues: GlobalValues;
15
17
  } & RequireExactlyOne<{
16
18
  /**
17
19
  * Set this internal router config if element-book is intended to be the current website's
@@ -1,5 +1,5 @@
1
1
  import { wait } from '@augment-vir/common';
2
- import { assign, css, html, listen, renderIf } from 'element-vir';
2
+ import { css, html, listen, renderIf } from 'element-vir';
3
3
  import { BookMainRoute, defaultBookFullRoute, } from '../../../routing/book-routing';
4
4
  import { colorThemeCssVars } from '../../color-theme/color-theme';
5
5
  import { ChangeRouteEvent } from '../../events/change-route.event';
@@ -26,12 +26,10 @@ export const BookBreadcrumbsBar = defineBookElement()({
26
26
  ${renderIf(!!inputs.currentSearch, html `
27
27
  &nbsp;
28
28
  `, html `
29
- <${BookBreadcrumbs}
30
- ${assign(BookBreadcrumbs, {
29
+ <${BookBreadcrumbs.assign({
31
30
  currentRoute: inputs.currentRoute,
32
31
  router: inputs.router,
33
- })}
34
- ></${BookBreadcrumbs}>
32
+ })}></${BookBreadcrumbs}>
35
33
  `)}
36
34
  <input
37
35
  placeholder="search"
@@ -52,13 +52,11 @@ export const BookEntryDisplay = defineBookElement()({
52
52
  originalTree: inputs.originalTree,
53
53
  });
54
54
  return html `
55
- <${BookBreadcrumbsBar}
56
- ${assign(BookBreadcrumbsBar, {
55
+ <${BookBreadcrumbsBar.assign({
57
56
  currentSearch,
58
57
  currentRoute: inputs.currentRoute,
59
58
  router: inputs.router,
60
- })}
61
- ></${BookBreadcrumbsBar}>
59
+ })}></${BookBreadcrumbsBar}>
62
60
  <div class="all-book-entries-wrapper">${entryTemplates}</div>
63
61
  <slot name=${ElementBookSlotName.Footer}></slot>
64
62
  `;
@@ -114,39 +112,35 @@ function createNodeTemplates({ currentNodes, isTopLevel, router, isSearching, cu
114
112
  : undefined;
115
113
  const hiddenAncestorControlsTemplate = hiddenAncestorControls && isLengthAtLeast(currentNodes, 1)
116
114
  ? html `
117
- <${BookPageControls}
118
- ${assign(BookPageControls, {
115
+ <${BookPageControls.assign({
119
116
  config: hiddenAncestorControls.config,
120
117
  currentValues: hiddenAncestorControls.current,
121
118
  fullUrlBreadcrumbs: hiddenAncestorControls.breadcrumbs,
122
- })}
123
- ></${BookPageControls}>
119
+ })}></${BookPageControls}>
124
120
  `
125
121
  : '';
126
122
  const templates = repeat(currentNodes, (node) => node.fullUrlBreadcrumbs.join('>'), (currentNode, index) => {
127
123
  if (isBookTreeNode(currentNode, BookEntryTypeEnum.Page)) {
128
124
  return html `
129
- <${BookPageWrapper}
130
- class="block-entry"
131
- ${assign(BookPageWrapper, {
125
+ <${BookPageWrapper.assign({
132
126
  isTopLevel,
133
127
  pageNode: currentNode,
134
128
  currentControls,
135
129
  router,
136
130
  })}
131
+ class="block-entry"
137
132
  ></${BookPageWrapper}>
138
133
  `;
139
134
  }
140
135
  else if (isBookTreeNode(currentNode, BookEntryTypeEnum.ElementExample)) {
141
136
  const controlsForElementExample = traverseCurrentControls(currentControls, currentNode.fullUrlBreadcrumbs.slice(0, -1));
142
137
  return html `
143
- <${BookElementExampleWrapper}
144
- class="inline-entry"
145
- ${assign(BookElementExampleWrapper, {
138
+ <${BookElementExampleWrapper.assign({
146
139
  elementExampleNode: currentNode,
147
140
  currentPageControls: controlsForElementExample,
148
141
  router,
149
142
  })}
143
+ class="inline-entry"
150
144
  ></${BookElementExampleWrapper}>
151
145
  `;
152
146
  }
@@ -1,6 +1,6 @@
1
1
  import { extractEventTarget } from '@augment-vir/browser';
2
2
  import { isRuntimeTypeOf } from '@augment-vir/common';
3
- import { assign, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
3
+ import { css, defineElementEvent, html, listen, renderIf } from 'element-vir';
4
4
  import { Options24Icon, ViraIcon } 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';
@@ -74,9 +74,8 @@ export const BookPageControls = defineBookElement()({
74
74
  return html `
75
75
  <div class="control-wrapper">
76
76
  ${renderIf(index === 0, html `
77
- <${ViraIcon}
77
+ <${ViraIcon.assign({ icon: Options24Icon })}
78
78
  class="options-icon"
79
- ${assign(ViraIcon, { icon: Options24Icon })}
80
79
  ></${ViraIcon}>
81
80
  `)}
82
81
  <label class="control-wrapper">
@@ -1,5 +1,5 @@
1
1
  import { combineErrors } from '@augment-vir/common';
2
- import { assign, css, html } from 'element-vir';
2
+ import { css, html } from 'element-vir';
3
3
  import { traverseCurrentControls, } from '../../../../data/book-entry/book-page/current-controls';
4
4
  import { BookMainRoute } from '../../../../routing/book-routing';
5
5
  import { BookError } from '../../common/book-error.element';
@@ -53,37 +53,29 @@ export const BookPageWrapper = defineBookElement()({
53
53
  return html `
54
54
  <div class="page-header block-entry">
55
55
  <div class="title-group">
56
- <${BookRouteLink}
57
- ${assign(BookRouteLink, {
56
+ <${BookRouteLink.assign({
58
57
  route: {
59
58
  paths: linkPaths,
60
59
  hash: undefined,
61
60
  search: undefined,
62
61
  },
63
62
  router: inputs.router,
64
- })}
65
- >
63
+ })}>
66
64
  ${titleTemplate}
67
65
  </${BookRouteLink}>
68
66
  ${!!error
69
67
  ? html `
70
- <${BookError}
71
- ${assign(BookError, { message: error.message })}
72
- ></${BookError}>
68
+ <${BookError.assign({ message: error.message })}></${BookError}>
73
69
  `
74
70
  : html `
75
- <${BookEntryDescription}
76
- ${assign(BookEntryDescription, {
71
+ <${BookEntryDescription.assign({
77
72
  descriptionParagraphs: inputs.pageNode.entry.descriptionParagraphs ?? [],
78
- })}
79
- ></${BookEntryDescription}>
80
- <${BookPageControls}
81
- ${assign(BookPageControls, {
73
+ })}></${BookEntryDescription}>
74
+ <${BookPageControls.assign({
82
75
  config: inputs.pageNode.entry.controls,
83
76
  currentValues: traverseCurrentControls(inputs.currentControls, inputs.pageNode.fullUrlBreadcrumbs),
84
77
  fullUrlBreadcrumbs: inputs.pageNode.fullUrlBreadcrumbs,
85
- })}
86
- ></${BookPageControls}>
78
+ })}></${BookPageControls}>
87
79
  `}
88
80
  </div>
89
81
  </div>
@@ -1,4 +1,4 @@
1
- import { assign, css, html } from 'element-vir';
1
+ import { css, html } from 'element-vir';
2
2
  import { BookMainRoute } from '../../../../routing/book-routing';
3
3
  import { colorThemeCssVars } from '../../../color-theme/color-theme';
4
4
  import { BookRouteLink } from '../../common/book-route-link.element';
@@ -19,16 +19,14 @@ export const BookElementExampleControls = defineBookElement()({
19
19
  ...inputs.elementExampleNode.fullUrlBreadcrumbs,
20
20
  ];
21
21
  return html `
22
- <${BookRouteLink}
23
- ${assign(BookRouteLink, {
22
+ <${BookRouteLink.assign({
24
23
  route: {
25
24
  paths: linkPaths,
26
25
  hash: undefined,
27
26
  search: undefined,
28
27
  },
29
28
  router: inputs.router,
30
- })}
31
- >
29
+ })}>
32
30
  ${inputs.elementExampleNode.entry.title}
33
31
  </${BookRouteLink}>
34
32
  `;
@@ -1,5 +1,5 @@
1
1
  import { combineErrors, extractErrorMessage } from '@augment-vir/common';
2
- import { assign, html, renderIf } from 'element-vir';
2
+ import { html, renderIf } from 'element-vir';
3
3
  import { unsetInternalState } from '../../../../data/unset';
4
4
  import { BookError } from '../../common/book-error.element';
5
5
  import { defineBookElement } from '../../define-book-element';
@@ -43,11 +43,9 @@ export const BookElementExampleViewer = defineBookElement()({
43
43
  catch (error) {
44
44
  console.error(error);
45
45
  return html `
46
- <${BookError}
47
- ${assign(BookError, {
46
+ <${BookError.assign({
48
47
  message: `${inputs.elementExampleNode.entry.title} failed: ${extractErrorMessage(error)}`,
49
- })}
50
- ></${BookError}>
48
+ })}></${BookError}>
51
49
  `;
52
50
  }
53
51
  },
@@ -1,4 +1,5 @@
1
- import { assign, css, html } from 'element-vir';
1
+ import { omitObjectKeys } from '@augment-vir/common';
2
+ import { css, html } from 'element-vir';
2
3
  import { colorThemeCssVars } from '../../../color-theme/color-theme';
3
4
  import { defineBookElement } from '../../define-book-element';
4
5
  import { BookElementExampleControls } from './book-element-example-controls.element';
@@ -41,12 +42,8 @@ export const BookElementExampleWrapper = defineBookElement()({
41
42
  renderCallback({ inputs }) {
42
43
  return html `
43
44
  <div class="individual-example-wrapper">
44
- <${BookElementExampleControls}
45
- ${assign(BookElementExampleControls, inputs)}
46
- ></${BookElementExampleControls}>
47
- <${BookElementExampleViewer}
48
- ${assign(BookElementExampleViewer, inputs)}
49
- ></${BookElementExampleViewer}>
45
+ <${BookElementExampleControls.assign(omitObjectKeys(inputs, ['currentPageControls']))}></${BookElementExampleControls}>
46
+ <${BookElementExampleViewer.assign(inputs)}></${BookElementExampleViewer}>
50
47
  </div>
51
48
  `;
52
49
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-book",
3
- "version": "7.0.8",
3
+ "version": "9.0.0",
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": "^15.3.0",
43
- "@augment-vir/common": "^15.3.0",
42
+ "@augment-vir/browser": "^15.4.0",
43
+ "@augment-vir/common": "^15.4.0",
44
44
  "colorjs.io": "0.4.5",
45
- "element-vir": "^14.0.3",
45
+ "element-vir": "^14.2.1",
46
46
  "lit-css-vars": "^2.0.3",
47
47
  "object-shape-tester": "^0.3.0",
48
48
  "spa-router-vir": "^2.1.1",
49
- "typed-event-target": "^1.3.0",
50
- "vira": "^0.6.0"
49
+ "typed-event-target": "^1.3.1",
50
+ "vira": "^0.6.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@augment-vir/browser-testing": "^15.3.0",
53
+ "@augment-vir/browser-testing": "^15.4.0",
54
54
  "@open-wc/testing": "^3.2.0",
55
55
  "@types/chai": "^4.3.5",
56
56
  "@types/mocha": "^10.0.1",
57
57
  "@web/dev-server-esbuild": "^0.4.1",
58
- "@web/test-runner": "^0.16.1",
59
- "@web/test-runner-commands": "^0.7.0",
58
+ "@web/test-runner": "^0.17.0",
59
+ "@web/test-runner-commands": "^0.8.0",
60
60
  "@web/test-runner-playwright": "^0.10.1",
61
- "@web/test-runner-visual-regression": "^0.8.0",
61
+ "@web/test-runner-visual-regression": "^0.8.2",
62
62
  "istanbul-smart-text-reporter": "^1.1.2",
63
- "type-fest": "^3.12.0",
63
+ "type-fest": "^4.0.0",
64
64
  "typescript": "^5.1.6"
65
65
  }
66
66
  }