storybook 10.0.0-beta.5 → 10.0.0-beta.7

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.
Files changed (88) hide show
  1. package/assets/server/openBrowser.applescript +94 -0
  2. package/dist/_browser-chunks/{WithTooltip-ERFLZL6W.js → WithTooltip-SK46ZJ2J.js} +1 -1
  3. package/dist/_browser-chunks/{chunk-EOILZP2R.js → chunk-BOOOPFZF.js} +7 -2
  4. package/dist/_browser-chunks/{chunk-YQV3EGQ5.js → chunk-OQ6NCFPL.js} +38 -15
  5. package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
  6. package/dist/_node-chunks/{builder-manager-ZTS4EIKQ.js → builder-manager-VFP7HSCF.js} +21 -151
  7. package/dist/_node-chunks/camelcase-ZLZNQMDD.js +18 -0
  8. package/dist/_node-chunks/{chunk-VQN4WAIA.js → chunk-2GCKJYK6.js} +7 -7
  9. package/dist/_node-chunks/{chunk-H52PBBSK.js → chunk-3NIQHNDU.js} +7 -7
  10. package/dist/_node-chunks/{chunk-3VVGIILJ.js → chunk-3QZ7KLON.js} +8 -8
  11. package/dist/_node-chunks/{chunk-VWSUFVUF.js → chunk-3XXQRL3A.js} +7 -7
  12. package/dist/_node-chunks/{chunk-OC3TVLYU.js → chunk-46BWYN3K.js} +7 -7
  13. package/dist/_node-chunks/{chunk-VX5P3IYA.js → chunk-4DIDWIST.js} +7 -7
  14. package/dist/_node-chunks/{chunk-TBWOUVTA.js → chunk-5YUTWYNI.js} +709 -935
  15. package/dist/_node-chunks/{chunk-4VDRH7SM.js → chunk-A2DKPKBY.js} +7 -7
  16. package/dist/_node-chunks/{chunk-KU3JBNPY.js → chunk-BC23FKU4.js} +8 -8
  17. package/dist/_node-chunks/{chunk-KZB7ELL6.js → chunk-BID2X7MU.js} +7 -7
  18. package/dist/_node-chunks/{chunk-PIKDGR3O.js → chunk-C4EOB63P.js} +7 -7
  19. package/dist/_node-chunks/{chunk-TVKUJ3SE.js → chunk-DH7BCQMG.js} +8 -8
  20. package/dist/_node-chunks/{chunk-J3DQMIO4.js → chunk-FCNWWJV7.js} +7 -7
  21. package/dist/_node-chunks/{chunk-EIHJ5J3O.js → chunk-GBZZSL2K.js} +264 -109
  22. package/dist/_node-chunks/{chunk-F7YW5W6B.js → chunk-GCWAGPDV.js} +12 -12
  23. package/dist/_node-chunks/{chunk-K4YETNYJ.js → chunk-I7SRMFT5.js} +7 -7
  24. package/dist/_node-chunks/{chunk-TKN5TEZV.js → chunk-IEFSRAX2.js} +13 -13
  25. package/dist/_node-chunks/{chunk-AK5PHLUA.js → chunk-IGWCAXA2.js} +7 -7
  26. package/dist/_node-chunks/chunk-IYOHZPPC.js +18 -0
  27. package/dist/_node-chunks/{chunk-F3WE3456.js → chunk-KVOP6ASA.js} +7 -7
  28. package/dist/_node-chunks/{chunk-DZJNLBBL.js → chunk-MHVF6Y35.js} +7 -7
  29. package/dist/_node-chunks/{chunk-UTCFHTQH.js → chunk-MRCMZPA2.js} +7 -7
  30. package/dist/_node-chunks/chunk-RNHUADRS.js +62 -0
  31. package/dist/_node-chunks/{chunk-4KRR46V2.js → chunk-RP3VMQPF.js} +15 -15
  32. package/dist/_node-chunks/{chunk-P7YMEOXF.js → chunk-TFIGR2HH.js} +7 -7
  33. package/dist/_node-chunks/{chunk-SW3VZAH7.js → chunk-TXDIOSHI.js} +9 -9
  34. package/dist/_node-chunks/{chunk-WCSHG2QT.js → chunk-U6MJQ7C6.js} +7 -7
  35. package/dist/_node-chunks/{chunk-ACUNHBEO.js → chunk-XXVKM2ZR.js} +26 -23
  36. package/dist/_node-chunks/{chunk-QHIU5I7C.js → chunk-YWU65VY4.js} +6 -6
  37. package/dist/_node-chunks/{chunk-P3TWEOO5.js → chunk-Z3PLI7S2.js} +7 -7
  38. package/dist/_node-chunks/{chunk-2VMDKLSW.js → chunk-ZM2HT2RW.js} +6 -6
  39. package/dist/_node-chunks/{chunk-D7SDB4XE.js → chunk-ZPNXCXIT.js} +8 -8
  40. package/dist/_node-chunks/{dist-OGRBL76N.js → dist-PG4I7ZDU.js} +9 -9
  41. package/dist/_node-chunks/{globby-65LOULA6.js → globby-HXB6X43W.js} +17 -13
  42. package/dist/_node-chunks/{lib-TF7JCT3A.js → lib-4JJTZC7T.js} +7 -7
  43. package/dist/_node-chunks/{mdx-N42X6CFJ-6ZJEUZMZ.js → mdx-N42X6CFJ-3JBJ7PQF.js} +8 -8
  44. package/dist/_node-chunks/{p-limit-PF7JSPDT.js → p-limit-WBBNX4KI.js} +7 -7
  45. package/dist/_node-chunks/{plugin-A6XAWMXN.js → plugin-SEQ2OPRK.js} +10 -10
  46. package/dist/_node-chunks/{plugin-LGHGAC6J.js → plugin-SG6I7RFC.js} +10 -10
  47. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-HDSEOU3Z.js → webpack-inject-mocker-runtime-plugin-5O25VYCQ.js} +10 -10
  48. package/dist/_node-chunks/{webpack-mock-plugin-ZJJVMJUS.js → webpack-mock-plugin-35I32SAF.js} +9 -9
  49. package/dist/babel/index.js +11 -11
  50. package/dist/bin/core.js +11 -11
  51. package/dist/bin/dispatcher.js +11 -11
  52. package/dist/bin/loader.js +8 -8
  53. package/dist/cli/index.js +27 -22
  54. package/dist/common/index.js +21 -21
  55. package/dist/components/index.js +8 -4
  56. package/dist/core-events/index.d.ts +18 -2
  57. package/dist/core-events/index.js +7 -1
  58. package/dist/core-server/index.js +1157 -1024
  59. package/dist/core-server/presets/common-manager.js +84 -39
  60. package/dist/core-server/presets/common-override-preset.js +9 -9
  61. package/dist/core-server/presets/common-preset.js +691 -29
  62. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
  63. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
  64. package/dist/csf/index.d.ts +9 -4
  65. package/dist/csf/index.js +37 -8
  66. package/dist/csf-tools/index.d.ts +13 -6
  67. package/dist/csf-tools/index.js +9 -9
  68. package/dist/manager/globals-runtime.js +1318 -1001
  69. package/dist/manager/globals.d.ts +0 -4
  70. package/dist/manager/globals.js +1 -6
  71. package/dist/manager/runtime.js +2198 -721
  72. package/dist/manager-api/index.d.ts +12 -5
  73. package/dist/manager-api/index.js +347 -76
  74. package/dist/node-logger/index.js +14 -14
  75. package/dist/preview/runtime.js +103 -63
  76. package/dist/preview-api/index.d.ts +70 -71
  77. package/dist/preview-api/index.js +1 -1
  78. package/dist/server-errors.js +10 -10
  79. package/dist/telemetry/index.d.ts +1 -1
  80. package/dist/telemetry/index.js +24 -24
  81. package/dist/types/index.d.ts +28 -7
  82. package/dist/viewport/index.d.ts +36 -4
  83. package/dist/viewport/index.js +1 -1
  84. package/package.json +5 -4
  85. package/dist/_node-chunks/camelcase-K3BM7RII.js +0 -18
  86. package/dist/_node-chunks/chunk-7LG5CLCT.js +0 -18
  87. package/dist/_node-chunks/chunk-DWJ7TV2O.js +0 -62
  88. package/dist/_node-chunks/default-browser-id-4RZZMHJE.js +0 -1719
