element-book 1.0.2 → 1.0.3

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,4 +1,4 @@
1
- import { PropertyInitMapBase, TypedEvent } from 'element-vir';
1
+ import { PropertyInitMapBase, RenderParams, TypedEvent } from 'element-vir';
2
2
  import { CSSResult } from 'lit';
3
3
  export type ElementBookPageExample<StateInit extends PropertyInitMapBase = {}> = {
4
4
  title: string;
@@ -14,9 +14,6 @@ export type ElementBookPageExample<StateInit extends PropertyInitMapBase = {}> =
14
14
  /** Set to true to hide the example controls (example title and buttons). */
15
15
  hideControls?: boolean | undefined;
16
16
  /** Render the example. */
17
- render: (renderParams: {
18
- state: StateInit;
19
- updateState: (newState: Partial<StateInit>) => void;
20
- }) => unknown;
17
+ render: (renderParams: Pick<RenderParams<any, any, StateInit, any, any, any>, 'state' | 'updateState'>) => unknown;
21
18
  };
22
19
  export declare function createExample<StateInit extends PropertyInitMapBase>(example: ElementBookPageExample<StateInit>): ElementBookPageExample<StateInit>;
@@ -2,6 +2,4 @@ import { ElementBookPageExample } from '../../../data/element-book-entry/element
2
2
  export declare const ElementBookExampleViewer: import("element-vir").DeclarativeElementDefinition<"element-book-example-viewer", {
3
3
  example: ElementBookPageExample;
4
4
  breadcrumbs: ReadonlyArray<string>;
5
- }, {
6
- internalState: any;
7
- }, {}, string, string, string | import("lit-html").HTMLTemplateResult>;
5
+ }, any, {}, string, string, string | import("lit-html").HTMLTemplateResult>;
@@ -5,23 +5,19 @@ const unsetInternalState = Symbol('unset-internal-state');
5
5
  export const ElementBookExampleViewer = defineElementBookElement()({
6
6
  tagName: 'element-book-example-viewer',
7
7
  stateInit: {
8
- internalState: unsetInternalState,
8
+ isUnset: unsetInternalState,
9
9
  },
10
10
  renderCallback({ state, inputs, updateState }) {
11
- if (state.internalState === unsetInternalState) {
12
- updateState({ internalState: inputs.example.stateInit });
11
+ if (state.isUnset === unsetInternalState) {
12
+ updateState({
13
+ isUnset: undefined,
14
+ ...inputs.example.stateInit,
15
+ });
13
16
  }
14
17
  try {
15
18
  const output = inputs.example.render({
16
- state: state.internalState,
17
- updateState: (newState) => {
18
- updateState({
19
- internalState: {
20
- ...state.internalState,
21
- ...newState,
22
- },
23
- });
24
- },
19
+ state,
20
+ updateState,
25
21
  });
26
22
  return html `
27
23
  ${renderIf(!!inputs.example.styles, html `
@@ -37,4 +33,7 @@ export const ElementBookExampleViewer = defineElementBookElement()({
37
33
  return `${inputs.breadcrumbs.join(' > ')} failed: ${extractErrorMessage(error)}`;
38
34
  }
39
35
  },
36
+ options: {
37
+ allowPolymorphicState: true,
38
+ },
40
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-book",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "keywords": [
5
5
  "book",
6
6
  "design system",
@@ -38,16 +38,16 @@
38
38
  "test:types": "tsc --noEmit"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/common": "^13.4.0",
41
+ "@augment-vir/common": "^14.2.0",
42
42
  "@electrovir/icon-element": "^0.0.2",
43
43
  "colorjs.io": "^0.4.3",
44
- "element-vir": "^12.4.6",
44
+ "element-vir": "^12.5.2",
45
45
  "lit-css-vars": "^2.0.2",
46
46
  "spa-router-vir": "^2.1.0",
47
47
  "typed-event-target": "^1.2.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@augment-vir/browser-testing": "^13.4.0",
50
+ "@augment-vir/browser-testing": "^14.2.0",
51
51
  "@open-wc/testing": "^3.1.8",
52
52
  "@types/mocha": "^10.0.1",
53
53
  "@web/dev-server-esbuild": "^0.4.1",
@@ -56,7 +56,7 @@
56
56
  "@web/test-runner-playwright": "^0.10.0",
57
57
  "@web/test-runner-visual-regression": "^0.8.0",
58
58
  "istanbul-smart-text-reporter": "^1.1.1",
59
- "type-fest": "^3.10.0",
59
+ "type-fest": "^3.11.0",
60
60
  "typescript": "^5.0.4"
61
61
  }
62
62
  }