@mui/docs 6.0.0-beta.3 → 6.0.0-beta.4

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/node/Ad/Ad.js ADDED
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AD_MARGIN_TOP = exports.AD_MARGIN_BOTTOM = exports.AD_HEIGHT_MOBILE = exports.AD_HEIGHT = void 0;
8
+ exports.Ad = Ad;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
11
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
12
+ var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
13
+ var _i18n = require("../i18n");
14
+ var _AdCarbon2 = _interopRequireDefault(require("./AdCarbon"));
15
+ var _AdInHouse = _interopRequireDefault(require("./AdInHouse"));
16
+ var _AdManager = require("./AdManager");
17
+ var _AdProvider = require("./AdProvider");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ var _span, _PleaseDisableAdblock, _AdCarbon;
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ function PleaseDisableAdblock() {
23
+ const t = (0, _i18n.useTranslate)();
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Paper.default, {
25
+ component: "span",
26
+ elevation: 0,
27
+ sx: {
28
+ display: 'block',
29
+ p: 1.5,
30
+ border: '2px solid',
31
+ borderColor: 'primary.main'
32
+ },
33
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
34
+ variant: "body2",
35
+ component: "span",
36
+ gutterBottom: true,
37
+ sx: {
38
+ display: 'block'
39
+ },
40
+ children: t('likeMui')
41
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
42
+ variant: "body2",
43
+ component: "span",
44
+ gutterBottom: true,
45
+ sx: {
46
+ display: 'block'
47
+ },
48
+ children: t('adblock')
49
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
50
+ variant: "body2",
51
+ component: "span",
52
+ sx: {
53
+ display: 'block'
54
+ },
55
+ children: [t('thanks'), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
56
+ role: "img",
57
+ "aria-label": t('emojiLove'),
58
+ children: "\u2764\uFE0F"
59
+ })]
60
+ })]
61
+ });
62
+ }
63
+ const disableAd = process.env.NODE_ENV !== 'production' && process.env.ENABLE_AD_IN_DEV_MODE !== 'true';
64
+ const inHouseAds = [{
65
+ name: 'scaffoldhub',
66
+ link: 'https://v2.scaffoldhub.io/scaffolds/react-material-ui?partner=1',
67
+ img: '/static/ads-in-house/scaffoldhub.png',
68
+ description: '<b>ScaffoldHub</b>. Automate building your full-stack Material UI web-app.'
69
+ }, {
70
+ name: 'templates',
71
+ link: 'https://mui.com/store/?utm_source=docs&utm_medium=referral&utm_campaign=in-house-templates',
72
+ img: '/static/ads-in-house/themes-2.jpg',
73
+ description: '<b>Premium Templates</b>. Start your project with the best templates for admins, dashboards, and more.'
74
+ }, {
75
+ name: 'themes',
76
+ link: 'https://mui.com/store/?utm_source=docs&utm_medium=referral&utm_campaign=in-house-themes',
77
+ img: '/static/ads-in-house/themes.png',
78
+ description: '<b>Premium Themes</b>. Kickstart your application development with a ready-made theme.'
79
+ }, {
80
+ name: 'tidelift',
81
+ link: 'https://tidelift.com/subscription/pkg/npm-material-ui?utm_source=npm-material-ui&utm_medium=referral&utm_campaign=enterprise&utm_content=ad',
82
+ img: '/static/ads-in-house/tidelift.png',
83
+ description: '<b>MUI for enterprise</b>. Save time and reduce risk. Managed open source — backed by maintainers.'
84
+ }, {
85
+ name: 'figma',
86
+ link: 'https://mui.com/store/items/figma-react/?utm_source=docs&utm_medium=referral&utm_campaign=in-house-figma',
87
+ img: '/static/ads-in-house/figma.png',
88
+ description: '<b>For Figma</b>. A large UI kit with over 600 handcrafted Material UI, MUI X, Joy UI components 🎨.'
89
+ }];
90
+ class AdErrorBoundary extends React.Component {
91
+ state = {
92
+ didError: false
93
+ };
94
+ static getDerivedStateFromError() {
95
+ return {
96
+ didError: true
97
+ };
98
+ }
99
+ componentDidCatch() {
100
+ // send explicit `'null'`
101
+ const eventLabel = String(this.props.eventLabel);
102
+ // TODO: Use proper error monitoring service (for example Sentry) instead
103
+
104
+ window.gtag('event', 'ad', {
105
+ eventAction: 'crash',
106
+ eventLabel
107
+ });
108
+ }
109
+ render() {
110
+ const {
111
+ didError
112
+ } = this.state;
113
+ const {
114
+ children
115
+ } = this.props;
116
+ if (didError) {
117
+ return null;
118
+ }
119
+ return children;
120
+ }
121
+ }
122
+ const AD_MARGIN_TOP = exports.AD_MARGIN_TOP = 3;
123
+ const AD_MARGIN_BOTTOM = exports.AD_MARGIN_BOTTOM = 3;
124
+ const AD_HEIGHT = exports.AD_HEIGHT = 126;
125
+ // Add more height on mobile as the text tends to wrap beyond the image height.
126
+ const AD_HEIGHT_MOBILE = exports.AD_HEIGHT_MOBILE = 126 + 16;
127
+
128
+ // https://stackoverflow.com/a/20084661
129
+ function isBot() {
130
+ return /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent);
131
+ }
132
+ function Ad() {
133
+ const [adblock, setAdblock] = React.useState(null);
134
+ const [carbonOut, setCarbonOut] = React.useState(null);
135
+ const {
136
+ current: randomAdblock
137
+ } = React.useRef(Math.random());
138
+ const {
139
+ current: randomInHouse
140
+ } = React.useRef(Math.random());
141
+ let children;
142
+ let label;
143
+ // Hide the content to google bot to avoid its indexation.
144
+ if (typeof window !== 'undefined' && isBot() || disableAd) {
145
+ children = _span || (_span = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}));
146
+ } else if (adblock) {
147
+ if (randomAdblock < 0.2) {
148
+ children = _PleaseDisableAdblock || (_PleaseDisableAdblock = /*#__PURE__*/(0, _jsxRuntime.jsx)(PleaseDisableAdblock, {}));
149
+ label = 'in-house-adblock';
150
+ } else {
151
+ children = /*#__PURE__*/(0, _jsxRuntime.jsx)(_AdInHouse.default, {
152
+ ad: inHouseAds[Math.floor(inHouseAds.length * randomInHouse)]
153
+ });
154
+ label = 'in-house';
155
+ }
156
+ } else if (carbonOut) {
157
+ children = /*#__PURE__*/(0, _jsxRuntime.jsx)(_AdInHouse.default, {
158
+ ad: inHouseAds[Math.floor(inHouseAds.length * randomInHouse)]
159
+ });
160
+ label = 'in-house-carbon';
161
+ } else {
162
+ children = _AdCarbon || (_AdCarbon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_AdCarbon2.default, {}));
163
+ label = 'carbon';
164
+ }
165
+ const ad = React.useContext(_AdManager.AdContext);
166
+ const eventLabel = label ? `${label}-${ad.placement}-${_AdManager.adShape}` : null;
167
+ const timerAdblock = React.useRef();
168
+ const checkAdblock = React.useCallback((attempt = 1) => {
169
+ if (document.querySelector('.ea-placement') || document.querySelector('#carbonads') || document.querySelector('.carbonads') || carbonOut) {
170
+ var _document$querySelect;
171
+ if (document.querySelector('#carbonads a') && ((_document$querySelect = document.querySelector('#carbonads a')) == null ? void 0 : _document$querySelect.getAttribute('href')) === 'https://material-ui-next.com/discover-more/backers') {
172
+ setCarbonOut(true);
173
+ }
174
+ setAdblock(false);
175
+ return;
176
+ }
177
+ if (attempt < 30) {
178
+ timerAdblock.current = setTimeout(() => {
179
+ checkAdblock(attempt + 1);
180
+ }, 500);
181
+ }
182
+ if (attempt > 6) {
183
+ setAdblock(true);
184
+ }
185
+ }, [carbonOut]);
186
+ React.useEffect(() => {
187
+ if (disableAd) {
188
+ return undefined;
189
+ }
190
+ checkAdblock();
191
+ return () => {
192
+ clearTimeout(timerAdblock.current);
193
+ };
194
+ }, [checkAdblock]);
195
+ const {
196
+ GADisplayRatio
197
+ } = (0, _AdProvider.useAdConfig)();
198
+ React.useEffect(() => {
199
+ // Avoid an exceed on the Google Analytics quotas.
200
+ if (Math.random() > (GADisplayRatio != null ? GADisplayRatio : 0.1) || !eventLabel) {
201
+ return undefined;
202
+ }
203
+ const delay = setTimeout(() => {
204
+ window.gtag('event', 'ad', {
205
+ eventAction: 'display',
206
+ eventLabel
207
+ });
208
+ }, 2500);
209
+ return () => {
210
+ clearTimeout(delay);
211
+ };
212
+ }, [GADisplayRatio, eventLabel]);
213
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
214
+ component: "span",
215
+ sx: theme => ({
216
+ position: 'relative',
217
+ display: 'block',
218
+ mt: AD_MARGIN_TOP,
219
+ mb: AD_MARGIN_BOTTOM,
220
+ minHeight: AD_HEIGHT_MOBILE,
221
+ [theme.breakpoints.up('sm')]: {
222
+ minHeight: AD_HEIGHT
223
+ },
224
+ ...(_AdManager.adShape === 'image' && {}),
225
+ ...(_AdManager.adShape === 'inline' && {
226
+ display: 'flex',
227
+ alignItems: 'flex-end'
228
+ })
229
+ }),
230
+ "data-ga-event-category": "ad",
231
+ "data-ga-event-action": "click",
232
+ "data-ga-event-label": eventLabel,
233
+ className: "Ad-root",
234
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AdErrorBoundary, {
235
+ eventLabel: eventLabel,
236
+ children: children
237
+ })
238
+ });
239
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AdCarbonInline = AdCarbonInline;
8
+ exports.default = AdCarbon;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _styles = require("@mui/material/styles");
11
+ var _loadScript = _interopRequireDefault(require("../utils/loadScript"));
12
+ var _AdDisplay = _interopRequireDefault(require("./AdDisplay"));
13
+ var _ad = require("./ad.styles");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ var _AdCarbonImage;
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ const CarbonRoot = (0, _styles.styled)('span')(({
19
+ theme
20
+ }) => {
21
+ const styles = (0, _ad.adBodyImageStyles)(theme);
22
+ return {
23
+ width: '100%',
24
+ '& > div': {
25
+ // The isolation logic of carbonads is broken.
26
+ // Once the script starts loading, it will asynchronous resolve, with no way to stop it.
27
+ // This leads to duplication of the ad.
28
+ //
29
+ // To solve the issue, we only display the #carbonads div
30
+ display: 'none'
31
+ },
32
+ '& #carbonads': {
33
+ ...styles.root,
34
+ '& .carbon-img': styles.imgWrapper,
35
+ '& img': styles.img,
36
+ '& a, & a:hover': styles.a,
37
+ '& .carbon-text': styles.description,
38
+ '& .carbon-poweredby': styles.poweredby
39
+ }
40
+ };
41
+ });
42
+ function AdCarbonImage() {
43
+ const ref = React.useRef(null);
44
+ React.useEffect(() => {
45
+ // The isolation logic of carbonads is broken.
46
+ // Once the script starts loading, it will asynchronous resolve, with no way to stop it.
47
+ // This leads to duplication of the ad.
48
+ //
49
+ // To solve the issue, for example StrictModel double effect execution, we debounce the load action.
50
+ const load = setTimeout(() => {
51
+ const script = (0, _loadScript.default)('https://cdn.carbonads.com/carbon.js?serve=CKYIL27L&placement=material-uicom', ref.current);
52
+ script.id = '_carbonads_js';
53
+ });
54
+ return () => {
55
+ clearTimeout(load);
56
+ };
57
+ }, []);
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(CarbonRoot, {
59
+ ref: ref
60
+ });
61
+ }
62
+ function AdCarbonInline() {
63
+ const [ad, setAd] = React.useState(null);
64
+ React.useEffect(() => {
65
+ let active = true;
66
+ let attempt = 0;
67
+ (async () => {
68
+ async function tryFetch() {
69
+ if (attempt >= 10 || !active) {
70
+ return null;
71
+ }
72
+ attempt += 1;
73
+ let response;
74
+ try {
75
+ response = await fetch('https://srv.buysellads.com/ads/CE7DC23W.json');
76
+ } catch (err) {
77
+ // Ad blocker crashes this request
78
+ return null;
79
+ }
80
+ const data = await response.json();
81
+ // Inspired by https://github.com/Semantic-Org/Semantic-UI-React/blob/2c7134128925dd831de85011e3eb0ec382ba7f73/docs/src/components/CarbonAd/CarbonAdNative.js#L9
82
+ const sanitizedAd = data.ads.filter(item => Object.keys(item).length > 0).filter(item => item.statlink).filter(Boolean)[0];
83
+ if (!sanitizedAd) {
84
+ return tryFetch();
85
+ }
86
+ return sanitizedAd;
87
+ }
88
+ const sanitizedAd = await tryFetch();
89
+ if (active) {
90
+ setAd(sanitizedAd);
91
+ }
92
+ })();
93
+ return () => {
94
+ active = false;
95
+ };
96
+ }, []);
97
+ return ad ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
98
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
99
+ src: ad.statimp,
100
+ alt: "",
101
+ style: {
102
+ display: 'none'
103
+ }
104
+ }), ad.pixel && ad.pixel.split('||').map((pixel, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
105
+ src: `${pixel.replace('[timestamp]', ad.timestamp)}`,
106
+ style: {
107
+ display: 'none'
108
+ },
109
+ alt: ""
110
+ }, i)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AdDisplay.default, {
111
+ className: "carbonads",
112
+ shape: "inline",
113
+ ad: {
114
+ link: ad.statlink,
115
+ img: ad.image,
116
+ name: ad.company,
117
+ description: `<strong>${ad.company}</strong> - ${ad.description}`,
118
+ poweredby: 'Carbon',
119
+ label: 'carbon-demo-inline'
120
+ }
121
+ })]
122
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
123
+ style: {
124
+ minHeight: 52
125
+ }
126
+ });
127
+ }
128
+ function AdCarbon() {
129
+ return _AdCarbonImage || (_AdCarbonImage = /*#__PURE__*/(0, _jsxRuntime.jsx)(AdCarbonImage, {}));
130
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = AdDisplay;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _styles = require("@mui/material/styles");
9
+ var _i18n = require("../i18n");
10
+ var _AdManager = require("./AdManager");
11
+ var _ad = require("./ad.styles");
12
+ var _AdProvider = require("./AdProvider");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const InlineShape = (0, _styles.styled)('span')(({
17
+ theme
18
+ }) => {
19
+ const styles = (0, _ad.adBodyInlineStyles)(theme);
20
+ return {
21
+ ...styles.root,
22
+ '& img': styles.img,
23
+ '& a, & a:hover': styles.a,
24
+ '& .AdDisplay-imageWrapper': styles.imgWrapper,
25
+ '& .AdDisplay-description': styles.description,
26
+ '& .AdDisplay-poweredby': styles.poweredby
27
+ };
28
+ });
29
+ const ImageShape = (0, _styles.styled)('span')(({
30
+ theme
31
+ }) => {
32
+ const styles = (0, _ad.adBodyImageStyles)(theme);
33
+ return {
34
+ ...styles.root,
35
+ '& img': styles.img,
36
+ '& a, & a:hover': styles.a,
37
+ '& .AdDisplay-imageWrapper': styles.imgWrapper,
38
+ '& .AdDisplay-description': styles.description,
39
+ '& .AdDisplay-poweredby': styles.poweredby
40
+ };
41
+ });
42
+ function AdDisplay(props) {
43
+ const {
44
+ ad,
45
+ className,
46
+ shape: shapeProp = 'auto'
47
+ } = props;
48
+ const t = (0, _i18n.useTranslate)();
49
+ const {
50
+ GADisplayRatio
51
+ } = (0, _AdProvider.useAdConfig)();
52
+ React.useEffect(() => {
53
+ // Avoid an exceed on the Google Analytics quotas.
54
+ if (Math.random() > (GADisplayRatio != null ? GADisplayRatio : 0.1) || !ad.label) {
55
+ return;
56
+ }
57
+ window.gtag('event', 'ad', {
58
+ eventAction: 'display',
59
+ eventLabel: ad.label
60
+ });
61
+ }, [GADisplayRatio, ad.label]);
62
+ const shape = shapeProp === 'auto' ? _AdManager.adShape : shapeProp;
63
+ const Root = shape === 'image' ? ImageShape : InlineShape;
64
+
65
+ /* eslint-disable react/no-danger */
66
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, {
67
+ className: className,
68
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
69
+ href: ad.link,
70
+ target: "_blank",
71
+ rel: "noopener sponsored",
72
+ ...(ad.label ? {
73
+ 'data-ga-event-category': 'ad',
74
+ 'data-ga-event-action': 'click',
75
+ 'data-ga-event-label': ad.label
76
+ } : {}),
77
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
78
+ className: "AdDisplay-imageWrapper",
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
80
+ height: "100",
81
+ width: "130",
82
+ src: ad.img,
83
+ alt: ad.name
84
+ })
85
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
86
+ className: "AdDisplay-description",
87
+ dangerouslySetInnerHTML: {
88
+ __html: ad.description
89
+ }
90
+ })]
91
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
92
+ className: "AdDisplay-poweredby",
93
+ children: t('adPublisher').replace('{{publisher}}', ad.poweredby)
94
+ })]
95
+ });
96
+ /* eslint-enable react/no-danger */
97
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AdGuest = AdGuest;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _Portal = _interopRequireDefault(require("@mui/material/Portal"));
10
+ var _AdManager = require("./AdManager");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function AdGuest(props) {
15
+ const {
16
+ classSelector = '.description',
17
+ children
18
+ } = props;
19
+ const ad = React.useContext(_AdManager.AdContext);
20
+ if (!ad.element) {
21
+ return null;
22
+ }
23
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Portal.default, {
24
+ container: () => {
25
+ const element = document.querySelector(classSelector);
26
+ if (element) {
27
+ if (ad.element === element) {
28
+ element.classList.add('ad');
29
+ } else {
30
+ element.classList.remove('ad');
31
+ }
32
+ }
33
+ return ad.element;
34
+ },
35
+ children: children
36
+ });
37
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = AdInHouse;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _AdDisplay = _interopRequireDefault(require("./AdDisplay"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function AdInHouse(props) {
14
+ const {
15
+ ad
16
+ } = props;
17
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AdDisplay.default, {
18
+ ad: {
19
+ poweredby: 'MUI',
20
+ label: `in-house-${ad.name}`,
21
+ ...ad
22
+ }
23
+ });
24
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AdContext = void 0;
7
+ exports.AdManager = AdManager;
8
+ exports.adShape = void 0;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _utils = require("@mui/material/utils");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const AdContext = exports.AdContext = /*#__PURE__*/React.createContext({
15
+ placement: 'body-top',
16
+ element: null
17
+ });
18
+
19
+ // Persisted for the whole session.
20
+ // The state is used to use different ad placements.
21
+ const randomSession = Math.random();
22
+
23
+ // Distribution profile:
24
+ // 20% body-inline
25
+ // 80% body-image
26
+ const adShape = exports.adShape = randomSession < 0.2 ? 'inline' : 'image';
27
+ function AdManager({
28
+ classSelector = '.description',
29
+ children
30
+ }) {
31
+ const [portal, setPortal] = React.useState({
32
+ placement: 'body-top',
33
+ element: null
34
+ });
35
+ (0, _utils.unstable_useEnhancedEffect)(() => {
36
+ const container = document.querySelector(classSelector);
37
+ setPortal({
38
+ placement: 'body-top',
39
+ element: container
40
+ });
41
+ }, [classSelector]);
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(AdContext.Provider, {
43
+ value: portal,
44
+ children: children
45
+ });
46
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AdProvider = AdProvider;
7
+ exports.useAdConfig = useAdConfig;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ const AdConfigContext = /*#__PURE__*/React.createContext(null);
13
+ function AdProvider(props) {
14
+ const {
15
+ children,
16
+ config
17
+ } = props;
18
+ const value = React.useMemo(() => ({
19
+ GADisplayRatio: 0.1,
20
+ ...config
21
+ }), [config]);
22
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(AdConfigContext.Provider, {
23
+ value: value,
24
+ children: children
25
+ });
26
+ }
27
+ function useAdConfig() {
28
+ const config = React.useContext(AdConfigContext);
29
+ if (!config) {
30
+ throw new Error('Could not find docs ad config context value; please ensure the component is wrapped in a <AdProvider>');
31
+ }
32
+ return config;
33
+ }