@mui/docs 6.0.0-dev.240424162023-9968b4889d → 6.0.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 (125) hide show
  1. package/Ad/Ad.d.ts +6 -0
  2. package/Ad/Ad.js +228 -0
  3. package/Ad/AdCarbon.d.ts +3 -0
  4. package/Ad/AdCarbon.js +120 -0
  5. package/Ad/AdDisplay.d.ts +16 -0
  6. package/Ad/AdDisplay.js +89 -0
  7. package/Ad/AdGuest.d.ts +10 -0
  8. package/Ad/AdGuest.js +29 -0
  9. package/Ad/AdInHouse.d.ts +5 -0
  10. package/Ad/AdInHouse.js +15 -0
  11. package/Ad/AdManager.d.ts +16 -0
  12. package/Ad/AdManager.js +36 -0
  13. package/Ad/AdProvider.d.ts +15 -0
  14. package/Ad/AdProvider.js +24 -0
  15. package/Ad/ad.styles.d.ts +4327 -0
  16. package/Ad/ad.styles.js +89 -0
  17. package/Ad/index.d.ts +5 -0
  18. package/Ad/index.js +7 -0
  19. package/Ad/package.json +6 -0
  20. package/CHANGELOG.md +1367 -22
  21. package/CodeCopy/CodeCopy.js +1 -1
  22. package/CodeCopy/CodeCopyButton.js +11 -20
  23. package/CodeCopy/index.js +3 -3
  24. package/CodeCopy/useClipboardCopy.js +1 -1
  25. package/ComponentLinkHeader/ComponentLinkHeader.d.ts +9 -0
  26. package/ComponentLinkHeader/ComponentLinkHeader.js +197 -0
  27. package/ComponentLinkHeader/index.d.ts +2 -0
  28. package/ComponentLinkHeader/index.js +2 -0
  29. package/ComponentLinkHeader/package.json +6 -0
  30. package/DocsProvider/DocsProvider.d.ts +3 -1
  31. package/DocsProvider/DocsProvider.js +10 -5
  32. package/DocsProvider/index.js +1 -1
  33. package/HighlightedCode/HighlightedCode.d.ts +3 -1
  34. package/HighlightedCode/HighlightedCode.js +50 -24
  35. package/HighlightedCode/index.js +1 -1
  36. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.d.ts +29 -0
  37. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +355 -0
  38. package/HighlightedCodeWithTabs/index.d.ts +2 -0
  39. package/HighlightedCodeWithTabs/index.js +2 -0
  40. package/HighlightedCodeWithTabs/package.json +6 -0
  41. package/InfoCard/InfoCard.d.ts +0 -1
  42. package/InfoCard/InfoCard.js +46 -45
  43. package/InfoCard/index.js +1 -1
  44. package/Link/Link.js +41 -41
  45. package/Link/index.js +1 -1
  46. package/MarkdownElement/MarkdownElement.d.ts +1 -0
  47. package/MarkdownElement/MarkdownElement.js +187 -165
  48. package/MarkdownElement/index.js +1 -1
  49. package/NProgressBar/NProgressBar.js +6 -7
  50. package/NProgressBar/index.js +1 -1
  51. package/README.md +2 -2
  52. package/SectionTitle/SectionTitle.d.ts +7 -0
  53. package/SectionTitle/SectionTitle.js +30 -0
  54. package/SectionTitle/index.d.ts +1 -0
  55. package/SectionTitle/index.js +1 -0
  56. package/SectionTitle/package.json +6 -0
  57. package/branding/BrandingProvider.d.ts +1 -1
  58. package/branding/BrandingProvider.js +1 -1
  59. package/branding/brandingTheme.d.ts +2 -2
  60. package/branding/brandingTheme.js +657 -369
  61. package/branding/index.js +2 -2
  62. package/i18n/i18n.d.ts +2 -1
  63. package/i18n/i18n.js +19 -9
  64. package/i18n/index.js +1 -1
  65. package/node/Ad/Ad.js +238 -0
  66. package/node/Ad/AdCarbon.js +130 -0
  67. package/node/Ad/AdDisplay.js +97 -0
  68. package/node/Ad/AdGuest.js +37 -0
  69. package/node/Ad/AdInHouse.js +24 -0
  70. package/node/Ad/AdManager.js +46 -0
  71. package/node/Ad/AdProvider.js +33 -0
  72. package/node/Ad/ad.styles.js +97 -0
  73. package/node/Ad/index.js +63 -0
  74. package/node/CodeCopy/CodeCopy.js +10 -16
  75. package/node/CodeCopy/CodeCopyButton.js +10 -19
  76. package/node/CodeCopy/useClipboardCopy.js +1 -1
  77. package/node/ComponentLinkHeader/ComponentLinkHeader.js +206 -0
  78. package/node/ComponentLinkHeader/index.js +24 -0
  79. package/node/DocsProvider/DocsProvider.js +9 -4
  80. package/node/HighlightedCode/HighlightedCode.js +48 -22
  81. package/node/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +365 -0
  82. package/node/HighlightedCodeWithTabs/index.js +24 -0
  83. package/node/InfoCard/InfoCard.js +45 -44
  84. package/node/Link/Link.js +43 -42
  85. package/node/MarkdownElement/MarkdownElement.js +642 -623
  86. package/node/NProgressBar/NProgressBar.js +6 -7
  87. package/node/SectionTitle/SectionTitle.js +38 -0
  88. package/node/SectionTitle/index.js +16 -0
  89. package/node/branding/brandingTheme.js +657 -369
  90. package/node/i18n/i18n.js +18 -8
  91. package/node/svgIcons/AdobeXDIcon.js +22 -0
  92. package/node/svgIcons/BundleSizeIcon.js +22 -0
  93. package/node/svgIcons/FigmaIcon.js +31 -0
  94. package/node/svgIcons/FileDownload.js +3 -3
  95. package/node/svgIcons/JavaScript.js +3 -3
  96. package/node/svgIcons/MaterialDesignIcon.js +27 -0
  97. package/node/svgIcons/SketchIcon.js +36 -0
  98. package/node/svgIcons/TypeScript.js +3 -3
  99. package/node/svgIcons/W3CIcon.js +24 -0
  100. package/node/translations/translations.json +9 -4
  101. package/node/utils/loadScript.js +15 -0
  102. package/package.json +12 -10
  103. package/svgIcons/AdobeXDIcon.d.ts +4 -0
  104. package/svgIcons/AdobeXDIcon.js +14 -0
  105. package/svgIcons/BundleSizeIcon.d.ts +4 -0
  106. package/svgIcons/BundleSizeIcon.js +14 -0
  107. package/svgIcons/FigmaIcon.d.ts +4 -0
  108. package/svgIcons/FigmaIcon.js +23 -0
  109. package/svgIcons/FileDownload.d.ts +7 -0
  110. package/svgIcons/FileDownload.js +3 -3
  111. package/svgIcons/JavaScript.d.ts +7 -0
  112. package/svgIcons/JavaScript.js +3 -3
  113. package/svgIcons/MaterialDesignIcon.d.ts +4 -0
  114. package/svgIcons/MaterialDesignIcon.js +19 -0
  115. package/svgIcons/SketchIcon.d.ts +4 -0
  116. package/svgIcons/SketchIcon.js +28 -0
  117. package/svgIcons/TypeScript.d.ts +7 -0
  118. package/svgIcons/TypeScript.js +3 -3
  119. package/svgIcons/W3CIcon.d.ts +4 -0
  120. package/svgIcons/W3CIcon.js +16 -0
  121. package/translations/index.js +1 -1
  122. package/translations/translations.json +9 -4
  123. package/tsconfig.build.tsbuildinfo +1 -1
  124. package/utils/loadScript.d.ts +1 -0
  125. package/utils/loadScript.js +9 -0
