1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = ClassNameConfigurator;
|
7 | exports.useClassNamesOverride = useClassNamesOverride;
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 | var _jsxRuntime = require("react/jsx-runtime");
|
10 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
12 | const defaultContextValue = {
|
13 | disableDefaultClasses: false
|
14 | };
|
15 | const ClassNameConfiguratorContext = React.createContext(defaultContextValue);
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function useClassNamesOverride(generateUtilityClass) {
|
25 | const {
|
26 | disableDefaultClasses
|
27 | } = React.useContext(ClassNameConfiguratorContext);
|
28 | return slot => {
|
29 | if (disableDefaultClasses) {
|
30 | return '';
|
31 | }
|
32 | return generateUtilityClass(slot);
|
33 | };
|
34 | }
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function ClassNameConfigurator(props) {
|
40 | const {
|
41 | disableDefaultClasses,
|
42 | children
|
43 | } = props;
|
44 | const contextValue = React.useMemo(() => ({
|
45 | disableDefaultClasses: disableDefaultClasses != null ? disableDefaultClasses : false
|
46 | }), [disableDefaultClasses]);
|
47 | return (0, _jsxRuntime.jsx)(ClassNameConfiguratorContext.Provider, {
|
48 | value: contextValue,
|
49 | children: children
|
50 | });
|
51 | } |
\ | No newline at end of file |