@kekonic/diagrams-element 1.0.0-rc.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kekonic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @kekonic/diagrams-element
2
+
3
+ Lit web components for embedding KDiagram diagrams in any page — no React required.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @kekonic/diagrams-element @kekonic/diagrams
9
+ ```
10
+
11
+ Import the element once in your bundled app:
12
+
13
+ ```ts
14
+ import "@kekonic/diagrams-element";
15
+ ```
16
+
17
+ The component carries its diagram styles. Import `@kekonic/diagrams/theme.css` only for host
18
+ CSS variable overrides. For a no-build HTML page, load the package through an ESM CDN; browsers do
19
+ not resolve bare npm package names or `node_modules` URLs directly.
20
+
21
+ ## `<k-diagram>`
22
+
23
+ ```html
24
+ <k-diagram id="checkout" theme="auto" height="420"></k-diagram>
25
+
26
+ <script type="module">
27
+ const diagram = document.querySelector("#checkout");
28
+ diagram.source = `diagram {
29
+ direction LR
30
+ api: gateway "API"
31
+ checkout: service "Checkout"
32
+ api -> checkout
33
+ }`;
34
+ </script>
35
+ ```
36
+
37
+ Assign multiline source through the JavaScript property rather than escaping it into an HTML
38
+ attribute.
39
+
40
+ ### No-build CDN
41
+
42
+ Import the published package directly in a modern browser:
43
+
44
+ ```html
45
+ <k-diagram id="checkout" theme="auto" height="420"></k-diagram>
46
+
47
+ <script type="module">
48
+ import "https://esm.sh/@kekonic/diagrams-element@x.y.z";
49
+
50
+ const diagram = document.querySelector("#checkout");
51
+ diagram.source = `diagram {
52
+ api: gateway "API"
53
+ checkout: service "Checkout"
54
+ api -> checkout
55
+ }`;
56
+ </script>
57
+ ```
58
+
59
+ Replace `x.y.z` with the package version you have chosen and pin it in CDN URLs. Prefer an installed
60
+ dependency and lockfile for application builds.
61
+
62
+ ### Attributes / properties
63
+
64
+ | Name | Type | Default | Notes |
65
+ | -------------------- | ------------------------------------------- | -------- | -------------------------------------------------- |
66
+ | `source` | string | `""` | KDiagram source. Updates call `controller.update`. |
67
+ | `theme` | `"dark"` \| `"light"` \| `"auto"` \| string | `"auto"` | `"auto"` follows `html[data-theme]`. |
68
+ | `height` | string \| number | `420` | Viewport height (`px` if number). |
69
+ | `frameless` | boolean | `false` | Remove the host border and panel background. |
70
+ | `show-theme-toggle` | boolean | `true` | Set `"false"` to hide. |
71
+ | `show-view-controls` | boolean | `true` | Zoom / fit / fullscreen. |
72
+ | `show-stats` | boolean | `false` | Compact layout stats badge. |
73
+ | `animation-controls` | boolean | `true` | Playback controls when animations exist. |
74
+ | `animation` | string | first | Preferred animation name or ID. |
75
+ | `autoplay` | boolean | `false` | Begin playback after the first render. |
76
+ | `loop` | boolean | `false` | Loop the selected animation. |
77
+
78
+ ### Methods
79
+
80
+ | Method | Notes |
81
+ | ------------------------ | --------------------------------------- |
82
+ | `fit()` | Fit diagram to the viewport |
83
+ | `zoomIn()` / `zoomOut()` | View controls |
84
+ | `resetView()` | Reset pan/zoom |
85
+ | `ready()` | Resolves when the first render finishes |
86
+
87
+ Same controller as `KDiagram.renderToElement` — pan, zoom, and theme swaps without remounting.
88
+ Built-in controls fade after brief pointer or keyboard inactivity, like video-player controls. They
89
+ return on activity and remain visible while a control has keyboard focus.
90
+
91
+ Use `frameless` for a diagram that should sit directly in a page composition. It removes the host
92
+ border and panel background without changing control settings.
93
+
94
+ Docs: [Web component](https://diagrams.kekonic.com/publish/web-component/).
@@ -0,0 +1,129 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from "lit";
2
+ import { InteractiveRenderOptions, InteractiveRenderOptions as InteractiveRenderOptions$1, ThemeMode, ThemeMode as ThemeMode$1 } from "@kekonic/diagrams";
3
+
4
+ //#region src/k-diagram.d.ts
5
+ /**
6
+ * Interactive Kekonic Diagrams diagram as a Lit custom element.
7
+ * Wraps `KDiagram.renderToElement` — pan/zoom, theme, live `source` updates.
8
+ */
9
+ declare class KDiagramElement extends LitElement {
10
+ #private;
11
+ static properties: {
12
+ source: {
13
+ type: StringConstructor;
14
+ };
15
+ theme: {
16
+ type: StringConstructor;
17
+ };
18
+ height: {};
19
+ frameless: {
20
+ type: BooleanConstructor;
21
+ converter: {
22
+ fromAttribute: (value: string | null) => boolean;
23
+ toAttribute: (value: boolean) => "false" | "";
24
+ };
25
+ reflect: boolean;
26
+ };
27
+ showThemeToggle: {
28
+ type: BooleanConstructor;
29
+ attribute: string;
30
+ converter: {
31
+ fromAttribute: (value: string | null) => boolean;
32
+ toAttribute: (value: boolean) => "false" | "";
33
+ };
34
+ };
35
+ showViewControls: {
36
+ type: BooleanConstructor;
37
+ attribute: string;
38
+ converter: {
39
+ fromAttribute: (value: string | null) => boolean;
40
+ toAttribute: (value: boolean) => "false" | "";
41
+ };
42
+ };
43
+ showStats: {
44
+ type: BooleanConstructor;
45
+ attribute: string;
46
+ converter: {
47
+ fromAttribute: (value: string | null) => boolean;
48
+ toAttribute: (value: boolean) => "false" | "";
49
+ };
50
+ };
51
+ showAnimationControls: {
52
+ type: BooleanConstructor;
53
+ attribute: string;
54
+ converter: {
55
+ fromAttribute: (value: string | null) => boolean;
56
+ toAttribute: (value: boolean) => "false" | "";
57
+ };
58
+ };
59
+ autoplay: {
60
+ type: BooleanConstructor;
61
+ converter: {
62
+ fromAttribute: (value: string | null) => boolean;
63
+ toAttribute: (value: boolean) => "false" | "";
64
+ };
65
+ };
66
+ animationLoop: {
67
+ type: BooleanConstructor;
68
+ attribute: string;
69
+ converter: {
70
+ fromAttribute: (value: string | null) => boolean;
71
+ toAttribute: (value: boolean) => "false" | "";
72
+ };
73
+ };
74
+ animation: {
75
+ type: StringConstructor;
76
+ };
77
+ options: {
78
+ attribute: boolean;
79
+ };
80
+ };
81
+ static styles: import("lit").CSSResult;
82
+ source: string;
83
+ theme: ThemeMode$1 | "auto";
84
+ height: string | number;
85
+ /** Remove the host border and panel background for ambient or page-level compositions. */
86
+ frameless: boolean;
87
+ showThemeToggle: boolean;
88
+ showViewControls: boolean;
89
+ showStats: boolean;
90
+ /** Animation chrome when an animation exists (auto or authored). Default on. */
91
+ showAnimationControls: boolean;
92
+ autoplay: boolean;
93
+ animationLoop: boolean;
94
+ /** Preferred authored animation name or id. */
95
+ animation: string;
96
+ options?: Omit<InteractiveRenderOptions$1, "theme">;
97
+ connectedCallback(): void;
98
+ disconnectedCallback(): void;
99
+ firstUpdated(): void;
100
+ updated(changed: PropertyValues): void;
101
+ /** Resolves when the first interactive render finishes. */
102
+ ready(): Promise<void>;
103
+ fit(): void;
104
+ zoomIn(): void;
105
+ zoomOut(): void;
106
+ resetView(): void;
107
+ /** Interactive animation controller (auto path or authored blocks). */
108
+ get animations(): import("@kekonic/diagrams-core").AnimationController | undefined;
109
+ /**
110
+ * Re-apply the current theme name (picks up `registerTheme` token updates
111
+ * even when the theme id is unchanged).
112
+ */
113
+ refreshTheme(): Promise<void>;
114
+ render(): TemplateResult<1>;
115
+ }
116
+ declare global {
117
+ interface HTMLElementTagNameMap {
118
+ "k-diagram": KDiagramElement;
119
+ }
120
+ }
121
+ //#endregion
122
+ //#region src/index.d.ts
123
+ /** Tag name for `<k-diagram>`. */
124
+ declare const K_DIAGRAM_TAG = "k-diagram";
125
+ /** Register `<k-diagram>` (idempotent). Called on package import. */
126
+ declare function registerKDiagramElements(): void;
127
+ //#endregion
128
+ export { type InteractiveRenderOptions, KDiagramElement, K_DIAGRAM_TAG, type ThemeMode, registerKDiagramElements };
129
+ //# sourceMappingURL=index.d.mts.map