package/branding/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './brandingTheme';
2
- export * from './BrandingProvider';
1
+ export * from "./brandingTheme.js";
2
+ export * from "./BrandingProvider.js";
package/i18n/i18n.d.ts CHANGED
@@ -17,7 +17,8 @@ export declare function useSetUserLanguage(): React.Dispatch<React.SetStateActio
17
17
  export interface TranslateOptions {
18
18
  ignoreWarning?: boolean;
19
19
  }
20
- export declare function useTranslate(): (key: string, options?: TranslateOptions) => any;
20
+ export type Translate = (key: string, options?: TranslateOptions) => any;
21
+ export declare function useTranslate(): Translate;
21
22
  export type Translations = {
22
23
  [key in string]?: string | Translations;
23
24
  };
package/i18n/i18n.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { deepmerge } from '@mui/utils';
4
- import defaultTranslations from '../translations';
4
+ import defaultTranslations from "../translations/index.js";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  const TranslationsContext = /*#__PURE__*/React.createContext(defaultTranslations);
7
7
  function TranslationsProvider({
@@ -19,7 +19,11 @@ function getPath(obj, path) {
19
19
  if (!path || typeof path !== 'string') {
20
20
  return null;
21
21
  }
22
- return path.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
22
+ const translation = path.split('.').reduce((acc, item) => acc && typeof acc === 'object' && acc[item] || null, obj);
23
+ if (typeof translation === 'object') {
24
+ return null;
25
+ }
26
+ return translation;
23
27
  }
24
28
  const UserLanguageContext = /*#__PURE__*/React.createContext({
25
29
  userLanguage: '',
@@ -60,6 +64,16 @@ export function useSetUserLanguage() {
60
64
  return React.useContext(UserLanguageContext).setUserLanguage;
61
65
  }
62
66
  const warnedOnce = {};
67
+
68
+ // TODO, migrate to use warnOnce() helper
69
+ const warn = (userLanguage, key, ignoreWarning) => {
70
+ const fullKey = `${userLanguage}:${key}`;
71
+ // No warnings in CI env
72
+ if (!ignoreWarning && !warnedOnce[fullKey] && typeof window !== 'undefined') {
73
+ console.warn(`Missing translation for ${fullKey}`);
74
+ warnedOnce[fullKey] = true;
75
+ }
76
+ };
63
77
  export function useTranslate() {
64
78
  const userLanguage = useUserLanguage();
65
79
  const translations = React.useContext(TranslationsContext);
@@ -74,13 +88,9 @@ export function useTranslate() {
74
88
  }
75
89
  const translation = getPath(wordings, key);
76
90
  if (!translation) {
77
- const fullKey = `${userLanguage}:${key}`;
78
- // No warnings in CI env
79
- if (!ignoreWarning && !warnedOnce[fullKey] && typeof window !== 'undefined') {
80
- console.error(`Missing translation for ${fullKey}`);
81
- warnedOnce[fullKey] = true;
82
- }
83
- return getPath(translations.en, key);
91
+ warn(userLanguage, key, ignoreWarning);
92
+ const enTranslation = getPath(translations.en, key);
93
+ return enTranslation ?? null;
84
94
  }
85
95
  return translation;
86
96
  }, [userLanguage, translations]);
package/i18n/index.js CHANGED
@@ -1 +1 @@
1
- export * from './i18n';
1
+ export * from "./i18n.js";
package/node/Ad/Ad.js ADDED
@@ -0,0 +1,238 @@
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(undefined);
168
+ const checkAdblock = React.useCallback((attempt = 1) => {
169
+ if (document.querySelector('.ea-placement') || document.querySelector('#carbonads') || document.querySelector('.carbonads') || carbonOut) {
170
+ if (document.querySelector('#carbonads a') && document.querySelector('#carbonads a')?.getAttribute('href') === 'https://material-ui-next.com/discover-more/backers') {
171
+ setCarbonOut(true);
172
+ }
173
+ setAdblock(false);
174
+ return;
175
+ }
176
+ if (attempt < 30) {
177
+ timerAdblock.current = setTimeout(() => {
178
+ checkAdblock(attempt + 1);
179
+ }, 500);
180
+ }
181
+ if (attempt > 6) {
182
+ setAdblock(true);
183
+ }
184
+ }, [carbonOut]);
185
+ React.useEffect(() => {
186
+ if (disableAd) {
187
+ return undefined;
188
+ }
189
+ checkAdblock();
190
+ return () => {
191
+ clearTimeout(timerAdblock.current);
192
+ };
193
+ }, [checkAdblock]);
194
+ const {
195
+ GADisplayRatio
196
+ } = (0, _AdProvider.useAdConfig)();
197
+ React.useEffect(() => {
198
+ // Avoid an exceed on the Google Analytics quotas.
199
+ if (Math.random() > (GADisplayRatio ?? 0.1) || !eventLabel) {
200
+ return undefined;
201
+ }
202
+ const delay = setTimeout(() => {
203
+ window.gtag('event', 'ad', {
204
+ eventAction: 'display',
205
+ eventLabel
206
+ });
207
+ }, 2500);
208
+ return () => {
209
+ clearTimeout(delay);
210
+ };
211
+ }, [GADisplayRatio, eventLabel]);
212
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
213
+ component: "span",
214
+ sx: theme => ({
215
+ position: 'relative',
216
+ display: 'block',
217
+ mt: AD_MARGIN_TOP,
218
+ mb: AD_MARGIN_BOTTOM,
219
+ minHeight: AD_HEIGHT_MOBILE,
220
+ [theme.breakpoints.up('sm')]: {
221
+ minHeight: AD_HEIGHT
222
+ },
223
+ ...(_AdManager.adShape === 'image' && {}),
224
+ ...(_AdManager.adShape === 'inline' && {
225
+ display: 'flex',
226
+ alignItems: 'flex-end'
227
+ })
228
+ }),
229
+ "data-ga-event-category": "ad",
230
+ "data-ga-event-action": "click",
231
+ "data-ga-event-label": eventLabel,
232
+ className: "Ad-root",
233
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AdErrorBoundary, {
234
+ eventLabel: eventLabel,
235
+ children: children
236
+ })
237
+ });
238
+ }
@@ -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 ?? 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
+ }