@fluentui/react-storybook-addon 0.5.1 → 0.6.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 +18 -2
- package/dist/index.d.ts +24 -3
- package/lib/components/DirectionSwitch.js +2 -2
- package/lib/components/DirectionSwitch.js.map +1 -1
- package/lib/components/ReactStrictMode.js +3 -4
- package/lib/components/ReactStrictMode.js.map +1 -1
- package/lib/components/ThemePicker.js +5 -6
- package/lib/components/ThemePicker.js.map +1 -1
- package/lib/docs/DirSwitch.js +1 -1
- package/lib/docs/DirSwitch.js.map +1 -1
- package/lib/docs/FluentCanvas.js +21 -0
- package/lib/docs/FluentCanvas.js.map +1 -0
- package/lib/docs/FluentDocsContainer.js +1 -1
- package/lib/docs/FluentDocsContainer.js.map +1 -1
- package/lib/docs/FluentDocsPage.js +37 -23
- package/lib/docs/FluentDocsPage.js.map +1 -1
- package/lib/docs/FluentStory.js +18 -0
- package/lib/docs/FluentStory.js.map +1 -0
- package/lib/docs/ThemePicker.js +1 -1
- package/lib/docs/ThemePicker.js.map +1 -1
- package/lib/docs/Toc.js +2 -2
- package/lib/docs/Toc.js.map +1 -1
- package/lib/docs/index.js +2 -0
- package/lib/docs/index.js.map +1 -1
- package/lib/docs/utils.js.map +1 -1
- package/lib/hooks.js +1 -1
- package/lib/hooks.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/preset/manager.js +1 -4
- package/lib/preset/manager.js.map +1 -1
- package/lib/preset/preview.js +2 -2
- package/lib/preset/preview.js.map +1 -1
- package/lib-commonjs/components/DirectionSwitch.js +2 -2
- package/lib-commonjs/components/DirectionSwitch.js.map +1 -1
- package/lib-commonjs/components/ReactStrictMode.js +3 -4
- package/lib-commonjs/components/ReactStrictMode.js.map +1 -1
- package/lib-commonjs/components/ThemePicker.js +5 -6
- package/lib-commonjs/components/ThemePicker.js.map +1 -1
- package/lib-commonjs/docs/DirSwitch.js +1 -1
- package/lib-commonjs/docs/DirSwitch.js.map +1 -1
- package/lib-commonjs/docs/FluentCanvas.js +29 -0
- package/lib-commonjs/docs/FluentCanvas.js.map +1 -0
- package/lib-commonjs/docs/FluentDocsContainer.js +3 -3
- package/lib-commonjs/docs/FluentDocsContainer.js.map +1 -1
- package/lib-commonjs/docs/FluentDocsPage.js +46 -32
- package/lib-commonjs/docs/FluentDocsPage.js.map +1 -1
- package/lib-commonjs/docs/FluentStory.js +26 -0
- package/lib-commonjs/docs/FluentStory.js.map +1 -0
- package/lib-commonjs/docs/ThemePicker.js +1 -1
- package/lib-commonjs/docs/ThemePicker.js.map +1 -1
- package/lib-commonjs/docs/Toc.js +3 -3
- package/lib-commonjs/docs/Toc.js.map +1 -1
- package/lib-commonjs/docs/index.js +8 -0
- package/lib-commonjs/docs/index.js.map +1 -1
- package/lib-commonjs/docs/utils.js.map +1 -1
- package/lib-commonjs/hooks.js +1 -1
- package/lib-commonjs/hooks.js.map +1 -1
- package/lib-commonjs/index.js +7 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/preset/manager.js +1 -4
- package/lib-commonjs/preset/manager.js.map +1 -1
- package/lib-commonjs/preset/preview.js +4 -4
- package/lib-commonjs/preset/preview.js.map +1 -1
- package/package.json +20 -27
package/lib/docs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/index.ts"],"sourcesContent":["export { FluentDocsContainer } from './FluentDocsContainer';\nexport { FluentDocsPage } from './FluentDocsPage';\n"],"names":["FluentDocsContainer","FluentDocsPage"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,cAAc,QAAQ,mBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../src/docs/index.ts"],"sourcesContent":["export { FluentCanvas } from './FluentCanvas';\nexport { FluentDocsContainer } from './FluentDocsContainer';\nexport { FluentDocsPage } from './FluentDocsPage';\nexport { FluentStory } from './FluentStory';\n"],"names":["FluentCanvas","FluentDocsContainer","FluentDocsPage","FluentStory"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,WAAW,QAAQ,gBAAgB"}
|
package/lib/docs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/utils.ts"],"sourcesContent":["import { type DocsContextProps } from '@storybook/addon-docs';\n\nimport { type FluentParameters } from '../hooks';\n\nconst docsDefaults = {\n copyAsMarkdown: true,\n tableOfContents: true,\n dirSwitcher: true,\n themePicker: true,\n argTable: {\n slotsApi: true,\n nativePropsApi: true,\n },\n};\n\nfunction getDocsParametersConfig(\n context: DocsContextProps,\n): NonNullable<FluentParameters['reactStorybookAddon']>['docs'] {\n return context?.projectAnnotations?.parameters?.reactStorybookAddon?.docs;\n}\n\n/**\n * Checks if the docs page is enabled\n */\nexport function isDocsEnabled(context: DocsContextProps): boolean {\n const docsConfig = getDocsParametersConfig(context);\n\n // If docs is true, enable page\n if (docsConfig === true) {\n return true;\n }\n\n // If docs is an object, page is enabled\n if (typeof docsConfig === 'object' && docsConfig !== null) {\n return true;\n }\n\n // Default: disabled\n return false;\n}\n\n/**\n * Gets the docs page configuration from context\n */\nexport function getDocsPageConfig(context: DocsContextProps): {\n tableOfContents: boolean;\n dirSwitcher: boolean;\n themePicker: boolean;\n copyAsMarkdown: boolean;\n argTable: {\n slotsApi: boolean;\n nativePropsApi: boolean;\n };\n} | null {\n const docsConfig = getDocsParametersConfig(context);\n\n // If docs is true, return default config (all enabled)\n if (docsConfig === true) {\n return docsDefaults;\n }\n\n // If docs is an object, extract the configuration directly\n if (typeof docsConfig === 'object' && docsConfig !== null) {\n return {\n copyAsMarkdown: docsConfig.copyAsMarkdown !== false,\n tableOfContents: docsConfig.tableOfContents !== false,\n dirSwitcher: docsConfig.dirSwitcher !== false,\n themePicker: docsConfig.themePicker !== false,\n argTable: getArgTableConfig(docsConfig.argTable),\n };\n }\n\n // Fallback\n return null;\n}\n\n/**\n * Gets the argTable configuration with early exit pattern\n */\nfunction getArgTableConfig(argTableConfig: boolean | { slotsApi?: boolean; nativePropsApi?: boolean } | undefined) {\n if (argTableConfig === false) {\n return {\n slotsApi: false,\n nativePropsApi: false,\n };\n }\n\n if (argTableConfig === true || argTableConfig === undefined) {\n return {\n slotsApi: true,\n nativePropsApi: true,\n };\n }\n\n if (typeof argTableConfig === 'object' && argTableConfig !== null) {\n return {\n slotsApi: argTableConfig.slotsApi !== false,\n nativePropsApi: argTableConfig.nativePropsApi !== false,\n };\n }\n\n // Fallback to default\n return docsDefaults.argTable;\n}\n"],"names":["docsDefaults","copyAsMarkdown","tableOfContents","dirSwitcher","themePicker","argTable","slotsApi","nativePropsApi","getDocsParametersConfig","context","projectAnnotations","parameters","reactStorybookAddon","docs","isDocsEnabled","docsConfig","getDocsPageConfig","getArgTableConfig","argTableConfig","undefined"],"mappings":"AAIA,MAAMA,eAAe;IACnBC,gBAAgB;IAChBC,iBAAiB;IACjBC,aAAa;IACbC,aAAa;IACbC,UAAU;QACRC,UAAU;QACVC,gBAAgB;IAClB;AACF;AAEA,SAASC,wBACPC,OAAyB;QAElBA,4DAAAA,wCAAAA;IAAP,OAAOA,oBAAAA,+BAAAA,8BAAAA,QAASC,kBAAkB,cAA3BD,mDAAAA,yCAAAA,4BAA6BE,UAAU,cAAvCF,8DAAAA,6DAAAA,uCAAyCG,mBAAmB,cAA5DH,iFAAAA,2DAA8DI,IAAI;AAC3E;AAEA;;CAEC,GACD,OAAO,SAASC,cAAcL,OAAyB;IACrD,MAAMM,aAAaP,wBAAwBC;IAE3C,+BAA+B;IAC/B,IAAIM,eAAe,MAAM;QACvB,OAAO;IACT;IAEA,wCAAwC;IACxC,IAAI,OAAOA,eAAe,YAAYA,eAAe,MAAM;QACzD,OAAO;IACT;IAEA,oBAAoB;IACpB,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,kBAAkBP,OAAyB;IAUzD,MAAMM,aAAaP,wBAAwBC;IAE3C,uDAAuD;IACvD,IAAIM,eAAe,MAAM;QACvB,OAAOf;IACT;IAEA,2DAA2D;IAC3D,IAAI,OAAOe,eAAe,YAAYA,eAAe,MAAM;QACzD,OAAO;YACLd,gBAAgBc,WAAWd,cAAc,KAAK;YAC9CC,iBAAiBa,WAAWb,eAAe,KAAK;YAChDC,aAAaY,WAAWZ,WAAW,KAAK;YACxCC,aAAaW,WAAWX,WAAW,KAAK;YACxCC,UAAUY,kBAAkBF,WAAWV,QAAQ;QACjD;IACF;IAEA,WAAW;IACX,OAAO;AACT;AAEA;;CAEC,GACD,SAASY,kBAAkBC,cAAsF;IAC/G,IAAIA,mBAAmB,OAAO;QAC5B,OAAO;YACLZ,UAAU;YACVC,gBAAgB;QAClB;IACF;IAEA,IAAIW,mBAAmB,QAAQA,mBAAmBC,WAAW;QAC3D,OAAO;YACLb,UAAU;YACVC,gBAAgB;QAClB;IACF;IAEA,IAAI,OAAOW,mBAAmB,YAAYA,mBAAmB,MAAM;QACjE,OAAO;YACLZ,UAAUY,eAAeZ,QAAQ,KAAK;YACtCC,gBAAgBW,eAAeX,cAAc,KAAK;QACpD;IACF;IAEA,sBAAsB;IACtB,OAAOP,aAAaK,QAAQ;AAC9B"}
|
|
1
|
+
{"version":3,"sources":["../src/docs/utils.ts"],"sourcesContent":["import { type DocsContextProps } from '@storybook/addon-docs/blocks';\n\nimport { type FluentParameters } from '../hooks';\n\nconst docsDefaults = {\n copyAsMarkdown: true,\n tableOfContents: true,\n dirSwitcher: true,\n themePicker: true,\n argTable: {\n slotsApi: true,\n nativePropsApi: true,\n },\n};\n\nfunction getDocsParametersConfig(\n context: DocsContextProps,\n): NonNullable<FluentParameters['reactStorybookAddon']>['docs'] {\n return context?.projectAnnotations?.parameters?.reactStorybookAddon?.docs;\n}\n\n/**\n * Checks if the docs page is enabled\n */\nexport function isDocsEnabled(context: DocsContextProps): boolean {\n const docsConfig = getDocsParametersConfig(context);\n\n // If docs is true, enable page\n if (docsConfig === true) {\n return true;\n }\n\n // If docs is an object, page is enabled\n if (typeof docsConfig === 'object' && docsConfig !== null) {\n return true;\n }\n\n // Default: disabled\n return false;\n}\n\n/**\n * Gets the docs page configuration from context\n */\nexport function getDocsPageConfig(context: DocsContextProps): {\n tableOfContents: boolean;\n dirSwitcher: boolean;\n themePicker: boolean;\n copyAsMarkdown: boolean;\n argTable: {\n slotsApi: boolean;\n nativePropsApi: boolean;\n };\n} | null {\n const docsConfig = getDocsParametersConfig(context);\n\n // If docs is true, return default config (all enabled)\n if (docsConfig === true) {\n return docsDefaults;\n }\n\n // If docs is an object, extract the configuration directly\n if (typeof docsConfig === 'object' && docsConfig !== null) {\n return {\n copyAsMarkdown: docsConfig.copyAsMarkdown !== false,\n tableOfContents: docsConfig.tableOfContents !== false,\n dirSwitcher: docsConfig.dirSwitcher !== false,\n themePicker: docsConfig.themePicker !== false,\n argTable: getArgTableConfig(docsConfig.argTable),\n };\n }\n\n // Fallback\n return null;\n}\n\n/**\n * Gets the argTable configuration with early exit pattern\n */\nfunction getArgTableConfig(argTableConfig: boolean | { slotsApi?: boolean; nativePropsApi?: boolean } | undefined) {\n if (argTableConfig === false) {\n return {\n slotsApi: false,\n nativePropsApi: false,\n };\n }\n\n if (argTableConfig === true || argTableConfig === undefined) {\n return {\n slotsApi: true,\n nativePropsApi: true,\n };\n }\n\n if (typeof argTableConfig === 'object' && argTableConfig !== null) {\n return {\n slotsApi: argTableConfig.slotsApi !== false,\n nativePropsApi: argTableConfig.nativePropsApi !== false,\n };\n }\n\n // Fallback to default\n return docsDefaults.argTable;\n}\n"],"names":["docsDefaults","copyAsMarkdown","tableOfContents","dirSwitcher","themePicker","argTable","slotsApi","nativePropsApi","getDocsParametersConfig","context","projectAnnotations","parameters","reactStorybookAddon","docs","isDocsEnabled","docsConfig","getDocsPageConfig","getArgTableConfig","argTableConfig","undefined"],"mappings":"AAIA,MAAMA,eAAe;IACnBC,gBAAgB;IAChBC,iBAAiB;IACjBC,aAAa;IACbC,aAAa;IACbC,UAAU;QACRC,UAAU;QACVC,gBAAgB;IAClB;AACF;AAEA,SAASC,wBACPC,OAAyB;QAElBA,4DAAAA,wCAAAA;IAAP,OAAOA,oBAAAA,+BAAAA,8BAAAA,QAASC,kBAAkB,cAA3BD,mDAAAA,yCAAAA,4BAA6BE,UAAU,cAAvCF,8DAAAA,6DAAAA,uCAAyCG,mBAAmB,cAA5DH,iFAAAA,2DAA8DI,IAAI;AAC3E;AAEA;;CAEC,GACD,OAAO,SAASC,cAAcL,OAAyB;IACrD,MAAMM,aAAaP,wBAAwBC;IAE3C,+BAA+B;IAC/B,IAAIM,eAAe,MAAM;QACvB,OAAO;IACT;IAEA,wCAAwC;IACxC,IAAI,OAAOA,eAAe,YAAYA,eAAe,MAAM;QACzD,OAAO;IACT;IAEA,oBAAoB;IACpB,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,kBAAkBP,OAAyB;IAUzD,MAAMM,aAAaP,wBAAwBC;IAE3C,uDAAuD;IACvD,IAAIM,eAAe,MAAM;QACvB,OAAOf;IACT;IAEA,2DAA2D;IAC3D,IAAI,OAAOe,eAAe,YAAYA,eAAe,MAAM;QACzD,OAAO;YACLd,gBAAgBc,WAAWd,cAAc,KAAK;YAC9CC,iBAAiBa,WAAWb,eAAe,KAAK;YAChDC,aAAaY,WAAWZ,WAAW,KAAK;YACxCC,aAAaW,WAAWX,WAAW,KAAK;YACxCC,UAAUY,kBAAkBF,WAAWV,QAAQ;QACjD;IACF;IAEA,WAAW;IACX,OAAO;AACT;AAEA;;CAEC,GACD,SAASY,kBAAkBC,cAAsF;IAC/G,IAAIA,mBAAmB,OAAO;QAC5B,OAAO;YACLZ,UAAU;YACVC,gBAAgB;QAClB;IACF;IAEA,IAAIW,mBAAmB,QAAQA,mBAAmBC,WAAW;QAC3D,OAAO;YACLb,UAAU;YACVC,gBAAgB;QAClB;IACF;IAEA,IAAI,OAAOW,mBAAmB,YAAYA,mBAAmB,MAAM;QACjE,OAAO;YACLZ,UAAUY,eAAeZ,QAAQ,KAAK;YACtCC,gBAAgBW,eAAeX,cAAc,KAAK;QACpD;IACF;IAEA,sBAAsB;IACtB,OAAOP,aAAaK,QAAQ;AAC9B"}
|
package/lib/hooks.js
CHANGED
package/lib/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["import { useGlobals as useStorybookGlobals } from '
|
|
1
|
+
{"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["import { useGlobals as useStorybookGlobals } from 'storybook/manager-api';\nimport { Args as StorybookArgs, StoryContext as StorybookContext, Parameters } from '@storybook/react-webpack5';\n\nimport { DIR_ID, STRICT_MODE_ID, THEME_ID } from './constants';\nimport type { ThemeIds } from './theme';\n\nexport interface FluentStoryContext extends StorybookContext {\n globals: FluentGlobals;\n parameters: FluentParameters;\n}\n\n/**\n * Extends the storybook globals object to include fluent specific properties\n */\nexport interface FluentGlobals extends StorybookArgs {\n [DIR_ID]?: 'ltr' | 'rtl';\n [THEME_ID]?: ThemeIds;\n [STRICT_MODE_ID]?: boolean;\n}\n\n/**\n * Extends the storybook parameters object to include fluent specific properties\n */\nexport interface FluentParameters extends Parameters {\n dir?: 'ltr' | 'rtl';\n fluentTheme?: ThemeIds;\n mode?: 'default' | 'vr-test';\n reactStorybookAddon?: {\n disabledDecorators?: ['AriaLive' | 'FluentProvider' | 'ReactStrictMode'];\n docs?: FluentDocsConfig;\n };\n}\n\n/**\n * Configuration for docs components\n */\ntype FluentDocsConfig =\n | boolean\n | {\n tableOfContents?: boolean;\n dirSwitcher?: boolean;\n themePicker?: boolean;\n copyAsMarkdown?: boolean;\n argTable?:\n | boolean\n | {\n slotsApi?: boolean;\n nativePropsApi?: boolean;\n };\n };\n\nexport function useGlobals(): [FluentGlobals, (newGlobals: FluentGlobals) => void, FluentGlobals, FluentGlobals] {\n return useStorybookGlobals();\n}\n\nexport function parameters(options?: FluentParameters): FluentParameters {\n return { dir: 'ltr', fluentTheme: 'web-light', mode: 'default', ...options };\n}\nexport function getParametersConfig(context: FluentStoryContext): FluentParameters['reactStorybookAddon'] {\n return context?.parameters?.reactStorybookAddon;\n}\n"],"names":["useGlobals","useStorybookGlobals","parameters","options","dir","fluentTheme","mode","getParametersConfig","context","reactStorybookAddon"],"mappings":"AAAA,SAASA,cAAcC,mBAAmB,QAAQ,wBAAwB;AAmD1E,OAAO,SAASD;IACd,OAAOC;AACT;AAEA,OAAO,SAASC,WAAWC,OAA0B;IACnD,OAAO;QAAEC,KAAK;QAAOC,aAAa;QAAaC,MAAM;QAAW,GAAGH,OAAO;IAAC;AAC7E;AACA,OAAO,SAASI,oBAAoBC,OAA2B;QACtDA;IAAP,OAAOA,oBAAAA,+BAAAA,sBAAAA,QAASN,UAAU,cAAnBM,0CAAAA,oBAAqBC,mBAAmB;AACjD"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { FluentGlobals, FluentParameters, FluentStoryContext } from './hooks';\nexport type { ThemeIds } from './theme';\nexport { themes } from './theme';\nexport { DIR_ID, THEME_ID } from './constants';\nexport { parameters } from './hooks';\n"],"names":["themes","DIR_ID","THEME_ID","parameters"],"mappings":"AAEA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,MAAM,EAAEC,QAAQ,QAAQ,cAAc;AAC/C,SAASC,UAAU,QAAQ,UAAU"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { FluentGlobals, FluentParameters, FluentStoryContext } from './hooks';\nexport type { ThemeIds } from './theme';\nexport { themes } from './theme';\nexport { DIR_ID, THEME_ID } from './constants';\nexport { parameters } from './hooks';\nexport { FluentCanvas, FluentStory } from './docs';\n"],"names":["themes","DIR_ID","THEME_ID","parameters","FluentCanvas","FluentStory"],"mappings":"AAEA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,MAAM,EAAEC,QAAQ,QAAQ,cAAc;AAC/C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,EAAEC,WAAW,QAAQ,SAAS"}
|
package/lib/preset/manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addons, types } from '
|
|
1
|
+
import { addons, types } from 'storybook/manager-api';
|
|
2
2
|
import { ADDON_ID, DIR_ID, STRICT_MODE_ID, THEME_ID } from '../constants';
|
|
3
3
|
import { ThemePicker } from '../components/ThemePicker';
|
|
4
4
|
import { ReactStrictMode } from '../components/ReactStrictMode';
|
|
@@ -6,20 +6,17 @@ import { DirectionSwitch } from '../components/DirectionSwitch';
|
|
|
6
6
|
addons.register(ADDON_ID, ()=>{
|
|
7
7
|
addons.add(THEME_ID, {
|
|
8
8
|
title: 'Fluent Theme Picker',
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
10
9
|
type: types.TOOL,
|
|
11
10
|
match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
|
|
12
11
|
render: ThemePicker
|
|
13
12
|
});
|
|
14
13
|
addons.add(DIR_ID, {
|
|
15
14
|
title: 'Direction Switch',
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
15
|
type: types.TOOL,
|
|
18
16
|
match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
|
|
19
17
|
render: DirectionSwitch
|
|
20
18
|
});
|
|
21
19
|
addons.add(STRICT_MODE_ID, {
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
23
20
|
type: types.TOOL,
|
|
24
21
|
title: 'React Strict Mode',
|
|
25
22
|
match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preset/manager.ts"],"sourcesContent":["import { addons, types } from '
|
|
1
|
+
{"version":3,"sources":["../src/preset/manager.ts"],"sourcesContent":["import { addons, types } from 'storybook/manager-api';\n\nimport { ADDON_ID, DIR_ID, STRICT_MODE_ID, THEME_ID } from '../constants';\nimport { ThemePicker } from '../components/ThemePicker';\nimport { ReactStrictMode } from '../components/ReactStrictMode';\nimport { DirectionSwitch } from '../components/DirectionSwitch';\n\naddons.register(ADDON_ID, () => {\n addons.add(THEME_ID, {\n title: 'Fluent Theme Picker',\n\n type: types.TOOL,\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: ThemePicker,\n });\n addons.add(DIR_ID, {\n title: 'Direction Switch',\n\n type: types.TOOL,\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: DirectionSwitch,\n });\n addons.add(STRICT_MODE_ID, {\n type: types.TOOL,\n title: 'React Strict Mode',\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: ReactStrictMode,\n });\n});\n"],"names":["addons","types","ADDON_ID","DIR_ID","STRICT_MODE_ID","THEME_ID","ThemePicker","ReactStrictMode","DirectionSwitch","register","add","title","type","TOOL","match","viewMode","render"],"mappings":"AAAA,SAASA,MAAM,EAAEC,KAAK,QAAQ,wBAAwB;AAEtD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,eAAe;AAC1E,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,eAAe,QAAQ,gCAAgC;AAEhER,OAAOS,QAAQ,CAACP,UAAU;IACxBF,OAAOU,GAAG,CAACL,UAAU;QACnBM,OAAO;QAEPC,MAAMX,MAAMY,IAAI;QAChBC,OAAO,CAAC,EAAEC,QAAQ,EAAE,GAAK,CAAC,CAAEA,CAAAA,YAAYA,SAASD,KAAK,CAAC,iBAAgB;QACvEE,QAAQV;IACV;IACAN,OAAOU,GAAG,CAACP,QAAQ;QACjBQ,OAAO;QAEPC,MAAMX,MAAMY,IAAI;QAChBC,OAAO,CAAC,EAAEC,QAAQ,EAAE,GAAK,CAAC,CAAEA,CAAAA,YAAYA,SAASD,KAAK,CAAC,iBAAgB;QACvEE,QAAQR;IACV;IACAR,OAAOU,GAAG,CAACN,gBAAgB;QACzBQ,MAAMX,MAAMY,IAAI;QAChBF,OAAO;QACPG,OAAO,CAAC,EAAEC,QAAQ,EAAE,GAAK,CAAC,CAAEA,CAAAA,YAAYA,SAASD,KAAK,CAAC,iBAAgB;QACvEE,QAAQT;IACV;AACF"}
|
package/lib/preset/preview.js
CHANGED
|
@@ -8,14 +8,14 @@ export const decorators = [
|
|
|
8
8
|
withAriaLive,
|
|
9
9
|
withReactStrictMode
|
|
10
10
|
];
|
|
11
|
-
export const
|
|
11
|
+
export const initialGlobals = {
|
|
12
12
|
[THEME_ID]: undefined,
|
|
13
13
|
[DIR_ID]: undefined,
|
|
14
14
|
[STRICT_MODE_ID]: undefined
|
|
15
15
|
}; // allow theme to be set by URL query param
|
|
16
16
|
const preview = {
|
|
17
17
|
decorators,
|
|
18
|
-
|
|
18
|
+
initialGlobals,
|
|
19
19
|
parameters: {
|
|
20
20
|
docs: {
|
|
21
21
|
container: FluentDocsContainer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Preview } from '@storybook/react-webpack5';\n\nimport { withFluentProvider } from '../decorators/withFluentProvider';\nimport { withReactStrictMode } from '../decorators/withReactStrictMode';\nimport { withAriaLive } from '../decorators/withAriaLive';\nimport { FluentDocsContainer, FluentDocsPage } from '../docs';\n\nimport { DIR_ID, STRICT_MODE_ID, THEME_ID } from '../constants';\n\nexport const decorators = [withFluentProvider, withAriaLive, withReactStrictMode] as Preview['decorators'];\n\nexport const initialGlobals = { [THEME_ID]: undefined, [DIR_ID]: undefined, [STRICT_MODE_ID]: undefined }; // allow theme to be set by URL query param\n\nconst preview: Preview = {\n decorators,\n initialGlobals,\n parameters: {\n docs: {\n container: FluentDocsContainer,\n page: FluentDocsPage,\n },\n },\n};\n\nexport default preview;\n"],"names":["withFluentProvider","withReactStrictMode","withAriaLive","FluentDocsContainer","FluentDocsPage","DIR_ID","STRICT_MODE_ID","THEME_ID","decorators","initialGlobals","undefined","preview","parameters","docs","container","page"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,mCAAmC;AACtE,SAASC,mBAAmB,QAAQ,oCAAoC;AACxE,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,mBAAmB,EAAEC,cAAc,QAAQ,UAAU;AAE9D,SAASC,MAAM,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,eAAe;AAEhE,OAAO,MAAMC,aAAa;IAACR;IAAoBE;IAAcD;CAAoB,CAA0B;AAE3G,OAAO,MAAMQ,iBAAiB;IAAE,CAACF,SAAS,EAAEG;IAAW,CAACL,OAAO,EAAEK;IAAW,CAACJ,eAAe,EAAEI;AAAU,EAAE,CAAC,2CAA2C;AAEtJ,MAAMC,UAAmB;IACvBH;IACAC;IACAG,YAAY;QACVC,MAAM;YACJC,WAAWX;YACXY,MAAMX;QACR;IACF;AACF;AAEA,eAAeO,QAAQ"}
|
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "DirectionSwitch", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _components = require("
|
|
14
|
-
const _theming = require("
|
|
13
|
+
const _components = require("storybook/internal/components");
|
|
14
|
+
const _theming = require("storybook/theming");
|
|
15
15
|
const _constants = require("../constants");
|
|
16
16
|
const _hooks = require("../hooks");
|
|
17
17
|
const Monospace = _theming.styled.span({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/DirectionSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '
|
|
1
|
+
{"version":3,"sources":["../src/components/DirectionSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from 'storybook/internal/components';\nimport { styled } from 'storybook/theming';\n\nimport { JSXElement } from '@fluentui/react-utilities';\nimport { DIR_ID } from '../constants';\nimport { useGlobals } from '../hooks';\n\nconst Monospace = styled.span({\n fontFamily: \"'Cascadia Code', Menlo, 'Courier New', Courier, monospace\",\n letterSpacing: '-0.05em',\n});\n\nexport const DirectionSwitch = (): JSXElement => {\n const [globals, updateGlobals] = useGlobals();\n\n const direction = globals[DIR_ID] ?? 'ltr';\n const isLTR = direction === 'ltr';\n\n const toggleDirection = React.useCallback(\n () =>\n updateGlobals({\n [DIR_ID]: isLTR ? 'rtl' : 'ltr',\n }),\n [isLTR, updateGlobals],\n );\n\n return (\n <IconButton key={DIR_ID} title=\"Change Direction\" onClick={toggleDirection}>\n <div>\n Direction: <Monospace>{direction.toUpperCase()}</Monospace>\n </div>\n </IconButton>\n );\n};\n"],"names":["DirectionSwitch","Monospace","styled","span","fontFamily","letterSpacing","globals","updateGlobals","useGlobals","direction","DIR_ID","isLTR","toggleDirection","React","useCallback","IconButton","key","title","onClick","div","toUpperCase"],"mappings":";;;;+BAaaA;;;eAAAA;;;;iEAbU;4BACI;yBACJ;2BAGA;uBACI;AAE3B,MAAMC,YAAYC,eAAM,CAACC,IAAI,CAAC;IAC5BC,YAAY;IACZC,eAAe;AACjB;AAEO,MAAML,kBAAkB;IAC7B,MAAM,CAACM,SAASC,cAAc,GAAGC,IAAAA,iBAAU;QAEzBF;IAAlB,MAAMG,YAAYH,CAAAA,kBAAAA,OAAO,CAACI,iBAAM,CAAC,cAAfJ,6BAAAA,kBAAmB;IACrC,MAAMK,QAAQF,cAAc;IAE5B,MAAMG,kBAAkBC,OAAMC,WAAW,CACvC,IACEP,cAAc;YACZ,CAACG,iBAAM,CAAC,EAAEC,QAAQ,QAAQ;QAC5B,IACF;QAACA;QAAOJ;KAAc;IAGxB,qBACE,qBAACQ,sBAAU;QAACC,KAAKN,iBAAM;QAAEO,OAAM;QAAmBC,SAASN;qBACzD,qBAACO,aAAI,6BACQ,qBAAClB,iBAAWQ,UAAUW,WAAW;AAIpD"}
|
|
@@ -10,7 +10,8 @@ Object.defineProperty(exports, "ReactStrictMode", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _components = require("
|
|
13
|
+
const _components = require("storybook/internal/components");
|
|
14
|
+
const _icons = require("@storybook/icons");
|
|
14
15
|
const _constants = require("../constants");
|
|
15
16
|
const _hooks = require("../hooks");
|
|
16
17
|
const ReactStrictMode = ()=>{
|
|
@@ -28,7 +29,5 @@ const ReactStrictMode = ()=>{
|
|
|
28
29
|
active: isActive,
|
|
29
30
|
title: "Toggle React Strict mode",
|
|
30
31
|
onClick: toggleStrictMode
|
|
31
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
32
|
-
icon: "lock"
|
|
33
|
-
}));
|
|
32
|
+
}, /*#__PURE__*/ _react.createElement(_icons.LockIcon, null));
|
|
34
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ReactStrictMode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton
|
|
1
|
+
{"version":3,"sources":["../src/components/ReactStrictMode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from 'storybook/internal/components';\nimport { LockIcon } from '@storybook/icons';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { STRICT_MODE_ID } from '../constants';\nimport { useGlobals } from '../hooks';\n\nexport const ReactStrictMode = (): JSXElement => {\n const [globals, updateGlobals] = useGlobals();\n\n const isActive = globals[STRICT_MODE_ID] ?? false;\n\n const toggleStrictMode = React.useCallback(\n () =>\n updateGlobals({\n [STRICT_MODE_ID]: !isActive,\n }),\n [isActive, updateGlobals],\n );\n\n return (\n <IconButton key={STRICT_MODE_ID} active={isActive} title=\"Toggle React Strict mode\" onClick={toggleStrictMode}>\n <LockIcon />\n </IconButton>\n );\n};\n"],"names":["ReactStrictMode","globals","updateGlobals","useGlobals","isActive","STRICT_MODE_ID","toggleStrictMode","React","useCallback","IconButton","key","active","title","onClick","LockIcon"],"mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;4BACI;uBACF;2BAGM;uBACJ;AAEpB,MAAMA,kBAAkB;IAC7B,MAAM,CAACC,SAASC,cAAc,GAAGC,IAAAA,iBAAU;QAE1BF;IAAjB,MAAMG,WAAWH,CAAAA,0BAAAA,OAAO,CAACI,yBAAc,CAAC,cAAvBJ,qCAAAA,0BAA2B;IAE5C,MAAMK,mBAAmBC,OAAMC,WAAW,CACxC,IACEN,cAAc;YACZ,CAACG,yBAAc,CAAC,EAAE,CAACD;QACrB,IACF;QAACA;QAAUF;KAAc;IAG3B,qBACE,qBAACO,sBAAU;QAACC,KAAKL,yBAAc;QAAEM,QAAQP;QAAUQ,OAAM;QAA2BC,SAASP;qBAC3F,qBAACQ,eAAQ;AAGf"}
|
|
@@ -10,8 +10,9 @@ Object.defineProperty(exports, "ThemePicker", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _components = require("
|
|
14
|
-
const
|
|
13
|
+
const _components = require("storybook/internal/components");
|
|
14
|
+
const _icons = require("@storybook/icons");
|
|
15
|
+
const _managerapi = require("storybook/manager-api");
|
|
15
16
|
const _theme = require("../theme");
|
|
16
17
|
const _constants = require("../constants");
|
|
17
18
|
const _hooks = require("../hooks");
|
|
@@ -56,15 +57,13 @@ const ThemePicker = ()=>{
|
|
|
56
57
|
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement(_components.WithTooltip, {
|
|
57
58
|
placement: "top",
|
|
58
59
|
trigger: "click",
|
|
59
|
-
|
|
60
|
+
closeOnOutsideClick: true,
|
|
60
61
|
tooltip: renderTooltip
|
|
61
62
|
}, /*#__PURE__*/ _react.createElement(_components.IconButton, {
|
|
62
63
|
key: _constants.THEME_ID,
|
|
63
64
|
title: "Change Fluent theme",
|
|
64
65
|
active: isActive
|
|
65
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
66
|
-
icon: "arrowdown"
|
|
67
|
-
}), /*#__PURE__*/ _react.createElement("span", {
|
|
66
|
+
}, /*#__PURE__*/ _react.createElement(_icons.ArrowDownIcon, null), /*#__PURE__*/ _react.createElement("span", {
|
|
68
67
|
style: {
|
|
69
68
|
marginLeft: 5
|
|
70
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ThemePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton,
|
|
1
|
+
{"version":3,"sources":["../src/components/ThemePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components';\nimport { ArrowDownIcon } from '@storybook/icons';\nimport { useParameter } from 'storybook/manager-api';\n\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { ThemeIds, themes, defaultTheme } from '../theme';\nimport { THEME_ID } from '../constants';\nimport { useGlobals, FluentParameters } from '../hooks';\n\nexport interface ThemeSelectorItem {\n id: string;\n title: string;\n onClick: () => void;\n value: string;\n active: boolean;\n}\n\nfunction createThemeItems(\n value: typeof themes,\n changeTheme: (id: ThemeIds) => void,\n getCurrentTheme: () => ThemeIds,\n): ThemeSelectorItem[] {\n return value.map(item => {\n return {\n id: item.id,\n title: item.id === defaultTheme.id ? `${item.label} (Default)` : item.label,\n onClick: () => {\n changeTheme(item.id);\n },\n value: item.id,\n active: getCurrentTheme() === item.id,\n };\n });\n}\n\nexport const ThemePicker = (): JSXElement => {\n const [globals, updateGlobals] = useGlobals();\n const fluentTheme: FluentParameters['fluentTheme'] = useParameter('fluentTheme');\n\n const selectedThemeId = fluentTheme ? fluentTheme : globals[THEME_ID] ?? defaultTheme.id;\n const selectedTheme = themes.find(entry => entry.id === selectedThemeId);\n\n const isActive = selectedThemeId !== defaultTheme.id;\n\n const setTheme = React.useCallback(\n (id: ThemeIds) => {\n updateGlobals({ [THEME_ID]: id });\n },\n [updateGlobals],\n );\n\n const renderTooltip = React.useCallback(\n (props: { onHide: () => void }) => {\n return (\n <TooltipLinkList\n links={createThemeItems(\n themes,\n id => {\n setTheme(id);\n props.onHide();\n },\n () => selectedThemeId,\n )}\n />\n );\n },\n [selectedThemeId, setTheme],\n );\n\n return (\n <>\n <WithTooltip placement=\"top\" trigger=\"click\" closeOnOutsideClick tooltip={renderTooltip}>\n <IconButton key={THEME_ID} title=\"Change Fluent theme\" active={isActive}>\n <ArrowDownIcon />\n <span style={{ marginLeft: 5 }}>Theme: {selectedTheme?.label}</span>\n </IconButton>\n </WithTooltip>\n </>\n );\n};\n"],"names":["ThemePicker","createThemeItems","value","changeTheme","getCurrentTheme","map","item","id","title","defaultTheme","label","onClick","active","globals","updateGlobals","useGlobals","fluentTheme","useParameter","selectedThemeId","THEME_ID","selectedTheme","themes","find","entry","isActive","setTheme","React","useCallback","renderTooltip","props","TooltipLinkList","links","onHide","WithTooltip","placement","trigger","closeOnOutsideClick","tooltip","IconButton","key","ArrowDownIcon","span","style","marginLeft"],"mappings":";;;;+BAoCaA;;;eAAAA;;;;iEApCU;4BACkC;uBAC3B;4BACD;uBAGkB;2BACtB;uBACoB;AAU7C,SAASC,iBACPC,KAAoB,EACpBC,WAAmC,EACnCC,eAA+B;IAE/B,OAAOF,MAAMG,GAAG,CAACC,CAAAA;QACf,OAAO;YACLC,IAAID,KAAKC,EAAE;YACXC,OAAOF,KAAKC,EAAE,KAAKE,mBAAY,CAACF,EAAE,GAAG,GAAGD,KAAKI,KAAK,CAAC,UAAU,CAAC,GAAGJ,KAAKI,KAAK;YAC3EC,SAAS;gBACPR,YAAYG,KAAKC,EAAE;YACrB;YACAL,OAAOI,KAAKC,EAAE;YACdK,QAAQR,sBAAsBE,KAAKC,EAAE;QACvC;IACF;AACF;AAEO,MAAMP,cAAc;IACzB,MAAM,CAACa,SAASC,cAAc,GAAGC,IAAAA,iBAAU;IAC3C,MAAMC,cAA+CC,IAAAA,wBAAY,EAAC;QAEdJ;IAApD,MAAMK,kBAAkBF,cAAcA,cAAcH,CAAAA,oBAAAA,OAAO,CAACM,mBAAQ,CAAC,cAAjBN,+BAAAA,oBAAqBJ,mBAAY,CAACF,EAAE;IACxF,MAAMa,gBAAgBC,aAAM,CAACC,IAAI,CAACC,CAAAA,QAASA,MAAMhB,EAAE,KAAKW;IAExD,MAAMM,WAAWN,oBAAoBT,mBAAY,CAACF,EAAE;IAEpD,MAAMkB,WAAWC,OAAMC,WAAW,CAChC,CAACpB;QACCO,cAAc;YAAE,CAACK,mBAAQ,CAAC,EAAEZ;QAAG;IACjC,GACA;QAACO;KAAc;IAGjB,MAAMc,gBAAgBF,OAAMC,WAAW,CACrC,CAACE;QACC,qBACE,qBAACC,2BAAe;YACdC,OAAO9B,iBACLoB,aAAM,EACNd,CAAAA;gBACEkB,SAASlB;gBACTsB,MAAMG,MAAM;YACd,GACA,IAAMd;;IAId,GACA;QAACA;QAAiBO;KAAS;IAG7B,qBACE,0DACE,qBAACQ,uBAAW;QAACC,WAAU;QAAMC,SAAQ;QAAQC,qBAAAA;QAAoBC,SAAST;qBACxE,qBAACU,sBAAU;QAACC,KAAKpB,mBAAQ;QAAEX,OAAM;QAAsBI,QAAQY;qBAC7D,qBAACgB,oBAAa,uBACd,qBAACC;QAAKC,OAAO;YAAEC,YAAY;QAAE;OAAG,WAAQvB,0BAAAA,oCAAAA,cAAeV,KAAK;AAKtE"}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "DirSwitch", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _previewapi = require("
|
|
13
|
+
const _previewapi = require("storybook/preview-api");
|
|
14
14
|
const _reactlabel = require("@fluentui/react-label");
|
|
15
15
|
const _reactswitch = require("@fluentui/react-switch");
|
|
16
16
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/DirSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { addons } from '
|
|
1
|
+
{"version":3,"sources":["../src/docs/DirSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { addons } from 'storybook/preview-api';\n\nimport { Label } from '@fluentui/react-label';\nimport { Switch, type SwitchProps } from '@fluentui/react-switch';\nimport { useId } from '@fluentui/react-utilities';\nimport { typographyStyles } from '@fluentui/react-theme';\nimport { makeStyles } from '@griffel/react';\n\nimport { DIR_ID } from '../constants';\n\nconst useStyles = makeStyles({\n container: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'start',\n },\n label: {\n ...typographyStyles.subtitle2,\n },\n});\n\n/**\n * Dir switch used in the react-components docs header\n */\nexport const DirSwitch: React.FC<{ dir?: 'ltr' | 'rtl' }> = ({ dir }) => {\n const switchId = useId('dir-switch');\n\n const styles = useStyles();\n\n const [currentDir, setCurrentDir] = React.useState(dir);\n const checked = currentDir === 'rtl';\n\n const setGlobalDir = (newDir: 'ltr' | 'rtl'): void => {\n addons.getChannel().emit('updateGlobals', { globals: { [DIR_ID]: newDir } });\n };\n\n const onChange = React.useCallback<NonNullable<SwitchProps['onChange']>>((_, data) => {\n const newDir = data.checked ? 'rtl' : 'ltr';\n setGlobalDir(newDir);\n setCurrentDir(newDir);\n }, []);\n\n return (\n <div className={styles.container}>\n <Label className={styles.label} htmlFor={currentDir === 'ltr' ? undefined : switchId}>\n LTR\n </Label>\n <Switch checked={checked} id={switchId} onChange={onChange} />\n <Label className={styles.label} htmlFor={currentDir === 'rtl' ? switchId : undefined}>\n RTL\n </Label>\n </div>\n );\n};\n"],"names":["DirSwitch","useStyles","makeStyles","container","alignItems","display","justifyContent","label","typographyStyles","subtitle2","dir","switchId","useId","styles","currentDir","setCurrentDir","React","useState","checked","setGlobalDir","newDir","addons","getChannel","emit","globals","DIR_ID","onChange","useCallback","_","data","div","className","Label","htmlFor","undefined","Switch","id"],"mappings":";;;;+BAyBaA;;;eAAAA;;;;iEAzBU;4BACA;4BAED;6BACmB;gCACnB;4BACW;wBACN;2BAEJ;AAEvB,MAAMC,YAAYC,IAAAA,kBAAU,EAAC;IAC3BC,WAAW;QACTC,YAAY;QACZC,SAAS;QACTC,gBAAgB;IAClB;IACAC,OAAO;QACL,GAAGC,4BAAgB,CAACC,SAAS;IAC/B;AACF;AAKO,MAAMT,YAA+C,CAAC,EAAEU,GAAG,EAAE;IAClE,MAAMC,WAAWC,IAAAA,qBAAK,EAAC;IAEvB,MAAMC,SAASZ;IAEf,MAAM,CAACa,YAAYC,cAAc,GAAGC,OAAMC,QAAQ,CAACP;IACnD,MAAMQ,UAAUJ,eAAe;IAE/B,MAAMK,eAAe,CAACC;QACpBC,kBAAM,CAACC,UAAU,GAAGC,IAAI,CAAC,iBAAiB;YAAEC,SAAS;gBAAE,CAACC,iBAAM,CAAC,EAAEL;YAAO;QAAE;IAC5E;IAEA,MAAMM,WAAWV,OAAMW,WAAW,CAAuC,CAACC,GAAGC;QAC3E,MAAMT,SAASS,KAAKX,OAAO,GAAG,QAAQ;QACtCC,aAAaC;QACbL,cAAcK;IAChB,GAAG,EAAE;IAEL,qBACE,qBAACU;QAAIC,WAAWlB,OAAOV,SAAS;qBAC9B,qBAAC6B,iBAAK;QAACD,WAAWlB,OAAON,KAAK;QAAE0B,SAASnB,eAAe,QAAQoB,YAAYvB;OAAU,sBAGtF,qBAACwB,mBAAM;QAACjB,SAASA;QAASkB,IAAIzB;QAAUe,UAAUA;sBAClD,qBAACM,iBAAK;QAACD,WAAWlB,OAAON,KAAK;QAAE0B,SAASnB,eAAe,QAAQH,WAAWuB;OAAW;AAK5F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FluentCanvas", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FluentCanvas;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _react1 = require("@griffel/react");
|
|
14
|
+
const useStyles = (0, _react1.makeStyles)({
|
|
15
|
+
canvas: {
|
|
16
|
+
padding: '20px',
|
|
17
|
+
boxSizing: 'border-box',
|
|
18
|
+
overflow: 'auto'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const FluentCanvas = (props)=>{
|
|
22
|
+
const styles = useStyles();
|
|
23
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
24
|
+
className: "sbdocs-preview"
|
|
25
|
+
}, /*#__PURE__*/ _react.createElement("div", {
|
|
26
|
+
className: styles.canvas,
|
|
27
|
+
...props
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/docs/FluentCanvas.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { makeStyles } from '@griffel/react';\n\nconst useStyles = makeStyles({\n canvas: {\n padding: '20px',\n boxSizing: 'border-box',\n overflow: 'auto',\n },\n});\n\n/**\n * Canvas component to wrap stories in a styled container.\n * Provides a similar experience to Storybook's v7 `Canvas` component.\n */\nexport const FluentCanvas = (props: React.ComponentProps<'div'>): JSXElement => {\n const styles = useStyles();\n\n return (\n <div className=\"sbdocs-preview\">\n <div className={styles.canvas} {...props} />\n </div>\n );\n};\n"],"names":["FluentCanvas","useStyles","makeStyles","canvas","padding","boxSizing","overflow","props","styles","div","className"],"mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;wBAEI;AAE3B,MAAMC,YAAYC,IAAAA,kBAAU,EAAC;IAC3BC,QAAQ;QACNC,SAAS;QACTC,WAAW;QACXC,UAAU;IACZ;AACF;AAMO,MAAMN,eAAe,CAACO;IAC3B,MAAMC,SAASP;IAEf,qBACE,qBAACQ;QAAIC,WAAU;qBACb,qBAACD;QAAIC,WAAWF,OAAOL,MAAM;QAAG,GAAGI,KAAK;;AAG9C"}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "FluentDocsContainer", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const
|
|
13
|
+
const _blocks = require("@storybook/addon-docs/blocks");
|
|
14
14
|
const _reacttheme = require("@fluentui/react-theme");
|
|
15
15
|
const _reactprovider = require("@fluentui/react-provider");
|
|
16
16
|
const _utils = require("./utils");
|
|
@@ -22,12 +22,12 @@ const FluentDocsContainer = ({ children, context })=>{
|
|
|
22
22
|
backgroundColor: 'transparent'
|
|
23
23
|
},
|
|
24
24
|
theme: _reacttheme.webLightTheme
|
|
25
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
25
|
+
}, /*#__PURE__*/ _react.createElement(_blocks.DocsContainer, {
|
|
26
26
|
context: context
|
|
27
27
|
}, children)));
|
|
28
28
|
}
|
|
29
29
|
// If docs container is not enabled, fall back to Storybook's default DocsContainer
|
|
30
|
-
return /*#__PURE__*/ _react.createElement(
|
|
30
|
+
return /*#__PURE__*/ _react.createElement(_blocks.DocsContainer, {
|
|
31
31
|
context: context
|
|
32
32
|
}, children);
|
|
33
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/FluentDocsContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DocsContainer, type DocsContextProps } from '@storybook/addon-docs';\nimport { webLightTheme } from '@fluentui/react-theme';\nimport { FluentProvider } from '@fluentui/react-provider';\n\nimport { isDocsEnabled } from './utils';\n\ninterface FluentDocsContainerProps {\n context: DocsContextProps;\n children: React.ReactNode;\n}\n\n/**\n * A container that wraps storybook's native docs container to add extra components to the docs experience\n */\nexport const FluentDocsContainer: React.FC<FluentDocsContainerProps> = ({ children, context }) => {\n if (isDocsEnabled(context)) {\n return (\n <>\n {/** TODO add table of contents */}\n <FluentProvider className=\"sb-unstyled\" style={{ backgroundColor: 'transparent' }} theme={webLightTheme}>\n <DocsContainer context={context}>{children}</DocsContainer>\n </FluentProvider>\n </>\n );\n }\n\n // If docs container is not enabled, fall back to Storybook's default DocsContainer\n return <DocsContainer context={context}>{children}</DocsContainer>;\n};\n"],"names":["FluentDocsContainer","children","context","isDocsEnabled","FluentProvider","className","style","backgroundColor","theme","webLightTheme","DocsContainer"],"mappings":";;;;+BAeaA;;;eAAAA;;;;iEAfU;
|
|
1
|
+
{"version":3,"sources":["../src/docs/FluentDocsContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DocsContainer, type DocsContextProps } from '@storybook/addon-docs/blocks';\nimport { webLightTheme } from '@fluentui/react-theme';\nimport { FluentProvider } from '@fluentui/react-provider';\n\nimport { isDocsEnabled } from './utils';\n\ninterface FluentDocsContainerProps {\n context: DocsContextProps;\n children: React.ReactNode;\n}\n\n/**\n * A container that wraps storybook's native docs container to add extra components to the docs experience\n */\nexport const FluentDocsContainer: React.FC<FluentDocsContainerProps> = ({ children, context }) => {\n if (isDocsEnabled(context)) {\n return (\n <>\n {/** TODO add table of contents */}\n <FluentProvider className=\"sb-unstyled\" style={{ backgroundColor: 'transparent' }} theme={webLightTheme}>\n <DocsContainer context={context}>{children}</DocsContainer>\n </FluentProvider>\n </>\n );\n }\n\n // If docs container is not enabled, fall back to Storybook's default DocsContainer\n return <DocsContainer context={context}>{children}</DocsContainer>;\n};\n"],"names":["FluentDocsContainer","children","context","isDocsEnabled","FluentProvider","className","style","backgroundColor","theme","webLightTheme","DocsContainer"],"mappings":";;;;+BAeaA;;;eAAAA;;;;iEAfU;wBAC8B;4BACvB;+BACC;uBAED;AAUvB,MAAMA,sBAA0D,CAAC,EAAEC,QAAQ,EAAEC,OAAO,EAAE;IAC3F,IAAIC,IAAAA,oBAAa,EAACD,UAAU;QAC1B,qBACE,0DAEE,qBAACE,6BAAc;YAACC,WAAU;YAAcC,OAAO;gBAAEC,iBAAiB;YAAc;YAAGC,OAAOC,yBAAa;yBACrG,qBAACC,qBAAa;YAACR,SAASA;WAAUD;IAI1C;IAEA,mFAAmF;IACnF,qBAAO,qBAACS,qBAAa;QAACR,SAASA;OAAUD;AAC3C"}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "FluentDocsPage", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const
|
|
13
|
+
const _blocks = require("@storybook/addon-docs/blocks");
|
|
14
14
|
const _reacttheme = require("@fluentui/react-theme");
|
|
15
15
|
const _reactlink = require("@fluentui/react-link");
|
|
16
16
|
const _reacttext = require("@fluentui/react-text");
|
|
@@ -141,37 +141,51 @@ const slotRegex = /as\?:\s*"([^"]+)"/;
|
|
|
141
141
|
const hasArgAsProp = options.nativePropsApi ? ((_story_argTypes_as = story.argTypes.as) === null || _story_argTypes_as === void 0 ? void 0 : (_story_argTypes_as_type = _story_argTypes_as.type) === null || _story_argTypes_as_type === void 0 ? void 0 : _story_argTypes_as_type.name) === 'enum' : false;
|
|
142
142
|
const argAsProp = hasArgAsProp ? story.argTypes.as.type.value : null;
|
|
143
143
|
let hasArgAsSlot = false;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
const transformArgTypeNameWithSlotShorthand = (typeName)=>{
|
|
145
|
+
const match = typeName.match(slotRegex);
|
|
146
|
+
if (match) {
|
|
147
|
+
hasArgAsSlot = true;
|
|
148
|
+
return `Slot<\"${match[1]}\">`;
|
|
149
|
+
}
|
|
150
|
+
if (typeName.includes('WithSlotShorthandValue')) {
|
|
151
|
+
hasArgAsSlot = true;
|
|
152
|
+
return `Slot`;
|
|
153
|
+
}
|
|
154
|
+
return typeName;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Transform the arg types with slot shorthand (mutates the arg types object reference)
|
|
158
|
+
* This is necessary to ensure that the arg types are correctly displayed in the docs page
|
|
159
|
+
*/ const transformArgTypesWithSlotShorthand = (argTypes)=>{
|
|
160
|
+
Object.values(argTypes).forEach((argType)=>{
|
|
161
|
+
var _argType_table_type, _argType_table, _argType_type;
|
|
162
|
+
// Transform the type summary if it exists
|
|
163
|
+
if (argType === null || argType === void 0 ? void 0 : (_argType_table = argType.table) === null || _argType_table === void 0 ? void 0 : (_argType_table_type = _argType_table.type) === null || _argType_table_type === void 0 ? void 0 : _argType_table_type.summary) {
|
|
164
|
+
argType.table.type.summary = transformArgTypeNameWithSlotShorthand(argType.table.type.summary);
|
|
154
165
|
}
|
|
155
|
-
if
|
|
156
|
-
|
|
166
|
+
// Transform the type name if it exists
|
|
167
|
+
if (argType === null || argType === void 0 ? void 0 : (_argType_type = argType.type) === null || _argType_type === void 0 ? void 0 : _argType_type.name) {
|
|
168
|
+
argType.type.name = transformArgTypeNameWithSlotShorthand(argType.type.name);
|
|
157
169
|
}
|
|
158
170
|
});
|
|
159
171
|
};
|
|
160
|
-
const
|
|
172
|
+
const transformComponentDocGenProps = (component)=>{
|
|
161
173
|
var _component___docgenInfo;
|
|
162
174
|
const docGenProps = component === null || component === void 0 ? void 0 : (_component___docgenInfo = component.__docgenInfo) === null || _component___docgenInfo === void 0 ? void 0 : _component___docgenInfo.props;
|
|
163
175
|
if (docGenProps) {
|
|
164
|
-
|
|
176
|
+
transformArgTypesWithSlotShorthand(docGenProps);
|
|
165
177
|
}
|
|
166
178
|
};
|
|
167
|
-
const component = story.
|
|
168
|
-
const subcomponents = story.subcomponents;
|
|
179
|
+
const component = story.moduleExport;
|
|
169
180
|
if (options.slotsApi) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
// Transform the arg types with slot shorthand (mutates the arg types object reference)
|
|
182
|
+
transformArgTypesWithSlotShorthand(story.argTypes);
|
|
183
|
+
// Transform the component doc gen props with slot shorthand (mutates the component doc gen props object reference)
|
|
184
|
+
transformComponentDocGenProps(component);
|
|
185
|
+
// Transform the subcomponents doc gen props with slot shorthand
|
|
186
|
+
// (mutates the subcomponents doc gen props object reference)
|
|
187
|
+
if (story.subcomponents) {
|
|
188
|
+
Object.values(story.subcomponents).forEach(transformComponentDocGenProps);
|
|
175
189
|
}
|
|
176
190
|
}
|
|
177
191
|
return {
|
|
@@ -207,7 +221,7 @@ const RenderArgsTable = ({ story, hideArgsTable, showSlotsApi, showNativePropsAp
|
|
|
207
221
|
role: "presentation"
|
|
208
222
|
}, "🙌")), /*#__PURE__*/ _react.createElement("br", null), /*#__PURE__*/ _react.createElement("span", null, "Slots in Fluent UI React components are designed to be modified or replaced, providing a flexible approach to customizing components. Each slot is exposed as a top-level prop and can be filled with primitive values, JSX/TSX, props objects, or render functions. This allows for more dynamic and reusable component structures, similar to slots in other frameworks.", ' ', /*#__PURE__*/ _react.createElement(_reactlink.Link, {
|
|
209
223
|
href: "/?path=/docs/concepts-developer-customizing-components-with-slots--docs"
|
|
210
|
-
}, "Customizing components with slots", ' '))))), /*#__PURE__*/ _react.createElement(
|
|
224
|
+
}, "Customizing components with slots", ' '))))), /*#__PURE__*/ _react.createElement(_blocks.ArgTypes, {
|
|
211
225
|
of: component
|
|
212
226
|
}));
|
|
213
227
|
};
|
|
@@ -215,14 +229,14 @@ const RenderPrimaryStory = ({ primaryStory, skipPrimaryStory })=>{
|
|
|
215
229
|
const styles = useStyles();
|
|
216
230
|
return skipPrimaryStory ? null : /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("hr", {
|
|
217
231
|
className: styles.divider
|
|
218
|
-
}), /*#__PURE__*/ _react.createElement(
|
|
232
|
+
}), /*#__PURE__*/ _react.createElement(_blocks.HeaderMdx, {
|
|
219
233
|
as: "h3",
|
|
220
234
|
id: (0, _Toc.nameToHash)(primaryStory.name)
|
|
221
|
-
}, primaryStory.name), /*#__PURE__*/ _react.createElement(
|
|
235
|
+
}, primaryStory.name), /*#__PURE__*/ _react.createElement(_blocks.Primary, null));
|
|
222
236
|
};
|
|
223
237
|
const FluentDocsPage = ()=>{
|
|
224
238
|
var _primaryStoryContext_parameters, _primaryStoryContext_globals, _primaryStoryContext_parameters_docs, _primaryStoryContext_parameters1, _primaryStoryContext_parameters_docs1, _primaryStoryContext_parameters2, _primaryStoryContext_parameters3;
|
|
225
|
-
const context = _react.useContext(
|
|
239
|
+
const context = _react.useContext(_blocks.DocsContext);
|
|
226
240
|
// Get the fluent docs page configuration from context
|
|
227
241
|
const docsPageConfig = (0, _utils.getDocsPageConfig)(context);
|
|
228
242
|
const stories = context.componentStories();
|
|
@@ -241,13 +255,13 @@ const FluentDocsPage = ()=>{
|
|
|
241
255
|
if (!docsPageConfig) {
|
|
242
256
|
return /*#__PURE__*/ _react.createElement("div", {
|
|
243
257
|
className: "sb-unstyled"
|
|
244
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
258
|
+
}, /*#__PURE__*/ _react.createElement(_blocks.Title, null), /*#__PURE__*/ _react.createElement(_blocks.Subtitle, null), /*#__PURE__*/ _react.createElement(_blocks.Description, null), /*#__PURE__*/ _react.createElement(RenderPrimaryStory, {
|
|
245
259
|
primaryStory: primaryStory,
|
|
246
260
|
skipPrimaryStory: skipPrimaryStory
|
|
247
261
|
}), /*#__PURE__*/ _react.createElement(RenderArgsTable, {
|
|
248
262
|
story: primaryStory,
|
|
249
263
|
hideArgsTable: hideArgsTable
|
|
250
|
-
}), /*#__PURE__*/ _react.createElement(
|
|
264
|
+
}), /*#__PURE__*/ _react.createElement(_blocks.Stories, null));
|
|
251
265
|
}
|
|
252
266
|
// Determine what to show based on configuration
|
|
253
267
|
const { tableOfContents: showTableOfContents, dirSwitcher: showDirSwitcher, themePicker: showThemePicker, copyAsMarkdown: showCopyAsMarkdown, argTable } = docsPageConfig;
|
|
@@ -264,7 +278,7 @@ const FluentDocsPage = ()=>{
|
|
|
264
278
|
// );
|
|
265
279
|
return /*#__PURE__*/ _react.createElement("div", {
|
|
266
280
|
className: "sb-unstyled"
|
|
267
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
281
|
+
}, /*#__PURE__*/ _react.createElement(_blocks.Title, null), /*#__PURE__*/ _react.createElement("div", {
|
|
268
282
|
className: styles.wrapper
|
|
269
283
|
}, /*#__PURE__*/ _react.createElement("div", {
|
|
270
284
|
className: styles.container
|
|
@@ -276,9 +290,9 @@ const FluentDocsPage = ()=>{
|
|
|
276
290
|
dir: dir
|
|
277
291
|
}), showCopyAsMarkdown && /*#__PURE__*/ _react.createElement(_CopyAsMarkdownButton.CopyAsMarkdownButton, {
|
|
278
292
|
storyId: primaryStory.id
|
|
279
|
-
})), /*#__PURE__*/ _react.createElement(
|
|
293
|
+
})), /*#__PURE__*/ _react.createElement(_blocks.Subtitle, null), /*#__PURE__*/ _react.createElement("div", {
|
|
280
294
|
className: styles.description
|
|
281
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
295
|
+
}, /*#__PURE__*/ _react.createElement(_blocks.Description, null), videos && /*#__PURE__*/ _react.createElement(VideoPreviews, {
|
|
282
296
|
videos: videos
|
|
283
297
|
})), /*#__PURE__*/ _react.createElement(RenderPrimaryStory, {
|
|
284
298
|
primaryStory: primaryStory,
|
|
@@ -288,7 +302,7 @@ const FluentDocsPage = ()=>{
|
|
|
288
302
|
hideArgsTable: hideArgsTable,
|
|
289
303
|
showSlotsApi: argTable.slotsApi,
|
|
290
304
|
showNativePropsApi: argTable.nativePropsApi
|
|
291
|
-
}), /*#__PURE__*/ _react.createElement(
|
|
305
|
+
}), /*#__PURE__*/ _react.createElement(_blocks.Stories, null)), showTableOfContents && /*#__PURE__*/ _react.createElement("div", {
|
|
292
306
|
className: styles.toc
|
|
293
307
|
}, /*#__PURE__*/ _react.createElement(_Toc.Toc, {
|
|
294
308
|
stories: stories
|