@mui/internal-docs-infra 0.1.1-alpha.3 → 0.1.1-canary.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.
- package/README.md +1 -3
- package/esm/package.json +1 -0
- package/esm/useCopier/index.d.ts +15 -0
- package/esm/useCopier/index.js +62 -0
- package/{useCode/useCode.d.ts → esm/useDemo/index.d.ts} +29 -15
- package/esm/useDemo/index.d.ts.map +1 -0
- package/esm/useDemo/index.js +104 -0
- package/package.json +34 -29
- package/useCopier/index.js +18 -10
- package/useDemo/index.d.ts +25 -13
- package/useDemo/index.js +109 -14
- package/CodeControllerContext/CodeControllerContext.d.ts +0 -22
- package/CodeControllerContext/CodeControllerContext.d.ts.map +0 -1
- package/CodeControllerContext/CodeControllerContext.js +0 -14
- package/CodeControllerContext/index.d.ts +0 -1
- package/CodeControllerContext/index.d.ts.map +0 -1
- package/CodeControllerContext/index.js +0 -1
- package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighter.js +0 -321
- package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterClient.js +0 -399
- package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -14
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterContext.js +0 -14
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +0 -7
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.js +0 -11
- package/CodeHighlighter/applyTransform.d.ts +0 -19
- package/CodeHighlighter/applyTransform.d.ts.map +0 -1
- package/CodeHighlighter/applyTransform.js +0 -75
- package/CodeHighlighter/codeToFallbackProps.d.ts +0 -2
- package/CodeHighlighter/codeToFallbackProps.d.ts.map +0 -1
- package/CodeHighlighter/codeToFallbackProps.js +0 -70
- package/CodeHighlighter/errors.d.ts +0 -0
- package/CodeHighlighter/errors.d.ts.map +0 -1
- package/CodeHighlighter/errors.js +0 -1
- package/CodeHighlighter/hasAllVariants.d.ts +0 -2
- package/CodeHighlighter/hasAllVariants.d.ts.map +0 -1
- package/CodeHighlighter/hasAllVariants.js +0 -31
- package/CodeHighlighter/index.d.ts +0 -4
- package/CodeHighlighter/index.d.ts.map +0 -1
- package/CodeHighlighter/index.js +0 -4
- package/CodeHighlighter/loadFallbackCode.d.ts +0 -9
- package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
- package/CodeHighlighter/loadFallbackCode.js +0 -468
- package/CodeHighlighter/loadVariant.d.ts +0 -11
- package/CodeHighlighter/loadVariant.d.ts.map +0 -1
- package/CodeHighlighter/loadVariant.js +0 -719
- package/CodeHighlighter/maybeInitialData.d.ts +0 -10
- package/CodeHighlighter/maybeInitialData.d.ts.map +0 -1
- package/CodeHighlighter/maybeInitialData.js +0 -94
- package/CodeHighlighter/parseCode.d.ts +0 -6
- package/CodeHighlighter/parseCode.d.ts.map +0 -1
- package/CodeHighlighter/parseCode.js +0 -122
- package/CodeHighlighter/parseControlledCode.d.ts +0 -6
- package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
- package/CodeHighlighter/parseControlledCode.js +0 -76
- package/CodeHighlighter/transformCode.d.ts +0 -20
- package/CodeHighlighter/transformCode.d.ts.map +0 -1
- package/CodeHighlighter/transformCode.js +0 -223
- package/CodeHighlighter/transformParsedSource.d.ts +0 -3
- package/CodeHighlighter/transformParsedSource.d.ts.map +0 -1
- package/CodeHighlighter/transformParsedSource.js +0 -66
- package/CodeHighlighter/transformSource.d.ts +0 -2
- package/CodeHighlighter/transformSource.d.ts.map +0 -1
- package/CodeHighlighter/transformSource.js +0 -107
- package/CodeHighlighter/types.d.ts +0 -138
- package/CodeHighlighter/types.d.ts.map +0 -1
- package/CodeHighlighter/types.js +0 -1
- package/CodeProvider/CodeContext.d.ts +0 -12
- package/CodeProvider/CodeContext.d.ts.map +0 -1
- package/CodeProvider/CodeContext.js +0 -8
- package/CodeProvider/CodeProvider.d.ts +0 -13
- package/CodeProvider/CodeProvider.d.ts.map +0 -1
- package/CodeProvider/CodeProvider.js +0 -50
- package/CodeProvider/index.d.ts +0 -2
- package/CodeProvider/index.d.ts.map +0 -1
- package/CodeProvider/index.js +0 -2
- package/hast/hast.d.ts +0 -11
- package/hast/hast.d.ts.map +0 -1
- package/hast/hast.js +0 -66
- package/hast/index.d.ts +0 -1
- package/hast/index.d.ts.map +0 -1
- package/hast/index.js +0 -1
- package/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
- package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/index.js +0 -4
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -195
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -20
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -15
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
- package/loadServerCodeMeta/index.d.ts +0 -1
- package/loadServerCodeMeta/index.d.ts.map +0 -1
- package/loadServerCodeMeta/index.js +0 -1
- package/loadServerCodeMeta/serverLoadCodeMeta.d.ts +0 -24
- package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
- package/loadServerCodeMeta/serverLoadCodeMeta.js +0 -77
- package/loadServerSource/index.d.ts +0 -1
- package/loadServerSource/index.d.ts.map +0 -1
- package/loadServerSource/index.js +0 -1
- package/loadServerSource/serverLoadSource.d.ts +0 -25
- package/loadServerSource/serverLoadSource.d.ts.map +0 -1
- package/loadServerSource/serverLoadSource.js +0 -100
- package/loaderUtils/getFileNameFromUrl.d.ts +0 -11
- package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/loaderUtils/getFileNameFromUrl.js +0 -32
- package/loaderUtils/index.d.ts +0 -5
- package/loaderUtils/index.d.ts.map +0 -1
- package/loaderUtils/index.js +0 -5
- package/loaderUtils/processImports.d.ts +0 -19
- package/loaderUtils/processImports.d.ts.map +0 -1
- package/loaderUtils/processImports.js +0 -82
- package/loaderUtils/resolveImports.d.ts +0 -4
- package/loaderUtils/resolveImports.d.ts.map +0 -1
- package/loaderUtils/resolveImports.js +0 -71
- package/loaderUtils/resolveModulePath.d.ts +0 -74
- package/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/loaderUtils/resolveModulePath.js +0 -862
- package/loaderUtils/resolveModulePathWithFs.d.ts +0 -44
- package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/loaderUtils/resolveModulePathWithFs.js +0 -159
- package/loaderUtils/rewriteImports.d.ts +0 -9
- package/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/loaderUtils/rewriteImports.js +0 -57
- package/parseSource/grammars.d.ts +0 -2
- package/parseSource/grammars.d.ts.map +0 -1
- package/parseSource/grammars.js +0 -27
- package/parseSource/index.d.ts +0 -1
- package/parseSource/index.d.ts.map +0 -1
- package/parseSource/index.js +0 -1
- package/parseSource/parseSource.d.ts +0 -3
- package/parseSource/parseSource.d.ts.map +0 -1
- package/parseSource/parseSource.js +0 -37
- package/transformRelativeMarkdownPaths/index.d.ts +0 -2
- package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/index.js +0 -4
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
- package/transformTsToJs/index.d.ts +0 -1
- package/transformTsToJs/index.d.ts.map +0 -1
- package/transformTsToJs/index.js +0 -1
- package/transformTsToJs/removeTypes.d.ts +0 -13
- package/transformTsToJs/removeTypes.d.ts.map +0 -1
- package/transformTsToJs/removeTypes.js +0 -134
- package/transformTsToJs/transformTsToJs.d.ts +0 -3
- package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
- package/transformTsToJs/transformTsToJs.js +0 -34
- package/useCode/index.d.ts +0 -1
- package/useCode/index.d.ts.map +0 -1
- package/useCode/index.js +0 -1
- package/useCode/useCode.d.ts.map +0 -1
- package/useCode/useCode.js +0 -442
- package/useDemo/index.d.ts.map +0 -1
- package/useOnHydrate/index.d.ts +0 -1
- package/useOnHydrate/index.d.ts.map +0 -1
- package/useOnHydrate/index.js +0 -1
- package/useOnHydrate/useOnHydrate.d.ts +0 -1
- package/useOnHydrate/useOnHydrate.d.ts.map +0 -1
- package/useOnHydrate/useOnHydrate.js +0 -18
- package/useOnIdle/index.d.ts +0 -1
- package/useOnIdle/index.d.ts.map +0 -1
- package/useOnIdle/index.js +0 -1
- package/useOnIdle/useOnIdle.d.ts +0 -1
- package/useOnIdle/useOnIdle.d.ts.map +0 -1
- package/useOnIdle/useOnIdle.js +0 -39
- /package/{useCopier → esm/useCopier}/index.d.ts.map +0 -0
package/README.md
CHANGED
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type OnCopied = () => void;
|
|
3
|
+
type OnCopyError = (error: unknown) => void;
|
|
4
|
+
type OnCopyClick = (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
5
|
+
export type UseCopierOpts = {
|
|
6
|
+
onCopied?: OnCopied;
|
|
7
|
+
onError?: OnCopyError;
|
|
8
|
+
onClick?: OnCopyClick;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function useCopier(contents: (() => string | undefined) | string, opts?: UseCopierOpts): {
|
|
12
|
+
copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import copyToClipboard from 'clipboard-copy';
|
|
6
|
+
export function useCopier(contents, opts) {
|
|
7
|
+
var _ref = opts || {},
|
|
8
|
+
onCopied = _ref.onCopied,
|
|
9
|
+
onError = _ref.onError,
|
|
10
|
+
onClick = _ref.onClick,
|
|
11
|
+
_ref$timeout = _ref.timeout,
|
|
12
|
+
timeout = _ref$timeout === void 0 ? 2000 : _ref$timeout;
|
|
13
|
+
var copyTimeoutRef = React.useRef(undefined);
|
|
14
|
+
var _React$useState = React.useState(false),
|
|
15
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
16
|
+
disabled = _React$useState2[0],
|
|
17
|
+
setDisabled = _React$useState2[1];
|
|
18
|
+
var copy = React.useCallback(/*#__PURE__*/function () {
|
|
19
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
20
|
+
var content;
|
|
21
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
clearTimeout(copyTimeoutRef.current);
|
|
25
|
+
setDisabled(true);
|
|
26
|
+
_context.prev = 2;
|
|
27
|
+
content = typeof contents === 'function' ? contents() : contents;
|
|
28
|
+
if (!content) {
|
|
29
|
+
_context.next = 7;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
_context.next = 7;
|
|
33
|
+
return copyToClipboard(content);
|
|
34
|
+
case 7:
|
|
35
|
+
onCopied == null || onCopied();
|
|
36
|
+
_context.next = 13;
|
|
37
|
+
break;
|
|
38
|
+
case 10:
|
|
39
|
+
_context.prev = 10;
|
|
40
|
+
_context.t0 = _context["catch"](2);
|
|
41
|
+
onError == null || onError(_context.t0);
|
|
42
|
+
case 13:
|
|
43
|
+
onClick == null || onClick(event);
|
|
44
|
+
copyTimeoutRef.current = setTimeout(function () {
|
|
45
|
+
clearTimeout(copyTimeoutRef.current);
|
|
46
|
+
setDisabled(false);
|
|
47
|
+
}, timeout);
|
|
48
|
+
case 15:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee, null, [[2, 10]]);
|
|
53
|
+
}));
|
|
54
|
+
return function (_x) {
|
|
55
|
+
return _ref2.apply(this, arguments);
|
|
56
|
+
};
|
|
57
|
+
}(), [contents, timeout, onCopied, onError, onClick]);
|
|
58
|
+
return {
|
|
59
|
+
copy: copy,
|
|
60
|
+
disabled: disabled
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Nodes } from 'hast';
|
|
2
3
|
import { UseCopierOpts } from "../useCopier/index.js";
|
|
3
|
-
|
|
4
|
-
type
|
|
4
|
+
type Source = Nodes;
|
|
5
|
+
export type Variant = {
|
|
6
|
+
component: React.ReactNode;
|
|
7
|
+
fileName: string;
|
|
8
|
+
source: Source;
|
|
9
|
+
extraSource?: {
|
|
10
|
+
[key: string]: Source;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type Demo = {
|
|
14
|
+
name?: string;
|
|
15
|
+
slug?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
variants: {
|
|
18
|
+
[key: string]: Variant;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type UseDemoOpts = {
|
|
5
22
|
defaultOpen?: boolean;
|
|
6
23
|
copy?: UseCopierOpts;
|
|
7
24
|
githubUrlPrefix?: string;
|
|
8
25
|
codeSandboxUrlPrefix?: string;
|
|
9
26
|
stackBlitzPrefix?: string;
|
|
10
|
-
initialVariant?: string;
|
|
11
|
-
initialTransform?: string;
|
|
12
27
|
};
|
|
13
|
-
export
|
|
28
|
+
export declare function useDemo(demo: Demo, opts?: UseDemoOpts): {
|
|
14
29
|
component: React.ReactNode;
|
|
30
|
+
name: string | undefined;
|
|
31
|
+
slug: string | undefined;
|
|
32
|
+
description: string | undefined;
|
|
15
33
|
ref: React.RefObject<HTMLDivElement | null>;
|
|
16
34
|
variants: string[];
|
|
17
35
|
selectedVariant: string;
|
|
18
36
|
selectVariant: React.Dispatch<React.SetStateAction<string>>;
|
|
19
|
-
files:
|
|
37
|
+
files: {
|
|
20
38
|
name: string;
|
|
21
|
-
component:
|
|
22
|
-
}
|
|
23
|
-
selectedFile:
|
|
39
|
+
component: JSX.Element;
|
|
40
|
+
}[];
|
|
41
|
+
selectedFile: any;
|
|
24
42
|
selectedFileName: string;
|
|
25
|
-
selectFileName:
|
|
43
|
+
selectFileName: React.Dispatch<React.SetStateAction<string>>;
|
|
26
44
|
expanded: boolean;
|
|
27
45
|
expand: () => void;
|
|
28
46
|
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
29
47
|
resetFocus: () => void;
|
|
30
48
|
copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
31
49
|
copyDisabled: boolean;
|
|
32
|
-
|
|
33
|
-
selectedTransform: string | null | undefined;
|
|
34
|
-
selectTransform: (transformName: string | null) => void;
|
|
35
|
-
}
|
|
36
|
-
export declare function useCode(contentProps: ContentProps, opts?: UseCodeOpts): UseCodeResult;
|
|
50
|
+
};
|
|
37
51
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useDemo/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAK7B,OAAO,EAAa,aAAa,EAAE,MAAM,cAAc,CAAC;AAExD,KAAK,MAAM,GAAG,KAAK,CAAC;AACpB,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACzC,CAAC;AACF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAMF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;EA0ErD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
import { toText } from 'hast-util-to-text';
|
|
6
|
+
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
|
7
|
+
import kebabCase from 'kebab-case';
|
|
8
|
+
import { useCopier } from "../useCopier/index.js";
|
|
9
|
+
function toComponent(source) {
|
|
10
|
+
return toJsxRuntime(source, {
|
|
11
|
+
Fragment: Fragment,
|
|
12
|
+
jsx: jsx,
|
|
13
|
+
jsxs: jsxs
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function useDemo(demo, opts) {
|
|
17
|
+
var _ref = opts || {},
|
|
18
|
+
copyOpts = _ref.copy,
|
|
19
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
20
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen;
|
|
21
|
+
var slug = React.useMemo(function () {
|
|
22
|
+
return demo.slug || (demo.name ? kebabCase(demo.name, false) : undefined);
|
|
23
|
+
}, [demo.slug, demo.name]);
|
|
24
|
+
var _React$useState = React.useState(defaultOpen),
|
|
25
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
26
|
+
expanded = _React$useState2[0],
|
|
27
|
+
setExpanded = _React$useState2[1];
|
|
28
|
+
var expand = React.useCallback(function () {
|
|
29
|
+
return setExpanded(true);
|
|
30
|
+
}, []);
|
|
31
|
+
var ref = React.useRef(null);
|
|
32
|
+
var resetFocus = React.useCallback(function () {
|
|
33
|
+
var _ref$current;
|
|
34
|
+
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
35
|
+
}, []);
|
|
36
|
+
var variantKeys = React.useMemo(function () {
|
|
37
|
+
return Object.keys(demo.variants);
|
|
38
|
+
}, [demo.variants]);
|
|
39
|
+
var _React$useState3 = React.useState(variantKeys[0]),
|
|
40
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
41
|
+
selectedVariantKey = _React$useState4[0],
|
|
42
|
+
setSelectedVariantKey = _React$useState4[1];
|
|
43
|
+
var selectedVariant = demo.variants[selectedVariantKey];
|
|
44
|
+
var _React$useState5 = React.useState(selectedVariant.fileName),
|
|
45
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
46
|
+
selectedFileName = _React$useState6[0],
|
|
47
|
+
setSelectedFileName = _React$useState6[1];
|
|
48
|
+
var selectedFile = React.useMemo(function () {
|
|
49
|
+
var _selectedVariant$extr;
|
|
50
|
+
return selectedFileName === selectedVariant.fileName ? selectedVariant.source : (_selectedVariant$extr = selectedVariant.extraSource) == null ? void 0 : _selectedVariant$extr[selectedFileName];
|
|
51
|
+
}, [selectedFileName, selectedVariant]);
|
|
52
|
+
|
|
53
|
+
// if copying, convert the selected file's hast to text
|
|
54
|
+
var sourceFileToText = React.useCallback(function () {
|
|
55
|
+
return selectedFile && toText(selectedFile, {
|
|
56
|
+
whitespace: 'pre'
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
// TODO: allow passing the filename to copy
|
|
60
|
+
[selectedFile]);
|
|
61
|
+
var _useCopier = useCopier(sourceFileToText, copyOpts),
|
|
62
|
+
copy = _useCopier.copy,
|
|
63
|
+
copyDisabled = _useCopier.disabled;
|
|
64
|
+
|
|
65
|
+
// transform hast source to React components
|
|
66
|
+
var files = React.useMemo(function () {
|
|
67
|
+
var extraSource = selectedVariant.extraSource;
|
|
68
|
+
return [{
|
|
69
|
+
name: selectedVariant.fileName,
|
|
70
|
+
component: toComponent(selectedVariant.source)
|
|
71
|
+
}].concat(_toConsumableArray(extraSource ? Object.keys(extraSource).map(function (name) {
|
|
72
|
+
return {
|
|
73
|
+
name: name,
|
|
74
|
+
component: toComponent(extraSource[name])
|
|
75
|
+
};
|
|
76
|
+
}) : []));
|
|
77
|
+
}, [selectedVariant]);
|
|
78
|
+
var selectedFileComponent = React.useMemo(function () {
|
|
79
|
+
var matchedFile = files.find(function (file) {
|
|
80
|
+
return file.name === selectedFileName;
|
|
81
|
+
});
|
|
82
|
+
return matchedFile ? matchedFile.component : null;
|
|
83
|
+
}, [files, selectedFileName]);
|
|
84
|
+
return {
|
|
85
|
+
component: selectedVariant.component,
|
|
86
|
+
name: demo.name,
|
|
87
|
+
slug: slug,
|
|
88
|
+
description: demo.description,
|
|
89
|
+
ref: ref,
|
|
90
|
+
variants: variantKeys,
|
|
91
|
+
selectedVariant: selectedVariantKey,
|
|
92
|
+
selectVariant: setSelectedVariantKey,
|
|
93
|
+
files: files,
|
|
94
|
+
selectedFile: selectedFileComponent,
|
|
95
|
+
selectedFileName: selectedFileName,
|
|
96
|
+
selectFileName: setSelectedFileName,
|
|
97
|
+
expanded: expanded,
|
|
98
|
+
expand: expand,
|
|
99
|
+
setExpanded: setExpanded,
|
|
100
|
+
resetFocus: resetFocus,
|
|
101
|
+
copy: copy,
|
|
102
|
+
copyDisabled: copyDisabled
|
|
103
|
+
};
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.1.1-
|
|
3
|
+
"version": "0.1.1-canary.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
"./package.json": "./package.json",
|
|
10
|
-
".": "./index.js",
|
|
11
|
-
"./*": "./*/index.js",
|
|
12
|
-
"./*/types": "./*/types.js",
|
|
13
|
-
"./*/errors": "./*/errors.js"
|
|
14
|
-
},
|
|
15
6
|
"keywords": [
|
|
16
7
|
"react",
|
|
17
8
|
"react-component",
|
|
@@ -31,23 +22,12 @@
|
|
|
31
22
|
"homepage": "https://github.com/mui/mui-public/tree/master/packages/docs-infra",
|
|
32
23
|
"dependencies": {
|
|
33
24
|
"@babel/runtime": "^7.27.6",
|
|
34
|
-
"@
|
|
35
|
-
"@wooorm/starry-night": "^3.8.0",
|
|
25
|
+
"@types/hast": "^3.0.4",
|
|
36
26
|
"clipboard-copy": "^4.0.1",
|
|
27
|
+
"hast": "^1.0.0",
|
|
37
28
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
38
|
-
"hast-util-to-mdast": "^10.1.2",
|
|
39
29
|
"hast-util-to-text": "^4.0.2",
|
|
40
|
-
"
|
|
41
|
-
"jsondiffpatch": "^0.7.3",
|
|
42
|
-
"kebab-case": "^2.0.2",
|
|
43
|
-
"prettier": "^3.5.3",
|
|
44
|
-
"rehype-parse": "^9.0.1",
|
|
45
|
-
"rehype-remark": "^10.0.1",
|
|
46
|
-
"rehype-sanitize": "^6.0.0",
|
|
47
|
-
"remark-stringify": "^11.0.0",
|
|
48
|
-
"unified": "^11.0.5",
|
|
49
|
-
"unist-util-visit": "^5.0.0",
|
|
50
|
-
"vscode-oniguruma": "^2.0.1"
|
|
30
|
+
"kebab-case": "^2.0.2"
|
|
51
31
|
},
|
|
52
32
|
"peerDependencies": {
|
|
53
33
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
@@ -59,12 +39,37 @@
|
|
|
59
39
|
"optional": true
|
|
60
40
|
}
|
|
61
41
|
},
|
|
62
|
-
"publishConfig": {
|
|
63
|
-
"access": "public",
|
|
64
|
-
"directory": "build"
|
|
65
|
-
},
|
|
66
42
|
"engines": {
|
|
67
43
|
"node": ">=14.0.0"
|
|
68
44
|
},
|
|
69
|
-
"
|
|
45
|
+
"gitSha": "874f7b535bb6647f1fc50086b11f8da2d4f27738",
|
|
46
|
+
"private": false,
|
|
47
|
+
"exports": {
|
|
48
|
+
"./package.json": "./package.json",
|
|
49
|
+
".": {
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./index.d.ts",
|
|
52
|
+
"default": "./index.js"
|
|
53
|
+
},
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./esm/index.d.ts",
|
|
56
|
+
"default": "./esm/index.js"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"./*": {
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./*/index.d.ts",
|
|
62
|
+
"default": "./*/index.js"
|
|
63
|
+
},
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./esm/*/index.d.ts",
|
|
66
|
+
"default": "./esm/*/index.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"./esm": null,
|
|
70
|
+
"./modern": null
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
}
|
|
70
75
|
}
|
package/useCopier/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useCopier = useCopier;
|
|
9
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _clipboardCopy = _interopRequireDefault(require("clipboard-copy"));
|
|
14
|
+
function useCopier(contents, opts) {
|
|
7
15
|
var _ref = opts || {},
|
|
8
16
|
onCopied = _ref.onCopied,
|
|
9
17
|
onError = _ref.onError,
|
|
@@ -12,13 +20,13 @@ export function useCopier(contents, opts) {
|
|
|
12
20
|
timeout = _ref$timeout === void 0 ? 2000 : _ref$timeout;
|
|
13
21
|
var copyTimeoutRef = React.useRef(undefined);
|
|
14
22
|
var _React$useState = React.useState(false),
|
|
15
|
-
_React$useState2 =
|
|
23
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
16
24
|
disabled = _React$useState2[0],
|
|
17
25
|
setDisabled = _React$useState2[1];
|
|
18
26
|
var copy = React.useCallback(/*#__PURE__*/function () {
|
|
19
|
-
var _ref2 =
|
|
27
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(event) {
|
|
20
28
|
var content;
|
|
21
|
-
return
|
|
29
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
22
30
|
while (1) switch (_context.prev = _context.next) {
|
|
23
31
|
case 0:
|
|
24
32
|
clearTimeout(copyTimeoutRef.current);
|
|
@@ -30,7 +38,7 @@ export function useCopier(contents, opts) {
|
|
|
30
38
|
break;
|
|
31
39
|
}
|
|
32
40
|
_context.next = 7;
|
|
33
|
-
return
|
|
41
|
+
return (0, _clipboardCopy["default"])(content);
|
|
34
42
|
case 7:
|
|
35
43
|
onCopied == null || onCopied();
|
|
36
44
|
_context.next = 13;
|
package/useDemo/index.d.ts
CHANGED
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Nodes } from 'hast';
|
|
2
3
|
import { UseCopierOpts } from "../useCopier/index.js";
|
|
3
|
-
|
|
4
|
+
type Source = Nodes;
|
|
5
|
+
export type Variant = {
|
|
6
|
+
component: React.ReactNode;
|
|
7
|
+
fileName: string;
|
|
8
|
+
source: Source;
|
|
9
|
+
extraSource?: {
|
|
10
|
+
[key: string]: Source;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type Demo = {
|
|
14
|
+
name?: string;
|
|
15
|
+
slug?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
variants: {
|
|
18
|
+
[key: string]: Variant;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
4
21
|
type UseDemoOpts = {
|
|
5
22
|
defaultOpen?: boolean;
|
|
6
23
|
copy?: UseCopierOpts;
|
|
7
24
|
githubUrlPrefix?: string;
|
|
8
25
|
codeSandboxUrlPrefix?: string;
|
|
9
26
|
stackBlitzPrefix?: string;
|
|
10
|
-
initialVariant?: string;
|
|
11
|
-
initialTransform?: string;
|
|
12
27
|
};
|
|
13
|
-
export declare function useDemo(
|
|
28
|
+
export declare function useDemo(demo: Demo, opts?: UseDemoOpts): {
|
|
29
|
+
component: React.ReactNode;
|
|
14
30
|
name: string | undefined;
|
|
15
31
|
slug: string | undefined;
|
|
16
32
|
description: string | undefined;
|
|
17
|
-
component: React.ReactNode;
|
|
18
33
|
ref: React.RefObject<HTMLDivElement | null>;
|
|
19
34
|
variants: string[];
|
|
20
35
|
selectedVariant: string;
|
|
21
36
|
selectVariant: React.Dispatch<React.SetStateAction<string>>;
|
|
22
|
-
files:
|
|
37
|
+
files: {
|
|
23
38
|
name: string;
|
|
24
|
-
component:
|
|
25
|
-
}
|
|
26
|
-
selectedFile:
|
|
39
|
+
component: JSX.Element;
|
|
40
|
+
}[];
|
|
41
|
+
selectedFile: any;
|
|
27
42
|
selectedFileName: string;
|
|
28
|
-
selectFileName:
|
|
43
|
+
selectFileName: React.Dispatch<React.SetStateAction<string>>;
|
|
29
44
|
expanded: boolean;
|
|
30
45
|
expand: () => void;
|
|
31
46
|
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
32
47
|
resetFocus: () => void;
|
|
33
48
|
copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
34
49
|
copyDisabled: boolean;
|
|
35
|
-
availableTransforms: string[];
|
|
36
|
-
selectedTransform: string | null | undefined;
|
|
37
|
-
selectTransform: (transformName: string | null) => void;
|
|
38
50
|
};
|
|
39
51
|
export {};
|
package/useDemo/index.js
CHANGED
|
@@ -1,17 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useDemo = useDemo;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
var _hastUtilToText = require("hast-util-to-text");
|
|
14
|
+
var _hastUtilToJsxRuntime = require("hast-util-to-jsx-runtime");
|
|
15
|
+
var _kebabCase = _interopRequireDefault(require("kebab-case"));
|
|
16
|
+
var _useCopier2 = require("../useCopier");
|
|
17
|
+
function toComponent(source) {
|
|
18
|
+
return (0, _hastUtilToJsxRuntime.toJsxRuntime)(source, {
|
|
19
|
+
Fragment: _jsxRuntime.Fragment,
|
|
20
|
+
jsx: _jsxRuntime.jsx,
|
|
21
|
+
jsxs: _jsxRuntime.jsxs
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function useDemo(demo, opts) {
|
|
25
|
+
var _ref = opts || {},
|
|
26
|
+
copyOpts = _ref.copy,
|
|
27
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
28
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen;
|
|
8
29
|
var slug = React.useMemo(function () {
|
|
9
|
-
return
|
|
10
|
-
}, [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
return demo.slug || (demo.name ? (0, _kebabCase["default"])(demo.name, false) : undefined);
|
|
31
|
+
}, [demo.slug, demo.name]);
|
|
32
|
+
var _React$useState = React.useState(defaultOpen),
|
|
33
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
34
|
+
expanded = _React$useState2[0],
|
|
35
|
+
setExpanded = _React$useState2[1];
|
|
36
|
+
var expand = React.useCallback(function () {
|
|
37
|
+
return setExpanded(true);
|
|
38
|
+
}, []);
|
|
39
|
+
var ref = React.useRef(null);
|
|
40
|
+
var resetFocus = React.useCallback(function () {
|
|
41
|
+
var _ref$current;
|
|
42
|
+
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
43
|
+
}, []);
|
|
44
|
+
var variantKeys = React.useMemo(function () {
|
|
45
|
+
return Object.keys(demo.variants);
|
|
46
|
+
}, [demo.variants]);
|
|
47
|
+
var _React$useState3 = React.useState(variantKeys[0]),
|
|
48
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
49
|
+
selectedVariantKey = _React$useState4[0],
|
|
50
|
+
setSelectedVariantKey = _React$useState4[1];
|
|
51
|
+
var selectedVariant = demo.variants[selectedVariantKey];
|
|
52
|
+
var _React$useState5 = React.useState(selectedVariant.fileName),
|
|
53
|
+
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 2),
|
|
54
|
+
selectedFileName = _React$useState6[0],
|
|
55
|
+
setSelectedFileName = _React$useState6[1];
|
|
56
|
+
var selectedFile = React.useMemo(function () {
|
|
57
|
+
var _selectedVariant$extr;
|
|
58
|
+
return selectedFileName === selectedVariant.fileName ? selectedVariant.source : (_selectedVariant$extr = selectedVariant.extraSource) == null ? void 0 : _selectedVariant$extr[selectedFileName];
|
|
59
|
+
}, [selectedFileName, selectedVariant]);
|
|
60
|
+
|
|
61
|
+
// if copying, convert the selected file's hast to text
|
|
62
|
+
var sourceFileToText = React.useCallback(function () {
|
|
63
|
+
return selectedFile && (0, _hastUtilToText.toText)(selectedFile, {
|
|
64
|
+
whitespace: 'pre'
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
// TODO: allow passing the filename to copy
|
|
68
|
+
[selectedFile]);
|
|
69
|
+
var _useCopier = (0, _useCopier2.useCopier)(sourceFileToText, copyOpts),
|
|
70
|
+
copy = _useCopier.copy,
|
|
71
|
+
copyDisabled = _useCopier.disabled;
|
|
72
|
+
|
|
73
|
+
// transform hast source to React components
|
|
74
|
+
var files = React.useMemo(function () {
|
|
75
|
+
var extraSource = selectedVariant.extraSource;
|
|
76
|
+
return [{
|
|
77
|
+
name: selectedVariant.fileName,
|
|
78
|
+
component: toComponent(selectedVariant.source)
|
|
79
|
+
}].concat((0, _toConsumableArray2["default"])(extraSource ? Object.keys(extraSource).map(function (name) {
|
|
80
|
+
return {
|
|
81
|
+
name: name,
|
|
82
|
+
component: toComponent(extraSource[name])
|
|
83
|
+
};
|
|
84
|
+
}) : []));
|
|
85
|
+
}, [selectedVariant]);
|
|
86
|
+
var selectedFileComponent = React.useMemo(function () {
|
|
87
|
+
var matchedFile = files.find(function (file) {
|
|
88
|
+
return file.name === selectedFileName;
|
|
89
|
+
});
|
|
90
|
+
return matchedFile ? matchedFile.component : null;
|
|
91
|
+
}, [files, selectedFileName]);
|
|
92
|
+
return {
|
|
93
|
+
component: selectedVariant.component,
|
|
94
|
+
name: demo.name,
|
|
14
95
|
slug: slug,
|
|
15
|
-
description:
|
|
16
|
-
|
|
96
|
+
description: demo.description,
|
|
97
|
+
ref: ref,
|
|
98
|
+
variants: variantKeys,
|
|
99
|
+
selectedVariant: selectedVariantKey,
|
|
100
|
+
selectVariant: setSelectedVariantKey,
|
|
101
|
+
files: files,
|
|
102
|
+
selectedFile: selectedFileComponent,
|
|
103
|
+
selectedFileName: selectedFileName,
|
|
104
|
+
selectFileName: setSelectedFileName,
|
|
105
|
+
expanded: expanded,
|
|
106
|
+
expand: expand,
|
|
107
|
+
setExpanded: setExpanded,
|
|
108
|
+
resetFocus: resetFocus,
|
|
109
|
+
copy: copy,
|
|
110
|
+
copyDisabled: copyDisabled
|
|
111
|
+
};
|
|
17
112
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ControlledCode } from "../CodeHighlighter/types.js";
|
|
3
|
-
export type Selection = {
|
|
4
|
-
variant: string;
|
|
5
|
-
fileName?: string;
|
|
6
|
-
transformKey?: string;
|
|
7
|
-
};
|
|
8
|
-
export interface CodeControllerContext {
|
|
9
|
-
code?: ControlledCode;
|
|
10
|
-
selection?: Selection;
|
|
11
|
-
setCode?: React.Dispatch<React.SetStateAction<ControlledCode | undefined>>;
|
|
12
|
-
setSelection?: React.Dispatch<React.SetStateAction<Selection>>;
|
|
13
|
-
components?: Record<string, React.ReactNode> | undefined;
|
|
14
|
-
}
|
|
15
|
-
export declare const CodeControllerContext: React.Context<CodeControllerContext | undefined>;
|
|
16
|
-
export declare function useControlledCode(): {
|
|
17
|
-
controlledCode: ControlledCode | undefined;
|
|
18
|
-
controlledSelection: Selection | undefined;
|
|
19
|
-
controlledSetCode: React.Dispatch<React.SetStateAction<ControlledCode | undefined>> | undefined;
|
|
20
|
-
controlledSetSelection: React.Dispatch<React.SetStateAction<Selection>> | undefined;
|
|
21
|
-
controlledComponents: Record<string, React.ReactNode> | undefined;
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeControllerContext.d.ts","sourceRoot":"","sources":["../../../src/CodeControllerContext/CodeControllerContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E,YAAY,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;CAC1D;AAED,eAAO,MAAM,qBAAqB,kDAEjC,CAAC;AAEF,wBAAgB,iBAAiB;;;;;;EAShC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
export var CodeControllerContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
|
-
export function useControlledCode() {
|
|
6
|
-
var context = React.useContext(CodeControllerContext);
|
|
7
|
-
return {
|
|
8
|
-
controlledCode: context == null ? void 0 : context.code,
|
|
9
|
-
controlledSelection: context == null ? void 0 : context.selection,
|
|
10
|
-
controlledSetCode: context == null ? void 0 : context.setCode,
|
|
11
|
-
controlledSetSelection: context == null ? void 0 : context.setSelection,
|
|
12
|
-
controlledComponents: context == null ? void 0 : context.components
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CodeControllerContext.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CodeControllerContext/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CodeControllerContext.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeHighlighter.d.ts","sourceRoot":"","sources":["../../../src/CodeHighlighter/CodeHighlighter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,oBAAoB,EAIrB,MAAM,SAAS,CAAC;AAkRjB,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA4F1D"}
|