@vueless/storybook 0.0.60 → 0.0.62
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,12 +1,30 @@
|
|
|
1
1
|
import { addons, useArgs, makeDecorator } from "@storybook/preview-api";
|
|
2
2
|
import { h, onMounted, watch } from "vue";
|
|
3
3
|
|
|
4
|
+
const params = new URLSearchParams(window.location.search);
|
|
5
|
+
let previousStoryId = null;
|
|
6
|
+
|
|
7
|
+
function getArgsFromUrl(storyId) {
|
|
8
|
+
const isInIframe = params.toString().includes("globals=");
|
|
9
|
+
const isSameComponent = parseInt(previousStoryId) === parseInt(storyId);
|
|
10
|
+
|
|
11
|
+
if (isInIframe || isSameComponent || previousStoryId === null) {
|
|
12
|
+
return parseKeyValuePairs(params.get("args"));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
params.delete("args");
|
|
16
|
+
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
|
|
4
20
|
export const vue3SourceDecorator = makeDecorator({
|
|
5
21
|
name: "vue3SourceDecorator",
|
|
6
22
|
wrapper: (storyFn, context) => {
|
|
7
23
|
const story = storyFn(context);
|
|
8
|
-
const urlArgs = getArgsFromUrl();
|
|
9
24
|
const [, updateArgs] = useArgs();
|
|
25
|
+
const urlArgs = getArgsFromUrl(context.id);
|
|
26
|
+
|
|
27
|
+
previousStoryId = context.id;
|
|
10
28
|
|
|
11
29
|
// this returns a new component that computes the source code when mounted
|
|
12
30
|
// and emits an events that is handled by addons-docs
|
|
@@ -137,16 +155,8 @@ function kebabCase(str) {
|
|
|
137
155
|
.join("");
|
|
138
156
|
}
|
|
139
157
|
|
|
140
|
-
function getArgsFromUrl() {
|
|
141
|
-
const params = new URLSearchParams(window.location.search);
|
|
142
|
-
const args = params.get("args");
|
|
143
|
-
|
|
144
|
-
if (!args) return {};
|
|
145
|
-
|
|
146
|
-
return parseKeyValuePairs(args);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
158
|
function parseKeyValuePairs(input) {
|
|
159
|
+
input = input || "";
|
|
150
160
|
const result = {};
|
|
151
161
|
|
|
152
162
|
// Split key-value pairs and parse them
|
package/.storybook/index.css
CHANGED