element-book 8.0.0 → 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.
@@ -10,4 +10,4 @@ export type CurrentControls = {
10
10
  };
11
11
  export declare function traverseCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>): BookPageControlsValues;
12
12
  export declare function createNewCurrentControls(currentControls: CurrentControls, fullUrlBreadcrumbs: ReadonlyArray<string>, newValues: BookPageControlsValues): CurrentControls;
13
- export declare function createControlsFromTree(node: BookTreeNode, globalControls: GlobalValues): 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, globalControls) {
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 {
@@ -54,7 +54,7 @@ export function createControlsFromTree(node, globalControls) {
54
54
  return {
55
55
  children: createControlsFromTree(child, {}),
56
56
  controls: {
57
- ...globalControls,
57
+ ...globalValues,
58
58
  ...mapObjectValues(child.entry.controls, (name, setup) => {
59
59
  return setup.initValue;
60
60
  }),
@@ -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>
@@ -12,7 +12,7 @@ export declare const ElementBookApp: import("element-vir").DeclarativeElementDef
12
12
  colors: ColorThemeState;
13
13
  treeBasedCurrentControls: {
14
14
  entries: ElementBookConfig['entries'];
15
- globalControls: GlobalValues;
15
+ globalValues: GlobalValues;
16
16
  currentControls: CurrentControls;
17
17
  } | undefined;
18
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';
@@ -133,12 +133,12 @@ export const ElementBookApp = defineElement()({
133
133
  });
134
134
  if (!state.treeBasedCurrentControls ||
135
135
  state.treeBasedCurrentControls.entries !== inputs.entries ||
136
- state.treeBasedCurrentControls.globalControls !== inputs.globalControls) {
136
+ state.treeBasedCurrentControls.globalValues !== inputs.globalValues) {
137
137
  updateState({
138
138
  treeBasedCurrentControls: {
139
139
  entries: inputs.entries,
140
- globalControls: inputs.globalControls ?? {},
141
- currentControls: createControlsFromTree(originalTree.tree, inputs.globalControls ?? {}),
140
+ globalValues: inputs.globalValues ?? {},
141
+ currentControls: createControlsFromTree(originalTree.tree, inputs.globalValues ?? {}),
142
142
  },
143
143
  });
144
144
  }
@@ -154,9 +154,9 @@ export const ElementBookApp = defineElement()({
154
154
  const currentControls = state.treeBasedCurrentControls?.currentControls;
155
155
  if (!currentControls) {
156
156
  return html `
157
- <${BookError}
158
- ${assign(BookError, { message: 'Failed to generate page controls.' })}
159
- ></${BookError}>
157
+ <${BookError.assign({
158
+ message: 'Failed to generate page controls.',
159
+ })}></${BookError}>
160
160
  `;
161
161
  }
162
162
  if (inputs.debug) {
@@ -193,30 +193,24 @@ export const ElementBookApp = defineElement()({
193
193
  });
194
194
  })}
195
195
  >
196
- <${BookNav}
197
- ${assign(BookNav, {
196
+ <${BookNav.assign({
198
197
  flattenedNodes: originalTree.flattenedNodes,
199
198
  router: state.router,
200
- selectedPath: searchQuery
201
- ? undefined
202
- : state.currentRoute.paths.slice(1),
203
- })}
204
- >
199
+ selectedPath: searchQuery ? undefined : state.currentRoute.paths.slice(1),
200
+ })}>
205
201
  <slot
206
202
  name=${ElementBookSlotName.NavHeader}
207
203
  slot=${ElementBookSlotName.NavHeader}
208
204
  ></slot>
209
205
  </${BookNav}>
210
- <${BookEntryDisplay}
211
- ${assign(BookEntryDisplay, {
206
+ <${BookEntryDisplay.assign({
212
207
  currentRoute: state.currentRoute,
213
208
  currentNodes,
214
209
  router: state.router,
215
210
  debug,
216
211
  currentControls,
217
212
  originalTree: originalTree.tree,
218
- })}
219
- >
213
+ })}>
220
214
  <slot
221
215
  name=${ElementBookSlotName.Footer}
222
216
  slot=${ElementBookSlotName.Footer}
@@ -13,7 +13,7 @@ type OptionalConfig = {
13
13
  everythingTitle: string;
14
14
  everythingDescriptionParagraphs: ReadonlyArray<string>;
15
15
  debug: boolean;
16
- globalControls: GlobalValues;
16
+ globalValues: GlobalValues;
17
17
  } & RequireExactlyOne<{
18
18
  /**
19
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": "8.0.0",
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
  }