element-book 23.4.2 → 24.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.
- package/README.md +2 -2
- package/dist/data/book-entry/book-page/book-page.d.ts +9 -6
- package/dist/data/book-entry/book-page/define-book-page.d.ts +1 -1
- package/dist/routing/book-routing.d.ts +2 -2
- package/dist/ui/elements/define-book-element.d.ts +1 -1
- package/dist/ui/elements/element-book-app/element-book-app.element.d.ts +1 -1
- package/dist/ui/elements/element-book-app/element-book-app.element.js +13 -11
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js +5 -3
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.js +5 -3
- package/dist/ui/events/change-route.event.d.ts +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ npm i element-book
|
|
|
10
10
|
|
|
11
11
|
## Terminology
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
13
|
+
- **Page**: a group of pages and / or element examples. Pages can be infinitely nested.
|
|
14
|
+
- **Element Example**: an individual element example with independent state, styles, title, etc.
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
@@ -25,7 +25,7 @@ export type BookPage<GlobalValuesType extends GlobalValues = {}, ParentPage exte
|
|
|
25
25
|
*
|
|
26
26
|
* @category Internal
|
|
27
27
|
*/
|
|
28
|
-
export type BookPageExampleRenderParams<GlobalValuesType extends GlobalValues, ControlsInit extends BookPageControlsInitBase,
|
|
28
|
+
export type BookPageExampleRenderParams<GlobalValuesType extends GlobalValues, ControlsInit extends BookPageControlsInitBase, State extends PropertyInitMapBase> = Pick<RenderParams<any, any, State, any, any, any, any>, 'state' | 'updateState'> & {
|
|
29
29
|
controls: ControlsToValues<ControlsInit> & GlobalValuesType;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
@@ -33,12 +33,15 @@ export type BookPageExampleRenderParams<GlobalValuesType extends GlobalValues, C
|
|
|
33
33
|
*
|
|
34
34
|
* @category Internal
|
|
35
35
|
*/
|
|
36
|
-
export type BookElementExample<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = {},
|
|
36
|
+
export type BookElementExample<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = {}, State extends PropertyInitMapBase = {}> = Overwrite<BaseBookEntry, {
|
|
37
37
|
parent: BookPage | undefined;
|
|
38
38
|
entryType: BookEntryType.ElementExample;
|
|
39
39
|
} & {
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the state for this example. This is only called once, before the first render
|
|
42
|
+
* of the example.
|
|
43
|
+
*/
|
|
44
|
+
state?: (() => State) | undefined;
|
|
42
45
|
/** Specify which events this example should intercept (so the user can see them). */
|
|
43
46
|
showEvents?: ReadonlyArray<string | TypedEvent> | undefined;
|
|
44
47
|
/**
|
|
@@ -47,7 +50,7 @@ export type BookElementExample<GlobalValuesType extends GlobalValues = {}, Contr
|
|
|
47
50
|
*/
|
|
48
51
|
styles?: CSSResult | undefined;
|
|
49
52
|
/** Render the example. */
|
|
50
|
-
render: (renderParams: BookPageExampleRenderParams<GlobalValuesType, ControlsInit,
|
|
53
|
+
render: (renderParams: BookPageExampleRenderParams<GlobalValuesType, ControlsInit, State>) => HtmlInterpolation;
|
|
51
54
|
}>;
|
|
52
55
|
/**
|
|
53
56
|
* The properties that are necessary to initialize an element example. Missing properties will be
|
|
@@ -55,4 +58,4 @@ export type BookElementExample<GlobalValuesType extends GlobalValues = {}, Contr
|
|
|
55
58
|
*
|
|
56
59
|
* @category Internal
|
|
57
60
|
*/
|
|
58
|
-
export type BookElementExampleInit<GlobalValuesType extends GlobalValues, Controls extends BookPageControlsInitBase,
|
|
61
|
+
export type BookElementExampleInit<GlobalValuesType extends GlobalValues, Controls extends BookPageControlsInitBase, State extends PropertyInitMapBase> = SetOptionalAndNullable<Omit<BookElementExample<GlobalValuesType, Controls, State>, 'entryType' | 'parent' | 'errors'>, 'descriptionParagraphs'>;
|
|
@@ -10,7 +10,7 @@ import { BookElementExampleInit, BookPage } from './book-page.js';
|
|
|
10
10
|
*
|
|
11
11
|
* @category Internal
|
|
12
12
|
*/
|
|
13
|
-
export type DefineExampleCallback<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = <
|
|
13
|
+
export type DefineExampleCallback<GlobalValuesType extends GlobalValues = {}, ControlsInit extends BookPageControlsInitBase = BookPageControlsInitBase> = <State extends PropertyInitMapBase>(exampleInit: BookElementExampleInit<GlobalValuesType, ControlsInit, State>) => void;
|
|
14
14
|
/**
|
|
15
15
|
* Used for `defineExamples` in a book page's init.
|
|
16
16
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FullSpaRoute } from 'spa-router-vir';
|
|
2
2
|
/**
|
|
3
3
|
* Top level routes supported by the element-book app.
|
|
4
4
|
*
|
|
@@ -19,7 +19,7 @@ export type ValidBookPaths = [BookMainRoute.Search, string] | [BookMainRoute.Boo
|
|
|
19
19
|
*
|
|
20
20
|
* @category Internal
|
|
21
21
|
*/
|
|
22
|
-
export type BookFullRoute =
|
|
22
|
+
export type BookFullRoute = Readonly<FullSpaRoute<ValidBookPaths, undefined, undefined>>;
|
|
23
23
|
/**
|
|
24
24
|
* Extract the current search query from the current route paths.
|
|
25
25
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type BookTagName = `book-${string}`;
|
|
2
|
-
export declare const defineBookElement: <Inputs extends {}>() => <const TagName extends `book-${string}`,
|
|
2
|
+
export declare const defineBookElement: <Inputs extends {}>(...errorParams: import("element-vir").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `book-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>, defineBookElementNoInputs: <const TagName extends `book-${string}`, Inputs extends {}, State extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
|
|
@@ -20,7 +20,7 @@ export type ColorThemeState = {
|
|
|
20
20
|
* @category Main
|
|
21
21
|
*/
|
|
22
22
|
export declare const ElementBookApp: import("element-vir").DeclarativeElementDefinition<"element-book-app", ElementBookConfig, {
|
|
23
|
-
currentRoute: Readonly<Required<
|
|
23
|
+
currentRoute: Readonly<Readonly<Required<import("spa-router-vir").SpaRoute<import("../../../routing/book-routing.js").ValidBookPaths, undefined, undefined>>>>;
|
|
24
24
|
router: undefined | BookRouter;
|
|
25
25
|
loading: boolean;
|
|
26
26
|
colors: ColorThemeState;
|
|
@@ -24,20 +24,22 @@ import { getCurrentNodes } from './get-current-nodes.js';
|
|
|
24
24
|
*/
|
|
25
25
|
export const ElementBookApp = defineElement()({
|
|
26
26
|
tagName: 'element-book-app',
|
|
27
|
+
state() {
|
|
28
|
+
return {
|
|
29
|
+
currentRoute: defaultBookFullRoute,
|
|
30
|
+
router: undefined,
|
|
31
|
+
loading: true,
|
|
32
|
+
colors: {
|
|
33
|
+
config: undefined,
|
|
34
|
+
theme: createTheme(undefined),
|
|
35
|
+
},
|
|
36
|
+
treeBasedControls: undefined,
|
|
37
|
+
originalWindowTitle: undefined,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
27
40
|
events: {
|
|
28
41
|
pathUpdate: defineElementEvent(),
|
|
29
42
|
},
|
|
30
|
-
stateInitStatic: {
|
|
31
|
-
currentRoute: defaultBookFullRoute,
|
|
32
|
-
router: undefined,
|
|
33
|
-
loading: true,
|
|
34
|
-
colors: {
|
|
35
|
-
config: undefined,
|
|
36
|
-
theme: createTheme(undefined),
|
|
37
|
-
},
|
|
38
|
-
treeBasedControls: undefined,
|
|
39
|
-
originalWindowTitle: undefined,
|
|
40
|
-
},
|
|
41
43
|
styles: css `
|
|
42
44
|
:host {
|
|
43
45
|
display: flex;
|
package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js
CHANGED
|
@@ -5,8 +5,10 @@ import { BookError } from '../../common/book-error.element.js';
|
|
|
5
5
|
import { defineBookElement } from '../../define-book-element.js';
|
|
6
6
|
export const BookElementExampleViewer = defineBookElement()({
|
|
7
7
|
tagName: 'book-element-example-viewer',
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
state() {
|
|
9
|
+
return {
|
|
10
|
+
isUnset: unsetInternalState,
|
|
11
|
+
};
|
|
10
12
|
},
|
|
11
13
|
render({ state, inputs, updateState }) {
|
|
12
14
|
try {
|
|
@@ -23,7 +25,7 @@ export const BookElementExampleViewer = defineBookElement()({
|
|
|
23
25
|
if (state.isUnset === unsetInternalState) {
|
|
24
26
|
updateState({
|
|
25
27
|
isUnset: undefined,
|
|
26
|
-
...inputs.elementExampleNode.entry.
|
|
28
|
+
...inputs.elementExampleNode.entry.state?.(),
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
const output = inputs.elementExampleNode.entry.render({
|
|
@@ -7,6 +7,11 @@ import { BookBreadcrumbsBar } from '../book-breadcrumbs-bar.element.js';
|
|
|
7
7
|
import { createNodeTemplates } from './create-node-templates.js';
|
|
8
8
|
export const BookEntryDisplay = defineBookElement()({
|
|
9
9
|
tagName: 'book-entry-display',
|
|
10
|
+
state() {
|
|
11
|
+
return {
|
|
12
|
+
lastElement: undefined,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
10
15
|
styles: css `
|
|
11
16
|
:host {
|
|
12
17
|
display: flex;
|
|
@@ -67,9 +72,6 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
67
72
|
events: {
|
|
68
73
|
loadingRender: defineElementEvent(),
|
|
69
74
|
},
|
|
70
|
-
stateInitStatic: {
|
|
71
|
-
lastElement: undefined,
|
|
72
|
-
},
|
|
73
75
|
render: ({ inputs, dispatch, events, state, updateState }) => {
|
|
74
76
|
const currentSearch = extractSearchQuery(inputs.currentRoute.paths);
|
|
75
77
|
const entryTemplates = createNodeTemplates({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ChangeRouteEvent: import("element-vir").DefinedTypedEvent<"element-book-change-route", Partial<Required<
|
|
1
|
+
export declare const ChangeRouteEvent: import("element-vir").DefinedTypedEvent<"element-book-change-route", Partial<Readonly<Required<import("spa-router-vir").SpaRoute<import("../../routing/book-routing.js").ValidBookPaths, undefined, undefined>>>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-book",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"book",
|
|
6
6
|
"design system",
|
|
@@ -41,28 +41,28 @@
|
|
|
41
41
|
"test:docs": "virmator docs check"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@augment-vir/assert": "^31.
|
|
45
|
-
"@augment-vir/common": "^31.
|
|
46
|
-
"@augment-vir/web": "^31.
|
|
44
|
+
"@augment-vir/assert": "^31.10.0",
|
|
45
|
+
"@augment-vir/common": "^31.10.0",
|
|
46
|
+
"@augment-vir/web": "^31.10.0",
|
|
47
47
|
"colorjs.io": "0.5.2",
|
|
48
48
|
"lit-css-vars": "^3.0.11",
|
|
49
|
-
"spa-router-vir": "^
|
|
50
|
-
"typed-event-target": "^4.0.
|
|
51
|
-
"vira": "^
|
|
49
|
+
"spa-router-vir": "^5.3.1",
|
|
50
|
+
"typed-event-target": "^4.0.3",
|
|
51
|
+
"vira": "^24.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@augment-vir/test": "^31.
|
|
54
|
+
"@augment-vir/test": "^31.10.0",
|
|
55
55
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
56
56
|
"@web/test-runner": "^0.20.0",
|
|
57
57
|
"@web/test-runner-commands": "^0.9.0",
|
|
58
58
|
"@web/test-runner-playwright": "^0.11.0",
|
|
59
59
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
60
|
-
"element-vir": "^
|
|
60
|
+
"element-vir": "^24.0.0",
|
|
61
61
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
62
62
|
"markdown-code-example-inserter": "^3.0.3",
|
|
63
|
-
"type-fest": "^4.
|
|
63
|
+
"type-fest": "^4.37.0",
|
|
64
64
|
"typedoc": "^0.27.9",
|
|
65
|
-
"typescript": "5.
|
|
65
|
+
"typescript": "5.8.2"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"element-vir": ">=17"
|