jaml-ui 0.7.1 → 0.7.2
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.
|
@@ -8,8 +8,12 @@ export interface JamlIdeSearchResult {
|
|
|
8
8
|
tallyLabels?: string[];
|
|
9
9
|
}
|
|
10
10
|
export interface JamlIdeProps {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/** Controlled value. When provided alongside `onChange`, the editor is fully controlled. */
|
|
12
|
+
jaml?: string;
|
|
13
|
+
/** Initial value for uncontrolled mode. Ignored when `jaml` is provided on first render. */
|
|
14
|
+
defaultJaml?: string;
|
|
15
|
+
/** Subscriber for every edit. Optional — the editor still works without it. */
|
|
16
|
+
onChange?: (jaml: string) => void;
|
|
13
17
|
defaultMode?: JamlIdeMode;
|
|
14
18
|
searchResults?: JamlIdeSearchResult[];
|
|
15
19
|
className?: string;
|
|
@@ -23,4 +27,4 @@ export interface JamlIdeProps {
|
|
|
23
27
|
}
|
|
24
28
|
export type { JamlVisualFilter } from "./JamlIdeVisual.js";
|
|
25
29
|
export type { JamlVisualClause, JamlZone } from "./JamlIdeVisual.js";
|
|
26
|
-
export declare function JamlIde({ jaml, onChange, defaultMode, searchResults, className, title, actions, codePlaceholder, onSearch, isSearching, visualFilter, onVisualFilterChange, }: JamlIdeProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function JamlIde({ jaml, defaultJaml, onChange, defaultMode, searchResults, className, title, actions, codePlaceholder, onSearch, isSearching, visualFilter, onVisualFilterChange, }: JamlIdeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -89,8 +89,20 @@ function ResultsView({ results }) {
|
|
|
89
89
|
}) })) : null] }, result.seed));
|
|
90
90
|
}) }));
|
|
91
91
|
}
|
|
92
|
-
export function JamlIde({ jaml, onChange, defaultMode = "code", searchResults = [], className = "", title = "JAML IDE", actions, codePlaceholder = "Enter JAML...", onSearch, isSearching = false, visualFilter, onVisualFilterChange, }) {
|
|
92
|
+
export function JamlIde({ jaml, defaultJaml, onChange, defaultMode = "code", searchResults = [], className = "", title = "JAML IDE", actions, codePlaceholder = "Enter JAML...", onSearch, isSearching = false, visualFilter, onVisualFilterChange, }) {
|
|
93
93
|
const [mode, setMode] = useState(defaultMode);
|
|
94
|
+
const [internalText, setInternalText] = useState(jaml ?? defaultJaml ?? "");
|
|
95
|
+
const [lastJamlProp, setLastJamlProp] = useState(jaml);
|
|
96
|
+
if (jaml !== lastJamlProp) {
|
|
97
|
+
setLastJamlProp(jaml);
|
|
98
|
+
if (jaml !== undefined)
|
|
99
|
+
setInternalText(jaml);
|
|
100
|
+
}
|
|
101
|
+
const text = internalText;
|
|
102
|
+
const handleTextChange = (next) => {
|
|
103
|
+
setInternalText(next);
|
|
104
|
+
onChange?.(next);
|
|
105
|
+
};
|
|
94
106
|
const results = useMemo(() => searchResults, [searchResults]);
|
|
95
107
|
return (_jsxs("div", { className: className, style: {
|
|
96
108
|
display: "flex",
|
|
@@ -110,7 +122,7 @@ export function JamlIde({ jaml, onChange, defaultMode = "code", searchResults =
|
|
|
110
122
|
padding: "10px 14px",
|
|
111
123
|
borderBottom: `1px solid ${JimboColorOption.PANEL_EDGE}`,
|
|
112
124
|
background: JimboColorOption.TEAL_GREY,
|
|
113
|
-
}, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 14, fontWeight: 800, fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: "Jimbo's Ante Markup Language" })] }), actions ? _jsx("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: actions }) : null] }), _jsx(JamlIdeToolbar, { mode: mode, onModeChange: setMode, resultCount: results.length, onSearch: onSearch, isSearching: isSearching }), _jsxs("div", { style: { flex: 1, minHeight: 0, overflow: "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" && visualFilter && onVisualFilterChange ? (_jsx(JamlIdeVisual, { filter: visualFilter, onChange: onVisualFilterChange })) : mode === "visual" ? (_jsxs("div", { style: { padding: 16, color: JimboColorOption.GREY, fontSize: 12, textAlign: "center" }, children: ["Pass ", _jsx("code", { children: "visualFilter" }), " and ", _jsx("code", { children: "onVisualFilterChange" }), " props to enable the visual editor."] })) : null, mode === "code" ? (_jsx("textarea", { title: "JAML IDE Editor", value:
|
|
125
|
+
}, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 14, fontWeight: 800, fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: "Jimbo's Ante Markup Language" })] }), actions ? _jsx("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: actions }) : null] }), _jsx(JamlIdeToolbar, { mode: mode, onModeChange: setMode, resultCount: results.length, onSearch: onSearch, isSearching: isSearching }), _jsxs("div", { style: { flex: 1, minHeight: 0, overflow: "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" && visualFilter && onVisualFilterChange ? (_jsx(JamlIdeVisual, { filter: visualFilter, onChange: onVisualFilterChange })) : mode === "visual" ? (_jsxs("div", { style: { padding: 16, color: JimboColorOption.GREY, fontSize: 12, textAlign: "center" }, children: ["Pass ", _jsx("code", { children: "visualFilter" }), " and ", _jsx("code", { children: "onVisualFilterChange" }), " props to enable the visual editor."] })) : null, mode === "code" ? (_jsx("textarea", { title: "JAML IDE Editor", value: text, onChange: (event) => handleTextChange(event.target.value), placeholder: codePlaceholder, spellCheck: false, autoCapitalize: "off", autoCorrect: "off", style: {
|
|
114
126
|
width: "100%",
|
|
115
127
|
minHeight: 320,
|
|
116
128
|
resize: "vertical",
|
|
@@ -122,5 +134,5 @@ export function JamlIde({ jaml, onChange, defaultMode = "code", searchResults =
|
|
|
122
134
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
123
135
|
fontSize: 13,
|
|
124
136
|
lineHeight: 1.7,
|
|
125
|
-
} })) : null, mode === "map" ? _jsx(JamlMapPreview, { jaml:
|
|
137
|
+
} })) : null, mode === "map" ? _jsx(JamlMapPreview, { jaml: text }) : null, mode === "results" ? (_jsx("div", { style: { padding: 12 }, children: _jsx(ResultsView, { results: results }) })) : null] })] }));
|
|
126
138
|
}
|