@storybook/web-components 11.0.0-alpha.6 → 11.0.0-alpha.8
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/dist/_browser-chunks/{chunk-TXUT6K6E.js → chunk-4CVRUPXU.js} +9 -6
- package/dist/_browser-chunks/{chunk-BNL7LBNI.js → chunk-XOX44XZE.js} +18 -11
- package/dist/_node-chunks/{chunk-X7F7EONQ.js → chunk-7DGX2RHV.js} +527 -117
- package/dist/_node-chunks/chunk-A2ZEEPU6.js +76 -0
- package/dist/docgen/docgen-worker.js +8 -8
- package/dist/docgen/index.d.ts +13 -15
- package/dist/docgen/index.js +8 -11
- package/dist/entry-preview-argtypes.js +7 -5
- package/dist/entry-preview.js +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +2 -2
- package/dist/preset.js +131 -559
- package/package.json +7 -4
- package/template/stories_lit-vite-default-ts/demo-wc-counter/DemoWcCounter.js +176 -0
- package/template/stories_lit-vite-default-ts/demo-wc-counter/index.js +3 -0
- package/template/stories_lit-vite-default-ts/demo-wc-counter.stories.js +217 -0
- package/dist/_node-chunks/chunk-GDY64HEP.js +0 -87
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
entry_preview_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XOX44XZE.js";
|
|
4
4
|
import {
|
|
5
5
|
entry_preview_docs_exports
|
|
6
6
|
} from "./chunk-EGBR6PF2.js";
|
|
@@ -15,6 +15,8 @@ globalWindow.STORYBOOK_ENV = "web-components";
|
|
|
15
15
|
|
|
16
16
|
// src/framework-api.ts
|
|
17
17
|
import { global as global2 } from "@storybook/global";
|
|
18
|
+
import { deprecate } from "storybook/internal/client-logger";
|
|
19
|
+
var RUNTIME_MANIFEST_DEPRECATION = "The runtime Custom Elements Manifest is deprecated and will be removed in Storybook 12. Set framework.options.customElementsManifest in .storybook/main and enable features.docgenServer instead.";
|
|
18
20
|
function isValidComponent(tagName) {
|
|
19
21
|
if (!tagName)
|
|
20
22
|
return !1;
|
|
@@ -27,17 +29,18 @@ function isValidMetaData(customElements) {
|
|
|
27
29
|
return !1;
|
|
28
30
|
if (customElements.tags && Array.isArray(customElements.tags) || customElements.modules && Array.isArray(customElements.modules))
|
|
29
31
|
return !0;
|
|
30
|
-
throw new Error(
|
|
31
|
-
|
|
32
|
+
throw new Error(
|
|
33
|
+
"You need to set up valid Custom Elements metadata with a manifest generated by @custom-elements-manifest/analyzer. Configure it with framework.options.customElementsManifest in .storybook/main."
|
|
34
|
+
);
|
|
32
35
|
}
|
|
33
36
|
function setCustomElements(customElements) {
|
|
34
|
-
global2.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
37
|
+
deprecate(`setCustomElements() is deprecated: ${RUNTIME_MANIFEST_DEPRECATION}`), global2.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
35
38
|
}
|
|
36
39
|
function setCustomElementsManifest(customElements) {
|
|
37
|
-
global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
40
|
+
deprecate(`setCustomElementsManifest() is deprecated: ${RUNTIME_MANIFEST_DEPRECATION}`), global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
38
41
|
}
|
|
39
42
|
function getCustomElements() {
|
|
40
|
-
return global2.
|
|
43
|
+
return global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ || global2.__STORYBOOK_CUSTOM_ELEMENTS__;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// src/portable-stories.ts
|
|
@@ -27,6 +27,7 @@ function parseArgKey(key) {
|
|
|
27
27
|
return { category, name: key.slice(0, -suffix.length) };
|
|
28
28
|
}
|
|
29
29
|
var ARG_KEY_SUFFIXES = {
|
|
30
|
+
attributes: "-attr",
|
|
30
31
|
events: "-event",
|
|
31
32
|
methods: "-method",
|
|
32
33
|
slots: "-slot",
|
|
@@ -36,6 +37,9 @@ var ARG_KEY_SUFFIXES = {
|
|
|
36
37
|
|
|
37
38
|
// src/bind-args.ts
|
|
38
39
|
var BINDERS = {
|
|
40
|
+
attributes: (element, name, value) => {
|
|
41
|
+
bindPrimitiveAttribute(element, name, value);
|
|
42
|
+
},
|
|
39
43
|
events: (element, name, value) => {
|
|
40
44
|
typeof value == "function" && element.addEventListener(name, value);
|
|
41
45
|
},
|
|
@@ -48,6 +52,8 @@ var BINDERS = {
|
|
|
48
52
|
function bindArgs(element, args) {
|
|
49
53
|
let observedAttributes = observedAttributesOf(element), styleRules = [];
|
|
50
54
|
for (let [key, value] of Object.entries(args)) {
|
|
55
|
+
if (value == null)
|
|
56
|
+
continue;
|
|
51
57
|
let parsedKey = parseArgKey(key);
|
|
52
58
|
if (parsedKey?.category === "cssProperties") {
|
|
53
59
|
bindCssCustomProperty(element, key, value);
|
|
@@ -57,16 +63,14 @@ function bindArgs(element, args) {
|
|
|
57
63
|
assignProperty(element, key, value);
|
|
58
64
|
continue;
|
|
59
65
|
}
|
|
60
|
-
if (observedAttributes.has(key) &&
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
continue;
|
|
66
|
+
if (!(observedAttributes.has(key) && bindPrimitiveAttribute(element, key, value))) {
|
|
67
|
+
if (parsedKey) {
|
|
68
|
+
let rule = BINDERS[parsedKey.category](element, parsedKey.name, value);
|
|
69
|
+
rule && styleRules.push(rule);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
assignProperty(element, key, value);
|
|
68
73
|
}
|
|
69
|
-
assignProperty(element, key, value);
|
|
70
74
|
}
|
|
71
75
|
return styleRules;
|
|
72
76
|
}
|
|
@@ -83,6 +87,9 @@ function isUnset(value) {
|
|
|
83
87
|
function assignProperty(element, key, value) {
|
|
84
88
|
element[key] = value;
|
|
85
89
|
}
|
|
90
|
+
function bindPrimitiveAttribute(element, name, value) {
|
|
91
|
+
return isPrimitive(value) ? (bindAttribute(element, name, value), !0) : !1;
|
|
92
|
+
}
|
|
86
93
|
function bindAttribute(element, name, value) {
|
|
87
94
|
isUnset(value) || value === !1 || element.setAttribute(name, value === !0 ? "" : String(value));
|
|
88
95
|
}
|
|
@@ -137,7 +144,7 @@ var { Node: Node2 } = global, render = (args, context) => {
|
|
|
137
144
|
}
|
|
138
145
|
return fragment.append(element), fragment;
|
|
139
146
|
};
|
|
140
|
-
function renderToCanvas({ storyFn,
|
|
147
|
+
function renderToCanvas({ storyFn, title, name, showMain, showError, forceRemount }, canvasElement) {
|
|
141
148
|
let element = storyFn();
|
|
142
149
|
if (showMain(), isTemplateResult(element)) {
|
|
143
150
|
(forceRemount || !canvasElement.querySelector('[id="root-inner"]')) && (canvasElement.innerHTML = '<div id="root-inner"></div>');
|
|
@@ -151,7 +158,7 @@ function renderToCanvas({ storyFn, kind, name, showMain, showError, forceRemount
|
|
|
151
158
|
canvasElement.innerHTML = "", canvasElement.appendChild(element), simulateDOMContentLoaded();
|
|
152
159
|
} else
|
|
153
160
|
showError({
|
|
154
|
-
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${
|
|
161
|
+
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${title}".`,
|
|
155
162
|
description: dedent`
|
|
156
163
|
Did you forget to return the HTML snippet from the story?
|
|
157
164
|
Use "() => <your snippet or node>" or when defining the story.
|