element-book 0.0.8 → 0.0.9

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,7 +1,7 @@
1
1
  import { ElementBookPageExample } from '../../../data/element-book-entry/element-book-page/element-book-page-example';
2
2
  export declare const ElementBookExampleViewer: import("element-vir").DeclarativeElementDefinition<"element-book-example-viewer", {
3
3
  example: ElementBookPageExample;
4
- parentBreadcrumbs: ReadonlyArray<string>;
4
+ breadcrumbs: ReadonlyArray<string>;
5
5
  }, {
6
6
  internalState: any;
7
7
  }, {}, string, string, string | import("lit-html").HTMLTemplateResult, undefined>;
@@ -8,7 +8,6 @@ export const ElementBookExampleViewer = defineElementBookElement()({
8
8
  internalState: unsetInternalState,
9
9
  },
10
10
  renderCallback({ state, inputs, updateState }) {
11
- const fullExampleBreadcrumbs = inputs.parentBreadcrumbs.concat(inputs.example.title);
12
11
  if (state.internalState === unsetInternalState) {
13
12
  updateState({ internalState: inputs.example.stateInit });
14
13
  }
@@ -35,7 +34,7 @@ export const ElementBookExampleViewer = defineElementBookElement()({
35
34
  }
36
35
  catch (error) {
37
36
  console.error(error);
38
- return `${fullExampleBreadcrumbs.join(' > ')} failed: ${extractErrorMessage(error)}`;
37
+ return `${inputs.breadcrumbs.join(' > ')} failed: ${extractErrorMessage(error)}`;
39
38
  }
40
39
  },
41
40
  });
@@ -2,4 +2,4 @@ import { ElementBookPage } from '../../../data/element-book-entry/element-book-p
2
2
  export declare const ElementBookPageExamples: import("element-vir").DeclarativeElementDefinition<"element-book-page-examples", {
3
3
  page: ElementBookPage;
4
4
  parentBreadcrumbs: ReadonlyArray<string>;
5
- }, {}, {}, string, string, import("lit-html").HTMLTemplateResult[], undefined>;
5
+ }, {}, {}, string, string, unknown, undefined>;
@@ -1,4 +1,4 @@
1
- import { assign, classMap, css, html, renderIf } from 'element-vir';
1
+ import { assign, classMap, css, html, renderIf, repeat } from 'element-vir';
2
2
  import { defineElementBookElement } from '../define-book-element';
3
3
  import { ElementBookExampleControls } from './element-book-example-controls.element';
4
4
  import { ElementBookExampleViewer } from './element-book-example-viewer.element';
@@ -24,23 +24,28 @@ export const ElementBookPageExamples = defineElementBookElement()({
24
24
  renderCallback({ inputs }) {
25
25
  const examples = inputs.page.examples;
26
26
  const allControlsHidden = examples.every((example) => example.hideControls);
27
- return examples.map((example) => {
27
+ /**
28
+ * Use the repeat directive here, instead of just a map, so that lit doesn't accidentally
29
+ * keep state cached between element book pages.
30
+ */
31
+ return repeat(examples, (example) => inputs.parentBreadcrumbs.concat(example.title).join('>'), (example) => {
32
+ const exampleBreadcrumbs = inputs.parentBreadcrumbs.concat(example.title);
28
33
  return html `
29
- <div class="individual-example-wrapper">
30
- ${renderIf(!allControlsHidden, html `
31
- <${ElementBookExampleControls}
32
- class=${classMap({ 'hidden-controls': !!example.hideControls })}
33
- ${assign(ElementBookExampleControls, { example })}
34
- ></${ElementBookExampleControls}>
35
- `)}
36
- <${ElementBookExampleViewer}
37
- ${assign(ElementBookExampleViewer, {
34
+ <div class="individual-example-wrapper">
35
+ ${renderIf(!allControlsHidden, html `
36
+ <${ElementBookExampleControls}
37
+ class=${classMap({ 'hidden-controls': !!example.hideControls })}
38
+ ${assign(ElementBookExampleControls, { example })}
39
+ ></${ElementBookExampleControls}>
40
+ `)}
41
+ <${ElementBookExampleViewer}
42
+ ${assign(ElementBookExampleViewer, {
38
43
  example,
39
- parentBreadcrumbs: inputs.parentBreadcrumbs,
44
+ breadcrumbs: exampleBreadcrumbs,
40
45
  })}
41
- ></${ElementBookExampleViewer}>
42
- </div>
43
- `;
46
+ ></${ElementBookExampleViewer}>
47
+ </div>
48
+ `;
44
49
  });
45
50
  },
46
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-book",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "keywords": [
5
5
  "book",
6
6
  "design system",