@fluentui/react-storybook-addon 0.4.1 → 0.4.2
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 +19 -2
- package/package.json +10 -10
- package/dist/index.d.ts +0 -86
- package/lib/components/DirectionSwitch.js +0 -26
- package/lib/components/DirectionSwitch.js.map +0 -1
- package/lib/components/ReactStrictMode.js +0 -23
- package/lib/components/ReactStrictMode.js.map +0 -1
- package/lib/components/ThemePicker.js +0 -61
- package/lib/components/ThemePicker.js.map +0 -1
- package/lib/constants.js +0 -4
- package/lib/constants.js.map +0 -1
- package/lib/decorators/withAriaLive.js +0 -18
- package/lib/decorators/withAriaLive.js.map +0 -1
- package/lib/decorators/withFluentProvider.js +0 -48
- package/lib/decorators/withFluentProvider.js.map +0 -1
- package/lib/decorators/withReactStrictMode.js +0 -16
- package/lib/decorators/withReactStrictMode.js.map +0 -1
- package/lib/docs/DirSwitch.js +0 -51
- package/lib/docs/DirSwitch.js.map +0 -1
- package/lib/docs/FluentDocsContainer.js +0 -24
- package/lib/docs/FluentDocsContainer.js.map +0 -1
- package/lib/docs/FluentDocsPage.js +0 -296
- package/lib/docs/FluentDocsPage.js.map +0 -1
- package/lib/docs/ThemePicker.js +0 -61
- package/lib/docs/ThemePicker.js.map +0 -1
- package/lib/docs/Toc.js +0 -130
- package/lib/docs/Toc.js.map +0 -1
- package/lib/docs/index.js +0 -2
- package/lib/docs/index.js.map +0 -1
- package/lib/docs/utils.js +0 -72
- package/lib/docs/utils.js.map +0 -1
- package/lib/hooks.js +0 -16
- package/lib/hooks.js.map +0 -1
- package/lib/index.js +0 -3
- package/lib/index.js.map +0 -1
- package/lib/preset/manager.js +0 -28
- package/lib/preset/manager.js.map +0 -1
- package/lib/preset/preview.js +0 -26
- package/lib/preset/preview.js.map +0 -1
- package/lib/theme.js +0 -31
- package/lib/theme.js.map +0 -1
- package/lib/utils/isDecoratorDisabled.js +0 -6
- package/lib/utils/isDecoratorDisabled.js.map +0 -1
- package/lib-commonjs/components/DirectionSwitch.js +0 -37
- package/lib-commonjs/components/DirectionSwitch.js.map +0 -1
- package/lib-commonjs/components/ReactStrictMode.js +0 -34
- package/lib-commonjs/components/ReactStrictMode.js.map +0 -1
- package/lib-commonjs/components/ThemePicker.js +0 -72
- package/lib-commonjs/components/ThemePicker.js.map +0 -1
- package/lib-commonjs/constants.js +0 -28
- package/lib-commonjs/constants.js.map +0 -1
- package/lib-commonjs/decorators/withAriaLive.js +0 -29
- package/lib-commonjs/decorators/withAriaLive.js.map +0 -1
- package/lib-commonjs/decorators/withFluentProvider.js +0 -59
- package/lib-commonjs/decorators/withFluentProvider.js.map +0 -1
- package/lib-commonjs/decorators/withReactStrictMode.js +0 -27
- package/lib-commonjs/decorators/withReactStrictMode.js.map +0 -1
- package/lib-commonjs/docs/DirSwitch.js +0 -60
- package/lib-commonjs/docs/DirSwitch.js.map +0 -1
- package/lib-commonjs/docs/FluentDocsContainer.js +0 -33
- package/lib-commonjs/docs/FluentDocsContainer.js.map +0 -1
- package/lib-commonjs/docs/FluentDocsPage.js +0 -307
- package/lib-commonjs/docs/FluentDocsPage.js.map +0 -1
- package/lib-commonjs/docs/ThemePicker.js +0 -70
- package/lib-commonjs/docs/ThemePicker.js.map +0 -1
- package/lib-commonjs/docs/Toc.js +0 -149
- package/lib-commonjs/docs/Toc.js.map +0 -1
- package/lib-commonjs/docs/index.js +0 -20
- package/lib-commonjs/docs/index.js.map +0 -1
- package/lib-commonjs/docs/utils.js +0 -86
- package/lib-commonjs/docs/utils.js.map +0 -1
- package/lib-commonjs/hooks.js +0 -37
- package/lib-commonjs/hooks.js.map +0 -1
- package/lib-commonjs/index.js +0 -27
- package/lib-commonjs/index.js.map +0 -1
- package/lib-commonjs/preset/manager.js +0 -32
- package/lib-commonjs/preset/manager.js.map +0 -1
- package/lib-commonjs/preset/preview.js +0 -47
- package/lib-commonjs/preset/preview.js.map +0 -1
- package/lib-commonjs/theme.js +0 -49
- package/lib-commonjs/theme.js.map +0 -1
- package/lib-commonjs/utils/isDecoratorDisabled.js +0 -16
- package/lib-commonjs/utils/isDecoratorDisabled.js.map +0 -1
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DirSwitch", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DirSwitch;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _previewapi = require("@storybook/preview-api");
|
|
14
|
-
const _reactlabel = require("@fluentui/react-label");
|
|
15
|
-
const _reactswitch = require("@fluentui/react-switch");
|
|
16
|
-
const _reactutilities = require("@fluentui/react-utilities");
|
|
17
|
-
const _reacttheme = require("@fluentui/react-theme");
|
|
18
|
-
const _react1 = require("@griffel/react");
|
|
19
|
-
const _constants = require("../constants");
|
|
20
|
-
const useStyles = (0, _react1.makeStyles)({
|
|
21
|
-
container: {
|
|
22
|
-
alignItems: 'center',
|
|
23
|
-
display: 'flex',
|
|
24
|
-
justifyContent: 'start'
|
|
25
|
-
},
|
|
26
|
-
label: {
|
|
27
|
-
..._reacttheme.typographyStyles.subtitle2
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const DirSwitch = ({ dir })=>{
|
|
31
|
-
const switchId = (0, _reactutilities.useId)('dir-switch');
|
|
32
|
-
const styles = useStyles();
|
|
33
|
-
const [currentDir, setCurrentDir] = _react.useState(dir);
|
|
34
|
-
const checked = currentDir === 'rtl';
|
|
35
|
-
const setGlobalDir = (newDir)=>{
|
|
36
|
-
_previewapi.addons.getChannel().emit('updateGlobals', {
|
|
37
|
-
globals: {
|
|
38
|
-
[_constants.DIR_ID]: newDir
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
const onChange = _react.useCallback((_, data)=>{
|
|
43
|
-
const newDir = data.checked ? 'rtl' : 'ltr';
|
|
44
|
-
setGlobalDir(newDir);
|
|
45
|
-
setCurrentDir(newDir);
|
|
46
|
-
}, []);
|
|
47
|
-
return /*#__PURE__*/ _react.createElement("div", {
|
|
48
|
-
className: styles.container
|
|
49
|
-
}, /*#__PURE__*/ _react.createElement(_reactlabel.Label, {
|
|
50
|
-
className: styles.label,
|
|
51
|
-
htmlFor: currentDir === 'ltr' ? undefined : switchId
|
|
52
|
-
}, "LTR"), /*#__PURE__*/ _react.createElement(_reactswitch.Switch, {
|
|
53
|
-
checked: checked,
|
|
54
|
-
id: switchId,
|
|
55
|
-
onChange: onChange
|
|
56
|
-
}), /*#__PURE__*/ _react.createElement(_reactlabel.Label, {
|
|
57
|
-
className: styles.label,
|
|
58
|
-
htmlFor: currentDir === 'rtl' ? switchId : undefined
|
|
59
|
-
}, "RTL"));
|
|
60
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "FluentDocsContainer", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return FluentDocsContainer;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _addondocs = require("@storybook/addon-docs");
|
|
14
|
-
const _reacttheme = require("@fluentui/react-theme");
|
|
15
|
-
const _reactprovider = require("@fluentui/react-provider");
|
|
16
|
-
const _utils = require("./utils");
|
|
17
|
-
const FluentDocsContainer = ({ children, context })=>{
|
|
18
|
-
if ((0, _utils.isDocsEnabled)(context)) {
|
|
19
|
-
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement(_reactprovider.FluentProvider, {
|
|
20
|
-
className: "sb-unstyled",
|
|
21
|
-
style: {
|
|
22
|
-
backgroundColor: 'transparent'
|
|
23
|
-
},
|
|
24
|
-
theme: _reacttheme.webLightTheme
|
|
25
|
-
}, /*#__PURE__*/ _react.createElement(_addondocs.DocsContainer, {
|
|
26
|
-
context: context
|
|
27
|
-
}, children)));
|
|
28
|
-
}
|
|
29
|
-
// If docs container is not enabled, fall back to Storybook's default DocsContainer
|
|
30
|
-
return /*#__PURE__*/ _react.createElement(_addondocs.DocsContainer, {
|
|
31
|
-
context: context
|
|
32
|
-
}, children);
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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;2BAC8B;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,wBAAa;YAACR,SAASA;WAAUD;IAI1C;IAEA,mFAAmF;IACnF,qBAAO,qBAACS,wBAAa;QAACR,SAASA;OAAUD;AAC3C"}
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "FluentDocsPage", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return FluentDocsPage;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
-
const _addondocs = require("@storybook/addon-docs");
|
|
14
|
-
const _reacttheme = require("@fluentui/react-theme");
|
|
15
|
-
const _reactlink = require("@fluentui/react-link");
|
|
16
|
-
const _reacttext = require("@fluentui/react-text");
|
|
17
|
-
const _react1 = require("@griffel/react");
|
|
18
|
-
const _reacticons = require("@fluentui/react-icons");
|
|
19
|
-
const _constants = require("../constants");
|
|
20
|
-
const _theme = require("../theme");
|
|
21
|
-
const _utils = require("./utils");
|
|
22
|
-
const _DirSwitch = require("./DirSwitch");
|
|
23
|
-
const _ThemePicker = require("./ThemePicker");
|
|
24
|
-
const _Toc = require("./Toc");
|
|
25
|
-
const useStyles = (0, _react1.makeStyles)({
|
|
26
|
-
divider: {
|
|
27
|
-
height: '1px',
|
|
28
|
-
backgroundColor: '#e1dfdd',
|
|
29
|
-
border: '0px none',
|
|
30
|
-
margin: '48px 0px'
|
|
31
|
-
},
|
|
32
|
-
wrapper: {
|
|
33
|
-
display: 'flex',
|
|
34
|
-
gap: '16px'
|
|
35
|
-
},
|
|
36
|
-
toc: {
|
|
37
|
-
flexBasis: '200px',
|
|
38
|
-
flexShrink: 0,
|
|
39
|
-
[`@media screen and (max-width: 1000px)`]: {
|
|
40
|
-
display: 'none'
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
container: {
|
|
44
|
-
// without a width, this div grows wider than its parent
|
|
45
|
-
width: '200px',
|
|
46
|
-
flexGrow: 1
|
|
47
|
-
},
|
|
48
|
-
globalTogglesContainer: {
|
|
49
|
-
columnGap: _reacttheme.tokens.spacingHorizontalXXXL,
|
|
50
|
-
display: 'flex'
|
|
51
|
-
},
|
|
52
|
-
description: {
|
|
53
|
-
display: 'grid',
|
|
54
|
-
gridTemplateColumns: '1fr min-content'
|
|
55
|
-
},
|
|
56
|
-
additionalInfoWrapper: {
|
|
57
|
-
display: 'flex',
|
|
58
|
-
flexDirection: 'column',
|
|
59
|
-
gap: _reacttheme.tokens.spacingVerticalM
|
|
60
|
-
},
|
|
61
|
-
additionalInfo: {
|
|
62
|
-
display: 'flex',
|
|
63
|
-
flexDirection: 'column',
|
|
64
|
-
gap: _reacttheme.tokens.spacingVerticalM,
|
|
65
|
-
border: `1px solid ${_reacttheme.tokens.colorNeutralStroke1}`,
|
|
66
|
-
borderRadius: _reacttheme.tokens.borderRadiusMedium,
|
|
67
|
-
padding: _reacttheme.tokens.spacingHorizontalM,
|
|
68
|
-
margin: `0 ${_reacttheme.tokens.spacingHorizontalM}`
|
|
69
|
-
},
|
|
70
|
-
additionalInfoIcon: {
|
|
71
|
-
alignSelf: 'center',
|
|
72
|
-
color: _reacttheme.tokens.colorBrandForeground1,
|
|
73
|
-
fontSize: '24px',
|
|
74
|
-
marginRight: _reacttheme.tokens.spacingHorizontalM
|
|
75
|
-
},
|
|
76
|
-
additionalInfoMessage: {
|
|
77
|
-
display: 'flex',
|
|
78
|
-
flexDirection: 'row',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
gap: _reacttheme.tokens.spacingVerticalXS
|
|
81
|
-
},
|
|
82
|
-
infoIcon: {
|
|
83
|
-
display: 'flex',
|
|
84
|
-
flexDirection: 'column',
|
|
85
|
-
gap: _reacttheme.tokens.spacingVerticalXS,
|
|
86
|
-
flex: 1
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
const useVideoClasses = (0, _react1.makeStyles)({
|
|
90
|
-
container: {
|
|
91
|
-
display: 'flex',
|
|
92
|
-
flexDirection: 'column',
|
|
93
|
-
gap: _reacttheme.tokens.spacingHorizontalMNudge
|
|
94
|
-
},
|
|
95
|
-
preview: {
|
|
96
|
-
borderRadius: _reacttheme.tokens.borderRadiusSmall,
|
|
97
|
-
display: 'flex',
|
|
98
|
-
flexDirection: 'column',
|
|
99
|
-
gap: _reacttheme.tokens.spacingHorizontalM,
|
|
100
|
-
padding: _reacttheme.tokens.spacingHorizontalM,
|
|
101
|
-
backgroundColor: _reacttheme.tokens.colorNeutralBackground2,
|
|
102
|
-
':hover': {
|
|
103
|
-
backgroundColor: _reacttheme.tokens.colorNeutralBackground2Hover
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
image: {
|
|
107
|
-
width: '200px'
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
const VideoPreviews = (props)=>{
|
|
111
|
-
const { videos } = props;
|
|
112
|
-
const classes = useVideoClasses();
|
|
113
|
-
return /*#__PURE__*/ _react.createElement("div", {
|
|
114
|
-
className: classes.container
|
|
115
|
-
}, videos.map((video)=>/*#__PURE__*/ _react.createElement(_reactlink.Link, {
|
|
116
|
-
className: classes.preview,
|
|
117
|
-
href: video.href,
|
|
118
|
-
target: "_blank",
|
|
119
|
-
key: video.href
|
|
120
|
-
}, /*#__PURE__*/ _react.createElement("img", {
|
|
121
|
-
alt: `Video: ${video.preview}`,
|
|
122
|
-
src: video.preview,
|
|
123
|
-
className: classes.image
|
|
124
|
-
}), /*#__PURE__*/ _react.createElement(_reacttext.Text, null, video.title))));
|
|
125
|
-
};
|
|
126
|
-
const getNativeElementsList = (elements)=>{
|
|
127
|
-
const elementsArr = elements === null || elements === void 0 ? void 0 : elements.map((el, idx)=>[
|
|
128
|
-
/*#__PURE__*/ _react.createElement("code", {
|
|
129
|
-
key: idx
|
|
130
|
-
}, `<${el}>`),
|
|
131
|
-
idx !== elements.length - 1 ? ', ' : ' '
|
|
132
|
-
]);
|
|
133
|
-
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, elementsArr, elementsArr.length > 1 ? 'elements' : 'element');
|
|
134
|
-
};
|
|
135
|
-
const slotRegex = /as\?:\s*"([^"]+)"/;
|
|
136
|
-
/**
|
|
137
|
-
* NOTE: this function mutates original story argTypes including all story subcomponents if they are present
|
|
138
|
-
*/ function withSlotEnhancer(story, options) {
|
|
139
|
-
var _story_argTypes_as_type, _story_argTypes_as;
|
|
140
|
-
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;
|
|
141
|
-
const argAsProp = hasArgAsProp ? story.argTypes.as.type.value : null;
|
|
142
|
-
let hasArgAsSlot = false;
|
|
143
|
-
const transformPropsWithSlotShorthand = (props)=>{
|
|
144
|
-
Object.entries(props).forEach(([key, argType])=>{
|
|
145
|
-
var _argType_type;
|
|
146
|
-
const value = argType === null || argType === void 0 ? void 0 : (_argType_type = argType.type) === null || _argType_type === void 0 ? void 0 : _argType_type.name;
|
|
147
|
-
// If DocGen was already transformed, skip the transformation but set hasArgAsSlot to true so that we can show the info message
|
|
148
|
-
if (value.includes('Slot')) {
|
|
149
|
-
hasArgAsSlot = true;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
// Initial Render Transformation for shorthand slot values (mutates DocGen Object reference)
|
|
153
|
-
if (value.includes('WithSlotShorthandValue')) {
|
|
154
|
-
hasArgAsSlot = true;
|
|
155
|
-
const match = value.match(slotRegex);
|
|
156
|
-
if (match) {
|
|
157
|
-
props[key].type.name = `Slot<\"${match[1]}\">`;
|
|
158
|
-
} else {
|
|
159
|
-
props[key].type.name = `Slot`;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
const transformComponent = (component)=>{
|
|
165
|
-
var _component___docgenInfo;
|
|
166
|
-
const docGenProps = component === null || component === void 0 ? void 0 : (_component___docgenInfo = component.__docgenInfo) === null || _component___docgenInfo === void 0 ? void 0 : _component___docgenInfo.props;
|
|
167
|
-
if (docGenProps) {
|
|
168
|
-
transformPropsWithSlotShorthand(docGenProps);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const component = story.component;
|
|
172
|
-
const subcomponents = story.subcomponents;
|
|
173
|
-
if (options.slotsApi) {
|
|
174
|
-
transformComponent(component);
|
|
175
|
-
if (subcomponents) {
|
|
176
|
-
Object.values(subcomponents).forEach((subcomponent)=>{
|
|
177
|
-
transformComponent(subcomponent);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
component,
|
|
183
|
-
hasArgAsSlot,
|
|
184
|
-
hasArgAsProp,
|
|
185
|
-
argAsProp
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
const AdditionalApiDocs = ({ children })=>{
|
|
189
|
-
const styles = useStyles();
|
|
190
|
-
return /*#__PURE__*/ _react.createElement("div", {
|
|
191
|
-
className: styles.additionalInfo
|
|
192
|
-
}, /*#__PURE__*/ _react.createElement("div", {
|
|
193
|
-
className: styles.additionalInfoMessage
|
|
194
|
-
}, /*#__PURE__*/ _react.createElement(_reacticons.InfoFilled, {
|
|
195
|
-
className: styles.additionalInfoIcon
|
|
196
|
-
}), /*#__PURE__*/ _react.createElement("div", {
|
|
197
|
-
className: styles.infoIcon
|
|
198
|
-
}, children)));
|
|
199
|
-
};
|
|
200
|
-
const RenderArgsTable = ({ story, hideArgsTable, showSlotsApi, showNativePropsApi })=>{
|
|
201
|
-
const { component, hasArgAsProp, hasArgAsSlot, argAsProp } = withSlotEnhancer(story, {
|
|
202
|
-
slotsApi: showSlotsApi,
|
|
203
|
-
nativePropsApi: showNativePropsApi
|
|
204
|
-
});
|
|
205
|
-
const styles = useStyles();
|
|
206
|
-
return hideArgsTable ? null : /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("div", {
|
|
207
|
-
className: styles.additionalInfoWrapper
|
|
208
|
-
}, hasArgAsProp && /*#__PURE__*/ _react.createElement(AdditionalApiDocs, null, /*#__PURE__*/ _react.createElement("p", null, /*#__PURE__*/ _react.createElement("b", null, "Native props are supported ", /*#__PURE__*/ _react.createElement("span", {
|
|
209
|
-
role: "presentation"
|
|
210
|
-
}, "🙌"), /*#__PURE__*/ _react.createElement("br", null)), /*#__PURE__*/ _react.createElement("span", null, "All HTML attributes native to the", getNativeElementsList(argAsProp), ", including all ", /*#__PURE__*/ _react.createElement("code", null, "aria-*"), " and ", /*#__PURE__*/ _react.createElement("code", null, "data-*"), ' ', "attributes, can be applied as native props on this component."))), hasArgAsSlot && /*#__PURE__*/ _react.createElement(AdditionalApiDocs, null, /*#__PURE__*/ _react.createElement("p", null, /*#__PURE__*/ _react.createElement("b", null, "Customizing components with slots ", /*#__PURE__*/ _react.createElement("span", {
|
|
211
|
-
role: "presentation"
|
|
212
|
-
}, "🙌")), /*#__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, {
|
|
213
|
-
href: "/?path=/docs/concepts-developer-customizing-components-with-slots--docs"
|
|
214
|
-
}, "Customizing components with slots", ' '))))), /*#__PURE__*/ _react.createElement(_addondocs.ArgsTable, {
|
|
215
|
-
of: component
|
|
216
|
-
}));
|
|
217
|
-
};
|
|
218
|
-
const RenderPrimaryStory = ({ primaryStory, skipPrimaryStory })=>{
|
|
219
|
-
const styles = useStyles();
|
|
220
|
-
return skipPrimaryStory ? null : /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("hr", {
|
|
221
|
-
className: styles.divider
|
|
222
|
-
}), /*#__PURE__*/ _react.createElement(_addondocs.HeaderMdx, {
|
|
223
|
-
as: "h3",
|
|
224
|
-
id: (0, _Toc.nameToHash)(primaryStory.name)
|
|
225
|
-
}, primaryStory.name), /*#__PURE__*/ _react.createElement(_addondocs.Primary, null));
|
|
226
|
-
};
|
|
227
|
-
const FluentDocsPage = ()=>{
|
|
228
|
-
var _primaryStoryContext_parameters, _primaryStoryContext_globals, _primaryStoryContext_parameters_docs, _primaryStoryContext_parameters1, _primaryStoryContext_parameters_docs1, _primaryStoryContext_parameters2, _primaryStoryContext_parameters3;
|
|
229
|
-
const context = _react.useContext(_addondocs.DocsContext);
|
|
230
|
-
// Get the fluent docs page configuration from context
|
|
231
|
-
const docsPageConfig = (0, _utils.getDocsPageConfig)(context);
|
|
232
|
-
const stories = context.componentStories();
|
|
233
|
-
const primaryStory = stories[0];
|
|
234
|
-
const primaryStoryContext = context.getStoryContext(primaryStory);
|
|
235
|
-
assertStoryMetaValues(primaryStory);
|
|
236
|
-
var _primaryStoryContext_parameters_dir, _ref;
|
|
237
|
-
const dir = (_ref = (_primaryStoryContext_parameters_dir = (_primaryStoryContext_parameters = primaryStoryContext.parameters) === null || _primaryStoryContext_parameters === void 0 ? void 0 : _primaryStoryContext_parameters.dir) !== null && _primaryStoryContext_parameters_dir !== void 0 ? _primaryStoryContext_parameters_dir : (_primaryStoryContext_globals = primaryStoryContext.globals) === null || _primaryStoryContext_globals === void 0 ? void 0 : _primaryStoryContext_globals[_constants.DIR_ID]) !== null && _ref !== void 0 ? _ref : 'ltr';
|
|
238
|
-
const selectedTheme = _theme.themes.find((theme)=>theme.id === primaryStoryContext.globals[_constants.THEME_ID]);
|
|
239
|
-
const hideArgsTable = Boolean((_primaryStoryContext_parameters1 = primaryStoryContext.parameters) === null || _primaryStoryContext_parameters1 === void 0 ? void 0 : (_primaryStoryContext_parameters_docs = _primaryStoryContext_parameters1.docs) === null || _primaryStoryContext_parameters_docs === void 0 ? void 0 : _primaryStoryContext_parameters_docs.hideArgsTable);
|
|
240
|
-
const skipPrimaryStory = Boolean((_primaryStoryContext_parameters2 = primaryStoryContext.parameters) === null || _primaryStoryContext_parameters2 === void 0 ? void 0 : (_primaryStoryContext_parameters_docs1 = _primaryStoryContext_parameters2.docs) === null || _primaryStoryContext_parameters_docs1 === void 0 ? void 0 : _primaryStoryContext_parameters_docs1.skipPrimaryStory);
|
|
241
|
-
var _primaryStoryContext_parameters_videos;
|
|
242
|
-
const videos = (_primaryStoryContext_parameters_videos = (_primaryStoryContext_parameters3 = primaryStoryContext.parameters) === null || _primaryStoryContext_parameters3 === void 0 ? void 0 : _primaryStoryContext_parameters3.videos) !== null && _primaryStoryContext_parameters_videos !== void 0 ? _primaryStoryContext_parameters_videos : null;
|
|
243
|
-
const styles = useStyles();
|
|
244
|
-
// If docs page is disabled, return Storybook's default docs page
|
|
245
|
-
if (!docsPageConfig) {
|
|
246
|
-
return /*#__PURE__*/ _react.createElement("div", {
|
|
247
|
-
className: "sb-unstyled"
|
|
248
|
-
}, /*#__PURE__*/ _react.createElement(_addondocs.Title, null), /*#__PURE__*/ _react.createElement(_addondocs.Subtitle, null), /*#__PURE__*/ _react.createElement(_addondocs.Description, null), /*#__PURE__*/ _react.createElement(RenderPrimaryStory, {
|
|
249
|
-
primaryStory: primaryStory,
|
|
250
|
-
skipPrimaryStory: skipPrimaryStory
|
|
251
|
-
}), /*#__PURE__*/ _react.createElement(RenderArgsTable, {
|
|
252
|
-
story: primaryStory,
|
|
253
|
-
hideArgsTable: hideArgsTable
|
|
254
|
-
}), /*#__PURE__*/ _react.createElement(_addondocs.Stories, null));
|
|
255
|
-
}
|
|
256
|
-
// Determine what to show based on configuration
|
|
257
|
-
const { tableOfContents: showTableOfContents, dirSwitcher: showDirSwitcher, themePicker: showThemePicker, argTable } = docsPageConfig;
|
|
258
|
-
// DEBUG
|
|
259
|
-
// console.log('FluentDocsPage', context);
|
|
260
|
-
// console.table(stories.map((s: StoreItem) => ({ id: s.id, kind: s.kind, name: s.name, story: s.story })));
|
|
261
|
-
// console.table(
|
|
262
|
-
// Object.values((context as any).argTypes).map(arg => ({
|
|
263
|
-
// name: arg.name,
|
|
264
|
-
// description: arg.description,
|
|
265
|
-
// type: arg.table?.type?.summary ?? '?',
|
|
266
|
-
// default: arg.table?.defaultValue?.summary ?? '-',
|
|
267
|
-
// })),
|
|
268
|
-
// );
|
|
269
|
-
return /*#__PURE__*/ _react.createElement("div", {
|
|
270
|
-
className: "sb-unstyled"
|
|
271
|
-
}, /*#__PURE__*/ _react.createElement(_addondocs.Title, null), /*#__PURE__*/ _react.createElement("div", {
|
|
272
|
-
className: styles.wrapper
|
|
273
|
-
}, /*#__PURE__*/ _react.createElement("div", {
|
|
274
|
-
className: styles.container
|
|
275
|
-
}, (showThemePicker || showDirSwitcher) && /*#__PURE__*/ _react.createElement("div", {
|
|
276
|
-
className: styles.globalTogglesContainer
|
|
277
|
-
}, showThemePicker && /*#__PURE__*/ _react.createElement(_ThemePicker.ThemePicker, {
|
|
278
|
-
selectedThemeId: selectedTheme === null || selectedTheme === void 0 ? void 0 : selectedTheme.id
|
|
279
|
-
}), showDirSwitcher && /*#__PURE__*/ _react.createElement(_DirSwitch.DirSwitch, {
|
|
280
|
-
dir: dir
|
|
281
|
-
})), /*#__PURE__*/ _react.createElement(_addondocs.Subtitle, null), /*#__PURE__*/ _react.createElement("div", {
|
|
282
|
-
className: styles.description
|
|
283
|
-
}, /*#__PURE__*/ _react.createElement(_addondocs.Description, null), videos && /*#__PURE__*/ _react.createElement(VideoPreviews, {
|
|
284
|
-
videos: videos
|
|
285
|
-
})), /*#__PURE__*/ _react.createElement(RenderPrimaryStory, {
|
|
286
|
-
primaryStory: primaryStory,
|
|
287
|
-
skipPrimaryStory: skipPrimaryStory
|
|
288
|
-
}), /*#__PURE__*/ _react.createElement(RenderArgsTable, {
|
|
289
|
-
story: primaryStory,
|
|
290
|
-
hideArgsTable: hideArgsTable,
|
|
291
|
-
showSlotsApi: argTable.slotsApi,
|
|
292
|
-
showNativePropsApi: argTable.nativePropsApi
|
|
293
|
-
}), /*#__PURE__*/ _react.createElement(_addondocs.Stories, null)), showTableOfContents && /*#__PURE__*/ _react.createElement("div", {
|
|
294
|
-
className: styles.toc
|
|
295
|
-
}, /*#__PURE__*/ _react.createElement(_Toc.Toc, {
|
|
296
|
-
stories: stories
|
|
297
|
-
}))));
|
|
298
|
-
};
|
|
299
|
-
function assertStoryMetaValues(story) {
|
|
300
|
-
if (story.component === null) {
|
|
301
|
-
throw new Error([
|
|
302
|
-
'🚨 Invalid Story Meta declaration:',
|
|
303
|
-
`- primaryStory.component of componentId:${story.componentId} is "null"`,
|
|
304
|
-
'- to resolve this error, please update "component" property value in your story definition to reference a React Component or remove it if it is not needed.'
|
|
305
|
-
].join('\n'));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/FluentDocsPage.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n DocsContext,\n ArgsTable,\n Title,\n Subtitle,\n Description,\n HeaderMdx,\n Primary,\n Stories,\n type DocsContextProps,\n} from '@storybook/addon-docs';\nimport type { PreparedStory, Renderer, SBEnumType } from '@storybook/types';\n\nimport { tokens } from '@fluentui/react-theme';\nimport { Link } from '@fluentui/react-link';\nimport { Text } from '@fluentui/react-text';\nimport { makeStyles } from '@griffel/react';\nimport { InfoFilled } from '@fluentui/react-icons';\n\nimport { DIR_ID, THEME_ID } from '../constants';\nimport { themes } from '../theme';\n\nimport { getDocsPageConfig } from './utils';\nimport { DirSwitch } from './DirSwitch';\nimport { ThemePicker } from './ThemePicker';\nimport { Toc, nameToHash } from './Toc';\n\ntype PrimaryStory = PreparedStory<Renderer>;\n\nconst useStyles = makeStyles({\n divider: {\n height: '1px',\n backgroundColor: '#e1dfdd',\n border: '0px none',\n margin: '48px 0px',\n },\n wrapper: {\n display: 'flex',\n gap: '16px',\n },\n toc: {\n flexBasis: '200px',\n flexShrink: 0,\n [`@media screen and (max-width: 1000px)`]: {\n display: 'none',\n },\n },\n container: {\n // without a width, this div grows wider than its parent\n width: '200px',\n flexGrow: 1,\n },\n globalTogglesContainer: {\n columnGap: tokens.spacingHorizontalXXXL,\n display: 'flex',\n },\n description: {\n display: 'grid',\n gridTemplateColumns: '1fr min-content',\n },\n additionalInfoWrapper: {\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.spacingVerticalM,\n },\n additionalInfo: {\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.spacingVerticalM,\n border: `1px solid ${tokens.colorNeutralStroke1}`,\n borderRadius: tokens.borderRadiusMedium,\n padding: tokens.spacingHorizontalM,\n margin: `0 ${tokens.spacingHorizontalM}`,\n },\n additionalInfoIcon: {\n alignSelf: 'center',\n color: tokens.colorBrandForeground1,\n fontSize: '24px',\n marginRight: tokens.spacingHorizontalM,\n },\n additionalInfoMessage: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n gap: tokens.spacingVerticalXS,\n },\n infoIcon: {\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.spacingVerticalXS,\n flex: 1,\n },\n});\n\nconst useVideoClasses = makeStyles({\n container: {\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.spacingHorizontalMNudge,\n },\n preview: {\n borderRadius: tokens.borderRadiusSmall,\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.spacingHorizontalM,\n padding: tokens.spacingHorizontalM,\n backgroundColor: tokens.colorNeutralBackground2,\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground2Hover,\n },\n },\n image: {\n width: '200px',\n },\n});\n\nconst VideoPreviews: React.FC<{\n videos: {\n href: string;\n preview: string;\n source: 'youtube';\n title: string;\n }[];\n}> = props => {\n const { videos } = props;\n const classes = useVideoClasses();\n\n return (\n <div className={classes.container}>\n {videos.map(video => (\n <Link className={classes.preview} href={video.href} target=\"_blank\" key={video.href}>\n <img alt={`Video: ${video.preview}`} src={video.preview} className={classes.image} />\n <Text>{video.title}</Text>\n </Link>\n ))}\n </div>\n );\n};\n\nconst getNativeElementsList = (elements: SBEnumType['value']): React.ReactElement => {\n const elementsArr = elements?.map((el, idx) => [\n <code key={idx}>{`<${el}>`}</code>,\n idx !== elements.length - 1 ? ', ' : ' ',\n ]);\n\n return (\n <>\n {elementsArr}\n {elementsArr.length > 1 ? 'elements' : 'element'}\n </>\n );\n};\n\nconst slotRegex = /as\\?:\\s*\"([^\"]+)\"/;\n/**\n * NOTE: this function mutates original story argTypes including all story subcomponents if they are present\n */\nfunction withSlotEnhancer(story: PreparedStory, options: { slotsApi?: boolean; nativePropsApi?: boolean }) {\n const hasArgAsProp = options.nativePropsApi ? story.argTypes.as?.type?.name === 'enum' : false;\n const argAsProp = hasArgAsProp ? (story.argTypes.as.type as SBEnumType).value : null;\n let hasArgAsSlot = false;\n\n type InternalComponentApi = {\n __docgenInfo: {\n props?: Record<string, { type: { name: string } }>;\n };\n [k: string]: unknown;\n };\n\n const transformPropsWithSlotShorthand = (props: Record<string, { type: { name: string } }>) => {\n Object.entries(props).forEach(([key, argType]) => {\n const value: string = argType?.type?.name;\n\n // If DocGen was already transformed, skip the transformation but set hasArgAsSlot to true so that we can show the info message\n if (value.includes('Slot')) {\n hasArgAsSlot = true;\n return;\n }\n // Initial Render Transformation for shorthand slot values (mutates DocGen Object reference)\n if (value.includes('WithSlotShorthandValue')) {\n hasArgAsSlot = true;\n const match = value.match(slotRegex);\n if (match) {\n props[key].type.name = `Slot<\\\"${match[1]}\\\">`;\n } else {\n props[key].type.name = `Slot`;\n }\n }\n });\n };\n\n const transformComponent = (component: InternalComponentApi) => {\n const docGenProps = component?.__docgenInfo?.props;\n if (docGenProps) {\n transformPropsWithSlotShorthand(docGenProps);\n }\n };\n\n const component = story.component as InternalComponentApi;\n const subcomponents = story.subcomponents as Record<string, InternalComponentApi>;\n\n if (options.slotsApi) {\n transformComponent(component);\n if (subcomponents) {\n Object.values(subcomponents).forEach(subcomponent => {\n transformComponent(subcomponent);\n });\n }\n }\n\n return { component, hasArgAsSlot, hasArgAsProp, argAsProp };\n}\n\nconst AdditionalApiDocs: React.FC<{ children: React.ReactElement | React.ReactElement[] }> = ({ children }) => {\n const styles = useStyles();\n return (\n <div className={styles.additionalInfo}>\n <div className={styles.additionalInfoMessage}>\n <InfoFilled className={styles.additionalInfoIcon} />\n <div className={styles.infoIcon}>{children}</div>\n </div>\n </div>\n );\n};\n\nconst RenderArgsTable = ({\n story,\n hideArgsTable,\n showSlotsApi,\n showNativePropsApi,\n}: {\n story: PrimaryStory;\n hideArgsTable: boolean;\n showSlotsApi?: boolean;\n showNativePropsApi?: boolean;\n}) => {\n const { component, hasArgAsProp, hasArgAsSlot, argAsProp } = withSlotEnhancer(story, {\n slotsApi: showSlotsApi,\n nativePropsApi: showNativePropsApi,\n });\n const styles = useStyles();\n\n return hideArgsTable ? null : (\n <>\n <div className={styles.additionalInfoWrapper}>\n {hasArgAsProp && (\n <AdditionalApiDocs>\n <p>\n <b>\n Native props are supported <span role=\"presentation\">🙌</span>\n <br />\n </b>\n <span>\n All HTML attributes native to the\n {getNativeElementsList(argAsProp!)}, including all <code>aria-*</code> and <code>data-*</code>{' '}\n attributes, can be applied as native props on this component.\n </span>\n </p>\n </AdditionalApiDocs>\n )}\n {hasArgAsSlot && (\n <AdditionalApiDocs>\n <p>\n <b>\n Customizing components with slots <span role=\"presentation\">🙌</span>\n </b>\n <br />\n <span>\n Slots in Fluent UI React components are designed to be modified or replaced, providing a flexible\n approach to customizing components. Each slot is exposed as a top-level prop and can be filled with\n primitive values, JSX/TSX, props objects, or render functions. This allows for more dynamic and reusable\n component structures, similar to slots in other frameworks.{' '}\n <Link href=\"/?path=/docs/concepts-developer-customizing-components-with-slots--docs\">\n Customizing components with slots{' '}\n </Link>\n </span>\n </p>\n </AdditionalApiDocs>\n )}\n </div>\n <ArgsTable of={component} />\n </>\n );\n};\n\nconst RenderPrimaryStory = ({\n primaryStory,\n skipPrimaryStory,\n}: {\n primaryStory: PrimaryStory;\n skipPrimaryStory: boolean;\n}) => {\n const styles = useStyles();\n return skipPrimaryStory ? null : (\n <>\n <hr className={styles.divider} />\n <HeaderMdx as=\"h3\" id={nameToHash(primaryStory.name)}>\n {primaryStory.name}\n </HeaderMdx>\n <Primary />\n </>\n );\n};\n\nexport const FluentDocsPage = () => {\n const context = React.useContext(DocsContext);\n\n // Get the fluent docs page configuration from context\n const docsPageConfig = getDocsPageConfig(context);\n\n const stories = context.componentStories();\n\n const primaryStory = stories[0];\n const primaryStoryContext = context.getStoryContext(primaryStory);\n\n assertStoryMetaValues(primaryStory);\n\n const dir = primaryStoryContext.parameters?.dir ?? primaryStoryContext.globals?.[DIR_ID] ?? 'ltr';\n const selectedTheme = themes.find(theme => theme.id === primaryStoryContext.globals![THEME_ID]);\n\n const hideArgsTable = Boolean(primaryStoryContext.parameters?.docs?.hideArgsTable);\n const skipPrimaryStory = Boolean(primaryStoryContext.parameters?.docs?.skipPrimaryStory);\n\n const videos = primaryStoryContext.parameters?.videos ?? null;\n const styles = useStyles();\n\n // If docs page is disabled, return Storybook's default docs page\n if (!docsPageConfig) {\n return (\n <div className=\"sb-unstyled\">\n <Title />\n <Subtitle />\n <Description />\n <RenderPrimaryStory primaryStory={primaryStory} skipPrimaryStory={skipPrimaryStory} />\n <RenderArgsTable story={primaryStory} hideArgsTable={hideArgsTable} />\n <Stories />\n </div>\n );\n }\n\n // Determine what to show based on configuration\n const {\n tableOfContents: showTableOfContents,\n dirSwitcher: showDirSwitcher,\n themePicker: showThemePicker,\n argTable,\n } = docsPageConfig;\n\n // DEBUG\n // console.log('FluentDocsPage', context);\n // console.table(stories.map((s: StoreItem) => ({ id: s.id, kind: s.kind, name: s.name, story: s.story })));\n // console.table(\n // Object.values((context as any).argTypes).map(arg => ({\n // name: arg.name,\n // description: arg.description,\n // type: arg.table?.type?.summary ?? '?',\n // default: arg.table?.defaultValue?.summary ?? '-',\n // })),\n // );\n\n return (\n <div className=\"sb-unstyled\">\n <Title />\n <div className={styles.wrapper}>\n <div className={styles.container}>\n {(showThemePicker || showDirSwitcher) && (\n <div className={styles.globalTogglesContainer}>\n {showThemePicker && <ThemePicker selectedThemeId={selectedTheme?.id} />}\n {showDirSwitcher && <DirSwitch dir={dir} />}\n </div>\n )}\n <Subtitle />\n <div className={styles.description}>\n <Description />\n {videos && <VideoPreviews videos={videos} />}\n </div>\n <RenderPrimaryStory primaryStory={primaryStory} skipPrimaryStory={skipPrimaryStory} />\n <RenderArgsTable\n story={primaryStory}\n hideArgsTable={hideArgsTable}\n showSlotsApi={argTable.slotsApi}\n showNativePropsApi={argTable.nativePropsApi}\n />\n <Stories />\n </div>\n {showTableOfContents && (\n <div className={styles.toc}>\n <Toc stories={stories} />\n </div>\n )}\n </div>\n </div>\n );\n};\n\nfunction assertStoryMetaValues(story: ReturnType<DocsContextProps['componentStories']>[number]) {\n if (story.component === null) {\n throw new Error(\n [\n '🚨 Invalid Story Meta declaration:',\n `- primaryStory.component of componentId:${story.componentId} is \"null\"`,\n '- to resolve this error, please update \"component\" property value in your story definition to reference a React Component or remove it if it is not needed.',\n ].join('\\n'),\n );\n }\n}\n"],"names":["FluentDocsPage","useStyles","makeStyles","divider","height","backgroundColor","border","margin","wrapper","display","gap","toc","flexBasis","flexShrink","container","width","flexGrow","globalTogglesContainer","columnGap","tokens","spacingHorizontalXXXL","description","gridTemplateColumns","additionalInfoWrapper","flexDirection","spacingVerticalM","additionalInfo","colorNeutralStroke1","borderRadius","borderRadiusMedium","padding","spacingHorizontalM","additionalInfoIcon","alignSelf","color","colorBrandForeground1","fontSize","marginRight","additionalInfoMessage","alignItems","spacingVerticalXS","infoIcon","flex","useVideoClasses","spacingHorizontalMNudge","preview","borderRadiusSmall","colorNeutralBackground2","colorNeutralBackground2Hover","image","VideoPreviews","props","videos","classes","div","className","map","video","Link","href","target","key","img","alt","src","Text","title","getNativeElementsList","elements","elementsArr","el","idx","code","length","slotRegex","withSlotEnhancer","story","options","hasArgAsProp","nativePropsApi","argTypes","as","type","name","argAsProp","value","hasArgAsSlot","transformPropsWithSlotShorthand","Object","entries","forEach","argType","includes","match","transformComponent","component","docGenProps","__docgenInfo","subcomponents","slotsApi","values","subcomponent","AdditionalApiDocs","children","styles","InfoFilled","RenderArgsTable","hideArgsTable","showSlotsApi","showNativePropsApi","p","b","span","role","br","ArgsTable","of","RenderPrimaryStory","primaryStory","skipPrimaryStory","hr","HeaderMdx","id","nameToHash","Primary","primaryStoryContext","context","React","useContext","DocsContext","docsPageConfig","getDocsPageConfig","stories","componentStories","getStoryContext","assertStoryMetaValues","dir","parameters","globals","DIR_ID","selectedTheme","themes","find","theme","THEME_ID","Boolean","docs","Title","Subtitle","Description","Stories","tableOfContents","showTableOfContents","dirSwitcher","showDirSwitcher","themePicker","showThemePicker","argTable","ThemePicker","selectedThemeId","DirSwitch","Toc","Error","componentId","join"],"mappings":";;;;+BAkTaA;;;eAAAA;;;;iEAlTU;2BAWhB;4BAGgB;2BACF;2BACA;wBACM;4BACA;2BAEM;uBACV;uBAEW;2BACR;6BACE;qBACI;AAIhC,MAAMC,YAAYC,IAAAA,kBAAU,EAAC;IAC3BC,SAAS;QACPC,QAAQ;QACRC,iBAAiB;QACjBC,QAAQ;QACRC,QAAQ;IACV;IACAC,SAAS;QACPC,SAAS;QACTC,KAAK;IACP;IACAC,KAAK;QACHC,WAAW;QACXC,YAAY;QACZ,CAAC,CAAC,qCAAqC,CAAC,CAAC,EAAE;YACzCJ,SAAS;QACX;IACF;IACAK,WAAW;QACT,wDAAwD;QACxDC,OAAO;QACPC,UAAU;IACZ;IACAC,wBAAwB;QACtBC,WAAWC,kBAAM,CAACC,qBAAqB;QACvCX,SAAS;IACX;IACAY,aAAa;QACXZ,SAAS;QACTa,qBAAqB;IACvB;IACAC,uBAAuB;QACrBd,SAAS;QACTe,eAAe;QACfd,KAAKS,kBAAM,CAACM,gBAAgB;IAC9B;IACAC,gBAAgB;QACdjB,S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sBAAsB;IACtB,oCAAoC;IACpC,6CAA6C;IAC7C,wDAAwD;IACxD,SAAS;IACT,KAAK;IAEL,qBACE,qBAAC5E;QAAIC,WAAU;qBACb,qBAAC4F,gBAAK,uBACN,qBAAC7F;QAAIC,WAAWiD,OAAOhG,OAAO;qBAC5B,qBAAC8C;QAAIC,WAAWiD,OAAO1F,SAAS;OAC7B,AAAC8I,CAAAA,mBAAmBF,eAAc,mBACjC,qBAACpG;QAAIC,WAAWiD,OAAOvF,sBAAsB;OAC1C2I,iCAAmB,qBAACE,wBAAW;QAACC,eAAe,EAAEnB,0BAAAA,oCAAAA,cAAelB,EAAE;QAClEgC,iCAAmB,qBAACM,oBAAS;QAACxB,KAAKA;uBAGxC,qBAACY,mBAAQ,uBACT,qBAAC9F;QAAIC,WAAWiD,OAAOnF,WAAW;qBAChC,qBAACgI,sBAAW,SACXjG,wBAAU,qBAACF;QAAcE,QAAQA;uBAEpC,qBAACiE;QAAmBC,cAAcA;QAAcC,kBAAkBA;sBAClE,qBAACb;QACC9B,OAAO0C;QACPX,eAAeA;QACfC,cAAciD,SAAS1D,QAAQ;QAC/BU,oBAAoBgD,SAAS9E,cAAc;sBAE7C,qBAACuE,kBAAO,UAETE,qCACC,qBAAClG;QAAIC,WAAWiD,OAAO7F,GAAG;qBACxB,qBAACsJ,QAAG;QAAC7B,SAASA;;AAM1B;AAEA,SAASG,sBAAsB3D,KAA+D;IAC5F,IAAIA,MAAMmB,SAAS,KAAK,MAAM;QAC5B,MAAM,IAAImE,MACR;YACE;YACA,CAAC,wCAAwC,EAAEtF,MAAMuF,WAAW,CAAC,UAAU,CAAC;YACxE;SACD,CAACC,IAAI,CAAC;IAEX;AACF"}
|
|
@@ -1,70 +0,0 @@
|
|
|
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 _previewapi = require("@storybook/preview-api");
|
|
14
|
-
const _reactmenu = require("@fluentui/react-menu");
|
|
15
|
-
const _reactbutton = require("@fluentui/react-button");
|
|
16
|
-
const _react1 = require("@griffel/react");
|
|
17
|
-
const _ = require("..");
|
|
18
|
-
const useStyles = (0, _react1.makeStyles)({
|
|
19
|
-
menuButton: {
|
|
20
|
-
minWidth: '210px',
|
|
21
|
-
justifyContent: 'flex-start'
|
|
22
|
-
},
|
|
23
|
-
chevronIcon: {
|
|
24
|
-
marginLeft: 'auto'
|
|
25
|
-
},
|
|
26
|
-
menuPopover: {
|
|
27
|
-
minWidth: '210px'
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const ThemePicker = ({ selectedThemeId })=>{
|
|
31
|
-
const styles = useStyles();
|
|
32
|
-
const [currentThemeId, setCurrentThemeId] = _react.useState(selectedThemeId !== null && selectedThemeId !== void 0 ? selectedThemeId : null);
|
|
33
|
-
const setGlobalTheme = (themeId)=>{
|
|
34
|
-
_previewapi.addons.getChannel().emit('updateGlobals', {
|
|
35
|
-
globals: {
|
|
36
|
-
[_.THEME_ID]: themeId
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
const onCheckedValueChange = (e, data)=>{
|
|
41
|
-
const newThemeId = data.checkedItems[0];
|
|
42
|
-
setGlobalTheme(newThemeId);
|
|
43
|
-
setCurrentThemeId(newThemeId);
|
|
44
|
-
};
|
|
45
|
-
const selectedTheme = _.themes.find((theme)=>theme.id === currentThemeId);
|
|
46
|
-
var _selectedTheme_label;
|
|
47
|
-
return /*#__PURE__*/ _react.createElement(_reactmenu.Menu, {
|
|
48
|
-
// eslint-disable-next-line react/jsx-no-bind
|
|
49
|
-
onCheckedValueChange: onCheckedValueChange,
|
|
50
|
-
checkedValues: {
|
|
51
|
-
theme: selectedThemeId ? [
|
|
52
|
-
selectedThemeId
|
|
53
|
-
] : []
|
|
54
|
-
},
|
|
55
|
-
positioning: {
|
|
56
|
-
autoSize: true
|
|
57
|
-
}
|
|
58
|
-
}, /*#__PURE__*/ _react.createElement(_reactmenu.MenuTrigger, null, /*#__PURE__*/ _react.createElement(_reactbutton.MenuButton, {
|
|
59
|
-
className: styles.menuButton,
|
|
60
|
-
menuIcon: {
|
|
61
|
-
className: styles.chevronIcon
|
|
62
|
-
}
|
|
63
|
-
}, (_selectedTheme_label = selectedTheme === null || selectedTheme === void 0 ? void 0 : selectedTheme.label) !== null && _selectedTheme_label !== void 0 ? _selectedTheme_label : 'Theme')), /*#__PURE__*/ _react.createElement(_reactmenu.MenuPopover, {
|
|
64
|
-
className: styles.menuPopover
|
|
65
|
-
}, /*#__PURE__*/ _react.createElement(_reactmenu.MenuList, null, _.themes.map((theme)=>/*#__PURE__*/ _react.createElement(_reactmenu.MenuItemRadio, {
|
|
66
|
-
name: "theme",
|
|
67
|
-
value: theme.id,
|
|
68
|
-
key: theme.id
|
|
69
|
-
}, theme.label)))));
|
|
70
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/ThemePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { addons } from '@storybook/preview-api';\n\nimport { Menu, MenuItemRadio, MenuList, MenuPopover, MenuTrigger } from '@fluentui/react-menu';\nimport type { MenuProps } from '@fluentui/react-menu';\nimport { MenuButton } from '@fluentui/react-button';\nimport { makeStyles } from '@griffel/react';\n\nimport { themes, ThemeIds, THEME_ID } from '..';\n\nconst useStyles = makeStyles({\n menuButton: {\n minWidth: '210px',\n justifyContent: 'flex-start',\n },\n\n chevronIcon: {\n marginLeft: 'auto',\n },\n\n menuPopover: {\n minWidth: '210px',\n },\n});\n\n/**\n * Theme picker used in the react-components docs header\n */\nexport const ThemePicker: React.FC<{ selectedThemeId?: string }> = ({ selectedThemeId }) => {\n const styles = useStyles();\n const [currentThemeId, setCurrentThemeId] = React.useState(selectedThemeId ?? null);\n\n const setGlobalTheme = (themeId: ThemeIds): void => {\n addons.getChannel().emit('updateGlobals', { globals: { [THEME_ID]: themeId } });\n };\n const onCheckedValueChange: MenuProps['onCheckedValueChange'] = (e, data) => {\n const newThemeId = data.checkedItems[0] as ThemeIds;\n setGlobalTheme(newThemeId);\n setCurrentThemeId(newThemeId);\n };\n\n const selectedTheme = themes.find(theme => theme.id === currentThemeId);\n\n return (\n <Menu\n // eslint-disable-next-line react/jsx-no-bind\n onCheckedValueChange={onCheckedValueChange}\n checkedValues={{ theme: selectedThemeId ? [selectedThemeId] : [] }}\n positioning={{ autoSize: true }}\n >\n <MenuTrigger>\n <MenuButton className={styles.menuButton} menuIcon={{ className: styles.chevronIcon }}>\n {selectedTheme?.label ?? 'Theme'}\n </MenuButton>\n </MenuTrigger>\n <MenuPopover className={styles.menuPopover}>\n <MenuList>\n {themes.map(theme => (\n <MenuItemRadio name=\"theme\" value={theme.id} key={theme.id}>\n {theme.label}\n </MenuItemRadio>\n ))}\n </MenuList>\n </MenuPopover>\n </Menu>\n );\n};\n"],"names":["ThemePicker","useStyles","makeStyles","menuButton","minWidth","justifyContent","chevronIcon","marginLeft","menuPopover","selectedThemeId","styles","currentThemeId","setCurrentThemeId","React","useState","setGlobalTheme","themeId","addons","getChannel","emit","globals","THEME_ID","onCheckedValueChange","e","data","newThemeId","checkedItems","selectedTheme","themes","find","theme","id","Menu","checkedValues","positioning","autoSize","MenuTrigger","MenuButton","className","menuIcon","label","MenuPopover","MenuList","map","MenuItemRadio","name","value","key"],"mappings":";;;;+BA4BaA;;;eAAAA;;;;iEA5BU;4BACA;2BAEiD;6BAE7C;wBACA;kBAEgB;AAE3C,MAAMC,YAAYC,IAAAA,kBAAU,EAAC;IAC3BC,YAAY;QACVC,UAAU;QACVC,gBAAgB;IACl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