@fluentui/react-storybook-addon 0.5.0 → 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.
Files changed (95) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/dist/index.d.ts +100 -0
  3. package/lib/components/DirectionSwitch.js +26 -0
  4. package/lib/components/DirectionSwitch.js.map +1 -0
  5. package/lib/components/ReactStrictMode.js +22 -0
  6. package/lib/components/ReactStrictMode.js.map +1 -0
  7. package/lib/components/ThemePicker.js +60 -0
  8. package/lib/components/ThemePicker.js.map +1 -0
  9. package/lib/constants.js +4 -0
  10. package/lib/constants.js.map +1 -0
  11. package/lib/decorators/withAriaLive.js +18 -0
  12. package/lib/decorators/withAriaLive.js.map +1 -0
  13. package/lib/decorators/withFluentProvider.js +48 -0
  14. package/lib/decorators/withFluentProvider.js.map +1 -0
  15. package/lib/decorators/withReactStrictMode.js +16 -0
  16. package/lib/decorators/withReactStrictMode.js.map +1 -0
  17. package/lib/docs/CopyAsMarkdownButton.js +177 -0
  18. package/lib/docs/CopyAsMarkdownButton.js.map +1 -0
  19. package/lib/docs/DirSwitch.js +51 -0
  20. package/lib/docs/DirSwitch.js.map +1 -0
  21. package/lib/docs/FluentCanvas.js +21 -0
  22. package/lib/docs/FluentCanvas.js.map +1 -0
  23. package/lib/docs/FluentDocsContainer.js +24 -0
  24. package/lib/docs/FluentDocsContainer.js.map +1 -0
  25. package/lib/docs/FluentDocsPage.js +308 -0
  26. package/lib/docs/FluentDocsPage.js.map +1 -0
  27. package/lib/docs/FluentStory.js +18 -0
  28. package/lib/docs/FluentStory.js.map +1 -0
  29. package/lib/docs/ThemePicker.js +61 -0
  30. package/lib/docs/ThemePicker.js.map +1 -0
  31. package/lib/docs/Toc.js +130 -0
  32. package/lib/docs/Toc.js.map +1 -0
  33. package/lib/docs/index.js +4 -0
  34. package/lib/docs/index.js.map +1 -0
  35. package/lib/docs/utils.js +74 -0
  36. package/lib/docs/utils.js.map +1 -0
  37. package/lib/hooks.js +16 -0
  38. package/lib/hooks.js.map +1 -0
  39. package/lib/index.js +4 -0
  40. package/lib/index.js.map +1 -0
  41. package/lib/preset/manager.js +25 -0
  42. package/lib/preset/manager.js.map +1 -0
  43. package/lib/preset/preview.js +26 -0
  44. package/lib/preset/preview.js.map +1 -0
  45. package/lib/theme.js +31 -0
  46. package/lib/theme.js.map +1 -0
  47. package/lib/utils/isDecoratorDisabled.js +6 -0
  48. package/lib/utils/isDecoratorDisabled.js.map +1 -0
  49. package/lib-commonjs/components/DirectionSwitch.js +37 -0
  50. package/lib-commonjs/components/DirectionSwitch.js.map +1 -0
  51. package/lib-commonjs/components/ReactStrictMode.js +33 -0
  52. package/lib-commonjs/components/ReactStrictMode.js.map +1 -0
  53. package/lib-commonjs/components/ThemePicker.js +71 -0
  54. package/lib-commonjs/components/ThemePicker.js.map +1 -0
  55. package/lib-commonjs/constants.js +28 -0
  56. package/lib-commonjs/constants.js.map +1 -0
  57. package/lib-commonjs/decorators/withAriaLive.js +29 -0
  58. package/lib-commonjs/decorators/withAriaLive.js.map +1 -0
  59. package/lib-commonjs/decorators/withFluentProvider.js +59 -0
  60. package/lib-commonjs/decorators/withFluentProvider.js.map +1 -0
  61. package/lib-commonjs/decorators/withReactStrictMode.js +27 -0
  62. package/lib-commonjs/decorators/withReactStrictMode.js.map +1 -0
  63. package/lib-commonjs/docs/CopyAsMarkdownButton.js +185 -0
  64. package/lib-commonjs/docs/CopyAsMarkdownButton.js.map +1 -0
  65. package/lib-commonjs/docs/DirSwitch.js +60 -0
  66. package/lib-commonjs/docs/DirSwitch.js.map +1 -0
  67. package/lib-commonjs/docs/FluentCanvas.js +29 -0
  68. package/lib-commonjs/docs/FluentCanvas.js.map +1 -0
  69. package/lib-commonjs/docs/FluentDocsContainer.js +33 -0
  70. package/lib-commonjs/docs/FluentDocsContainer.js.map +1 -0
  71. package/lib-commonjs/docs/FluentDocsPage.js +319 -0
  72. package/lib-commonjs/docs/FluentDocsPage.js.map +1 -0
  73. package/lib-commonjs/docs/FluentStory.js +26 -0
  74. package/lib-commonjs/docs/FluentStory.js.map +1 -0
  75. package/lib-commonjs/docs/ThemePicker.js +70 -0
  76. package/lib-commonjs/docs/ThemePicker.js.map +1 -0
  77. package/lib-commonjs/docs/Toc.js +149 -0
  78. package/lib-commonjs/docs/Toc.js.map +1 -0
  79. package/lib-commonjs/docs/index.js +28 -0
  80. package/lib-commonjs/docs/index.js.map +1 -0
  81. package/lib-commonjs/docs/utils.js +88 -0
  82. package/lib-commonjs/docs/utils.js.map +1 -0
  83. package/lib-commonjs/hooks.js +37 -0
  84. package/lib-commonjs/hooks.js.map +1 -0
  85. package/lib-commonjs/index.js +34 -0
  86. package/lib-commonjs/index.js.map +1 -0
  87. package/lib-commonjs/preset/manager.js +29 -0
  88. package/lib-commonjs/preset/manager.js.map +1 -0
  89. package/lib-commonjs/preset/preview.js +47 -0
  90. package/lib-commonjs/preset/preview.js.map +1 -0
  91. package/lib-commonjs/theme.js +49 -0
  92. package/lib-commonjs/theme.js.map +1 -0
  93. package/lib-commonjs/utils/isDecoratorDisabled.js +16 -0
  94. package/lib-commonjs/utils/isDecoratorDisabled.js.map +1 -0
  95. package/package.json +20 -27