@@ -44,10 +44,147 @@ import {
44
44
  __toESM
45
45
  } from "../_browser-chunks/chunk-MM7DTO55.js";
46
46
 
47
+ // ../node_modules/toggle-selection/index.js
48
+ var require_toggle_selection = __commonJS({
49
+ "../node_modules/toggle-selection/index.js"(exports, module) {
50
+ module.exports = function() {
51
+ var selection = document.getSelection();
52
+ if (!selection.rangeCount) {
53
+ return function() {
54
+ };
55
+ }
56
+ var active = document.activeElement;
57
+ var ranges = [];
58
+ for (var i = 0; i < selection.rangeCount; i++) {
59
+ ranges.push(selection.getRangeAt(i));
60
+ }
61
+ switch (active.tagName.toUpperCase()) {
62
+ // .toUpperCase handles XHTML
63
+ case "INPUT":
64
+ case "TEXTAREA":
65
+ active.blur();
66
+ break;
67
+ default:
68
+ active = null;
69
+ break;
70
+ }
71
+ selection.removeAllRanges();
72
+ return function() {
73
+ selection.type === "Caret" && selection.removeAllRanges();
74
+ if (!selection.rangeCount) {
75
+ ranges.forEach(function(range) {
76
+ selection.addRange(range);
77
+ });
78
+ }
79
+ active && active.focus();
80
+ };
81
+ };
82
+ }
83
+ });
84
+
85
+ // ../node_modules/copy-to-clipboard/index.js
86
+ var require_copy_to_clipboard = __commonJS({
87
+ "../node_modules/copy-to-clipboard/index.js"(exports, module) {
88
+ "use strict";
89
+ var deselectCurrent = require_toggle_selection();
90
+ var clipboardToIE11Formatting = {
91
+ "text/plain": "Text",
92
+ "text/html": "Url",
93
+ "default": "Text"
94
+ };
95
+ var defaultMessage = "Copy to clipboard: #{key}, Enter";
96
+ function format(message) {
97
+ var copyKey = (/mac os x/i.test(navigator.userAgent) ? "\u2318" : "Ctrl") + "+C";
98
+ return message.replace(/#{\s*key\s*}/g, copyKey);
99
+ }
100
+ __name(format, "format");
101
+ function copy2(text, options) {
102
+ var debug, message, reselectPrevious, range, selection, mark, success = false;
103
+ if (!options) {
104
+ options = {};
105
+ }
106
+ debug = options.debug || false;
107
+ try {
108
+ reselectPrevious = deselectCurrent();
109
+ range = document.createRange();
110
+ selection = document.getSelection();
111
+ mark = document.createElement("span");
112
+ mark.textContent = text;
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"];
132
+ window.clipboardData.setData(format2, text);
133
+ } else {
134
+ e.clipboardData.clearData();
135
+ e.clipboardData.setData(options.format, text);
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);
146
+ var successful = document.execCommand("copy");
147
+ if (!successful) {
148
+ throw new Error("copy command was unsuccessful");
149
+ }
150
+ success = true;
151
+ } catch (err) {
152
+ debug && console.error("unable to copy using execCommand: ", err);
153
+ debug && console.warn("trying IE specific stuff");
154
+ try {
155
+ window.clipboardData.setData(options.format || "text", text);
156
+ options.onCopy && options.onCopy(window.clipboardData);
157
+ success = true;
158
+ } 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);
163
+ }
164
+ } finally {
165
+ if (selection) {
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();
176
+ }
177
+ return success;
178
+ }
179
+ __name(copy2, "copy");
180
+ module.exports = copy2;
181
+ }
182
+ });
183
+
47
184
  // ../node_modules/store2/dist/store2.js
