storybook 10.1.0-alpha.1 → 10.1.0-alpha.11
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/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/chunk-BE2DAXKJ.js +2966 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/chunk-L4RMQ7D7.js +223 -0
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
- package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-DK2ODWXH.js → syntaxhighlighter-WKBQ5RC7.js} +707 -1851
- package/dist/_node-chunks/{builder-manager-6UBDPV7P.js → builder-manager-PMPHOSM2.js} +495 -1013
- package/dist/_node-chunks/camelcase-K3IOOFQW.js +18 -0
- package/dist/_node-chunks/{chunk-QNUGJO6L.js → chunk-32NE3UE3.js} +15 -24
- package/dist/_node-chunks/chunk-4GZCFQFG.js +58 -0
- package/dist/_node-chunks/chunk-5QK5MSOI.js +943 -0
- package/dist/_node-chunks/{chunk-3FPF5Y2F.js → chunk-6ZOLETQK.js} +8 -10
- package/dist/_node-chunks/chunk-7I22Y76Z.js +1047 -0
- package/dist/_node-chunks/chunk-AKTRSR3O.js +72 -0
- package/dist/_node-chunks/chunk-BBOP3XCK.js +119 -0
- package/dist/_node-chunks/chunk-C2GQVDWI.js +34 -0
- package/dist/_node-chunks/{chunk-SCTKVDWR.js → chunk-GG2WQZSG.js} +4619 -7350
- package/dist/_node-chunks/chunk-GQJOWVVR.js +3214 -0
- package/dist/_node-chunks/chunk-JCRM2YVK.js +3009 -0
- package/dist/_node-chunks/chunk-KK4AT5F3.js +1029 -0
- package/dist/_node-chunks/chunk-L7MYXJUM.js +1114 -0
- package/dist/_node-chunks/{chunk-LAU7VVPC.js → chunk-LCZO45L7.js} +469 -983
- package/dist/_node-chunks/chunk-LR3QITDI.js +209 -0
- package/dist/_node-chunks/chunk-LXG4DK35.js +3171 -0
- package/dist/_node-chunks/chunk-MJ3WOS6F.js +37 -0
- package/dist/_node-chunks/chunk-PHOZWZZO.js +61 -0
- package/dist/_node-chunks/chunk-QECOQWRJ.js +936 -0
- package/dist/_node-chunks/chunk-QH4V5YDB.js +20 -0
- package/dist/_node-chunks/chunk-R6HWGZWD.js +26 -0
- package/dist/_node-chunks/chunk-SPQXMU2Q.js +759 -0
- package/dist/_node-chunks/chunk-TXZY6V6O.js +1564 -0
- package/dist/_node-chunks/chunk-UGDPX5LE.js +756 -0
- package/dist/_node-chunks/chunk-UY26MQLT.js +603 -0
- package/dist/_node-chunks/chunk-WK3EMYK6.js +61 -0
- package/dist/_node-chunks/{chunk-CJHAP7SE.js → chunk-WLHMN7AP.js} +292 -688
- package/dist/_node-chunks/chunk-XGVLB4UJ.js +54 -0
- package/dist/_node-chunks/{chunk-J7N7PD5Q.js → chunk-YHRFI6BE.js} +87 -227
- package/dist/_node-chunks/chunk-YK4KVMFW.js +18 -0
- package/dist/_node-chunks/chunk-ZZALGOA6.js +4523 -0
- package/dist/_node-chunks/chunk-ZZPBSYA5.js +301 -0
- package/dist/_node-chunks/chunk-ZZSRFAC6.js +45571 -0
- package/dist/_node-chunks/dist-4DWOCZUD.js +121 -0
- package/dist/_node-chunks/globby-AAARUKEU.js +3452 -0
- package/dist/_node-chunks/lib-HEUKGL62.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-DCVRPS6N.js +14329 -0
- package/dist/_node-chunks/p-limit-F5ZKJ6WZ.js +116 -0
- package/dist/_node-chunks/plugin-7YY7JXCH.js +123 -0
- package/dist/_node-chunks/{plugin-HJLCLGNT.js → plugin-SZP3CW6W.js} +36 -56
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-TGKNDPO6.js +46623 -0
- package/dist/_node-chunks/webpack-mock-plugin-LNTZZFBE.js +92 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +592 -1546
- package/dist/bin/dispatcher.js +26 -37
- package/dist/bin/loader.js +23 -34
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.js +1966 -5347
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +210 -3
- package/dist/common/index.js +28 -20
- package/dist/components/index.d.ts +472 -280
- package/dist/components/index.js +15992 -75
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.js +3837 -7191
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2511 -5219
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +434 -924
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
- package/dist/csf/index.js +534 -1172
- package/dist/csf-tools/index.d.ts +15 -4
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +47968 -56484
- package/dist/manager/globals.js +2 -3
- package/dist/manager/runtime.js +4901 -10318
- package/dist/manager-api/index.d.ts +11 -3
- package/dist/manager-api/index.js +1250 -2397
- package/dist/manager-errors.d.ts +3 -0
- package/dist/manager-errors.js +3 -3
- package/dist/node-logger/index.d.ts +1 -1
- package/dist/node-logger/index.js +1270 -2593
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10767 -22386
- package/dist/preview-api/index.d.ts +67 -68
- package/dist/preview-api/index.js +15 -15
- package/dist/preview-errors.d.ts +3 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +3 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.js +24 -24
- package/dist/test/index.js +6129 -11914
- package/dist/theming/create.d.ts +4 -2
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3397 -2628
- package/dist/theming/index.js +502 -1091
- package/dist/types/index.d.ts +50 -5
- package/dist/types/index.js +2 -11
- package/dist/viewport/index.js +3 -3
- package/package.json +17 -9
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-C4XOKMDU.js +0 -270
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-I74EUU5O.js +0 -5809
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-W4QKLQSC.js +0 -4182
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-WKJOVNPM.js +0 -18
- package/dist/_node-chunks/chunk-2RIKHYCS.js +0 -304
- package/dist/_node-chunks/chunk-3JCSHYSU.js +0 -1657
- package/dist/_node-chunks/chunk-4GE6Q4MX.js +0 -1531
- package/dist/_node-chunks/chunk-5SEHHENC.js +0 -64656
- package/dist/_node-chunks/chunk-6GD23U64.js +0 -420
- package/dist/_node-chunks/chunk-6OAXYS5T.js +0 -1544
- package/dist/_node-chunks/chunk-7TNUMFKR.js +0 -4741
- package/dist/_node-chunks/chunk-BCDHUXAJ.js +0 -4272
- package/dist/_node-chunks/chunk-BYVQZ2HU.js +0 -220
- package/dist/_node-chunks/chunk-DAMVKHAC.js +0 -101
- package/dist/_node-chunks/chunk-FEOC7OX2.js +0 -1586
- package/dist/_node-chunks/chunk-FY7XZPLY.js +0 -2248
- package/dist/_node-chunks/chunk-GD2FXWDF.js +0 -697
- package/dist/_node-chunks/chunk-HM6B7FE5.js +0 -18
- package/dist/_node-chunks/chunk-HORWITP7.js +0 -90
- package/dist/_node-chunks/chunk-II4AFH3V.js +0 -28
- package/dist/_node-chunks/chunk-MF2PUEWG.js +0 -5029
- package/dist/_node-chunks/chunk-RVE4UTVQ.js +0 -1518
- package/dist/_node-chunks/chunk-TUFWZUTO.js +0 -69
- package/dist/_node-chunks/chunk-TXHNWNH4.js +0 -79
- package/dist/_node-chunks/chunk-ULWNTI6M.js +0 -1198
- package/dist/_node-chunks/chunk-VYRFXLRO.js +0 -6712
- package/dist/_node-chunks/chunk-WNOSTIYP.js +0 -34
- package/dist/_node-chunks/chunk-X67VGZN4.js +0 -1250
- package/dist/_node-chunks/chunk-XCEBYOA4.js +0 -61
- package/dist/_node-chunks/chunk-XW7YMR7I.js +0 -111
- package/dist/_node-chunks/chunk-ZRFYQ46H.js +0 -61
- package/dist/_node-chunks/dist-APCKHSY3.js +0 -175
- package/dist/_node-chunks/globby-TSGXGDA2.js +0 -5222
- package/dist/_node-chunks/lib-DZ5TVIU5.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-Z6BYQCPN.js +0 -22017
- package/dist/_node-chunks/p-limit-MLJNGG2K.js +0 -168
- package/dist/_node-chunks/plugin-J3JI3ZKJ.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-3QHNTM5B.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-4Y3MWPJ6.js +0 -124
|
@@ -2,62 +2,57 @@ import {
|
|
|
2
2
|
UniversalStore,
|
|
3
3
|
parse,
|
|
4
4
|
stringify
|
|
5
|
-
} from "../_browser-chunks/chunk-
|
|
5
|
+
} from "../_browser-chunks/chunk-UD6FQLAF.js";
|
|
6
6
|
import {
|
|
7
7
|
StatusTypeIdMismatchError
|
|
8
|
-
} from "../_browser-chunks/chunk-
|
|
8
|
+
} from "../_browser-chunks/chunk-X3DUQ5RA.js";
|
|
9
9
|
import {
|
|
10
10
|
StatusTypeIdMismatchError as StatusTypeIdMismatchError2
|
|
11
|
-
} from "../_browser-chunks/chunk-
|
|
11
|
+
} from "../_browser-chunks/chunk-74YHFU5B.js";
|
|
12
12
|
import {
|
|
13
13
|
StorybookError
|
|
14
|
-
} from "../_browser-chunks/chunk-
|
|
14
|
+
} from "../_browser-chunks/chunk-EBHB6RPS.js";
|
|
15
15
|
import {
|
|
16
16
|
countBy,
|
|
17
17
|
dequal,
|
|
18
18
|
partition
|
|
19
|
-
} from "../_browser-chunks/chunk-
|
|
19
|
+
} from "../_browser-chunks/chunk-XJNX76GA.js";
|
|
20
20
|
import {
|
|
21
21
|
require_picocolors_browser
|
|
22
|
-
} from "../_browser-chunks/chunk-
|
|
22
|
+
} from "../_browser-chunks/chunk-EZSQOHRI.js";
|
|
23
23
|
import {
|
|
24
24
|
isEqual
|
|
25
|
-
} from "../_browser-chunks/chunk-
|
|
26
|
-
import "../_browser-chunks/chunk-
|
|
25
|
+
} from "../_browser-chunks/chunk-3IAH5M2U.js";
|
|
26
|
+
import "../_browser-chunks/chunk-QKODTO7K.js";
|
|
27
27
|
import {
|
|
28
28
|
mapValues,
|
|
29
29
|
mergeWith,
|
|
30
30
|
pick,
|
|
31
31
|
toMerged
|
|
32
|
-
} from "../_browser-chunks/chunk-
|
|
33
|
-
import "../_browser-chunks/chunk-
|
|
32
|
+
} from "../_browser-chunks/chunk-AIOS4NGK.js";
|
|
33
|
+
import "../_browser-chunks/chunk-GFLS4VP3.js";
|
|
34
34
|
import {
|
|
35
35
|
require_memoizerific
|
|
36
|
-
} from "../_browser-chunks/chunk-
|
|
36
|
+
} from "../_browser-chunks/chunk-WJYERY3R.js";
|
|
37
37
|
import {
|
|
38
38
|
dedent
|
|
39
|
-
} from "../_browser-chunks/chunk-
|
|
39
|
+
} from "../_browser-chunks/chunk-JP7NCOJX.js";
|
|
40
40
|
import {
|
|
41
41
|
__commonJS,
|
|
42
42
|
__export,
|
|
43
|
-
__name,
|
|
44
43
|
__toESM
|
|
45
|
-
} from "../_browser-chunks/chunk-
|
|
44
|
+
} from "../_browser-chunks/chunk-A242L54C.js";
|
|
46
45
|
|
|
47
46
|
// ../node_modules/toggle-selection/index.js
|
|
48
47
|
var require_toggle_selection = __commonJS({
|
|
49
48
|
"../node_modules/toggle-selection/index.js"(exports, module) {
|
|
50
49
|
module.exports = function() {
|
|
51
50
|
var selection = document.getSelection();
|
|
52
|
-
if (!selection.rangeCount)
|
|
51
|
+
if (!selection.rangeCount)
|
|
53
52
|
return function() {
|
|
54
53
|
};
|
|
55
|
-
|
|
56
|
-
var active = document.activeElement;
|
|
57
|
-
var ranges = [];
|
|
58
|
-
for (var i = 0; i < selection.rangeCount; i++) {
|
|
54
|
+
for (var active = document.activeElement, ranges = [], i = 0; i < selection.rangeCount; i++)
|
|
59
55
|
ranges.push(selection.getRangeAt(i));
|
|
60
|
-
}
|
|
61
56
|
switch (active.tagName.toUpperCase()) {
|
|
62
57
|
// .toUpperCase handles XHTML
|
|
63
58
|
case "INPUT":
|
|
@@ -68,15 +63,10 @@ var require_toggle_selection = __commonJS({
|
|
|
68
63
|
active = null;
|
|
69
64
|
break;
|
|
70
65
|
}
|
|
71
|
-
selection.removeAllRanges()
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
ranges.forEach(function(range) {
|
|
76
|
-
selection.addRange(range);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
active && active.focus();
|
|
66
|
+
return selection.removeAllRanges(), function() {
|
|
67
|
+
selection.type === "Caret" && selection.removeAllRanges(), selection.rangeCount || ranges.forEach(function(range) {
|
|
68
|
+
selection.addRange(range);
|
|
69
|
+
}), active && active.focus();
|
|
80
70
|
};
|
|
81
71
|
};
|
|
82
72
|
}
|
|
@@ -86,97 +76,45 @@ var require_toggle_selection = __commonJS({
|
|
|
86
76
|
var require_copy_to_clipboard = __commonJS({
|
|
87
77
|
"../node_modules/copy-to-clipboard/index.js"(exports, module) {
|
|
88
78
|
"use strict";
|
|
89
|
-
var deselectCurrent = require_toggle_selection()
|
|
90
|
-
var clipboardToIE11Formatting = {
|
|
79
|
+
var deselectCurrent = require_toggle_selection(), clipboardToIE11Formatting = {
|
|
91
80
|
"text/plain": "Text",
|
|
92
81
|
"text/html": "Url",
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
82
|
+
default: "Text"
|
|
83
|
+
}, defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
96
84
|
function format(message) {
|
|
97
85
|
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "\u2318" : "Ctrl") + "+C";
|
|
98
86
|
return message.replace(/#{\s*key\s*}/g, copyKey);
|
|
99
87
|
}
|
|
100
|
-
__name(format, "format");
|
|
101
88
|
function copy2(text, options) {
|
|
102
|
-
var debug, message, reselectPrevious, range, selection, mark, success =
|
|
103
|
-
|
|
104
|
-
options = {};
|
|
105
|
-
}
|
|
106
|
-
debug = options.debug || false;
|
|
89
|
+
var debug, message, reselectPrevious, range, selection, mark, success = !1;
|
|
90
|
+
options || (options = {}), debug = options.debug || !1;
|
|
107
91
|
try {
|
|
108
|
-
reselectPrevious = deselectCurrent()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
mark.ariaHidden = "true";
|
|
114
|
-
mark.style.all = "unset";
|
|
115
|
-
mark.style.position = "fixed";
|
|
116
|
-
mark.style.top = 0;
|
|
117
|
-
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
118
|
-
mark.style.whiteSpace = "pre";
|
|
119
|
-
mark.style.webkitUserSelect = "text";
|
|
120
|
-
mark.style.MozUserSelect = "text";
|
|
121
|
-
mark.style.msUserSelect = "text";
|
|
122
|
-
mark.style.userSelect = "text";
|
|
123
|
-
mark.addEventListener("copy", function(e) {
|
|
124
|
-
e.stopPropagation();
|
|
125
|
-
if (options.format) {
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
if (typeof e.clipboardData === "undefined") {
|
|
128
|
-
debug && console.warn("unable to use e.clipboardData");
|
|
129
|
-
debug && console.warn("trying IE specific stuff");
|
|
130
|
-
window.clipboardData.clearData();
|
|
131
|
-
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
92
|
+
reselectPrevious = deselectCurrent(), range = document.createRange(), selection = document.getSelection(), mark = document.createElement("span"), mark.textContent = text, mark.ariaHidden = "true", mark.style.all = "unset", mark.style.position = "fixed", mark.style.top = 0, mark.style.clip = "rect(0, 0, 0, 0)", mark.style.whiteSpace = "pre", mark.style.webkitUserSelect = "text", mark.style.MozUserSelect = "text", mark.style.msUserSelect = "text", mark.style.userSelect = "text", mark.addEventListener("copy", function(e) {
|
|
93
|
+
if (e.stopPropagation(), options.format)
|
|
94
|
+
if (e.preventDefault(), typeof e.clipboardData > "u") {
|
|
95
|
+
debug && console.warn("unable to use e.clipboardData"), debug && console.warn("trying IE specific stuff"), window.clipboardData.clearData();
|
|
96
|
+
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting.default;
|
|
132
97
|
window.clipboardData.setData(format2, text);
|
|
133
|
-
} else
|
|
134
|
-
e.clipboardData.clearData();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
if (options.onCopy) {
|
|
139
|
-
e.preventDefault();
|
|
140
|
-
options.onCopy(e.clipboardData);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
document.body.appendChild(mark);
|
|
144
|
-
range.selectNodeContents(mark);
|
|
145
|
-
selection.addRange(range);
|
|
98
|
+
} else
|
|
99
|
+
e.clipboardData.clearData(), e.clipboardData.setData(options.format, text);
|
|
100
|
+
options.onCopy && (e.preventDefault(), options.onCopy(e.clipboardData));
|
|
101
|
+
}), document.body.appendChild(mark), range.selectNodeContents(mark), selection.addRange(range);
|
|
146
102
|
var successful = document.execCommand("copy");
|
|
147
|
-
if (!successful)
|
|
103
|
+
if (!successful)
|
|
148
104
|
throw new Error("copy command was unsuccessful");
|
|
149
|
-
|
|
150
|
-
success = true;
|
|
105
|
+
success = !0;
|
|
151
106
|
} catch (err) {
|
|
152
|
-
debug && console.error("unable to copy using execCommand: ", err);
|
|
153
|
-
debug && console.warn("trying IE specific stuff");
|
|
107
|
+
debug && console.error("unable to copy using execCommand: ", err), debug && console.warn("trying IE specific stuff");
|
|
154
108
|
try {
|
|
155
|
-
window.clipboardData.setData(options.format || "text", text);
|
|
156
|
-
options.onCopy && options.onCopy(window.clipboardData);
|
|
157
|
-
success = true;
|
|
109
|
+
window.clipboardData.setData(options.format || "text", text), options.onCopy && options.onCopy(window.clipboardData), success = !0;
|
|
158
110
|
} catch (err2) {
|
|
159
|
-
debug && console.error("unable to copy using clipboardData: ", err2);
|
|
160
|
-
debug && console.error("falling back to prompt");
|
|
161
|
-
message = format("message" in options ? options.message : defaultMessage);
|
|
162
|
-
window.prompt(message, text);
|
|
111
|
+
debug && console.error("unable to copy using clipboardData: ", err2), debug && console.error("falling back to prompt"), message = format("message" in options ? options.message : defaultMessage), window.prompt(message, text);
|
|
163
112
|
}
|
|
164
113
|
} finally {
|
|
165
|
-
|
|
166
|
-
if (typeof selection.removeRange == "function") {
|
|
167
|
-
selection.removeRange(range);
|
|
168
|
-
} else {
|
|
169
|
-
selection.removeAllRanges();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (mark) {
|
|
173
|
-
document.body.removeChild(mark);
|
|
174
|
-
}
|
|
175
|
-
reselectPrevious();
|
|
114
|
+
selection && (typeof selection.removeRange == "function" ? selection.removeRange(range) : selection.removeAllRanges()), mark && document.body.removeChild(mark), reselectPrevious();
|
|
176
115
|
}
|
|
177
116
|
return success;
|
|
178
117
|
}
|
|
179
|
-
__name(copy2, "copy");
|
|
180
118
|
module.exports = copy2;
|
|
181
119
|
}
|
|
182
120
|
});
|
|
@@ -191,331 +129,212 @@ var require_store2 = __commonJS({
|
|
|
191
129
|
apis: {},
|
|
192
130
|
nsdelim: ".",
|
|
193
131
|
// utilities
|
|
194
|
-
inherit:
|
|
195
|
-
for (var p in api)
|
|
196
|
-
|
|
197
|
-
Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
132
|
+
inherit: function(api, o) {
|
|
133
|
+
for (var p in api)
|
|
134
|
+
o.hasOwnProperty(p) || Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
|
|
200
135
|
return o;
|
|
201
|
-
},
|
|
202
|
-
stringify:
|
|
203
|
-
return d === void 0 || typeof d
|
|
204
|
-
},
|
|
205
|
-
parse:
|
|
136
|
+
},
|
|
137
|
+
stringify: function(d, fn) {
|
|
138
|
+
return d === void 0 || typeof d == "function" ? d + "" : JSON.stringify(d, fn || _.replace);
|
|
139
|
+
},
|
|
140
|
+
parse: function(s, fn) {
|
|
206
141
|
try {
|
|
207
142
|
return JSON.parse(s, fn || _.revive);
|
|
208
|
-
} catch
|
|
143
|
+
} catch {
|
|
209
144
|
return s;
|
|
210
145
|
}
|
|
211
|
-
},
|
|
146
|
+
},
|
|
212
147
|
// extension hooks
|
|
213
|
-
fn:
|
|
148
|
+
fn: function(name, fn) {
|
|
214
149
|
_.storeAPI[name] = fn;
|
|
215
|
-
for (var api in _.apis)
|
|
150
|
+
for (var api in _.apis)
|
|
216
151
|
_.apis[api][name] = fn;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
get: /* @__PURE__ */ __name(function(area, key) {
|
|
152
|
+
},
|
|
153
|
+
get: function(area, key) {
|
|
220
154
|
return area.getItem(key);
|
|
221
|
-
},
|
|
222
|
-
set:
|
|
155
|
+
},
|
|
156
|
+
set: function(area, key, string) {
|
|
223
157
|
area.setItem(key, string);
|
|
224
|
-
},
|
|
225
|
-
remove:
|
|
158
|
+
},
|
|
159
|
+
remove: function(area, key) {
|
|
226
160
|
area.removeItem(key);
|
|
227
|
-
},
|
|
228
|
-
key:
|
|
161
|
+
},
|
|
162
|
+
key: function(area, i) {
|
|
229
163
|
return area.key(i);
|
|
230
|
-
},
|
|
231
|
-
length:
|
|
164
|
+
},
|
|
165
|
+
length: function(area) {
|
|
232
166
|
return area.length;
|
|
233
|
-
},
|
|
234
|
-
clear:
|
|
167
|
+
},
|
|
168
|
+
clear: function(area) {
|
|
235
169
|
area.clear();
|
|
236
|
-
},
|
|
170
|
+
},
|
|
237
171
|
// core functions
|
|
238
|
-
Store:
|
|
172
|
+
Store: function(id, area, namespace) {
|
|
239
173
|
var store3 = _.inherit(_.storeAPI, function(key, data, overwrite) {
|
|
240
|
-
|
|
241
|
-
return store3.getAll();
|
|
242
|
-
}
|
|
243
|
-
if (typeof data === "function") {
|
|
244
|
-
return store3.transact(key, data, overwrite);
|
|
245
|
-
}
|
|
246
|
-
if (data !== void 0) {
|
|
247
|
-
return store3.set(key, data, overwrite);
|
|
248
|
-
}
|
|
249
|
-
if (typeof key === "string" || typeof key === "number") {
|
|
250
|
-
return store3.get(key);
|
|
251
|
-
}
|
|
252
|
-
if (typeof key === "function") {
|
|
253
|
-
return store3.each(key);
|
|
254
|
-
}
|
|
255
|
-
if (!key) {
|
|
256
|
-
return store3.clear();
|
|
257
|
-
}
|
|
258
|
-
return store3.setAll(key, data);
|
|
174
|
+
return arguments.length === 0 ? store3.getAll() : typeof data == "function" ? store3.transact(key, data, overwrite) : data !== void 0 ? store3.set(key, data, overwrite) : typeof key == "string" || typeof key == "number" ? store3.get(key) : typeof key == "function" ? store3.each(key) : key ? store3.setAll(key, data) : store3.clear();
|
|
259
175
|
});
|
|
260
176
|
store3._id = id;
|
|
261
177
|
try {
|
|
262
178
|
var testKey = "__store2_test";
|
|
263
|
-
area.setItem(testKey, "ok");
|
|
264
|
-
|
|
265
|
-
area.removeItem(testKey);
|
|
266
|
-
} catch (e) {
|
|
179
|
+
area.setItem(testKey, "ok"), store3._area = area, area.removeItem(testKey);
|
|
180
|
+
} catch {
|
|
267
181
|
store3._area = _.storage("fake");
|
|
268
182
|
}
|
|
269
|
-
store3._ns = namespace || "";
|
|
270
|
-
|
|
271
|
-
_.areas[id] = store3._area;
|
|
272
|
-
}
|
|
273
|
-
if (!_.apis[store3._ns + store3._id]) {
|
|
274
|
-
_.apis[store3._ns + store3._id] = store3;
|
|
275
|
-
}
|
|
276
|
-
return store3;
|
|
277
|
-
}, "Store"),
|
|
183
|
+
return store3._ns = namespace || "", _.areas[id] || (_.areas[id] = store3._area), _.apis[store3._ns + store3._id] || (_.apis[store3._ns + store3._id] = store3), store3;
|
|
184
|
+
},
|
|
278
185
|
storeAPI: {
|
|
279
186
|
// admin functions
|
|
280
|
-
area:
|
|
187
|
+
area: function(id, area) {
|
|
281
188
|
var store3 = this[id];
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return store3;
|
|
289
|
-
}, "area"),
|
|
290
|
-
namespace: /* @__PURE__ */ __name(function(namespace, singleArea, delim) {
|
|
291
|
-
delim = delim || this._delim || _.nsdelim;
|
|
292
|
-
if (!namespace) {
|
|
189
|
+
return (!store3 || !store3.area) && (store3 = _.Store(id, area, this._ns), this[id] || (this[id] = store3)), store3;
|
|
190
|
+
},
|
|
191
|
+
namespace: function(namespace, singleArea, delim) {
|
|
192
|
+
if (delim = delim || this._delim || _.nsdelim, !namespace)
|
|
293
193
|
return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
|
|
294
|
-
}
|
|
295
194
|
var ns = namespace, store3 = this[ns];
|
|
296
|
-
if (!store3 || !store3.namespace)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (!this[ns]) {
|
|
300
|
-
this[ns] = store3;
|
|
301
|
-
}
|
|
302
|
-
if (!singleArea) {
|
|
303
|
-
for (var name in _.areas) {
|
|
304
|
-
store3.area(name, _.areas[name]);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
195
|
+
if ((!store3 || !store3.namespace) && (store3 = _.Store(this._id, this._area, this._ns + ns + delim), store3._delim = delim, this[ns] || (this[ns] = store3), !singleArea))
|
|
196
|
+
for (var name in _.areas)
|
|
197
|
+
store3.area(name, _.areas[name]);
|
|
308
198
|
return store3;
|
|
309
|
-
},
|
|
310
|
-
isFake:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
} else if (force === false) {
|
|
315
|
-
this._area = this._real || this._area;
|
|
316
|
-
}
|
|
317
|
-
return this._area.name === "fake";
|
|
318
|
-
}, "isFake"),
|
|
319
|
-
toString: /* @__PURE__ */ __name(function() {
|
|
199
|
+
},
|
|
200
|
+
isFake: function(force) {
|
|
201
|
+
return force ? (this._real = this._area, this._area = _.storage("fake")) : force === !1 && (this._area = this._real || this._area), this._area.name === "fake";
|
|
202
|
+
},
|
|
203
|
+
toString: function() {
|
|
320
204
|
return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
|
|
321
|
-
},
|
|
205
|
+
},
|
|
322
206
|
// storage functions
|
|
323
|
-
has:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return !!(this._in(key) in this._area);
|
|
328
|
-
}, "has"),
|
|
329
|
-
size: /* @__PURE__ */ __name(function() {
|
|
207
|
+
has: function(key) {
|
|
208
|
+
return this._area.has ? this._area.has(this._in(key)) : this._in(key) in this._area;
|
|
209
|
+
},
|
|
210
|
+
size: function() {
|
|
330
211
|
return this.keys().length;
|
|
331
|
-
},
|
|
332
|
-
each:
|
|
212
|
+
},
|
|
213
|
+
each: function(fn, fill) {
|
|
333
214
|
for (var i = 0, m = _.length(this._area); i < m; i++) {
|
|
334
215
|
var key = this._out(_.key(this._area, i));
|
|
335
|
-
if (key !== void 0)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (m > _.length(this._area)) {
|
|
341
|
-
m--;
|
|
342
|
-
i--;
|
|
343
|
-
}
|
|
216
|
+
if (key !== void 0 && fn.call(this, key, this.get(key), fill) === !1)
|
|
217
|
+
break;
|
|
218
|
+
m > _.length(this._area) && (m--, i--);
|
|
344
219
|
}
|
|
345
220
|
return fill || this;
|
|
346
|
-
},
|
|
347
|
-
keys:
|
|
221
|
+
},
|
|
222
|
+
keys: function(fillList) {
|
|
348
223
|
return this.each(function(k, v, list) {
|
|
349
224
|
list.push(k);
|
|
350
225
|
}, fillList || []);
|
|
351
|
-
},
|
|
352
|
-
get:
|
|
226
|
+
},
|
|
227
|
+
get: function(key, alt) {
|
|
353
228
|
var s = _.get(this._area, this._in(key)), fn;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
return s !== null ? _.parse(s, fn) : alt != null ? alt : s;
|
|
359
|
-
}, "get"),
|
|
360
|
-
getAll: /* @__PURE__ */ __name(function(fillObj) {
|
|
229
|
+
return typeof alt == "function" && (fn = alt, alt = null), s !== null ? _.parse(s, fn) : alt ?? s;
|
|
230
|
+
},
|
|
231
|
+
getAll: function(fillObj) {
|
|
361
232
|
return this.each(function(k, v, all) {
|
|
362
233
|
all[k] = v;
|
|
363
234
|
}, fillObj || {});
|
|
364
|
-
},
|
|
365
|
-
transact:
|
|
235
|
+
},
|
|
236
|
+
transact: function(key, fn, alt) {
|
|
366
237
|
var val = this.get(key, alt), ret = fn(val);
|
|
367
|
-
this.set(key, ret === void 0 ? val : ret);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
set: /* @__PURE__ */ __name(function(key, data, overwrite) {
|
|
238
|
+
return this.set(key, ret === void 0 ? val : ret), this;
|
|
239
|
+
},
|
|
240
|
+
set: function(key, data, overwrite) {
|
|
371
241
|
var d = this.get(key), replacer;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (typeof overwrite === "function") {
|
|
376
|
-
replacer = overwrite;
|
|
377
|
-
overwrite = void 0;
|
|
378
|
-
}
|
|
379
|
-
return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
|
|
380
|
-
}, "set"),
|
|
381
|
-
setAll: /* @__PURE__ */ __name(function(data, overwrite) {
|
|
242
|
+
return d != null && overwrite === !1 ? data : (typeof overwrite == "function" && (replacer = overwrite, overwrite = void 0), _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d);
|
|
243
|
+
},
|
|
244
|
+
setAll: function(data, overwrite) {
|
|
382
245
|
var changed, val;
|
|
383
|
-
for (var key in data)
|
|
384
|
-
val = data[key];
|
|
385
|
-
if (this.set(key, val, overwrite) !== val) {
|
|
386
|
-
changed = true;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
246
|
+
for (var key in data)
|
|
247
|
+
val = data[key], this.set(key, val, overwrite) !== val && (changed = !0);
|
|
389
248
|
return changed;
|
|
390
|
-
},
|
|
391
|
-
add:
|
|
249
|
+
},
|
|
250
|
+
add: function(key, data, replacer) {
|
|
392
251
|
var d = this.get(key);
|
|
393
|
-
if (d instanceof Array)
|
|
252
|
+
if (d instanceof Array)
|
|
394
253
|
data = d.concat(data);
|
|
395
|
-
|
|
254
|
+
else if (d !== null) {
|
|
396
255
|
var type = typeof d;
|
|
397
256
|
if (type === typeof data && type === "object") {
|
|
398
|
-
for (var k in data)
|
|
257
|
+
for (var k in data)
|
|
399
258
|
d[k] = data[k];
|
|
400
|
-
}
|
|
401
259
|
data = d;
|
|
402
|
-
} else
|
|
260
|
+
} else
|
|
403
261
|
data = d + data;
|
|
404
|
-
}
|
|
405
262
|
}
|
|
406
|
-
_.set(this._area, this._in(key), _.stringify(data, replacer));
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
remove: /* @__PURE__ */ __name(function(key, alt) {
|
|
263
|
+
return _.set(this._area, this._in(key), _.stringify(data, replacer)), data;
|
|
264
|
+
},
|
|
265
|
+
remove: function(key, alt) {
|
|
410
266
|
var d = this.get(key, alt);
|
|
411
|
-
_.remove(this._area, this._in(key));
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
_.remove(this._area, this._in(k));
|
|
420
|
-
}, 1);
|
|
421
|
-
}
|
|
422
|
-
return this;
|
|
423
|
-
}, "clear"),
|
|
424
|
-
clearAll: /* @__PURE__ */ __name(function() {
|
|
267
|
+
return _.remove(this._area, this._in(key)), d;
|
|
268
|
+
},
|
|
269
|
+
clear: function() {
|
|
270
|
+
return this._ns ? this.each(function(k) {
|
|
271
|
+
_.remove(this._area, this._in(k));
|
|
272
|
+
}, 1) : _.clear(this._area), this;
|
|
273
|
+
},
|
|
274
|
+
clearAll: function() {
|
|
425
275
|
var area = this._area;
|
|
426
|
-
for (var id in _.areas)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
this._area = area;
|
|
433
|
-
return this;
|
|
434
|
-
}, "clearAll"),
|
|
276
|
+
for (var id in _.areas)
|
|
277
|
+
_.areas.hasOwnProperty(id) && (this._area = _.areas[id], this.clear());
|
|
278
|
+
return this._area = area, this;
|
|
279
|
+
},
|
|
435
280
|
// internal use functions
|
|
436
|
-
_in:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return this._ns ? this._ns + k : k;
|
|
441
|
-
}, "_in"),
|
|
442
|
-
_out: /* @__PURE__ */ __name(function(k) {
|
|
281
|
+
_in: function(k) {
|
|
282
|
+
return typeof k != "string" && (k = _.stringify(k)), this._ns ? this._ns + k : k;
|
|
283
|
+
},
|
|
284
|
+
_out: function(k) {
|
|
443
285
|
return this._ns ? k && k.indexOf(this._ns) === 0 ? k.substring(this._ns.length) : void 0 : (
|
|
444
286
|
// so each() knows to skip it
|
|
445
287
|
k
|
|
446
288
|
);
|
|
447
|
-
}
|
|
289
|
+
}
|
|
448
290
|
},
|
|
449
291
|
// end _.storeAPI
|
|
450
|
-
storage:
|
|
292
|
+
storage: function(name) {
|
|
451
293
|
return _.inherit(_.storageAPI, { items: {}, name });
|
|
452
|
-
},
|
|
294
|
+
},
|
|
453
295
|
storageAPI: {
|
|
454
296
|
length: 0,
|
|
455
|
-
has:
|
|
297
|
+
has: function(k) {
|
|
456
298
|
return this.items.hasOwnProperty(k);
|
|
457
|
-
},
|
|
458
|
-
key:
|
|
299
|
+
},
|
|
300
|
+
key: function(i) {
|
|
459
301
|
var c = 0;
|
|
460
|
-
for (var k in this.items)
|
|
461
|
-
if (this.has(k) && i === c++)
|
|
302
|
+
for (var k in this.items)
|
|
303
|
+
if (this.has(k) && i === c++)
|
|
462
304
|
return k;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}, "setItem"),
|
|
472
|
-
removeItem: /* @__PURE__ */ __name(function(k) {
|
|
473
|
-
if (this.has(k)) {
|
|
474
|
-
delete this.items[k];
|
|
475
|
-
this.length--;
|
|
476
|
-
}
|
|
477
|
-
}, "removeItem"),
|
|
478
|
-
getItem: /* @__PURE__ */ __name(function(k) {
|
|
305
|
+
},
|
|
306
|
+
setItem: function(k, v) {
|
|
307
|
+
this.has(k) || this.length++, this.items[k] = v;
|
|
308
|
+
},
|
|
309
|
+
removeItem: function(k) {
|
|
310
|
+
this.has(k) && (delete this.items[k], this.length--);
|
|
311
|
+
},
|
|
312
|
+
getItem: function(k) {
|
|
479
313
|
return this.has(k) ? this.items[k] : null;
|
|
480
|
-
},
|
|
481
|
-
clear:
|
|
482
|
-
for (var k in this.items)
|
|
314
|
+
},
|
|
315
|
+
clear: function() {
|
|
316
|
+
for (var k in this.items)
|
|
483
317
|
this.removeItem(k);
|
|
484
|
-
|
|
485
|
-
}, "clear")
|
|
318
|
+
}
|
|
486
319
|
}
|
|
487
320
|
// end _.storageAPI
|
|
488
|
-
}
|
|
489
|
-
var store2 = (
|
|
321
|
+
}, store2 = (
|
|
490
322
|
// safely set this up (throws error in IE10/32bit mode for local files)
|
|
491
|
-
_.Store("local", function() {
|
|
323
|
+
_.Store("local", (function() {
|
|
492
324
|
try {
|
|
493
325
|
return localStorage;
|
|
494
|
-
} catch
|
|
326
|
+
} catch {
|
|
495
327
|
}
|
|
496
|
-
}())
|
|
328
|
+
})())
|
|
497
329
|
);
|
|
498
|
-
store2.local = store2
|
|
499
|
-
store2._ = _;
|
|
500
|
-
store2.area("session", function() {
|
|
330
|
+
store2.local = store2, store2._ = _, store2.area("session", (function() {
|
|
501
331
|
try {
|
|
502
332
|
return sessionStorage;
|
|
503
|
-
} catch
|
|
333
|
+
} catch {
|
|
504
334
|
}
|
|
505
|
-
}())
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
define("store2", [], function() {
|
|
509
|
-
return store2;
|
|
510
|
-
});
|
|
511
|
-
} else if (typeof module !== "undefined" && module.exports) {
|
|
512
|
-
module.exports = store2;
|
|
513
|
-
} else {
|
|
514
|
-
if (window2.store) {
|
|
515
|
-
_.conflict = window2.store;
|
|
516
|
-
}
|
|
517
|
-
window2.store = store2;
|
|
518
|
-
}
|
|
335
|
+
})()), store2.area("page", _.storage("page")), typeof define == "function" && define.amd !== void 0 ? define("store2", [], function() {
|
|
336
|
+
return store2;
|
|
337
|
+
}) : typeof module < "u" && module.exports ? module.exports = store2 : (window2.store && (_.conflict = window2.store), window2.store = store2);
|
|
519
338
|
})(exports, exports && exports.define);
|
|
520
339
|
}
|
|
521
340
|
});
|
|
@@ -542,74 +361,54 @@ import {
|
|
|
542
361
|
|
|
543
362
|
// src/manager-api/context.ts
|
|
544
363
|
import { createContext as ReactCreateContext } from "react";
|
|
545
|
-
var createContext =
|
|
364
|
+
var createContext = ({ api, state }) => ReactCreateContext({ api, state });
|
|
546
365
|
|
|
547
366
|
// src/manager-api/lib/merge.ts
|
|
548
367
|
import { logger } from "storybook/internal/client-logger";
|
|
549
|
-
var merge_default =
|
|
368
|
+
var merge_default = (a, ...b) => {
|
|
550
369
|
let target = {};
|
|
551
370
|
target = mergeWith(
|
|
552
371
|
{},
|
|
553
372
|
a,
|
|
554
373
|
(objValue, srcValue) => {
|
|
555
|
-
if (Array.isArray(srcValue) && Array.isArray(objValue))
|
|
556
|
-
srcValue.forEach((s) => {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
});
|
|
562
|
-
return objValue;
|
|
563
|
-
}
|
|
564
|
-
if (Array.isArray(objValue)) {
|
|
565
|
-
logger.log(["the types mismatch, picking", objValue]);
|
|
566
|
-
return objValue;
|
|
567
|
-
}
|
|
374
|
+
if (Array.isArray(srcValue) && Array.isArray(objValue))
|
|
375
|
+
return srcValue.forEach((s) => {
|
|
376
|
+
objValue.find((o) => o === s || isEqual(o, s)) || objValue.push(s);
|
|
377
|
+
}), objValue;
|
|
378
|
+
if (Array.isArray(objValue))
|
|
379
|
+
return logger.log(["the types mismatch, picking", objValue]), objValue;
|
|
568
380
|
}
|
|
569
381
|
);
|
|
570
|
-
for (
|
|
382
|
+
for (let obj of b)
|
|
571
383
|
target = mergeWith(target, obj, (objValue, srcValue) => {
|
|
572
|
-
if (Array.isArray(srcValue) && Array.isArray(objValue))
|
|
573
|
-
srcValue.forEach((s) => {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
});
|
|
579
|
-
return objValue;
|
|
580
|
-
}
|
|
581
|
-
if (Array.isArray(objValue)) {
|
|
582
|
-
logger.log(["the types mismatch, picking", objValue]);
|
|
583
|
-
return objValue;
|
|
584
|
-
}
|
|
384
|
+
if (Array.isArray(srcValue) && Array.isArray(objValue))
|
|
385
|
+
return srcValue.forEach((s) => {
|
|
386
|
+
objValue.find((o) => o === s || isEqual(o, s)) || objValue.push(s);
|
|
387
|
+
}), objValue;
|
|
388
|
+
if (Array.isArray(objValue))
|
|
389
|
+
return logger.log(["the types mismatch, picking", objValue]), objValue;
|
|
585
390
|
});
|
|
586
|
-
}
|
|
587
391
|
return target;
|
|
588
|
-
},
|
|
589
|
-
var noArrayMerge = /* @__PURE__ */ __name((a, ...b) => {
|
|
392
|
+
}, noArrayMerge = (a, ...b) => {
|
|
590
393
|
let target = {};
|
|
591
394
|
target = mergeWith(
|
|
592
395
|
{},
|
|
593
396
|
a,
|
|
594
397
|
(objValue, srcValue) => {
|
|
595
|
-
if (Array.isArray(srcValue))
|
|
398
|
+
if (Array.isArray(srcValue))
|
|
596
399
|
return srcValue;
|
|
597
|
-
}
|
|
598
400
|
}
|
|
599
401
|
);
|
|
600
|
-
for (
|
|
402
|
+
for (let obj of b)
|
|
601
403
|
target = mergeWith(target, obj, (objValue, srcValue) => {
|
|
602
|
-
if (Array.isArray(srcValue))
|
|
404
|
+
if (Array.isArray(srcValue))
|
|
603
405
|
return srcValue;
|
|
604
|
-
}
|
|
605
406
|
});
|
|
606
|
-
}
|
|
607
407
|
return target;
|
|
608
|
-
}
|
|
408
|
+
};
|
|
609
409
|
|
|
610
410
|
// src/manager-api/initial-state.ts
|
|
611
|
-
var main =
|
|
612
|
-
var initial_state_default = main;
|
|
411
|
+
var main = (...additions) => additions.reduce((acc, item) => merge_default(acc, item), {}), initial_state_default = main;
|
|
613
412
|
|
|
614
413
|
// src/manager-api/lib/addons.ts
|
|
615
414
|
import { logger as logger2 } from "storybook/internal/client-logger";
|
|
@@ -620,45 +419,33 @@ import { global } from "@storybook/global";
|
|
|
620
419
|
// src/manager-api/lib/storybook-channel-mock.ts
|
|
621
420
|
import { Channel } from "storybook/internal/channels";
|
|
622
421
|
function mockChannel() {
|
|
623
|
-
|
|
624
|
-
setHandler:
|
|
625
|
-
},
|
|
626
|
-
send:
|
|
627
|
-
}
|
|
422
|
+
let transport = {
|
|
423
|
+
setHandler: () => {
|
|
424
|
+
},
|
|
425
|
+
send: () => {
|
|
426
|
+
}
|
|
628
427
|
};
|
|
629
428
|
return new Channel({ transport });
|
|
630
429
|
}
|
|
631
|
-
__name(mockChannel, "mockChannel");
|
|
632
430
|
|
|
633
431
|
// src/manager-api/lib/addons.ts
|
|
634
|
-
var
|
|
432
|
+
var AddonStore = class {
|
|
635
433
|
constructor() {
|
|
636
434
|
this.loaders = {};
|
|
637
435
|
this.elements = {};
|
|
638
436
|
this.config = {};
|
|
639
|
-
this.getChannel =
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}
|
|
645
|
-
this.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
this.setConfig = /* @__PURE__ */ __name((value) => {
|
|
652
|
-
Object.assign(this.config, value);
|
|
653
|
-
if (this.hasChannel()) {
|
|
654
|
-
this.getChannel().emit(SET_CONFIG, this.config);
|
|
655
|
-
} else {
|
|
656
|
-
this.ready().then((channel) => {
|
|
657
|
-
channel.emit(SET_CONFIG, this.config);
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
}, "setConfig");
|
|
661
|
-
this.getConfig = /* @__PURE__ */ __name(() => this.config, "getConfig");
|
|
437
|
+
this.getChannel = () => (this.channel || this.setChannel(mockChannel()), this.channel);
|
|
438
|
+
this.ready = () => this.promise;
|
|
439
|
+
this.hasChannel = () => !!this.channel;
|
|
440
|
+
this.setChannel = (channel) => {
|
|
441
|
+
this.channel = channel, this.resolve();
|
|
442
|
+
};
|
|
443
|
+
this.setConfig = (value) => {
|
|
444
|
+
Object.assign(this.config, value), this.hasChannel() ? this.getChannel().emit(SET_CONFIG, this.config) : this.ready().then((channel) => {
|
|
445
|
+
channel.emit(SET_CONFIG, this.config);
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
this.getConfig = () => this.config;
|
|
662
449
|
/**
|
|
663
450
|
* Registers an addon loader function.
|
|
664
451
|
*
|
|
@@ -666,24 +453,18 @@ var _AddonStore = class _AddonStore {
|
|
|
666
453
|
* @param {(api: API) => void} callback - The function that will be called to register the addon.
|
|
667
454
|
* @returns {void}
|
|
668
455
|
*/
|
|
669
|
-
this.register =
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
this.loaders[id] = callback;
|
|
674
|
-
}, "register");
|
|
675
|
-
this.loadAddons = /* @__PURE__ */ __name((api) => {
|
|
456
|
+
this.register = (id, callback) => {
|
|
457
|
+
this.loaders[id] && logger2.warn(`${id} was loaded twice, this could have bad side-effects`), this.loaders[id] = callback;
|
|
458
|
+
};
|
|
459
|
+
this.loadAddons = (api) => {
|
|
676
460
|
Object.values(this.loaders).forEach((value) => value(api));
|
|
677
|
-
}
|
|
461
|
+
};
|
|
678
462
|
this.promise = new Promise((res) => {
|
|
679
463
|
this.resolve = () => res(this.getChannel());
|
|
680
464
|
});
|
|
681
465
|
}
|
|
682
466
|
getElements(type) {
|
|
683
|
-
|
|
684
|
-
this.elements[type] = {};
|
|
685
|
-
}
|
|
686
|
-
return this.elements[type];
|
|
467
|
+
return this.elements[type] || (this.elements[type] = {}), this.elements[type];
|
|
687
468
|
}
|
|
688
469
|
/**
|
|
689
470
|
* Adds an addon to the addon store.
|
|
@@ -693,24 +474,16 @@ var _AddonStore = class _AddonStore {
|
|
|
693
474
|
* @returns {void}
|
|
694
475
|
*/
|
|
695
476
|
add(id, addon) {
|
|
696
|
-
|
|
697
|
-
const collection = this.getElements(type);
|
|
477
|
+
let { type } = addon, collection = this.getElements(type);
|
|
698
478
|
collection[id] = { ...addon, id };
|
|
699
479
|
}
|
|
700
480
|
experimental_getRegisteredAddons() {
|
|
701
481
|
return Object.keys(this.loaders);
|
|
702
482
|
}
|
|
703
|
-
};
|
|
704
|
-
__name(_AddonStore, "AddonStore");
|
|
705
|
-
var AddonStore = _AddonStore;
|
|
706
|
-
var KEY = "__STORYBOOK_ADDONS_MANAGER";
|
|
483
|
+
}, KEY = "__STORYBOOK_ADDONS_MANAGER";
|
|
707
484
|
function getAddonsStore() {
|
|
708
|
-
|
|
709
|
-
global[KEY] = new AddonStore();
|
|
710
|
-
}
|
|
711
|
-
return global[KEY];
|
|
485
|
+
return global[KEY] || (global[KEY] = new AddonStore()), global[KEY];
|
|
712
486
|
}
|
|
713
|
-
__name(getAddonsStore, "getAddonsStore");
|
|
714
487
|
var addons = getAddonsStore();
|
|
715
488
|
|
|
716
489
|
// src/manager-api/modules/addons.ts
|
|
@@ -721,36 +494,27 @@ __export(addons_exports, {
|
|
|
721
494
|
});
|
|
722
495
|
import { Addon_TypesEnum as Addon_TypesEnum2 } from "storybook/internal/types";
|
|
723
496
|
function ensurePanel(panels, selectedPanel, currentPanel) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
return selectedPanel;
|
|
727
|
-
}
|
|
728
|
-
if (keys2.length) {
|
|
729
|
-
return keys2[0];
|
|
730
|
-
}
|
|
731
|
-
return currentPanel;
|
|
497
|
+
let keys2 = Object.keys(panels);
|
|
498
|
+
return keys2.indexOf(selectedPanel) >= 0 ? selectedPanel : keys2.length ? keys2[0] : currentPanel;
|
|
732
499
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const { selectedPanel } = store2.getState();
|
|
500
|
+
var init = ({ provider, store: store2, fullAPI }) => {
|
|
501
|
+
let api = {
|
|
502
|
+
getElements: (type) => provider.getElements(type),
|
|
503
|
+
getSelectedPanel: () => {
|
|
504
|
+
let { selectedPanel } = store2.getState();
|
|
739
505
|
return ensurePanel(api.getElements(Addon_TypesEnum2.PANEL), selectedPanel, selectedPanel);
|
|
740
|
-
},
|
|
741
|
-
setSelectedPanel:
|
|
506
|
+
},
|
|
507
|
+
setSelectedPanel: (panelName) => {
|
|
742
508
|
store2.setState({ selectedPanel: panelName }, { persistence: "session" });
|
|
743
|
-
},
|
|
509
|
+
},
|
|
744
510
|
setAddonState(addonId, newStateOrMerger, options) {
|
|
745
|
-
|
|
511
|
+
let merger = typeof newStateOrMerger == "function" ? newStateOrMerger : () => newStateOrMerger;
|
|
746
512
|
return store2.setState(
|
|
747
513
|
(s) => ({ ...s, addons: { ...s.addons, [addonId]: merger(s.addons[addonId]) } }),
|
|
748
514
|
options
|
|
749
515
|
).then(() => api.getAddonState(addonId));
|
|
750
516
|
},
|
|
751
|
-
getAddonState:
|
|
752
|
-
return store2.getState().addons[addonId] || globalThis?.STORYBOOK_ADDON_STATE[addonId];
|
|
753
|
-
}, "getAddonState")
|
|
517
|
+
getAddonState: (addonId) => store2.getState().addons[addonId] || globalThis?.STORYBOOK_ADDON_STATE[addonId]
|
|
754
518
|
};
|
|
755
519
|
return {
|
|
756
520
|
api,
|
|
@@ -762,31 +526,22 @@ var init = /* @__PURE__ */ __name(({ provider, store: store2, fullAPI }) => {
|
|
|
762
526
|
addons: {}
|
|
763
527
|
}
|
|
764
528
|
};
|
|
765
|
-
}
|
|
529
|
+
};
|
|
766
530
|
|
|
767
531
|
// src/manager-api/modules/channel.ts
|
|
768
532
|
var channel_exports = {};
|
|
769
533
|
__export(channel_exports, {
|
|
770
534
|
init: () => init2
|
|
771
535
|
});
|
|
772
|
-
var init2 =
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
emit: /* @__PURE__ */ __name((type, data, ...args) => {
|
|
782
|
-
if (data?.options?.target && data.options.target !== "storybook-preview-iframe" && !data.options.target.startsWith("storybook-ref-")) {
|
|
783
|
-
data.options.target = data.options.target !== "storybook_internal" ? `storybook-ref-${data.options.target}` : "storybook-preview-iframe";
|
|
784
|
-
}
|
|
785
|
-
provider.channel?.emit(type, data, ...args);
|
|
786
|
-
}, "emit")
|
|
787
|
-
};
|
|
788
|
-
return { api, state: {} };
|
|
789
|
-
}, "init");
|
|
536
|
+
var init2 = ({ provider }) => ({ api: {
|
|
537
|
+
getChannel: () => provider.channel,
|
|
538
|
+
on: (type, handler) => (provider.channel?.on(type, handler), () => provider.channel?.off(type, handler)),
|
|
539
|
+
off: (type, handler) => provider.channel?.off(type, handler),
|
|
540
|
+
once: (type, handler) => provider.channel?.once(type, handler),
|
|
541
|
+
emit: (type, data, ...args) => {
|
|
542
|
+
data?.options?.target && data.options.target !== "storybook-preview-iframe" && !data.options.target.startsWith("storybook-ref-") && (data.options.target = data.options.target !== "storybook_internal" ? `storybook-ref-${data.options.target}` : "storybook-preview-iframe"), provider.channel?.emit(type, data, ...args);
|
|
543
|
+
}
|
|
544
|
+
}, state: {} });
|
|
790
545
|
|
|
791
546
|
// src/manager-api/modules/globals.ts
|
|
792
547
|
var globals_exports = {};
|
|
@@ -813,167 +568,104 @@ import { sanitize } from "storybook/internal/csf";
|
|
|
813
568
|
var import_memoizerific = __toESM(require_memoizerific(), 1);
|
|
814
569
|
|
|
815
570
|
// src/manager-api/lib/intersect.ts
|
|
816
|
-
var intersect_default =
|
|
817
|
-
if (!Array.isArray(a) || !Array.isArray(b) || !a.length || !b.length) {
|
|
818
|
-
return [];
|
|
819
|
-
}
|
|
820
|
-
return a.reduce((acc, aValue) => {
|
|
821
|
-
if (b.includes(aValue)) {
|
|
822
|
-
acc.push(aValue);
|
|
823
|
-
}
|
|
824
|
-
return acc;
|
|
825
|
-
}, []);
|
|
826
|
-
}, "default");
|
|
571
|
+
var intersect_default = (a, b) => !Array.isArray(a) || !Array.isArray(b) || !a.length || !b.length ? [] : a.reduce((acc, aValue) => (b.includes(aValue) && acc.push(aValue), acc), []);
|
|
827
572
|
|
|
828
573
|
// src/manager-api/lib/stories.ts
|
|
829
|
-
var TITLE_PATH_SEPARATOR = /\s*\/\s
|
|
830
|
-
var denormalizeStoryParameters = /* @__PURE__ */ __name(({
|
|
574
|
+
var TITLE_PATH_SEPARATOR = /\s*\/\s*/, denormalizeStoryParameters = ({
|
|
831
575
|
globalParameters,
|
|
832
576
|
kindParameters,
|
|
833
577
|
stories
|
|
834
|
-
}) => {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
var transformSetStoriesStoryDataToPreparedStoryIndex = /* @__PURE__ */ __name((stories) => {
|
|
845
|
-
const entries = Object.entries(stories).reduce(
|
|
846
|
-
(acc, [id, story]) => {
|
|
847
|
-
if (!story) {
|
|
848
|
-
return acc;
|
|
849
|
-
}
|
|
850
|
-
const { docsOnly, fileName, ...parameters } = story.parameters;
|
|
851
|
-
const base = {
|
|
852
|
-
title: story.kind,
|
|
853
|
-
id,
|
|
854
|
-
name: story.name,
|
|
855
|
-
importPath: fileName
|
|
856
|
-
};
|
|
857
|
-
if (docsOnly) {
|
|
858
|
-
acc[id] = {
|
|
859
|
-
type: "docs",
|
|
860
|
-
tags: ["stories-mdx"],
|
|
861
|
-
storiesImports: [],
|
|
862
|
-
...base
|
|
863
|
-
};
|
|
864
|
-
} else {
|
|
865
|
-
const { argTypes, args, initialArgs } = story;
|
|
866
|
-
acc[id] = {
|
|
867
|
-
type: "story",
|
|
868
|
-
subtype: "story",
|
|
869
|
-
...base,
|
|
870
|
-
parameters,
|
|
871
|
-
argTypes,
|
|
872
|
-
args,
|
|
873
|
-
initialArgs
|
|
874
|
-
};
|
|
875
|
-
}
|
|
578
|
+
}) => mapValues(stories, (storyData) => ({
|
|
579
|
+
...storyData,
|
|
580
|
+
parameters: combineParameters(
|
|
581
|
+
globalParameters,
|
|
582
|
+
kindParameters[storyData.kind],
|
|
583
|
+
storyData.parameters
|
|
584
|
+
)
|
|
585
|
+
})), transformSetStoriesStoryDataToPreparedStoryIndex = (stories) => ({ v: 5, entries: Object.entries(stories).reduce(
|
|
586
|
+
(acc, [id, story]) => {
|
|
587
|
+
if (!story)
|
|
876
588
|
return acc;
|
|
877
|
-
},
|
|
589
|
+
let { docsOnly, fileName, ...parameters } = story.parameters, base = {
|
|
590
|
+
title: story.kind,
|
|
591
|
+
id,
|
|
592
|
+
name: story.name,
|
|
593
|
+
importPath: fileName
|
|
594
|
+
};
|
|
595
|
+
if (docsOnly)
|
|
596
|
+
acc[id] = {
|
|
597
|
+
type: "docs",
|
|
598
|
+
tags: ["stories-mdx"],
|
|
599
|
+
storiesImports: [],
|
|
600
|
+
...base
|
|
601
|
+
};
|
|
602
|
+
else {
|
|
603
|
+
let { argTypes, args, initialArgs } = story;
|
|
604
|
+
acc[id] = {
|
|
605
|
+
type: "story",
|
|
606
|
+
subtype: "story",
|
|
607
|
+
...base,
|
|
608
|
+
parameters,
|
|
609
|
+
argTypes,
|
|
610
|
+
args,
|
|
611
|
+
initialArgs
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
return acc;
|
|
615
|
+
},
|
|
616
|
+
{}
|
|
617
|
+
) }), transformStoryIndexV2toV3 = (index) => ({
|
|
618
|
+
v: 3,
|
|
619
|
+
stories: Object.values(index.stories).reduce(
|
|
620
|
+
(acc, entry) => (acc[entry.id] = {
|
|
621
|
+
...entry,
|
|
622
|
+
title: entry.kind,
|
|
623
|
+
name: entry.name || entry.story,
|
|
624
|
+
importPath: entry.parameters.fileName || ""
|
|
625
|
+
}, acc),
|
|
878
626
|
{}
|
|
879
|
-
)
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
var transformStoryIndexV2toV3 = /* @__PURE__ */ __name((index) => {
|
|
883
|
-
return {
|
|
884
|
-
v: 3,
|
|
885
|
-
stories: Object.values(index.stories).reduce(
|
|
886
|
-
(acc, entry) => {
|
|
887
|
-
acc[entry.id] = {
|
|
888
|
-
...entry,
|
|
889
|
-
title: entry.kind,
|
|
890
|
-
name: entry.name || entry.story,
|
|
891
|
-
importPath: entry.parameters.fileName || ""
|
|
892
|
-
};
|
|
893
|
-
return acc;
|
|
894
|
-
},
|
|
895
|
-
{}
|
|
896
|
-
)
|
|
897
|
-
};
|
|
898
|
-
}, "transformStoryIndexV2toV3");
|
|
899
|
-
var transformStoryIndexV3toV4 = /* @__PURE__ */ __name((index) => {
|
|
900
|
-
const countByTitle = countBy(Object.values(index.stories), (item) => item.title);
|
|
627
|
+
)
|
|
628
|
+
}), transformStoryIndexV3toV4 = (index) => {
|
|
629
|
+
let countByTitle = countBy(Object.values(index.stories), (item) => item.title);
|
|
901
630
|
return {
|
|
902
631
|
v: 4,
|
|
903
632
|
entries: Object.values(index.stories).reduce(
|
|
904
633
|
(acc, entry) => {
|
|
905
634
|
let type = "story";
|
|
906
|
-
|
|
907
|
-
type = "docs";
|
|
908
|
-
}
|
|
909
|
-
acc[entry.id] = {
|
|
635
|
+
return (entry.parameters?.docsOnly || entry.name === "Page" && countByTitle[entry.title] === 1) && (type = "docs"), acc[entry.id] = {
|
|
910
636
|
type,
|
|
911
637
|
...type === "docs" && { tags: ["stories-mdx"], storiesImports: [] },
|
|
912
638
|
...entry
|
|
913
|
-
};
|
|
914
|
-
delete acc[entry.id].story;
|
|
915
|
-
delete acc[entry.id].kind;
|
|
916
|
-
return acc;
|
|
639
|
+
}, delete acc[entry.id].story, delete acc[entry.id].kind, acc;
|
|
917
640
|
},
|
|
918
641
|
{}
|
|
919
642
|
)
|
|
920
643
|
};
|
|
921
|
-
},
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
},
|
|
933
|
-
{}
|
|
934
|
-
)
|
|
935
|
-
};
|
|
936
|
-
}, "transformStoryIndexV4toV5");
|
|
937
|
-
var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider, docsOptions, filters, allStatuses }) => {
|
|
938
|
-
if (!input.v) {
|
|
644
|
+
}, transformStoryIndexV4toV5 = (index) => ({
|
|
645
|
+
v: 5,
|
|
646
|
+
entries: Object.values(index.entries).reduce(
|
|
647
|
+
(acc, entry) => (acc[entry.id] = {
|
|
648
|
+
...entry,
|
|
649
|
+
tags: entry.tags ? ["dev", "test", ...entry.tags] : ["dev"]
|
|
650
|
+
}, acc),
|
|
651
|
+
{}
|
|
652
|
+
)
|
|
653
|
+
}), transformStoryIndexToStoriesHash = (input, { provider, docsOptions, filters, allStatuses }) => {
|
|
654
|
+
if (!input.v)
|
|
939
655
|
throw new Error("Composition: Missing stories.json version");
|
|
940
|
-
}
|
|
941
656
|
let index = input;
|
|
942
|
-
index = index.v === 2 ? transformStoryIndexV2toV3(index) : index;
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
const entryValues = indexEntries.filter((entry) => {
|
|
949
|
-
const statuses = allStatuses[entry.id] ?? {};
|
|
950
|
-
if (Object.values(statuses).some(({ value }) => value === "status-value:error")) {
|
|
951
|
-
return true;
|
|
952
|
-
}
|
|
953
|
-
if (filterFunctions.every((fn) => fn({ ...entry, statuses }))) {
|
|
954
|
-
return true;
|
|
955
|
-
}
|
|
956
|
-
const children = indexEntries.filter((item) => "parent" in item && item.parent === entry.id);
|
|
957
|
-
return children.some((child) => filterFunctions.every((fn) => fn({ ...child, statuses })));
|
|
958
|
-
});
|
|
959
|
-
const { sidebar = {} } = provider.getConfig();
|
|
960
|
-
const { showRoots, collapsedRoots = [], renderLabel } = sidebar;
|
|
961
|
-
const setShowRoots = typeof showRoots !== "undefined";
|
|
962
|
-
const storiesHashOutOfOrder = entryValues.reduce((acc, item) => {
|
|
963
|
-
if (docsOptions.docsMode && item.type !== "docs") {
|
|
657
|
+
index = index.v === 2 ? transformStoryIndexV2toV3(index) : index, index = index.v === 3 ? transformStoryIndexV3toV4(index) : index, index = index.v === 4 ? transformStoryIndexV4toV5(index) : index, index = index;
|
|
658
|
+
let indexEntries = Object.values(index.entries), filterFunctions = Object.values(filters), entryValues = indexEntries.filter((entry) => {
|
|
659
|
+
let statuses = allStatuses[entry.id] ?? {};
|
|
660
|
+
return Object.values(statuses).some(({ value }) => value === "status-value:error") || filterFunctions.every((fn) => fn({ ...entry, statuses })) ? !0 : indexEntries.filter((item) => "parent" in item && item.parent === entry.id).some((child) => filterFunctions.every((fn) => fn({ ...child, statuses })));
|
|
661
|
+
}), { sidebar = {} } = provider.getConfig(), { showRoots, collapsedRoots = [], renderLabel } = sidebar, setShowRoots = typeof showRoots < "u", storiesHashOutOfOrder = entryValues.reduce((acc, item) => {
|
|
662
|
+
if (docsOptions.docsMode && item.type !== "docs")
|
|
964
663
|
return acc;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
const root = (!setShowRoots || showRoots) && groups.length > 1 ? [groups.shift()] : [];
|
|
969
|
-
const names = [...root, ...groups];
|
|
970
|
-
const paths = names.reduce((list, name, idx) => {
|
|
971
|
-
const parent = idx > 0 && list[idx - 1];
|
|
972
|
-
const id = sanitize(parent ? `${parent}-${name}` : name);
|
|
973
|
-
if (name.trim() === "") {
|
|
664
|
+
let { title } = item, groups = title.trim().split(TITLE_PATH_SEPARATOR), root = (!setShowRoots || showRoots) && groups.length > 1 ? [groups.shift()] : [], names = [...root, ...groups], paths = names.reduce((list, name, idx) => {
|
|
665
|
+
let parent = idx > 0 && list[idx - 1], id = sanitize(parent ? `${parent}-${name}` : name);
|
|
666
|
+
if (name.trim() === "")
|
|
974
667
|
throw new Error(dedent`Invalid title ${title} ending in slash.`);
|
|
975
|
-
|
|
976
|
-
if (parent === id) {
|
|
668
|
+
if (parent === id)
|
|
977
669
|
throw new Error(
|
|
978
670
|
dedent`
|
|
979
671
|
Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}'
|
|
@@ -981,249 +673,150 @@ var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider
|
|
|
981
673
|
Did you create a path that uses the separator char accidentally, such as 'Vue <docs/>' where '/' is a separator char? See https://github.com/storybookjs/storybook/issues/6128
|
|
982
674
|
`
|
|
983
675
|
);
|
|
984
|
-
|
|
985
|
-
list.push(id);
|
|
986
|
-
return list;
|
|
676
|
+
return list.push(id), list;
|
|
987
677
|
}, []);
|
|
988
|
-
paths.forEach((id, idx) => {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
678
|
+
return paths.forEach((id, idx) => {
|
|
679
|
+
let childId = paths[idx + 1] || item.id;
|
|
680
|
+
root.length && idx === 0 ? acc[id] = merge_default(acc[id] || {}, {
|
|
681
|
+
type: "root",
|
|
682
|
+
id,
|
|
683
|
+
name: names[idx],
|
|
684
|
+
tags: [],
|
|
685
|
+
depth: idx,
|
|
686
|
+
renderLabel,
|
|
687
|
+
startCollapsed: collapsedRoots.includes(id),
|
|
688
|
+
// Note that this will later get appended to the previous list of children (see below)
|
|
689
|
+
children: [childId]
|
|
690
|
+
}) : (!acc[id] || acc[id].type === "component") && idx === paths.length - 1 ? acc[id] = merge_default(acc[id] || {}, {
|
|
691
|
+
type: "component",
|
|
692
|
+
id,
|
|
693
|
+
name: names[idx],
|
|
694
|
+
tags: [],
|
|
695
|
+
parent: paths[idx - 1],
|
|
696
|
+
depth: idx,
|
|
697
|
+
renderLabel,
|
|
698
|
+
...childId && {
|
|
1000
699
|
children: [childId]
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
} else {
|
|
1016
|
-
acc[id] = merge_default(acc[id] || {}, {
|
|
1017
|
-
type: "group",
|
|
1018
|
-
id,
|
|
1019
|
-
name: names[idx],
|
|
1020
|
-
tags: [],
|
|
1021
|
-
parent: paths[idx - 1],
|
|
1022
|
-
depth: idx,
|
|
1023
|
-
renderLabel,
|
|
1024
|
-
...childId && {
|
|
1025
|
-
children: [childId]
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
acc[item.id] = {
|
|
700
|
+
}
|
|
701
|
+
}) : acc[id] = merge_default(acc[id] || {}, {
|
|
702
|
+
type: "group",
|
|
703
|
+
id,
|
|
704
|
+
name: names[idx],
|
|
705
|
+
tags: [],
|
|
706
|
+
parent: paths[idx - 1],
|
|
707
|
+
depth: idx,
|
|
708
|
+
renderLabel,
|
|
709
|
+
...childId && {
|
|
710
|
+
children: [childId]
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}), acc[item.id] = {
|
|
1031
714
|
tags: [],
|
|
1032
715
|
...item,
|
|
1033
716
|
depth: paths.length,
|
|
1034
717
|
parent: "parent" in item ? item.parent : paths[paths.length - 1],
|
|
1035
718
|
renderLabel,
|
|
1036
719
|
prepared: !!item.parameters
|
|
1037
|
-
};
|
|
1038
|
-
return acc;
|
|
720
|
+
}, acc;
|
|
1039
721
|
}, {});
|
|
1040
722
|
function addItem(acc, item) {
|
|
1041
|
-
if (
|
|
1042
|
-
acc[item.
|
|
1043
|
-
|
|
1044
|
-
item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId]));
|
|
1045
|
-
item.tags = item.children.reduce((currentTags, childId) => {
|
|
1046
|
-
return currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags);
|
|
1047
|
-
}, null) || [];
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
if (item.type === "component") {
|
|
1051
|
-
const firstChild = acc[item.children[0]];
|
|
1052
|
-
if (firstChild && "importPath" in firstChild) {
|
|
1053
|
-
item.importPath = firstChild.importPath;
|
|
1054
|
-
}
|
|
723
|
+
if (acc[item.id] || (acc[item.id] = item, "children" in item && item.children && (item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId])), item.tags = item.children.reduce((currentTags, childId) => currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags), null) || [])), item.type === "component") {
|
|
724
|
+
let firstChild = acc[item.children[0]];
|
|
725
|
+
firstChild && "importPath" in firstChild && (item.importPath = firstChild.importPath);
|
|
1055
726
|
}
|
|
1056
727
|
return acc;
|
|
1057
728
|
}
|
|
1058
|
-
__name(addItem, "addItem");
|
|
1059
729
|
let storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type !== "root" && !i.parent).reduce((acc, item) => addItem(acc, item), {});
|
|
1060
|
-
storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash)
|
|
1061
|
-
storiesHash = Object.values(storiesHash).reduce((acc, item) => {
|
|
730
|
+
return storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash), storiesHash = Object.values(storiesHash).reduce((acc, item) => {
|
|
1062
731
|
if (item.type === "story" && item.subtype === "test") {
|
|
1063
|
-
|
|
1064
|
-
const component = acc[story.parent];
|
|
732
|
+
let story = acc[item.parent], component = acc[story.parent];
|
|
1065
733
|
acc[component.id] = {
|
|
1066
734
|
...component,
|
|
1067
735
|
// Remove test from the component node as it will be attached to the story node instead
|
|
1068
736
|
children: component.children && component.children.filter((id) => id !== item.id)
|
|
1069
|
-
}
|
|
1070
|
-
acc[story.id] = {
|
|
737
|
+
}, acc[story.id] = {
|
|
1071
738
|
...story,
|
|
1072
739
|
// Add test to the story node
|
|
1073
740
|
children: (story.children || []).concat(item.id)
|
|
1074
|
-
}
|
|
1075
|
-
acc[item.id] = {
|
|
741
|
+
}, acc[item.id] = {
|
|
1076
742
|
...item,
|
|
1077
743
|
depth: item.depth + 1
|
|
1078
744
|
};
|
|
1079
|
-
} else
|
|
745
|
+
} else
|
|
1080
746
|
acc[item.id] = item;
|
|
1081
|
-
}
|
|
1082
747
|
return acc;
|
|
1083
|
-
}, {});
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
if (newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared) {
|
|
1094
|
-
if ("children" in oldEntry) {
|
|
1095
|
-
delete oldEntry.children;
|
|
1096
|
-
}
|
|
1097
|
-
return [id, { ...oldEntry, ...newEntry, prepared: true }];
|
|
1098
|
-
}
|
|
1099
|
-
return [id, newEntry];
|
|
1100
|
-
})
|
|
1101
|
-
);
|
|
1102
|
-
}, "addPreparedStories");
|
|
1103
|
-
var getComponentLookupList = (0, import_memoizerific.default)(1)((hash) => {
|
|
1104
|
-
return Object.entries(hash).reduce((acc, i) => {
|
|
1105
|
-
const value = i[1];
|
|
1106
|
-
if (value.type === "component") {
|
|
1107
|
-
acc.push([...value.children]);
|
|
1108
|
-
}
|
|
1109
|
-
return acc;
|
|
1110
|
-
}, []);
|
|
1111
|
-
});
|
|
1112
|
-
var getStoriesLookupList = (0, import_memoizerific.default)(1)((hash) => {
|
|
1113
|
-
return Object.keys(hash).filter((k) => ["story", "docs"].includes(hash[k].type));
|
|
1114
|
-
});
|
|
748
|
+
}, {}), storiesHash;
|
|
749
|
+
}, addPreparedStories = (newHash, oldHash) => oldHash ? Object.fromEntries(
|
|
750
|
+
Object.entries(newHash).map(([id, newEntry]) => {
|
|
751
|
+
let oldEntry = oldHash[id];
|
|
752
|
+
return newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared ? ("children" in oldEntry && delete oldEntry.children, [id, { ...oldEntry, ...newEntry, prepared: !0 }]) : [id, newEntry];
|
|
753
|
+
})
|
|
754
|
+
) : newHash, getComponentLookupList = (0, import_memoizerific.default)(1)((hash) => Object.entries(hash).reduce((acc, i) => {
|
|
755
|
+
let value = i[1];
|
|
756
|
+
return value.type === "component" && acc.push([...value.children]), acc;
|
|
757
|
+
}, [])), getStoriesLookupList = (0, import_memoizerific.default)(1)((hash) => Object.keys(hash).filter((k) => ["story", "docs"].includes(hash[k].type)));
|
|
1115
758
|
|
|
1116
759
|
// src/manager-api/modules/refs.ts
|
|
1117
|
-
var { location, fetch } = global2
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const localFull = `${localOrigin + localPathname}`.replace("/iframe.html", "").replace(/\/$/, "");
|
|
1122
|
-
const sourceFull = `${sourceOrigin + sourcePathname}`.replace("/iframe.html", "").replace(/\/$/, "");
|
|
1123
|
-
if (localFull === sourceFull) {
|
|
1124
|
-
return ["local", sourceFull];
|
|
1125
|
-
}
|
|
1126
|
-
if (refId || source) {
|
|
1127
|
-
return ["external", sourceFull];
|
|
1128
|
-
}
|
|
1129
|
-
return [null, null];
|
|
1130
|
-
}, "getSourceType");
|
|
1131
|
-
var defaultStoryMapper = /* @__PURE__ */ __name((b, a) => {
|
|
1132
|
-
return { ...a, kind: a.kind.replace("|", "/") };
|
|
1133
|
-
}, "defaultStoryMapper");
|
|
1134
|
-
var addRefIds = /* @__PURE__ */ __name((input, ref) => {
|
|
1135
|
-
return Object.entries(input).reduce((acc, [id, item]) => {
|
|
1136
|
-
return { ...acc, [id]: { ...item, refId: ref.id } };
|
|
1137
|
-
}, {});
|
|
1138
|
-
}, "addRefIds");
|
|
760
|
+
var { location, fetch } = global2, getSourceType = (source, refId) => {
|
|
761
|
+
let { origin: localOrigin, pathname: localPathname } = location, { origin: sourceOrigin, pathname: sourcePathname } = new URL(source), localFull = `${localOrigin + localPathname}`.replace("/iframe.html", "").replace(/\/$/, ""), sourceFull = `${sourceOrigin + sourcePathname}`.replace("/iframe.html", "").replace(/\/$/, "");
|
|
762
|
+
return localFull === sourceFull ? ["local", sourceFull] : refId || source ? ["external", sourceFull] : [null, null];
|
|
763
|
+
}, defaultStoryMapper = (b, a) => ({ ...a, kind: a.kind.replace("|", "/") }), addRefIds = (input, ref) => Object.entries(input).reduce((acc, [id, item]) => ({ ...acc, [id]: { ...item, refId: ref.id } }), {});
|
|
1139
764
|
async function handleRequest(request) {
|
|
1140
|
-
if (!request)
|
|
765
|
+
if (!request)
|
|
1141
766
|
return {};
|
|
1142
|
-
}
|
|
1143
767
|
try {
|
|
1144
|
-
|
|
1145
|
-
if (response ===
|
|
768
|
+
let response = await request;
|
|
769
|
+
if (response === !1 || response === !0)
|
|
1146
770
|
throw new Error("Unexpected boolean response");
|
|
1147
|
-
|
|
1148
|
-
if (!response.ok) {
|
|
771
|
+
if (!response.ok)
|
|
1149
772
|
throw new Error(`Unexpected response not OK: ${response.statusText}`);
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
if (json.entries || json.stories) {
|
|
1153
|
-
return { storyIndex: json };
|
|
1154
|
-
}
|
|
1155
|
-
return json;
|
|
773
|
+
let json = await response.json();
|
|
774
|
+
return json.entries || json.stories ? { storyIndex: json } : json;
|
|
1156
775
|
} catch (err) {
|
|
1157
776
|
return { indexError: err };
|
|
1158
777
|
}
|
|
1159
778
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
let cleanUrl = url;
|
|
1164
|
-
let authorization;
|
|
1165
|
-
const [, credentials] = url.match(credentialsRegex) || [];
|
|
1166
|
-
if (credentials) {
|
|
1167
|
-
cleanUrl = url.replace(`${credentials}@`, "");
|
|
1168
|
-
authorization = btoa(`${credentials}`);
|
|
1169
|
-
}
|
|
1170
|
-
return {
|
|
779
|
+
var parseUrl = (url) => {
|
|
780
|
+
let credentialsRegex = /https?:\/\/(.+:.+)@/, cleanUrl = url, authorization, [, credentials] = url.match(credentialsRegex) || [];
|
|
781
|
+
return credentials && (cleanUrl = url.replace(`${credentials}@`, ""), authorization = btoa(`${credentials}`)), {
|
|
1171
782
|
url: cleanUrl,
|
|
1172
783
|
authorization
|
|
1173
784
|
};
|
|
1174
|
-
},
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
return input;
|
|
1183
|
-
}, "map");
|
|
1184
|
-
var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docsOptions = {} }, { runCheck = true } = {}) => {
|
|
1185
|
-
const api = {
|
|
1186
|
-
findRef: /* @__PURE__ */ __name((source) => {
|
|
1187
|
-
const refs2 = api.getRefs();
|
|
785
|
+
}, map = (input, ref, options) => {
|
|
786
|
+
let { storyMapper } = options;
|
|
787
|
+
return storyMapper ? Object.entries(input).reduce((acc, [id, item]) => ({ ...acc, [id]: storyMapper(ref, item) }), {}) : input;
|
|
788
|
+
}, init3 = ({ store: store2, provider, singleStory, docsOptions = {} }, { runCheck = !0 } = {}) => {
|
|
789
|
+
let api = {
|
|
790
|
+
findRef: (source) => {
|
|
791
|
+
let refs2 = api.getRefs();
|
|
1188
792
|
return Object.values(refs2).find(({ url }) => url.match(source));
|
|
1189
|
-
},
|
|
1190
|
-
changeRefVersion:
|
|
1191
|
-
|
|
1192
|
-
const ref = {
|
|
793
|
+
},
|
|
794
|
+
changeRefVersion: async (id, url) => {
|
|
795
|
+
let { versions, title } = api.getRefs()[id], ref = {
|
|
1193
796
|
id,
|
|
1194
797
|
url,
|
|
1195
798
|
versions,
|
|
1196
799
|
title,
|
|
1197
800
|
index: {},
|
|
1198
801
|
filteredIndex: {},
|
|
1199
|
-
expanded:
|
|
802
|
+
expanded: !0
|
|
1200
803
|
};
|
|
1201
|
-
await api.setRef(id, { ...ref, type: "unknown" },
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
updated[id] = { ...ref, previewInitialized };
|
|
1207
|
-
store2.setState({
|
|
804
|
+
await api.setRef(id, { ...ref, type: "unknown" }, !1), await api.checkRef(ref);
|
|
805
|
+
},
|
|
806
|
+
changeRefState: (id, previewInitialized) => {
|
|
807
|
+
let { [id]: ref, ...updated } = api.getRefs();
|
|
808
|
+
updated[id] = { ...ref, previewInitialized }, store2.setState({
|
|
1208
809
|
refs: updated
|
|
1209
810
|
});
|
|
1210
|
-
},
|
|
1211
|
-
checkRef:
|
|
1212
|
-
|
|
1213
|
-
const isPublic = type === "server-checked";
|
|
1214
|
-
const loadedData = {};
|
|
1215
|
-
const query = version2 ? `?version=${version2}` : "";
|
|
1216
|
-
const credentials = isPublic ? "omit" : "include";
|
|
1217
|
-
const urlParseResult = parseUrl(url);
|
|
1218
|
-
const headers = {
|
|
811
|
+
},
|
|
812
|
+
checkRef: async (ref) => {
|
|
813
|
+
let { id, url, version: version2, type } = ref, isPublic = type === "server-checked", loadedData = {}, query = version2 ? `?version=${version2}` : "", credentials = isPublic ? "omit" : "include", urlParseResult = parseUrl(url), headers = {
|
|
1219
814
|
Accept: "application/json"
|
|
1220
815
|
};
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
const [indexResult, storiesResult] = await Promise.all(
|
|
816
|
+
urlParseResult.authorization && Object.assign(headers, {
|
|
817
|
+
Authorization: `Basic ${urlParseResult.authorization}`
|
|
818
|
+
});
|
|
819
|
+
let [indexResult, storiesResult] = await Promise.all(
|
|
1227
820
|
["index.json", "stories.json"].map(
|
|
1228
821
|
async (file) => handleRequest(
|
|
1229
822
|
fetch(`${urlParseResult.url}/${file}${query}`, {
|
|
@@ -1234,20 +827,19 @@ var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docs
|
|
|
1234
827
|
)
|
|
1235
828
|
);
|
|
1236
829
|
if (!indexResult.indexError || !storiesResult.indexError) {
|
|
1237
|
-
|
|
830
|
+
let metadata = await handleRequest(
|
|
1238
831
|
fetch(`${urlParseResult.url}/metadata.json${query}`, {
|
|
1239
832
|
headers,
|
|
1240
833
|
credentials,
|
|
1241
834
|
cache: "no-cache"
|
|
1242
|
-
}).catch(() =>
|
|
835
|
+
}).catch(() => !1)
|
|
1243
836
|
);
|
|
1244
837
|
Object.assign(loadedData, {
|
|
1245
838
|
...indexResult.indexError ? storiesResult : indexResult,
|
|
1246
839
|
...!metadata.indexError && metadata
|
|
1247
840
|
});
|
|
1248
|
-
} else
|
|
1249
|
-
|
|
1250
|
-
message: dedent`
|
|
841
|
+
} else isPublic || (loadedData.indexError = {
|
|
842
|
+
message: dedent`
|
|
1251
843
|
Error: Loading of ref failed
|
|
1252
844
|
at fetch (lib/api/src/modules/refs.ts)
|
|
1253
845
|
|
|
@@ -1258,95 +850,64 @@ var init3 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory, docs
|
|
|
1258
850
|
|
|
1259
851
|
Please check your dev-tools network tab.
|
|
1260
852
|
`
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
const versions = ref.versions && Object.keys(ref.versions).length ? ref.versions : loadedData.versions;
|
|
853
|
+
});
|
|
854
|
+
let versions = ref.versions && Object.keys(ref.versions).length ? ref.versions : loadedData.versions;
|
|
1264
855
|
await api.setRef(id, {
|
|
1265
856
|
id,
|
|
1266
857
|
url: urlParseResult.url,
|
|
1267
858
|
...loadedData,
|
|
1268
859
|
...versions ? { versions } : {},
|
|
1269
|
-
type:
|
|
860
|
+
type: loadedData.storyIndex ? "lazy" : "auto-inject"
|
|
1270
861
|
});
|
|
1271
|
-
},
|
|
1272
|
-
getRefs:
|
|
1273
|
-
|
|
862
|
+
},
|
|
863
|
+
getRefs: () => {
|
|
864
|
+
let { refs: refs2 = {} } = store2.getState();
|
|
1274
865
|
return refs2;
|
|
1275
|
-
},
|
|
1276
|
-
setRef:
|
|
1277
|
-
if (singleStory)
|
|
866
|
+
},
|
|
867
|
+
setRef: async (id, { storyIndex, setStoriesData, ...rest }, ready = !1) => {
|
|
868
|
+
if (singleStory)
|
|
1278
869
|
return;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
index = transformStoryIndexToStoriesHash(storyIndex, {
|
|
1297
|
-
provider,
|
|
1298
|
-
docsOptions,
|
|
1299
|
-
filters: {},
|
|
1300
|
-
allStatuses: {}
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
if (index) {
|
|
1304
|
-
index = addRefIds(index, ref);
|
|
1305
|
-
}
|
|
1306
|
-
if (filteredIndex) {
|
|
1307
|
-
filteredIndex = addRefIds(filteredIndex, ref);
|
|
1308
|
-
}
|
|
1309
|
-
await api.updateRef(id, { ...ref, ...rest, index, filteredIndex, internal_index });
|
|
1310
|
-
}, "setRef"),
|
|
1311
|
-
updateRef: /* @__PURE__ */ __name(async (id, data) => {
|
|
1312
|
-
const { [id]: ref, ...updated } = api.getRefs();
|
|
870
|
+
let internal_index, index, filteredIndex, { filters } = store2.getState(), { storyMapper = defaultStoryMapper } = provider.getConfig(), ref = api.getRefs()[id];
|
|
871
|
+
(storyIndex || setStoriesData) && (internal_index = setStoriesData ? transformSetStoriesStoryDataToPreparedStoryIndex(
|
|
872
|
+
map(setStoriesData, ref, { storyMapper })
|
|
873
|
+
) : storyIndex, filteredIndex = transformStoryIndexToStoriesHash(storyIndex, {
|
|
874
|
+
provider,
|
|
875
|
+
docsOptions,
|
|
876
|
+
filters,
|
|
877
|
+
allStatuses: {}
|
|
878
|
+
}), index = transformStoryIndexToStoriesHash(storyIndex, {
|
|
879
|
+
provider,
|
|
880
|
+
docsOptions,
|
|
881
|
+
filters: {},
|
|
882
|
+
allStatuses: {}
|
|
883
|
+
})), index && (index = addRefIds(index, ref)), filteredIndex && (filteredIndex = addRefIds(filteredIndex, ref)), await api.updateRef(id, { ...ref, ...rest, index, filteredIndex, internal_index });
|
|
884
|
+
},
|
|
885
|
+
updateRef: async (id, data) => {
|
|
886
|
+
let { [id]: ref, ...updated } = api.getRefs();
|
|
1313
887
|
updated[id] = { ...ref, ...data };
|
|
1314
|
-
|
|
1315
|
-
obj[key] = updated[key];
|
|
1316
|
-
return obj;
|
|
1317
|
-
}, {});
|
|
888
|
+
let ordered = Object.keys(initialState).reduce((obj, key) => (obj[key] = updated[key], obj), {});
|
|
1318
889
|
await store2.setState({
|
|
1319
890
|
refs: ordered
|
|
1320
891
|
});
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
await api.checkRef({ ...ref, stories: {} });
|
|
1329
|
-
}
|
|
1330
|
-
resolve(void 0);
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
return {
|
|
892
|
+
}
|
|
893
|
+
}, refs = !singleStory && global2.REFS || {}, initialState = refs;
|
|
894
|
+
return runCheck && new Promise(async (resolve) => {
|
|
895
|
+
for (let ref of Object.values(refs))
|
|
896
|
+
await api.checkRef({ ...ref, stories: {} });
|
|
897
|
+
resolve(void 0);
|
|
898
|
+
}), {
|
|
1334
899
|
api,
|
|
1335
900
|
state: {
|
|
1336
901
|
refs: initialState
|
|
1337
902
|
}
|
|
1338
903
|
};
|
|
1339
|
-
}
|
|
904
|
+
};
|
|
1340
905
|
|
|
1341
906
|
// src/manager-api/lib/events.ts
|
|
1342
|
-
var getEventMetadata =
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
let
|
|
1346
|
-
if (refId || sourceType === "external") {
|
|
1347
|
-
ref = refId && fullAPI.getRefs()[refId] ? fullAPI.getRefs()[refId] : fullAPI.findRef(sourceLocation);
|
|
1348
|
-
}
|
|
1349
|
-
const meta = {
|
|
907
|
+
var getEventMetadata = (context, fullAPI) => {
|
|
908
|
+
let { source, refId, type } = context, [sourceType, sourceLocation] = getSourceType(source, refId), ref;
|
|
909
|
+
(refId || sourceType === "external") && (ref = refId && fullAPI.getRefs()[refId] ? fullAPI.getRefs()[refId] : fullAPI.findRef(sourceLocation));
|
|
910
|
+
let meta = {
|
|
1350
911
|
source,
|
|
1351
912
|
sourceType,
|
|
1352
913
|
sourceLocation,
|
|
@@ -1354,23 +915,20 @@ var getEventMetadata = /* @__PURE__ */ __name((context, fullAPI) => {
|
|
|
1354
915
|
ref,
|
|
1355
916
|
type
|
|
1356
917
|
};
|
|
1357
|
-
switch (
|
|
1358
|
-
case typeof refId
|
|
918
|
+
switch (!0) {
|
|
919
|
+
case typeof refId == "string":
|
|
1359
920
|
case sourceType === "local":
|
|
1360
|
-
case sourceType === "external":
|
|
921
|
+
case sourceType === "external":
|
|
1361
922
|
return meta;
|
|
1362
|
-
}
|
|
1363
923
|
// if we couldn't find the source, something risky happened, we ignore the input, and log a warning
|
|
1364
|
-
default:
|
|
1365
|
-
logger3.warn(`Received a ${type} frame that was not configured as a ref`);
|
|
1366
|
-
return null;
|
|
1367
|
-
}
|
|
924
|
+
default:
|
|
925
|
+
return logger3.warn(`Received a ${type} frame that was not configured as a ref`), null;
|
|
1368
926
|
}
|
|
1369
|
-
}
|
|
927
|
+
};
|
|
1370
928
|
|
|
1371
929
|
// src/manager-api/modules/globals.ts
|
|
1372
|
-
var init4 =
|
|
1373
|
-
|
|
930
|
+
var init4 = ({ store: store2, fullAPI, provider }) => {
|
|
931
|
+
let api = {
|
|
1374
932
|
getGlobals() {
|
|
1375
933
|
return store2.getState().globals;
|
|
1376
934
|
},
|
|
@@ -1391,66 +949,42 @@ var init4 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
|
|
|
1391
949
|
}
|
|
1392
950
|
});
|
|
1393
951
|
}
|
|
1394
|
-
}
|
|
1395
|
-
const state = {
|
|
952
|
+
}, state = {
|
|
1396
953
|
globals: {},
|
|
1397
954
|
userGlobals: {},
|
|
1398
955
|
storyGlobals: {},
|
|
1399
956
|
globalTypes: {}
|
|
1400
|
-
}
|
|
1401
|
-
const updateGlobals = /* @__PURE__ */ __name(({
|
|
957
|
+
}, updateGlobals = ({
|
|
1402
958
|
globals,
|
|
1403
959
|
storyGlobals,
|
|
1404
960
|
userGlobals
|
|
1405
961
|
}) => {
|
|
1406
|
-
|
|
962
|
+
let {
|
|
1407
963
|
globals: currentGlobals,
|
|
1408
964
|
userGlobals: currentUserGlobals,
|
|
1409
965
|
storyGlobals: currentStoryGlobals
|
|
1410
966
|
} = store2.getState();
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
if (!dequal(userGlobals, currentUserGlobals)) {
|
|
1415
|
-
store2.setState({ userGlobals });
|
|
1416
|
-
}
|
|
1417
|
-
if (!dequal(storyGlobals, currentStoryGlobals)) {
|
|
1418
|
-
store2.setState({ storyGlobals });
|
|
1419
|
-
}
|
|
1420
|
-
}, "updateGlobals");
|
|
1421
|
-
provider.channel?.on(
|
|
967
|
+
dequal(globals, currentGlobals) || store2.setState({ globals }), dequal(userGlobals, currentUserGlobals) || store2.setState({ userGlobals }), dequal(storyGlobals, currentStoryGlobals) || store2.setState({ storyGlobals });
|
|
968
|
+
};
|
|
969
|
+
return provider.channel?.on(
|
|
1422
970
|
GLOBALS_UPDATED,
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
);
|
|
1431
|
-
}
|
|
1432
|
-
}, "handleGlobalsUpdated")
|
|
1433
|
-
);
|
|
1434
|
-
provider.channel?.on(
|
|
971
|
+
function({ globals, storyGlobals, userGlobals }) {
|
|
972
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
973
|
+
ref ? logger4.warn(
|
|
974
|
+
"received a GLOBALS_UPDATED from a non-local ref. This is not currently supported."
|
|
975
|
+
) : updateGlobals({ globals, storyGlobals, userGlobals });
|
|
976
|
+
}
|
|
977
|
+
), provider.channel?.on(
|
|
1435
978
|
SET_GLOBALS,
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
} else if (Object.keys(globals).length > 0) {
|
|
1442
|
-
logger4.warn("received globals from a non-local ref. This is not currently supported.");
|
|
1443
|
-
}
|
|
1444
|
-
if (currentGlobals && Object.keys(currentGlobals).length !== 0 && !dequal(globals, currentGlobals)) {
|
|
1445
|
-
api.updateGlobals(currentGlobals);
|
|
1446
|
-
}
|
|
1447
|
-
}, "handleSetGlobals")
|
|
1448
|
-
);
|
|
1449
|
-
return {
|
|
979
|
+
function({ globals, globalTypes }) {
|
|
980
|
+
let { ref } = getEventMetadata(this, fullAPI), currentGlobals = store2.getState()?.globals;
|
|
981
|
+
ref ? Object.keys(globals).length > 0 && logger4.warn("received globals from a non-local ref. This is not currently supported.") : store2.setState({ globals, userGlobals: globals, globalTypes }), currentGlobals && Object.keys(currentGlobals).length !== 0 && !dequal(globals, currentGlobals) && api.updateGlobals(currentGlobals);
|
|
982
|
+
}
|
|
983
|
+
), {
|
|
1450
984
|
api,
|
|
1451
985
|
state
|
|
1452
986
|
};
|
|
1453
|
-
}
|
|
987
|
+
};
|
|
1454
988
|
|
|
1455
989
|
// src/manager-api/modules/layout.ts
|
|
1456
990
|
var layout_exports = {};
|
|
@@ -1463,20 +997,17 @@ __export(layout_exports, {
|
|
|
1463
997
|
import { SET_CONFIG as SET_CONFIG2 } from "storybook/internal/core-events";
|
|
1464
998
|
import { global as global3 } from "@storybook/global";
|
|
1465
999
|
import { create } from "storybook/theming/create";
|
|
1466
|
-
var { document: document2 } = global3
|
|
1467
|
-
var isFunction = /* @__PURE__ */ __name((val) => typeof val === "function", "isFunction");
|
|
1468
|
-
var ActiveTabs = {
|
|
1000
|
+
var { document: document2 } = global3, isFunction = (val) => typeof val == "function", ActiveTabs = {
|
|
1469
1001
|
SIDEBAR: "sidebar",
|
|
1470
1002
|
CANVAS: "canvas",
|
|
1471
1003
|
ADDONS: "addons"
|
|
1472
|
-
}
|
|
1473
|
-
var defaultLayoutState = {
|
|
1004
|
+
}, defaultLayoutState = {
|
|
1474
1005
|
ui: {
|
|
1475
|
-
enableShortcuts:
|
|
1006
|
+
enableShortcuts: !0
|
|
1476
1007
|
},
|
|
1477
1008
|
layout: {
|
|
1478
1009
|
initialActive: ActiveTabs.CANVAS,
|
|
1479
|
-
showToolbar:
|
|
1010
|
+
showToolbar: !0,
|
|
1480
1011
|
navSize: 300,
|
|
1481
1012
|
bottomPanelHeight: 300,
|
|
1482
1013
|
rightPanelWidth: 400,
|
|
@@ -1486,7 +1017,7 @@ var defaultLayoutState = {
|
|
|
1486
1017
|
rightPanelWidth: 400
|
|
1487
1018
|
},
|
|
1488
1019
|
panelPosition: "bottom",
|
|
1489
|
-
showTabs:
|
|
1020
|
+
showTabs: !0
|
|
1490
1021
|
},
|
|
1491
1022
|
layoutCustomisations: {
|
|
1492
1023
|
showSidebar: void 0,
|
|
@@ -1494,40 +1025,24 @@ var defaultLayoutState = {
|
|
|
1494
1025
|
},
|
|
1495
1026
|
selectedPanel: void 0,
|
|
1496
1027
|
theme: create()
|
|
1497
|
-
}
|
|
1498
|
-
var focusableUIElements = {
|
|
1028
|
+
}, focusableUIElements = {
|
|
1499
1029
|
storySearchField: "storybook-explorer-searchfield",
|
|
1500
1030
|
storyListMenu: "storybook-explorer-menu",
|
|
1501
1031
|
storyPanelRoot: "storybook-panel-root"
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
return state.layout.navSize > 0;
|
|
1505
|
-
}, "getIsNavShown");
|
|
1506
|
-
var getIsPanelShown = /* @__PURE__ */ __name((state) => {
|
|
1507
|
-
const { bottomPanelHeight, rightPanelWidth, panelPosition } = state.layout;
|
|
1032
|
+
}, getIsNavShown = (state) => state.layout.navSize > 0, getIsPanelShown = (state) => {
|
|
1033
|
+
let { bottomPanelHeight, rightPanelWidth, panelPosition } = state.layout;
|
|
1508
1034
|
return panelPosition === "bottom" && bottomPanelHeight > 0 || panelPosition === "right" && rightPanelWidth > 0;
|
|
1509
|
-
},
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
navSize: layoutState.navSize > 0 ? layoutState.navSize : layoutState.recentVisibleSizes.navSize,
|
|
1516
|
-
bottomPanelHeight: layoutState.bottomPanelHeight > 0 ? layoutState.bottomPanelHeight : layoutState.recentVisibleSizes.bottomPanelHeight,
|
|
1517
|
-
rightPanelWidth: layoutState.rightPanelWidth > 0 ? layoutState.rightPanelWidth : layoutState.recentVisibleSizes.rightPanelWidth
|
|
1518
|
-
};
|
|
1519
|
-
}, "getRecentVisibleSizes");
|
|
1520
|
-
var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) => {
|
|
1521
|
-
const api = {
|
|
1035
|
+
}, getIsFullscreen = (state) => !getIsNavShown(state) && !getIsPanelShown(state), getRecentVisibleSizes = (layoutState) => ({
|
|
1036
|
+
navSize: layoutState.navSize > 0 ? layoutState.navSize : layoutState.recentVisibleSizes.navSize,
|
|
1037
|
+
bottomPanelHeight: layoutState.bottomPanelHeight > 0 ? layoutState.bottomPanelHeight : layoutState.recentVisibleSizes.bottomPanelHeight,
|
|
1038
|
+
rightPanelWidth: layoutState.rightPanelWidth > 0 ? layoutState.rightPanelWidth : layoutState.recentVisibleSizes.rightPanelWidth
|
|
1039
|
+
}), init5 = ({ store: store2, provider, singleStory }) => {
|
|
1040
|
+
let api = {
|
|
1522
1041
|
toggleFullscreen(nextState) {
|
|
1523
1042
|
return store2.setState(
|
|
1524
1043
|
(state) => {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
if (shouldFullscreen === isFullscreen) {
|
|
1528
|
-
return { layout: state.layout };
|
|
1529
|
-
}
|
|
1530
|
-
return shouldFullscreen ? {
|
|
1044
|
+
let isFullscreen = getIsFullscreen(state), shouldFullscreen = typeof nextState == "boolean" ? nextState : !isFullscreen;
|
|
1045
|
+
return shouldFullscreen === isFullscreen ? { layout: state.layout } : shouldFullscreen ? {
|
|
1531
1046
|
layout: {
|
|
1532
1047
|
...state.layout,
|
|
1533
1048
|
navSize: 0,
|
|
@@ -1550,12 +1065,8 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1550
1065
|
togglePanel(nextState) {
|
|
1551
1066
|
return store2.setState(
|
|
1552
1067
|
(state) => {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
if (shouldShowPanel === isPanelShown) {
|
|
1556
|
-
return { layout: state.layout };
|
|
1557
|
-
}
|
|
1558
|
-
return shouldShowPanel ? {
|
|
1068
|
+
let isPanelShown = getIsPanelShown(state), shouldShowPanel = typeof nextState == "boolean" ? nextState : !isPanelShown;
|
|
1069
|
+
return shouldShowPanel === isPanelShown ? { layout: state.layout } : shouldShowPanel ? {
|
|
1559
1070
|
layout: {
|
|
1560
1071
|
...state.layout,
|
|
1561
1072
|
bottomPanelHeight: state.layout.recentVisibleSizes.bottomPanelHeight,
|
|
@@ -1576,7 +1087,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1576
1087
|
togglePanelPosition(position) {
|
|
1577
1088
|
return store2.setState(
|
|
1578
1089
|
(state) => {
|
|
1579
|
-
|
|
1090
|
+
let nextPosition = position || (state.layout.panelPosition === "right" ? "bottom" : "right");
|
|
1580
1091
|
return {
|
|
1581
1092
|
layout: {
|
|
1582
1093
|
...state.layout,
|
|
@@ -1592,15 +1103,10 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1592
1103
|
toggleNav(nextState) {
|
|
1593
1104
|
return store2.setState(
|
|
1594
1105
|
(state) => {
|
|
1595
|
-
if (state.singleStory)
|
|
1596
|
-
return { layout: state.layout };
|
|
1597
|
-
}
|
|
1598
|
-
const isNavShown = getIsNavShown(state);
|
|
1599
|
-
const shouldShowNav = typeof nextState === "boolean" ? nextState : !isNavShown;
|
|
1600
|
-
if (shouldShowNav === isNavShown) {
|
|
1106
|
+
if (state.singleStory)
|
|
1601
1107
|
return { layout: state.layout };
|
|
1602
|
-
|
|
1603
|
-
return shouldShowNav ? {
|
|
1108
|
+
let isNavShown = getIsNavShown(state), shouldShowNav = typeof nextState == "boolean" ? nextState : !isNavShown;
|
|
1109
|
+
return shouldShowNav === isNavShown ? { layout: state.layout } : shouldShowNav ? {
|
|
1604
1110
|
layout: {
|
|
1605
1111
|
...state.layout,
|
|
1606
1112
|
navSize: state.layout.recentVisibleSizes.navSize
|
|
@@ -1619,7 +1125,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1619
1125
|
toggleToolbar(toggled) {
|
|
1620
1126
|
return store2.setState(
|
|
1621
1127
|
(state) => {
|
|
1622
|
-
|
|
1128
|
+
let value = typeof toggled < "u" ? toggled : !state.layout.showToolbar;
|
|
1623
1129
|
return {
|
|
1624
1130
|
layout: {
|
|
1625
1131
|
...state.layout,
|
|
@@ -1637,7 +1143,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1637
1143
|
}) {
|
|
1638
1144
|
return store2.setState(
|
|
1639
1145
|
(state) => {
|
|
1640
|
-
|
|
1146
|
+
let nextLayoutState = {
|
|
1641
1147
|
...state.layout,
|
|
1642
1148
|
navSize: navSize ?? state.layout.navSize,
|
|
1643
1149
|
bottomPanelHeight: bottomPanelHeight ?? state.layout.bottomPanelHeight,
|
|
@@ -1653,20 +1159,35 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1653
1159
|
{ persistence: "session" }
|
|
1654
1160
|
);
|
|
1655
1161
|
},
|
|
1162
|
+
/**
|
|
1163
|
+
* Attempts to focus (and select) an element identified by its ID. It is the responsibility of
|
|
1164
|
+
* the callee to ensure that the element is present in the DOM and that no focus trap is
|
|
1165
|
+
* available. This API polls and attempts to perform the focus for a set duration (max 500ms),
|
|
1166
|
+
* so that race conditions can be avoided with the current API design. Because this API is
|
|
1167
|
+
* historically synchronous, it cannot report errors or failure to focus. It fails silently.
|
|
1168
|
+
*
|
|
1169
|
+
* @param elementId The id of the element to focus.
|
|
1170
|
+
* @param select Whether to call select() on the element after focusing it.
|
|
1171
|
+
*/
|
|
1656
1172
|
focusOnUIElement(elementId, select) {
|
|
1657
|
-
if (!elementId)
|
|
1173
|
+
if (!elementId)
|
|
1658
1174
|
return;
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1175
|
+
let startTime = Date.now(), maxDuration = 500, pollInterval = 50, attemptFocus = () => {
|
|
1176
|
+
let element = document2.getElementById(elementId);
|
|
1177
|
+
return !element || (element.focus(), element !== document2.activeElement) ? !1 : (select && element.select?.(), !0);
|
|
1178
|
+
};
|
|
1179
|
+
if (attemptFocus())
|
|
1180
|
+
return;
|
|
1181
|
+
let intervalId = setInterval(() => {
|
|
1182
|
+
if (Date.now() - startTime >= maxDuration) {
|
|
1183
|
+
clearInterval(intervalId);
|
|
1184
|
+
return;
|
|
1665
1185
|
}
|
|
1666
|
-
|
|
1186
|
+
attemptFocus() && clearInterval(intervalId);
|
|
1187
|
+
}, pollInterval);
|
|
1667
1188
|
},
|
|
1668
1189
|
getInitialOptions() {
|
|
1669
|
-
|
|
1190
|
+
let { theme, selectedPanel, layoutCustomisations, ...options } = provider.getConfig();
|
|
1670
1191
|
return {
|
|
1671
1192
|
...defaultLayoutState,
|
|
1672
1193
|
layout: {
|
|
@@ -1695,115 +1216,78 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
|
|
|
1695
1216
|
return getIsNavShown(store2.getState());
|
|
1696
1217
|
},
|
|
1697
1218
|
getShowToolbarWithCustomisations(showToolbar) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
return state.layoutCustomisations.showToolbar(state, showToolbar) ?? showToolbar;
|
|
1701
|
-
}
|
|
1702
|
-
return showToolbar;
|
|
1219
|
+
let state = store2.getState();
|
|
1220
|
+
return isFunction(state.layoutCustomisations.showToolbar) ? state.layoutCustomisations.showToolbar(state, showToolbar) ?? showToolbar : showToolbar;
|
|
1703
1221
|
},
|
|
1704
1222
|
getShowPanelWithCustomisations(showPanel) {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
return state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel;
|
|
1708
|
-
}
|
|
1709
|
-
return showPanel;
|
|
1223
|
+
let state = store2.getState();
|
|
1224
|
+
return isFunction(state.layoutCustomisations.showPanel) ? state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel : showPanel;
|
|
1710
1225
|
},
|
|
1711
1226
|
getNavSizeWithCustomisations(navSize) {
|
|
1712
|
-
|
|
1227
|
+
let state = store2.getState();
|
|
1713
1228
|
if (isFunction(state.layoutCustomisations.showSidebar)) {
|
|
1714
|
-
|
|
1715
|
-
if (navSize === 0 && shouldShowNav ===
|
|
1229
|
+
let shouldShowNav = state.layoutCustomisations.showSidebar(state, navSize !== 0);
|
|
1230
|
+
if (navSize === 0 && shouldShowNav === !0)
|
|
1716
1231
|
return state.layout.recentVisibleSizes.navSize;
|
|
1717
|
-
|
|
1232
|
+
if (navSize !== 0 && shouldShowNav === !1)
|
|
1718
1233
|
return 0;
|
|
1719
|
-
}
|
|
1720
1234
|
}
|
|
1721
1235
|
return navSize;
|
|
1722
1236
|
},
|
|
1723
|
-
setOptions:
|
|
1724
|
-
|
|
1725
|
-
if (!options)
|
|
1237
|
+
setOptions: (options) => {
|
|
1238
|
+
let { layout, ui, selectedPanel, theme } = store2.getState();
|
|
1239
|
+
if (!options)
|
|
1726
1240
|
return;
|
|
1727
|
-
|
|
1728
|
-
const updatedLayout = {
|
|
1241
|
+
let updatedLayout = {
|
|
1729
1242
|
...layout,
|
|
1730
1243
|
...options.layout || {},
|
|
1731
1244
|
...pick(options, Object.keys(layout)),
|
|
1732
1245
|
...singleStory && { navSize: 0 }
|
|
1733
|
-
}
|
|
1734
|
-
const updatedUi = {
|
|
1246
|
+
}, updatedUi = {
|
|
1735
1247
|
...ui,
|
|
1736
1248
|
...options.ui,
|
|
1737
1249
|
...toMerged(options.ui || {}, pick(options, Object.keys(ui)))
|
|
1738
|
-
}
|
|
1739
|
-
const updatedTheme = {
|
|
1250
|
+
}, updatedTheme = {
|
|
1740
1251
|
...theme,
|
|
1741
1252
|
...options.theme
|
|
1742
|
-
};
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
if (!isEqual(layout, updatedLayout)) {
|
|
1748
|
-
modification.layout = updatedLayout;
|
|
1749
|
-
}
|
|
1750
|
-
if (options.selectedPanel && !isEqual(selectedPanel, options.selectedPanel)) {
|
|
1751
|
-
modification.selectedPanel = options.selectedPanel;
|
|
1752
|
-
}
|
|
1753
|
-
if (Object.keys(modification).length) {
|
|
1754
|
-
store2.setState(modification, { persistence: "permanent" });
|
|
1755
|
-
}
|
|
1756
|
-
if (!isEqual(theme, updatedTheme)) {
|
|
1757
|
-
store2.setState({ theme: updatedTheme });
|
|
1758
|
-
}
|
|
1759
|
-
}, "setOptions")
|
|
1760
|
-
};
|
|
1761
|
-
const persisted = pick(store2.getState(), ["layout", "selectedPanel"]);
|
|
1762
|
-
provider.channel?.on(SET_CONFIG2, () => {
|
|
1253
|
+
}, modification = {};
|
|
1254
|
+
isEqual(ui, updatedUi) || (modification.ui = updatedUi), isEqual(layout, updatedLayout) || (modification.layout = updatedLayout), options.selectedPanel && !isEqual(selectedPanel, options.selectedPanel) && (modification.selectedPanel = options.selectedPanel), Object.keys(modification).length && store2.setState(modification, { persistence: "permanent" }), isEqual(theme, updatedTheme) || store2.setState({ theme: updatedTheme });
|
|
1255
|
+
}
|
|
1256
|
+
}, persisted = pick(store2.getState(), ["layout", "selectedPanel"]);
|
|
1257
|
+
return provider.channel?.on(SET_CONFIG2, () => {
|
|
1763
1258
|
api.setOptions(merge_default(api.getInitialOptions(), persisted));
|
|
1764
|
-
})
|
|
1765
|
-
return {
|
|
1259
|
+
}), {
|
|
1766
1260
|
api,
|
|
1767
1261
|
state: merge_default(api.getInitialOptions(), persisted)
|
|
1768
1262
|
};
|
|
1769
|
-
}
|
|
1263
|
+
};
|
|
1770
1264
|
|
|
1771
1265
|
// src/manager-api/modules/notifications.ts
|
|
1772
1266
|
var notifications_exports = {};
|
|
1773
1267
|
__export(notifications_exports, {
|
|
1774
1268
|
init: () => init6
|
|
1775
1269
|
});
|
|
1776
|
-
var init6 =
|
|
1777
|
-
|
|
1778
|
-
addNotification:
|
|
1270
|
+
var init6 = ({ store: store2 }) => ({
|
|
1271
|
+
api: {
|
|
1272
|
+
addNotification: (newNotification) => {
|
|
1779
1273
|
store2.setState(({ notifications }) => {
|
|
1780
|
-
|
|
1781
|
-
existing.forEach((notification) => {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
}
|
|
1785
|
-
});
|
|
1786
|
-
return { notifications: [...others, newNotification] };
|
|
1274
|
+
let [existing, others] = partition(notifications, (n) => n.id === newNotification.id);
|
|
1275
|
+
return existing.forEach((notification) => {
|
|
1276
|
+
notification.onClear && notification.onClear({ dismissed: !1, timeout: !1 });
|
|
1277
|
+
}), { notifications: [...others, newNotification] };
|
|
1787
1278
|
});
|
|
1788
|
-
},
|
|
1789
|
-
clearNotification:
|
|
1279
|
+
},
|
|
1280
|
+
clearNotification: (notificationId) => {
|
|
1790
1281
|
store2.setState(({ notifications }) => {
|
|
1791
|
-
|
|
1792
|
-
matching.forEach((notification) => {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
}
|
|
1796
|
-
});
|
|
1797
|
-
return { notifications: others };
|
|
1282
|
+
let [matching, others] = partition(notifications, (n) => n.id === notificationId);
|
|
1283
|
+
return matching.forEach((notification) => {
|
|
1284
|
+
notification.onClear && notification.onClear({ dismissed: !1, timeout: !1 });
|
|
1285
|
+
}), { notifications: others };
|
|
1798
1286
|
});
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
api,
|
|
1804
|
-
state
|
|
1805
|
-
};
|
|
1806
|
-
}, "init");
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
state: { notifications: [] }
|
|
1290
|
+
});
|
|
1807
1291
|
|
|
1808
1292
|
// src/manager-api/modules/open-in-editor.tsx
|
|
1809
1293
|
var open_in_editor_exports = {};
|
|
@@ -1816,101 +1300,80 @@ import {
|
|
|
1816
1300
|
OPEN_IN_EDITOR_RESPONSE
|
|
1817
1301
|
} from "storybook/internal/core-events";
|
|
1818
1302
|
import { FailedIcon } from "@storybook/icons";
|
|
1819
|
-
var init7 =
|
|
1820
|
-
|
|
1303
|
+
var init7 = ({ provider, fullAPI }) => ({
|
|
1304
|
+
api: {
|
|
1821
1305
|
openInEditor(payload) {
|
|
1822
1306
|
return new Promise((resolve) => {
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
resolve(res);
|
|
1828
|
-
}
|
|
1829
|
-
}, "handler");
|
|
1830
|
-
provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler);
|
|
1831
|
-
provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
|
|
1307
|
+
let { file, line, column } = payload, handler = (res) => {
|
|
1308
|
+
res.file === file && res.line === line && res.column === column && (provider.channel?.off(OPEN_IN_EDITOR_RESPONSE, handler), resolve(res));
|
|
1309
|
+
};
|
|
1310
|
+
provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler), provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
|
|
1832
1311
|
});
|
|
1833
1312
|
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
subHeadline: payload.error || "Check the Storybook process on the command line for more details."
|
|
1848
|
-
},
|
|
1849
|
-
icon: React.createElement(FailedIcon, { color: color.negative }),
|
|
1850
|
-
duration: 8e3
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1313
|
+
},
|
|
1314
|
+
state: { notifications: [] },
|
|
1315
|
+
init: async () => {
|
|
1316
|
+
let { color } = await import("../theming/index.js");
|
|
1317
|
+
provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, (payload) => {
|
|
1318
|
+
payload.error !== null && fullAPI.addNotification({
|
|
1319
|
+
id: "open-in-editor-error",
|
|
1320
|
+
content: {
|
|
1321
|
+
headline: "Failed to open in editor",
|
|
1322
|
+
subHeadline: payload.error || "Check the Storybook process on the command line for more details."
|
|
1323
|
+
},
|
|
1324
|
+
icon: React.createElement(FailedIcon, { color: color.negative }),
|
|
1325
|
+
duration: 8e3
|
|
1853
1326
|
});
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1857
1330
|
|
|
1858
1331
|
// src/manager-api/modules/provider.ts
|
|
1859
1332
|
var provider_exports = {};
|
|
1860
1333
|
__export(provider_exports, {
|
|
1861
1334
|
init: () => init8
|
|
1862
1335
|
});
|
|
1863
|
-
var init8 =
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
};
|
|
1871
|
-
}, "init");
|
|
1336
|
+
var init8 = ({ provider, fullAPI }) => ({
|
|
1337
|
+
api: provider.renderPreview ? { renderPreview: provider.renderPreview } : {},
|
|
1338
|
+
state: {},
|
|
1339
|
+
init: () => {
|
|
1340
|
+
provider.handleAPI(fullAPI);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1872
1343
|
|
|
1873
1344
|
// src/manager-api/modules/settings.ts
|
|
1874
1345
|
var settings_exports = {};
|
|
1875
1346
|
__export(settings_exports, {
|
|
1876
1347
|
init: () => init9
|
|
1877
1348
|
});
|
|
1878
|
-
var init9 =
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
const api = {
|
|
1884
|
-
closeSettings: /* @__PURE__ */ __name(() => {
|
|
1885
|
-
const {
|
|
1349
|
+
var init9 = ({ store: store2, navigate, fullAPI }) => ({
|
|
1350
|
+
state: { settings: { lastTrackedStoryId: null } },
|
|
1351
|
+
api: {
|
|
1352
|
+
closeSettings: () => {
|
|
1353
|
+
let {
|
|
1886
1354
|
settings: { lastTrackedStoryId }
|
|
1887
1355
|
} = store2.getState();
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
fullAPI.selectFirstStory();
|
|
1892
|
-
}
|
|
1893
|
-
}, "closeSettings"),
|
|
1894
|
-
changeSettingsTab: /* @__PURE__ */ __name((path) => {
|
|
1356
|
+
lastTrackedStoryId ? fullAPI.selectStory(lastTrackedStoryId) : fullAPI.selectFirstStory();
|
|
1357
|
+
},
|
|
1358
|
+
changeSettingsTab: (path) => {
|
|
1895
1359
|
navigate(`/settings/${path}`);
|
|
1896
|
-
},
|
|
1897
|
-
isSettingsScreenActive
|
|
1360
|
+
},
|
|
1361
|
+
isSettingsScreenActive: () => {
|
|
1362
|
+
let { path } = fullAPI.getUrlState();
|
|
1363
|
+
return !!(path || "").match(/^\/settings/);
|
|
1364
|
+
},
|
|
1898
1365
|
retrieveSelection() {
|
|
1899
|
-
|
|
1366
|
+
let { settings } = store2.getState();
|
|
1900
1367
|
return settings.lastTrackedStoryId;
|
|
1901
1368
|
},
|
|
1902
|
-
storeSelection:
|
|
1903
|
-
|
|
1369
|
+
storeSelection: async () => {
|
|
1370
|
+
let { storyId, settings } = store2.getState();
|
|
1904
1371
|
await store2.setState({
|
|
1905
1372
|
settings: { ...settings, lastTrackedStoryId: storyId }
|
|
1906
1373
|
});
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
state: { settings: { lastTrackedStoryId: null } },
|
|
1911
|
-
api
|
|
1912
|
-
};
|
|
1913
|
-
}, "init");
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1914
1377
|
|
|
1915
1378
|
// src/manager-api/modules/shortcuts.ts
|
|
1916
1379
|
var shortcuts_exports = {};
|
|
@@ -1930,33 +1393,17 @@ import {
|
|
|
1930
1393
|
} from "storybook/internal/core-events";
|
|
1931
1394
|
import { global as global5 } from "@storybook/global";
|
|
1932
1395
|
|
|
1933
|
-
// src/manager-api/lib/
|
|
1396
|
+
// src/manager-api/lib/platform.ts
|
|
1934
1397
|
import { global as global4 } from "@storybook/global";
|
|
1935
|
-
var { navigator: navigator2 } = global4;
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
var
|
|
1939
|
-
|
|
1940
|
-
var isShortcutTaken = /* @__PURE__ */ __name((arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2), "isShortcutTaken");
|
|
1941
|
-
var eventToShortcut = /* @__PURE__ */ __name((e) => {
|
|
1942
|
-
if (["Meta", "Alt", "Control", "Shift"].includes(e.key)) {
|
|
1398
|
+
var { navigator: navigator2 } = global4, isMacLike = () => navigator2 && navigator2.platform ? !!navigator2.platform.match(/(Mac|iPhone|iPod|iPad)/i) : !1;
|
|
1399
|
+
|
|
1400
|
+
// src/manager-api/lib/shortcut.ts
|
|
1401
|
+
var controlOrMetaSymbol = () => isMacLike() ? "\u2318" : "ctrl", controlOrMetaKey = () => isMacLike() ? "meta" : "control", optionOrAltSymbol = () => isMacLike() ? "\u2325" : "alt", isShortcutTaken = (arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2), eventToShortcut = (e) => {
|
|
1402
|
+
if (["Meta", "Alt", "Control", "Shift", "Tab"].includes(e.key))
|
|
1943
1403
|
return null;
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
keys2.push("alt");
|
|
1948
|
-
}
|
|
1949
|
-
if (e.ctrlKey) {
|
|
1950
|
-
keys2.push("control");
|
|
1951
|
-
}
|
|
1952
|
-
if (e.metaKey) {
|
|
1953
|
-
keys2.push("meta");
|
|
1954
|
-
}
|
|
1955
|
-
if (e.shiftKey) {
|
|
1956
|
-
keys2.push("shift");
|
|
1957
|
-
}
|
|
1958
|
-
const codeUpper = e.code?.toUpperCase();
|
|
1959
|
-
const codeToCharMap = {
|
|
1404
|
+
let keys2 = [];
|
|
1405
|
+
e.altKey && keys2.push("alt"), e.ctrlKey && keys2.push("control"), e.metaKey && keys2.push("meta"), e.shiftKey && keys2.push("shift");
|
|
1406
|
+
let codeUpper = e.code?.toUpperCase(), codeToCharMap = {
|
|
1960
1407
|
MINUS: "-",
|
|
1961
1408
|
EQUAL: "=",
|
|
1962
1409
|
BRACKETLEFT: "[",
|
|
@@ -1968,104 +1415,21 @@ var eventToShortcut = /* @__PURE__ */ __name((e) => {
|
|
|
1968
1415
|
COMMA: ",",
|
|
1969
1416
|
PERIOD: ".",
|
|
1970
1417
|
SLASH: "/"
|
|
1971
|
-
};
|
|
1972
|
-
const codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : codeToCharMap[codeUpper] : void 0;
|
|
1418
|
+
}, codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : codeToCharMap[codeUpper] : void 0;
|
|
1973
1419
|
if (e.key && e.key.length === 1 && e.key !== " ") {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
} else if (e.key === "Dead" && codeChar) {
|
|
1982
|
-
keys2.push(codeChar);
|
|
1983
|
-
}
|
|
1984
|
-
if (e.key === " ") {
|
|
1985
|
-
keys2.push("space");
|
|
1986
|
-
}
|
|
1987
|
-
if (e.key === "Escape") {
|
|
1988
|
-
keys2.push("escape");
|
|
1989
|
-
}
|
|
1990
|
-
if (e.key === "ArrowRight") {
|
|
1991
|
-
keys2.push("ArrowRight");
|
|
1992
|
-
}
|
|
1993
|
-
if (e.key === "ArrowDown") {
|
|
1994
|
-
keys2.push("ArrowDown");
|
|
1995
|
-
}
|
|
1996
|
-
if (e.key === "ArrowUp") {
|
|
1997
|
-
keys2.push("ArrowUp");
|
|
1998
|
-
}
|
|
1999
|
-
if (e.key === "ArrowLeft") {
|
|
2000
|
-
keys2.push("ArrowLeft");
|
|
2001
|
-
}
|
|
2002
|
-
return keys2.length > 0 ? keys2 : null;
|
|
2003
|
-
}, "eventToShortcut");
|
|
2004
|
-
var shortcutMatchesShortcut = /* @__PURE__ */ __name((inputShortcut, shortcut) => {
|
|
2005
|
-
if (!inputShortcut || !shortcut) {
|
|
2006
|
-
return false;
|
|
2007
|
-
}
|
|
2008
|
-
if (inputShortcut.join("").startsWith("shift/")) {
|
|
2009
|
-
inputShortcut.shift();
|
|
2010
|
-
}
|
|
2011
|
-
if (inputShortcut.length !== shortcut.length) {
|
|
2012
|
-
return false;
|
|
2013
|
-
}
|
|
2014
|
-
return !inputShortcut.find(
|
|
2015
|
-
(input, i) => Array.isArray(input) ? !input.includes(shortcut[i]) : input !== shortcut[i]
|
|
2016
|
-
);
|
|
2017
|
-
}, "shortcutMatchesShortcut");
|
|
2018
|
-
var eventMatchesShortcut = /* @__PURE__ */ __name((e, shortcut) => {
|
|
2019
|
-
return shortcutMatchesShortcut(eventToShortcut(e), shortcut);
|
|
2020
|
-
}, "eventMatchesShortcut");
|
|
2021
|
-
var keyToSymbol = /* @__PURE__ */ __name((key) => {
|
|
2022
|
-
if (key === "alt") {
|
|
2023
|
-
return optionOrAltSymbol();
|
|
2024
|
-
}
|
|
2025
|
-
if (key === "control") {
|
|
2026
|
-
return "\u2303";
|
|
2027
|
-
}
|
|
2028
|
-
if (key === "meta") {
|
|
2029
|
-
return "\u2318";
|
|
2030
|
-
}
|
|
2031
|
-
if (key === "shift") {
|
|
2032
|
-
return "\u21E7\u200B";
|
|
2033
|
-
}
|
|
2034
|
-
if (key === "Enter" || key === "Backspace" || key === "Esc") {
|
|
2035
|
-
return "";
|
|
2036
|
-
}
|
|
2037
|
-
if (key === "escape") {
|
|
2038
|
-
return "";
|
|
2039
|
-
}
|
|
2040
|
-
if (key === " ") {
|
|
2041
|
-
return "SPACE";
|
|
2042
|
-
}
|
|
2043
|
-
if (key === "ArrowUp") {
|
|
2044
|
-
return "\u2191";
|
|
2045
|
-
}
|
|
2046
|
-
if (key === "ArrowDown") {
|
|
2047
|
-
return "\u2193";
|
|
2048
|
-
}
|
|
2049
|
-
if (key === "ArrowLeft") {
|
|
2050
|
-
return "\u2190";
|
|
2051
|
-
}
|
|
2052
|
-
if (key === "ArrowRight") {
|
|
2053
|
-
return "\u2192";
|
|
2054
|
-
}
|
|
2055
|
-
return key?.toUpperCase();
|
|
2056
|
-
}, "keyToSymbol");
|
|
2057
|
-
var shortcutToHumanString = /* @__PURE__ */ __name((shortcut) => {
|
|
2058
|
-
return shortcut.map(keyToSymbol).join(" ");
|
|
2059
|
-
}, "shortcutToHumanString");
|
|
1420
|
+
let key = e.key.toUpperCase(), code = codeChar;
|
|
1421
|
+
code && code.length === 1 && code !== key ? keys2.push([key, code]) : keys2.push(key);
|
|
1422
|
+
} else e.key === "Dead" && codeChar && keys2.push(codeChar);
|
|
1423
|
+
return e.key === " " && keys2.push("space"), e.key === "Escape" && keys2.push("escape"), e.key === "ArrowRight" && keys2.push("ArrowRight"), e.key === "ArrowDown" && keys2.push("ArrowDown"), e.key === "ArrowUp" && keys2.push("ArrowUp"), e.key === "ArrowLeft" && keys2.push("ArrowLeft"), keys2.length > 0 ? keys2 : null;
|
|
1424
|
+
}, shortcutMatchesShortcut = (inputShortcut, shortcut) => !inputShortcut || !shortcut || (inputShortcut.join("").startsWith("shift/") && inputShortcut.shift(), inputShortcut.length !== shortcut.length) ? !1 : !inputShortcut.find(
|
|
1425
|
+
(input, i) => Array.isArray(input) ? !input.includes(shortcut[i]) : input !== shortcut[i]
|
|
1426
|
+
), eventMatchesShortcut = (e, shortcut) => shortcutMatchesShortcut(eventToShortcut(e), shortcut), keyToSymbol = (key) => key === "alt" ? optionOrAltSymbol() : key === "control" ? "\u2303" : key === "meta" ? "\u2318" : key === "shift" ? "\u21E7\u200B" : key === "Enter" || key === "Backspace" || key === "Esc" || key === "escape" ? "" : key === " " ? "SPACE" : key === "ArrowUp" ? "\u2191" : key === "ArrowDown" ? "\u2193" : key === "ArrowLeft" ? "\u2190" : key === "ArrowRight" ? "\u2192" : key?.toUpperCase(), shortcutToHumanString = (shortcut) => shortcut.map(keyToSymbol).join(" "), shortcutToAriaKeyshortcuts = (shortcut) => shortcut.map((shortcut2) => shortcut2 === "+" ? "plus" : shortcut2 === " " ? "space" : shortcut2).join("+");
|
|
2060
1427
|
|
|
2061
1428
|
// src/manager-api/modules/shortcuts.ts
|
|
2062
|
-
var { navigator: navigator3, document: document3 } = global5;
|
|
2063
|
-
var isMacLike2 = /* @__PURE__ */ __name(() => navigator3 && navigator3.platform ? !!navigator3.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
|
|
2064
|
-
var controlOrMetaKey2 = /* @__PURE__ */ __name(() => isMacLike2() ? "meta" : "control", "controlOrMetaKey");
|
|
1429
|
+
var { navigator: navigator3, document: document3 } = global5, isMacLike2 = () => navigator3 && navigator3.platform ? !!navigator3.platform.match(/(Mac|iPhone|iPod|iPad)/i) : !1, controlOrMetaKey2 = () => isMacLike2() ? "meta" : "control";
|
|
2065
1430
|
function keys(o) {
|
|
2066
1431
|
return Object.keys(o);
|
|
2067
1432
|
}
|
|
2068
|
-
__name(keys, "keys");
|
|
2069
1433
|
var defaultShortcuts = Object.freeze({
|
|
2070
1434
|
fullScreen: ["alt", "F"],
|
|
2071
1435
|
togglePanel: ["alt", "A"],
|
|
@@ -2091,22 +1455,13 @@ var defaultShortcuts = Object.freeze({
|
|
|
2091
1455
|
copyStoryLink: ["alt", "shift", "L"]
|
|
2092
1456
|
// TODO: bring this back once we want to add shortcuts for this
|
|
2093
1457
|
// copyStoryName: ['alt', 'shift', 'C'],
|
|
2094
|
-
});
|
|
2095
|
-
var addonsShortcuts = {};
|
|
1458
|
+
}), addonsShortcuts = {};
|
|
2096
1459
|
function shouldSkipShortcut(event) {
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
return true;
|
|
2100
|
-
}
|
|
2101
|
-
const dialogElement = target.closest("dialog[open]");
|
|
2102
|
-
if (dialogElement) {
|
|
2103
|
-
return true;
|
|
2104
|
-
}
|
|
2105
|
-
return false;
|
|
1460
|
+
let target = event.target;
|
|
1461
|
+
return !!(/input|textarea/i.test(target.tagName) || target.getAttribute("contenteditable") !== null || target.closest("dialog[open]"));
|
|
2106
1462
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
const api = {
|
|
1463
|
+
var init10 = ({ store: store2, fullAPI, provider }) => {
|
|
1464
|
+
let api = {
|
|
2110
1465
|
// Getting and setting shortcuts
|
|
2111
1466
|
getShortcutKeys() {
|
|
2112
1467
|
return store2.getState().shortcuts;
|
|
@@ -2121,227 +1476,174 @@ var init10 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
|
|
|
2121
1476
|
return addonsShortcuts;
|
|
2122
1477
|
},
|
|
2123
1478
|
getAddonsShortcutLabels() {
|
|
2124
|
-
|
|
2125
|
-
Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => {
|
|
1479
|
+
let labels = {};
|
|
1480
|
+
return Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => {
|
|
2126
1481
|
labels[actionName] = label;
|
|
2127
|
-
});
|
|
2128
|
-
return labels;
|
|
1482
|
+
}), labels;
|
|
2129
1483
|
},
|
|
2130
1484
|
getAddonsShortcutDefaults() {
|
|
2131
|
-
|
|
2132
|
-
Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => {
|
|
1485
|
+
let defaults = {};
|
|
1486
|
+
return Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => {
|
|
2133
1487
|
defaults[actionName] = defaultShortcut;
|
|
2134
|
-
});
|
|
2135
|
-
return defaults;
|
|
1488
|
+
}), defaults;
|
|
2136
1489
|
},
|
|
2137
1490
|
async setShortcuts(shortcuts) {
|
|
2138
|
-
await store2.setState({ shortcuts }, { persistence: "permanent" });
|
|
2139
|
-
return shortcuts;
|
|
1491
|
+
return await store2.setState({ shortcuts }, { persistence: "permanent" }), shortcuts;
|
|
2140
1492
|
},
|
|
2141
1493
|
async restoreAllDefaultShortcuts() {
|
|
2142
1494
|
return api.setShortcuts(api.getDefaultShortcuts());
|
|
2143
1495
|
},
|
|
2144
1496
|
async setShortcut(action, value) {
|
|
2145
|
-
|
|
2146
|
-
await api.setShortcuts({ ...shortcuts, [action]: value });
|
|
2147
|
-
return value;
|
|
1497
|
+
let shortcuts = api.getShortcutKeys();
|
|
1498
|
+
return await api.setShortcuts({ ...shortcuts, [action]: value }), value;
|
|
2148
1499
|
},
|
|
2149
1500
|
async setAddonShortcut(addon, shortcut) {
|
|
2150
|
-
|
|
2151
|
-
await api.setShortcuts({
|
|
1501
|
+
let shortcuts = api.getShortcutKeys();
|
|
1502
|
+
return await api.setShortcuts({
|
|
2152
1503
|
...shortcuts,
|
|
2153
1504
|
[`${addon}-${shortcut.actionName}`]: shortcut.defaultShortcut
|
|
2154
|
-
});
|
|
2155
|
-
addonsShortcuts[`${addon}-${shortcut.actionName}`] = shortcut;
|
|
2156
|
-
return shortcut;
|
|
1505
|
+
}), addonsShortcuts[`${addon}-${shortcut.actionName}`] = shortcut, shortcut;
|
|
2157
1506
|
},
|
|
2158
1507
|
async restoreDefaultShortcut(action) {
|
|
2159
|
-
|
|
1508
|
+
let defaultShortcut = api.getDefaultShortcuts()[action];
|
|
2160
1509
|
return api.setShortcut(action, defaultShortcut);
|
|
2161
1510
|
},
|
|
2162
1511
|
// Listening to shortcut events
|
|
2163
1512
|
handleKeydownEvent(event) {
|
|
2164
|
-
|
|
2165
|
-
const shortcuts = api.getShortcutKeys();
|
|
2166
|
-
const actions = keys(shortcuts);
|
|
2167
|
-
const matchedFeature = actions.find(
|
|
1513
|
+
let shortcut = eventToShortcut(event), shortcuts = api.getShortcutKeys(), matchedFeature = keys(shortcuts).find(
|
|
2168
1514
|
(feature) => shortcutMatchesShortcut(shortcut, shortcuts[feature])
|
|
2169
1515
|
);
|
|
2170
|
-
|
|
2171
|
-
api.handleShortcutFeature(matchedFeature, event);
|
|
2172
|
-
}
|
|
1516
|
+
matchedFeature && api.handleShortcutFeature(matchedFeature, event);
|
|
2173
1517
|
},
|
|
2174
1518
|
// warning: event might not have a full prototype chain because it may originate from the channel
|
|
2175
1519
|
handleShortcutFeature(feature, event) {
|
|
2176
|
-
|
|
1520
|
+
let {
|
|
2177
1521
|
ui: { enableShortcuts },
|
|
2178
1522
|
storyId
|
|
2179
1523
|
} = store2.getState();
|
|
2180
|
-
if (
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
}
|
|
2186
|
-
switch (feature) {
|
|
2187
|
-
case "escape": {
|
|
2188
|
-
if (fullAPI.getIsFullscreen()) {
|
|
2189
|
-
fullAPI.toggleFullscreen(false);
|
|
2190
|
-
} else if (fullAPI.getIsNavShown()) {
|
|
2191
|
-
fullAPI.toggleNav(true);
|
|
1524
|
+
if (enableShortcuts)
|
|
1525
|
+
switch (event?.preventDefault && event.preventDefault(), feature) {
|
|
1526
|
+
case "escape": {
|
|
1527
|
+
fullAPI.getIsFullscreen() ? fullAPI.toggleFullscreen(!1) : fullAPI.getIsNavShown() && fullAPI.toggleNav(!0);
|
|
1528
|
+
break;
|
|
2192
1529
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
if (fullAPI.getIsFullscreen()) {
|
|
2197
|
-
fullAPI.toggleFullscreen(false);
|
|
1530
|
+
case "focusNav": {
|
|
1531
|
+
fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsNavShown() || fullAPI.toggleNav(!0), fullAPI.focusOnUIElement(focusableUIElements.storyListMenu);
|
|
1532
|
+
break;
|
|
2198
1533
|
}
|
|
2199
|
-
|
|
2200
|
-
fullAPI.toggleNav(
|
|
1534
|
+
case "search": {
|
|
1535
|
+
fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsNavShown() || fullAPI.toggleNav(!0), setTimeout(() => {
|
|
1536
|
+
fullAPI.focusOnUIElement(focusableUIElements.storySearchField, !0);
|
|
1537
|
+
}, 0);
|
|
1538
|
+
break;
|
|
2201
1539
|
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
1540
|
+
case "focusIframe": {
|
|
1541
|
+
let element = document3.getElementById("storybook-preview-iframe");
|
|
1542
|
+
if (element)
|
|
1543
|
+
try {
|
|
1544
|
+
element.contentWindow.focus();
|
|
1545
|
+
} catch {
|
|
1546
|
+
}
|
|
1547
|
+
break;
|
|
2208
1548
|
}
|
|
2209
|
-
|
|
2210
|
-
fullAPI.
|
|
1549
|
+
case "focusPanel": {
|
|
1550
|
+
fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsPanelShown() || fullAPI.togglePanel(!0), fullAPI.focusOnUIElement(focusableUIElements.storyPanelRoot);
|
|
1551
|
+
break;
|
|
2211
1552
|
}
|
|
2212
|
-
|
|
2213
|
-
fullAPI.
|
|
2214
|
-
|
|
2215
|
-
break;
|
|
2216
|
-
}
|
|
2217
|
-
case "focusIframe": {
|
|
2218
|
-
const element = document3.getElementById("storybook-preview-iframe");
|
|
2219
|
-
if (element) {
|
|
2220
|
-
try {
|
|
2221
|
-
element.contentWindow.focus();
|
|
2222
|
-
} catch (e) {
|
|
2223
|
-
}
|
|
1553
|
+
case "nextStory": {
|
|
1554
|
+
fullAPI.jumpToStory(1);
|
|
1555
|
+
break;
|
|
2224
1556
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
if (fullAPI.getIsFullscreen()) {
|
|
2229
|
-
fullAPI.toggleFullscreen(false);
|
|
1557
|
+
case "prevStory": {
|
|
1558
|
+
fullAPI.jumpToStory(-1);
|
|
1559
|
+
break;
|
|
2230
1560
|
}
|
|
2231
|
-
|
|
2232
|
-
fullAPI.
|
|
1561
|
+
case "nextComponent": {
|
|
1562
|
+
fullAPI.jumpToComponent(1);
|
|
1563
|
+
break;
|
|
2233
1564
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
case "nextStory": {
|
|
2238
|
-
fullAPI.jumpToStory(1);
|
|
2239
|
-
break;
|
|
2240
|
-
}
|
|
2241
|
-
case "prevStory": {
|
|
2242
|
-
fullAPI.jumpToStory(-1);
|
|
2243
|
-
break;
|
|
2244
|
-
}
|
|
2245
|
-
case "nextComponent": {
|
|
2246
|
-
fullAPI.jumpToComponent(1);
|
|
2247
|
-
break;
|
|
2248
|
-
}
|
|
2249
|
-
case "prevComponent": {
|
|
2250
|
-
fullAPI.jumpToComponent(-1);
|
|
2251
|
-
break;
|
|
2252
|
-
}
|
|
2253
|
-
case "fullScreen": {
|
|
2254
|
-
fullAPI.toggleFullscreen();
|
|
2255
|
-
break;
|
|
2256
|
-
}
|
|
2257
|
-
case "togglePanel": {
|
|
2258
|
-
fullAPI.togglePanel();
|
|
2259
|
-
break;
|
|
2260
|
-
}
|
|
2261
|
-
case "toggleNav": {
|
|
2262
|
-
fullAPI.toggleNav();
|
|
2263
|
-
break;
|
|
2264
|
-
}
|
|
2265
|
-
case "toolbar": {
|
|
2266
|
-
fullAPI.toggleToolbar();
|
|
2267
|
-
break;
|
|
2268
|
-
}
|
|
2269
|
-
case "panelPosition": {
|
|
2270
|
-
if (fullAPI.getIsFullscreen()) {
|
|
2271
|
-
fullAPI.toggleFullscreen(false);
|
|
1565
|
+
case "prevComponent": {
|
|
1566
|
+
fullAPI.jumpToComponent(-1);
|
|
1567
|
+
break;
|
|
2272
1568
|
}
|
|
2273
|
-
|
|
2274
|
-
fullAPI.
|
|
1569
|
+
case "fullScreen": {
|
|
1570
|
+
fullAPI.toggleFullscreen();
|
|
1571
|
+
break;
|
|
2275
1572
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
fullAPI.
|
|
1573
|
+
case "togglePanel": {
|
|
1574
|
+
fullAPI.togglePanel();
|
|
1575
|
+
break;
|
|
1576
|
+
}
|
|
1577
|
+
case "toggleNav": {
|
|
1578
|
+
fullAPI.toggleNav();
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
case "toolbar": {
|
|
1582
|
+
fullAPI.toggleToolbar();
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1585
|
+
case "panelPosition": {
|
|
1586
|
+
fullAPI.getIsFullscreen() && fullAPI.toggleFullscreen(!1), fullAPI.getIsPanelShown() || fullAPI.togglePanel(!0), fullAPI.togglePanelPosition();
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
case "aboutPage": {
|
|
1590
|
+
fullAPI.navigate("/settings/about");
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
case "shortcutsPage": {
|
|
1594
|
+
fullAPI.navigate("/settings/shortcuts");
|
|
1595
|
+
break;
|
|
1596
|
+
}
|
|
1597
|
+
case "collapseAll": {
|
|
1598
|
+
fullAPI.emit(STORIES_COLLAPSE_ALL);
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
case "expandAll": {
|
|
1602
|
+
fullAPI.emit(STORIES_EXPAND_ALL);
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
case "remount": {
|
|
1606
|
+
fullAPI.emit(FORCE_REMOUNT, { storyId });
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
case "openInEditor": {
|
|
1610
|
+
global5.CONFIG_TYPE === "DEVELOPMENT" && fullAPI.openInEditor({
|
|
2302
1611
|
file: fullAPI.getCurrentStoryData().importPath
|
|
2303
1612
|
});
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1615
|
+
// TODO: bring this back once we want to add shortcuts for this
|
|
1616
|
+
// case 'copyStoryName': {
|
|
1617
|
+
// const storyData = fullAPI.getCurrentStoryData();
|
|
1618
|
+
// if (storyData.type === 'story') {
|
|
1619
|
+
// copy(storyData.exportName);
|
|
1620
|
+
// }
|
|
1621
|
+
// break;
|
|
1622
|
+
// }
|
|
1623
|
+
case "copyStoryLink": {
|
|
1624
|
+
(0, import_copy_to_clipboard.default)(window.location.href);
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
default:
|
|
1628
|
+
addonsShortcuts[feature].action();
|
|
1629
|
+
break;
|
|
2318
1630
|
}
|
|
2319
|
-
default:
|
|
2320
|
-
addonsShortcuts[feature].action();
|
|
2321
|
-
break;
|
|
2322
|
-
}
|
|
2323
1631
|
}
|
|
2324
|
-
}
|
|
2325
|
-
const { shortcuts: persistedShortcuts = defaultShortcuts } = store2.getState();
|
|
2326
|
-
const state = {
|
|
1632
|
+
}, { shortcuts: persistedShortcuts = defaultShortcuts } = store2.getState(), state = {
|
|
2327
1633
|
// Any saved shortcuts that are still in our set of defaults
|
|
2328
1634
|
shortcuts: keys(defaultShortcuts).reduce(
|
|
2329
1635
|
(acc, key) => ({ ...acc, [key]: persistedShortcuts[key] || defaultShortcuts[key] }),
|
|
2330
1636
|
defaultShortcuts
|
|
2331
1637
|
)
|
|
2332
1638
|
};
|
|
2333
|
-
|
|
1639
|
+
return { api, state, init: () => {
|
|
2334
1640
|
document3.addEventListener("keydown", (event) => {
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
}
|
|
2338
|
-
});
|
|
2339
|
-
provider.channel?.on(PREVIEW_KEYDOWN, (data) => {
|
|
1641
|
+
shouldSkipShortcut(event) || api.handleKeydownEvent(event);
|
|
1642
|
+
}), provider.channel?.on(PREVIEW_KEYDOWN, (data) => {
|
|
2340
1643
|
api.handleKeydownEvent(data.event);
|
|
2341
1644
|
});
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
}, "init");
|
|
1645
|
+
} };
|
|
1646
|
+
};
|
|
2345
1647
|
|
|
2346
1648
|
// src/manager-api/modules/stories.ts
|
|
2347
1649
|
var stories_exports = {};
|
|
@@ -2374,9 +1676,10 @@ import { global as global6 } from "@storybook/global";
|
|
|
2374
1676
|
|
|
2375
1677
|
// src/server-errors.ts
|
|
2376
1678
|
var import_picocolors = __toESM(require_picocolors_browser(), 1);
|
|
2377
|
-
var
|
|
1679
|
+
var StatusTypeIdMismatchError3 = class extends StorybookError {
|
|
2378
1680
|
constructor(data) {
|
|
2379
1681
|
super({
|
|
1682
|
+
name: "StatusTypeIdMismatchError",
|
|
2380
1683
|
category: "CORE-SERVER" /* CORE_SERVER */,
|
|
2381
1684
|
code: 16,
|
|
2382
1685
|
message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
|
|
@@ -2388,16 +1691,13 @@ var _StatusTypeIdMismatchError = class _StatusTypeIdMismatchError extends Storyb
|
|
|
2388
1691
|
this.data = data;
|
|
2389
1692
|
}
|
|
2390
1693
|
};
|
|
2391
|
-
__name(_StatusTypeIdMismatchError, "StatusTypeIdMismatchError");
|
|
2392
|
-
var StatusTypeIdMismatchError3 = _StatusTypeIdMismatchError;
|
|
2393
1694
|
|
|
2394
1695
|
// src/shared/status-store/index.ts
|
|
2395
1696
|
var UNIVERSAL_STATUS_STORE_OPTIONS = {
|
|
2396
1697
|
id: "storybook/status",
|
|
2397
|
-
leader:
|
|
1698
|
+
leader: !0,
|
|
2398
1699
|
initialState: {}
|
|
2399
|
-
}
|
|
2400
|
-
var StatusStoreEventType = {
|
|
1700
|
+
}, StatusStoreEventType = {
|
|
2401
1701
|
SELECT: "select"
|
|
2402
1702
|
};
|
|
2403
1703
|
function createStatusStore({
|
|
@@ -2405,15 +1705,15 @@ function createStatusStore({
|
|
|
2405
1705
|
useUniversalStore: useUniversalStore2,
|
|
2406
1706
|
environment
|
|
2407
1707
|
}) {
|
|
2408
|
-
|
|
1708
|
+
let fullStatusStore2 = {
|
|
2409
1709
|
getAll() {
|
|
2410
1710
|
return universalStatusStore2.getState();
|
|
2411
1711
|
},
|
|
2412
1712
|
set(statuses) {
|
|
2413
1713
|
universalStatusStore2.setState((state) => {
|
|
2414
|
-
|
|
2415
|
-
for (
|
|
2416
|
-
|
|
1714
|
+
let newState = { ...state };
|
|
1715
|
+
for (let status of statuses) {
|
|
1716
|
+
let { storyId, typeId } = status;
|
|
2417
1717
|
newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
|
|
2418
1718
|
}
|
|
2419
1719
|
return newState;
|
|
@@ -2429,32 +1729,30 @@ function createStatusStore({
|
|
|
2429
1729
|
listener(event.payload);
|
|
2430
1730
|
});
|
|
2431
1731
|
},
|
|
2432
|
-
selectStatuses:
|
|
1732
|
+
selectStatuses: (statuses) => {
|
|
2433
1733
|
universalStatusStore2.send({ type: StatusStoreEventType.SELECT, payload: statuses });
|
|
2434
|
-
},
|
|
1734
|
+
},
|
|
2435
1735
|
unset(storyIds) {
|
|
2436
1736
|
if (!storyIds) {
|
|
2437
1737
|
universalStatusStore2.setState({});
|
|
2438
1738
|
return;
|
|
2439
1739
|
}
|
|
2440
1740
|
universalStatusStore2.setState((state) => {
|
|
2441
|
-
|
|
2442
|
-
for (
|
|
1741
|
+
let newState = { ...state };
|
|
1742
|
+
for (let storyId of storyIds)
|
|
2443
1743
|
delete newState[storyId];
|
|
2444
|
-
}
|
|
2445
1744
|
return newState;
|
|
2446
1745
|
});
|
|
2447
1746
|
},
|
|
2448
1747
|
typeId: void 0
|
|
2449
|
-
}
|
|
2450
|
-
const getStatusStoreByTypeId2 = /* @__PURE__ */ __name((typeId) => ({
|
|
1748
|
+
}, getStatusStoreByTypeId2 = (typeId) => ({
|
|
2451
1749
|
getAll: fullStatusStore2.getAll,
|
|
2452
1750
|
set(statuses) {
|
|
2453
1751
|
universalStatusStore2.setState((state) => {
|
|
2454
|
-
|
|
2455
|
-
for (
|
|
2456
|
-
|
|
2457
|
-
if (status.typeId !== typeId)
|
|
1752
|
+
let newState = { ...state };
|
|
1753
|
+
for (let status of statuses) {
|
|
1754
|
+
let { storyId } = status;
|
|
1755
|
+
if (status.typeId !== typeId)
|
|
2458
1756
|
switch (environment) {
|
|
2459
1757
|
case "server":
|
|
2460
1758
|
throw new StatusTypeIdMismatchError3({
|
|
@@ -2473,7 +1771,6 @@ function createStatusStore({
|
|
|
2473
1771
|
typeId
|
|
2474
1772
|
});
|
|
2475
1773
|
}
|
|
2476
|
-
}
|
|
2477
1774
|
newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
|
|
2478
1775
|
}
|
|
2479
1776
|
return newState;
|
|
@@ -2482,72 +1779,51 @@ function createStatusStore({
|
|
|
2482
1779
|
onAllStatusChange: fullStatusStore2.onAllStatusChange,
|
|
2483
1780
|
onSelect(listener) {
|
|
2484
1781
|
return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
|
|
2485
|
-
|
|
2486
|
-
listener(event.payload);
|
|
2487
|
-
}
|
|
1782
|
+
event.payload.some((status) => status.typeId === typeId) && listener(event.payload);
|
|
2488
1783
|
});
|
|
2489
1784
|
},
|
|
2490
1785
|
unset(storyIds) {
|
|
2491
1786
|
universalStatusStore2.setState((state) => {
|
|
2492
|
-
|
|
2493
|
-
for (
|
|
1787
|
+
let newState = { ...state };
|
|
1788
|
+
for (let storyId in newState)
|
|
2494
1789
|
if (newState[storyId]?.[typeId] && (!storyIds || storyIds?.includes(storyId))) {
|
|
2495
|
-
|
|
1790
|
+
let { [typeId]: omittedStatus, ...storyStatusesWithoutTypeId } = newState[storyId];
|
|
2496
1791
|
newState[storyId] = storyStatusesWithoutTypeId;
|
|
2497
1792
|
}
|
|
2498
|
-
}
|
|
2499
1793
|
return newState;
|
|
2500
1794
|
});
|
|
2501
1795
|
},
|
|
2502
1796
|
typeId
|
|
2503
|
-
})
|
|
2504
|
-
|
|
2505
|
-
return { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
|
|
2506
|
-
}
|
|
2507
|
-
return {
|
|
1797
|
+
});
|
|
1798
|
+
return useUniversalStore2 ? {
|
|
2508
1799
|
getStatusStoreByTypeId: getStatusStoreByTypeId2,
|
|
2509
1800
|
fullStatusStore: fullStatusStore2,
|
|
2510
1801
|
universalStatusStore: universalStatusStore2,
|
|
2511
|
-
useStatusStore:
|
|
2512
|
-
};
|
|
1802
|
+
useStatusStore: (selector) => useUniversalStore2(universalStatusStore2, selector)[0]
|
|
1803
|
+
} : { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
|
|
2513
1804
|
}
|
|
2514
|
-
__name(createStatusStore, "createStatusStore");
|
|
2515
1805
|
|
|
2516
1806
|
// src/shared/universal-store/use-universal-store-manager.ts
|
|
2517
1807
|
import * as React2 from "react";
|
|
2518
|
-
var useUniversalStore =
|
|
2519
|
-
|
|
1808
|
+
var useUniversalStore = (universalStore, selector) => {
|
|
1809
|
+
let snapshotRef = React2.useRef(
|
|
2520
1810
|
selector ? selector(universalStore.getState()) : universalStore.getState()
|
|
2521
|
-
)
|
|
2522
|
-
const subscribe = React2.useCallback(
|
|
1811
|
+
), subscribe = React2.useCallback(
|
|
2523
1812
|
(listener) => universalStore.onStateChange((state2, previousState) => {
|
|
2524
1813
|
if (!selector) {
|
|
2525
|
-
snapshotRef.current = state2;
|
|
2526
|
-
listener();
|
|
1814
|
+
snapshotRef.current = state2, listener();
|
|
2527
1815
|
return;
|
|
2528
1816
|
}
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
const hasChanges = !isEqual(selectedState, selectedPreviousState);
|
|
2532
|
-
if (hasChanges) {
|
|
2533
|
-
snapshotRef.current = selectedState;
|
|
2534
|
-
listener();
|
|
2535
|
-
}
|
|
1817
|
+
let selectedState = selector(state2), selectedPreviousState = selector(previousState);
|
|
1818
|
+
!isEqual(selectedState, selectedPreviousState) && (snapshotRef.current = selectedState, listener());
|
|
2536
1819
|
}),
|
|
2537
1820
|
[universalStore, selector]
|
|
2538
|
-
)
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
const selectedState = selector ? selector(currentState) : currentState;
|
|
2542
|
-
if (isEqual(selectedState, snapshotRef.current)) {
|
|
2543
|
-
return snapshotRef.current;
|
|
2544
|
-
}
|
|
2545
|
-
snapshotRef.current = selectedState;
|
|
2546
|
-
return snapshotRef.current;
|
|
1821
|
+
), getSnapshot = React2.useCallback(() => {
|
|
1822
|
+
let currentState = universalStore.getState(), selectedState = selector ? selector(currentState) : currentState;
|
|
1823
|
+
return isEqual(selectedState, snapshotRef.current) || (snapshotRef.current = selectedState), snapshotRef.current;
|
|
2547
1824
|
}, [universalStore, selector]);
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
}, "useUniversalStore");
|
|
1825
|
+
return [React2.useSyncExternalStore(subscribe, getSnapshot), universalStore.setState];
|
|
1826
|
+
};
|
|
2551
1827
|
|
|
2552
1828
|
// src/manager-api/stores/status.ts
|
|
2553
1829
|
var statusStore = createStatusStore({
|
|
@@ -2557,27 +1833,19 @@ var statusStore = createStatusStore({
|
|
|
2557
1833
|
}),
|
|
2558
1834
|
useUniversalStore,
|
|
2559
1835
|
environment: "manager"
|
|
2560
|
-
});
|
|
2561
|
-
var { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
|
|
1836
|
+
}), { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
|
|
2562
1837
|
|
|
2563
1838
|
// src/manager-api/modules/stories.ts
|
|
2564
|
-
var { fetch: fetch2 } = global6;
|
|
2565
|
-
var STORY_INDEX_PATH = "./index.json";
|
|
2566
|
-
var removedOptions = ["enableShortcuts", "theme", "showRoots"];
|
|
1839
|
+
var { fetch: fetch2 } = global6, STORY_INDEX_PATH = "./index.json", removedOptions = ["enableShortcuts", "theme", "showRoots"];
|
|
2567
1840
|
function removeRemovedOptions(options) {
|
|
2568
|
-
if (!options || typeof options
|
|
1841
|
+
if (!options || typeof options == "string")
|
|
2569
1842
|
return options;
|
|
2570
|
-
}
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
delete result[option];
|
|
2575
|
-
}
|
|
2576
|
-
});
|
|
2577
|
-
return result;
|
|
1843
|
+
let result = { ...options };
|
|
1844
|
+
return removedOptions.forEach((option) => {
|
|
1845
|
+
option in result && delete result[option];
|
|
1846
|
+
}), result;
|
|
2578
1847
|
}
|
|
2579
|
-
|
|
2580
|
-
var init11 = /* @__PURE__ */ __name(({
|
|
1848
|
+
var init11 = ({
|
|
2581
1849
|
fullAPI,
|
|
2582
1850
|
store: store2,
|
|
2583
1851
|
navigate,
|
|
@@ -2586,213 +1854,146 @@ var init11 = /* @__PURE__ */ __name(({
|
|
|
2586
1854
|
viewMode: initialViewMode,
|
|
2587
1855
|
docsOptions = {}
|
|
2588
1856
|
}) => {
|
|
2589
|
-
|
|
1857
|
+
let api = {
|
|
2590
1858
|
storyId: toId,
|
|
2591
|
-
getData:
|
|
2592
|
-
|
|
2593
|
-
if (result?.type === "story" || result?.type === "docs")
|
|
1859
|
+
getData: (storyId, refId) => {
|
|
1860
|
+
let result = api.resolveStory(storyId, refId);
|
|
1861
|
+
if (result?.type === "story" || result?.type === "docs")
|
|
2594
1862
|
return result;
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
},
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
if (refId && !refs[refId]) {
|
|
2608
|
-
return void 0;
|
|
2609
|
-
}
|
|
2610
|
-
if (refId) {
|
|
2611
|
-
return refs?.[refId]?.index?.[storyId] ?? void 0;
|
|
2612
|
-
}
|
|
2613
|
-
return index ? index[storyId] : void 0;
|
|
2614
|
-
}, "resolveStory"),
|
|
2615
|
-
getCurrentStoryData: /* @__PURE__ */ __name(() => {
|
|
2616
|
-
const { storyId, refId } = store2.getState();
|
|
1863
|
+
},
|
|
1864
|
+
isPrepared: (storyId, refId) => {
|
|
1865
|
+
let data = api.getData(storyId, refId);
|
|
1866
|
+
return data ? data.type === "story" ? data.prepared : !0 : !1;
|
|
1867
|
+
},
|
|
1868
|
+
resolveStory: (storyId, refId) => {
|
|
1869
|
+
let { refs, index } = store2.getState();
|
|
1870
|
+
if (!(refId && !refs[refId]))
|
|
1871
|
+
return refId ? refs?.[refId]?.index?.[storyId] ?? void 0 : index ? index[storyId] : void 0;
|
|
1872
|
+
},
|
|
1873
|
+
getCurrentStoryData: () => {
|
|
1874
|
+
let { storyId, refId } = store2.getState();
|
|
2617
1875
|
return api.getData(storyId, refId);
|
|
2618
|
-
},
|
|
2619
|
-
getParameters:
|
|
2620
|
-
|
|
2621
|
-
const data = api.getData(storyId, refId);
|
|
1876
|
+
},
|
|
1877
|
+
getParameters: (storyIdOrCombo, parameterName) => {
|
|
1878
|
+
let { storyId, refId } = typeof storyIdOrCombo == "string" ? { storyId: storyIdOrCombo, refId: void 0 } : storyIdOrCombo, data = api.getData(storyId, refId);
|
|
2622
1879
|
if (["story", "docs"].includes(data?.type)) {
|
|
2623
|
-
|
|
2624
|
-
if (parameters)
|
|
1880
|
+
let { parameters } = data;
|
|
1881
|
+
if (parameters)
|
|
2625
1882
|
return parameterName ? parameters[parameterName] : parameters;
|
|
2626
|
-
}
|
|
2627
1883
|
}
|
|
2628
1884
|
return null;
|
|
2629
|
-
},
|
|
2630
|
-
getCurrentParameter:
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
const story = api.getData(storyId, refId);
|
|
2638
|
-
if (!story) {
|
|
1885
|
+
},
|
|
1886
|
+
getCurrentParameter: (parameterName) => {
|
|
1887
|
+
let { storyId, refId } = store2.getState();
|
|
1888
|
+
return api.getParameters({ storyId, refId }, parameterName) || void 0;
|
|
1889
|
+
},
|
|
1890
|
+
jumpToComponent: (direction) => {
|
|
1891
|
+
let { filteredIndex, storyId, refs, refId } = store2.getState();
|
|
1892
|
+
if (!api.getData(storyId, refId))
|
|
2639
1893
|
return;
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
if (!hash) {
|
|
1894
|
+
let hash = refId ? refs[refId].filteredIndex || {} : filteredIndex;
|
|
1895
|
+
if (!hash)
|
|
2643
1896
|
return;
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
}
|
|
2649
|
-
|
|
2650
|
-
jumpToStory: /* @__PURE__ */ __name((direction) => {
|
|
2651
|
-
const { filteredIndex, storyId, refs, refId } = store2.getState();
|
|
2652
|
-
const story = api.getData(storyId, refId);
|
|
2653
|
-
if (!story) {
|
|
1897
|
+
let result = api.findSiblingStoryId(storyId, hash, direction, !0);
|
|
1898
|
+
result && api.selectStory(result, void 0, { ref: refId });
|
|
1899
|
+
},
|
|
1900
|
+
jumpToStory: (direction) => {
|
|
1901
|
+
let { filteredIndex, storyId, refs, refId } = store2.getState(), story = api.getData(storyId, refId);
|
|
1902
|
+
if (!story)
|
|
2654
1903
|
return;
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
if (!hash) {
|
|
1904
|
+
let hash = story.refId ? refs[story.refId].filteredIndex : filteredIndex;
|
|
1905
|
+
if (!hash)
|
|
2658
1906
|
return;
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
selectFirstStory: /* @__PURE__ */ __name(() => {
|
|
2666
|
-
const { index } = store2.getState();
|
|
2667
|
-
if (!index) {
|
|
1907
|
+
let result = api.findSiblingStoryId(storyId, hash, direction, !1);
|
|
1908
|
+
result && api.selectStory(result, void 0, { ref: refId });
|
|
1909
|
+
},
|
|
1910
|
+
selectFirstStory: () => {
|
|
1911
|
+
let { index } = store2.getState();
|
|
1912
|
+
if (!index)
|
|
2668
1913
|
return;
|
|
2669
|
-
|
|
2670
|
-
const firstStory = Object.keys(index).find((id) => index[id].type === "story");
|
|
1914
|
+
let firstStory = Object.keys(index).find((id) => index[id].type === "story");
|
|
2671
1915
|
if (firstStory) {
|
|
2672
1916
|
api.selectStory(firstStory);
|
|
2673
1917
|
return;
|
|
2674
1918
|
}
|
|
2675
1919
|
navigate("/");
|
|
2676
|
-
},
|
|
2677
|
-
selectStory:
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
if (!name) {
|
|
2695
|
-
const entry = titleOrId ? hash[titleOrId] || hash[sanitize2(titleOrId)] : hash[kindSlug];
|
|
2696
|
-
if (!entry) {
|
|
2697
|
-
throw new Error(`Unknown id or title: '${titleOrId}'`);
|
|
2698
|
-
}
|
|
2699
|
-
if (!gotoStory(entry)) {
|
|
2700
|
-
gotoStory(api.findLeafEntry(filteredHash, entry.id));
|
|
2701
|
-
}
|
|
2702
|
-
} else if (!titleOrId) {
|
|
2703
|
-
gotoStory(hash[toId(kindSlug, name)]);
|
|
2704
|
-
} else {
|
|
2705
|
-
const id = ref ? `${ref}_${toId(titleOrId, name)}` : toId(titleOrId, name);
|
|
2706
|
-
if (hash[id]) {
|
|
2707
|
-
gotoStory(hash[id]);
|
|
2708
|
-
} else {
|
|
2709
|
-
const entry = hash[sanitize2(titleOrId)];
|
|
2710
|
-
if (entry?.type === "component") {
|
|
2711
|
-
const foundId = entry.children.find((childId) => hash[childId].name === name);
|
|
2712
|
-
gotoStory(foundId ? hash[foundId] : void 0);
|
|
1920
|
+
},
|
|
1921
|
+
selectStory: (titleOrId = void 0, name = void 0, options = {}) => {
|
|
1922
|
+
let { ref } = options, { storyId, index, filteredIndex, refs, settings } = store2.getState(), gotoStory = (entry) => entry?.type === "docs" || entry?.type === "story" ? (store2.setState({ settings: { ...settings, lastTrackedStoryId: entry.id } }), navigate(`/${entry.type}/${entry.refId ? `${entry.refId}_${entry.id}` : entry.id}`), !0) : !1, kindSlug = storyId?.split("--", 2)[0], hash = ref ? refs[ref].index : index, filteredHash = ref ? refs[ref].filteredIndex : filteredIndex;
|
|
1923
|
+
if (!(!hash || !filteredHash))
|
|
1924
|
+
if (name)
|
|
1925
|
+
if (!titleOrId)
|
|
1926
|
+
gotoStory(hash[toId(kindSlug, name)]);
|
|
1927
|
+
else {
|
|
1928
|
+
let id = ref ? `${ref}_${toId(titleOrId, name)}` : toId(titleOrId, name);
|
|
1929
|
+
if (hash[id])
|
|
1930
|
+
gotoStory(hash[id]);
|
|
1931
|
+
else {
|
|
1932
|
+
let entry = hash[sanitize2(titleOrId)];
|
|
1933
|
+
if (entry?.type === "component") {
|
|
1934
|
+
let foundId = entry.children.find((childId) => hash[childId].name === name);
|
|
1935
|
+
gotoStory(foundId ? hash[foundId] : void 0);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
2713
1938
|
}
|
|
1939
|
+
else {
|
|
1940
|
+
let entry = titleOrId ? hash[titleOrId] || hash[sanitize2(titleOrId)] : hash[kindSlug];
|
|
1941
|
+
if (!entry)
|
|
1942
|
+
throw new Error(`Unknown id or title: '${titleOrId}'`);
|
|
1943
|
+
gotoStory(entry) || gotoStory(api.findLeafEntry(filteredHash, entry.id));
|
|
2714
1944
|
}
|
|
2715
|
-
|
|
2716
|
-
}, "selectStory"),
|
|
1945
|
+
},
|
|
2717
1946
|
findLeafEntry(index, storyId) {
|
|
2718
|
-
|
|
2719
|
-
if (entry.type === "docs" || entry.type === "story")
|
|
1947
|
+
let entry = index[storyId];
|
|
1948
|
+
if (entry.type === "docs" || entry.type === "story")
|
|
2720
1949
|
return entry;
|
|
2721
|
-
|
|
2722
|
-
const childStoryId = entry.children.find((childId) => index[childId]) || entry.children[0];
|
|
1950
|
+
let childStoryId = entry.children.find((childId) => index[childId]) || entry.children[0];
|
|
2723
1951
|
return api.findLeafEntry(index, childStoryId);
|
|
2724
1952
|
},
|
|
2725
1953
|
findLeafStoryId(index, storyId) {
|
|
2726
1954
|
return api.findLeafEntry(index, storyId)?.id;
|
|
2727
1955
|
},
|
|
2728
1956
|
findAllLeafStoryIds(entryId) {
|
|
2729
|
-
|
|
2730
|
-
if (!index)
|
|
1957
|
+
let { index } = store2.getState();
|
|
1958
|
+
if (!index)
|
|
2731
1959
|
return [];
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
return results;
|
|
2737
|
-
}
|
|
2738
|
-
if (node.type === "story") {
|
|
2739
|
-
results.push(node.id);
|
|
2740
|
-
}
|
|
2741
|
-
if ("children" in node) {
|
|
2742
|
-
node.children?.forEach((childId) => findChildEntriesRecursively(childId, results));
|
|
2743
|
-
}
|
|
2744
|
-
return results;
|
|
2745
|
-
}, "findChildEntriesRecursively");
|
|
1960
|
+
let findChildEntriesRecursively = (currentEntryId, results = []) => {
|
|
1961
|
+
let node = index[currentEntryId];
|
|
1962
|
+
return node && (node.type === "story" && results.push(node.id), "children" in node && node.children?.forEach((childId) => findChildEntriesRecursively(childId, results))), results;
|
|
1963
|
+
};
|
|
2746
1964
|
return findChildEntriesRecursively(entryId, []);
|
|
2747
1965
|
},
|
|
2748
1966
|
findSiblingStoryId(storyId, index, direction, toSiblingGroup) {
|
|
2749
1967
|
if (toSiblingGroup) {
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
if (position2 === lookupList2.length - 1 && direction > 0) {
|
|
2753
|
-
return;
|
|
2754
|
-
}
|
|
2755
|
-
if (position2 === 0 && direction < 0) {
|
|
2756
|
-
return;
|
|
2757
|
-
}
|
|
2758
|
-
if (lookupList2[position2 + direction]) {
|
|
2759
|
-
return lookupList2[position2 + direction][0];
|
|
2760
|
-
}
|
|
2761
|
-
return;
|
|
1968
|
+
let lookupList2 = getComponentLookupList(index), position2 = lookupList2.findIndex((i) => i.includes(storyId));
|
|
1969
|
+
return position2 === lookupList2.length - 1 && direction > 0 || position2 === 0 && direction < 0 ? void 0 : lookupList2[position2 + direction] ? lookupList2[position2 + direction][0] : void 0;
|
|
2762
1970
|
}
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
return;
|
|
2767
|
-
}
|
|
2768
|
-
if (position === 0 && direction < 0) {
|
|
2769
|
-
return;
|
|
2770
|
-
}
|
|
2771
|
-
return lookupList[position + direction];
|
|
1971
|
+
let lookupList = getStoriesLookupList(index), position = lookupList.indexOf(storyId);
|
|
1972
|
+
if (!(position === lookupList.length - 1 && direction > 0) && !(position === 0 && direction < 0))
|
|
1973
|
+
return lookupList[position + direction];
|
|
2772
1974
|
},
|
|
2773
|
-
updateStoryArgs:
|
|
2774
|
-
|
|
1975
|
+
updateStoryArgs: (story, updatedArgs) => {
|
|
1976
|
+
let { id: storyId, refId } = story;
|
|
2775
1977
|
provider.channel?.emit(UPDATE_STORY_ARGS, {
|
|
2776
1978
|
storyId,
|
|
2777
1979
|
updatedArgs,
|
|
2778
1980
|
options: { target: refId }
|
|
2779
1981
|
});
|
|
2780
|
-
},
|
|
2781
|
-
resetStoryArgs:
|
|
2782
|
-
|
|
1982
|
+
},
|
|
1983
|
+
resetStoryArgs: (story, argNames) => {
|
|
1984
|
+
let { id: storyId, refId } = story;
|
|
2783
1985
|
provider.channel?.emit(RESET_STORY_ARGS, {
|
|
2784
1986
|
storyId,
|
|
2785
1987
|
argNames,
|
|
2786
1988
|
options: { target: refId }
|
|
2787
1989
|
});
|
|
2788
|
-
},
|
|
2789
|
-
fetchIndex:
|
|
1990
|
+
},
|
|
1991
|
+
fetchIndex: async () => {
|
|
2790
1992
|
try {
|
|
2791
|
-
|
|
2792
|
-
if (result.status !== 200)
|
|
1993
|
+
let result = await fetch2(STORY_INDEX_PATH);
|
|
1994
|
+
if (result.status !== 200)
|
|
2793
1995
|
throw new Error(await result.text());
|
|
2794
|
-
|
|
2795
|
-
const storyIndex = await result.json();
|
|
1996
|
+
let storyIndex = await result.json();
|
|
2796
1997
|
if (storyIndex.v < 3) {
|
|
2797
1998
|
logger5.warn(`Skipping story index with version v${storyIndex.v}, awaiting SET_STORIES.`);
|
|
2798
1999
|
return;
|
|
@@ -2801,20 +2002,17 @@ var init11 = /* @__PURE__ */ __name(({
|
|
|
2801
2002
|
} catch (err) {
|
|
2802
2003
|
await store2.setState({ indexError: err });
|
|
2803
2004
|
}
|
|
2804
|
-
},
|
|
2005
|
+
},
|
|
2805
2006
|
// The story index we receive on SET_INDEX is "prepared" in that it has parameters
|
|
2806
2007
|
// The story index we receive on fetchStoryIndex is not, but all the prepared fields are optional
|
|
2807
2008
|
// so we can cast one to the other easily enough
|
|
2808
|
-
setIndex:
|
|
2809
|
-
|
|
2810
|
-
const allStatuses = fullStatusStore.getAll();
|
|
2811
|
-
const newFilteredHash = transformStoryIndexToStoriesHash(input, {
|
|
2009
|
+
setIndex: async (input) => {
|
|
2010
|
+
let { filteredIndex: oldFilteredHash, index: oldHash, filters } = store2.getState(), allStatuses = fullStatusStore.getAll(), newFilteredHash = transformStoryIndexToStoriesHash(input, {
|
|
2812
2011
|
provider,
|
|
2813
2012
|
docsOptions,
|
|
2814
2013
|
filters,
|
|
2815
2014
|
allStatuses
|
|
2816
|
-
})
|
|
2817
|
-
const newHash = transformStoryIndexToStoriesHash(input, {
|
|
2015
|
+
}), newHash = transformStoryIndexToStoriesHash(input, {
|
|
2818
2016
|
provider,
|
|
2819
2017
|
docsOptions,
|
|
2820
2018
|
filters: {},
|
|
@@ -2826,152 +2024,105 @@ var init11 = /* @__PURE__ */ __name(({
|
|
|
2826
2024
|
index: addPreparedStories(newHash, oldHash),
|
|
2827
2025
|
indexError: void 0
|
|
2828
2026
|
});
|
|
2829
|
-
},
|
|
2027
|
+
},
|
|
2830
2028
|
// FIXME: is there a bug where filtered stories get added back in on updateStory???
|
|
2831
|
-
updateStory:
|
|
2832
|
-
if (
|
|
2833
|
-
|
|
2834
|
-
if (index) {
|
|
2835
|
-
index[storyId] = {
|
|
2836
|
-
...index[storyId],
|
|
2837
|
-
...update2
|
|
2838
|
-
};
|
|
2839
|
-
}
|
|
2840
|
-
if (filteredIndex) {
|
|
2841
|
-
filteredIndex[storyId] = {
|
|
2842
|
-
...filteredIndex[storyId],
|
|
2843
|
-
...update2
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
if (index || filteredIndex) {
|
|
2847
|
-
await store2.setState({ index, filteredIndex });
|
|
2848
|
-
}
|
|
2849
|
-
} else {
|
|
2850
|
-
const { id: refId, index, filteredIndex } = ref;
|
|
2029
|
+
updateStory: async (storyId, update2, ref) => {
|
|
2030
|
+
if (ref) {
|
|
2031
|
+
let { id: refId, index, filteredIndex } = ref;
|
|
2851
2032
|
index[storyId] = {
|
|
2852
2033
|
...index[storyId],
|
|
2853
2034
|
...update2
|
|
2854
|
-
}
|
|
2855
|
-
filteredIndex[storyId] = {
|
|
2035
|
+
}, filteredIndex[storyId] = {
|
|
2856
2036
|
...filteredIndex[storyId],
|
|
2857
2037
|
...update2
|
|
2858
|
-
};
|
|
2859
|
-
await fullAPI.updateRef(refId, { index, filteredIndex });
|
|
2860
|
-
}
|
|
2861
|
-
}, "updateStory"),
|
|
2862
|
-
updateDocs: /* @__PURE__ */ __name(async (docsId, update2, ref) => {
|
|
2863
|
-
if (!ref) {
|
|
2864
|
-
const { index, filteredIndex } = store2.getState();
|
|
2865
|
-
if (index) {
|
|
2866
|
-
index[docsId] = {
|
|
2867
|
-
...index[docsId],
|
|
2868
|
-
...update2
|
|
2869
|
-
};
|
|
2870
|
-
}
|
|
2871
|
-
if (filteredIndex) {
|
|
2872
|
-
filteredIndex[docsId] = {
|
|
2873
|
-
...filteredIndex[docsId],
|
|
2874
|
-
...update2
|
|
2875
|
-
};
|
|
2876
|
-
}
|
|
2877
|
-
if (index || filteredIndex) {
|
|
2878
|
-
await store2.setState({ index, filteredIndex });
|
|
2879
|
-
}
|
|
2038
|
+
}, await fullAPI.updateRef(refId, { index, filteredIndex });
|
|
2880
2039
|
} else {
|
|
2881
|
-
|
|
2040
|
+
let { index, filteredIndex } = store2.getState();
|
|
2041
|
+
index && (index[storyId] = {
|
|
2042
|
+
...index[storyId],
|
|
2043
|
+
...update2
|
|
2044
|
+
}), filteredIndex && (filteredIndex[storyId] = {
|
|
2045
|
+
...filteredIndex[storyId],
|
|
2046
|
+
...update2
|
|
2047
|
+
}), (index || filteredIndex) && await store2.setState({ index, filteredIndex });
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
updateDocs: async (docsId, update2, ref) => {
|
|
2051
|
+
if (ref) {
|
|
2052
|
+
let { id: refId, index, filteredIndex } = ref;
|
|
2882
2053
|
index[docsId] = {
|
|
2883
2054
|
...index[docsId],
|
|
2884
2055
|
...update2
|
|
2885
|
-
}
|
|
2886
|
-
filteredIndex[docsId] = {
|
|
2056
|
+
}, filteredIndex[docsId] = {
|
|
2887
2057
|
...filteredIndex[docsId],
|
|
2888
2058
|
...update2
|
|
2889
|
-
};
|
|
2890
|
-
await fullAPI.updateRef(refId, { index, filteredIndex });
|
|
2891
|
-
}
|
|
2892
|
-
}, "updateDocs"),
|
|
2893
|
-
setPreviewInitialized: /* @__PURE__ */ __name(async (ref) => {
|
|
2894
|
-
if (!ref) {
|
|
2895
|
-
store2.setState({ previewInitialized: true });
|
|
2059
|
+
}, await fullAPI.updateRef(refId, { index, filteredIndex });
|
|
2896
2060
|
} else {
|
|
2897
|
-
|
|
2061
|
+
let { index, filteredIndex } = store2.getState();
|
|
2062
|
+
index && (index[docsId] = {
|
|
2063
|
+
...index[docsId],
|
|
2064
|
+
...update2
|
|
2065
|
+
}), filteredIndex && (filteredIndex[docsId] = {
|
|
2066
|
+
...filteredIndex[docsId],
|
|
2067
|
+
...update2
|
|
2068
|
+
}), (index || filteredIndex) && await store2.setState({ index, filteredIndex });
|
|
2898
2069
|
}
|
|
2899
|
-
},
|
|
2900
|
-
|
|
2070
|
+
},
|
|
2071
|
+
setPreviewInitialized: async (ref) => {
|
|
2072
|
+
ref ? fullAPI.updateRef(ref.id, { previewInitialized: !0 }) : store2.setState({ previewInitialized: !0 });
|
|
2073
|
+
},
|
|
2074
|
+
experimental_setFilter: async (id, filterFunction) => {
|
|
2901
2075
|
await store2.setState({ filters: { ...store2.getState().filters, [id]: filterFunction } });
|
|
2902
|
-
|
|
2903
|
-
if (!index)
|
|
2076
|
+
let { internal_index: index } = store2.getState();
|
|
2077
|
+
if (!index)
|
|
2904
2078
|
return;
|
|
2905
|
-
}
|
|
2906
2079
|
await api.setIndex(index);
|
|
2907
|
-
|
|
2080
|
+
let refs = await fullAPI.getRefs();
|
|
2908
2081
|
Object.entries(refs).forEach(([refId, { internal_index, ...ref }]) => {
|
|
2909
|
-
fullAPI.setRef(refId, { ...ref, storyIndex: internal_index },
|
|
2910
|
-
});
|
|
2911
|
-
|
|
2912
|
-
}, "experimental_setFilter")
|
|
2082
|
+
fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, !0);
|
|
2083
|
+
}), provider.channel?.emit(SET_FILTER, { id });
|
|
2084
|
+
}
|
|
2913
2085
|
};
|
|
2914
2086
|
provider.channel?.on(
|
|
2915
2087
|
STORY_SPECIFIED,
|
|
2916
|
-
|
|
2088
|
+
function({
|
|
2917
2089
|
storyId,
|
|
2918
2090
|
viewMode
|
|
2919
2091
|
}) {
|
|
2920
|
-
|
|
2092
|
+
let { sourceType } = getEventMetadata(this, fullAPI);
|
|
2921
2093
|
if (sourceType === "local") {
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
const isStory = !(type === "root" || type === "component" || type === "group");
|
|
2928
|
-
if (isCanvasRoute) {
|
|
2929
|
-
if (stateHasSelection && stateSelectionDifferent && isStory) {
|
|
2930
|
-
provider.channel?.emit(SET_CURRENT_STORY, {
|
|
2931
|
-
storyId: state.storyId,
|
|
2932
|
-
viewMode: state.viewMode
|
|
2933
|
-
});
|
|
2934
|
-
} else if (stateSelectionDifferent) {
|
|
2935
|
-
navigate(`/${viewMode}/${storyId}`);
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2094
|
+
let state = store2.getState(), isCanvasRoute = state.path === "/" || state.viewMode === "story" || state.viewMode === "docs", stateHasSelection = state.viewMode && state.storyId, stateSelectionDifferent = state.viewMode !== viewMode || state.storyId !== storyId, { type } = state.index?.[state.storyId] || {};
|
|
2095
|
+
isCanvasRoute && (stateHasSelection && stateSelectionDifferent && !(type === "root" || type === "component" || type === "group") ? provider.channel?.emit(SET_CURRENT_STORY, {
|
|
2096
|
+
storyId: state.storyId,
|
|
2097
|
+
viewMode: state.viewMode
|
|
2098
|
+
}) : stateSelectionDifferent && navigate(`/${viewMode}/${storyId}`));
|
|
2938
2099
|
}
|
|
2939
|
-
}
|
|
2940
|
-
)
|
|
2941
|
-
|
|
2942
|
-
const { ref } = getEventMetadata(this, fullAPI);
|
|
2100
|
+
}
|
|
2101
|
+
), provider.channel?.on(CURRENT_STORY_WAS_SET, function() {
|
|
2102
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
2943
2103
|
api.setPreviewInitialized(ref);
|
|
2944
|
-
},
|
|
2945
|
-
|
|
2946
|
-
const { sourceType } = getEventMetadata(this, fullAPI);
|
|
2104
|
+
}), provider.channel?.on(STORY_CHANGED, function() {
|
|
2105
|
+
let { sourceType } = getEventMetadata(this, fullAPI);
|
|
2947
2106
|
if (sourceType === "local") {
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
fullAPI.setOptions(removeRemovedOptions(options));
|
|
2951
|
-
}
|
|
2107
|
+
let options = api.getCurrentParameter("options");
|
|
2108
|
+
options && fullAPI.setOptions(removeRemovedOptions(options));
|
|
2952
2109
|
}
|
|
2953
|
-
},
|
|
2954
|
-
provider.channel?.on(
|
|
2110
|
+
}), provider.channel?.on(
|
|
2955
2111
|
STORY_PREPARED,
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
api.updateStory(id, { ...update2, prepared:
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
const { options } = update2.parameters;
|
|
2962
|
-
fullAPI.setOptions(removeRemovedOptions(options));
|
|
2963
|
-
store2.setState({ hasCalledSetOptions: true });
|
|
2964
|
-
}
|
|
2112
|
+
function({ id, ...update2 }) {
|
|
2113
|
+
let { ref, sourceType } = getEventMetadata(this, fullAPI);
|
|
2114
|
+
if (api.updateStory(id, { ...update2, prepared: !0 }, ref), !ref && !store2.getState().hasCalledSetOptions) {
|
|
2115
|
+
let { options } = update2.parameters;
|
|
2116
|
+
fullAPI.setOptions(removeRemovedOptions(options)), store2.setState({ hasCalledSetOptions: !0 });
|
|
2965
2117
|
}
|
|
2966
2118
|
if (sourceType === "local") {
|
|
2967
|
-
|
|
2968
|
-
if (!index)
|
|
2119
|
+
let { storyId, index, refId } = store2.getState();
|
|
2120
|
+
if (!index)
|
|
2969
2121
|
return;
|
|
2970
|
-
|
|
2971
|
-
const toBePreloaded = Array.from(
|
|
2122
|
+
let toBePreloaded = Array.from(
|
|
2972
2123
|
/* @__PURE__ */ new Set([
|
|
2973
|
-
api.findSiblingStoryId(storyId, index, 1,
|
|
2974
|
-
api.findSiblingStoryId(storyId, index, -1,
|
|
2124
|
+
api.findSiblingStoryId(storyId, index, 1, !0),
|
|
2125
|
+
api.findSiblingStoryId(storyId, index, -1, !0)
|
|
2975
2126
|
])
|
|
2976
2127
|
).filter(Boolean);
|
|
2977
2128
|
provider.channel?.emit(PRELOAD_ENTRIES, {
|
|
@@ -2979,37 +2130,31 @@ var init11 = /* @__PURE__ */ __name(({
|
|
|
2979
2130
|
options: { target: refId }
|
|
2980
2131
|
});
|
|
2981
2132
|
}
|
|
2982
|
-
}
|
|
2983
|
-
)
|
|
2984
|
-
provider.channel?.on(
|
|
2133
|
+
}
|
|
2134
|
+
), provider.channel?.on(
|
|
2985
2135
|
DOCS_PREPARED,
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
api.updateStory(id, { ...update2, prepared:
|
|
2989
|
-
}
|
|
2990
|
-
)
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2136
|
+
function({ id, ...update2 }) {
|
|
2137
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
2138
|
+
api.updateStory(id, { ...update2, prepared: !0 }, ref);
|
|
2139
|
+
}
|
|
2140
|
+
), provider.channel?.on(SET_INDEX, function(index) {
|
|
2141
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
2142
|
+
if (ref)
|
|
2143
|
+
fullAPI.setRef(ref.id, { ...ref, storyIndex: index }, !0);
|
|
2144
|
+
else {
|
|
2994
2145
|
api.setIndex(index);
|
|
2995
|
-
|
|
2146
|
+
let options = api.getCurrentParameter("options");
|
|
2996
2147
|
fullAPI.setOptions(removeRemovedOptions(options));
|
|
2997
|
-
} else {
|
|
2998
|
-
fullAPI.setRef(ref.id, { ...ref, storyIndex: index }, true);
|
|
2999
2148
|
}
|
|
3000
|
-
},
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
2149
|
+
}), provider.channel?.on(SET_STORIES, function(data) {
|
|
2150
|
+
let { ref } = getEventMetadata(this, fullAPI), setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories;
|
|
2151
|
+
if (ref)
|
|
2152
|
+
fullAPI.setRef(ref.id, { ...ref, setStoriesData }, !0);
|
|
2153
|
+
else
|
|
3005
2154
|
throw new Error("Cannot call SET_STORIES for local frame");
|
|
3006
|
-
|
|
3007
|
-
fullAPI.setRef(ref.id, { ...ref, setStoriesData }, true);
|
|
3008
|
-
}
|
|
3009
|
-
}, "handler"));
|
|
3010
|
-
provider.channel?.on(
|
|
2155
|
+
}), provider.channel?.on(
|
|
3011
2156
|
SELECT_STORY,
|
|
3012
|
-
|
|
2157
|
+
function({
|
|
3013
2158
|
kind,
|
|
3014
2159
|
title = kind,
|
|
3015
2160
|
story,
|
|
@@ -3017,67 +2162,54 @@ var init11 = /* @__PURE__ */ __name(({
|
|
|
3017
2162
|
storyId,
|
|
3018
2163
|
...rest
|
|
3019
2164
|
}) {
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
fullAPI.selectStory(storyId || title, name, { ...rest, ref: ref.id });
|
|
3025
|
-
}
|
|
3026
|
-
}, "handler")
|
|
3027
|
-
);
|
|
3028
|
-
provider.channel?.on(
|
|
2165
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
2166
|
+
ref ? fullAPI.selectStory(storyId || title, name, { ...rest, ref: ref.id }) : fullAPI.selectStory(storyId || title, name, rest);
|
|
2167
|
+
}
|
|
2168
|
+
), provider.channel?.on(
|
|
3029
2169
|
STORY_ARGS_UPDATED,
|
|
3030
|
-
|
|
3031
|
-
|
|
2170
|
+
function({ storyId, args }) {
|
|
2171
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
3032
2172
|
api.updateStory(storyId, { args }, ref);
|
|
3033
|
-
}
|
|
3034
|
-
)
|
|
3035
|
-
|
|
3036
|
-
const { ref } = getEventMetadata(this, fullAPI);
|
|
2173
|
+
}
|
|
2174
|
+
), provider.channel?.on(CONFIG_ERROR, function(err) {
|
|
2175
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
3037
2176
|
api.setPreviewInitialized(ref);
|
|
3038
|
-
},
|
|
3039
|
-
|
|
3040
|
-
const { ref } = getEventMetadata(this, fullAPI);
|
|
2177
|
+
}), provider.channel?.on(STORY_MISSING, function(err) {
|
|
2178
|
+
let { ref } = getEventMetadata(this, fullAPI);
|
|
3041
2179
|
api.setPreviewInitialized(ref);
|
|
3042
|
-
},
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
filters
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
});
|
|
3054
|
-
fullStatusStore.onAllStatusChange(async () => {
|
|
3055
|
-
const { internal_index: index } = store2.getState();
|
|
3056
|
-
if (!index) {
|
|
2180
|
+
}), provider.channel?.on(SET_CONFIG3, () => {
|
|
2181
|
+
let config2 = provider.getConfig();
|
|
2182
|
+
config2?.sidebar?.filters && store2.setState({
|
|
2183
|
+
filters: {
|
|
2184
|
+
...store2.getState().filters,
|
|
2185
|
+
...config2?.sidebar?.filters
|
|
2186
|
+
}
|
|
2187
|
+
});
|
|
2188
|
+
}), fullStatusStore.onAllStatusChange(async () => {
|
|
2189
|
+
let { internal_index: index } = store2.getState();
|
|
2190
|
+
if (!index)
|
|
3057
2191
|
return;
|
|
3058
|
-
}
|
|
3059
2192
|
await api.setIndex(index);
|
|
3060
|
-
|
|
2193
|
+
let refs = await fullAPI.getRefs();
|
|
3061
2194
|
Object.entries(refs).forEach(([refId, { internal_index, ...ref }]) => {
|
|
3062
|
-
fullAPI.setRef(refId, { ...ref, storyIndex: internal_index },
|
|
2195
|
+
fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, !0);
|
|
3063
2196
|
});
|
|
3064
2197
|
});
|
|
3065
|
-
|
|
2198
|
+
let config = provider.getConfig();
|
|
3066
2199
|
return {
|
|
3067
2200
|
api,
|
|
3068
2201
|
state: {
|
|
3069
2202
|
storyId: initialStoryId,
|
|
3070
2203
|
viewMode: initialViewMode,
|
|
3071
|
-
hasCalledSetOptions:
|
|
3072
|
-
previewInitialized:
|
|
2204
|
+
hasCalledSetOptions: !1,
|
|
2205
|
+
previewInitialized: !1,
|
|
3073
2206
|
filters: config?.sidebar?.filters || {}
|
|
3074
2207
|
},
|
|
3075
|
-
init:
|
|
3076
|
-
provider.channel?.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex());
|
|
3077
|
-
|
|
3078
|
-
}, "init")
|
|
2208
|
+
init: async () => {
|
|
2209
|
+
provider.channel?.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex()), await api.fetchIndex();
|
|
2210
|
+
}
|
|
3079
2211
|
};
|
|
3080
|
-
}
|
|
2212
|
+
};
|
|
3081
2213
|
|
|
3082
2214
|
// src/manager-api/modules/url.ts
|
|
3083
2215
|
var url_exports = {};
|
|
@@ -3093,22 +2225,16 @@ import {
|
|
|
3093
2225
|
} from "storybook/internal/core-events";
|
|
3094
2226
|
import { buildArgsParam, queryFromLocation } from "storybook/internal/router";
|
|
3095
2227
|
import { global as global7 } from "@storybook/global";
|
|
3096
|
-
var { window: globalWindow } = global7
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
return false;
|
|
3103
|
-
}
|
|
3104
|
-
return void 0;
|
|
3105
|
-
}, "parseBoolean");
|
|
3106
|
-
var prevParams;
|
|
3107
|
-
var initialUrlSupport = /* @__PURE__ */ __name(({
|
|
2228
|
+
var { window: globalWindow } = global7, parseBoolean = (value) => {
|
|
2229
|
+
if (value === "true" || value === "1")
|
|
2230
|
+
return !0;
|
|
2231
|
+
if (value === "false" || value === "0")
|
|
2232
|
+
return !1;
|
|
2233
|
+
}, prevParams, initialUrlSupport = ({
|
|
3108
2234
|
state: { location: location2, path, viewMode, storyId: storyIdFromUrl },
|
|
3109
2235
|
singleStory
|
|
3110
2236
|
}) => {
|
|
3111
|
-
|
|
2237
|
+
let {
|
|
3112
2238
|
full,
|
|
3113
2239
|
panel,
|
|
3114
2240
|
nav,
|
|
@@ -3118,61 +2244,29 @@ var initialUrlSupport = /* @__PURE__ */ __name(({
|
|
|
3118
2244
|
path: queryPath,
|
|
3119
2245
|
...otherParams
|
|
3120
2246
|
// the rest gets passed to the iframe
|
|
3121
|
-
} = queryFromLocation(location2);
|
|
3122
|
-
|
|
3123
|
-
let
|
|
3124
|
-
let rightPanelWidth;
|
|
3125
|
-
if (parseBoolean(full) === true) {
|
|
3126
|
-
navSize = 0;
|
|
3127
|
-
bottomPanelHeight = 0;
|
|
3128
|
-
rightPanelWidth = 0;
|
|
3129
|
-
} else if (parseBoolean(full) === false) {
|
|
3130
|
-
navSize = defaultLayoutState.layout.navSize;
|
|
3131
|
-
bottomPanelHeight = defaultLayoutState.layout.bottomPanelHeight;
|
|
3132
|
-
rightPanelWidth = defaultLayoutState.layout.rightPanelWidth;
|
|
3133
|
-
}
|
|
3134
|
-
if (!singleStory) {
|
|
3135
|
-
if (parseBoolean(nav) === true) {
|
|
3136
|
-
navSize = defaultLayoutState.layout.navSize;
|
|
3137
|
-
}
|
|
3138
|
-
if (parseBoolean(nav) === false) {
|
|
3139
|
-
navSize = 0;
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
if (parseBoolean(panel) === false) {
|
|
3143
|
-
bottomPanelHeight = 0;
|
|
3144
|
-
rightPanelWidth = 0;
|
|
3145
|
-
}
|
|
3146
|
-
const layout = {
|
|
2247
|
+
} = queryFromLocation(location2), navSize, bottomPanelHeight, rightPanelWidth;
|
|
2248
|
+
parseBoolean(full) === !0 ? (navSize = 0, bottomPanelHeight = 0, rightPanelWidth = 0) : parseBoolean(full) === !1 && (navSize = defaultLayoutState.layout.navSize, bottomPanelHeight = defaultLayoutState.layout.bottomPanelHeight, rightPanelWidth = defaultLayoutState.layout.rightPanelWidth), singleStory || (parseBoolean(nav) === !0 && (navSize = defaultLayoutState.layout.navSize), parseBoolean(nav) === !1 && (navSize = 0)), parseBoolean(panel) === !1 && (bottomPanelHeight = 0, rightPanelWidth = 0);
|
|
2249
|
+
let layout = {
|
|
3147
2250
|
navSize,
|
|
3148
2251
|
bottomPanelHeight,
|
|
3149
2252
|
rightPanelWidth,
|
|
3150
2253
|
panelPosition: ["right", "bottom"].includes(panel) ? panel : void 0,
|
|
3151
2254
|
showTabs: parseBoolean(tabs)
|
|
3152
|
-
}
|
|
3153
|
-
const ui = {
|
|
2255
|
+
}, ui = {
|
|
3154
2256
|
enableShortcuts: parseBoolean(shortcuts)
|
|
3155
|
-
};
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
return { viewMode, layout, ui, selectedPanel, location: location2, path, customQueryParams, storyId };
|
|
3161
|
-
}, "initialUrlSupport");
|
|
3162
|
-
var init12 = /* @__PURE__ */ __name((moduleArgs) => {
|
|
3163
|
-
const { store: store2, navigate, provider, fullAPI } = moduleArgs;
|
|
3164
|
-
const navigateTo = /* @__PURE__ */ __name((path, queryParams = {}, options = {}) => {
|
|
3165
|
-
const params = Object.entries(queryParams).filter(([, v]) => v).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`);
|
|
3166
|
-
const to = [path, ...params].join("&");
|
|
2257
|
+
}, selectedPanel = addonPanel || void 0, storyId = storyIdFromUrl, customQueryParams = dequal(prevParams, otherParams) ? prevParams : otherParams;
|
|
2258
|
+
return prevParams = customQueryParams, { viewMode, layout, ui, selectedPanel, location: location2, path, customQueryParams, storyId };
|
|
2259
|
+
}, init12 = (moduleArgs) => {
|
|
2260
|
+
let { store: store2, navigate, provider, fullAPI } = moduleArgs, navigateTo = (path, queryParams = {}, options = {}) => {
|
|
2261
|
+
let params = Object.entries(queryParams).filter(([, v]) => v).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`), to = [path, ...params].join("&");
|
|
3167
2262
|
return navigate(to, options);
|
|
3168
|
-
},
|
|
3169
|
-
const api = {
|
|
2263
|
+
}, api = {
|
|
3170
2264
|
getQueryParam(key) {
|
|
3171
|
-
|
|
2265
|
+
let { customQueryParams } = store2.getState();
|
|
3172
2266
|
return customQueryParams ? customQueryParams[key] : void 0;
|
|
3173
2267
|
},
|
|
3174
2268
|
getUrlState() {
|
|
3175
|
-
|
|
2269
|
+
let { location: location2, path, customQueryParams, storyId, url, viewMode } = store2.getState();
|
|
3176
2270
|
return {
|
|
3177
2271
|
path,
|
|
3178
2272
|
hash: location2.hash ?? "",
|
|
@@ -3183,74 +2277,43 @@ var init12 = /* @__PURE__ */ __name((moduleArgs) => {
|
|
|
3183
2277
|
};
|
|
3184
2278
|
},
|
|
3185
2279
|
setQueryParams(input) {
|
|
3186
|
-
|
|
3187
|
-
const queryParams = {};
|
|
3188
|
-
const update2 = {
|
|
2280
|
+
let { customQueryParams } = store2.getState(), queryParams = {}, update2 = {
|
|
3189
2281
|
...customQueryParams,
|
|
3190
|
-
...Object.entries(input).reduce((acc, [key, value]) =>
|
|
3191
|
-
if (value !== null) {
|
|
3192
|
-
acc[key] = value;
|
|
3193
|
-
}
|
|
3194
|
-
return acc;
|
|
3195
|
-
}, queryParams)
|
|
2282
|
+
...Object.entries(input).reduce((acc, [key, value]) => (value !== null && (acc[key] = value), acc), queryParams)
|
|
3196
2283
|
};
|
|
3197
|
-
|
|
3198
|
-
store2.setState({ customQueryParams: update2 });
|
|
3199
|
-
provider.channel?.emit(UPDATE_QUERY_PARAMS, update2);
|
|
3200
|
-
}
|
|
2284
|
+
dequal(customQueryParams, update2) || (store2.setState({ customQueryParams: update2 }), provider.channel?.emit(UPDATE_QUERY_PARAMS, update2));
|
|
3201
2285
|
},
|
|
3202
2286
|
applyQueryParams(input, options) {
|
|
3203
|
-
|
|
3204
|
-
navigateTo(`${path}${hash}`, { ...queryParams, ...input }, options);
|
|
3205
|
-
api.setQueryParams(input);
|
|
2287
|
+
let { path, hash = "", queryParams } = api.getUrlState();
|
|
2288
|
+
navigateTo(`${path}${hash}`, { ...queryParams, ...input }, options), api.setQueryParams(input);
|
|
3206
2289
|
},
|
|
3207
2290
|
navigateUrl(url, options) {
|
|
3208
|
-
navigate(url, { plain:
|
|
2291
|
+
navigate(url, { plain: !0, ...options });
|
|
3209
2292
|
}
|
|
3210
|
-
}
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
if (viewMode !== "story") {
|
|
2293
|
+
}, updateArgsParam = () => {
|
|
2294
|
+
let { path, hash = "", queryParams, viewMode } = api.getUrlState();
|
|
2295
|
+
if (viewMode !== "story")
|
|
3214
2296
|
return;
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
if (currentStory?.type !== "story") {
|
|
2297
|
+
let currentStory = fullAPI.getCurrentStoryData();
|
|
2298
|
+
if (currentStory?.type !== "story")
|
|
3218
2299
|
return;
|
|
3219
|
-
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
navigateTo(`${path}${hash}`, { ...queryParams, args: argsString }, { replace: true });
|
|
3223
|
-
api.setQueryParams({ args: argsString });
|
|
3224
|
-
}, "updateArgsParam");
|
|
2300
|
+
let { args, initialArgs } = currentStory, argsString = buildArgsParam(initialArgs, args);
|
|
2301
|
+
navigateTo(`${path}${hash}`, { ...queryParams, args: argsString }, { replace: !0 }), api.setQueryParams({ args: argsString });
|
|
2302
|
+
};
|
|
3225
2303
|
provider.channel?.on(SET_CURRENT_STORY2, () => updateArgsParam());
|
|
3226
2304
|
let handleOrId;
|
|
3227
|
-
provider.channel?.on(STORY_ARGS_UPDATED2, () => {
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
} else {
|
|
3234
|
-
if (handleOrId) {
|
|
3235
|
-
clearTimeout(handleOrId);
|
|
3236
|
-
}
|
|
3237
|
-
setTimeout(updateArgsParam, 100);
|
|
3238
|
-
}
|
|
3239
|
-
});
|
|
3240
|
-
provider.channel?.on(GLOBALS_UPDATED2, ({ userGlobals, initialGlobals }) => {
|
|
3241
|
-
const { path, hash = "", queryParams } = api.getUrlState();
|
|
3242
|
-
const globalsString = buildArgsParam(initialGlobals, userGlobals);
|
|
3243
|
-
navigateTo(`${path}${hash}`, { ...queryParams, globals: globalsString }, { replace: true });
|
|
3244
|
-
api.setQueryParams({ globals: globalsString });
|
|
3245
|
-
});
|
|
3246
|
-
provider.channel?.on(NAVIGATE_URL, (url, options) => {
|
|
2305
|
+
return provider.channel?.on(STORY_ARGS_UPDATED2, () => {
|
|
2306
|
+
"requestIdleCallback" in globalWindow ? (handleOrId && globalWindow.cancelIdleCallback(handleOrId), handleOrId = globalWindow.requestIdleCallback(updateArgsParam, { timeout: 1e3 })) : (handleOrId && clearTimeout(handleOrId), setTimeout(updateArgsParam, 100));
|
|
2307
|
+
}), provider.channel?.on(GLOBALS_UPDATED2, ({ userGlobals, initialGlobals }) => {
|
|
2308
|
+
let { path, hash = "", queryParams } = api.getUrlState(), globalsString = buildArgsParam(initialGlobals, userGlobals);
|
|
2309
|
+
navigateTo(`${path}${hash}`, { ...queryParams, globals: globalsString }, { replace: !0 }), api.setQueryParams({ globals: globalsString });
|
|
2310
|
+
}), provider.channel?.on(NAVIGATE_URL, (url, options) => {
|
|
3247
2311
|
api.navigateUrl(url, options);
|
|
3248
|
-
})
|
|
3249
|
-
return {
|
|
2312
|
+
}), {
|
|
3250
2313
|
api,
|
|
3251
2314
|
state: initialUrlSupport(moduleArgs)
|
|
3252
2315
|
};
|
|
3253
|
-
}
|
|
2316
|
+
};
|
|
3254
2317
|
|
|
3255
2318
|
// src/manager-api/modules/versions.ts
|
|
3256
2319
|
var versions_exports = {};
|
|
@@ -3262,26 +2325,17 @@ import { global as global8 } from "@storybook/global";
|
|
|
3262
2325
|
import semver from "semver";
|
|
3263
2326
|
|
|
3264
2327
|
// src/manager-api/version.ts
|
|
3265
|
-
var version = "10.1.0-alpha.
|
|
2328
|
+
var version = "10.1.0-alpha.11";
|
|
3266
2329
|
|
|
3267
2330
|
// src/manager-api/modules/versions.ts
|
|
3268
|
-
var { VERSIONCHECK } = global8
|
|
3269
|
-
var getVersionCheckData = (0, import_memoizerific2.default)(1)(() => {
|
|
2331
|
+
var { VERSIONCHECK } = global8, getVersionCheckData = (0, import_memoizerific2.default)(1)(() => {
|
|
3270
2332
|
try {
|
|
3271
2333
|
return { ...JSON.parse(VERSIONCHECK).data || {} };
|
|
3272
|
-
} catch
|
|
2334
|
+
} catch {
|
|
3273
2335
|
return {};
|
|
3274
2336
|
}
|
|
3275
|
-
})
|
|
3276
|
-
|
|
3277
|
-
if (renderer.includes("vue")) {
|
|
3278
|
-
return "vue";
|
|
3279
|
-
}
|
|
3280
|
-
return renderer;
|
|
3281
|
-
}, "normalizeRendererName");
|
|
3282
|
-
var init13 = /* @__PURE__ */ __name(({ store: store2 }) => {
|
|
3283
|
-
const { dismissedVersionNotification } = store2.getState();
|
|
3284
|
-
const state = {
|
|
2337
|
+
}), normalizeRendererName = (renderer) => renderer.includes("vue") ? "vue" : renderer, init13 = ({ store: store2 }) => {
|
|
2338
|
+
let { dismissedVersionNotification } = store2.getState(), state = {
|
|
3285
2339
|
versions: {
|
|
3286
2340
|
current: {
|
|
3287
2341
|
version
|
|
@@ -3289,81 +2343,56 @@ var init13 = /* @__PURE__ */ __name(({ store: store2 }) => {
|
|
|
3289
2343
|
...getVersionCheckData()
|
|
3290
2344
|
},
|
|
3291
2345
|
dismissedVersionNotification
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
const {
|
|
2346
|
+
}, api = {
|
|
2347
|
+
getCurrentVersion: () => {
|
|
2348
|
+
let {
|
|
3296
2349
|
versions: { current }
|
|
3297
2350
|
} = store2.getState();
|
|
3298
2351
|
return current;
|
|
3299
|
-
},
|
|
3300
|
-
getLatestVersion:
|
|
3301
|
-
|
|
2352
|
+
},
|
|
2353
|
+
getLatestVersion: () => {
|
|
2354
|
+
let {
|
|
3302
2355
|
versions: { latest, next, current }
|
|
3303
2356
|
} = store2.getState();
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
}
|
|
3307
|
-
return latest;
|
|
3308
|
-
}, "getLatestVersion"),
|
|
2357
|
+
return current && semver.prerelease(current.version) && next ? latest && semver.gt(latest.version, next.version) ? latest : next : latest;
|
|
2358
|
+
},
|
|
3309
2359
|
// TODO: Move this to it's own "info" module later
|
|
3310
|
-
getDocsUrl:
|
|
3311
|
-
|
|
2360
|
+
getDocsUrl: ({ subpath, versioned, renderer }) => {
|
|
2361
|
+
let {
|
|
3312
2362
|
versions: { latest, current }
|
|
3313
|
-
} = store2.getState();
|
|
3314
|
-
let url = "https://storybook.js.org/docs/";
|
|
2363
|
+
} = store2.getState(), url = "https://storybook.js.org/docs/";
|
|
3315
2364
|
if (versioned && current?.version && latest?.version) {
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
semver.satisfies(current.version, "0.0.0", { includePrerelease:
|
|
3319
|
-
if (!isLatestDocs) {
|
|
3320
|
-
url += `${semver.major(current.version)}.${semver.minor(current.version)}/`;
|
|
3321
|
-
}
|
|
3322
|
-
}
|
|
3323
|
-
const [cleanedSubpath, hash] = subpath?.split("#") || [];
|
|
3324
|
-
if (cleanedSubpath) {
|
|
3325
|
-
url += `${cleanedSubpath}/`;
|
|
3326
|
-
}
|
|
3327
|
-
if (renderer && typeof global8.STORYBOOK_RENDERER !== "undefined") {
|
|
3328
|
-
const rendererName = global8.STORYBOOK_RENDERER;
|
|
3329
|
-
if (rendererName) {
|
|
3330
|
-
url += `?renderer=${normalizeRendererName(rendererName)}`;
|
|
3331
|
-
}
|
|
2365
|
+
let versionDiff = semver.diff(latest.version, current.version);
|
|
2366
|
+
versionDiff === "patch" || versionDiff === null || // assume latest version when current version is a 0.0.0 canary
|
|
2367
|
+
semver.satisfies(current.version, "0.0.0", { includePrerelease: !0 }) || (url += `${semver.major(current.version)}.${semver.minor(current.version)}/`);
|
|
3332
2368
|
}
|
|
3333
|
-
|
|
3334
|
-
|
|
2369
|
+
let [cleanedSubpath, hash] = subpath?.split("#") || [];
|
|
2370
|
+
if (cleanedSubpath && (url += `${cleanedSubpath}/`), renderer && typeof global8.STORYBOOK_RENDERER < "u") {
|
|
2371
|
+
let rendererName = global8.STORYBOOK_RENDERER;
|
|
2372
|
+
rendererName && (url += `?renderer=${normalizeRendererName(rendererName)}`);
|
|
3335
2373
|
}
|
|
3336
|
-
return url;
|
|
3337
|
-
},
|
|
3338
|
-
versionUpdateAvailable:
|
|
3339
|
-
|
|
3340
|
-
const current = api.getCurrentVersion();
|
|
2374
|
+
return hash && (url += `#${hash}`), url;
|
|
2375
|
+
},
|
|
2376
|
+
versionUpdateAvailable: () => {
|
|
2377
|
+
let latest = api.getLatestVersion(), current = api.getCurrentVersion();
|
|
3341
2378
|
if (latest) {
|
|
3342
|
-
if (!latest.version)
|
|
3343
|
-
return
|
|
3344
|
-
}
|
|
3345
|
-
if (!current.version) {
|
|
3346
|
-
return true;
|
|
3347
|
-
}
|
|
3348
|
-
const onPrerelease = !!semver.prerelease(current.version);
|
|
3349
|
-
const actualCurrent = onPrerelease ? `${semver.major(current.version)}.${semver.minor(current.version)}.${semver.patch(
|
|
2379
|
+
if (!latest.version || !current.version)
|
|
2380
|
+
return !0;
|
|
2381
|
+
let actualCurrent = !!semver.prerelease(current.version) ? `${semver.major(current.version)}.${semver.minor(current.version)}.${semver.patch(
|
|
3350
2382
|
current.version
|
|
3351
|
-
)}` : current.version;
|
|
3352
|
-
const diff = semver.diff(actualCurrent, latest.version);
|
|
2383
|
+
)}` : current.version, diff = semver.diff(actualCurrent, latest.version);
|
|
3353
2384
|
return semver.gt(latest.version, actualCurrent) && diff !== "patch" && !diff.includes("pre");
|
|
3354
2385
|
}
|
|
3355
|
-
return
|
|
3356
|
-
}
|
|
2386
|
+
return !1;
|
|
2387
|
+
}
|
|
3357
2388
|
};
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
const { latest, next } = getVersionCheckData();
|
|
2389
|
+
return { init: async () => {
|
|
2390
|
+
let { versions = {} } = store2.getState(), { latest, next } = getVersionCheckData();
|
|
3361
2391
|
await store2.setState({
|
|
3362
2392
|
versions: { ...versions, latest, next }
|
|
3363
2393
|
});
|
|
3364
|
-
},
|
|
3365
|
-
|
|
3366
|
-
}, "init");
|
|
2394
|
+
}, state, api };
|
|
2395
|
+
};
|
|
3367
2396
|
|
|
3368
2397
|
// src/manager-api/modules/whatsnew.tsx
|
|
3369
2398
|
var whatsnew_exports = {};
|
|
@@ -3378,107 +2407,84 @@ import {
|
|
|
3378
2407
|
TOGGLE_WHATS_NEW_NOTIFICATIONS
|
|
3379
2408
|
} from "storybook/internal/core-events";
|
|
3380
2409
|
import { global as global9 } from "@storybook/global";
|
|
3381
|
-
var WHATS_NEW_NOTIFICATION_ID = "whats-new"
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
2410
|
+
var WHATS_NEW_NOTIFICATION_ID = "whats-new", StorybookIcon = ({ color = "currentColor", size = 14 }) => React3.createElement(
|
|
2411
|
+
"svg",
|
|
2412
|
+
{
|
|
2413
|
+
width: size,
|
|
2414
|
+
height: size,
|
|
2415
|
+
viewBox: "0 0 14 14",
|
|
2416
|
+
fill: "none",
|
|
2417
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2418
|
+
},
|
|
2419
|
+
React3.createElement(
|
|
2420
|
+
"path",
|
|
3385
2421
|
{
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
fill:
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
{
|
|
3395
|
-
fillRule: "evenodd",
|
|
3396
|
-
clipRule: "evenodd",
|
|
3397
|
-
d: "M2.042.616a.704.704 0 00-.66.729L1.816 12.9c.014.367.306.66.672.677l9.395.422h.032a.704.704 0 00.704-.703V.704c0-.015 0-.03-.002-.044a.704.704 0 00-.746-.659l-.773.049.057 1.615a.105.105 0 01-.17.086l-.52-.41-.617.468a.105.105 0 01-.168-.088L9.746.134 2.042.616zm8.003 4.747c-.247.192-2.092.324-2.092.05.04-1.045-.429-1.091-.689-1.091-.247 0-.662.075-.662.634 0 .57.607.893 1.32 1.27 1.014.538 2.24 1.188 2.24 2.823 0 1.568-1.273 2.433-2.898 2.433-1.676 0-3.141-.678-2.976-3.03.065-.275 2.197-.21 2.197 0-.026.971.195 1.256.753 1.256.43 0 .624-.236.624-.634 0-.602-.633-.958-1.361-1.367-.987-.554-2.148-1.205-2.148-2.7 0-1.494 1.027-2.489 2.86-2.489 1.832 0 2.832.98 2.832 2.845z",
|
|
3398
|
-
fill: color
|
|
3399
|
-
}
|
|
3400
|
-
)
|
|
3401
|
-
);
|
|
3402
|
-
}, "StorybookIcon");
|
|
3403
|
-
var init14 = /* @__PURE__ */ __name(({ fullAPI, store: store2, provider }) => {
|
|
3404
|
-
const state = {
|
|
2422
|
+
fillRule: "evenodd",
|
|
2423
|
+
clipRule: "evenodd",
|
|
2424
|
+
d: "M2.042.616a.704.704 0 00-.66.729L1.816 12.9c.014.367.306.66.672.677l9.395.422h.032a.704.704 0 00.704-.703V.704c0-.015 0-.03-.002-.044a.704.704 0 00-.746-.659l-.773.049.057 1.615a.105.105 0 01-.17.086l-.52-.41-.617.468a.105.105 0 01-.168-.088L9.746.134 2.042.616zm8.003 4.747c-.247.192-2.092.324-2.092.05.04-1.045-.429-1.091-.689-1.091-.247 0-.662.075-.662.634 0 .57.607.893 1.32 1.27 1.014.538 2.24 1.188 2.24 2.823 0 1.568-1.273 2.433-2.898 2.433-1.676 0-3.141-.678-2.976-3.03.065-.275 2.197-.21 2.197 0-.026.971.195 1.256.753 1.256.43 0 .624-.236.624-.634 0-.602-.633-.958-1.361-1.367-.987-.554-2.148-1.205-2.148-2.7 0-1.494 1.027-2.489 2.86-2.489 1.832 0 2.832.98 2.832 2.845z",
|
|
2425
|
+
fill: color
|
|
2426
|
+
}
|
|
2427
|
+
)
|
|
2428
|
+
), init14 = ({ fullAPI, store: store2, provider }) => {
|
|
2429
|
+
let state = {
|
|
3405
2430
|
whatsNewData: void 0
|
|
3406
2431
|
};
|
|
3407
2432
|
function setWhatsNewState(newState) {
|
|
3408
|
-
store2.setState({ whatsNewData: newState });
|
|
3409
|
-
state.whatsNewData = newState;
|
|
2433
|
+
store2.setState({ whatsNewData: newState }), state.whatsNewData = newState;
|
|
3410
2434
|
}
|
|
3411
|
-
|
|
3412
|
-
const api = {
|
|
2435
|
+
let api = {
|
|
3413
2436
|
isWhatsNewUnread() {
|
|
3414
2437
|
return state.whatsNewData?.status === "SUCCESS" && !state.whatsNewData.postIsRead;
|
|
3415
2438
|
},
|
|
3416
2439
|
whatsNewHasBeenRead() {
|
|
3417
|
-
|
|
3418
|
-
setWhatsNewCache({ lastReadPost: state.whatsNewData.url });
|
|
3419
|
-
setWhatsNewState({ ...state.whatsNewData, postIsRead: true });
|
|
3420
|
-
fullAPI.clearNotification(WHATS_NEW_NOTIFICATION_ID);
|
|
3421
|
-
}
|
|
2440
|
+
state.whatsNewData?.status === "SUCCESS" && (setWhatsNewCache({ lastReadPost: state.whatsNewData.url }), setWhatsNewState({ ...state.whatsNewData, postIsRead: !0 }), fullAPI.clearNotification(WHATS_NEW_NOTIFICATION_ID));
|
|
3422
2441
|
},
|
|
3423
2442
|
toggleWhatsNewNotifications() {
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
disableWhatsNewNotifications: state.whatsNewData.disableWhatsNewNotifications
|
|
3431
|
-
});
|
|
3432
|
-
}
|
|
2443
|
+
state.whatsNewData?.status === "SUCCESS" && (setWhatsNewState({
|
|
2444
|
+
...state.whatsNewData,
|
|
2445
|
+
disableWhatsNewNotifications: !state.whatsNewData.disableWhatsNewNotifications
|
|
2446
|
+
}), provider.channel?.emit(TOGGLE_WHATS_NEW_NOTIFICATIONS, {
|
|
2447
|
+
disableWhatsNewNotifications: state.whatsNewData.disableWhatsNewNotifications
|
|
2448
|
+
}));
|
|
3433
2449
|
}
|
|
3434
2450
|
};
|
|
3435
2451
|
function getLatestWhatsNewPost() {
|
|
3436
|
-
provider.channel?.emit(REQUEST_WHATS_NEW_DATA)
|
|
3437
|
-
return new Promise(
|
|
2452
|
+
return provider.channel?.emit(REQUEST_WHATS_NEW_DATA), new Promise(
|
|
3438
2453
|
(resolve) => provider.channel?.once(
|
|
3439
2454
|
RESULT_WHATS_NEW_DATA,
|
|
3440
2455
|
({ data }) => resolve(data)
|
|
3441
2456
|
)
|
|
3442
2457
|
);
|
|
3443
2458
|
}
|
|
3444
|
-
__name(getLatestWhatsNewPost, "getLatestWhatsNewPost");
|
|
3445
2459
|
function setWhatsNewCache(cache) {
|
|
3446
2460
|
provider.channel?.emit(SET_WHATS_NEW_CACHE, cache);
|
|
3447
2461
|
}
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
if (global9.CONFIG_TYPE !== "DEVELOPMENT") {
|
|
2462
|
+
return { init: async () => {
|
|
2463
|
+
if (global9.CONFIG_TYPE !== "DEVELOPMENT")
|
|
3451
2464
|
return;
|
|
3452
|
-
|
|
3453
|
-
const whatsNewData = await getLatestWhatsNewPost();
|
|
2465
|
+
let whatsNewData = await getLatestWhatsNewPost();
|
|
3454
2466
|
setWhatsNewState(whatsNewData);
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
}
|
|
3471
|
-
});
|
|
3472
|
-
}
|
|
3473
|
-
}, "initModule");
|
|
3474
|
-
return { init: initModule, state, api };
|
|
3475
|
-
}, "init");
|
|
2467
|
+
let urlState = fullAPI.getUrlState();
|
|
2468
|
+
!(urlState?.path === "/onboarding" || urlState.queryParams?.onboarding === "true") && whatsNewData.status === "SUCCESS" && !whatsNewData.disableWhatsNewNotifications && whatsNewData.showNotification && fullAPI.addNotification({
|
|
2469
|
+
id: WHATS_NEW_NOTIFICATION_ID,
|
|
2470
|
+
link: "/settings/whats-new",
|
|
2471
|
+
content: {
|
|
2472
|
+
headline: whatsNewData.title,
|
|
2473
|
+
subHeadline: "Learn what's new in Storybook"
|
|
2474
|
+
},
|
|
2475
|
+
icon: React3.createElement(StorybookIcon, null),
|
|
2476
|
+
onClear({ dismissed }) {
|
|
2477
|
+
dismissed && setWhatsNewCache({ lastDismissedPost: whatsNewData.url });
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}, state, api };
|
|
2481
|
+
};
|
|
3476
2482
|
|
|
3477
2483
|
// src/manager-api/store.ts
|
|
3478
2484
|
var import_store2 = __toESM(require_store2(), 1);
|
|
3479
2485
|
|
|
3480
2486
|
// src/manager-api/lib/store-setup.ts
|
|
3481
|
-
var store_setup_default =
|
|
2487
|
+
var store_setup_default = (_) => {
|
|
3482
2488
|
_.fn("set", function(key, data) {
|
|
3483
2489
|
return _.set(
|
|
3484
2490
|
// @ts-expect-error('this' implicitly has type 'any')
|
|
@@ -3487,34 +2493,28 @@ var store_setup_default = /* @__PURE__ */ __name((_) => {
|
|
|
3487
2493
|
this._in(key),
|
|
3488
2494
|
stringify(data, { maxDepth: 50 })
|
|
3489
2495
|
);
|
|
3490
|
-
})
|
|
3491
|
-
|
|
3492
|
-
const value = _.get(this._area, this._in(key));
|
|
2496
|
+
}), _.fn("get", function(key, alt) {
|
|
2497
|
+
let value = _.get(this._area, this._in(key));
|
|
3493
2498
|
return value !== null ? parse(value) : alt || value;
|
|
3494
2499
|
});
|
|
3495
|
-
}
|
|
2500
|
+
};
|
|
3496
2501
|
|
|
3497
2502
|
// src/manager-api/store.ts
|
|
3498
2503
|
store_setup_default(import_store2.default._);
|
|
3499
2504
|
var STORAGE_KEY = "@storybook/manager/store";
|
|
3500
2505
|
function get(storage) {
|
|
3501
|
-
|
|
3502
|
-
return data || {};
|
|
2506
|
+
return storage.get(STORAGE_KEY) || {};
|
|
3503
2507
|
}
|
|
3504
|
-
__name(get, "get");
|
|
3505
2508
|
function set(storage, value) {
|
|
3506
2509
|
return storage.set(STORAGE_KEY, value);
|
|
3507
2510
|
}
|
|
3508
|
-
__name(set, "set");
|
|
3509
2511
|
function update(storage, patch) {
|
|
3510
|
-
|
|
2512
|
+
let previous = get(storage);
|
|
3511
2513
|
return set(storage, { ...previous, ...patch });
|
|
3512
2514
|
}
|
|
3513
|
-
|
|
3514
|
-
var _Store = class _Store {
|
|
2515
|
+
var Store = class {
|
|
3515
2516
|
constructor({ setState, getState }) {
|
|
3516
|
-
this.upstreamSetState = setState;
|
|
3517
|
-
this.upstreamGetState = getState;
|
|
2517
|
+
this.upstreamSetState = setState, this.upstreamGetState = getState;
|
|
3518
2518
|
}
|
|
3519
2519
|
// The assumption is that this will be called once, to initialize the React state
|
|
3520
2520
|
// when the module is instantiated
|
|
@@ -3525,99 +2525,57 @@ var _Store = class _Store {
|
|
|
3525
2525
|
return this.upstreamGetState();
|
|
3526
2526
|
}
|
|
3527
2527
|
async setState(inputPatch, cbOrOptions, inputOptions) {
|
|
3528
|
-
let callback;
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
} else {
|
|
3534
|
-
options = cbOrOptions;
|
|
3535
|
-
}
|
|
3536
|
-
const { persistence = "none" } = options || {};
|
|
3537
|
-
let patch = {};
|
|
3538
|
-
let delta = {};
|
|
3539
|
-
if (typeof inputPatch === "function") {
|
|
3540
|
-
patch = /* @__PURE__ */ __name((state) => {
|
|
3541
|
-
const getDelta = inputPatch;
|
|
3542
|
-
delta = getDelta(state);
|
|
3543
|
-
return delta;
|
|
3544
|
-
}, "patch");
|
|
3545
|
-
} else {
|
|
3546
|
-
patch = inputPatch;
|
|
3547
|
-
delta = patch;
|
|
3548
|
-
}
|
|
3549
|
-
const newState = await new Promise((resolve) => {
|
|
2528
|
+
let callback, options;
|
|
2529
|
+
typeof cbOrOptions == "function" ? (callback = cbOrOptions, options = inputOptions) : options = cbOrOptions;
|
|
2530
|
+
let { persistence = "none" } = options || {}, patch = {}, delta = {};
|
|
2531
|
+
typeof inputPatch == "function" ? patch = (state) => (delta = inputPatch(state), delta) : (patch = inputPatch, delta = patch);
|
|
2532
|
+
let newState = await new Promise((resolve) => {
|
|
3550
2533
|
this.upstreamSetState(patch, () => {
|
|
3551
2534
|
resolve(this.getState());
|
|
3552
2535
|
});
|
|
3553
2536
|
});
|
|
3554
2537
|
if (persistence !== "none") {
|
|
3555
|
-
|
|
2538
|
+
let storage = persistence === "session" ? import_store2.default.session : import_store2.default.local;
|
|
3556
2539
|
await update(storage, delta);
|
|
3557
2540
|
}
|
|
3558
|
-
|
|
3559
|
-
callback(newState);
|
|
3560
|
-
}
|
|
3561
|
-
return newState;
|
|
2541
|
+
return callback && callback(newState), newState;
|
|
3562
2542
|
}
|
|
3563
2543
|
};
|
|
3564
|
-
__name(_Store, "Store");
|
|
3565
|
-
var Store = _Store;
|
|
3566
2544
|
|
|
3567
2545
|
// src/manager-api/lib/request-response.ts
|
|
3568
|
-
var
|
|
2546
|
+
var RequestResponseError = class extends Error {
|
|
3569
2547
|
constructor(message, payload) {
|
|
3570
2548
|
super(message);
|
|
3571
2549
|
this.payload = void 0;
|
|
3572
2550
|
this.payload = payload;
|
|
3573
2551
|
}
|
|
3574
|
-
}
|
|
3575
|
-
__name(_RequestResponseError, "RequestResponseError");
|
|
3576
|
-
var RequestResponseError = _RequestResponseError;
|
|
3577
|
-
var experimental_requestResponse = /* @__PURE__ */ __name((channel, requestEvent, responseEvent, payload, timeout = 5e3) => {
|
|
2552
|
+
}, experimental_requestResponse = (channel, requestEvent, responseEvent, payload, timeout = 5e3) => {
|
|
3578
2553
|
let timeoutId;
|
|
3579
2554
|
return new Promise((resolve, reject) => {
|
|
3580
|
-
|
|
2555
|
+
let request = {
|
|
3581
2556
|
id: Math.random().toString(16).slice(2),
|
|
3582
2557
|
payload
|
|
2558
|
+
}, responseHandler = (response) => {
|
|
2559
|
+
response.id === request.id && (clearTimeout(timeoutId), channel.off(responseEvent, responseHandler), response.success ? resolve(response.payload) : reject(new RequestResponseError(response.error, response.payload)));
|
|
3583
2560
|
};
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
return;
|
|
3587
|
-
}
|
|
3588
|
-
clearTimeout(timeoutId);
|
|
3589
|
-
channel.off(responseEvent, responseHandler);
|
|
3590
|
-
if (response.success) {
|
|
3591
|
-
resolve(response.payload);
|
|
3592
|
-
} else {
|
|
3593
|
-
reject(new RequestResponseError(response.error, response.payload));
|
|
3594
|
-
}
|
|
3595
|
-
}, "responseHandler");
|
|
3596
|
-
channel.emit(requestEvent, request);
|
|
3597
|
-
channel.on(responseEvent, responseHandler);
|
|
3598
|
-
timeoutId = setTimeout(() => {
|
|
3599
|
-
channel.off(responseEvent, responseHandler);
|
|
3600
|
-
reject(new RequestResponseError("Timed out waiting for response"));
|
|
2561
|
+
channel.emit(requestEvent, request), channel.on(responseEvent, responseHandler), timeoutId = setTimeout(() => {
|
|
2562
|
+
channel.off(responseEvent, responseHandler), reject(new RequestResponseError("Timed out waiting for response"));
|
|
3601
2563
|
}, timeout);
|
|
3602
2564
|
});
|
|
3603
|
-
}
|
|
2565
|
+
};
|
|
3604
2566
|
|
|
3605
2567
|
// src/manager-api/root.tsx
|
|
3606
2568
|
var { ActiveTabs: ActiveTabs2 } = layout_exports;
|
|
3607
|
-
var ManagerContext = createContext({ api: void 0, state: initial_state_default({}) })
|
|
3608
|
-
var combineParameters = /* @__PURE__ */ __name((...parameterSets) => noArrayMerge({}, ...parameterSets), "combineParameters");
|
|
3609
|
-
var _ManagerProvider = class _ManagerProvider extends Component {
|
|
2569
|
+
var ManagerContext = createContext({ api: void 0, state: initial_state_default({}) }), combineParameters = (...parameterSets) => noArrayMerge({}, ...parameterSets), ManagerProvider = class extends Component {
|
|
3610
2570
|
constructor(props) {
|
|
3611
2571
|
super(props);
|
|
3612
2572
|
this.api = {};
|
|
3613
|
-
this.initModules =
|
|
2573
|
+
this.initModules = () => {
|
|
3614
2574
|
this.modules.forEach((module) => {
|
|
3615
|
-
|
|
3616
|
-
module.init();
|
|
3617
|
-
}
|
|
2575
|
+
"init" in module && module.init();
|
|
3618
2576
|
});
|
|
3619
|
-
}
|
|
3620
|
-
|
|
2577
|
+
};
|
|
2578
|
+
let {
|
|
3621
2579
|
location: location2,
|
|
3622
2580
|
path,
|
|
3623
2581
|
refId,
|
|
@@ -3626,18 +2584,12 @@ var _ManagerProvider = class _ManagerProvider extends Component {
|
|
|
3626
2584
|
storyId,
|
|
3627
2585
|
docsOptions,
|
|
3628
2586
|
navigate
|
|
3629
|
-
} = props
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
this.setState(stateChange, () => callback(this.state));
|
|
3634
|
-
return this.state;
|
|
3635
|
-
}, "setState")
|
|
3636
|
-
});
|
|
3637
|
-
const routeData = { location: location2, path, viewMode, singleStory, storyId, refId };
|
|
3638
|
-
const optionsData = { docsOptions };
|
|
2587
|
+
} = props, store2 = new Store({
|
|
2588
|
+
getState: () => this.state,
|
|
2589
|
+
setState: (stateChange, callback) => (this.setState(stateChange, () => callback(this.state)), this.state)
|
|
2590
|
+
}), routeData = { location: location2, path, viewMode, singleStory, storyId, refId }, optionsData = { docsOptions };
|
|
3639
2591
|
this.state = store2.getInitialState(initial_state_default({ ...routeData, ...optionsData }));
|
|
3640
|
-
|
|
2592
|
+
let apiData = {
|
|
3641
2593
|
navigate,
|
|
3642
2594
|
store: store2,
|
|
3643
2595
|
provider: props.provider
|
|
@@ -3660,347 +2612,248 @@ var _ManagerProvider = class _ManagerProvider extends Component {
|
|
|
3660
2612
|
].map(
|
|
3661
2613
|
(m) => m.init({ ...routeData, ...optionsData, ...apiData, state: this.state, fullAPI: this.api })
|
|
3662
2614
|
);
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
this.state = state;
|
|
3666
|
-
this.api = api;
|
|
2615
|
+
let state = initial_state_default(this.state, ...this.modules.map((m) => m.state)), api = Object.assign(this.api, { navigate }, ...this.modules.map((m) => m.api));
|
|
2616
|
+
this.state = state, this.api = api;
|
|
3667
2617
|
}
|
|
3668
2618
|
static getDerivedStateFromProps(props, state) {
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
};
|
|
3678
|
-
}
|
|
3679
|
-
return null;
|
|
2619
|
+
return state.path !== props.path ? {
|
|
2620
|
+
...state,
|
|
2621
|
+
location: props.location,
|
|
2622
|
+
path: props.path,
|
|
2623
|
+
refId: props.refId,
|
|
2624
|
+
viewMode: props.viewMode,
|
|
2625
|
+
storyId: props.storyId
|
|
2626
|
+
} : null;
|
|
3680
2627
|
}
|
|
3681
2628
|
shouldComponentUpdate(nextProps, nextState) {
|
|
3682
|
-
|
|
3683
|
-
const prevState = this.state;
|
|
2629
|
+
let prevProps = this.props, prevState = this.state;
|
|
3684
2630
|
return prevProps.path !== nextProps.path || !isEqual(prevState, nextState);
|
|
3685
2631
|
}
|
|
3686
2632
|
render() {
|
|
3687
|
-
|
|
3688
|
-
const value = {
|
|
2633
|
+
let { children } = this.props, value = {
|
|
3689
2634
|
state: this.state,
|
|
3690
2635
|
api: this.api
|
|
3691
2636
|
};
|
|
3692
2637
|
return React4.createElement(EffectOnMount, { effect: this.initModules }, React4.createElement(ManagerContext.Provider, { value }, React4.createElement(ManagerConsumer, null, children)));
|
|
3693
2638
|
}
|
|
3694
2639
|
};
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
var ManagerProvider = _ManagerProvider;
|
|
3698
|
-
var EffectOnMount = /* @__PURE__ */ __name(({ children, effect }) => {
|
|
3699
|
-
React4.useEffect(effect, []);
|
|
3700
|
-
return children;
|
|
3701
|
-
}, "EffectOnMount");
|
|
3702
|
-
var defaultFilter = /* @__PURE__ */ __name((c) => c, "defaultFilter");
|
|
2640
|
+
ManagerProvider.displayName = "Manager";
|
|
2641
|
+
var EffectOnMount = ({ children, effect }) => (React4.useEffect(effect, []), children), defaultFilter = (c) => c;
|
|
3703
2642
|
function ManagerConsumer({
|
|
3704
2643
|
// @ts-expect-error (Converted from ts-ignore)
|
|
3705
2644
|
filter = defaultFilter,
|
|
3706
2645
|
children
|
|
3707
2646
|
}) {
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
const filterer = useRef2(filter);
|
|
3711
|
-
if (typeof renderer.current !== "function") {
|
|
2647
|
+
let managerContext = useContext(ManagerContext), renderer = useRef2(children), filterer = useRef2(filter);
|
|
2648
|
+
if (typeof renderer.current != "function")
|
|
3712
2649
|
return React4.createElement(Fragment, null, renderer.current);
|
|
3713
|
-
|
|
3714
|
-
const comboData = filterer.current(managerContext);
|
|
3715
|
-
const comboDataArray = useMemo(() => {
|
|
3716
|
-
return [...Object.entries(comboData).reduce((acc, keyval) => acc.concat(keyval), [])];
|
|
3717
|
-
}, [managerContext.state]);
|
|
2650
|
+
let comboData = filterer.current(managerContext), comboDataArray = useMemo(() => [...Object.entries(comboData).reduce((acc, keyval) => acc.concat(keyval), [])], [managerContext.state]);
|
|
3718
2651
|
return useMemo(() => {
|
|
3719
|
-
|
|
2652
|
+
let Child = renderer.current;
|
|
3720
2653
|
return React4.createElement(Child, { ...comboData });
|
|
3721
2654
|
}, comboDataArray);
|
|
3722
2655
|
}
|
|
3723
|
-
__name(ManagerConsumer, "ManagerConsumer");
|
|
3724
2656
|
function useStorybookState() {
|
|
3725
|
-
|
|
2657
|
+
let { state } = useContext(ManagerContext);
|
|
3726
2658
|
return state;
|
|
3727
2659
|
}
|
|
3728
|
-
__name(useStorybookState, "useStorybookState");
|
|
3729
2660
|
function useStorybookApi() {
|
|
3730
|
-
|
|
2661
|
+
let { api } = useContext(ManagerContext);
|
|
3731
2662
|
return api;
|
|
3732
2663
|
}
|
|
3733
|
-
__name(useStorybookApi, "useStorybookApi");
|
|
3734
2664
|
function orDefault(fromStore, defaultState) {
|
|
3735
|
-
|
|
3736
|
-
return defaultState;
|
|
3737
|
-
}
|
|
3738
|
-
return fromStore;
|
|
2665
|
+
return typeof fromStore > "u" ? defaultState : fromStore;
|
|
3739
2666
|
}
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
|
|
3747
|
-
};
|
|
3748
|
-
}, deps);
|
|
3749
|
-
return api.emit;
|
|
3750
|
-
}, "useChannel");
|
|
2667
|
+
var useChannel = (eventMap, deps = []) => {
|
|
2668
|
+
let api = useStorybookApi();
|
|
2669
|
+
return useEffect(() => (Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener)), () => {
|
|
2670
|
+
Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
|
|
2671
|
+
}), deps), api.emit;
|
|
2672
|
+
};
|
|
3751
2673
|
function useStoryPrepared(storyId) {
|
|
3752
|
-
|
|
3753
|
-
return api.isPrepared(storyId);
|
|
2674
|
+
return useStorybookApi().isPrepared(storyId);
|
|
3754
2675
|
}
|
|
3755
|
-
__name(useStoryPrepared, "useStoryPrepared");
|
|
3756
2676
|
function useParameter(parameterKey, defaultValue) {
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
const handleParameterChange = useCallback2(() => {
|
|
3760
|
-
const newParameter = api.getCurrentParameter(parameterKey);
|
|
2677
|
+
let api = useStorybookApi(), [parameter, setParameter] = useState(api.getCurrentParameter(parameterKey)), handleParameterChange = useCallback2(() => {
|
|
2678
|
+
let newParameter = api.getCurrentParameter(parameterKey);
|
|
3761
2679
|
setParameter(newParameter);
|
|
3762
2680
|
}, [api, parameterKey]);
|
|
3763
|
-
useChannel(
|
|
2681
|
+
return useChannel(
|
|
3764
2682
|
{
|
|
3765
2683
|
[STORY_PREPARED2]: handleParameterChange,
|
|
3766
2684
|
[DOCS_PREPARED2]: handleParameterChange
|
|
3767
2685
|
},
|
|
3768
2686
|
[handleParameterChange]
|
|
3769
|
-
);
|
|
3770
|
-
return orDefault(parameter, defaultValue);
|
|
2687
|
+
), orDefault(parameter, defaultValue);
|
|
3771
2688
|
}
|
|
3772
|
-
__name(useParameter, "useParameter");
|
|
3773
2689
|
globalThis.STORYBOOK_ADDON_STATE = {};
|
|
3774
2690
|
var { STORYBOOK_ADDON_STATE } = globalThis;
|
|
3775
2691
|
function useSharedState(stateId, defaultState) {
|
|
3776
|
-
|
|
3777
|
-
const existingState = api.getAddonState(stateId) || STORYBOOK_ADDON_STATE[stateId];
|
|
3778
|
-
const state = orDefault(
|
|
2692
|
+
let api = useStorybookApi(), existingState = api.getAddonState(stateId) || STORYBOOK_ADDON_STATE[stateId], state = orDefault(
|
|
3779
2693
|
existingState,
|
|
3780
2694
|
STORYBOOK_ADDON_STATE[stateId] ? STORYBOOK_ADDON_STATE[stateId] : defaultState
|
|
3781
|
-
);
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
STORYBOOK_ADDON_STATE[stateId] = defaultState;
|
|
3785
|
-
quicksync = true;
|
|
3786
|
-
}
|
|
3787
|
-
useEffect(() => {
|
|
3788
|
-
if (quicksync) {
|
|
3789
|
-
api.setAddonState(stateId, defaultState);
|
|
3790
|
-
}
|
|
2695
|
+
), quicksync = !1;
|
|
2696
|
+
state === defaultState && defaultState !== void 0 && (STORYBOOK_ADDON_STATE[stateId] = defaultState, quicksync = !0), useEffect(() => {
|
|
2697
|
+
quicksync && api.setAddonState(stateId, defaultState);
|
|
3791
2698
|
}, [quicksync]);
|
|
3792
|
-
|
|
2699
|
+
let setState = useCallback2(
|
|
3793
2700
|
async (s, options) => {
|
|
3794
2701
|
await api.setAddonState(stateId, s, options);
|
|
3795
|
-
|
|
3796
|
-
STORYBOOK_ADDON_STATE[stateId] = result;
|
|
3797
|
-
return result;
|
|
2702
|
+
let result = api.getAddonState(stateId);
|
|
2703
|
+
return STORYBOOK_ADDON_STATE[stateId] = result, result;
|
|
3798
2704
|
},
|
|
3799
2705
|
[api, stateId]
|
|
3800
|
-
)
|
|
3801
|
-
|
|
3802
|
-
const stateChangeHandlers = {
|
|
2706
|
+
), allListeners = useMemo(() => {
|
|
2707
|
+
let stateChangeHandlers = {
|
|
3803
2708
|
[`${SHARED_STATE_CHANGED}-client-${stateId}`]: setState,
|
|
3804
2709
|
[`${SHARED_STATE_SET}-client-${stateId}`]: setState
|
|
3805
|
-
}
|
|
3806
|
-
const stateInitializationHandlers = {
|
|
2710
|
+
}, stateInitializationHandlers = {
|
|
3807
2711
|
[SET_STORIES2]: async () => {
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
STORYBOOK_ADDON_STATE[stateId] = currentState;
|
|
3811
|
-
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
|
|
3812
|
-
} else if (STORYBOOK_ADDON_STATE[stateId]) {
|
|
3813
|
-
await setState(STORYBOOK_ADDON_STATE[stateId]);
|
|
3814
|
-
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, STORYBOOK_ADDON_STATE[stateId]);
|
|
3815
|
-
} else if (defaultState !== void 0) {
|
|
3816
|
-
await setState(defaultState);
|
|
3817
|
-
STORYBOOK_ADDON_STATE[stateId] = defaultState;
|
|
3818
|
-
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, defaultState);
|
|
3819
|
-
}
|
|
2712
|
+
let currentState = api.getAddonState(stateId);
|
|
2713
|
+
currentState ? (STORYBOOK_ADDON_STATE[stateId] = currentState, api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState)) : STORYBOOK_ADDON_STATE[stateId] ? (await setState(STORYBOOK_ADDON_STATE[stateId]), api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, STORYBOOK_ADDON_STATE[stateId])) : defaultState !== void 0 && (await setState(defaultState), STORYBOOK_ADDON_STATE[stateId] = defaultState, api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, defaultState));
|
|
3820
2714
|
},
|
|
3821
2715
|
[STORY_CHANGED2]: () => {
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
|
|
3825
|
-
}
|
|
2716
|
+
let currentState = api.getAddonState(stateId);
|
|
2717
|
+
currentState !== void 0 && api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
|
|
3826
2718
|
}
|
|
3827
2719
|
};
|
|
3828
2720
|
return {
|
|
3829
2721
|
...stateChangeHandlers,
|
|
3830
2722
|
...stateInitializationHandlers
|
|
3831
2723
|
};
|
|
3832
|
-
}, [stateId])
|
|
3833
|
-
const emit = useChannel(allListeners);
|
|
3834
|
-
const stateSetter = useCallback2(
|
|
2724
|
+
}, [stateId]), emit = useChannel(allListeners), stateSetter = useCallback2(
|
|
3835
2725
|
async (newStateOrMerger, options) => {
|
|
3836
2726
|
await setState(newStateOrMerger, options);
|
|
3837
|
-
|
|
2727
|
+
let result = api.getAddonState(stateId);
|
|
3838
2728
|
emit(`${SHARED_STATE_CHANGED}-manager-${stateId}`, result);
|
|
3839
2729
|
},
|
|
3840
2730
|
[api, emit, setState, stateId]
|
|
3841
2731
|
);
|
|
3842
2732
|
return [state, stateSetter];
|
|
3843
2733
|
}
|
|
3844
|
-
__name(useSharedState, "useSharedState");
|
|
3845
2734
|
function useAddonState(addonId, defaultState) {
|
|
3846
2735
|
return useSharedState(addonId, defaultState);
|
|
3847
2736
|
}
|
|
3848
|
-
__name(useAddonState, "useAddonState");
|
|
3849
2737
|
function useArgs() {
|
|
3850
|
-
|
|
3851
|
-
const data = getCurrentStoryData();
|
|
3852
|
-
const args = data?.type === "story" ? data.args : {};
|
|
3853
|
-
const initialArgs = data?.type === "story" ? data.initialArgs : {};
|
|
3854
|
-
const updateArgs = useCallback2(
|
|
2738
|
+
let { getCurrentStoryData, updateStoryArgs, resetStoryArgs } = useStorybookApi(), data = getCurrentStoryData(), args = data?.type === "story" ? data.args : {}, initialArgs = data?.type === "story" ? data.initialArgs : {}, updateArgs = useCallback2(
|
|
3855
2739
|
(newArgs) => updateStoryArgs(data, newArgs),
|
|
3856
2740
|
[data, updateStoryArgs]
|
|
3857
|
-
)
|
|
3858
|
-
const resetArgs = useCallback2(
|
|
2741
|
+
), resetArgs = useCallback2(
|
|
3859
2742
|
(argNames) => resetStoryArgs(data, argNames),
|
|
3860
2743
|
[data, resetStoryArgs]
|
|
3861
2744
|
);
|
|
3862
2745
|
return [args, updateArgs, resetArgs, initialArgs];
|
|
3863
2746
|
}
|
|
3864
|
-
__name(useArgs, "useArgs");
|
|
3865
2747
|
function useGlobals() {
|
|
3866
|
-
|
|
2748
|
+
let api = useStorybookApi();
|
|
3867
2749
|
return [api.getGlobals(), api.updateGlobals, api.getStoryGlobals(), api.getUserGlobals()];
|
|
3868
2750
|
}
|
|
3869
|
-
__name(useGlobals, "useGlobals");
|
|
3870
2751
|
function useGlobalTypes() {
|
|
3871
2752
|
return useStorybookApi().getGlobalTypes();
|
|
3872
2753
|
}
|
|
3873
|
-
__name(useGlobalTypes, "useGlobalTypes");
|
|
3874
2754
|
function useCurrentStory() {
|
|
3875
|
-
|
|
2755
|
+
let { getCurrentStoryData } = useStorybookApi();
|
|
3876
2756
|
return getCurrentStoryData();
|
|
3877
2757
|
}
|
|
3878
|
-
__name(useCurrentStory, "useCurrentStory");
|
|
3879
2758
|
function useArgTypes() {
|
|
3880
|
-
|
|
2759
|
+
let current = useCurrentStory();
|
|
3881
2760
|
return current?.type === "story" && current.argTypes || {};
|
|
3882
2761
|
}
|
|
3883
|
-
__name(useArgTypes, "useArgTypes");
|
|
3884
2762
|
var typesX = Addon_TypesEnum;
|
|
3885
2763
|
|
|
3886
2764
|
// src/shared/universal-store/mock.ts
|
|
3887
2765
|
import { Channel as Channel2 } from "storybook/internal/channels";
|
|
3888
|
-
var
|
|
2766
|
+
var MockUniversalStore = class _MockUniversalStore extends UniversalStore {
|
|
3889
2767
|
constructor(options, testUtils) {
|
|
3890
|
-
UniversalStore.isInternalConstructing =
|
|
3891
|
-
|
|
3892
|
-
{ ...options, leader: true },
|
|
2768
|
+
UniversalStore.isInternalConstructing = !0, super(
|
|
2769
|
+
{ ...options, leader: !0 },
|
|
3893
2770
|
{ channel: new Channel2({}), environment: UniversalStore.Environment.MOCK }
|
|
3894
|
-
);
|
|
3895
|
-
UniversalStore.isInternalConstructing = false;
|
|
3896
|
-
if (typeof testUtils?.fn !== "function") {
|
|
3897
|
-
return;
|
|
3898
|
-
}
|
|
3899
|
-
this.testUtils = testUtils;
|
|
3900
|
-
this.getState = testUtils.fn(this.getState);
|
|
3901
|
-
this.setState = testUtils.fn(this.setState);
|
|
3902
|
-
this.subscribe = testUtils.fn(this.subscribe);
|
|
3903
|
-
this.onStateChange = testUtils.fn(this.onStateChange);
|
|
3904
|
-
this.send = testUtils.fn(this.send);
|
|
2771
|
+
), UniversalStore.isInternalConstructing = !1, typeof testUtils?.fn == "function" && (this.testUtils = testUtils, this.getState = testUtils.fn(this.getState), this.setState = testUtils.fn(this.setState), this.subscribe = testUtils.fn(this.subscribe), this.onStateChange = testUtils.fn(this.onStateChange), this.send = testUtils.fn(this.send));
|
|
3905
2772
|
}
|
|
3906
2773
|
/** Create a mock universal store. This is just an alias for the constructor */
|
|
3907
2774
|
static create(options, testUtils) {
|
|
3908
2775
|
return new _MockUniversalStore(options, testUtils);
|
|
3909
2776
|
}
|
|
3910
2777
|
unsubscribeAll() {
|
|
3911
|
-
if (!this.testUtils)
|
|
2778
|
+
if (!this.testUtils)
|
|
3912
2779
|
throw new Error(
|
|
3913
2780
|
dedent`Cannot call unsubscribeAll on a store that does not have testUtils.
|
|
3914
2781
|
Please provide testUtils as the second argument when creating the store.`
|
|
3915
2782
|
);
|
|
3916
|
-
|
|
3917
|
-
const callReturnedUnsubscribeFn = /* @__PURE__ */ __name((result) => {
|
|
2783
|
+
let callReturnedUnsubscribeFn = (result) => {
|
|
3918
2784
|
try {
|
|
3919
2785
|
result.value();
|
|
3920
|
-
} catch
|
|
2786
|
+
} catch {
|
|
3921
2787
|
}
|
|
3922
|
-
}
|
|
3923
|
-
this.subscribe.mock?.results.forEach(callReturnedUnsubscribeFn);
|
|
3924
|
-
this.onStateChange.mock?.results.forEach(callReturnedUnsubscribeFn);
|
|
2788
|
+
};
|
|
2789
|
+
this.subscribe.mock?.results.forEach(callReturnedUnsubscribeFn), this.onStateChange.mock?.results.forEach(callReturnedUnsubscribeFn);
|
|
3925
2790
|
}
|
|
3926
2791
|
};
|
|
3927
|
-
__name(_MockUniversalStore, "MockUniversalStore");
|
|
3928
|
-
var MockUniversalStore = _MockUniversalStore;
|
|
3929
2792
|
|
|
3930
2793
|
// src/shared/test-provider-store/index.ts
|
|
3931
2794
|
var UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS = {
|
|
3932
2795
|
id: "storybook/test-provider",
|
|
3933
|
-
leader:
|
|
2796
|
+
leader: !0,
|
|
3934
2797
|
initialState: {}
|
|
3935
2798
|
};
|
|
3936
2799
|
function createTestProviderStore({
|
|
3937
2800
|
universalTestProviderStore: universalTestProviderStore2,
|
|
3938
2801
|
useUniversalStore: useUniversalStore2
|
|
3939
2802
|
}) {
|
|
3940
|
-
|
|
3941
|
-
settingsChanged:
|
|
2803
|
+
let baseStore = {
|
|
2804
|
+
settingsChanged: () => {
|
|
3942
2805
|
universalTestProviderStore2.untilReady().then(() => {
|
|
3943
2806
|
universalTestProviderStore2.send({ type: "settings-changed" });
|
|
3944
2807
|
});
|
|
3945
|
-
},
|
|
3946
|
-
onRunAll:
|
|
3947
|
-
onClearAll:
|
|
3948
|
-
}
|
|
3949
|
-
const fullTestProviderStore2 = {
|
|
2808
|
+
},
|
|
2809
|
+
onRunAll: (listener) => universalTestProviderStore2.subscribe("run-all", listener),
|
|
2810
|
+
onClearAll: (listener) => universalTestProviderStore2.subscribe("clear-all", listener)
|
|
2811
|
+
}, fullTestProviderStore2 = {
|
|
3950
2812
|
...baseStore,
|
|
3951
2813
|
getFullState: universalTestProviderStore2.getState,
|
|
3952
2814
|
setFullState: universalTestProviderStore2.setState,
|
|
3953
|
-
onSettingsChanged:
|
|
3954
|
-
runAll:
|
|
3955
|
-
await universalTestProviderStore2.untilReady();
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
};
|
|
3963
|
-
const getTestProviderStoreById2 = /* @__PURE__ */ __name((testProviderId) => {
|
|
3964
|
-
const getStateForTestProvider = /* @__PURE__ */ __name(() => universalTestProviderStore2.getState()[testProviderId] ?? "test-provider-state:pending", "getStateForTestProvider");
|
|
3965
|
-
const setStateForTestProvider = /* @__PURE__ */ __name((state) => {
|
|
2815
|
+
onSettingsChanged: (listener) => universalTestProviderStore2.subscribe("settings-changed", listener),
|
|
2816
|
+
runAll: async () => {
|
|
2817
|
+
await universalTestProviderStore2.untilReady(), universalTestProviderStore2.send({ type: "run-all" });
|
|
2818
|
+
},
|
|
2819
|
+
clearAll: async () => {
|
|
2820
|
+
await universalTestProviderStore2.untilReady(), universalTestProviderStore2.send({ type: "clear-all" });
|
|
2821
|
+
}
|
|
2822
|
+
}, getTestProviderStoreById2 = (testProviderId) => {
|
|
2823
|
+
let getStateForTestProvider = () => universalTestProviderStore2.getState()[testProviderId] ?? "test-provider-state:pending", setStateForTestProvider = (state) => {
|
|
3966
2824
|
universalTestProviderStore2.untilReady().then(() => {
|
|
3967
2825
|
universalTestProviderStore2.setState((currentState) => ({
|
|
3968
2826
|
...currentState,
|
|
3969
2827
|
[testProviderId]: state
|
|
3970
2828
|
}));
|
|
3971
2829
|
});
|
|
3972
|
-
}
|
|
2830
|
+
};
|
|
3973
2831
|
return {
|
|
3974
2832
|
...baseStore,
|
|
3975
2833
|
testProviderId,
|
|
3976
2834
|
getState: getStateForTestProvider,
|
|
3977
2835
|
setState: setStateForTestProvider,
|
|
3978
|
-
runWithState:
|
|
2836
|
+
runWithState: async (callback) => {
|
|
3979
2837
|
setStateForTestProvider("test-provider-state:running");
|
|
3980
2838
|
try {
|
|
3981
|
-
await callback();
|
|
3982
|
-
|
|
3983
|
-
} catch (error) {
|
|
2839
|
+
await callback(), setStateForTestProvider("test-provider-state:succeeded");
|
|
2840
|
+
} catch {
|
|
3984
2841
|
setStateForTestProvider("test-provider-state:crashed");
|
|
3985
2842
|
}
|
|
3986
|
-
}
|
|
3987
|
-
};
|
|
3988
|
-
}, "getTestProviderStoreById");
|
|
3989
|
-
if (useUniversalStore2) {
|
|
3990
|
-
return {
|
|
3991
|
-
getTestProviderStoreById: getTestProviderStoreById2,
|
|
3992
|
-
fullTestProviderStore: fullTestProviderStore2,
|
|
3993
|
-
universalTestProviderStore: universalTestProviderStore2,
|
|
3994
|
-
useTestProviderStore: /* @__PURE__ */ __name((selector) => useUniversalStore2(universalTestProviderStore2, selector)[0], "useTestProviderStore")
|
|
2843
|
+
}
|
|
3995
2844
|
};
|
|
3996
|
-
}
|
|
3997
|
-
return {
|
|
2845
|
+
};
|
|
2846
|
+
return useUniversalStore2 ? {
|
|
2847
|
+
getTestProviderStoreById: getTestProviderStoreById2,
|
|
2848
|
+
fullTestProviderStore: fullTestProviderStore2,
|
|
2849
|
+
universalTestProviderStore: universalTestProviderStore2,
|
|
2850
|
+
useTestProviderStore: (selector) => useUniversalStore2(universalTestProviderStore2, selector)[0]
|
|
2851
|
+
} : {
|
|
3998
2852
|
getTestProviderStoreById: getTestProviderStoreById2,
|
|
3999
2853
|
fullTestProviderStore: fullTestProviderStore2,
|
|
4000
2854
|
universalTestProviderStore: universalTestProviderStore2
|
|
4001
2855
|
};
|
|
4002
2856
|
}
|
|
4003
|
-
__name(createTestProviderStore, "createTestProviderStore");
|
|
4004
2857
|
|
|
4005
2858
|
// src/manager-api/stores/test-provider.ts
|
|
4006
2859
|
var testProviderStore = createTestProviderStore({
|
|
@@ -4009,8 +2862,7 @@ var testProviderStore = createTestProviderStore({
|
|
|
4009
2862
|
leader: globalThis.CONFIG_TYPE === "PRODUCTION"
|
|
4010
2863
|
}),
|
|
4011
2864
|
useUniversalStore
|
|
4012
|
-
})
|
|
4013
|
-
var {
|
|
2865
|
+
}), {
|
|
4014
2866
|
fullTestProviderStore,
|
|
4015
2867
|
getTestProviderStoreById,
|
|
4016
2868
|
useTestProviderStore,
|
|
@@ -4047,6 +2899,7 @@ export {
|
|
|
4047
2899
|
mockChannel,
|
|
4048
2900
|
optionOrAltSymbol,
|
|
4049
2901
|
shortcutMatchesShortcut,
|
|
2902
|
+
shortcutToAriaKeyshortcuts,
|
|
4050
2903
|
shortcutToHumanString,
|
|
4051
2904
|
typesX as types,
|
|
4052
2905
|
useAddonState,
|