@mui/internal-docs-infra 0.1.1-alpha.9 → 0.1.1-canary.1
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.d.ts.map +1 -0
- package/esm/useCopier/index.js +62 -0
- package/esm/useDemo/index.d.ts +51 -0
- package/esm/useDemo/index.d.ts.map +1 -0
- package/esm/useDemo/index.js +104 -0
- package/package.json +31 -32
- package/useCopier/index.d.ts +1 -1
- package/useCopier/index.js +23 -15
- package/useDemo/index.d.ts +51 -6
- package/useDemo/index.js +112 -6
- 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/CodeExternalsContext/CodeExternalsContext.d.ts +0 -8
- package/CodeExternalsContext/CodeExternalsContext.d.ts.map +0 -1
- package/CodeExternalsContext/CodeExternalsContext.js +0 -7
- package/CodeExternalsContext/index.d.ts +0 -1
- package/CodeExternalsContext/index.d.ts.map +0 -1
- package/CodeExternalsContext/index.js +0 -1
- package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighter.js +0 -470
- package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterClient.js +0 -837
- package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -16
- 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 -13
- 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 -73
- 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 -10
- package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
- package/CodeHighlighter/loadFallbackCode.js +0 -632
- package/CodeHighlighter/loadVariant.d.ts +0 -12
- package/CodeHighlighter/loadVariant.d.ts.map +0 -1
- package/CodeHighlighter/loadVariant.js +0 -1083
- 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 -134
- package/CodeHighlighter/parseControlledCode.d.ts +0 -6
- package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
- package/CodeHighlighter/parseControlledCode.js +0 -87
- package/CodeHighlighter/transformCode.d.ts +0 -21
- package/CodeHighlighter/transformCode.d.ts.map +0 -1
- package/CodeHighlighter/transformCode.js +0 -263
- 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 -160
- 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 -65
- package/CodeProvider/index.d.ts +0 -1
- package/CodeProvider/index.d.ts.map +0 -1
- package/CodeProvider/index.js +0 -1
- package/abstractCreateDemo/abstractCreateDemo.d.ts +0 -35
- package/abstractCreateDemo/abstractCreateDemo.d.ts.map +0 -1
- package/abstractCreateDemo/abstractCreateDemo.js +0 -91
- package/abstractCreateDemo/index.d.ts +0 -1
- package/abstractCreateDemo/index.d.ts.map +0 -1
- package/abstractCreateDemo/index.js +0 -1
- package/createDemoData/createDemoData.d.ts +0 -44
- package/createDemoData/createDemoData.d.ts.map +0 -1
- package/createDemoData/createDemoData.js +0 -75
- package/createDemoData/index.d.ts +0 -1
- package/createDemoData/index.d.ts.map +0 -1
- package/createDemoData/index.js +0 -1
- package/createDemoData/types.d.ts +0 -28
- package/createDemoData/types.d.ts.map +0 -1
- package/createDemoData/types.js +0 -1
- package/pipeline/hastUtils/hastUtils.d.ts +0 -11
- package/pipeline/hastUtils/hastUtils.d.ts.map +0 -1
- package/pipeline/hastUtils/hastUtils.js +0 -67
- package/pipeline/hastUtils/index.d.ts +0 -1
- package/pipeline/hastUtils/index.d.ts.map +0 -1
- package/pipeline/hastUtils/index.js +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +0 -54
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +0 -465
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +0 -15
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +0 -253
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/index.js +0 -4
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -20
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -224
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -31
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -433
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -19
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -25
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -73
- package/pipeline/loadServerCodeMeta/index.d.ts +0 -1
- package/pipeline/loadServerCodeMeta/index.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/index.js +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +0 -24
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +0 -92
- package/pipeline/loadServerSource/index.d.ts +0 -1
- package/pipeline/loadServerSource/index.d.ts.map +0 -1
- package/pipeline/loadServerSource/index.js +0 -1
- package/pipeline/loadServerSource/loadServerSource.d.ts +0 -25
- package/pipeline/loadServerSource/loadServerSource.d.ts.map +0 -1
- package/pipeline/loadServerSource/loadServerSource.js +0 -135
- package/pipeline/loaderUtils/externalsToPackages.d.ts +0 -1
- package/pipeline/loaderUtils/externalsToPackages.d.ts.map +0 -1
- package/pipeline/loaderUtils/externalsToPackages.js +0 -46
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -34
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +0 -161
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts +0 -11
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/getFileNameFromUrl.js +0 -32
- package/pipeline/loaderUtils/index.d.ts +0 -7
- package/pipeline/loaderUtils/index.d.ts.map +0 -1
- package/pipeline/loaderUtils/index.js +0 -7
- package/pipeline/loaderUtils/mergeExternals.d.ts +0 -32
- package/pipeline/loaderUtils/mergeExternals.d.ts.map +0 -1
- package/pipeline/loaderUtils/mergeExternals.js +0 -72
- package/pipeline/loaderUtils/parseImports.d.ts +0 -20
- package/pipeline/loaderUtils/parseImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/parseImports.js +0 -307
- package/pipeline/loaderUtils/processRelativeImports.d.ts +0 -19
- package/pipeline/loaderUtils/processRelativeImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/processRelativeImports.js +0 -329
- package/pipeline/loaderUtils/resolveModulePath.d.ts +0 -87
- package/pipeline/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePath.js +0 -1449
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +0 -47
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePathWithFs.js +0 -163
- package/pipeline/loaderUtils/rewriteImports.d.ts +0 -9
- package/pipeline/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/rewriteImports.js +0 -35
- package/pipeline/parseSource/grammars.d.ts +0 -2
- package/pipeline/parseSource/grammars.d.ts.map +0 -1
- package/pipeline/parseSource/grammars.js +0 -27
- package/pipeline/parseSource/index.d.ts +0 -1
- package/pipeline/parseSource/index.d.ts.map +0 -1
- package/pipeline/parseSource/index.js +0 -1
- package/pipeline/parseSource/parseSource.d.ts +0 -3
- package/pipeline/parseSource/parseSource.d.ts.map +0 -1
- package/pipeline/parseSource/parseSource.js +0 -47
- package/pipeline/transformHtmlCode/index.d.ts +0 -2
- package/pipeline/transformHtmlCode/index.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/index.js +0 -4
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/transformHtmlCode.js +0 -303
- package/pipeline/transformMarkdownCode/index.d.ts +0 -2
- package/pipeline/transformMarkdownCode/index.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/index.js +0 -4
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +0 -2
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/transformMarkdownCode.js +0 -514
- package/pipeline/transformTypescriptToJavascript/index.d.ts +0 -1
- package/pipeline/transformTypescriptToJavascript/index.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/index.js +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +0 -13
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.js +0 -134
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +0 -3
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.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 +0 -39
- package/useCode/useCode.d.ts.map +0 -1
- package/useCode/useCode.js +0 -122
- package/useCode/useCodeUtils.d.ts +0 -45
- package/useCode/useCodeUtils.d.ts.map +0 -1
- package/useCode/useCodeUtils.js +0 -240
- package/useCode/useCopyFunctionality.d.ts +0 -17
- package/useCode/useCopyFunctionality.d.ts.map +0 -1
- package/useCode/useCopyFunctionality.js +0 -28
- package/useCode/useFileNavigation.d.ts +0 -48
- package/useCode/useFileNavigation.d.ts.map +0 -1
- package/useCode/useFileNavigation.js +0 -370
- package/useCode/useSourceEditing.d.ts +0 -19
- package/useCode/useSourceEditing.d.ts.map +0 -1
- package/useCode/useSourceEditing.js +0 -32
- package/useCode/useTransformManagement.d.ts +0 -28
- package/useCode/useTransformManagement.d.ts.map +0 -1
- package/useCode/useTransformManagement.js +0 -82
- package/useCode/useUIState.d.ts +0 -16
- package/useCode/useUIState.d.ts.map +0 -1
- package/useCode/useUIState.js +0 -21
- package/useCode/useVariantSelection.d.ts +0 -21
- package/useCode/useVariantSelection.d.ts.map +0 -1
- package/useCode/useVariantSelection.js +0 -84
- package/useCopier/index.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.d.ts +0 -18
- package/useDemo/createCodeSandbox.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.js +0 -48
- package/useDemo/createStackBlitz.d.ts +0 -22
- package/useDemo/createStackBlitz.d.ts.map +0 -1
- package/useDemo/createStackBlitz.js +0 -38
- package/useDemo/examineVariant.d.ts +0 -25
- package/useDemo/examineVariant.d.ts.map +0 -1
- package/useDemo/examineVariant.js +0 -134
- package/useDemo/exportVariant.d.ts +0 -110
- package/useDemo/exportVariant.d.ts.map +0 -1
- package/useDemo/exportVariant.js +0 -320
- package/useDemo/exportVariantAsCra.d.ts +0 -15
- package/useDemo/exportVariantAsCra.d.ts.map +0 -1
- package/useDemo/exportVariantAsCra.js +0 -56
- package/useDemo/flattenVariant.d.ts +0 -17
- package/useDemo/flattenVariant.d.ts.map +0 -1
- package/useDemo/flattenVariant.js +0 -206
- package/useDemo/index.d.ts.map +0 -1
- package/useDemo/useDemo.d.ts +0 -78
- package/useDemo/useDemo.d.ts.map +0 -1
- package/useDemo/useDemo.js +0 -174
- package/useLocalStorageState/index.d.ts +0 -2
- package/useLocalStorageState/index.d.ts.map +0 -1
- package/useLocalStorageState/index.js +0 -2
- package/useLocalStorageState/useLocalStorageState.d.ts +0 -14
- package/useLocalStorageState/useLocalStorageState.d.ts.map +0 -1
- package/useLocalStorageState/useLocalStorageState.js +0 -128
- 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/useUrlHashState/index.d.ts +0 -1
- package/useUrlHashState/index.d.ts.map +0 -1
- package/useUrlHashState/index.js +0 -1
- package/useUrlHashState/useUrlHashState.d.ts +0 -50
- package/useUrlHashState/useUrlHashState.d.ts.map +0 -1
- package/useUrlHashState/useUrlHashState.js +0 -113
package/useDemo/useDemo.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { UseCopierOpts } from "../useCopier/index.js";
|
|
3
|
-
import type { ContentProps } from "../CodeHighlighter/types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Demo templates use the exportVariant/exportVariantAsCra with flattenVariant pattern:
|
|
6
|
-
*
|
|
7
|
-
* For StackBlitz:
|
|
8
|
-
* const { exported: exportedVariant, entrypoint } = exportVariant(variantCode);
|
|
9
|
-
* const flattenedFiles = flattenVariant(exportedVariant);
|
|
10
|
-
* createStackBlitzDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
|
|
11
|
-
*
|
|
12
|
-
* For CodeSandbox:
|
|
13
|
-
* const { exported: craExport, entrypoint } = exportVariantAsCra(variantCode, { title, description, useTypescript });
|
|
14
|
-
* const flattenedFiles = flattenVariant(craExport);
|
|
15
|
-
* createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
|
|
16
|
-
* createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript })
|
|
17
|
-
*/
|
|
18
|
-
type UseDemoOpts = {
|
|
19
|
-
defaultOpen?: boolean;
|
|
20
|
-
copy?: UseCopierOpts;
|
|
21
|
-
githubUrlPrefix?: string;
|
|
22
|
-
codeSandboxUrlPrefix?: string;
|
|
23
|
-
stackBlitzPrefix?: string;
|
|
24
|
-
initialVariant?: string;
|
|
25
|
-
initialTransform?: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Helper to create HTML form element with hidden inputs
|
|
29
|
-
*/
|
|
30
|
-
export declare function addHiddenInput(form: HTMLFormElement, name: string, value: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Generic function to create and submit a form for opening online demo platforms
|
|
33
|
-
* This function creates HTML elements and should be used in browser contexts
|
|
34
|
-
*/
|
|
35
|
-
export declare function openWithForm({
|
|
36
|
-
url,
|
|
37
|
-
formData,
|
|
38
|
-
method,
|
|
39
|
-
target
|
|
40
|
-
}: {
|
|
41
|
-
url: string;
|
|
42
|
-
formData: Record<string, string>;
|
|
43
|
-
method?: string;
|
|
44
|
-
target?: string;
|
|
45
|
-
}): void;
|
|
46
|
-
export declare function useDemo<T extends {} = {}>(contentProps: ContentProps<T>, opts?: UseDemoOpts): {
|
|
47
|
-
component: string | number | bigint | true | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
|
|
48
|
-
ref: React.RefObject<HTMLDivElement | null>;
|
|
49
|
-
resetFocus: () => void;
|
|
50
|
-
openStackBlitz: () => void;
|
|
51
|
-
openCodeSandbox: () => void;
|
|
52
|
-
name: string | undefined;
|
|
53
|
-
slug: string | undefined;
|
|
54
|
-
variants: string[];
|
|
55
|
-
selectedVariant: string;
|
|
56
|
-
selectVariant: React.Dispatch<React.SetStateAction<string>>;
|
|
57
|
-
files: Array<{
|
|
58
|
-
name: string;
|
|
59
|
-
slug?: string;
|
|
60
|
-
component: React.ReactNode;
|
|
61
|
-
}>;
|
|
62
|
-
selectedFile: React.ReactNode;
|
|
63
|
-
selectedFileName: string | undefined;
|
|
64
|
-
selectFileName: (fileName: string) => void;
|
|
65
|
-
expanded: boolean;
|
|
66
|
-
expand: () => void;
|
|
67
|
-
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
68
|
-
copy: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
69
|
-
availableTransforms: string[];
|
|
70
|
-
selectedTransform: string | null | undefined;
|
|
71
|
-
selectTransform: (transformName: string | null) => void;
|
|
72
|
-
setSource?: (source: string) => void;
|
|
73
|
-
userProps: T & {
|
|
74
|
-
name?: string;
|
|
75
|
-
slug?: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
export {};
|
package/useDemo/useDemo.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDemo.d.ts","sourceRoot":"","sources":["../../src/useDemo/useDemo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQ7D;;;;;;;;;;;;;GAaG;AAEH,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;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMvF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,QAAQ,EACR,MAAe,EACf,MAAiB,GAClB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CAaP;AAGD,wBAAgB,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW;;;;;;;;;;;;;YAxDnD,CAAC;;;;;;;;;;;;;;;;;;EA4KzC"}
|
package/useDemo/useDemo.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import kebabCase from 'kebab-case';
|
|
5
|
-
import { useCode } from "../useCode/index.js";
|
|
6
|
-
import { CodeHighlighterContext } from "../CodeHighlighter/CodeHighlighterContext.js";
|
|
7
|
-
import { createStackBlitz } from "./createStackBlitz.js";
|
|
8
|
-
import { createCodeSandbox } from "./createCodeSandbox.js";
|
|
9
|
-
import { exportVariant } from "./exportVariant.js";
|
|
10
|
-
import { exportVariantAsCra } from "./exportVariantAsCra.js";
|
|
11
|
-
import { flattenVariant } from "./flattenVariant.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Demo templates use the exportVariant/exportVariantAsCra with flattenVariant pattern:
|
|
15
|
-
*
|
|
16
|
-
* For StackBlitz:
|
|
17
|
-
* const { exported: exportedVariant, entrypoint } = exportVariant(variantCode);
|
|
18
|
-
* const flattenedFiles = flattenVariant(exportedVariant);
|
|
19
|
-
* createStackBlitzDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
|
|
20
|
-
*
|
|
21
|
-
* For CodeSandbox:
|
|
22
|
-
* const { exported: craExport, entrypoint } = exportVariantAsCra(variantCode, { title, description, useTypescript });
|
|
23
|
-
* const flattenedFiles = flattenVariant(craExport);
|
|
24
|
-
* createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
|
|
25
|
-
* createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript })
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Helper to create HTML form element with hidden inputs
|
|
30
|
-
*/
|
|
31
|
-
export function addHiddenInput(form, name, value) {
|
|
32
|
-
var input = document.createElement('input');
|
|
33
|
-
input.type = 'hidden';
|
|
34
|
-
input.name = name;
|
|
35
|
-
input.value = value;
|
|
36
|
-
form.appendChild(input);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Generic function to create and submit a form for opening online demo platforms
|
|
41
|
-
* This function creates HTML elements and should be used in browser contexts
|
|
42
|
-
*/
|
|
43
|
-
export function openWithForm(_ref) {
|
|
44
|
-
var url = _ref.url,
|
|
45
|
-
formData = _ref.formData,
|
|
46
|
-
_ref$method = _ref.method,
|
|
47
|
-
method = _ref$method === void 0 ? 'POST' : _ref$method,
|
|
48
|
-
_ref$target = _ref.target,
|
|
49
|
-
target = _ref$target === void 0 ? '_blank' : _ref$target;
|
|
50
|
-
var form = document.createElement('form');
|
|
51
|
-
form.method = method;
|
|
52
|
-
form.target = target;
|
|
53
|
-
form.action = url;
|
|
54
|
-
Object.entries(formData).forEach(function (_ref2) {
|
|
55
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
56
|
-
name = _ref3[0],
|
|
57
|
-
value = _ref3[1];
|
|
58
|
-
addHiddenInput(form, name, value);
|
|
59
|
-
});
|
|
60
|
-
document.body.appendChild(form);
|
|
61
|
-
form.submit();
|
|
62
|
-
document.body.removeChild(form);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// TODO: take initialVariant and initialTransforms as parameters
|
|
66
|
-
export function useDemo(contentProps, opts) {
|
|
67
|
-
var codeResult = useCode(contentProps, opts);
|
|
68
|
-
|
|
69
|
-
// Get context to access components if available (using React.useContext to avoid import conflicts)
|
|
70
|
-
var context = React.useContext(CodeHighlighterContext);
|
|
71
|
-
var slug = React.useMemo(function () {
|
|
72
|
-
return contentProps.slug || (contentProps.name ? kebabCase(contentProps.name, false) : undefined);
|
|
73
|
-
}, [contentProps.slug, contentProps.name]);
|
|
74
|
-
|
|
75
|
-
// Get the effective components object - context overrides contentProps
|
|
76
|
-
var effectiveComponents = React.useMemo(function () {
|
|
77
|
-
return (context == null ? void 0 : context.components) || contentProps.components || {};
|
|
78
|
-
}, [context == null ? void 0 : context.components, contentProps.components]);
|
|
79
|
-
|
|
80
|
-
// Get the component for the current variant
|
|
81
|
-
var component = React.useMemo(function () {
|
|
82
|
-
return effectiveComponents[codeResult.selectedVariant] || null;
|
|
83
|
-
}, [effectiveComponents, codeResult.selectedVariant]);
|
|
84
|
-
|
|
85
|
-
// Demo-specific ref and focus management
|
|
86
|
-
var ref = React.useRef(null);
|
|
87
|
-
var resetFocus = React.useCallback(function () {
|
|
88
|
-
var _ref$current;
|
|
89
|
-
(_ref$current = ref.current) == null || _ref$current.focus();
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
// Get the effective code - context overrides contentProps if available
|
|
93
|
-
var effectiveCode = React.useMemo(function () {
|
|
94
|
-
return (context == null ? void 0 : context.code) || contentProps.code || {};
|
|
95
|
-
}, [context == null ? void 0 : context.code, contentProps.code]);
|
|
96
|
-
|
|
97
|
-
// Create StackBlitz demo callback
|
|
98
|
-
var openStackBlitz = React.useCallback(function () {
|
|
99
|
-
// Get the current variant code
|
|
100
|
-
var variantCode = effectiveCode[codeResult.selectedVariant];
|
|
101
|
-
if (!variantCode || typeof variantCode === 'string') {
|
|
102
|
-
console.warn('No valid variant code available for StackBlitz demo');
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
var title = contentProps.name || 'Demo';
|
|
106
|
-
var description = "".concat(title, " demo");
|
|
107
|
-
|
|
108
|
-
// Determine if we should use TypeScript based on whether 'js' transform is NOT applied
|
|
109
|
-
// If 'js' transform is applied, it means we're showing the JS version of TS code
|
|
110
|
-
var useTypescript = codeResult.selectedTransform !== 'js';
|
|
111
|
-
|
|
112
|
-
// Export variant with additional configuration files
|
|
113
|
-
var _exportVariant = exportVariant(variantCode, {
|
|
114
|
-
title: title,
|
|
115
|
-
description: description,
|
|
116
|
-
useTypescript: useTypescript
|
|
117
|
-
}),
|
|
118
|
-
exported = _exportVariant.exported,
|
|
119
|
-
rootFile = _exportVariant.rootFile;
|
|
120
|
-
|
|
121
|
-
// Flatten the variant to get a flat file structure
|
|
122
|
-
var flattenedFiles = flattenVariant(exported);
|
|
123
|
-
var stackBlitzDemo = createStackBlitz({
|
|
124
|
-
title: title,
|
|
125
|
-
description: description,
|
|
126
|
-
flattenedFiles: flattenedFiles,
|
|
127
|
-
rootFile: rootFile
|
|
128
|
-
});
|
|
129
|
-
openWithForm(stackBlitzDemo);
|
|
130
|
-
}, [effectiveCode, codeResult.selectedVariant, codeResult.selectedTransform, contentProps.name]);
|
|
131
|
-
|
|
132
|
-
// Create CodeSandbox demo callback
|
|
133
|
-
var openCodeSandbox = React.useCallback(function () {
|
|
134
|
-
// Get the current variant code
|
|
135
|
-
var variantCode = effectiveCode[codeResult.selectedVariant];
|
|
136
|
-
if (!variantCode || typeof variantCode === 'string') {
|
|
137
|
-
console.warn('No valid variant code available for CodeSandbox demo');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
var title = contentProps.name || 'Demo';
|
|
141
|
-
var description = "".concat(title, " demo");
|
|
142
|
-
|
|
143
|
-
// Determine if we should use TypeScript based on whether 'js' transform is NOT applied
|
|
144
|
-
// If 'js' transform is applied, it means we're showing the JS version of TS code
|
|
145
|
-
var useTypescript = codeResult.selectedTransform !== 'js';
|
|
146
|
-
|
|
147
|
-
// Export variant as CRA template with additional configuration files
|
|
148
|
-
var _exportVariantAsCra = exportVariantAsCra(variantCode, {
|
|
149
|
-
title: title,
|
|
150
|
-
description: description,
|
|
151
|
-
useTypescript: useTypescript
|
|
152
|
-
}),
|
|
153
|
-
craExport = _exportVariantAsCra.exported,
|
|
154
|
-
rootFile = _exportVariantAsCra.rootFile;
|
|
155
|
-
|
|
156
|
-
// Flatten the variant to get a flat file structure
|
|
157
|
-
var flattenedFiles = flattenVariant(craExport);
|
|
158
|
-
var codeSandboxDemo = createCodeSandbox({
|
|
159
|
-
flattenedFiles: flattenedFiles,
|
|
160
|
-
rootFile: rootFile
|
|
161
|
-
});
|
|
162
|
-
openWithForm(codeSandboxDemo);
|
|
163
|
-
}, [effectiveCode, codeResult.selectedVariant, codeResult.selectedTransform, contentProps.name]);
|
|
164
|
-
return _objectSpread(_objectSpread({}, codeResult), {}, {
|
|
165
|
-
// Demo-specific additions
|
|
166
|
-
component: component,
|
|
167
|
-
ref: ref,
|
|
168
|
-
resetFocus: resetFocus,
|
|
169
|
-
openStackBlitz: openStackBlitz,
|
|
170
|
-
openCodeSandbox: openCodeSandbox,
|
|
171
|
-
name: contentProps.name,
|
|
172
|
-
slug: slug
|
|
173
|
-
});
|
|
174
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useLocalStorageState/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
type Initializer = () => string | null;
|
|
3
|
-
type UseStorageStateHookResult = [string | null, React.Dispatch<React.SetStateAction<string | null>>];
|
|
4
|
-
/**
|
|
5
|
-
* Sync state to local storage so that it persists through a page refresh. Usage is
|
|
6
|
-
* similar to useState except we pass in a storage key so that we can default
|
|
7
|
-
* to that value on page load instead of the specified initial value.
|
|
8
|
-
*
|
|
9
|
-
* Since the storage API isn't available in server-rendering environments, we
|
|
10
|
-
* return null during SSR and hydration.
|
|
11
|
-
*/
|
|
12
|
-
declare function useLocalStorageStateBrowser(key: string | null, initializer?: string | null | Initializer): UseStorageStateHookResult;
|
|
13
|
-
declare const _default: typeof useLocalStorageStateBrowser;
|
|
14
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorageState.d.ts","sourceRoot":"","sources":["../../src/useLocalStorageState/useLocalStorageState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAwF/B,KAAK,WAAW,GAAG,MAAM,MAAM,GAAG,IAAI,CAAC;AAEvC,KAAK,yBAAyB,GAAG;IAC/B,MAAM,GAAG,IAAI;IACb,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC;AAQF;;;;;;;GAOG;AACH,iBAAS,2BAA2B,CAClC,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,WAAW,GAAE,MAAM,GAAG,IAAI,GAAG,WAAkB,GAC9C,yBAAyB,CAoC3B;;AAED,wBAEgC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Copied from https://github.com/mui/material-ui/blob/9dfc2b12f3fc5c41071da5e10b0088fb04045a26/packages/mui-utils/src/useLocalStorageState/useLocalStorageState.ts
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// storage events only work across tabs, we'll use an event emitter to announce within the current tab
|
|
11
|
-
var currentTabChangeListeners = new Map();
|
|
12
|
-
function onCurrentTabStorageChange(key, handler) {
|
|
13
|
-
var listeners = currentTabChangeListeners.get(key);
|
|
14
|
-
if (!listeners) {
|
|
15
|
-
listeners = new Set();
|
|
16
|
-
currentTabChangeListeners.set(key, listeners);
|
|
17
|
-
}
|
|
18
|
-
listeners.add(handler);
|
|
19
|
-
}
|
|
20
|
-
function offCurrentTabStorageChange(key, handler) {
|
|
21
|
-
var listeners = currentTabChangeListeners.get(key);
|
|
22
|
-
if (!listeners) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
listeners["delete"](handler);
|
|
26
|
-
if (listeners.size === 0) {
|
|
27
|
-
currentTabChangeListeners["delete"](key);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function emitCurrentTabStorageChange(key) {
|
|
31
|
-
var listeners = currentTabChangeListeners.get(key);
|
|
32
|
-
if (listeners) {
|
|
33
|
-
listeners.forEach(function (listener) {
|
|
34
|
-
return listener();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function subscribe(area, key, callback) {
|
|
39
|
-
if (!key) {
|
|
40
|
-
return function () {};
|
|
41
|
-
}
|
|
42
|
-
var storageHandler = function storageHandler(event) {
|
|
43
|
-
if (event.storageArea === area && event.key === key) {
|
|
44
|
-
callback();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
window.addEventListener('storage', storageHandler);
|
|
48
|
-
onCurrentTabStorageChange(key, callback);
|
|
49
|
-
return function () {
|
|
50
|
-
window.removeEventListener('storage', storageHandler);
|
|
51
|
-
offCurrentTabStorageChange(key, callback);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function getSnapshot(area, key) {
|
|
55
|
-
if (!key) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
return area.getItem(key);
|
|
60
|
-
} catch (_unused) {
|
|
61
|
-
// ignore
|
|
62
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function setValue(area, key, value) {
|
|
67
|
-
if (!key) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
if (value === null) {
|
|
72
|
-
area.removeItem(key);
|
|
73
|
-
} else {
|
|
74
|
-
area.setItem(key, String(value));
|
|
75
|
-
}
|
|
76
|
-
} catch (_unused2) {
|
|
77
|
-
// ignore
|
|
78
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
emitCurrentTabStorageChange(key);
|
|
82
|
-
}
|
|
83
|
-
var serverValue = [null, function () {}];
|
|
84
|
-
function useLocalStorageStateServer() {
|
|
85
|
-
return serverValue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Sync state to local storage so that it persists through a page refresh. Usage is
|
|
90
|
-
* similar to useState except we pass in a storage key so that we can default
|
|
91
|
-
* to that value on page load instead of the specified initial value.
|
|
92
|
-
*
|
|
93
|
-
* Since the storage API isn't available in server-rendering environments, we
|
|
94
|
-
* return null during SSR and hydration.
|
|
95
|
-
*/
|
|
96
|
-
function useLocalStorageStateBrowser(key) {
|
|
97
|
-
var initializer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
98
|
-
var _React$useState = React.useState(initializer),
|
|
99
|
-
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
100
|
-
initialValue = _React$useState2[0];
|
|
101
|
-
var area = window.localStorage;
|
|
102
|
-
var subscribeKey = React.useCallback(function (callback) {
|
|
103
|
-
return subscribe(area, key, callback);
|
|
104
|
-
}, [area, key]);
|
|
105
|
-
var getKeySnapshot = React.useCallback(function () {
|
|
106
|
-
var _getSnapshot;
|
|
107
|
-
return (_getSnapshot = getSnapshot(area, key)) != null ? _getSnapshot : initialValue;
|
|
108
|
-
}, [area, initialValue, key]);
|
|
109
|
-
|
|
110
|
-
// Start with null for the hydration, and then switch to the actual value.
|
|
111
|
-
var getKeyServerSnapshot = function getKeyServerSnapshot() {
|
|
112
|
-
return null;
|
|
113
|
-
};
|
|
114
|
-
var storedValue = React.useSyncExternalStore(subscribeKey, getKeySnapshot, getKeyServerSnapshot);
|
|
115
|
-
var setStoredValue = React.useCallback(function (value) {
|
|
116
|
-
var valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
117
|
-
setValue(area, key, valueToStore);
|
|
118
|
-
}, [area, key, storedValue]);
|
|
119
|
-
var _React$useState3 = React.useState(initialValue),
|
|
120
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
121
|
-
nonStoredValue = _React$useState4[0],
|
|
122
|
-
setNonStoredValue = _React$useState4[1];
|
|
123
|
-
if (!key) {
|
|
124
|
-
return [nonStoredValue, setNonStoredValue];
|
|
125
|
-
}
|
|
126
|
-
return [storedValue, setStoredValue];
|
|
127
|
-
}
|
|
128
|
-
export default typeof window === 'undefined' ? useLocalStorageStateServer : useLocalStorageStateBrowser;
|
package/useOnHydrate/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useOnHydrate.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useOnHydrate/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/useOnHydrate/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useOnHydrate.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useOnHydrate(callback?: () => void): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOnHydrate.d.ts","sourceRoot":"","sources":["../../src/useOnHydrate/useOnHydrate.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,WAYjD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
export function useOnHydrate(callback) {
|
|
4
|
-
var _React$useState = React.useState(false),
|
|
5
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6
|
-
isHydrated = _React$useState2[0],
|
|
7
|
-
setIsHydrated = _React$useState2[1];
|
|
8
|
-
var callbackRef = React.useRef(callback);
|
|
9
|
-
callbackRef.current = callback;
|
|
10
|
-
React.useEffect(function () {
|
|
11
|
-
if (typeof window !== 'undefined') {
|
|
12
|
-
var _callbackRef$current;
|
|
13
|
-
(_callbackRef$current = callbackRef.current) == null || _callbackRef$current.call(callbackRef);
|
|
14
|
-
setIsHydrated(true);
|
|
15
|
-
}
|
|
16
|
-
}, []);
|
|
17
|
-
return isHydrated;
|
|
18
|
-
}
|
package/useOnIdle/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useOnIdle.js";
|
package/useOnIdle/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useOnIdle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/useOnIdle/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useOnIdle.js";
|
package/useOnIdle/useOnIdle.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useOnIdle(callback?: () => void, timeout?: number): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOnIdle.d.ts","sourceRoot":"","sources":["../../src/useOnIdle/useOnIdle.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,EAAE,OAAO,SAAO,WAkC9D"}
|
package/useOnIdle/useOnIdle.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
export function useOnIdle(callback) {
|
|
4
|
-
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
5
|
-
var _React$useState = React.useState(false),
|
|
6
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
7
|
-
isIdle = _React$useState2[0],
|
|
8
|
-
setIsIdle = _React$useState2[1];
|
|
9
|
-
var callbackRef = React.useRef(callback);
|
|
10
|
-
callbackRef.current = callback;
|
|
11
|
-
React.useEffect(function () {
|
|
12
|
-
if (typeof window === 'undefined') {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
var handleIdle = function handleIdle() {
|
|
16
|
-
var _callbackRef$current;
|
|
17
|
-
(_callbackRef$current = callbackRef.current) == null || _callbackRef$current.call(callbackRef);
|
|
18
|
-
setIsIdle(true);
|
|
19
|
-
};
|
|
20
|
-
var idleCallbackId;
|
|
21
|
-
var timeoutId;
|
|
22
|
-
if ('requestIdleCallback' in window) {
|
|
23
|
-
idleCallbackId = window.requestIdleCallback(handleIdle, {
|
|
24
|
-
timeout: timeout
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
timeoutId = setTimeout(handleIdle, timeout);
|
|
28
|
-
}
|
|
29
|
-
return function () {
|
|
30
|
-
if (idleCallbackId && 'cancelIdleCallback' in window) {
|
|
31
|
-
window.cancelIdleCallback(idleCallbackId);
|
|
32
|
-
}
|
|
33
|
-
if (timeoutId) {
|
|
34
|
-
clearTimeout(timeoutId);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}, [timeout]);
|
|
38
|
-
return isIdle;
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useUrlHashState.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useUrlHashState/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/useUrlHashState/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useUrlHashState.js";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface UseUrlHashStateOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Whether to automatically read the hash on mount
|
|
4
|
-
* @default true
|
|
5
|
-
*/
|
|
6
|
-
readOnMount?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Whether to automatically watch for hash changes
|
|
9
|
-
* @default true
|
|
10
|
-
*/
|
|
11
|
-
watchChanges?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Custom hash parser function
|
|
14
|
-
* @default (hash) => hash.slice(1) // Remove the '#'
|
|
15
|
-
*/
|
|
16
|
-
parseHash?: (hash: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Custom hash formatter function
|
|
19
|
-
* @default (value) => value
|
|
20
|
-
*/
|
|
21
|
-
formatHash?: (value: string) => string;
|
|
22
|
-
}
|
|
23
|
-
export interface UseUrlHashStateResult {
|
|
24
|
-
/**
|
|
25
|
-
* Current hash value (without the '#')
|
|
26
|
-
*/
|
|
27
|
-
hash: string | null;
|
|
28
|
-
/**
|
|
29
|
-
* Set a new hash value (will update the URL)
|
|
30
|
-
* @param value - New hash value
|
|
31
|
-
* @param replace - Whether to use replaceState instead of pushState
|
|
32
|
-
*/
|
|
33
|
-
setHash: (value: string | null, replace?: boolean) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Whether the initial hash has been processed
|
|
36
|
-
*/
|
|
37
|
-
hasProcessedInitialHash: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Whether the user has explicitly interacted with the hash
|
|
40
|
-
*/
|
|
41
|
-
hasUserInteraction: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Mark that user has interacted with the hash
|
|
44
|
-
*/
|
|
45
|
-
markUserInteraction: () => void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Hook for managing URL hash state with SSR support
|
|
49
|
-
*/
|
|
50
|
-
export declare function useUrlHashState(options?: UseUrlHashStateOptions): UseUrlHashStateResult;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUrlHashState.d.ts","sourceRoot":"","sources":["../../src/useUrlHashState/useUrlHashState.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAErC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;;;OAIG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE3D;;OAEG;IACH,uBAAuB,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAKD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,qBAAqB,CAkG3F"}
|