48
185
  var require_store2 = __commonJS({
49
186
  "../node_modules/store2/dist/store2.js"(exports, module) {
50
- (function(window, define) {
187
+ (function(window2, define) {
51
188
  var _ = {
52
189
  version: "2.14.4",
53
190
  areas: {},
@@ -374,17 +511,17 @@ var require_store2 = __commonJS({
374
511
  } else if (typeof module !== "undefined" && module.exports) {
375
512
  module.exports = store2;
376
513
  } else {
377
- if (window.store) {
378
- _.conflict = window.store;
514
+ if (window2.store) {
515
+ _.conflict = window2.store;
379
516
  }
380
- window.store = store2;
517
+ window2.store = store2;
381
518
  }
382
519
  })(exports, exports && exports.define);
383
520
  }
384
521
  });
385
522
 
386
523
  // src/manager-api/root.tsx
387
- import React3, {
524
+ import React4, {
388
525
  Component,
389
526
  Fragment,
390
527
  useCallback as useCallback2,
@@ -758,6 +895,7 @@ var transformSetStoriesStoryDataToPreparedStoryIndex = /* @__PURE__ */ __name((s
758
895
  const { argTypes, args, initialArgs } = story;
759
896
  acc[id] = {
760
897
  type: "story",
898
+ subtype: "story",
761
899
  ...base,
762
900
  parameters,
763
901
  argTypes,
@@ -835,19 +973,18 @@ var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider
835
973
  index = index.v === 3 ? transformStoryIndexV3toV4(index) : index;
836
974
  index = index.v === 4 ? transformStoryIndexV4toV5(index) : index;
837
975
  index = index;
838
- const entryValues = Object.values(index.entries).filter((entry) => {
839
- let result = true;
840
- const storyStatuses = allStatuses[entry.id] ?? {};
841
- if (Object.values(storyStatuses).some(({ value }) => value === "status-value:error")) {
842
- return result;
976
+ const indexEntries = Object.values(index.entries);
977
+ const filterFunctions = Object.values(filters);
978
+ const entryValues = indexEntries.filter((entry) => {
979
+ const statuses = allStatuses[entry.id] ?? {};
980
+ if (Object.values(statuses).some(({ value }) => value === "status-value:error")) {
981
+ return true;
843
982
  }
844
- Object.values(filters).forEach((filter) => {
845
- if (result === false) {
846
- return;
847
- }
848
- result = filter({ ...entry, statuses: storyStatuses });
849
- });
850
- return result;
983
+ if (filterFunctions.every((fn) => fn({ ...entry, statuses }))) {
984
+ return true;
985
+ }
986
+ const children = indexEntries.filter((item) => "parent" in item && item.parent === entry.id);
987
+ return children.some((child) => filterFunctions.every((fn) => fn({ ...child, statuses })));
851
988
  });
852
989
  const { sidebar = {} } = provider.getConfig();
853
990
  const { showRoots, collapsedRoots = [], renderLabel } = sidebar;
@@ -870,7 +1007,7 @@ var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider
870
1007
  throw new Error(
871
1008
  dedent`
872
1009
  Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}'
873
-
1010
+
874
1011
  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
875
1012
  `
876
1013
  );
@@ -921,33 +1058,60 @@ var transformStoryIndexToStoriesHash = /* @__PURE__ */ __name((input, { provider
921
1058
  }
922
1059
  });
923
1060
  acc[item.id] = {
924
- type: "story",
925
1061
  tags: [],
926
1062
  ...item,
927
1063
  depth: paths.length,
928
- parent: paths[paths.length - 1],
1064
+ parent: "parent" in item ? item.parent : paths[paths.length - 1],
929
1065
  renderLabel,
930
1066
  prepared: !!item.parameters
931
1067
  };
932
1068
  return acc;
933
1069
  }, {});
934
1070
  function addItem(acc, item) {
935
- if (acc[item.id]) {
936
- return acc;
1071
+ if (!acc[item.id]) {
1072
+ acc[item.id] = item;
1073
+ if ("children" in item && item.children) {
1074
+ item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId]));
1075
+ item.tags = item.children.reduce((currentTags, childId) => {
1076
+ return currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags);
1077
+ }, null) || [];
1078
+ }
937
1079
  }
938
- acc[item.id] = item;
939
- if (item.type === "root" || item.type === "group" || item.type === "component") {
940
- item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId]));
941
- item.tags = item.children.reduce((currentTags, childId) => {
942
- const child = acc[childId];
943
- return currentTags === null ? child.tags : intersect_default(currentTags, child.tags);
944
- }, null);
1080
+ if (item.type === "component") {
1081
+ const firstChild = acc[item.children[0]];
1082
+ if (firstChild && "importPath" in firstChild) {
1083
+ item.importPath = firstChild.importPath;
1084
+ }
945
1085
  }
946
1086
  return acc;
947
1087
  }
948
1088
  __name(addItem, "addItem");
949
- const orphanHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type !== "root" && !i.parent).reduce(addItem, {});
950
- return Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, orphanHash);
1089
+ let storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type !== "root" && !i.parent).reduce((acc, item) => addItem(acc, item), {});
1090
+ storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash);
1091
+ storiesHash = Object.values(storiesHash).reduce((acc, item) => {
1092
+ if (item.type === "story" && item.subtype === "test") {
1093
+ const story = acc[item.parent];
1094
+ const component = acc[story.parent];
1095
+ acc[component.id] = {
1096
+ ...component,
1097
+ // Remove test from the component node as it will be attached to the story node instead
1098
+ children: component.children && component.children.filter((id) => id !== item.id)
1099
+ };
1100
+ acc[story.id] = {
1101
+ ...story,
1102
+ // Add test to the story node
1103
+ children: (story.children || []).concat(item.id)
1104
+ };
1105
+ acc[item.id] = {
1106
+ ...item,
1107
+ depth: item.depth + 1
1108
+ };
1109
+ } else {
1110
+ acc[item.id] = item;
1111
+ }
1112
+ return acc;
1113
+ }, {});
1114
+ return storiesHash;
951
1115
  }, "transformStoryIndexToStoriesHash");
