jaml-ui 0.24.13 → 0.24.14

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.
@@ -10,6 +10,8 @@ import { JamlCodeEditor } from "./JamlCodeEditor.js";
10
10
  import { JimboColorOption } from "../ui/tokens.js";
11
11
  import { JimboModal } from "../ui/panel.js";
12
12
  import { jamlTextToVisualFilter, visualFilterToJamlText } from "../utils/jamlVisualFilter.js";
13
+ import { DeckSprite } from "./DeckSprite.js";
14
+ import { DECK_OPTIONS, STAKE_OPTIONS } from "../lib/data/constants.js";
13
15
  const CATEGORY_CONFIG_MAP = {
14
16
  voucher: VOUCHER_PICKER_CONFIG,
15
17
  tag: TAG_PICKER_CONFIG,
@@ -89,6 +91,38 @@ function ResultsView({ results, jaml }) {
89
91
  })] })] })) : null] }, result.seed));
90
92
  }) }));
91
93
  }
94
+ function readRootValue(jaml, key, fallback) {
95
+ const match = jaml.match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
96
+ return match?.[1]?.trim() || fallback;
97
+ }
98
+ function setRootValue(jaml, key, value) {
99
+ const line = `${key}: ${value}`;
100
+ const pattern = new RegExp(`^${key}:\\s*.*$`, "m");
101
+ if (pattern.test(jaml)) {
102
+ return jaml.replace(pattern, line);
103
+ }
104
+ const trimmed = jaml.trimEnd();
105
+ return trimmed.length > 0 ? `${line}\n${trimmed}` : line;
106
+ }
107
+ function DeckStakeSelector({ jaml, onChange, }) {
108
+ const deck = readRootValue(jaml, "deck", "Red");
109
+ const stake = readRootValue(jaml, "stake", "White");
110
+ const setDeck = (nextDeck) => onChange(setRootValue(jaml, "deck", nextDeck));
111
+ const setStake = (nextStake) => onChange(setRootValue(jaml, "stake", nextStake));
112
+ return (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }, children: [_jsx(DeckSprite, { deck: deck, stake: stake, size: compactDeckSpriteSize }), _jsx("select", { value: deck, onChange: (event) => setDeck(event.currentTarget.value), style: selectorStyle, children: DECK_OPTIONS.map((option) => (_jsx("option", { value: option, children: option }, option))) }), _jsx("select", { value: stake, onChange: (event) => setStake(event.currentTarget.value), style: selectorStyle, children: STAKE_OPTIONS.map((option) => (_jsx("option", { value: option, children: option }, option))) })] }));
113
+ }
114
+ const compactDeckSpriteSize = 24;
115
+ const selectorStyle = {
116
+ minWidth: 0,
117
+ height: 28,
118
+ borderRadius: 8,
119
+ border: `1px solid ${JimboColorOption.PANEL_EDGE}`,
120
+ background: JimboColorOption.DARKEST,
121
+ color: JimboColorOption.WHITE,
122
+ fontFamily: "m6x11plus, monospace",
123
+ fontSize: 12,
124
+ padding: "0 8px",
125
+ };
92
126
  export function JamlIde({ jaml, defaultJaml, onChange, defaultMode = "code", searchResults = [], className = "", style, title = "JAML IDE", subtitle = "Jimbo's Ante Markup Language", compactHeader = false, actions, codePlaceholder = "Enter JAML...", onSearch, isSearching = false, hideFooter = false, visualFilter, onVisualFilterChange, }) {
93
127
  const [mode, setMode] = useState(defaultMode);
94
128
  const [internalText, setInternalText] = useState(jaml ?? defaultJaml ?? "");
@@ -189,5 +223,5 @@ export function JamlIde({ jaml, defaultJaml, onChange, defaultMode = "code", sea
189
223
  padding: compactHeader ? "8px 10px" : "10px 14px",
190
224
  borderBottom: `1px solid ${JimboColorOption.PANEL_EDGE}`,
191
225
  background: JimboColorOption.TEAL_GREY,
192
- }, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 16, fontWeight: "normal", fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), subtitle ? _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: subtitle }) : null] }), 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: mode === "map" ? "hidden" : "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" ? (_jsx(JamlIdeVisual, { filter: activeFilter, onChange: handleVisualFilterChange, onAddClause: handleAddClause })) : null, mode === "code" ? (_jsx(JamlCodeEditor, { value: text, onChange: handleTextChange, placeholder: codePlaceholder })) : null, mode === "map" ? _jsx(JamlMapEditor, { onChange: handleTextChange }) : null, mode === "results" ? (_jsx("div", { style: { padding: 12 }, children: _jsx(ResultsView, { results: results, jaml: text }) })) : null] }), !hideFooter && _jsx(JimboBalatroFooter, {}), _jsx(JimboModal, { open: addZone !== null, onClose: handlePickerClose, children: addZone !== null && (pickerFlow === "category" ? (_jsx(CategoryMenu, { onSelect: (cat) => setPickerFlow(cat) })) : pickerFlow === "joker" ? (_jsx(JokerPicker, { onSelect: handlePickerSelect, onCancel: handlePickerClose })) : (_jsx(CategoryPicker, { config: CATEGORY_CONFIG_MAP[pickerFlow], onSelect: handlePickerSelect, onCancel: handlePickerClose }))) })] }));
226
+ }, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 16, fontWeight: "normal", fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), subtitle ? _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: subtitle }) : null] }), _jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", justifyContent: "flex-end" }, children: [_jsx(DeckStakeSelector, { jaml: text, onChange: handleTextChange }), actions] })] }), _jsx(JamlIdeToolbar, { mode: mode, onModeChange: setMode, resultCount: results.length, onSearch: onSearch, isSearching: isSearching }), _jsxs("div", { style: { flex: 1, minHeight: 0, overflow: mode === "map" ? "hidden" : "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" ? (_jsx(JamlIdeVisual, { filter: activeFilter, onChange: handleVisualFilterChange, onAddClause: handleAddClause })) : null, mode === "code" ? (_jsx(JamlCodeEditor, { value: text, onChange: handleTextChange, placeholder: codePlaceholder })) : null, mode === "map" ? _jsx(JamlMapEditor, { onChange: handleTextChange }) : null, mode === "results" ? (_jsx("div", { style: { padding: 12 }, children: _jsx(ResultsView, { results: results, jaml: text }) })) : null] }), !hideFooter && _jsx(JimboBalatroFooter, {}), _jsx(JimboModal, { open: addZone !== null, onClose: handlePickerClose, children: addZone !== null && (pickerFlow === "category" ? (_jsx(CategoryMenu, { onSelect: (cat) => setPickerFlow(cat) })) : pickerFlow === "joker" ? (_jsx(JokerPicker, { onSelect: handlePickerSelect, onCancel: handlePickerClose })) : (_jsx(CategoryPicker, { config: CATEGORY_CONFIG_MAP[pickerFlow], onSelect: handlePickerSelect, onCancel: handlePickerClose }))) })] }));
193
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaml-ui",
3
- "version": "0.24.13",
3
+ "version": "0.24.14",
4
4
  "description": "Balatro rendering components, sprite metadata, and optional Motely helpers for React apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",