@lax-wp/design-system 0.8.14 → 0.8.16
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/dist/components/data-display/code-editor/CodeEditor.d.ts +0 -3
- package/dist/components/data-display/code-editor-beta/CodeEditorBeta.d.ts +89 -0
- package/dist/components/data-display/code-editor-beta/index.d.ts +4 -0
- package/dist/components/data-display/code-editor-beta/usePythonSyntaxCM.d.ts +56 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.es.js +30870 -10674
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +54 -36
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +24 -0
- package/package.json +6 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import { type ReactCodeMirrorRef } from "@uiw/react-codemirror";
|
|
3
|
+
declare const TABS: ("JSON" | "Grid")[];
|
|
4
|
+
export type TTabKey = (typeof TABS)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Toolbar context passed to the `renderToolbarActions` callback.
|
|
7
|
+
*/
|
|
8
|
+
export interface CodeEditorBetaToolbarContext {
|
|
9
|
+
/** The CodeMirror editor view ref */
|
|
10
|
+
editorRef: ReactCodeMirrorRef | null;
|
|
11
|
+
/** Current editor value */
|
|
12
|
+
value: string;
|
|
13
|
+
/** Value change callback */
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
/** Active language */
|
|
16
|
+
language: "json" | "python";
|
|
17
|
+
/** Whether the editor is editable */
|
|
18
|
+
isEditMode: boolean;
|
|
19
|
+
/** Current active tab (JSON or Grid) */
|
|
20
|
+
activeTab: "JSON" | "Grid";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Props for the experimental CodeMirror-based CodeEditor.
|
|
24
|
+
*/
|
|
25
|
+
export interface CodeEditorBetaProps {
|
|
26
|
+
/** The code content to display in the editor */
|
|
27
|
+
value: string;
|
|
28
|
+
/** Callback fired when the code value changes */
|
|
29
|
+
onChange?: (value: string) => void;
|
|
30
|
+
/** Enable fullscreen toggle button */
|
|
31
|
+
withFullScreen?: boolean;
|
|
32
|
+
/** Enable light/dark theme toggle */
|
|
33
|
+
withTheme?: boolean;
|
|
34
|
+
/** Whether the editor is editable vs read-only */
|
|
35
|
+
isEditMode?: boolean;
|
|
36
|
+
/** Height of the editor (CSS units) */
|
|
37
|
+
height?: string;
|
|
38
|
+
/** Programming language for syntax highlighting */
|
|
39
|
+
language?: "json" | "python";
|
|
40
|
+
/** Show copy-to-clipboard button (JSON/Python only) */
|
|
41
|
+
isShowCopy?: boolean;
|
|
42
|
+
/** Show download file button (JSON/Python only) */
|
|
43
|
+
isShowDownload?: boolean;
|
|
44
|
+
/** Enable JSON Grid view for JSON language */
|
|
45
|
+
withJsonGrid?: boolean;
|
|
46
|
+
/** Editor theme: 'light' or 'dark' */
|
|
47
|
+
theme?: "light" | "dark";
|
|
48
|
+
/** Additional CSS classes for the outer container */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** Auto-format JSON on mount */
|
|
51
|
+
enableAutoFormatting?: boolean;
|
|
52
|
+
/** Disables parent save button during Python validation (mirrors original CodeEditor) */
|
|
53
|
+
setIsDisableSave?: (flag: boolean) => void;
|
|
54
|
+
/** API to check Python syntax — returns an error object if invalid */
|
|
55
|
+
checkSyntaxAPI?: (code: string) => Promise<{
|
|
56
|
+
data: {
|
|
57
|
+
error?: {
|
|
58
|
+
message: string;
|
|
59
|
+
line?: number;
|
|
60
|
+
column?: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
/** API to format Python code — returns formatted_code string */
|
|
65
|
+
formatCodeAPI?: (code: string) => Promise<{
|
|
66
|
+
data: {
|
|
67
|
+
formatted_code?: string;
|
|
68
|
+
};
|
|
69
|
+
}>;
|
|
70
|
+
/** Custom toolbar actions render function */
|
|
71
|
+
renderToolbarActions?: (context: CodeEditorBetaToolbarContext) => React.ReactNode;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* CodeEditorBeta — experimental CodeMirror 6 replacement for the Monaco-based CodeEditor.
|
|
75
|
+
*
|
|
76
|
+
* Smaller bundle, no web workers, same toolbar UX. Drops Codeium AI completions.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <CodeEditorBeta
|
|
81
|
+
* value={jsonString}
|
|
82
|
+
* onChange={setJsonString}
|
|
83
|
+
* language="json"
|
|
84
|
+
* height="400px"
|
|
85
|
+
* />
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare const CodeEditorBeta: FC<CodeEditorBetaProps>;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type EditorView } from "@codemirror/view";
|
|
2
|
+
import type { Extension } from "@codemirror/state";
|
|
3
|
+
export interface UsePythonSyntaxCMProps {
|
|
4
|
+
/** The CodeMirror EditorView (obtain from ref.current?.view) */
|
|
5
|
+
editorView: EditorView | null;
|
|
6
|
+
/** Current code string */
|
|
7
|
+
code: string;
|
|
8
|
+
/** Callback to update the code value */
|
|
9
|
+
setCode: (code: string) => void;
|
|
10
|
+
/** Whether the hook is active */
|
|
11
|
+
enable: boolean;
|
|
12
|
+
/** API to check Python syntax — returns an error object if invalid */
|
|
13
|
+
checkSyntaxAPI?: (code: string) => Promise<{
|
|
14
|
+
data: {
|
|
15
|
+
error?: {
|
|
16
|
+
message: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
/** API to format Python code — returns formatted_code string */
|
|
23
|
+
formatCodeAPI?: (code: string) => Promise<{
|
|
24
|
+
data: {
|
|
25
|
+
formatted_code?: string;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* CodeMirror-compatible replacement for usePythonSyntax.
|
|
31
|
+
*
|
|
32
|
+
* Uses `@codemirror/lint` diagnostics instead of Monaco's `setModelMarkers`
|
|
33
|
+
* for inline error display. Supports the same optional API-backed syntax
|
|
34
|
+
* checking and formatting as the original hook.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const { lintExtension, handleFormatCode, pythonLoading } = usePythonSyntaxCM({
|
|
39
|
+
* editorView: editorRef.current?.view ?? null,
|
|
40
|
+
* code: value,
|
|
41
|
+
* setCode: onChange,
|
|
42
|
+
* enable: isEditMode && language === "python",
|
|
43
|
+
* checkSyntaxAPI: myCheckAPI,
|
|
44
|
+
* formatCodeAPI: myFormatAPI,
|
|
45
|
+
* });
|
|
46
|
+
* // Add lintExtension to CodeMirror's extensions array
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const usePythonSyntaxCM: ({ editorView, code, setCode, enable, checkSyntaxAPI, formatCodeAPI, }: UsePythonSyntaxCMProps) => {
|
|
50
|
+
pythonError: any;
|
|
51
|
+
pythonLoading: boolean;
|
|
52
|
+
handleCheckSyntax: () => Promise<void>;
|
|
53
|
+
handleFormatCode: () => Promise<void>;
|
|
54
|
+
/** Add this to CodeMirror's extensions array to show the lint gutter */
|
|
55
|
+
lintExtension: Extension;
|
|
56
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,10 @@ export { ConfirmationModal } from "./components/feedback/confirmation-modal/Conf
|
|
|
79
79
|
export type { IConfirmationModalProps, } from "./components/feedback/confirmation-modal/ConfirmationModal";
|
|
80
80
|
export { CodeEditor } from "./components/data-display/code-editor/CodeEditor";
|
|
81
81
|
export type { CodeEditorProps } from "./types";
|
|
82
|
+
export { CodeEditorBeta } from "./components/data-display/code-editor-beta/CodeEditorBeta";
|
|
83
|
+
export type { CodeEditorBetaProps, CodeEditorBetaToolbarContext, } from "./components/data-display/code-editor-beta/CodeEditorBeta";
|
|
84
|
+
export { usePythonSyntaxCM } from "./components/data-display/code-editor-beta/usePythonSyntaxCM";
|
|
85
|
+
export type { UsePythonSyntaxCMProps } from "./components/data-display/code-editor-beta/usePythonSyntaxCM";
|
|
82
86
|
export { JsonGrid } from "./components/data-display/code-editor/JsonGrid";
|
|
83
87
|
export type { JsonGridProps } from "./components/data-display/code-editor/JsonGrid";
|
|
84
88
|
export { Tabs as CodeEditorTabs } from "./components/data-display/code-editor/Tabs";
|
|
@@ -117,7 +121,7 @@ export { DynamicDataModal } from "./components/data-display/dynamic-data-modal/D
|
|
|
117
121
|
export type { DynamicDataModalProps, TTabKey as DynamicDataModalTabKey } from "./components/data-display/dynamic-data-modal/DynamicDataModal";
|
|
118
122
|
export { DeleteModal } from "./components/data-display/delete-modal/DeleteModal";
|
|
119
123
|
export type { DeleteModalProps } from "./components/data-display/delete-modal/DeleteModal";
|
|
120
|
-
export type { JsonValue, JsonObject, JsonArray, Tab as CodeEditorTab, ThemeContextType, PythonError, JsonGridContextType } from "./types";
|
|
124
|
+
export type { JsonValue, JsonObject, JsonArray, Tab as CodeEditorTab, ThemeContextType, PythonError, JsonGridContextType, CodeBlockInfo, } from "./types";
|
|
121
125
|
export { COUNTRY_CODES, countryNameFromCode } from "./types/icon-picker";
|
|
122
126
|
export { DiffViewer, InlineDiffHighlighter, } from "./components/data-display/diff-viewer/DiffViewer";
|
|
123
127
|
export type { DiffViewerProps, DiffType, DiffTheme, } from "./components/data-display/diff-viewer/DiffViewer";
|