@lax-wp/design-system 0.8.5-beta.0 → 0.8.6
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/index.d.ts +1 -5
- package/dist/index.es.js +10749 -30941
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +36 -54
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +0 -24
- package/package.json +1 -6
- package/dist/components/data-display/code-editor-beta/CodeEditorBeta.d.ts +0 -89
- package/dist/components/data-display/code-editor-beta/index.d.ts +0 -4
- package/dist/components/data-display/code-editor-beta/usePythonSyntaxCM.d.ts +0 -56
package/dist/types/index.d.ts
CHANGED
|
@@ -19,21 +19,6 @@ export interface CodeEditorToolbarContext {
|
|
|
19
19
|
isEditMode: boolean;
|
|
20
20
|
activeTab: 'JSON' | 'Grid';
|
|
21
21
|
}
|
|
22
|
-
/** Information about a folding range (code block) at the cursor position. */
|
|
23
|
-
export interface CodeBlockInfo {
|
|
24
|
-
/** 1-based start line of the folding range */
|
|
25
|
-
startLine: number;
|
|
26
|
-
/** 1-based end line of the folding range */
|
|
27
|
-
endLine: number;
|
|
28
|
-
/** The raw text content of the block */
|
|
29
|
-
text: string;
|
|
30
|
-
/** The folding kind if available ('comment' | 'imports' | 'region' | undefined) */
|
|
31
|
-
kind?: string;
|
|
32
|
-
/** 1-based line where the cursor was when clicked */
|
|
33
|
-
cursorLine: number;
|
|
34
|
-
/** 1-based column where the cursor was when clicked */
|
|
35
|
-
cursorColumn: number;
|
|
36
|
-
}
|
|
37
22
|
export interface CodeEditorProps {
|
|
38
23
|
value: string;
|
|
39
24
|
onChange?: (value: string) => void;
|
|
@@ -53,15 +38,6 @@ export interface CodeEditorProps {
|
|
|
53
38
|
className?: string;
|
|
54
39
|
enableAutoFormatting?: boolean;
|
|
55
40
|
renderToolbarActions?: (context: CodeEditorToolbarContext) => React.ReactNode;
|
|
56
|
-
/** Callback fired when the user clicks inside a code block (folding range). Receives the innermost block. */
|
|
57
|
-
onBlockClick?: (block: CodeBlockInfo) => void;
|
|
58
|
-
/**
|
|
59
|
-
* When set, the editor searches for this text, scrolls to the match,
|
|
60
|
-
* and highlights the enclosing code block (folding range / bracket pair).
|
|
61
|
-
* For JSON, passing `"customer"` navigates to the `"customer": { ... }` block.
|
|
62
|
-
* Change the value to trigger navigation; set to `undefined` to clear.
|
|
63
|
-
*/
|
|
64
|
-
focusBlock?: string;
|
|
65
41
|
}
|
|
66
42
|
export interface ThemeContextType {
|
|
67
43
|
theme: 'light' | 'dark';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lax-wp/design-system",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -38,11 +38,6 @@
|
|
|
38
38
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\""
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@codemirror/autocomplete": "^6.20.0",
|
|
42
|
-
"@codemirror/lang-json": "^6.0.2",
|
|
43
|
-
"@codemirror/lang-python": "^6.2.1",
|
|
44
|
-
"@codemirror/language": "^6.12.2",
|
|
45
|
-
"@uiw/react-codemirror": "^4.25.5",
|
|
46
41
|
"array-move": "2.2.2",
|
|
47
42
|
"classnames": "^2.5.1",
|
|
48
43
|
"clsx": "^2.1.1",
|
|
@@ -1,89 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
};
|