@lcars-gui/romulus 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aarondnas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @lcars-gui/romulus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ UI-Komponenten im Stil des Romulanischen Sternenimperiums: leuchtende Linien auf dunklem Grund,
4
+ abgeschrägte Ecken, Krallen-Ecken an Panels, Rauten statt Kreisen.
5
+
6
+ **[Live-Demo](https://aarondnas.github.io/lcars-gui/romulus.html)**
7
+
8
+ ![Romulus](https://raw.githubusercontent.com/aarondnas/lcars-gui/main/docs/romulus.gif)
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ npm install @lcars-gui/romulus
14
+ ```
15
+
16
+ ## Verwendung
17
+
18
+ ```ts
19
+ // React
20
+ import "@lcars-gui/romulus/ui.css";
21
+ import { Panel, Button, RomulusRoot, SoundProvider } from "@lcars-gui/romulus/react";
22
+
23
+ <SoundProvider>
24
+ <RomulusRoot theme="warbird">
25
+ <Panel code="R-7734" title="Taktisch" sidebar={<Button>Tarnung</Button>}>
26
+ …
27
+ </Panel>
28
+ </RomulusRoot>
29
+ </SoundProvider>
30
+ ```
31
+
32
+ ```html
33
+ <!-- Reines HTML/JS -->
34
+ <link rel="stylesheet" href="https://unpkg.com/@lcars-gui/romulus/dist/ui.css">
35
+ <script src="https://unpkg.com/@lcars-gui/romulus/dist/index.global.js"></script>
36
+ <script>const ui = LcarsRomulus.initRomulus({ sound: true });</script>
37
+ ```
38
+
39
+ ## Themes
40
+
41
+ | Theme | Stil | Extras (`themes/<name>.css`) |
42
+ |--------------|-----------------------------------------|-------------------------------|
43
+ | `warbird` | TNG, D'deridex-Klasse (Standard) | Scanlines auf Panels |
44
+ | `tal-shiar` | kühler, blaugrün | flackernde Titel und Kennungen |
45
+ | `free-state` | Picard-Ära, mit Goldakzent | Leuchten auf Schrift/Kontakten |
46
+
47
+ ## Schrift
48
+
49
+ Es wird keine Schrift mitgeliefert. Gut passt [Michroma](https://fonts.google.com/specimen/Michroma)
50
+ (Google Fonts, frei); ohne sie greifen Eurostile, Bahnschrift oder Arial Narrow.
51
+
52
+ ## CSS-Variablen
53
+
54
+ Alle Variablen tragen das Präfix `--rom-` (z. B. `--rom-colors-color1`), damit sich Romulus
55
+ und andere Fraktionen auf einer Seite nicht in die Quere kommen.
56
+
57
+ ## Lizenz
58
+
59
+ MIT. Star Trek ist eine Marke von CBS Studios / Paramount; dies ist ein inoffizielles Fan-Projekt.
@@ -0,0 +1,151 @@
1
+ import { LcarsSoundOptions, InitBehaviorsOptions, LcarsController } from '@lcars-gui/core';
2
+ export { LcarsController, LcarsSound, LcarsSoundKind, createLcarsSound, pressedChangeEvent } from '@lcars-gui/core';
3
+
4
+ type RomulusColor = 1 | 2 | 3 | 4 | 5 | 6;
5
+ type RomulusLength = "xs" | "s" | "m" | "l" | "xl";
6
+ type RomulusTheme = "warbird" | "tal-shiar" | "free-state";
7
+ type AlertLevel = "red" | "yellow";
8
+ type StatusKind = "ok" | "warn" | "error" | "off";
9
+ type Orientation = "horizontal" | "vertical";
10
+ /** data-color nur setzen, wenn eine Farbe angegeben ist (sonst CSS-Default). */
11
+ declare function colorAttribute(color?: RomulusColor): {
12
+ "data-color": string;
13
+ } | {
14
+ "data-color"?: undefined;
15
+ };
16
+
17
+ type ButtonSize = "xs" | "s" | "m" | "l" | "xl";
18
+ type ButtonShape = "chamfer" | "rect" | "point-left" | "point-right";
19
+ type ButtonVariant = "outline" | "solid";
20
+ type ButtonAlign = "center" | "start";
21
+ /**
22
+ * Plattformneutrale Button-Props (ohne Events/Children,
23
+ * die liefert der jeweilige Renderer).
24
+ */
25
+ interface ButtonProps {
26
+ color?: RomulusColor;
27
+ size?: ButtonSize;
28
+ length?: RomulusLength;
29
+ shape?: ButtonShape;
30
+ variant?: ButtonVariant;
31
+ align?: ButtonAlign;
32
+ disabled?: boolean;
33
+ }
34
+ /** CSS-Klasse aus ui.css */
35
+ declare const buttonClassName = "rom-btn";
36
+ /**
37
+ * Liefert die data-Attribute, auf die das CSS reagiert.
38
+ */
39
+ declare function buttonDataAttributes({ color, size, length, shape, variant, align }: ButtonProps): {
40
+ "data-align"?: "start" | undefined;
41
+ "data-variant"?: "solid" | undefined;
42
+ "data-shape"?: "rect" | "point-left" | "point-right" | undefined;
43
+ "data-length"?: RomulusLength | undefined;
44
+ "data-size": ButtonSize;
45
+ "data-color": string;
46
+ } | {
47
+ "data-align"?: "start" | undefined;
48
+ "data-variant"?: "solid" | undefined;
49
+ "data-shape"?: "rect" | "point-left" | "point-right" | undefined;
50
+ "data-length"?: RomulusLength | undefined;
51
+ "data-size": ButtonSize;
52
+ "data-color"?: undefined;
53
+ };
54
+
55
+ type BarCap = "left" | "right" | "both";
56
+ interface BarProps {
57
+ color?: RomulusColor;
58
+ cap?: BarCap;
59
+ length?: RomulusLength;
60
+ segmented?: boolean;
61
+ }
62
+ interface BlockProps {
63
+ color?: RomulusColor;
64
+ fill?: boolean;
65
+ }
66
+ /** CSS-Klassen aus ui.css */
67
+ declare const panelClassNames: {
68
+ readonly panel: "rom-panel";
69
+ readonly header: "rom-panel-header";
70
+ readonly code: "rom-panel-code";
71
+ readonly sidebar: "rom-panel-sidebar";
72
+ readonly content: "rom-panel-content";
73
+ readonly footer: "rom-panel-footer";
74
+ readonly bar: "rom-bar";
75
+ readonly block: "rom-block";
76
+ readonly title: "rom-title";
77
+ readonly stack: "rom-stack";
78
+ };
79
+ declare function barDataAttributes({ color, cap, length, segmented }: BarProps): {
80
+ "data-segmented"?: string | undefined;
81
+ "data-length"?: RomulusLength | undefined;
82
+ "data-cap"?: BarCap | undefined;
83
+ "data-color": string;
84
+ } | {
85
+ "data-segmented"?: string | undefined;
86
+ "data-length"?: RomulusLength | undefined;
87
+ "data-cap"?: BarCap | undefined;
88
+ "data-color"?: undefined;
89
+ };
90
+ declare function blockDataAttributes({ color, fill }: BlockProps): {
91
+ "data-fill"?: string | undefined;
92
+ "data-color": string;
93
+ } | {
94
+ "data-fill"?: string | undefined;
95
+ "data-color"?: undefined;
96
+ };
97
+
98
+ /** CSS-Klassen aus ui.css */
99
+ declare const displayClassNames: {
100
+ readonly cascade: "rom-cascade";
101
+ readonly cascadeCol: "rom-cascade-col";
102
+ readonly readout: "rom-readout";
103
+ readonly number: "rom-number";
104
+ readonly divider: "rom-divider";
105
+ readonly grid: "rom-grid";
106
+ readonly level: "rom-level";
107
+ readonly gauge: "rom-gauge";
108
+ readonly sensor: "rom-sensor";
109
+ readonly blip: "rom-blip";
110
+ readonly scan: "rom-scan";
111
+ readonly status: "rom-status";
112
+ readonly alert: "rom-alert";
113
+ readonly alertTitle: "rom-alert-title";
114
+ readonly alertText: "rom-alert-text";
115
+ };
116
+ declare const controlClassNames: {
117
+ readonly tabs: "rom-tabs";
118
+ readonly tablist: "rom-tablist";
119
+ readonly tab: "rom-tab";
120
+ readonly tabpanel: "rom-tabpanel";
121
+ readonly field: "rom-field";
122
+ readonly fieldLabel: "rom-field-label";
123
+ readonly input: "rom-input";
124
+ readonly range: "rom-range";
125
+ readonly keypad: "rom-keypad";
126
+ readonly keypadDisplay: "rom-keypad-display";
127
+ };
128
+ /**
129
+ * Spalten aus Hex-Gruppen wie „3F·A9“, zufällig aber reproduzierbar
130
+ * (gleicher Seed → gleiche Werte, wichtig für Server-Rendering).
131
+ */
132
+ declare function cascadeGlyphs(columns: number, rows: number, seed?: number): string[][];
133
+ /** Welche Segmente einer Pegelanzeige leuchten. */
134
+ declare function levelSegments(value: number, segments?: number, max?: number): boolean[];
135
+ /** Wert auf 0–100 % umrechnen (für die Gauge). */
136
+ declare function toPercent(value: number, max?: number): number;
137
+
138
+ /** Romulanische Bedien-Töne: tiefer, dreieckige Welle, absteigende Folgen. */
139
+ declare const romulanSound: LcarsSoundOptions;
140
+
141
+ type InitRomulusOptions = InitBehaviorsOptions;
142
+ /**
143
+ * Macht statisches romulanisches Markup interaktiv.
144
+ * Der zurückgegebene Controller spielt Töne und entfernt die Listener wieder.
145
+ */
146
+ declare function initRomulus(options?: InitRomulusOptions): LcarsController;
147
+ /** Füllt leere Data Cascades (data-columns / data-rows / data-seed) mit Hex-Gruppen. */
148
+ declare function fillCascades(root?: Document | HTMLElement): void;
149
+
150
+ export { barDataAttributes, blockDataAttributes, buttonClassName, buttonDataAttributes, cascadeGlyphs, colorAttribute, controlClassNames, displayClassNames, fillCascades, initRomulus, levelSegments, panelClassNames, romulanSound, toPercent };
151
+ export type { AlertLevel, BarCap, BarProps, BlockProps, ButtonAlign, ButtonProps, ButtonShape, ButtonSize, ButtonVariant, InitRomulusOptions, Orientation, RomulusColor, RomulusLength, RomulusTheme, StatusKind };
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ var LcarsRomulus = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ barDataAttributes: () => barDataAttributes,
25
+ blockDataAttributes: () => blockDataAttributes,
26
+ buttonClassName: () => buttonClassName,
27
+ buttonDataAttributes: () => buttonDataAttributes,
28
+ cascadeGlyphs: () => cascadeGlyphs,
29
+ colorAttribute: () => colorAttribute,
30
+ controlClassNames: () => controlClassNames,
31
+ createLcarsSound: () => createLcarsSound,
32
+ displayClassNames: () => displayClassNames,
33
+ fillCascades: () => fillCascades,
34
+ initRomulus: () => initRomulus,
35
+ levelSegments: () => levelSegments,
36
+ panelClassNames: () => panelClassNames,
37
+ pressedChangeEvent: () => pressedChangeEvent,
38
+ romulanSound: () => romulanSound,
39
+ toPercent: () => toPercent
40
+ });
41
+
42
+ // src/shared.ts
43
+ function colorAttribute(color) {
44
+ return color ? { "data-color": String(color) } : {};
45
+ }
46
+
47
+ // src/button.ts
48
+ var buttonClassName = "rom-btn";
49
+ function buttonDataAttributes({ color, size = "m", length, shape = "chamfer", variant = "outline", align = "center" }) {
50
+ return {
51
+ ...colorAttribute(color),
52
+ "data-size": size,
53
+ ...length && { "data-length": length },
54
+ ...shape !== "chamfer" && { "data-shape": shape },
55
+ ...variant !== "outline" && { "data-variant": variant },
56
+ ...align !== "center" && { "data-align": align }
57
+ };
58
+ }
59
+
60
+ // src/panel.ts
61
+ var panelClassNames = {
62
+ panel: "rom-panel",
63
+ header: "rom-panel-header",
64
+ code: "rom-panel-code",
65
+ sidebar: "rom-panel-sidebar",
66
+ content: "rom-panel-content",
67
+ footer: "rom-panel-footer",
68
+ bar: "rom-bar",
69
+ block: "rom-block",
70
+ title: "rom-title",
71
+ stack: "rom-stack"
72
+ };
73
+ function barDataAttributes({ color, cap, length, segmented }) {
74
+ return {
75
+ ...colorAttribute(color),
76
+ ...cap && { "data-cap": cap },
77
+ ...length && { "data-length": length },
78
+ ...segmented && { "data-segmented": "" }
79
+ };
80
+ }
81
+ function blockDataAttributes({ color, fill }) {
82
+ return {
83
+ ...colorAttribute(color),
84
+ ...fill && { "data-fill": "" }
85
+ };
86
+ }
87
+
88
+ // ../core/dist/index.js
89
+ var defaultPatterns = {
90
+ beep: [[1320, 70]],
91
+ confirm: [[880, 70], [1320, 110]],
92
+ deny: [[440, 110], [330, 180]],
93
+ alert: [[620, 220], [880, 220], [620, 220], [880, 220]]
94
+ };
95
+ function createLcarsSound(volume = 0.12, { patterns = defaultPatterns, wave = "sine" } = {}) {
96
+ let ctx;
97
+ return {
98
+ play(kind = "beep") {
99
+ if (typeof AudioContext === "undefined") return;
100
+ ctx ?? (ctx = new AudioContext());
101
+ let t = ctx.currentTime;
102
+ for (const [freq, ms] of patterns[kind]) {
103
+ const osc = ctx.createOscillator();
104
+ const gain = ctx.createGain();
105
+ const end = t + ms / 1e3;
106
+ osc.type = wave;
107
+ osc.frequency.value = freq;
108
+ gain.gain.setValueAtTime(volume, t);
109
+ gain.gain.exponentialRampToValueAtTime(1e-4, end);
110
+ osc.connect(gain).connect(ctx.destination);
111
+ osc.start(t);
112
+ osc.stop(end);
113
+ t = end + 0.02;
114
+ }
115
+ }
116
+ };
117
+ }
118
+ var pressedChangeEvent = "lcar:pressedchange";
119
+ function initBehaviors(selectors, { root = document, sound = false, volume, onKeypadSubmit } = {}, soundOptions) {
120
+ const player = createLcarsSound(volume, soundOptions);
121
+ let soundOn = sound;
122
+ const play = (kind) => soundOn && player.play(kind);
123
+ const onClick = (e) => {
124
+ const target = e.target;
125
+ const control = target.closest(selectors.control);
126
+ if (control && control.dataset.sound !== "none") play(control.dataset.sound || "beep");
127
+ const toggle = target.closest("[aria-pressed]");
128
+ if (toggle) {
129
+ const pressed = toggle.getAttribute("aria-pressed") !== "true";
130
+ toggle.setAttribute("aria-pressed", String(pressed));
131
+ toggle.dispatchEvent(new CustomEvent(pressedChangeEvent, { bubbles: true, detail: { pressed } }));
132
+ }
133
+ const tab = target.closest('[role="tab"]');
134
+ if (tab) selectTab(tab);
135
+ const key = target.closest(`${selectors.keypad} ${selectors.keypadKey}`);
136
+ if (key) pressKey(key.closest(selectors.keypad), key.textContent.trim());
137
+ };
138
+ const onKeyDown = (e) => {
139
+ const { key, target } = e;
140
+ const step = key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0;
141
+ const tab = target.closest('[role="tab"]');
142
+ if (!step || !tab) return;
143
+ const list = tabsOf(tab);
144
+ const next = list[(list.indexOf(tab) + step + list.length) % list.length];
145
+ selectTab(next);
146
+ play("beep");
147
+ next.focus();
148
+ };
149
+ const codes = /* @__PURE__ */ new WeakMap();
150
+ const pressKey = (pad, key) => {
151
+ const display = pad.querySelector(selectors.keypadDisplay);
152
+ const length = Number(pad.dataset.length) || 6;
153
+ let code = codes.get(pad) ?? "";
154
+ const show = (text, state) => {
155
+ if (!display) return;
156
+ display.textContent = text || "\u2013".repeat(length);
157
+ if (state) display.dataset.state = state;
158
+ else delete display.dataset.state;
159
+ };
160
+ if (key === "ENT") {
161
+ const accepted = onKeypadSubmit ? onKeypadSubmit(code, pad) : code === pad.dataset.code;
162
+ codes.set(pad, "");
163
+ if (accepted === void 0) return play("confirm");
164
+ play(accepted ? "confirm" : "deny");
165
+ return show(accepted ? "OK" : "Denied", accepted ? "ok" : "error");
166
+ }
167
+ if (key === "CLR") code = "";
168
+ else if (code.length < length) code += key;
169
+ codes.set(pad, code);
170
+ show(pad.dataset.mask === void 0 ? code : "\u2022".repeat(code.length));
171
+ };
172
+ root.addEventListener("click", onClick);
173
+ root.addEventListener("keydown", onKeyDown);
174
+ return {
175
+ play: (kind) => player.play(kind),
176
+ setSound: (enabled) => soundOn = enabled,
177
+ destroy() {
178
+ root.removeEventListener("click", onClick);
179
+ root.removeEventListener("keydown", onKeyDown);
180
+ }
181
+ };
182
+ }
183
+ function tabsOf(tab) {
184
+ return [...tab.closest('[role="tablist"]')?.querySelectorAll('[role="tab"]') ?? []];
185
+ }
186
+ function selectTab(tab) {
187
+ for (const t of tabsOf(tab)) {
188
+ const on = t === tab;
189
+ t.setAttribute("aria-selected", String(on));
190
+ t.tabIndex = on ? 0 : -1;
191
+ const panel = document.getElementById(t.getAttribute("aria-controls") ?? "");
192
+ if (panel) panel.hidden = !on;
193
+ }
194
+ }
195
+ function seededRandom(seed = 47) {
196
+ let state = seed >>> 0;
197
+ return () => {
198
+ state = state + 1831565813 >>> 0;
199
+ let t = state;
200
+ t = Math.imul(t ^ t >>> 15, t | 1);
201
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
202
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
203
+ };
204
+ }
205
+
206
+ // src/display.ts
207
+ var displayClassNames = {
208
+ cascade: "rom-cascade",
209
+ cascadeCol: "rom-cascade-col",
210
+ readout: "rom-readout",
211
+ number: "rom-number",
212
+ divider: "rom-divider",
213
+ grid: "rom-grid",
214
+ level: "rom-level",
215
+ gauge: "rom-gauge",
216
+ sensor: "rom-sensor",
217
+ blip: "rom-blip",
218
+ scan: "rom-scan",
219
+ status: "rom-status",
220
+ alert: "rom-alert",
221
+ alertTitle: "rom-alert-title",
222
+ alertText: "rom-alert-text"
223
+ };
224
+ var controlClassNames = {
225
+ tabs: "rom-tabs",
226
+ tablist: "rom-tablist",
227
+ tab: "rom-tab",
228
+ tabpanel: "rom-tabpanel",
229
+ field: "rom-field",
230
+ fieldLabel: "rom-field-label",
231
+ input: "rom-input",
232
+ range: "rom-range",
233
+ keypad: "rom-keypad",
234
+ keypadDisplay: "rom-keypad-display"
235
+ };
236
+ function cascadeGlyphs(columns, rows, seed = 1701) {
237
+ const random = seededRandom(seed);
238
+ const hex = () => Math.floor(random() * 256).toString(16).toUpperCase().padStart(2, "0");
239
+ return Array.from({ length: columns }, (_, col) => {
240
+ const groups = 1 + col % 3;
241
+ return Array.from({ length: rows }, () => Array.from({ length: groups }, hex).join("\xB7"));
242
+ });
243
+ }
244
+ function levelSegments(value, segments = 12, max = 100) {
245
+ const lit = Math.round(Math.min(Math.max(value, 0), max) / max * segments);
246
+ return Array.from({ length: segments }, (_, i) => i < lit);
247
+ }
248
+ function toPercent(value, max = 100) {
249
+ return Math.min(Math.max(value / max * 100, 0), 100);
250
+ }
251
+
252
+ // src/sound.ts
253
+ var romulanSound = {
254
+ wave: "triangle",
255
+ patterns: {
256
+ beep: [[523, 55]],
257
+ confirm: [[392, 60], [523, 60], [784, 100]],
258
+ deny: [[311, 140], [233, 220]],
259
+ alert: [[466, 180], [349, 180], [466, 180], [349, 180]]
260
+ }
261
+ };
262
+
263
+ // src/behaviors.ts
264
+ function initRomulus(options = {}) {
265
+ fillCascades(options.root);
266
+ return initBehaviors(
267
+ {
268
+ control: `.${buttonClassName}, .${controlClassNames.tab}`,
269
+ keypad: `.${controlClassNames.keypad}`,
270
+ keypadKey: `.${buttonClassName}`,
271
+ keypadDisplay: `.${controlClassNames.keypadDisplay}`
272
+ },
273
+ options,
274
+ romulanSound
275
+ );
276
+ }
277
+ function fillCascades(root = document) {
278
+ root.querySelectorAll(`.${displayClassNames.cascade}[data-columns]`).forEach((el, k) => {
279
+ const { columns, rows = "6", seed } = el.dataset;
280
+ const data = cascadeGlyphs(Number(columns), Number(rows), seed ? Number(seed) : 1701 + k);
281
+ el.innerHTML = data.map((col, c) => `<div class="${displayClassNames.cascadeCol}">${col.map((g, r) => `<span style="--i:${r * 3 + c}">${g}</span>`).join("")}</div>`).join("");
282
+ });
283
+ }
284
+ return __toCommonJS(src_exports);
285
+ })();
package/dist/index.js ADDED
@@ -0,0 +1,148 @@
1
+ // src/shared.ts
2
+ function colorAttribute(color) {
3
+ return color ? { "data-color": String(color) } : {};
4
+ }
5
+
6
+ // src/button.ts
7
+ var buttonClassName = "rom-btn";
8
+ function buttonDataAttributes({ color, size = "m", length, shape = "chamfer", variant = "outline", align = "center" }) {
9
+ return {
10
+ ...colorAttribute(color),
11
+ "data-size": size,
12
+ ...length && { "data-length": length },
13
+ ...shape !== "chamfer" && { "data-shape": shape },
14
+ ...variant !== "outline" && { "data-variant": variant },
15
+ ...align !== "center" && { "data-align": align }
16
+ };
17
+ }
18
+
19
+ // src/panel.ts
20
+ var panelClassNames = {
21
+ panel: "rom-panel",
22
+ header: "rom-panel-header",
23
+ code: "rom-panel-code",
24
+ sidebar: "rom-panel-sidebar",
25
+ content: "rom-panel-content",
26
+ footer: "rom-panel-footer",
27
+ bar: "rom-bar",
28
+ block: "rom-block",
29
+ title: "rom-title",
30
+ stack: "rom-stack"
31
+ };
32
+ function barDataAttributes({ color, cap, length, segmented }) {
33
+ return {
34
+ ...colorAttribute(color),
35
+ ...cap && { "data-cap": cap },
36
+ ...length && { "data-length": length },
37
+ ...segmented && { "data-segmented": "" }
38
+ };
39
+ }
40
+ function blockDataAttributes({ color, fill }) {
41
+ return {
42
+ ...colorAttribute(color),
43
+ ...fill && { "data-fill": "" }
44
+ };
45
+ }
46
+
47
+ // src/display.ts
48
+ import { seededRandom } from "@lcars-gui/core";
49
+ var displayClassNames = {
50
+ cascade: "rom-cascade",
51
+ cascadeCol: "rom-cascade-col",
52
+ readout: "rom-readout",
53
+ number: "rom-number",
54
+ divider: "rom-divider",
55
+ grid: "rom-grid",
56
+ level: "rom-level",
57
+ gauge: "rom-gauge",
58
+ sensor: "rom-sensor",
59
+ blip: "rom-blip",
60
+ scan: "rom-scan",
61
+ status: "rom-status",
62
+ alert: "rom-alert",
63
+ alertTitle: "rom-alert-title",
64
+ alertText: "rom-alert-text"
65
+ };
66
+ var controlClassNames = {
67
+ tabs: "rom-tabs",
68
+ tablist: "rom-tablist",
69
+ tab: "rom-tab",
70
+ tabpanel: "rom-tabpanel",
71
+ field: "rom-field",
72
+ fieldLabel: "rom-field-label",
73
+ input: "rom-input",
74
+ range: "rom-range",
75
+ keypad: "rom-keypad",
76
+ keypadDisplay: "rom-keypad-display"
77
+ };
78
+ function cascadeGlyphs(columns, rows, seed = 1701) {
79
+ const random = seededRandom(seed);
80
+ const hex = () => Math.floor(random() * 256).toString(16).toUpperCase().padStart(2, "0");
81
+ return Array.from({ length: columns }, (_, col) => {
82
+ const groups = 1 + col % 3;
83
+ return Array.from({ length: rows }, () => Array.from({ length: groups }, hex).join("\xB7"));
84
+ });
85
+ }
86
+ function levelSegments(value, segments = 12, max = 100) {
87
+ const lit = Math.round(Math.min(Math.max(value, 0), max) / max * segments);
88
+ return Array.from({ length: segments }, (_, i) => i < lit);
89
+ }
90
+ function toPercent(value, max = 100) {
91
+ return Math.min(Math.max(value / max * 100, 0), 100);
92
+ }
93
+
94
+ // src/sound.ts
95
+ var romulanSound = {
96
+ wave: "triangle",
97
+ patterns: {
98
+ beep: [[523, 55]],
99
+ confirm: [[392, 60], [523, 60], [784, 100]],
100
+ deny: [[311, 140], [233, 220]],
101
+ alert: [[466, 180], [349, 180], [466, 180], [349, 180]]
102
+ }
103
+ };
104
+
105
+ // src/behaviors.ts
106
+ import { initBehaviors } from "@lcars-gui/core";
107
+ import { pressedChangeEvent } from "@lcars-gui/core";
108
+ function initRomulus(options = {}) {
109
+ fillCascades(options.root);
110
+ return initBehaviors(
111
+ {
112
+ control: `.${buttonClassName}, .${controlClassNames.tab}`,
113
+ keypad: `.${controlClassNames.keypad}`,
114
+ keypadKey: `.${buttonClassName}`,
115
+ keypadDisplay: `.${controlClassNames.keypadDisplay}`
116
+ },
117
+ options,
118
+ romulanSound
119
+ );
120
+ }
121
+ function fillCascades(root = document) {
122
+ root.querySelectorAll(`.${displayClassNames.cascade}[data-columns]`).forEach((el, k) => {
123
+ const { columns, rows = "6", seed } = el.dataset;
124
+ const data = cascadeGlyphs(Number(columns), Number(rows), seed ? Number(seed) : 1701 + k);
125
+ el.innerHTML = data.map((col, c) => `<div class="${displayClassNames.cascadeCol}">${col.map((g, r) => `<span style="--i:${r * 3 + c}">${g}</span>`).join("")}</div>`).join("");
126
+ });
127
+ }
128
+
129
+ // src/index.ts
130
+ import { createLcarsSound } from "@lcars-gui/core";
131
+ export {
132
+ barDataAttributes,
133
+ blockDataAttributes,
134
+ buttonClassName,
135
+ buttonDataAttributes,
136
+ cascadeGlyphs,
137
+ colorAttribute,
138
+ controlClassNames,
139
+ createLcarsSound,
140
+ displayClassNames,
141
+ fillCascades,
142
+ initRomulus,
143
+ levelSegments,
144
+ panelClassNames,
145
+ pressedChangeEvent,
146
+ romulanSound,
147
+ toPercent
148
+ };