@fluentui/react-storybook-addon-export-to-sandbox 0.1.3 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Change Log - @fluentui/react-storybook-addon-export-to-sandbox
2
2
 
3
- This log was last generated on Tue, 04 Nov 2025 14:46:32 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 03 Mar 2026 13:15:59 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-storybook-addon-export-to-sandbox_v0.2.0)
8
+
9
+ Tue, 03 Mar 2026 13:15:59 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.3..@fluentui/react-storybook-addon-export-to-sandbox_v0.2.0)
11
+
12
+ ### Minor changes
13
+
14
+ - add withExportToSandboxButton decorator export and fix default story missing export button ([PR #35677](https://github.com/microsoft/fluentui/pull/35677) by dmytrokirpa@microsoft.com)
15
+ - feat: upgrade to storybook 9 ([PR #35459](https://github.com/microsoft/fluentui/pull/35459) by dmytrokirpa@microsoft.com)
16
+ - BREAKING: upgrade storybook to v8 ([PR #35279](https://github.com/microsoft/fluentui/pull/35279) by dmytrokirpa@microsoft.com)
17
+
18
+ ### Patches
19
+
20
+ - chore: bump storybook to mitigate CVE ([PR #35748](https://github.com/microsoft/fluentui/pull/35748) by martinhochel@microsoft.com)
21
+
7
22
  ## [0.1.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.3)
8
23
 
9
- Tue, 04 Nov 2025 14:46:32 GMT
24
+ Tue, 04 Nov 2025 14:47:01 GMT
10
25
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.2..@fluentui/react-storybook-addon-export-to-sandbox_v0.1.3)
11
26
 
12
27
  ### Patches
package/dist/index.d.ts CHANGED
@@ -1 +1,35 @@
1
+ import type { JSXElement } from '@fluentui/react-utilities';
2
+ import type { Parameters as Parameters_2 } from '@storybook/react-webpack5';
3
+ import type { StoryContext as StoryContext_2 } from '@storybook/react-webpack5';
4
+
5
+ /**
6
+ * NOTE:
7
+ * Don't import anything from source code in this file !!
8
+ *
9
+ * only pure API definitions of addon are allowed to live here, that are used both internal and for external storybook `Parameter` type extensions
10
+ */
11
+ declare interface ParametersConfig {
12
+ optionalDependencies?: Record<string, string>;
13
+ requiredDependencies?: Record<string, string>;
14
+ provider: 'codesandbox-cloud' | 'codesandbox-browser' | 'stackblitz-cloud';
15
+ bundler: 'vite' | 'cra';
16
+ }
17
+
18
+ declare interface ParametersExtension {
19
+ exportToSandbox?: ParametersConfig;
20
+ }
21
+
22
+ declare interface StoryContext extends StoryContext_2 {
23
+ parameters: Parameters_2 & ParametersExtension;
24
+ }
25
+
26
+ /**
27
+ * Decorator to add "Export to Sandbox" button in Storybook Docs view
28
+ *
29
+ * @param storyFn - original story function
30
+ * @param context - story context
31
+ * @returns - decorated story
32
+ */
33
+ export declare const withExportToSandboxButton: (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => JSXElement;
34
+
1
35
  export { }
@@ -1,5 +1,11 @@
1
1
  import { addDemoActionButton } from '../sandbox-factory';
2
- export const withExportToSandboxButton = (storyFn, context)=>{
2
+ /**
3
+ * Decorator to add "Export to Sandbox" button in Storybook Docs view
4
+ *
5
+ * @param storyFn - original story function
6
+ * @param context - story context
7
+ * @returns - decorated story
8
+ */ export const withExportToSandboxButton = (storyFn, context)=>{
3
9
  if (context.viewMode === 'docs') {
4
10
  addDemoActionButton(context);
5
11
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["addDemoActionButton","withExportToSandboxButton","storyFn","context","viewMode"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,qBAAqB;AAGzD,OAAO,MAAMC,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BJ,oBAAoBG;IACtB;IAEA,OAAOD,QAAQC;AACjB,EAAE"}
1
+ {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\n/**\n * Decorator to add \"Export to Sandbox\" button in Storybook Docs view\n *\n * @param storyFn - original story function\n * @param context - story context\n * @returns - decorated story\n */\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["addDemoActionButton","withExportToSandboxButton","storyFn","context","viewMode"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,qBAAqB;AAGzD;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BJ,oBAAoBG;IACtB;IAEA,OAAOD,QAAQC;AACjB,EAAE"}
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export { withExportToSandboxButton } from './decorators/with-export-to-sandbox-button';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {};\n"],"names":[],"mappings":"AAAA,WAAU"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { withExportToSandboxButton } from './decorators/with-export-to-sandbox-button';\n"],"names":["withExportToSandboxButton"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,6CAA6C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["withExportToSandboxButton","decorators","parameters","docs","source","transform","storyContext","fullSource"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,8CAA8C;AAExF,OAAO,MAAMC,aAAa;IAACD;CAA0B,CAAC;AAEtD,OAAO,MAAME,aAAyB;IACpCC,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaJ,UAAU,CAACK,UAAU;YAC3C;QACF;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react-webpack5';\nimport type { StoryContextForEnhancers } from 'storybook/internal/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["withExportToSandboxButton","decorators","parameters","docs","source","transform","storyContext","fullSource"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,8CAA8C;AAExF,OAAO,MAAMC,aAAa;IAACD;CAA0B,CAAC;AAEtD,OAAO,MAAME,aAAyB;IACpCC,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaJ,UAAU,CAACK,UAAU;YAC3C;QACF;IACF;AACF,EAAE"}
@@ -1,6 +1,6 @@
1
1
  import { getParameters } from 'codesandbox-import-utils/lib/api/define';
2
2
  import { scaffold } from './sandbox-scaffold';
3
- import { addHiddenInput, prepareData, prepareSandboxContainer } from './sandbox-utils';
3
+ import { addHiddenInput, prepareData, prepareSandboxContainers } from './sandbox-utils';
4
4
  const defaultFileToPreview = encodeURIComponent('src/example.tsx');
5
5
  const actionConfig = {
6
6
  'codesandbox-cloud': {
@@ -26,12 +26,13 @@ const actionConfig = {
26
26
  }
27
27
  };
28
28
  export function addDemoActionButton(context) {
29
- const { container, cssClasses } = prepareSandboxContainer(context);
30
29
  const config = prepareData(context);
31
30
  if (!config) {
32
31
  throw new Error('issues with data');
33
32
  }
34
- addActionButton(container, config, cssClasses);
33
+ prepareSandboxContainers(context).forEach(({ container, cssClasses })=>{
34
+ addActionButton(container, config, cssClasses);
35
+ });
35
36
  }
36
37
  function addActionButton(container, config, classList) {
37
38
  const files = scaffold[config.bundler](config);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["getParameters","scaffold","addHiddenInput","prepareData","prepareSandboxContainer","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","addDemoActionButton","context","container","cssClasses","Error","addActionButton","classList","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters"],"mappings":"AAAA,SAASA,aAAa,QAAQ,0CAA0C;AAExE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,cAAc,EAAEC,WAAW,EAAEC,uBAAuB,QAAmB,kBAAkB;AAGlG,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,oBAAoB;QAClBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBE,eAAe;gBAAEH;gBAAO,GAAGC,MAAM;YAAC;IAC9F;AACF;AAEA,OAAO,SAASG,oBAAoBC,OAAqB;IACvD,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGb,wBAAwBW;IAC1D,MAAMJ,SAASR,YAAYY;IAC3B,IAAI,CAACJ,QAAQ;QACX,MAAM,IAAIO,MAAM;IA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AAMwB,qBAAqBT,OAAOU,OAAO,CAACtC,OAAOuC,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAM/B,aAAa,sBAAsB,WAAW;IAC1D,MAAMgC,aAAavD,cAAc;QAAEU,OAAOqC;IAAmB;IAE7D,MAAMZ,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEgC,KAAK;IAEjFpD,eAAeiC,MAAM,cAAcoB;IACnCrD,eAAeiC,MAAM,SAAS,CAAC,KAAK,EAAE9B,sBAAsB;IAC5DoB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B"}
1
+ {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainers, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n prepareSandboxContainers(context).forEach(({ container, cssClasses }) => {\n addActionButton(container, config, cssClasses);\n });\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["getParameters","scaffold","addHiddenInput","prepareData","prepareSandboxContainers","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","addDemoActionButton","context","Error","forEach","container","cssClasses","addActionButton","classList","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","Object","keys","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters"],"mappings":"AAAA,SAASA,aAAa,QAAQ,0CAA0C;AAExE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,cAAc,EAAEC,WAAW,EAAEC,wBAAwB,QAAmB,kBAAkB;AAGnG,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,oBAAoB;QAClBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBE,eAAe;gBAAEH;gBAAO,GAAGC,MAAM;YAAC;IAC9F;AACF;AAEA,OAAO,SAASG,oBAAoBC,OAAqB;IACvD,MAAMJ,SAASR,YAAYY;IAC3B,IAAI,CAACJ,QAAQ;QACX,MAAM,IAAIK,MAAM;IAClB;IAEAZ,yBAAyBW,SAASE,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,UAAU,EAAE;QAClEC,gBAAgBF,WAAWP,QAAQQ;IACrC;AACF;AAEA,SAASC,gBAAgBF,SAAsB,EAAEP,MAAY,EAAEU,SAAmB;IAChF,MAAMX,QAAQT,QAAQ,CAACU,OAAOW,OAAO,CAAC,CAACX;IACvC,MAAMY,SAAShB,YAAY,CAACI,OAAOa,QAAQ,CAAC;IAE5C,MAAMC,SAASC,SAASC,aAAa,CAAC;IACtCF,OAAOJ,SAAS,CAACO,GAAG,IAAIP;IACxBI,OAAOI,WAAW,GAAG,CAAC,QAAQ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,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAE+B,KAAK;IAEjFpD,eAAekC,MAAM,cAAcmB;IACnCrD,eAAekC,MAAM,SAAS,CAAC,KAAK,EAAE/B,sBAAsB;IAC5DqB,SAASiB,IAAI,CAACC,WAAW,CAACR;IAC1BA,KAAKS,MAAM;IACXnB,SAASiB,IAAI,CAACG,WAAW,CAACV;AAC5B"}
@@ -7,25 +7,27 @@ export function addHiddenInput(form, name, value) {
7
7
  input.value = value;
8
8
  form.appendChild(input);
9
9
  }
10
- export function prepareSandboxContainer(context) {
10
+ export function prepareSandboxContainers(context) {
11
11
  const docsSelector = `#anchor--${context.id} .docs-story`;
12
- const rootElement = document.querySelector(docsSelector);
13
- if (!rootElement) {
12
+ const rootElements = document.querySelectorAll(docsSelector);
13
+ if (!rootElements.length) {
14
14
  throw new Error(`css selector: ${docsSelector}, doesn't exist `);
15
15
  }
16
- const showCodeButton = rootElement.querySelector('.docblock-code-toggle');
17
- const container = showCodeButton === null || showCodeButton === void 0 ? void 0 : showCodeButton.parentElement;
18
- if (!container) {
19
- throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);
20
- }
21
- const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');
22
- // remove button if it already existed
23
- const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
24
- ourButtons.forEach((node)=>node.remove());
25
- return {
26
- container,
27
- cssClasses: classList
28
- };
16
+ return Array.from(rootElements).map((rootElement)=>{
17
+ const showCodeButton = rootElement.querySelector('.docblock-code-toggle');
18
+ const container = showCodeButton === null || showCodeButton === void 0 ? void 0 : showCodeButton.parentElement;
19
+ if (!container) {
20
+ throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);
21
+ }
22
+ const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');
23
+ // remove button if it already existed
24
+ const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
25
+ ourButtons.forEach((node)=>node.remove());
26
+ return {
27
+ container,
28
+ cssClasses: classList
29
+ };
30
+ });
29
31
  }
30
32
  const addonConfigDefaults = {
31
33
  requiredDependencies: {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["dedent","getDependencies","addHiddenInput","form","name","value","input","document","createElement","type","appendChild","prepareSandboxContainer","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","prepareData","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","title","dependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,SAASC,eAAe,QAAQ,oBAAoB;AAKpD,OAAO,SAASC,eAAeC,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,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QAAQ8B,KAAK,CAAC,mCAAmC,CAAC;QAErH,OAAO;IACT;IAEA,MAAM,EAAEZ,oBAAoB,EAAEC,oBAAoB,EAAE,GAAGI;IACvD,MAAMQ,eAAe1C,gBAAgBqC,WAAWR,sBAAsBC;IAEtE,MAAMW,QAAQ;IACd,MAAME,cAAc,CAAC,YAAY,EAAEhC,QAAQ8B,KAAK,CAAC,GAAG,EAAE9B,QAAQR,IAAI,EAAE;IAEpE,2EAA2E;IAC3E,kEAAkE;IAClE,mEAAmE;IACnE,oFAAoF;IACpF,yBAAyB;IACzB,qFAAqF;IACrF,MAAMyC,mBAAmBjC,QAAQkC,eAAe,CAAC1C,IAAI,CAACkB,KAAK,CAAC,aAAayB,KAAK,CAAC,CAAC,GAAGC,GAAG;IACtF,IAAI,CAACH,kBAAkB;QACrB,MAAM,IAAI5B,MAAM;IAClB;IAEA,MAAMgC,WAAW;QACfX;QACAO;QACAT;QACAC;QACAM;QACAD;QACAE;IACF;IAEA,OAAOK;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainers(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElements = document.querySelectorAll(docsSelector);\n\n if (!rootElements.length) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n return Array.from(rootElements).map(rootElement => {\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n });\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["dedent","getDependencies","addHiddenInput","form","name","value","input","document","createElement","type","appendChild","prepareSandboxContainers","context","docsSelector","id","rootElements","querySelectorAll","length","Error","Array","from","map","rootElement","showCodeButton","querySelector","container","parentElement","classList","split","ourButtons","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","prepareData","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","title","dependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,SAASC,eAAe,QAAQ,oBAAoB;AAKpD,OAAO,SAASC,eAAeC,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW,CAACJ;AACnB;AAEA,OAAO,SAASK,yBAAyBC,OAAqB;IAC5D,MAAMC,eAAe,CAAC,SAAS,EAAED,QAAQE,EAAE,CAAC,YAAY,CAAC;IACzD,MAAMC,eAAeR,SAASS,gBAAgB,CAACH;IAE/C,IAAI,CAACE,aAAaE,MAAM,EAAE;QACxB,MAAM,IAAIC,MAAM,CAAC,cAAc,EAAEL,aAAa,gBAAgB,CAAC;IACjE;IAEA,OAAOM,MAAMC,IAAI,CAACL,cAAcM,GAAG,CAACC,CAAAA;QAClC,MAAMC,iBAAiBD,YAAYE,aAAa,CAAC;QACjD,MAAMC,YAAYF,2BAAAA,qCAAAA,eAAgBG,aAAa;QAE/C,IAAI,CAACD,WAAW;YACd,MAAM,IAAIP,MAAM,CAAC,qDAAqD,CAAC;QACzE;QAEA,MAAMS,YAAY,AAACJ,CAAAA,eAAeI,SAAS,CAACtB,KAAK,GAAG,2BAA0B,EAAGuB,KAAK,CAAC;QAEvF,sCAAsC;QACtC,MAAMC,aAAaJ,UAAUT,gBAAgB,CAAC,CAAC,yBAAyB,CAAC;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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { StoryContext as StoryContextOrigin, Parameters } from '@storybook/react';\nimport type { ParametersExtension, PresetConfig } from './public-types';\n\nexport interface StoryContext extends StoryContextOrigin {\n parameters: Parameters & ParametersExtension;\n}\n\nexport type { ParametersExtension, PresetConfig };\n"],"names":[],"mappings":"AAOA,WAAkD"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { StoryContext as StoryContextOrigin, Parameters } from '@storybook/react-webpack5';\nimport type { ParametersExtension, PresetConfig } from './public-types';\n\nexport interface StoryContext extends StoryContextOrigin {\n parameters: Parameters & ParametersExtension;\n}\n\nexport type { ParametersExtension, PresetConfig };\n"],"names":[],"mappings":"AAOA,WAAkD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["withExportToSandboxButton","storyFn","context","viewMode","addDemoActionButton"],"mappings":";;;;+BAKaA;;;eAAAA;;;gCAHuB;AAG7B,MAAMA,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BC,IAAAA,mCAAmB,EAACF;IACtB;IAEA,OAAOD,QAAQC;AACjB"}
1
+ {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\n/**\n * Decorator to add \"Export to Sandbox\" button in Storybook Docs view\n *\n * @param storyFn - original story function\n * @param context - story context\n * @returns - decorated story\n */\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["withExportToSandboxButton","storyFn","context","viewMode","addDemoActionButton"],"mappings":";;;;+BAYaA;;;eAAAA;;;gCAVuB;AAU7B,MAAMA,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BC,IAAAA,mCAAmB,EAACF;IACtB;IAEA,OAAOD,QAAQC;AACjB"}
@@ -2,3 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ Object.defineProperty(exports, "withExportToSandboxButton", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _withexporttosandboxbutton.withExportToSandboxButton;
9
+ }
10
+ });
11
+ const _withexporttosandboxbutton = require("./decorators/with-export-to-sandbox-button");
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { withExportToSandboxButton } from './decorators/with-export-to-sandbox-button';\n"],"names":["withExportToSandboxButton"],"mappings":";;;;+BAASA;;;eAAAA,oDAAyB;;;2CAAQ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["decorators","parameters","withExportToSandboxButton","docs","source","transform","storyContext","fullSource"],"mappings":";;;;;;;;;;;IAKaA,UAAU;eAAVA;;IAEAC,UAAU;eAAVA;;;2CAJ6B;AAEnC,MAAMD,aAAa;IAACE,oDAAyB;CAAC;AAE9C,MAAMD,aAAyB;IACpCE,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaL,UAAU,CAACM,UAAU;YAC3C;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react-webpack5';\nimport type { StoryContextForEnhancers } from 'storybook/internal/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["decorators","parameters","withExportToSandboxButton","docs","source","transform","storyContext","fullSource"],"mappings":";;;;;;;;;;;IAKaA,UAAU;eAAVA;;IAEAC,UAAU;eAAVA;;;2CAJ6B;AAEnC,MAAMD,aAAa;IAACE,oDAAyB;CAAC;AAE9C,MAAMD,aAAyB;IACpCE,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaL,UAAU,CAACM,UAAU;YAC3C;QACF;IACF;AACF"}
@@ -36,12 +36,13 @@ const actionConfig = {
36
36
  }
37
37
  };
38
38
  function addDemoActionButton(context) {
39
- const { container, cssClasses } = (0, _sandboxutils.prepareSandboxContainer)(context);
40
39
  const config = (0, _sandboxutils.prepareData)(context);
41
40
  if (!config) {
42
41
  throw new Error('issues with data');
43
42
  }
44
- addActionButton(container, config, cssClasses);
43
+ (0, _sandboxutils.prepareSandboxContainers)(context).forEach(({ container, cssClasses })=>{
44
+ addActionButton(container, config, cssClasses);
45
+ });
45
46
  }
46
47
  function addActionButton(container, config, classList) {
47
48
  const files = _sandboxscaffold.scaffold[config.bundler](config);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["addDemoActionButton","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","context","container","cssClasses","prepareSandboxContainer","prepareData","Error","addActionButton","classList","scaffold","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","addHiddenInput","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters","getParameters"],"mappings":";;;;+BAuBgBA;;;eAAAA;;;wBAvBc;iCAEL;8BACuD;AAGhF,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAA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ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainers, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n prepareSandboxContainers(context).forEach(({ container, cssClasses }) => {\n addActionButton(container, config, cssClasses);\n });\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["addDemoActionButton","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","context","prepareData","Error","prepareSandboxContainers","forEach","container","cssClasses","addActionButton","classList","scaffold","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","addHiddenInput","Object","keys","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters","getParameters"],"mappings":";;;;+BAuBgBA;;;eAAAA;;;wBAvBc;iCAEL;8BACwD;AAGjF,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,oBAAoB;QAClBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBE,eAAe;gBAAEH;gBAAO,GAAGC,MAAM;YAAC;IAC9F;AACF;AAEO,SAASP,oBAAoBU,OAAqB;IACvD,MAAMH,SAASI,IAA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AI,CAAC,CAAC,EAAEC;IACjD;IAEAjB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B;AAEA;;;CAGC,GACD,SAAS1B,gBAAgB,EAAEF,KAAK,EAAEgB,QAAQ,EAA4C;IACpF,MAAMwB,qBAAqBR,OAAOS,OAAO,CAACzC,OAAO0C,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAM/B,aAAa,sBAAsB,WAAW;IAC1D,MAAMgC,aAAaC,IAAAA,qBAAa,EAAC;QAAEjD,OAAOwC;IAAmB;IAE7D,MAAMZ,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEgC,KAAK;IAEjFhB,IAAAA,4BAAc,EAACH,MAAM,cAAcoB;IACnCjB,IAAAA,4BAAc,EAACH,MAAM,SAAS,CAAC,KAAK,EAAEjC,sBAAsB;IAC5DuB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B"}
@@ -15,8 +15,8 @@ _export(exports, {
15
15
  prepareData: function() {
16
16
  return prepareData;
17
17
  },
18
- prepareSandboxContainer: function() {
19
- return prepareSandboxContainer;
18
+ prepareSandboxContainers: function() {
19
+ return prepareSandboxContainers;
20
20
  }
21
21
  });
22
22
  const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
@@ -29,25 +29,27 @@ function addHiddenInput(form, name, value) {
29
29
  input.value = value;
30
30
  form.appendChild(input);
31
31
  }
32
- function prepareSandboxContainer(context) {
32
+ function prepareSandboxContainers(context) {
33
33
  const docsSelector = `#anchor--${context.id} .docs-story`;
34
- const rootElement = document.querySelector(docsSelector);
35
- if (!rootElement) {
34
+ const rootElements = document.querySelectorAll(docsSelector);
35
+ if (!rootElements.length) {
36
36
  throw new Error(`css selector: ${docsSelector}, doesn't exist `);
37
37
  }
38
- const showCodeButton = rootElement.querySelector('.docblock-code-toggle');
39
- const container = showCodeButton === null || showCodeButton === void 0 ? void 0 : showCodeButton.parentElement;
40
- if (!container) {
41
- throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);
42
- }
43
- const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');
44
- // remove button if it already existed
45
- const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
46
- ourButtons.forEach((node)=>node.remove());
47
- return {
48
- container,
49
- cssClasses: classList
50
- };
38
+ return Array.from(rootElements).map((rootElement)=>{
39
+ const showCodeButton = rootElement.querySelector('.docblock-code-toggle');
40
+ const container = showCodeButton === null || showCodeButton === void 0 ? void 0 : showCodeButton.parentElement;
41
+ if (!container) {
42
+ throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);
43
+ }
44
+ const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');
45
+ // remove button if it already existed
46
+ const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
47
+ ourButtons.forEach((node)=>node.remove());
48
+ return {
49
+ container,
50
+ cssClasses: classList
51
+ };
52
+ });
51
53
  }
52
54
  const addonConfigDefaults = {
53
55
  requiredDependencies: {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["addHiddenInput","prepareData","prepareSandboxContainer","form","name","value","input","document","createElement","type","appendChild","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","dedent","title","dependencies","getDependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":";;;;;;;;;;;IAOgBA,cAAc;eAAdA;;IAkDAC,WAAW;eAAXA;;IA1CAC,uBAAuB;eAAvBA;;;;iEAfG;iCAEa;AAKzB,SAASF,eAAeG,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW,CAACJ;AACnB;AAEO,SAASJ,wBAAwBS,OAAqB;IAC3D,MAAMC,eAAe,CAAC,SAAS,EAAED,QAAQE,EAAE,CAAC,YAAY,CAAC;IACzD,MAAMC,cAAcP,SAASQ,aAAa,CAACH;IAE3C,IAAI,CAACE,aAAa;QAChB,MAAM,IAAIE,MAAM,CAAC,cAAc,EAAEJ,aAAa,gBAAgB,CAAC;IACjE;IAEA,MAAMK,iBAAiBH,YAAYC,aAAa,CAAC;IACjD,MAAMG,YAAYD,2BAAAA,qCAAAA,eAAgBE,aAAa;IAE/C,IAAI,CAAC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C,QAAQmC,eAAe,CAAC1C,IAAI,CAACiB,KAAK,CAAC,aAAa0B,KAAK,CAAC,CAAC,GAAGC,GAAG;IACtF,IAAI,CAACH,kBAAkB;QACrB,MAAM,IAAI7B,MAAM;IAClB;IAEA,MAAMiC,WAAW;QACfb;QACAS;QACAX;QACAC;QACAO;QACAD;QACAG;IACF;IAEA,OAAOK;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainers(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElements = document.querySelectorAll(docsSelector);\n\n if (!rootElements.length) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n return Array.from(rootElements).map(rootElement => {\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n });\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["addHiddenInput","prepareData","prepareSandboxContainers","form","name","value","input","document","createElement","type","appendChild","context","docsSelector","id","rootElements","querySelectorAll","length","Error","Array","from","map","rootElement","showCodeButton","querySelector","container","parentElement","classList","split","ourButtons","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","dedent","title","dependencies","getDependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":";;;;;;;;;;;IAOgBA,cAAc;eAAdA;;IAoDAC,WAAW;eAAXA;;IA5CAC,wBAAwB;eAAxBA;;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AQyB,UAAU,CAACC,eAAe;IACvC;IACA,MAAM,EAAEE,QAAQ,EAAEC,OAAO,EAAE,GAAGF;IAC9B,MAAMG,aAAY9B,sBAAAA,QAAQyB,UAAU,cAAlBzB,0CAAAA,oBAAoB+B,UAAU;IAEhD,IAAI,CAACD,WAAW;QACdE,QAAQC,KAAK,CACXC,IAAAA,eAAM,CAAA,CAAC,wDAAwD,EAAElC,QAAQmC,KAAK,CAAC,mCAAmC,CAAC;QAErH,OAAO;IACT;IAEA,MAAM,EAAEZ,oBAAoB,EAAEC,oBAAoB,EAAE,GAAGG;IACvD,MAAMS,eAAeC,IAAAA,gCAAe,EAACP,WAAWP,sBAAsBC;IAEtE,MAAMW,QAAQ;IACd,MAAMG,cAAc,CAAC,YAAY,EAAEtC,QAAQmC,KAAK,CAAC,GAAG,EAAEnC,QAAQP,IAAI,EAAE;IAEpE,2EAA2E;IAC3E,kEAAkE;IAClE,mEAAmE;IACnE,oFAAoF;IACpF,yBAAyB;IACzB,qFAAqF;IACrF,MAAM8C,mBAAmBvC,QAAQwC,eAAe,CAAC/C,IAAI,CAACuB,KAAK,CAAC,aAAayB,KAAK,CAAC,CAAC,GAAGC,GAAG;IACtF,IAAI,CAACH,kBAAkB;QACrB,MAAM,IAAIjC,MAAM;IAClB;IAEA,MAAMqC,WAAW;QACfb;QACAS;QACAX;QACAC;QACAO;QACAD;QACAG;IACF;IAEA,OAAOK;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-storybook-addon-export-to-sandbox",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Storybook addon that enables cloud/web sandbox exports for stories doc mode code examples",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -10,10 +10,6 @@
10
10
  "url": "https://github.com/microsoft/fluentui"
11
11
  },
12
12
  "license": "MIT",
13
- "devDependencies": {
14
- "@fluentui/eslint-plugin": "*",
15
- "@fluentui/scripts-api-extractor": "*"
16
- },
17
13
  "dependencies": {
18
14
  "@swc/helpers": "^0.5.1",
19
15
  "babel-loader": "^9.1.3",
@@ -22,9 +18,7 @@
22
18
  "dedent": "^1.2.0"
23
19
  },
24
20
  "peerDependencies": {
25
- "@storybook/manager-api": "^7.6.20",
26
- "@storybook/preview-api": "^7.6.20",
27
- "@storybook/react": "^7.6.20"
21
+ "@storybook/react": "^9.1.17"
28
22
  },
29
23
  "beachball": {
30
24
  "disallowedChangeTypes": [