952
1116
  var addPreparedStories = /* @__PURE__ */ __name((newHash, oldHash) => {
953
1117
  if (!oldHash) {
@@ -957,6 +1121,9 @@ var addPreparedStories = /* @__PURE__ */ __name((newHash, oldHash) => {
957
1121
  Object.entries(newHash).map(([id, newEntry]) => {
958
1122
  const oldEntry = oldHash[id];
959
1123
  if (newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared) {
1124
+ if ("children" in oldEntry) {
1125
+ delete oldEntry.children;
1126
+ }
960
1127
  return [id, { ...oldEntry, ...newEntry, prepared: true }];
961
1128
  }
962
1129
  return [id, newEntry];
@@ -1326,7 +1493,7 @@ __export(layout_exports, {
1326
1493
  import { SET_CONFIG as SET_CONFIG2 } from "storybook/internal/core-events";
1327
1494
  import { global as global3 } from "@storybook/global";
1328
1495
  import { create } from "storybook/theming/create";
1329
- var { document } = global3;
1496
+ var { document: document2 } = global3;
1330
1497
  var isFunction = /* @__PURE__ */ __name((val) => typeof val === "function", "isFunction");
1331
1498
  var ActiveTabs = {
1332
1499
  SIDEBAR: "sidebar",
@@ -1520,7 +1687,7 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1520
1687
  if (!elementId) {
1521
1688
  return;
1522
1689
  }
1523
- const element = document.getElementById(elementId);
1690
+ const element = document2.getElementById(elementId);
1524
1691
  if (element) {
1525
1692
  element.focus();
1526
1693
  if (select) {
@@ -1564,6 +1731,13 @@ var init5 = /* @__PURE__ */ __name(({ store: store2, provider, singleStory }) =>
1564
1731
  }
1565
1732
  return showToolbar;
1566
1733
  },
1734
+ getShowPanelWithCustomisations(showPanel) {
1735
+ const state = store2.getState();
1736
+ if (isFunction(state.layoutCustomisations.showPanel)) {
1737
+ return state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel;
1738
+ }
1739
+ return showPanel;
1740
+ },
1567
1741
  getNavSizeWithCustomisations(navSize) {
1568
1742
  const state = store2.getState();
1569
1743
  if (isFunction(state.layoutCustomisations.showSidebar)) {
@@ -1655,15 +1829,68 @@ var init6 = /* @__PURE__ */ __name(({ store: store2 }) => {
1655
1829
  }, "clearNotification")
1656
1830
  };
1657
1831
  const state = { notifications: [] };
1658
- return { api, state };
1832
+ return {
1833
+ api,
1834
+ state
1835
+ };
1836
+ }, "init");
1837
+
1838
+ // src/manager-api/modules/open-in-editor.tsx
1839
+ var open_in_editor_exports = {};
1840
+ __export(open_in_editor_exports, {
1841
+ init: () => init7
1842
+ });
1843
+ import React from "react";
1844
+ import {
1845
+ OPEN_IN_EDITOR_REQUEST,
1846
+ OPEN_IN_EDITOR_RESPONSE
1847
+ } from "storybook/internal/core-events";
1848
+ import { FailedIcon } from "@storybook/icons";
1849
+ import { color } from "storybook/theming";
1850
+ var init7 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1851
+ const api = {
1852
+ openInEditor(payload) {
1853
+ return new Promise((resolve) => {
1854
+ const { file, line, column } = payload;
1855
+ const handler = /* @__PURE__ */ __name((res) => {
1856
+ if (res.file === file && res.line === line && res.column === column) {
1857
+ provider.channel?.off(OPEN_IN_EDITOR_RESPONSE, handler);
1858
+ resolve(res);
1859
+ }
1860
+ }, "handler");
1861
+ provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler);
1862
+ provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
1863
+ });
1864
+ }
1865
+ };
1866
+ const state = { notifications: [] };
1867
+ return {
1868
+ api,
1869
+ state,
1870
+ init: /* @__PURE__ */ __name(async () => {
1871
+ provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, (payload) => {
1872
+ if (payload.error !== null) {
1873
+ fullAPI.addNotification({
1874
+ id: "open-in-editor-error",
1875
+ content: {
1876
+ headline: "Failed to open in editor",
1877
+ subHeadline: payload.error || "Check the Storybook process on the command line for more details."
1878
+ },
1879
+ icon: React.createElement(FailedIcon, { color: color.negative }),
1880
+ duration: 8e3
1881
+ });
1882
+ }
1883
+ });
1884
+ }, "init")
1885
+ };
1659
1886
  }, "init");
1660
1887
 
1661
1888
  // src/manager-api/modules/provider.ts
1662
1889
  var provider_exports = {};
1663
1890
  __export(provider_exports, {
1664
- init: () => init7
1891
+ init: () => init8
1665
1892
  });
1666
- var init7 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1893
+ var init8 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1667
1894
  return {
1668
1895
  api: provider.renderPreview ? { renderPreview: provider.renderPreview } : {},
1669
1896
  state: {},
@@ -1676,9 +1903,9 @@ var init7 = /* @__PURE__ */ __name(({ provider, fullAPI }) => {
1676
1903
  // src/manager-api/modules/settings.ts
1677
1904
  var settings_exports = {};
1678
1905
  __export(settings_exports, {
1679
- init: () => init8
1906
+ init: () => init9
1680
1907
  });
1681
- var init8 = /* @__PURE__ */ __name(({ store: store2, navigate, fullAPI }) => {
1908
+ var init9 = /* @__PURE__ */ __name(({ store: store2, navigate, fullAPI }) => {
1682
1909
  const isSettingsScreenActive = /* @__PURE__ */ __name(() => {
1683
1910
  const { path } = fullAPI.getUrlState();
1684
1911
  return !!(path || "").match(/^\/settings/);
@@ -1720,10 +1947,11 @@ var shortcuts_exports = {};
1720
1947
  __export(shortcuts_exports, {
1721
1948
  controlOrMetaKey: () => controlOrMetaKey2,
1722
1949
  defaultShortcuts: () => defaultShortcuts,
1723
- init: () => init9,
1950
+ init: () => init10,
1724
1951
  isMacLike: () => isMacLike2,
1725
1952
  keys: () => keys
1726
1953
  });
1954
+ var import_copy_to_clipboard = __toESM(require_copy_to_clipboard(), 1);
1727
1955
  import {
1728
1956
  FORCE_REMOUNT,
1729
1957
  PREVIEW_KEYDOWN,
@@ -1734,8 +1962,8 @@ import { global as global5 } from "@storybook/global";
1734
1962
 
1735
1963
  // src/manager-api/lib/shortcut.ts
1736
1964
  import { global as global4 } from "@storybook/global";
1737
- var { navigator } = global4;
1738
- var isMacLike = /* @__PURE__ */ __name(() => navigator && navigator.platform ? !!navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
1965
+ var { navigator: navigator2 } = global4;
1966
+ var isMacLike = /* @__PURE__ */ __name(() => navigator2 && navigator2.platform ? !!navigator2.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
1739
1967
  var controlOrMetaSymbol = /* @__PURE__ */ __name(() => isMacLike() ? "\u2318" : "ctrl", "controlOrMetaSymbol");
1740
1968
  var controlOrMetaKey = /* @__PURE__ */ __name(() => isMacLike() ? "meta" : "control", "controlOrMetaKey");
1741
1969
  var optionOrAltSymbol = /* @__PURE__ */ __name(() => isMacLike() ? "\u2325" : "alt", "optionOrAltSymbol");
@@ -1757,14 +1985,31 @@ var eventToShortcut = /* @__PURE__ */ __name((e) => {
1757
1985
  if (e.shiftKey) {
1758
1986
  keys2.push("shift");
1759
1987
  }
1988
+ const codeUpper = e.code?.toUpperCase();
1989
+ const codeToCharMap = {
1990
+ MINUS: "-",
1991
+ EQUAL: "=",
1992
+ BRACKETLEFT: "[",
1993
+ BRACKETRIGHT: "]",
1994
+ BACKSLASH: "\\",
1995
+ SEMICOLON: ";",
1996
+ QUOTE: "'",
1997
+ BACKQUOTE: "`",
1998
+ COMMA: ",",
1999
+ PERIOD: ".",
2000
+ SLASH: "/"
2001
+ };
2002
+ const codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : codeToCharMap[codeUpper] : void 0;
1760
2003
  if (e.key && e.key.length === 1 && e.key !== " ") {
1761
2004
  const key = e.key.toUpperCase();
1762
- const code = e.code?.toUpperCase().replace("KEY", "").replace("DIGIT", "");
2005
+ const code = codeChar;
1763
2006
  if (code && code.length === 1 && code !== key) {
1764
2007
  keys2.push([key, code]);
1765
2008
  } else {
1766
2009
  keys2.push(key);
1767
2010
  }
2011
+ } else if (e.key === "Dead" && codeChar) {
2012
+ keys2.push(codeChar);
1768
2013
  }
1769
2014
  if (e.key === " ") {
1770
2015
  keys2.push("space");
@@ -1837,15 +2082,15 @@ var keyToSymbol = /* @__PURE__ */ __name((key) => {
1837
2082
  if (key === "ArrowRight") {
1838
2083
  return "\u2192";
1839
2084
  }
1840
- return key.toUpperCase();
2085
+ return key?.toUpperCase();
1841
2086
  }, "keyToSymbol");
1842
2087
  var shortcutToHumanString = /* @__PURE__ */ __name((shortcut) => {
1843
2088
  return shortcut.map(keyToSymbol).join(" ");
1844
2089
  }, "shortcutToHumanString");
1845
2090
 
1846
2091
  // src/manager-api/modules/shortcuts.ts
1847
- var { navigator: navigator2, document: document2 } = global5;
1848
- var isMacLike2 = /* @__PURE__ */ __name(() => navigator2 && navigator2.platform ? !!navigator2.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
2092
+ var { navigator: navigator3, document: document3 } = global5;
2093
+ var isMacLike2 = /* @__PURE__ */ __name(() => navigator3 && navigator3.platform ? !!navigator3.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false, "isMacLike");
1849
2094
  var controlOrMetaKey2 = /* @__PURE__ */ __name(() => isMacLike2() ? "meta" : "control", "controlOrMetaKey");
1850
2095
  function keys(o) {
1851
2096
  return Object.keys(o);
@@ -1871,7 +2116,11 @@ var defaultShortcuts = Object.freeze({
1871
2116
  // This one is not customizable
1872
2117
  collapseAll: [controlOrMetaKey2(), "shift", "ArrowUp"],
1873
2118
  expandAll: [controlOrMetaKey2(), "shift", "ArrowDown"],
1874
- remount: ["alt", "R"]
2119
+ remount: ["alt", "R"],
2120
+ openInEditor: ["alt", "shift", "E"],
2121
+ copyStoryLink: ["alt", "shift", "L"]
2122
+ // TODO: bring this back once we want to add shortcuts for this
2123
+ // copyStoryName: ['alt', 'shift', 'C'],
1875
2124
  });
1876
2125
  var addonsShortcuts = {};
1877
2126
  function shouldSkipShortcut(event) {
@@ -1886,7 +2135,7 @@ function shouldSkipShortcut(event) {
1886
2135
  return false;
1887
2136
  }
1888
2137
  __name(shouldSkipShortcut, "shouldSkipShortcut");
1889
- var init9 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2138
+ var init10 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
1890
2139
  const api = {
1891
2140
  // Getting and setting shortcuts
1892
2141
  getShortcutKeys() {
@@ -1996,7 +2245,7 @@ var init9 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
1996
2245
  break;
1997
2246
  }
1998
2247
  case "focusIframe": {
1999
- const element = document2.getElementById("storybook-preview-iframe");
2248
+ const element = document3.getElementById("storybook-preview-iframe");
2000
2249
  if (element) {
2001
2250
  try {
2002
2251
  element.contentWindow.focus();
@@ -2077,6 +2326,26 @@ var init9 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2077
2326
  fullAPI.emit(FORCE_REMOUNT, { storyId });
2078
2327
  break;
2079
2328
  }
2329
+ case "openInEditor": {
2330
+ if (global5.CONFIG_TYPE === "DEVELOPMENT") {
2331
+ fullAPI.openInEditor({
2332
+ file: fullAPI.getCurrentStoryData().importPath
2333
+ });
2334
+ }
2335
+ break;
2336
+ }
2337
+ // TODO: bring this back once we want to add shortcuts for this
2338
+ // case 'copyStoryName': {
2339
+ // const storyData = fullAPI.getCurrentStoryData();
2340
+ // if (storyData.type === 'story') {
2341
+ // copy(storyData.exportName);
2342
+ // }
2343
+ // break;
2344
+ // }
2345
+ case "copyStoryLink": {
2346
+ (0, import_copy_to_clipboard.default)(window.location.href);
2347
+ break;
2348
+ }
2080
2349
  default:
2081
2350
  addonsShortcuts[feature].action();
2082
2351
  break;
@@ -2092,7 +2361,7 @@ var init9 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2092
2361
  )
2093
2362
  };
2094
2363
  const initModule = /* @__PURE__ */ __name(() => {
2095
- document2.addEventListener("keydown", (event) => {
2364
+ document3.addEventListener("keydown", (event) => {
2096
2365
  if (!shouldSkipShortcut(event)) {
2097
2366
  api.handleKeydownEvent(event);
2098
2367
  }
@@ -2107,7 +2376,7 @@ var init9 = /* @__PURE__ */ __name(({ store: store2, fullAPI, provider }) => {
2107
2376
  // src/manager-api/modules/stories.ts
2108
2377
  var stories_exports = {};
2109
2378
  __export(stories_exports, {
2110
- init: () => init10
2379
+ init: () => init11
2111
2380
  });
2112
2381
  import { logger as logger5 } from "storybook/internal/client-logger";
2113
2382
  import {
@@ -2275,12 +2544,12 @@ function createStatusStore({
2275
2544
  __name(createStatusStore, "createStatusStore");
2276
2545
 
2277
2546
  // src/shared/universal-store/use-universal-store-manager.ts
2278
- import * as React from "react";
2547
+ import * as React2 from "react";
2279
2548
  var useUniversalStore = /* @__PURE__ */ __name((universalStore, selector) => {
2280
- const snapshotRef = React.useRef(
2549
+ const snapshotRef = React2.useRef(
2281
2550
  selector ? selector(universalStore.getState()) : universalStore.getState()
2282
2551
  );
2283
- const subscribe = React.useCallback(
2552
+ const subscribe = React2.useCallback(
2284
2553
  (listener) => universalStore.onStateChange((state2, previousState) => {
2285
2554
  if (!selector) {
2286
2555
  snapshotRef.current = state2;
@@ -2297,7 +2566,7 @@ var useUniversalStore = /* @__PURE__ */ __name((universalStore, selector) => {
2297
2566
  }),
2298
2567
  [universalStore, selector]
2299
2568
  );
2300
- const getSnapshot = React.useCallback(() => {
2569
+ const getSnapshot = React2.useCallback(() => {
2301
2570
  const currentState = universalStore.getState();
2302
2571
  const selectedState = selector ? selector(currentState) : currentState;
2303
2572
  if (isEqual(selectedState, snapshotRef.current)) {
@@ -2306,7 +2575,7 @@ var useUniversalStore = /* @__PURE__ */ __name((universalStore, selector) => {
2306
2575
  snapshotRef.current = selectedState;
2307
2576
  return snapshotRef.current;
2308
2577
  }, [universalStore, selector]);
2309
- const state = React.useSyncExternalStore(subscribe, getSnapshot);
2578
+ const state = React2.useSyncExternalStore(subscribe, getSnapshot);
2310
2579
  return [state, universalStore.setState];
2311
2580
  }, "useUniversalStore");
2312
2581
 
@@ -2338,7 +2607,7 @@ function removeRemovedOptions(options) {
2338
2607
  return result;
2339
2608
  }
2340
2609
  __name(removeRemovedOptions, "removeRemovedOptions");
2341
- var init10 = /* @__PURE__ */ __name(({
2610
+ var init11 = /* @__PURE__ */ __name(({
2342
2611
  fullAPI,
2343
2612
  store: store2,
2344
2613
  navigate,
@@ -2495,8 +2764,9 @@ var init10 = /* @__PURE__ */ __name(({
2495
2764
  }
2496
2765
  if (node.type === "story") {
2497
2766
  results.push(node.id);
2498
- } else if ("children" in node) {
2499
- node.children.forEach((childId) => findChildEntriesRecursively(childId, results));
2767
+ }
2768
+ if ("children" in node) {
2769
+ node.children?.forEach((childId) => findChildEntriesRecursively(childId, results));
2500
2770
  }
2501
2771
  return results;
2502
2772
  }, "findChildEntriesRecursively");
@@ -2839,7 +3109,7 @@ var init10 = /* @__PURE__ */ __name(({
2839
3109
  // src/manager-api/modules/url.ts
2840
3110
  var url_exports = {};
2841
3111
  __export(url_exports, {
2842
- init: () => init11
3112
+ init: () => init12
2843
3113
  });
2844
3114
  import {
2845
3115
  GLOBALS_UPDATED as GLOBALS_UPDATED2,
@@ -2916,7 +3186,7 @@ var initialUrlSupport = /* @__PURE__ */ __name(({
2916
3186
  prevParams = customQueryParams;
2917
3187
  return { viewMode, layout, ui, selectedPanel, location: location2, path, customQueryParams, storyId };
2918
3188
  }, "initialUrlSupport");
2919
- var init11 = /* @__PURE__ */ __name((moduleArgs) => {
3189
+ var init12 = /* @__PURE__ */ __name((moduleArgs) => {
2920
3190
  const { store: store2, navigate, provider, fullAPI } = moduleArgs;
2921
3191
  const navigateTo = /* @__PURE__ */ __name((path, queryParams = {}, options = {}) => {
2922
3192
  const params = Object.entries(queryParams).filter(([, v]) => v).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`);
@@ -3012,14 +3282,14 @@ var init11 = /* @__PURE__ */ __name((moduleArgs) => {
3012
3282
  // src/manager-api/modules/versions.ts
3013
3283
  var versions_exports = {};
3014
3284
  __export(versions_exports, {
3015
- init: () => init12
3285
+ init: () => init13
3016
3286
  });
3017
3287
  var import_memoizerific2 = __toESM(require_memoizerific(), 1);
3018
3288
  import { global as global8 } from "@storybook/global";
3019
3289
  import semver from "semver";
3020
3290
 
3021
3291
  // src/manager-api/version.ts
3022
- var version = "10.0.0-beta.5";
3292
+ var version = "10.0.0-beta.7";
3023
3293
 
3024
3294
  // src/manager-api/modules/versions.ts
3025
3295
  var { VERSIONCHECK } = global8;
@@ -3036,7 +3306,7 @@ var normalizeRendererName = /* @__PURE__ */ __name((renderer) => {
3036
3306
  }
3037
3307
  return renderer;
3038
3308
  }, "normalizeRendererName");
3039
- var init12 = /* @__PURE__ */ __name(({ store: store2 }) => {
3309
+ var init13 = /* @__PURE__ */ __name(({ store: store2 }) => {
3040
3310
  const { dismissedVersionNotification } = store2.getState();
3041
3311
  const state = {
3042
3312
  versions: {
@@ -3125,9 +3395,9 @@ var init12 = /* @__PURE__ */ __name(({ store: store2 }) => {
3125
3395
  // src/manager-api/modules/whatsnew.tsx
3126
3396
  var whatsnew_exports = {};
3127
3397
  __export(whatsnew_exports, {
3128
- init: () => init13
3398
+ init: () => init14
3129
3399
  });
3130
- import React2 from "react";
3400
+ import React3 from "react";
3131
3401
  import {
3132
3402
  REQUEST_WHATS_NEW_DATA,
3133
3403
  RESULT_WHATS_NEW_DATA,
@@ -3136,8 +3406,8 @@ import {
3136
3406
  } from "storybook/internal/core-events";
3137
3407
  import { global as global9 } from "@storybook/global";
3138
3408
  var WHATS_NEW_NOTIFICATION_ID = "whats-new";
3139
- var StorybookIcon = /* @__PURE__ */ __name(({ color = "currentColor", size = 14 }) => {
3140
- return React2.createElement(
3409
+ var StorybookIcon = /* @__PURE__ */ __name(({ color: color2 = "currentColor", size = 14 }) => {
3410
+ return React3.createElement(
3141
3411
  "svg",
3142
3412
  {
3143
3413
  width: size,
@@ -3146,18 +3416,18 @@ var StorybookIcon = /* @__PURE__ */ __name(({ color = "currentColor", size = 14
3146
3416
  fill: "none",
3147
3417
  xmlns: "http://www.w3.org/2000/svg"
3148
3418
  },
3149
- React2.createElement(
3419
+ React3.createElement(
3150
3420
  "path",
3151
3421
  {
3152
3422
  fillRule: "evenodd",
3153
3423
  clipRule: "evenodd",
3154
3424
  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",
3155
- fill: color
3425
+ fill: color2
3156
3426
  }
3157
3427
  )
3158
3428
  );
3159
3429
  }, "StorybookIcon");
3160
- var init13 = /* @__PURE__ */ __name(({ fullAPI, store: store2, provider }) => {
3430
+ var init14 = /* @__PURE__ */ __name(({ fullAPI, store: store2, provider }) => {
3161
3431
  const state = {
3162
3432
  whatsNewData: void 0
3163
3433
  };
@@ -3219,7 +3489,7 @@ var init13 = /* @__PURE__ */ __name(({ fullAPI, store: store2, provider }) => {
3219
3489
  headline: whatsNewData.title,
3220
3490
  subHeadline: "Learn what's new in Storybook"
3221
3491
  },
3222
- icon: React2.createElement(StorybookIcon, null),
3492
+ icon: React3.createElement(StorybookIcon, null),
3223
3493
  onClear({ dismissed }) {
3224
3494
  if (dismissed) {
3225
3495
  setWhatsNewCache({ lastDismissedPost: whatsNewData.url });
@@ -3412,7 +3682,8 @@ var _ManagerProvider = class _ManagerProvider extends Component {
3412
3682
  globals_exports,
3413
3683
  url_exports,
3414
3684
  versions_exports,
3415
- whatsnew_exports
3685
+ whatsnew_exports,
3686
+ open_in_editor_exports
3416
3687
  ].map(
3417
3688
  (m) => m.init({ ...routeData, ...optionsData, ...apiData, state: this.state, fullAPI: this.api })
3418
3689
  );
@@ -3445,14 +3716,14 @@ var _ManagerProvider = class _ManagerProvider extends Component {
3445
3716
  state: this.state,
3446
3717
  api: this.api
3447
3718
  };
3448
- return React3.createElement(EffectOnMount, { effect: this.initModules }, React3.createElement(ManagerContext.Provider, { value }, React3.createElement(ManagerConsumer, null, children)));
3719
+ return React4.createElement(EffectOnMount, { effect: this.initModules }, React4.createElement(ManagerContext.Provider, { value }, React4.createElement(ManagerConsumer, null, children)));
3449
3720
  }
3450
3721
  };
3451
3722
  __name(_ManagerProvider, "ManagerProvider");
3452
3723
  _ManagerProvider.displayName = "Manager";
3453
3724
  var ManagerProvider = _ManagerProvider;
3454
3725
  var EffectOnMount = /* @__PURE__ */ __name(({ children, effect }) => {
3455
- React3.useEffect(effect, []);
3726
+ React4.useEffect(effect, []);
3456
3727
  return children;
3457
3728
  }, "EffectOnMount");
3458
3729
  var defaultFilter = /* @__PURE__ */ __name((c) => c, "defaultFilter");
@@ -3465,7 +3736,7 @@ function ManagerConsumer({
3465
3736
  const renderer = useRef2(children);
3466
3737
  const filterer = useRef2(filter);
3467
3738
  if (typeof renderer.current !== "function") {
3468
- return React3.createElement(Fragment, null, renderer.current);
3739
+ return React4.createElement(Fragment, null, renderer.current);
3469
3740
  }
3470
3741
  const comboData = filterer.current(managerContext);
3471
3742
  const comboDataArray = useMemo(() => {
@@ -3473,7 +3744,7 @@ function ManagerConsumer({
3473
3744
  }, [managerContext.state]);
3474
3745
  return useMemo(() => {
3475
3746
  const Child = renderer.current;
3476
- return React3.createElement(Child, { ...comboData });
3747
+ return React4.createElement(Child, { ...comboData });
3477
3748
  }, comboDataArray);
3478
3749
  }
3479
3750
  __name(ManagerConsumer, "ManagerConsumer");