@@ -0,0 +1,130 @@
1
+ import * as React from 'react';
2
+ import { addons } from 'storybook/manager-api';
3
+ import { NAVIGATE_URL } from 'storybook/internal/core-events';
4
+ import { makeStyles } from '@griffel/react';
5
+ const useTocStyles = makeStyles({
6
+ root: {
7
+ top: '64px',
8
+ position: 'sticky',
9
+ marginLeft: '40px'
10
+ },
11
+ heading: {
12
+ fontSize: '11px',
13
+ fontWeight: 'bold',
14
+ textTransform: 'uppercase',
15
+ marginBottom: '20px'
16
+ },
17
+ ol: {
18
+ position: 'relative',
19
+ listStyleType: 'none',
20
+ marginLeft: 0,
21
+ marginTop: 0,
22
+ paddingInlineStart: '20px',
23
+ '& li': {
24
+ marginBottom: '15px',
25
+ lineHeight: '16px'
26
+ },
27
+ '& a': {
28
+ textDecorationLine: 'none',
29
+ color: '#201F1E',
30
+ fontSize: '14px',
31
+ ':hover': {
32
+ color: '#201F1E'
33
+ }
34
+ },
35
+ '&:before': {
36
+ content: '""',
37
+ position: 'absolute',
38
+ left: 0,
39
+ height: '100%',
40
+ width: '3px',
41
+ backgroundColor: '#EDEBE9',
42
+ borderRadius: '4px'
43
+ }
44
+ },
45
+ selected: {
46
+ position: 'relative',
47
+ '&:after': {
48
+ content: '""',
49
+ position: 'absolute',
50
+ left: '-20px',
51
+ top: 0,
52
+ bottom: 0,
53
+ width: '3px',
54
+ backgroundColor: '#436DCD',
55
+ borderRadius: '4px'
56
+ }
57
+ }
58
+ });
59
+ // // Alternative approach to navigate - rerenders the iframe
60
+ // // Usage: selectStory({ story: s.name, kind: s.kind });
61
+ // const selectStory = (story: { kind: string; story: string }) => {
62
+ // console.log('Select Story', story);
63
+ // addons.getChannel().emit(SELECT_STORY, story);
64
+ // };
65
+ const navigate = (url)=>{
66
+ addons.getChannel().emit(NAVIGATE_URL, url);
67
+ };
68
+ export const nameToHash = (id)=>id.toLowerCase().replace(/[^a-z0-9]/gi, '-');
69
+ export const Toc = ({ stories })=>{
70
+ const [selected, setSelected] = React.useState('');
71
+ const isNavigating = React.useRef(false);
72
+ React.useEffect(()=>{
73
+ // eslint-disable-next-line @nx/workspace-no-restricted-globals
74
+ const observer = new IntersectionObserver((entries)=>{
75
+ if (isNavigating.current) {
76
+ isNavigating.current = false;
77
+ return;
78
+ }
79
+ for (const entry of entries){
80
+ const { intersectionRatio, target } = entry;
81
+ if (intersectionRatio > 0.5) {
82
+ setSelected(target.id);
83
+ return;
84
+ }
85
+ }
86
+ }, {
87
+ threshold: [
88
+ 0.5
89
+ ]
90
+ });
91
+ stories.forEach((link)=>{
92
+ // eslint-disable-next-line @nx/workspace-no-restricted-globals
93
+ const element = document.getElementById(nameToHash(link.name));
94
+ if (element) {
95
+ observer.observe(element);
96
+ }
97
+ });
98
+ return ()=>observer.disconnect();
99
+ }, [
100
+ stories
101
+ ]);
102
+ const tocItems = stories.map((item)=>{
103
+ return {
104
+ ...item,
105
+ selected: nameToHash(item.name) === selected
106
+ };
107
+ });
108
+ const tocClasses = useTocStyles();
109
+ return /*#__PURE__*/ React.createElement("nav", {
110
+ className: tocClasses.root
111
+ }, /*#__PURE__*/ React.createElement("h3", {
112
+ className: tocClasses.heading
113
+ }, "On this page"), /*#__PURE__*/ React.createElement("ol", {
114
+ className: tocClasses.ol
115
+ }, tocItems.map((s)=>{
116
+ const name = nameToHash(s.name);
117
+ return /*#__PURE__*/ React.createElement("li", {
118
+ className: s.selected ? tocClasses.selected : '',
119
+ key: s.id
120
+ }, /*#__PURE__*/ React.createElement("a", {
121
+ href: `#${name}`,
122
+ target: "_self",
123
+ onClick: (e)=>{
124
+ isNavigating.current = true;
125
+ navigate(`#${name}`);
126
+ setSelected(name);
127
+ }
128
+ }, s.name));
129
+ })));
130
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/docs/Toc.tsx"],"sourcesContent":["import * as React from 'react';\nimport { addons } from 'storybook/manager-api';\nimport { NAVIGATE_URL } from 'storybook/internal/core-events';\n\nimport { makeStyles } from '@griffel/react';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\nconst useTocStyles = makeStyles({\n root: {\n top: '64px',\n position: 'sticky',\n marginLeft: '40px',\n },\n heading: {\n fontSize: '11px',\n fontWeight: 'bold',\n textTransform: 'uppercase',\n marginBottom: '20px',\n },\n ol: {\n position: 'relative',\n listStyleType: 'none',\n marginLeft: 0,\n marginTop: 0,\n paddingInlineStart: '20px',\n '& li': {\n marginBottom: '15px',\n lineHeight: '16px',\n },\n '& a': {\n textDecorationLine: 'none',\n color: '#201F1E',\n fontSize: '14px',\n ':hover': {\n color: '#201F1E',\n },\n },\n '&:before': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n height: '100%',\n width: '3px',\n backgroundColor: '#EDEBE9',\n borderRadius: '4px',\n },\n },\n selected: {\n position: 'relative',\n '&:after': {\n content: '\"\"',\n position: 'absolute',\n left: '-20px',\n top: 0,\n bottom: 0,\n width: '3px',\n backgroundColor: '#436DCD',\n borderRadius: '4px',\n },\n },\n});\n\ntype TocItem = { name: string; id: string; selected?: boolean };\n\n// // Alternative approach to navigate - rerenders the iframe\n// // Usage: selectStory({ story: s.name, kind: s.kind });\n// const selectStory = (story: { kind: string; story: string }) => {\n// console.log('Select Story', story);\n// addons.getChannel().emit(SELECT_STORY, story);\n// };\n\nconst navigate = (url: string) => {\n addons.getChannel().emit(NAVIGATE_URL, url);\n};\n\nexport const nameToHash = (id: string): string => id.toLowerCase().replace(/[^a-z0-9]/gi, '-');\n\nexport const Toc = ({ stories }: { stories: TocItem[] }): JSXElement => {\n const [selected, setSelected] = React.useState('');\n const isNavigating = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n // eslint-disable-next-line @nx/workspace-no-restricted-globals\n const observer = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) => {\n if (isNavigating.current) {\n isNavigating.current = false;\n return;\n }\n for (const entry of entries) {\n const { intersectionRatio, target } = entry;\n if (intersectionRatio > 0.5) {\n setSelected(target.id);\n return;\n }\n }\n },\n {\n threshold: [0.5],\n },\n );\n\n stories.forEach(link => {\n // eslint-disable-next-line @nx/workspace-no-restricted-globals\n const element = document.getElementById(nameToHash(link.name));\n if (element) {\n observer.observe(element);\n }\n });\n\n return () => observer.disconnect();\n }, [stories]);\n\n const tocItems = stories.map(item => {\n return { ...item, selected: nameToHash(item.name) === selected };\n });\n const tocClasses = useTocStyles();\n return (\n <nav className={tocClasses.root}>\n <h3 className={tocClasses.heading}>On this page</h3>\n <ol className={tocClasses.ol}>\n {tocItems.map(s => {\n const name = nameToHash(s.name);\n return (\n <li className={s.selected ? tocClasses.selected : ''} key={s.id}>\n <a\n href={`#${name}`}\n target=\"_self\"\n onClick={e => {\n isNavigating.current = true;\n navigate(`#${name}`);\n setSelected(name);\n }}\n >\n {s.name}\n </a>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n};\n"],"names":["React","addons","NAVIGATE_URL","makeStyles","useTocStyles","root","top","position","marginLeft","heading","fontSize","fontWeight","textTransform","marginBottom","ol","listStyleType","marginTop","paddingInlineStart","lineHeight","textDecorationLine","color","content","left","height","width","backgroundColor","borderRadius","selected","bottom","navigate","url","getChannel","emit","nameToHash","id","toLowerCase","replace","Toc","stories","setSelected","useState","isNavigating","useRef","useEffect","observer","IntersectionObserver","entries","current","entry","intersectionRatio","target","threshold","forEach","link","element","document","getElementById","name","observe","disconnect","tocItems","map","item","tocClasses","nav","className","h3","s","li","key","a","href","onClick","e"],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { FluentCanvas } from './FluentCanvas';
2
+ export { FluentDocsContainer } from './FluentDocsContainer';
3
+ export { FluentDocsPage } from './FluentDocsPage';
4
+ export { FluentStory } from './FluentStory';
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,74 @@
1
+ const docsDefaults = {
2
+ copyAsMarkdown: true,
3
+ tableOfContents: true,
4
+ dirSwitcher: true,
5
+ themePicker: true,
6
+ argTable: {
7
+ slotsApi: true,
8
+ nativePropsApi: true
9
+ }
10
+ };
11
+ function getDocsParametersConfig(context) {
12
+ var _context_projectAnnotations_parameters_reactStorybookAddon, _context_projectAnnotations_parameters, _context_projectAnnotations;
13
+ return context === null || context === void 0 ? void 0 : (_context_projectAnnotations = context.projectAnnotations) === null || _context_projectAnnotations === void 0 ? void 0 : (_context_projectAnnotations_parameters = _context_projectAnnotations.parameters) === null || _context_projectAnnotations_parameters === void 0 ? void 0 : (_context_projectAnnotations_parameters_reactStorybookAddon = _context_projectAnnotations_parameters.reactStorybookAddon) === null || _context_projectAnnotations_parameters_reactStorybookAddon === void 0 ? void 0 : _context_projectAnnotations_parameters_reactStorybookAddon.docs;
14
+ }
15
+ /**
16
+ * Checks if the docs page is enabled
17
+ */ export function isDocsEnabled(context) {
18
+ const docsConfig = getDocsParametersConfig(context);
19
+ // If docs is true, enable page
20
+ if (docsConfig === true) {
21
+ return true;
22
+ }
23
+ // If docs is an object, page is enabled
24
+ if (typeof docsConfig === 'object' && docsConfig !== null) {
25
+ return true;
26
+ }
27
+ // Default: disabled
28
+ return false;
29
+ }
30
+ /**
31
+ * Gets the docs page configuration from context
32
+ */ export function getDocsPageConfig(context) {
33
+ const docsConfig = getDocsParametersConfig(context);
34
+ // If docs is true, return default config (all enabled)
35
+ if (docsConfig === true) {
36
+ return docsDefaults;
37
+ }
38
+ // If docs is an object, extract the configuration directly
39
+ if (typeof docsConfig === 'object' && docsConfig !== null) {
40
+ return {
41
+ copyAsMarkdown: docsConfig.copyAsMarkdown !== false,
42
+ tableOfContents: docsConfig.tableOfContents !== false,
43
+ dirSwitcher: docsConfig.dirSwitcher !== false,
44
+ themePicker: docsConfig.themePicker !== false,
45
+ argTable: getArgTableConfig(docsConfig.argTable)
46
+ };
47
+ }
48
+ // Fallback
49
+ return null;
50
+ }
51
+ /**
52
+ * Gets the argTable configuration with early exit pattern
53
+ */ function getArgTableConfig(argTableConfig) {
54
+ if (argTableConfig === false) {
55
+ return {
56
+ slotsApi: false,
57
+ nativePropsApi: false
58
+ };
59
+ }
60
+ if (argTableConfig === true || argTableConfig === undefined) {
61
+ return {
62
+ slotsApi: true,
63
+ nativePropsApi: true
64
+ };
65
+ }
66
+ if (typeof argTableConfig === 'object' && argTableConfig !== null) {
67
+ return {
68
+ slotsApi: argTableConfig.slotsApi !== false,
69
+ nativePropsApi: argTableConfig.nativePropsApi !== false
70
+ };
71
+ }
72
+ // Fallback to default
73
+ return docsDefaults.argTable;
74
+ }
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,16 @@
1
+ import { useGlobals as useStorybookGlobals } from 'storybook/manager-api';
2
+ export function useGlobals() {
3
+ return useStorybookGlobals();
4
+ }
5
+ export function parameters(options) {
6
+ return {
7
+ dir: 'ltr',
8
+ fluentTheme: 'web-light',
9
+ mode: 'default',
10
+ ...options
11
+ };
12
+ }
13
+ export function getParametersConfig(context) {
14
+ var _context_parameters;
15
+ return context === null || context === void 0 ? void 0 : (_context_parameters = context.parameters) === null || _context_parameters === void 0 ? void 0 : _context_parameters.reactStorybookAddon;
16
+ }
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,4 @@
1
+ export { themes } from './theme';
2
+ export { DIR_ID, THEME_ID } from './constants';
3
+ export { parameters } from './hooks';
4
+ export { FluentCanvas, FluentStory } from './docs';
@@ -0,0 +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';\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"}
@@ -0,0 +1,25 @@
1
+ import { addons, types } from 'storybook/manager-api';
2
+ import { ADDON_ID, DIR_ID, STRICT_MODE_ID, THEME_ID } from '../constants';
3
+ import { ThemePicker } from '../components/ThemePicker';
4
+ import { ReactStrictMode } from '../components/ReactStrictMode';
5
+ import { DirectionSwitch } from '../components/DirectionSwitch';
6
+ addons.register(ADDON_ID, ()=>{
7
+ addons.add(THEME_ID, {
8
+ title: 'Fluent Theme Picker',
9
+ type: types.TOOL,
10
+ match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
11
+ render: ThemePicker
12
+ });
13
+ addons.add(DIR_ID, {
14
+ title: 'Direction Switch',
15
+ type: types.TOOL,
16
+ match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
17
+ render: DirectionSwitch
18
+ });
19
+ addons.add(STRICT_MODE_ID, {
20
+ type: types.TOOL,
21
+ title: 'React Strict Mode',
22
+ match: ({ viewMode })=>!!(viewMode && viewMode.match(/^(story|docs)$/)),
23
+ render: ReactStrictMode
24
+ });
25
+ });
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,26 @@
1
+ import { withFluentProvider } from '../decorators/withFluentProvider';
2
+ import { withReactStrictMode } from '../decorators/withReactStrictMode';
3
+ import { withAriaLive } from '../decorators/withAriaLive';
4
+ import { FluentDocsContainer, FluentDocsPage } from '../docs';
5
+ import { DIR_ID, STRICT_MODE_ID, THEME_ID } from '../constants';
6
+ export const decorators = [
7
+ withFluentProvider,
8
+ withAriaLive,
9
+ withReactStrictMode
10
+ ];
11
+ export const initialGlobals = {
12
+ [THEME_ID]: undefined,
13
+ [DIR_ID]: undefined,
14
+ [STRICT_MODE_ID]: undefined
15
+ }; // allow theme to be set by URL query param
16
+ const preview = {
17
+ decorators,
18
+ initialGlobals,
19
+ parameters: {
20
+ docs: {
21
+ container: FluentDocsContainer,
22
+ page: FluentDocsPage
23
+ }
24
+ }
25
+ };
26
+ export default preview;
@@ -0,0 +1 @@
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"}
package/lib/theme.js ADDED
@@ -0,0 +1,31 @@
1
+ export const themes = [
2
+ {
3
+ id: 'web-light',
4
+ label: 'Web Light'
5
+ },
6
+ {
7
+ id: 'web-dark',
8
+ label: 'Web Dark'
9
+ },
10
+ {
11
+ id: 'teams-light',
12
+ label: 'Teams Light'
13
+ },
14
+ {
15
+ id: 'teams-dark',
16
+ label: 'Teams Dark'
17
+ },
18
+ {
19
+ id: 'teams-light-v21',
20
+ label: 'Teams Light V2.1'
21
+ },
22
+ {
23
+ id: 'teams-dark-v21',
24
+ label: 'Teams Dark V2.1'
25
+ },
26
+ {
27
+ id: 'teams-high-contrast',
28
+ label: 'Teams High Contrast'
29
+ }
30
+ ];
31
+ export const defaultTheme = themes[0];
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/theme.ts"],"sourcesContent":["export const themes = [\n { id: 'web-light', label: 'Web Light' },\n { id: 'web-dark', label: 'Web Dark' },\n { id: 'teams-light', label: 'Teams Light' },\n { id: 'teams-dark', label: 'Teams Dark' },\n { id: 'teams-light-v21', label: 'Teams Light V2.1' },\n { id: 'teams-dark-v21', label: 'Teams Dark V2.1' },\n { id: 'teams-high-contrast', label: 'Teams High Contrast' },\n] as const;\n\nexport const defaultTheme = themes[0];\n\nexport type ThemeIds = (typeof themes)[number]['id'];\nexport type ThemeLabels = (typeof themes)[number]['label'];\n"],"names":["themes","id","label","defaultTheme"],"mappings":"AAAA,OAAO,MAAMA,SAAS;IACpB;QAAEC,IAAI;QAAaC,OAAO;IAAY;IACtC;QAAED,IAAI;QAAYC,OAAO;IAAW;IACpC;QAAED,IAAI;QAAeC,OAAO;IAAc;IAC1C;QAAED,IAAI;QAAcC,OAAO;IAAa;IACxC;QAAED,IAAI;QAAmBC,OAAO;IAAmB;IACnD;QAAED,IAAI;QAAkBC,OAAO;IAAkB;IACjD;QAAED,IAAI;QAAuBC,OAAO;IAAsB;CAC3D,CAAU;AAEX,OAAO,MAAMC,eAAeH,MAAM,CAAC,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { getParametersConfig } from '../hooks';
2
+ export function isDecoratorDisabled(context, decoratorName) {
3
+ var _getParametersConfig_disabledDecorators, _getParametersConfig;
4
+ var _getParametersConfig_disabledDecorators_includes;
5
+ return (_getParametersConfig_disabledDecorators_includes = (_getParametersConfig = getParametersConfig(context)) === null || _getParametersConfig === void 0 ? void 0 : (_getParametersConfig_disabledDecorators = _getParametersConfig.disabledDecorators) === null || _getParametersConfig_disabledDecorators === void 0 ? void 0 : _getParametersConfig_disabledDecorators.includes(decoratorName)) !== null && _getParametersConfig_disabledDecorators_includes !== void 0 ? _getParametersConfig_disabledDecorators_includes : false;
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/isDecoratorDisabled.ts"],"sourcesContent":["import { getParametersConfig, type FluentParameters, type FluentStoryContext } from '../hooks';\n\ntype DecoratorName = NonNullable<NonNullable<FluentParameters['reactStorybookAddon']>['disabledDecorators']>[number];\n\nexport function isDecoratorDisabled(context: FluentStoryContext, decoratorName: DecoratorName): boolean {\n return getParametersConfig(context)?.disabledDecorators?.includes(decoratorName) ?? false;\n}\n"],"names":["getParametersConfig","isDecoratorDisabled","context","decoratorName","disabledDecorators","includes"],"mappings":"AAAA,SAASA,mBAAmB,QAAwD,WAAW;AAI/F,OAAO,SAASC,oBAAoBC,OAA2B,EAAEC,aAA4B;QACpFH,yCAAAA;QAAAA;IAAP,OAAOA,CAAAA,oDAAAA,uBAAAA,oBAAoBE,sBAApBF,4CAAAA,0CAAAA,qBAA8BI,kBAAkB,cAAhDJ,8DAAAA,wCAAkDK,QAAQ,CAACF,4BAA3DH,8DAAAA,mDAA6E;AACtF"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DirectionSwitch", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DirectionSwitch;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _components = require("storybook/internal/components");
14
+ const _theming = require("storybook/theming");
15
+ const _constants = require("../constants");
16
+ const _hooks = require("../hooks");
17
+ const Monospace = _theming.styled.span({
18
+ fontFamily: "'Cascadia Code', Menlo, 'Courier New', Courier, monospace",
19
+ letterSpacing: '-0.05em'
20
+ });
21
+ const DirectionSwitch = ()=>{
22
+ const [globals, updateGlobals] = (0, _hooks.useGlobals)();
23
+ var _globals_DIR_ID;
24
+ const direction = (_globals_DIR_ID = globals[_constants.DIR_ID]) !== null && _globals_DIR_ID !== void 0 ? _globals_DIR_ID : 'ltr';
25
+ const isLTR = direction === 'ltr';
26
+ const toggleDirection = _react.useCallback(()=>updateGlobals({
27
+ [_constants.DIR_ID]: isLTR ? 'rtl' : 'ltr'
28
+ }), [
29
+ isLTR,
30
+ updateGlobals
31
+ ]);
32
+ return /*#__PURE__*/ _react.createElement(_components.IconButton, {
33
+ key: _constants.DIR_ID,
34
+ title: "Change Direction",
35
+ onClick: toggleDirection
36
+ }, /*#__PURE__*/ _react.createElement("div", null, "Direction: ", /*#__PURE__*/ _react.createElement(Monospace, null, direction.toUpperCase())));
37
+ };
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ReactStrictMode", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ReactStrictMode;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _components = require("storybook/internal/components");
14
+ const _icons = require("@storybook/icons");
15
+ const _constants = require("../constants");
16
+ const _hooks = require("../hooks");
17
+ const ReactStrictMode = ()=>{
18
+ const [globals, updateGlobals] = (0, _hooks.useGlobals)();
19
+ var _globals_STRICT_MODE_ID;
20
+ const isActive = (_globals_STRICT_MODE_ID = globals[_constants.STRICT_MODE_ID]) !== null && _globals_STRICT_MODE_ID !== void 0 ? _globals_STRICT_MODE_ID : false;
21
+ const toggleStrictMode = _react.useCallback(()=>updateGlobals({
22
+ [_constants.STRICT_MODE_ID]: !isActive
23
+ }), [
24
+ isActive,
25
+ updateGlobals
26
+ ]);
27
+ return /*#__PURE__*/ _react.createElement(_components.IconButton, {
28
+ key: _constants.STRICT_MODE_ID,
29
+ active: isActive,
30
+ title: "Toggle React Strict mode",
31
+ onClick: toggleStrictMode
32
+ }, /*#__PURE__*/ _react.createElement(_icons.LockIcon, null));
33
+ };
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ThemePicker", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ThemePicker;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _components = require("storybook/internal/components");
14
+ const _icons = require("@storybook/icons");
15
+ const _managerapi = require("storybook/manager-api");
16
+ const _theme = require("../theme");
17
+ const _constants = require("../constants");
18
+ const _hooks = require("../hooks");
19
+ function createThemeItems(value, changeTheme, getCurrentTheme) {
20
+ return value.map((item)=>{
21
+ return {
22
+ id: item.id,
23
+ title: item.id === _theme.defaultTheme.id ? `${item.label} (Default)` : item.label,
24
+ onClick: ()=>{
25
+ changeTheme(item.id);
26
+ },
27
+ value: item.id,
28
+ active: getCurrentTheme() === item.id
29
+ };
30
+ });
31
+ }
32
+ const ThemePicker = ()=>{
33
+ const [globals, updateGlobals] = (0, _hooks.useGlobals)();
34
+ const fluentTheme = (0, _managerapi.useParameter)('fluentTheme');
35
+ var _globals_THEME_ID;
36
+ const selectedThemeId = fluentTheme ? fluentTheme : (_globals_THEME_ID = globals[_constants.THEME_ID]) !== null && _globals_THEME_ID !== void 0 ? _globals_THEME_ID : _theme.defaultTheme.id;
37
+ const selectedTheme = _theme.themes.find((entry)=>entry.id === selectedThemeId);
38
+ const isActive = selectedThemeId !== _theme.defaultTheme.id;
39
+ const setTheme = _react.useCallback((id)=>{
40
+ updateGlobals({
41
+ [_constants.THEME_ID]: id
42
+ });
43
+ }, [
44
+ updateGlobals
45
+ ]);
46
+ const renderTooltip = _react.useCallback((props)=>{
47
+ return /*#__PURE__*/ _react.createElement(_components.TooltipLinkList, {
48
+ links: createThemeItems(_theme.themes, (id)=>{
49
+ setTheme(id);
50
+ props.onHide();
51
+ }, ()=>selectedThemeId)
52
+ });
53
+ }, [
54
+ selectedThemeId,
55
+ setTheme
56
+ ]);
57
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement(_components.WithTooltip, {
58
+ placement: "top",
59
+ trigger: "click",
60
+ closeOnOutsideClick: true,
61
+ tooltip: renderTooltip
62
+ }, /*#__PURE__*/ _react.createElement(_components.IconButton, {
63
+ key: _constants.THEME_ID,
64
+ title: "Change Fluent theme",
65
+ active: isActive
66
+ }, /*#__PURE__*/ _react.createElement(_icons.ArrowDownIcon, null), /*#__PURE__*/ _react.createElement("span", {
67
+ style: {
68
+ marginLeft: 5
69
+ }
70
+ }, "Theme: ", selectedTheme === null || selectedTheme === void 0 ? void 0 : selectedTheme.label))));
71
+ };
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ ADDON_ID: function() {
13
+ return ADDON_ID;
14
+ },
15
+ DIR_ID: function() {
16
+ return DIR_ID;
17
+ },
18
+ STRICT_MODE_ID: function() {
19
+ return STRICT_MODE_ID;
20
+ },
21
+ THEME_ID: function() {
22
+ return THEME_ID;
23
+ }
24
+ });
25
+ const ADDON_ID = 'storybook_fluentui-react-addon';
26
+ const DIR_ID = `${ADDON_ID}_dir`;
27
+ const STRICT_MODE_ID = `${ADDON_ID}_strict-mode`;
28
+ const THEME_ID = `${ADDON_ID}_theme`;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const ADDON_ID = 'storybook_fluentui-react-addon';\n\nexport const DIR_ID = `${ADDON_ID}_dir` as const;\nexport const STRICT_MODE_ID = `${ADDON_ID}_strict-mode` as const;\nexport const THEME_ID = `${ADDON_ID}_theme` as const;\n"],"names":["ADDON_ID","DIR_ID","STRICT_MODE_ID","THEME_ID"],"mappings":";;;;;;;;;;;IAAaA,QAAQ;eAARA;;IAEAC,MAAM;eAANA;;IACAC,cAAc;eAAdA;;IACAC,QAAQ;eAARA;;;AAJN,MAAMH,WAAW;AAEjB,MAAMC,SAAS,GAAGD,SAAS,IAAI,CAAC;AAChC,MAAME,iBAAiB,GAAGF,SAAS,YAAY,CAAC;AAChD,MAAMG,WAAW,GAAGH,SAAS,MAAM,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "withAriaLive", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return withAriaLive;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _reactaria = require("@fluentui/react-aria");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
+ const _isDecoratorDisabled = require("../utils/isDecoratorDisabled");
15
+ const withAriaLive = (Story, context)=>{
16
+ if ((0, _isDecoratorDisabled.isDecoratorDisabled)(context, 'AriaLive')) {
17
+ return Story();
18
+ }
19
+ return /*#__PURE__*/ _react.createElement(AriaLiveWrapper, null, /*#__PURE__*/ _react.createElement(Story, null));
20
+ };
21
+ const AriaLiveWrapper = (props)=>{
22
+ const [mounted, setMounted] = _react.useState(false);
23
+ _react.useEffect(()=>{
24
+ // The AriaLiveAnnouncer appends an element to DOM in an effect
25
+ // Trigger an extra renderer to make sure that doc examples that need to announce on mount can do so
26
+ setMounted(true);
27
+ }, []);
28
+ return /*#__PURE__*/ _react.createElement(_reactaria.AriaLiveAnnouncer, null, mounted && props.children);
29
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/decorators/withAriaLive.tsx"],"sourcesContent":["import { AriaLiveAnnouncer } from '@fluentui/react-aria';\nimport * as React from 'react';\n\nimport type { FluentStoryContext } from '../hooks';\nimport { isDecoratorDisabled } from '../utils/isDecoratorDisabled';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\nexport const withAriaLive = (Story: () => JSXElement, context: FluentStoryContext): JSXElement => {\n if (isDecoratorDisabled(context, 'AriaLive')) {\n return Story();\n }\n\n return (\n <AriaLiveWrapper>\n <Story />\n </AriaLiveWrapper>\n );\n};\n\nconst AriaLiveWrapper: React.FC<{ children: React.ReactNode }> = props => {\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n // The AriaLiveAnnouncer appends an element to DOM in an effect\n // Trigger an extra renderer to make sure that doc examples that need to announce on mount can do so\n setMounted(true);\n }, []);\n\n return <AriaLiveAnnouncer>{mounted && props.children}</AriaLiveAnnouncer>;\n};\n"],"names":["withAriaLive","Story","context","isDecoratorDisabled","AriaLiveWrapper","props","mounted","setMounted","React","useState","useEffect","AriaLiveAnnouncer","children"],"mappings":";;;;+BAOaA;;;eAAAA;;;;2BAPqB;iEACX;qCAGa;AAG7B,MAAMA,eAAe,CAACC,OAAyBC;IACpD,IAAIC,IAAAA,wCAAmB,EAACD,SAAS,aAAa;QAC5C,OAAOD;IACT;IAEA,qBACE,qBAACG,qCACC,qBAACH;AAGP;AAEA,MAAMG,kBAA2DC,CAAAA;IAC/D,MAAM,CAACC,SAASC,WAAW,GAAGC,OAAMC,QAAQ,CAAC;IAE7CD,OAAME,SAAS,CAAC;QACd,+DAA+D;QAC/D,oGAAoG;QACpGH,WAAW;IACb,GAAG,EAAE;IAEL,qBAAO,qBAACI,4BAAiB,QAAEL,WAAWD,MAAMO,QAAQ;AACtD"}